textmode.js 0.3.2-beta.2 → 0.3.2-beta.3

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.
@@ -28,14 +28,14 @@ ${"↓".repeat(24)}
28
28
  }
29
29
  }
30
30
  var ct = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(ct || {});
31
- const _ = class _ {
31
+ const D = class D {
32
32
  constructor() {
33
33
  h(this, "u", { globalLevel: 3 });
34
34
  }
35
35
  static _() {
36
- return _.l || (_.l = new _()), _.l;
36
+ return D.l || (D.l = new D()), D.l;
37
37
  }
38
- v(t, e) {
38
+ m(t, e) {
39
39
  const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
40
40
  switch (this.u.globalLevel) {
41
41
  case 0:
@@ -48,20 +48,20 @@ const _ = class _ {
48
48
  throw new C(t, e);
49
49
  }
50
50
  }
51
- m(t, e, i) {
52
- return !!t || (this.v(e, i), !1);
51
+ v(t, e, i) {
52
+ return !!t || (this.m(e, i), !1);
53
53
  }
54
54
  A(t) {
55
55
  this.u.globalLevel = t;
56
56
  }
57
57
  };
58
- h(_, "l", null);
59
- let q = _;
60
- const N = q._(), et = /* @__PURE__ */ new WeakMap();
61
- function W(a, t) {
58
+ h(D, "l", null);
59
+ let K = D;
60
+ const z = K._(), et = /* @__PURE__ */ new WeakMap();
61
+ function Y(a, t) {
62
62
  et.set(a, t);
63
63
  }
64
- function H(a) {
64
+ function W(a) {
65
65
  return et.get(a);
66
66
  }
67
67
  class it {
@@ -76,25 +76,25 @@ class it {
76
76
  h(this, "$", !1);
77
77
  h(this, "D", !1);
78
78
  h(this, "k", !1);
79
- h(this, "L", [0, 0]);
80
- h(this, "O", [0, 0, 0, 1]);
81
- h(this, "G", []);
79
+ h(this, "O", [0, 0]);
80
+ h(this, "L", [0, 0, 0, 1]);
81
+ h(this, "H", []);
82
82
  }
83
- H() {
84
- this.G.push({ I: this.C, N: this.M, X: this.U, W: this.F, L: [...this.L], K: this.$, Y: this.D, k: this.k, j: [...this.R], V: [...this.P], q: [...this.S] });
83
+ G() {
84
+ this.H.push({ I: this.C, N: this.M, X: this.U, W: this.F, O: [...this.O], K: this.$, j: this.D, k: this.k, Y: [...this.R], V: [...this.P], q: [...this.S] });
85
85
  }
86
86
  Z() {
87
- const t = this.G.pop();
88
- t ? (this.C = t.I, this.M = t.N, this.U = t.X, this.F = t.W, this.L = t.L, this.$ = t.K, this.D = t.Y, this.k = t.k, this.R = t.j, this.P = t.V, this.S = t.q) : console.warn("pop() called without matching push()");
87
+ const t = this.H.pop();
88
+ t ? (this.C = t.I, this.M = t.N, this.U = t.X, this.F = t.W, this.O = t.O, this.$ = t.K, this.D = t.j, this.k = t.k, this.R = t.Y, this.P = t.V, this.S = t.q) : console.warn("pop() called without matching push()");
89
89
  }
90
90
  J(t) {
91
- t.I = this.C, t.N = this.M, t.X = this.U, t.W = this.F, t.j[0] = this.R[0], t.j[1] = this.R[1], t.j[2] = this.R[2], t.V[0] = this.P[0], t.V[1] = this.P[1], t.V[2] = this.P[2], t.V[3] = this.P[3], t.q[0] = this.S[0], t.q[1] = this.S[1], t.q[2] = this.S[2], t.q[3] = this.S[3], t.K = this.$, t.Y = this.D, t.k = this.k, t.L[0] = this.L[0], t.L[1] = this.L[1];
91
+ t.I = this.C, t.N = this.M, t.X = this.U, t.W = this.F, t.Y[0] = this.R[0], t.Y[1] = this.R[1], t.Y[2] = this.R[2], t.V[0] = this.P[0], t.V[1] = this.P[1], t.V[2] = this.P[2], t.V[3] = this.P[3], t.q[0] = this.S[0], t.q[1] = this.S[1], t.q[2] = this.S[2], t.q[3] = this.S[3], t.K = this.$, t.j = this.D, t.k = this.k, t.O[0] = this.O[0], t.O[1] = this.O[1];
92
92
  }
93
93
  get lineWeight() {
94
94
  return this.C;
95
95
  }
96
96
  get canvasBackgroundColor() {
97
- return this.O;
97
+ return this.L;
98
98
  }
99
99
  tt(t) {
100
100
  this.C = Math.abs(t);
@@ -128,21 +128,21 @@ class it {
128
128
  }
129
129
  ut(t) {
130
130
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
131
- this.L = [i, s];
131
+ this.O = [i, s];
132
132
  }
133
133
  ft(t, e, i, s) {
134
- this.O = [t / 255, e / 255, i / 255, s / 255];
134
+ this.L = [t / 255, e / 255, i / 255, s / 255];
135
135
  }
136
136
  }
137
- class K {
137
+ class j {
138
138
  constructor(t, e, i = e, s = 1, r = {}, n = null, o = !1) {
139
139
  h(this, "dt");
140
140
  h(this, "_t");
141
141
  h(this, "u");
142
142
  h(this, "vt", null);
143
143
  h(this, "gt");
144
- h(this, "At");
145
- h(this, "yt", []);
144
+ h(this, "yt");
145
+ h(this, "At", []);
146
146
  h(this, "Ct");
147
147
  h(this, "wt", null);
148
148
  h(this, "bt", []);
@@ -151,24 +151,24 @@ class K {
151
151
  h(this, "Ft", null);
152
152
  this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.gt = t, this.Ct = Math.min(Math.max(1, s), 8), this.xt = n, this.Mt = !!o, this.Ft = this.Mt ? new it() : null;
153
153
  const c = t.getParameter(t.MAX_DRAW_BUFFERS), l = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
154
- this.Ct = Math.min(this.Ct, c, l), this.At = t.createFramebuffer(), this.zt(), this.Rt(), this.bt = Array(this.Ct).fill(null);
154
+ this.Ct = Math.min(this.Ct, c, l), this.yt = t.createFramebuffer(), this.zt(), this.Rt(), this.bt = Array(this.Ct).fill(null);
155
155
  }
156
156
  zt() {
157
157
  const t = this.gt, e = this.u.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.u.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, s = this.u.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
158
158
  for (let r = 0; r < this.Ct; r++) {
159
159
  const n = t.createTexture();
160
- t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.dt, this._t, 0, t.RGBA, s, null), this.yt.push(n);
160
+ t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.dt, this._t, 0, t.RGBA, s, null), this.At.push(n);
161
161
  }
162
162
  t.bindTexture(t.TEXTURE_2D, null);
163
163
  }
164
164
  Rt() {
165
165
  const t = this.gt;
166
- if (t.bindFramebuffer(t.FRAMEBUFFER, this.At), this.Ct === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.yt[0], 0);
166
+ if (t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.Ct === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.At[0], 0);
167
167
  else {
168
168
  const i = [];
169
169
  for (let s = 0; s < this.Ct; s++) {
170
170
  const r = t.COLOR_ATTACHMENT0 + s;
171
- t.framebufferTexture2D(t.FRAMEBUFFER, r, t.TEXTURE_2D, this.yt[s], 0), i.push(r);
171
+ t.framebufferTexture2D(t.FRAMEBUFFER, r, t.TEXTURE_2D, this.At[s], 0), i.push(r);
172
172
  }
173
173
  t.drawBuffers(i);
174
174
  }
@@ -177,19 +177,19 @@ class K {
177
177
  }
178
178
  Tt(t) {
179
179
  const e = this.gt;
180
- e.bindTexture(e.TEXTURE_2D, this.yt[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
180
+ e.bindTexture(e.TEXTURE_2D, this.At[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
181
181
  }
182
182
  resize(t, e) {
183
183
  this.dt = t, this._t = e, this.vt = null, this.bt = Array(this.Ct).fill(null);
184
184
  const i = this.gt, s = this.u.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
185
- for (const r of this.yt) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.dt, this._t, 0, i.RGBA, s, null);
185
+ for (const r of this.At) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.dt, this._t, 0, i.RGBA, s, null);
186
186
  i.bindTexture(i.TEXTURE_2D, null);
187
187
  }
188
188
  readPixels(t) {
189
189
  const e = this.gt, i = this.bt[t];
190
190
  if (i) return i;
191
191
  const s = this.dt, r = this._t, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
192
- e.bindFramebuffer(e.READ_FRAMEBUFFER, this.At), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
192
+ e.bindFramebuffer(e.READ_FRAMEBUFFER, this.yt), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
193
193
  const c = 4 * s, l = new Uint8Array(n.length);
194
194
  for (let f = 0; f < r; f++) {
195
195
  const u = (r - 1 - f) * c, m = f * c;
@@ -204,9 +204,9 @@ class K {
204
204
  const n = ((i = (e = this.xt).Pt) == null ? void 0 : i.call(e)) ?? null;
205
205
  n && this.xt.St(n), this.Mt && this.Ft && ((r = (s = this.xt).Et) == null || r.call(s, this.Ft));
206
206
  }
207
- this.wt = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.At), this.bt = Array(this.Ct).fill(null);
207
+ this.wt = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.bt = Array(this.Ct).fill(null);
208
208
  for (let n = 0; n < this.Ct; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
209
- t.viewport(0, 0, this.dt, this._t), W(t, [0, 0, this.dt, this._t]);
209
+ t.viewport(0, 0, this.dt, this._t), Y(t, [0, 0, this.dt, this._t]);
210
210
  }
211
211
  end() {
212
212
  var e, i, s, r;
@@ -216,12 +216,12 @@ class K {
216
216
  const n = ((i = (e = this.xt).Pt) == null ? void 0 : i.call(e)) ?? null;
217
217
  n && this.xt.St(n);
218
218
  }
219
- t.bindFramebuffer(t.FRAMEBUFFER, this.wt.framebuffer), t.viewport(...this.wt.viewport), W(t, this.wt.viewport), this.wt = null, this.xt && this.Mt && this.Ft && ((r = (s = this.xt).$t) == null || r.call(s));
219
+ t.bindFramebuffer(t.FRAMEBUFFER, this.wt.framebuffer), t.viewport(...this.wt.viewport), Y(t, this.wt.viewport), this.wt = null, this.xt && this.Mt && this.Ft && ((r = (s = this.xt).$t) == null || r.call(s));
220
220
  }
221
221
  Dt() {
222
222
  const t = this.gt;
223
- t.deleteFramebuffer(this.At);
224
- for (const e of this.yt) t.deleteTexture(e);
223
+ t.deleteFramebuffer(this.yt);
224
+ for (const e of this.At) t.deleteTexture(e);
225
225
  }
226
226
  get width() {
227
227
  return this.dt;
@@ -230,32 +230,32 @@ class K {
230
230
  return this._t;
231
231
  }
232
232
  get textures() {
233
- return [...this.yt];
233
+ return [...this.At];
234
234
  }
235
235
  }
236
- class O {
236
+ class B {
237
237
  constructor(t, e, i) {
238
238
  h(this, "gt");
239
239
  h(this, "kt");
240
240
  h(this, "Bt", /* @__PURE__ */ new Map());
241
- h(this, "Lt", /* @__PURE__ */ new Map());
242
- h(this, "Ot", 0);
243
- this.gt = t, this.kt = this.Gt(e, i), this.Ht();
241
+ h(this, "Ot", /* @__PURE__ */ new Map());
242
+ h(this, "Lt", 0);
243
+ this.gt = t, this.kt = this.Ht(e, i), this.Gt();
244
244
  }
245
- Ht() {
245
+ Gt() {
246
246
  const t = this.gt.getProgramParameter(this.kt, this.gt.ACTIVE_UNIFORMS);
247
247
  for (let e = 0; e < t; e++) {
248
248
  const i = this.gt.getActiveUniform(this.kt, e);
249
249
  if (i) {
250
250
  const s = this.gt.getUniformLocation(this.kt, i.name);
251
- if (s && (this.Bt.set(i.name, s), this.Lt.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
251
+ if (s && (this.Bt.set(i.name, s), this.Ot.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
252
252
  const r = i.name.replace(/\[.*\]$/, "");
253
- this.Bt.has(r) || (this.Bt.set(r, s), this.Lt.set(r, { type: i.type, size: i.size }));
253
+ this.Bt.has(r) || (this.Bt.set(r, s), this.Ot.set(r, { type: i.type, size: i.size }));
254
254
  }
255
255
  }
256
256
  }
257
257
  }
258
- Gt(t, e) {
258
+ Ht(t, e) {
259
259
  const i = this.It(this.gt.VERTEX_SHADER, t), s = this.It(this.gt.FRAGMENT_SHADER, e), r = this.gt.createProgram();
260
260
  if (this.gt.attachShader(r, i), this.gt.attachShader(r, s), this.gt.linkProgram(r), !this.gt.getProgramParameter(r, this.gt.LINK_STATUS)) {
261
261
  const n = this.gt.getProgramInfoLog(r);
@@ -275,27 +275,27 @@ class O {
275
275
  this.gt.useProgram(this.kt), this.Xt();
276
276
  }
277
277
  Xt() {
278
- this.Ot = 0;
278
+ this.Lt = 0;
279
279
  }
280
280
  Wt(t) {
281
281
  for (const [e, i] of Object.entries(t)) this.Kt(e, i);
282
282
  }
283
- Yt(t) {
283
+ jt(t) {
284
284
  return this.Bt.has(t);
285
285
  }
286
- jt(t) {
287
- return this.Lt.get(t) || null;
286
+ Yt(t) {
287
+ return this.Ot.get(t) || null;
288
288
  }
289
289
  Vt() {
290
290
  const t = [];
291
- for (const [e, i] of this.Lt.entries()) t.push({ name: e, ...i });
291
+ for (const [e, i] of this.Ot.entries()) t.push({ name: e, ...i });
292
292
  return t;
293
293
  }
294
294
  Kt(t, e) {
295
295
  var c;
296
296
  const i = this.Bt.get(t);
297
297
  if (!i) return;
298
- const s = this.Lt.get(t);
298
+ const s = this.Ot.get(t);
299
299
  if (!s) return void console.warn(`No type information found for uniform '${t}'`);
300
300
  const { type: r, size: n } = s, o = this.gt;
301
301
  if (typeof e == "number") switch (r) {
@@ -347,13 +347,13 @@ class O {
347
347
  else if (e instanceof WebGLTexture) {
348
348
  const l = this.qt();
349
349
  o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e);
350
- } else if (e instanceof K) {
350
+ } else if (e instanceof j) {
351
351
  const l = this.qt();
352
352
  o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e.textures[0]);
353
353
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
354
354
  }
355
355
  qt() {
356
- return this.Ot++;
356
+ return this.Lt++;
357
357
  }
358
358
  get Zt() {
359
359
  return this.kt;
@@ -362,8 +362,8 @@ class O {
362
362
  this.gt.deleteProgram(this.kt);
363
363
  }
364
364
  }
365
- const X = `#version 300 es
366
- in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, st = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
365
+ const H = `#version 300 es
366
+ in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uy;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uy)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, st = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
367
367
  class lt {
368
368
  constructor(t) {
369
369
  h(this, "gt");
@@ -371,9 +371,9 @@ class lt {
371
371
  h(this, "Jt");
372
372
  h(this, "ts");
373
373
  h(this, "ss");
374
- this.gt = t, this.Jt = new O(this.gt, X, `#version 300 es
375
- precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Qt = new O(this.gt, X, `#version 300 es
376
- precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new O(this.gt, st, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.ss = new O(this.gt, X, `#version 300 es
374
+ this.gt = t, this.Jt = new B(this.gt, H, `#version 300 es
375
+ precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Qt = new B(this.gt, H, `#version 300 es
376
+ precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ts = new B(this.gt, st, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.ss = new B(this.gt, H, `#version 300 es
377
377
  precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec4 Uq;uniform bool Ur;uniform vec4 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299f,0.587f,0.114f));}void main(){vec2 C=vec2(v_uv.x,1.0f-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.0f),0.0f,F-1.0f);int H=int(floor(G+0.5f));vec3 I=Uv[H];o_character=vec4(I,1.0f);}else{o_character=vec4(E,0.0f,0.0f,1.0f);}vec4 J=Up?Uq:D;vec4 K=Ur?Us:D;if(D.a<0.01f){J=Ut;K=Ut;}else{}o_primaryColor=vec4(J);o_secondaryColor=vec4(K);o_rotation=vec4(Uo.xy,0.0f,1.0f);o_transform=vec4(float(Ul),float(Um),float(Un),1.0f);}`);
378
378
  }
379
379
  es() {
@@ -389,10 +389,10 @@ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform
389
389
  return this.ss;
390
390
  }
391
391
  hs(t) {
392
- return new O(this.gt, X, t);
392
+ return new B(this.gt, H, t);
393
393
  }
394
394
  cs(t, e) {
395
- return new O(this.gt, t, e);
395
+ return new B(this.gt, t, e);
396
396
  }
397
397
  Dt() {
398
398
  this.Qt.Dt(), this.Jt.Dt(), this.ts.Dt(), this.ss.Dt();
@@ -413,9 +413,9 @@ class ut {
413
413
  if (!o) {
414
414
  o = r.createVertexArray(), n.set(e, o), r.bindVertexArray(o), r.bindBuffer(r.ARRAY_BUFFER, s);
415
415
  const c = r.getAttribLocation(t, "a_position");
416
- c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.ds.fs.size, r.FLOAT, !1, i._s, i.ds.fs.offset), r.vertexAttribDivisor(c, 0));
416
+ c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.ds.fs.size, r.FLOAT, !1, i.ps, i.ds.fs.offset), r.vertexAttribDivisor(c, 0));
417
417
  const l = r.getAttribLocation(t, "a_texCoord");
418
- l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.ds.ps.size, r.FLOAT, !1, i._s, i.ds.ps.offset), r.vertexAttribDivisor(l, 0));
418
+ l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.ds._s.size, r.FLOAT, !1, i.ps, i.ds._s.offset), r.vertexAttribDivisor(l, 0));
419
419
  }
420
420
  r.bindVertexArray(o);
421
421
  }
@@ -436,8 +436,8 @@ class ft {
436
436
  this.gt = t, this.gs = new ut(t), this.xt = e;
437
437
  }
438
438
  ws(t, e, i) {
439
- const { shader: s } = t, r = H(this.gt) || this.gt.getParameter(this.gt.VIEWPORT);
440
- s.Wt({ U9: r[2] / r[3], Uw: [r[2], r[3]] });
439
+ const { shader: s } = t, r = W(this.gt) || this.gt.getParameter(this.gt.VIEWPORT);
440
+ s.Wt({ U9: r[2] / r[3], Uy: [r[2], r[3]] });
441
441
  const n = (l) => {
442
442
  if (!l || !l.bs()) return;
443
443
  const f = l.unitGeometry, u = l.unitBuffer;
@@ -468,7 +468,7 @@ class ft {
468
468
  Ds(t, e, i, s, r, n, o, c) {
469
469
  e.Nt(), e.Wt(i);
470
470
  const l = this.gt.getParameter(this.gt.VIEWPORT);
471
- if (e.Wt({ U9: l[2] / l[3], Uw: [l[2], l[3]] }), t.Ps(), t.Es({ x: s, y: r, width: n, height: o }, c), t.bs()) {
471
+ if (e.Wt({ U9: l[2] / l[3], Uy: [l[2], l[3]] }), t.Ps(), t.Es({ x: s, y: r, width: n, height: o }, c), t.bs()) {
472
472
  const f = t.unitGeometry, u = t.unitBuffer;
473
473
  try {
474
474
  this.gs.us(e.Zt, t.type + "", f, u), t.batch.Ms(e), t.batch.Fs(f.zs, f.Rs);
@@ -481,7 +481,7 @@ class ft {
481
481
  return this.xt.es();
482
482
  }
483
483
  $s(t, e) {
484
- return this.As && this.Cs && this.Cs.w === t && this.Cs.h === e || (this.As && this.As.Dt(), this.As = new K(this.gt, t, e, 5), this.Cs = { w: t, h: e }), this.As;
484
+ return this.As && this.Cs && this.Cs.w === t && this.Cs.h === e || (this.As && this.As.Dt(), this.As = new j(this.gt, t, e, 5), this.Cs = { w: t, h: e }), this.As;
485
485
  }
486
486
  Dt() {
487
487
  this.gs.Dt(), this.As && this.As.Dt();
@@ -490,82 +490,82 @@ class ft {
490
490
  class dt {
491
491
  constructor() {
492
492
  h(this, "Bs", []);
493
- h(this, "Ls", 1);
494
- h(this, "Os", 0);
493
+ h(this, "Os", 1);
494
+ h(this, "Ls", 0);
495
495
  }
496
- Gs(t) {
497
- if (this.Os >= this.Bs.length) {
498
- const i = { id: this.Ls++, type: t, params: {}, state: { I: 1, N: 0, X: 0, W: 0, j: [0, 0, 0], V: [1, 1, 1, 1], q: [0, 0, 0, 1], K: !1, Y: !1, k: !1, L: [0, 0] } };
496
+ Hs(t) {
497
+ if (this.Ls >= this.Bs.length) {
498
+ const i = { id: this.Os++, type: t, params: {}, state: { I: 1, N: 0, X: 0, W: 0, Y: [0, 0, 0], V: [1, 1, 1, 1], q: [0, 0, 0, 1], K: !1, j: !1, k: !1, O: [0, 0] } };
499
499
  this.Bs.push(i);
500
500
  }
501
- const e = this.Bs[this.Os];
502
- return e.id = this.Ls++, e.type = t, this.Os++, e;
501
+ const e = this.Bs[this.Ls];
502
+ return e.id = this.Os++, e.type = t, this.Ls++, e;
503
503
  }
504
- Hs(t, e, i, s, r) {
505
- const n = this.Gs(E.RECTANGLE);
504
+ Gs(t, e, i, s, r) {
505
+ const n = this.Hs(E.RECTANGLE);
506
506
  return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
507
507
  }
508
508
  Is(t, e, i, s, r, n, o) {
509
- const c = this.Gs(E.CUSTOM);
509
+ const c = this.Hs(E.CUSTOM);
510
510
  return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.shader = r, c.params.uniforms = n, o.J(c.state), c.id;
511
511
  }
512
512
  Ns(t, e, i, s, r, n) {
513
- const o = this.Gs(E.LINE);
513
+ const o = this.Hs(E.LINE);
514
514
  return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.J(o.state), o.id;
515
515
  }
516
516
  Xs(t, e, i, s, r) {
517
- const n = this.Gs(E.ELLIPSE);
517
+ const n = this.Hs(E.ELLIPSE);
518
518
  return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
519
519
  }
520
520
  Ws(t, e, i, s, r, n, o) {
521
- const c = this.Gs(E.ARC);
521
+ const c = this.Hs(E.ARC);
522
522
  return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.start = r, c.params.stop = n, o.J(c.state), c.id;
523
523
  }
524
524
  Ks(t, e, i, s, r, n, o) {
525
- const c = this.Gs(E.TRIANGLE);
525
+ const c = this.Hs(E.TRIANGLE);
526
526
  return c.params.x1 = t, c.params.y1 = e, c.params.x2 = i, c.params.y2 = s, c.params.x3 = r, c.params.y3 = n, o.J(c.state), c.id;
527
527
  }
528
- Ys(t, e, i, s, r, n, o, c, l, f) {
529
- const u = this.Gs(E.BEZIER_CURVE);
528
+ js(t, e, i, s, r, n, o, c, l, f) {
529
+ const u = this.Hs(E.BEZIER_CURVE);
530
530
  return u.params.x1 = t, u.params.y1 = e, u.params.cp1x = i, u.params.cp1y = s, u.params.cp2x = r, u.params.cp2y = n, u.params.x2 = o, u.params.y2 = c, u.params.thickness = l, f.J(u.state), u.id;
531
531
  }
532
532
  get length() {
533
- return this.Os;
533
+ return this.Ls;
534
534
  }
535
535
  get isEmpty() {
536
- return this.Os === 0;
536
+ return this.Ls === 0;
537
537
  }
538
- js() {
539
- this.Os = 0;
538
+ Ys() {
539
+ this.Ls = 0;
540
540
  }
541
541
  [Symbol.iterator]() {
542
542
  let t = 0;
543
- const e = this.Os, i = this.Bs;
543
+ const e = this.Ls, i = this.Bs;
544
544
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
545
545
  }
546
546
  }
547
- const L = class L {
547
+ const M = class M {
548
548
  static Vs(t, e, i = 0) {
549
549
  var n, o, c, l, f, u, m, p, g, d;
550
- const s = e || new Float32Array(L.FLOATS_PER_INSTANCE);
550
+ const s = e || new Float32Array(M.FLOATS_PER_INSTANCE);
551
551
  let r = i;
552
- return s[r++] = t.fs[0], s[r++] = t.fs[1], s[r++] = t.Os[0], s[r++] = t.Os[1], s[r++] = t.j[0], s[r++] = t.j[1], s[r++] = t.j[2], s[r++] = t.V[0], s[r++] = t.V[1], s[r++] = t.V[2], s[r++] = t.V[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.L[0], s[r++] = t.L[1], s[r++] = t.qs[0], s[r++] = t.qs[1], s[r++] = t.qs[2], s[r++] = t.N, s[r++] = t.X, s[r++] = t.W, s[r++] = t.Zs[0], s[r++] = t.Zs[1], s[r++] = ((n = t.Qs) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Qs) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.Js) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.Js) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.te) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.te) == null ? void 0 : u[1]) || 0, s[r++] = ((m = t.se) == null ? void 0 : m[0]) || 0, s[r++] = ((p = t.se) == null ? void 0 : p[1]) || 0, s[r++] = ((g = t.ee) == null ? void 0 : g[0]) || 0, s[r++] = ((d = t.ee) == null ? void 0 : d[1]) || 0, s;
552
+ return s[r++] = t.fs[0], s[r++] = t.fs[1], s[r++] = t.Ls[0], s[r++] = t.Ls[1], s[r++] = t.Y[0], s[r++] = t.Y[1], s[r++] = t.Y[2], s[r++] = t.V[0], s[r++] = t.V[1], s[r++] = t.V[2], s[r++] = t.V[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.O[0], s[r++] = t.O[1], s[r++] = t.qs[0], s[r++] = t.qs[1], s[r++] = t.qs[2], s[r++] = t.N, s[r++] = t.X, s[r++] = t.W, s[r++] = t.Zs[0], s[r++] = t.Zs[1], s[r++] = ((n = t.Qs) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Qs) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.Js) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.Js) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.te) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.te) == null ? void 0 : u[1]) || 0, s[r++] = ((m = t.se) == null ? void 0 : m[0]) || 0, s[r++] = ((p = t.se) == null ? void 0 : p[1]) || 0, s[r++] = ((g = t.ee) == null ? void 0 : g[0]) || 0, s[r++] = ((d = t.ee) == null ? void 0 : d[1]) || 0, s;
553
553
  }
554
554
  static ie(t) {
555
- const e = t.length * L.FLOATS_PER_INSTANCE, i = new Float32Array(e);
555
+ const e = t.length * M.FLOATS_PER_INSTANCE, i = new Float32Array(e);
556
556
  for (let s = 0; s < t.length; s++) {
557
- const r = s * L.FLOATS_PER_INSTANCE;
558
- L.Vs(t[s], i, r);
557
+ const r = s * M.FLOATS_PER_INSTANCE;
558
+ M.Vs(t[s], i, r);
559
559
  }
560
560
  return i;
561
561
  }
562
562
  };
563
- h(L, "BYTES_PER_INSTANCE", 140), h(L, "FLOATS_PER_INSTANCE", 35);
564
- let D = L;
563
+ h(M, "BYTES_PER_INSTANCE", 140), h(M, "FLOATS_PER_INSTANCE", 35);
564
+ let S = M;
565
565
  const b = class b {
566
566
  };
567
- h(b, "STRIDE", D.BYTES_PER_INSTANCE), h(b, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 132, divisor: 1 } });
568
- let j = b;
567
+ h(b, "STRIDE", S.BYTES_PER_INSTANCE), h(b, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: b.STRIDE, offset: 132, divisor: 1 } });
568
+ let k = b;
569
569
  class gt {
570
570
  constructor(t, e = 1e3, i = 1.5) {
571
571
  h(this, "gt");
@@ -600,22 +600,22 @@ class gt {
600
600
  fe() {
601
601
  const t = this.gt;
602
602
  this.he && t.deleteBuffer(this.he), this.he = t.createBuffer();
603
- const e = this.ne * D.BYTES_PER_INSTANCE;
603
+ const e = this.ne * S.BYTES_PER_INSTANCE;
604
604
  t.bindBuffer(t.ARRAY_BUFFER, this.he), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !0, this.ce = 0;
605
605
  }
606
- _e() {
606
+ pe() {
607
607
  if (!this.ae || this.re.length === 0) return;
608
608
  const t = this.gt, e = this.re.length;
609
- this.de(e), (!this.ue || this.ue.length < e * D.FLOATS_PER_INSTANCE) && (this.ue = new Float32Array(e * D.FLOATS_PER_INSTANCE));
610
- const i = D.ie(this.re);
609
+ this.de(e), (!this.ue || this.ue.length < e * S.FLOATS_PER_INSTANCE) && (this.ue = new Float32Array(e * S.FLOATS_PER_INSTANCE));
610
+ const i = S.ie(this.re);
611
611
  t.bindBuffer(t.ARRAY_BUFFER, this.he), e <= this.ce ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !1, this.ce = e;
612
612
  }
613
- pe(t) {
613
+ _e(t) {
614
614
  let e = this.le.get(t);
615
615
  if (!e) {
616
616
  e = /* @__PURE__ */ new Map();
617
617
  const i = this.gt;
618
- for (const s in j.ATTRIBUTES) {
618
+ for (const s in k.ATTRIBUTES) {
619
619
  const r = i.getAttribLocation(t, s);
620
620
  r !== -1 && e.set(s, r);
621
621
  }
@@ -626,16 +626,16 @@ class gt {
626
626
  Ms(t) {
627
627
  if (!this.he || this.re.length === 0) return;
628
628
  const e = this.gt, i = t.Zt;
629
- this._e();
630
- const s = this.pe(i);
629
+ this.pe();
630
+ const s = this._e(i);
631
631
  e.bindBuffer(e.ARRAY_BUFFER, this.he);
632
632
  for (const [r, n] of s) {
633
- const o = j.ATTRIBUTES[r];
633
+ const o = k.ATTRIBUTES[r];
634
634
  o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
635
635
  }
636
636
  }
637
637
  Ts(t) {
638
- const e = this.gt, i = this.pe(t.Zt);
638
+ const e = this.gt, i = this._e(t.Zt);
639
639
  for (const [, s] of i) e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0);
640
640
  }
641
641
  Fs(t, e) {
@@ -645,45 +645,45 @@ class gt {
645
645
  this.he && this.gt.deleteBuffer(this.he);
646
646
  }
647
647
  }
648
- class S {
648
+ class O {
649
649
  constructor(t, e, i, s) {
650
650
  h(this, "gt");
651
- h(this, "ve");
652
651
  h(this, "me");
652
+ h(this, "ve");
653
653
  h(this, "ge");
654
- h(this, "Ae", null);
655
- this.gt = t, this.ve = e, this.me = i, this.ge = s;
654
+ h(this, "ye", null);
655
+ this.gt = t, this.me = e, this.ve = i, this.ge = s;
656
656
  const r = this.gt.createBuffer();
657
657
  if (!r) throw Error("Failed to create unit geometry buffer");
658
- this.gt.bindBuffer(this.gt.ARRAY_BUFFER, r), this.gt.bufferData(this.gt.ARRAY_BUFFER, this.ge.ye, this.gt.STATIC_DRAW), this.gt.bindBuffer(this.gt.ARRAY_BUFFER, null), this.Ae = r;
658
+ this.gt.bindBuffer(this.gt.ARRAY_BUFFER, r), this.gt.bufferData(this.gt.ARRAY_BUFFER, this.ge.Ae, this.gt.STATIC_DRAW), this.gt.bindBuffer(this.gt.ARRAY_BUFFER, null), this.ye = r;
659
659
  }
660
660
  get type() {
661
- return this.me;
661
+ return this.ve;
662
662
  }
663
663
  get unitGeometry() {
664
664
  return this.ge;
665
665
  }
666
666
  get unitBuffer() {
667
- return this.Ae;
667
+ return this.ye;
668
668
  }
669
669
  get batch() {
670
- return this.ve;
670
+ return this.me;
671
671
  }
672
672
  Ps() {
673
- this.ve.clear();
673
+ this.me.clear();
674
674
  }
675
675
  bs() {
676
- return !this.ve.isEmpty;
676
+ return !this.me.isEmpty;
677
677
  }
678
678
  Dt() {
679
- this.ve.Dt(), this.gt.deleteBuffer(this.Ae);
679
+ this.me.Dt(), this.gt.deleteBuffer(this.ye);
680
680
  }
681
681
  Ce(t, e, i, s, r) {
682
682
  const n = this.we(t, e, i, s, r.N || 0, r.X || 0, r.W || 0);
683
- return { fs: [t, e], Os: [i, s], j: r.j || [0, 0, 0], V: r.V || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], L: r.L || [0, 0], qs: [r.k ? 1 : 0, r.K ? 1 : 0, r.Y ? 1 : 0], N: n.radiansX, X: n.radiansY, W: n.radiansZ, Zs: [n.centerX, n.centerY] };
683
+ return { fs: [t, e], Ls: [i, s], Y: r.Y || [0, 0, 0], V: r.V || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], O: r.O || [0, 0], qs: [r.k ? 1 : 0, r.K ? 1 : 0, r.j ? 1 : 0], N: n.radiansX, X: n.radiansY, W: n.radiansZ, Zs: [n.centerX, n.centerY] };
684
684
  }
685
685
  be(t, e) {
686
- const i = H(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height];
686
+ const i = W(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height];
687
687
  return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
688
688
  }
689
689
  xe(t, e, i) {
@@ -691,96 +691,96 @@ class S {
691
691
  t.Zs = [s.nx, s.ny];
692
692
  }
693
693
  we(t, e, i, s, r, n, o) {
694
- const c = H(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height], l = c[2], f = c[3];
694
+ const c = W(this.gt) || [0, 0, this.gt.canvas.width, this.gt.canvas.height], l = c[2], f = c[3];
695
695
  return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / f * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / f };
696
696
  }
697
697
  }
698
- const mt = { ye: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), Rs: 6, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
699
- class At extends S {
698
+ const mt = { Ae: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), Rs: 6, zs: WebGL2RenderingContext.TRIANGLES, ps: 16, ds: { fs: { size: 2, offset: 0 }, _s: { size: 2, offset: 8 } } };
699
+ class At extends O {
700
700
  constructor(t, e) {
701
701
  super(t, e, E.RECTANGLE, mt);
702
702
  }
703
703
  Es(t, e) {
704
704
  const i = this.Ce(t.x, t.y, t.width, t.height, e);
705
- return this.ve.Es(i);
705
+ return this.me.Es(i);
706
706
  }
707
707
  }
708
- const pt = { ye: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), Rs: 6, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
709
- class vt extends S {
708
+ const pt = { Ae: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), Rs: 6, zs: WebGL2RenderingContext.TRIANGLES, ps: 16, ds: { fs: { size: 2, offset: 0 }, _s: { size: 2, offset: 8 } } };
709
+ class vt extends O {
710
710
  constructor(t, e) {
711
711
  super(t, e, E.LINE, pt);
712
712
  }
713
713
  Es(t, e) {
714
714
  const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.I || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2, f = c, u = this.Ce(l, f, r, n, e);
715
- return this.xe(u, o, c), this.ve.Es(u);
715
+ return this.xe(u, o, c), this.me.Es(u);
716
716
  }
717
717
  }
718
- const yt = { ye: function(a = 32) {
718
+ const yt = { Ae: function(a = 32) {
719
719
  const t = [], e = 2 * Math.PI / a;
720
720
  for (let i = 0; i < a; i++) {
721
721
  const s = i * e, r = (i + 1) % a * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), f = Math.cos(r), u = Math.sin(r), m = 0.5 * (f + 1), p = 0.5 * (u + 1);
722
722
  t.push(0, 0, 0.5, 0.5, n, o, c, l, f, u, m, p);
723
723
  }
724
724
  return new Float32Array(t);
725
- }(32), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
726
- class Et extends S {
725
+ }(32), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, ps: 16, ds: { fs: { size: 2, offset: 0 }, _s: { size: 2, offset: 8 } } };
726
+ class Et extends O {
727
727
  constructor(t, e) {
728
728
  super(t, e, E.ELLIPSE, yt);
729
729
  }
730
730
  Es(t, e) {
731
731
  const i = this.Ce(t.x, t.y, t.width, t.height, e);
732
- return this.xe(i, t.x, t.y), this.ve.Es(i);
732
+ return this.xe(i, t.x, t.y), this.me.Es(i);
733
733
  }
734
734
  }
735
- let xt = { ye: function(a) {
735
+ let xt = { Ae: function(a) {
736
736
  const t = [];
737
737
  for (let e = 0; e < a; e++) {
738
738
  const i = e / a, s = (e + 1) / a;
739
739
  t.push(i, 0, i, 0, i, 1, i, 1, s, 1, s, 1);
740
740
  }
741
741
  return new Float32Array(t);
742
- }(32), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
743
- class wt extends S {
742
+ }(32), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, ps: 16, ds: { fs: { size: 2, offset: 0 }, _s: { size: 2, offset: 8 } } };
743
+ class wt extends O {
744
744
  constructor(t, e) {
745
745
  super(t, e, E.ARC, xt);
746
746
  }
747
747
  Es(t, e) {
748
748
  const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.Ce(i, s, t.width, t.height, e);
749
- return this.xe(o, t.x, t.y), o.Qs = [r, n], this.ve.Es(o);
749
+ return this.xe(o, t.x, t.y), o.Qs = [r, n], this.me.Es(o);
750
750
  }
751
751
  }
752
- const Tt = { ye: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Rs: 3, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
753
- class Rt extends S {
752
+ const Tt = { Ae: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), Rs: 3, zs: WebGL2RenderingContext.TRIANGLES, ps: 16, ds: { fs: { size: 2, offset: 0 }, _s: { size: 2, offset: 8 } } };
753
+ class Rt extends O {
754
754
  constructor(t, e) {
755
755
  super(t, e, E.TRIANGLE, Tt);
756
756
  }
757
757
  Es(t, e) {
758
758
  const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.Ce(i, r, n, o, e), l = i + 0.5 * n, f = r + o * (1 / 3);
759
- return this.xe(c, l, f), this.ve.Es(c);
759
+ return this.xe(c, l, f), this.me.Es(c);
760
760
  }
761
761
  }
762
762
  function $(a, t, e, i, s) {
763
763
  const r = 1 - a, n = r * r, o = a * a;
764
764
  return n * r * t + 3 * n * a * e + 3 * r * o * i + o * a * s;
765
765
  }
766
- const bt = { ye: function(a = 16) {
766
+ const bt = { Ae: function(a = 16) {
767
767
  const t = [];
768
768
  for (let e = 0; e < a; e++) {
769
769
  const i = e / a, s = (e + 1) / a;
770
770
  t.push(i, -0.5, i, 0), t.push(s, -0.5, s, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(s, -0.5, s, 0), t.push(s, 0.5, s, 1);
771
771
  }
772
772
  return new Float32Array(t);
773
- }(16), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, _s: 16, ds: { fs: { size: 2, offset: 0 }, ps: { size: 2, offset: 8 } } };
774
- class Ct extends S {
773
+ }(16), Rs: 96, zs: WebGL2RenderingContext.TRIANGLES, ps: 16, ds: { fs: { size: 2, offset: 0 }, _s: { size: 2, offset: 8 } } };
774
+ class Ct extends O {
775
775
  constructor(t, e) {
776
776
  super(t, e, E.BEZIER_CURVE, bt);
777
777
  }
778
778
  Es(t, e) {
779
779
  const i = e.I || 1, s = $(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = $(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.Ce(0, 0, 1, i, e);
780
- return this.xe(n, s, r), n.se = [t.x1, t.y1], n.Js = [t.cp1x, t.cp1y], n.te = [t.cp2x, t.cp2y], n.ee = [t.x2, t.y2], this.ve.Es(n);
780
+ return this.xe(n, s, r), n.se = [t.x1, t.y1], n.Js = [t.cp1x, t.cp1y], n.te = [t.cp2x, t.cp2y], n.ee = [t.x2, t.y2], this.me.Es(n);
781
781
  }
782
782
  }
783
- class Ut {
783
+ class Lt {
784
784
  constructor(t) {
785
785
  h(this, "gt");
786
786
  h(this, "Me", null);
@@ -792,8 +792,8 @@ class Ut {
792
792
  h(this, "Se");
793
793
  h(this, "Ee");
794
794
  h(this, "$e");
795
- h(this, "G", []);
796
- this.gt = t, this.Fe = new lt(t), this.$e = new it(), this.Se = new ft(t, this), this.Ee = new dt(), this.Te = t.createBuffer(), W(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
795
+ h(this, "H", []);
796
+ this.gt = t, this.Fe = new lt(t), this.$e = new it(), this.Se = new ft(t, this), this.Ee = new dt(), this.Te = t.createBuffer(), Y(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
797
797
  }
798
798
  De(t) {
799
799
  let e = this.Pe.get(t);
@@ -825,18 +825,18 @@ class Ut {
825
825
  Kt(t, e) {
826
826
  this.Re[t] = e;
827
827
  }
828
- Le(t) {
828
+ Oe(t) {
829
829
  Object.assign(this.Re, t);
830
830
  }
831
831
  hs(t) {
832
832
  return this.Fe.hs(t);
833
833
  }
834
- Oe(t, e, i, s, r) {
834
+ Le(t, e, i, s, r) {
835
835
  const n = this.es(), o = { Ue: t.textures[0], Uf: t.textures[1], Ug: t.textures[2], Uh: t.textures[3], Ui: t.textures[4], Uj: [t.width, t.height] };
836
836
  this.Ee.Is(e, i, s, r, n, o, this.$e);
837
837
  }
838
- Ge(t, e, i, s, r) {
839
- const n = this.ns(), o = t.He(), c = { Uk: o.texture, Ul: !!o.invert, Um: !!o.flipX, Un: !!o.flipY, Uo: o.charRotation, Up: o.charColorFixed, Uq: o.charColor, Ur: o.cellColorFixed, Us: o.cellColor, Ut: o.backgroundColor, Uu: o.charCount, Uv: o.charList };
838
+ He(t, e, i, s, r) {
839
+ const n = this.ns(), o = t.Ge(), c = { Uk: o.texture, Ul: !!o.invert, Um: !!o.flipX, Un: !!o.flipY, Uo: o.charRotation, Up: o.charColorFixed, Uq: o.charColor, Ur: o.cellColorFixed, Us: o.cellColor, Ut: o.backgroundColor, Uu: o.charCount, Uv: o.charList };
840
840
  this.Ee.Is(e, i, s, r, n, c, this.$e);
841
841
  }
842
842
  Ie(t, e, i, s) {
@@ -847,7 +847,7 @@ class Ut {
847
847
  g !== -1 && (r.enableVertexAttribArray(g), r.vertexAttribPointer(g, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), g !== -1 && r.disableVertexAttribArray(g);
848
848
  }
849
849
  Ne(t, e, i, s) {
850
- this.ze ? (this.Ee.Is(t, e, i, s, this.ze, { ...this.Re }, this.$e), this.ze = null, this.Re = {}) : this.Ee.Hs(t, e, i, s, this.$e);
850
+ this.ze ? (this.Ee.Is(t, e, i, s, this.ze, { ...this.Re }, this.$e), this.ze = null, this.Re = {}) : this.Ee.Gs(t, e, i, s, this.$e);
851
851
  }
852
852
  Xe(t, e, i, s) {
853
853
  this.Ee.Ns(t, e, i, s, this.$e.lineWeight, this.$e);
@@ -858,24 +858,24 @@ class Ut {
858
858
  Ke(t, e, i, s, r, n) {
859
859
  this.Ee.Ks(t, e, i, s, r, n, this.$e);
860
860
  }
861
- Ye(t, e, i, s, r, n, o, c) {
861
+ je(t, e, i, s, r, n, o, c) {
862
862
  const l = this.$e.lineWeight;
863
- this.Ee.Ys(t, e, i, s, r, n, o, c, l, this.$e);
863
+ this.Ee.js(t, e, i, s, r, n, o, c, l, this.$e);
864
864
  }
865
- je(t, e, i = 1, s = {}) {
866
- return new K(this.gt, t, e, i, s, this, !0);
865
+ Ye(t, e, i = 1, s = {}) {
866
+ return new j(this.gt, t, e, i, s, this, !0);
867
867
  }
868
868
  Ve(t, e, i, s, r, n) {
869
869
  this.Ee.Ws(t, e, i, s, r, n, this.$e);
870
870
  }
871
871
  qe(t, e = t, i = t, s = 255) {
872
- this.$e.ft(t, e, i, s), this.js(t / 255, e / 255, i / 255, s / 255);
872
+ this.$e.ft(t, e, i, s), this.Ys(t / 255, e / 255, i / 255, s / 255);
873
873
  }
874
- js(t = 0, e = 0, i = 0, s = 0) {
874
+ Ys(t = 0, e = 0, i = 0, s = 0) {
875
875
  this.gt.clearColor(t, e, i, s), this.gt.clear(this.gt.COLOR_BUFFER_BIT);
876
876
  }
877
877
  Ze() {
878
- this.gt.viewport(0, 0, this.gt.canvas.width, this.gt.canvas.height), W(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
878
+ this.gt.viewport(0, 0, this.gt.canvas.width, this.gt.canvas.height), Y(this.gt, [0, 0, this.gt.canvas.width, this.gt.canvas.height]);
879
879
  }
880
880
  get context() {
881
881
  return this.gt;
@@ -884,22 +884,22 @@ class Ut {
884
884
  return this.$e;
885
885
  }
886
886
  Et(t) {
887
- this.G.push(this.$e), this.$e = t;
887
+ this.H.push(this.$e), this.$e = t;
888
888
  }
889
889
  $t() {
890
- const t = this.G.pop();
890
+ const t = this.H.pop();
891
891
  t && (this.$e = t);
892
892
  }
893
893
  St(t) {
894
- const e = t, i = H(this.gt) ?? this.gt.getParameter(this.gt.VIEWPORT), s = { shader: e, gl: this.gt, viewport: i };
894
+ const e = t, i = W(this.gt) ?? this.gt.getParameter(this.gt.VIEWPORT), s = { shader: e, gl: this.gt, viewport: i };
895
895
  this.ke(e);
896
896
  const r = /* @__PURE__ */ new Set();
897
897
  for (const n of this.Ee) n.type === E.CUSTOM ? r.add(E.RECTANGLE) : r.add(n.type);
898
898
  for (const n of r) n !== E.CUSTOM && this.De(n);
899
- this.Se.ws(s, this.Ee, this.Pe), this.Ee.js();
899
+ this.Se.ws(s, this.Ee, this.Pe), this.Ee.Ys();
900
900
  }
901
901
  Dt() {
902
- this.gt.deleteBuffer(this.Te), this.Ee.js();
902
+ this.gt.deleteBuffer(this.Te), this.Ee.Ys();
903
903
  for (const t of this.Pe.values()) t.Dt();
904
904
  this.Fe.Dt(), this.Se.Dt();
905
905
  }
@@ -925,17 +925,17 @@ const w = { readShort: (a, t) => (w.t.uint16[0] = a[t] << 8 | a[t + 1], w.t.int1
925
925
  const a = new ArrayBuffer(8);
926
926
  return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
927
927
  })() };
928
- function Y(a) {
928
+ function X(a) {
929
929
  return a + 3 & -4;
930
930
  }
931
- function k(a, t, e) {
931
+ function V(a, t, e) {
932
932
  const i = t + e;
933
933
  let s = 0;
934
934
  const r = w.t;
935
935
  for (let n = t; n < i; n += 4) r.uint8[3] = a[n] || 0, r.uint8[2] = a[n + 1] || 0, r.uint8[1] = a[n + 2] || 0, r.uint8[0] = a[n + 3] || 0, s = s + (r.uint32[0] >>> 0) >>> 0;
936
936
  return s >>> 0;
937
937
  }
938
- class Bt {
938
+ class Ut {
939
939
  constructor(t) {
940
940
  h(this, "b");
941
941
  h(this, "p", 0);
@@ -958,7 +958,7 @@ class Bt {
958
958
  return this.p;
959
959
  }
960
960
  }
961
- function z(a) {
961
+ function N(a) {
962
962
  let t = 32, e = 0;
963
963
  for (const o of a) o && (o < t && (t = o), o > e && (e = o));
964
964
  if (e === 0) return { min: 0, max: 0, table: /* @__PURE__ */ new Map() };
@@ -978,7 +978,7 @@ function z(a) {
978
978
  }
979
979
  return { min: t, max: e, table: n };
980
980
  }
981
- function V(a, t) {
981
+ function q(a, t) {
982
982
  let e = 0;
983
983
  for (let i = 1; i <= t.max; i++) {
984
984
  e |= a.readBits(1) << i - 1;
@@ -995,7 +995,7 @@ function Ft(a, t) {
995
995
  for (let i = 0; i < t; i++) e = e << 1 | 1 & a, a >>>= 1;
996
996
  return e >>> 0;
997
997
  }
998
- function Lt(a) {
998
+ function Pt(a) {
999
999
  if (a.length < 2) throw Error("ZLIB data too short");
1000
1000
  const t = a[0], e = a[1];
1001
1001
  if ((15 & t) != 8) throw Error("Unsupported ZLIB compression method");
@@ -1024,33 +1024,33 @@ function Lt(a) {
1024
1024
  for (let v = 144; v <= 255; v++) d[v] = 9;
1025
1025
  for (let v = 256; v <= 279; v++) d[v] = 7;
1026
1026
  for (let v = 280; v <= 287; v++) d[v] = 8;
1027
- p = z(d), g = z(Array(32).fill(5));
1027
+ p = N(d), g = N(Array(32).fill(5));
1028
1028
  } else {
1029
1029
  const d = r.readBits(5) + 257, v = r.readBits(5) + 1, A = r.readBits(4) + 4, x = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], y = Array(19).fill(0);
1030
- for (let B = 0; B < A; B++) y[x[B]] = r.readBits(3);
1031
- const U = z(y), T = [];
1030
+ for (let U = 0; U < A; U++) y[x[U]] = r.readBits(3);
1031
+ const L = N(y), T = [];
1032
1032
  for (; T.length < d + v; ) {
1033
- const B = V(r, U);
1034
- if (B <= 15) T.push(B);
1035
- else if (B === 16) {
1036
- const I = r.readBits(2) + 3, M = T[T.length - 1] || 0;
1037
- for (let J = 0; J < I; J++) T.push(M);
1038
- } else if (B === 17) {
1033
+ const U = q(r, L);
1034
+ if (U <= 15) T.push(U);
1035
+ else if (U === 16) {
1036
+ const I = r.readBits(2) + 3, _ = T[T.length - 1] || 0;
1037
+ for (let J = 0; J < I; J++) T.push(_);
1038
+ } else if (U === 17) {
1039
1039
  const I = r.readBits(3) + 3;
1040
- for (let M = 0; M < I; M++) T.push(0);
1040
+ for (let _ = 0; _ < I; _++) T.push(0);
1041
1041
  } else {
1042
- if (B !== 18) throw Error("Invalid code length symbol");
1042
+ if (U !== 18) throw Error("Invalid code length symbol");
1043
1043
  {
1044
1044
  const I = r.readBits(7) + 11;
1045
- for (let M = 0; M < I; M++) T.push(0);
1045
+ for (let _ = 0; _ < I; _++) T.push(0);
1046
1046
  }
1047
1047
  }
1048
1048
  }
1049
1049
  const R = T.slice(0, d), F = T.slice(d, d + v);
1050
- p = z(R), g = z(F);
1050
+ p = N(R), g = N(F);
1051
1051
  }
1052
1052
  for (; ; ) {
1053
- const d = V(r, p);
1053
+ const d = q(r, p);
1054
1054
  if (d < 256) n.push(d);
1055
1055
  else {
1056
1056
  if (d === 256) break;
@@ -1059,12 +1059,12 @@ function Lt(a) {
1059
1059
  let A = o[v];
1060
1060
  const x = c[v];
1061
1061
  x && (A += r.readBits(x));
1062
- const y = V(r, g);
1062
+ const y = q(r, g);
1063
1063
  if (y >= 30) throw Error("Invalid distance symbol");
1064
- let U = l[y];
1064
+ let L = l[y];
1065
1065
  const T = f[y];
1066
- T && (U += r.readBits(T));
1067
- const R = n.length - U;
1066
+ T && (L += r.readBits(T));
1067
+ const R = n.length - L;
1068
1068
  if (R < 0) throw Error("Invalid distance");
1069
1069
  for (let F = 0; F < A; F++) n.push(n[R + F] || 0);
1070
1070
  } else if (d === 286 || d === 287) throw Error("Reserved length symbol");
@@ -1073,21 +1073,21 @@ function Lt(a) {
1073
1073
  }
1074
1074
  }
1075
1075
  }
1076
- }(new Bt(a.subarray(i)), s), new Uint8Array(s);
1076
+ }(new Ut(a.subarray(i)), s), new Uint8Array(s);
1077
1077
  }
1078
- function Pt(a) {
1078
+ function Mt(a) {
1079
1079
  const t = w, e = new Uint8Array(a);
1080
1080
  if (t.readASCII(e, 0, 4) !== "wOFF") throw Error("Invalid WOFF signature");
1081
1081
  const i = t.readUint(e, 4), s = t.readUshort(e, 12), r = t.readUint(e, 16), n = [];
1082
1082
  let o = 44;
1083
1083
  for (let A = 0; A < s; A++) {
1084
- const x = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), U = t.readUint(e, o + 8), T = t.readUint(e, o + 12), R = t.readUint(e, o + 16);
1085
- n.push({ tag: x, offset: y, compLength: U, origLength: T, checksum: R }), o += 20;
1084
+ const x = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), L = t.readUint(e, o + 8), T = t.readUint(e, o + 12), R = t.readUint(e, o + 16);
1085
+ n.push({ tag: x, offset: y, compLength: L, origLength: T, checksum: R }), o += 20;
1086
1086
  }
1087
1087
  for (const A of n) {
1088
1088
  const x = new Uint8Array(e.buffer, A.offset, A.compLength);
1089
1089
  if (A.compLength === A.origLength) A.data = new Uint8Array(x);
1090
- else if (A.data = Lt(x), A.data.length !== A.origLength) if (A.data.length < A.origLength) {
1090
+ else if (A.data = Pt(x), A.data.length !== A.origLength) if (A.data.length < A.origLength) {
1091
1091
  const y = new Uint8Array(A.origLength);
1092
1092
  y.set(A.data), A.data = y;
1093
1093
  } else A.data = A.data.subarray(0, A.origLength);
@@ -1098,7 +1098,7 @@ function Pt(a) {
1098
1098
  const u = 16 * l, m = 16 * c - u;
1099
1099
  let p = 12 + 16 * c;
1100
1100
  const g = {};
1101
- for (const A of n) g[A.tag] = p, p = Y(p + A.data.length);
1101
+ for (const A of n) g[A.tag] = p, p = X(p + A.data.length);
1102
1102
  const d = new Uint8Array(Math.max(r || 0, p));
1103
1103
  t.writeUint(d, 0, i), t.writeUshort(d, 4, c), t.writeUshort(d, 6, u), t.writeUshort(d, 8, f), t.writeUshort(d, 10, m);
1104
1104
  let v = 12;
@@ -1108,10 +1108,10 @@ function Pt(a) {
1108
1108
  if (A.tag === "head" && x.length >= 12) {
1109
1109
  const y = new Uint8Array(x);
1110
1110
  t.writeUint(y, 8, 0);
1111
- const U = k(y, 0, Y(y.length));
1112
- t.writeUint(d, v, U), v += 4;
1111
+ const L = V(y, 0, X(y.length));
1112
+ t.writeUint(d, v, L), v += 4;
1113
1113
  } else {
1114
- const y = k(x, 0, Y(x.length));
1114
+ const y = V(x, 0, X(x.length));
1115
1115
  t.writeUint(d, v, y), v += 4;
1116
1116
  }
1117
1117
  t.writeUint(d, v, g[A.tag]), v += 4, t.writeUint(d, v, A.data.length), v += 4;
@@ -1121,17 +1121,17 @@ function Pt(a) {
1121
1121
  d.set(A.data, x);
1122
1122
  }
1123
1123
  if (n.find((A) => A.tag === "head")) {
1124
- const A = g.head, x = function(y, U) {
1125
- const T = w, R = U + 8, F = [y[R], y[R + 1], y[R + 2], y[R + 3]];
1124
+ const A = g.head, x = function(y, L) {
1125
+ const T = w, R = L + 8, F = [y[R], y[R + 1], y[R + 2], y[R + 3]];
1126
1126
  T.writeUint(y, R, 0);
1127
- const B = 2981146554 - (k(y, 0, Y(y.length)) >>> 0) >>> 0;
1128
- return y[R] = F[0], y[R + 1] = F[1], y[R + 2] = F[2], y[R + 3] = F[3], B >>> 0;
1127
+ const U = 2981146554 - (V(y, 0, X(y.length)) >>> 0) >>> 0;
1128
+ return y[R] = F[0], y[R + 1] = F[1], y[R + 2] = F[2], y[R + 3] = F[3], U >>> 0;
1129
1129
  }(d, A);
1130
1130
  t.writeUint(d, A + 8, x);
1131
1131
  }
1132
1132
  return d.buffer;
1133
1133
  }
1134
- const Mt = { parseTab(a, t, e) {
1134
+ const _t = { parseTab(a, t, e) {
1135
1135
  const i = { tables: [], ids: {}, off: t };
1136
1136
  a = new Uint8Array(a.buffer, t, e), t = 0;
1137
1137
  const s = w, r = s.readUshort, n = r(a, t += 2);
@@ -1168,7 +1168,7 @@ const Mt = { parseTab(a, t, e) {
1168
1168
  const s = new Uint32Array(3 * i);
1169
1169
  for (let r = 0; r < 3 * i; r += 3) s[r] = e(a, t + (r << 2)), s[r + 1] = e(a, t + (r << 2) + 4), s[r + 2] = e(a, t + (r << 2) + 8);
1170
1170
  return { format: 12, groups: s };
1171
- } }, _t = { parseTab(a, t, e) {
1171
+ } }, Dt = { parseTab(a, t, e) {
1172
1172
  const i = w;
1173
1173
  t += 18;
1174
1174
  const s = i.readUshort(a, t);
@@ -1181,7 +1181,7 @@ const Mt = { parseTab(a, t, e) {
1181
1181
  t += 2;
1182
1182
  const c = i.readShort(a, t);
1183
1183
  return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
1184
- } }, Dt = { parseTab(a, t, e) {
1184
+ } }, St = { parseTab(a, t, e) {
1185
1185
  const i = w;
1186
1186
  t += 4;
1187
1187
  const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
@@ -1190,16 +1190,16 @@ const Mt = { parseTab(a, t, e) {
1190
1190
  r[o] = c(a, t + 2 * n);
1191
1191
  }
1192
1192
  return r;
1193
- } }, Ot = { parseTab(a, t, e, i) {
1193
+ } }, Bt = { parseTab(a, t, e, i) {
1194
1194
  const s = w, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1195
1195
  let l = 0, f = 0, u = 0;
1196
1196
  for (; u < c; ) l = s.readUshort(a, t + (u << 2)), f = s.readShort(a, t + (u << 2) + 2), r.push(l), n.push(f), u++;
1197
1197
  for (; u < o; ) r.push(l), n.push(f), u++;
1198
1198
  return { aWidth: r, lsBearing: n };
1199
- } }, tt = { cmap: Mt, head: _t, hhea: Dt, maxp: { parseTab(a, t, e) {
1199
+ } }, tt = { cmap: _t, head: Dt, hhea: St, maxp: { parseTab(a, t, e) {
1200
1200
  const i = w;
1201
1201
  return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
1202
- } }, hmtx: Ot, loca: { parseTab(a, t, e, i) {
1202
+ } }, hmtx: Bt, loca: { parseTab(a, t, e, i) {
1203
1203
  const s = w, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1204
1204
  if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
1205
1205
  else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
@@ -1248,7 +1248,7 @@ const Mt = { parseTab(a, t, e) {
1248
1248
  return o;
1249
1249
  } } }, P = { parse(a) {
1250
1250
  const t = new Uint8Array(a), e = w.readASCII(t, 0, 4);
1251
- if (e === "wOFF") a = Pt(a);
1251
+ if (e === "wOFF") a = Mt(a);
1252
1252
  else if (e === "wOF2") throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");
1253
1253
  return [((i, s, r, n) => {
1254
1254
  const o = tt, c = { Je: i, si: s, ti: r };
@@ -1274,7 +1274,7 @@ const Mt = { parseTab(a, t, e) {
1274
1274
  }
1275
1275
  return null;
1276
1276
  }, T: tt, B: w };
1277
- class St {
1277
+ class Ot {
1278
1278
  ei(t) {
1279
1279
  var i;
1280
1280
  const e = [];
@@ -1351,11 +1351,11 @@ class Z {
1351
1351
  for (const n of s.tables) if (n.format === 4 ? r = this.fi(e, n) : n.format === 12 && (r = this.di(e, n)), r > 0) break;
1352
1352
  return this.ai.set(i, r), r;
1353
1353
  }
1354
- _i(t, e) {
1354
+ pi(t, e) {
1355
1355
  const i = e.codePointAt(0);
1356
1356
  return i === void 0 ? 0 : this.li(t, i);
1357
1357
  }
1358
- pi(t, e) {
1358
+ _i(t, e) {
1359
1359
  const i = t.hmtx;
1360
1360
  return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1361
1361
  }
@@ -1398,27 +1398,27 @@ class Z {
1398
1398
  }
1399
1399
  class It {
1400
1400
  constructor(t) {
1401
- h(this, "Ai");
1402
1401
  h(this, "yi");
1402
+ h(this, "Ai");
1403
1403
  h(this, "xt");
1404
1404
  h(this, "Ci");
1405
- this.xt = t, this.Ci = new Z(), this.Ai = document.createElement("canvas"), this.yi = this.Ai.getContext("2d", { willReadFrequently: !0, alpha: !0 });
1405
+ this.xt = t, this.Ci = new Z(), this.yi = document.createElement("canvas"), this.Ai = this.yi.getContext("2d", { willReadFrequently: !0, alpha: !0 });
1406
1406
  }
1407
1407
  createTextureAtlas(t, e, i, s) {
1408
1408
  const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o, f = typeof s == "object" ? s : null;
1409
1409
  this.wi(c, l), this.bi(t, e, n, i, f);
1410
- const u = this.xt.je(c, l, 1, { filter: "nearest" });
1411
- return u.Tt(this.Ai), { framebuffer: u, columns: n, rows: o };
1410
+ const u = this.xt.Ye(c, l, 1, { filter: "nearest" });
1411
+ return u.Tt(this.yi), { framebuffer: u, columns: n, rows: o };
1412
1412
  }
1413
1413
  wi(t, e) {
1414
- this.Ai.width = t, this.Ai.height = e, this.Ai.style.width = t + "px", this.Ai.style.height = e + "px", this.yi.imageSmoothingEnabled = !1, this.Ai.style.imageRendering = "pixelated", this.yi.clearRect(0, 0, t, e), this.yi.textBaseline = "top", this.yi.textAlign = "left", this.yi.fillStyle = "white";
1414
+ this.yi.width = t, this.yi.height = e, this.yi.style.width = t + "px", this.yi.style.height = e + "px", this.Ai.imageSmoothingEnabled = !1, this.yi.style.imageRendering = "pixelated", this.Ai.clearRect(0, 0, t, e), this.Ai.textBaseline = "top", this.Ai.textAlign = "left", this.Ai.fillStyle = "white";
1415
1415
  }
1416
1416
  bi(t, e, i, s, r) {
1417
1417
  const n = s / r.head.unitsPerEm;
1418
1418
  for (let o = 0; o < t.length; o++) {
1419
1419
  const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.xi(r, f);
1420
1420
  if (!u) continue;
1421
- const m = f.codePointAt(0) || 0, p = this.Ci.li(r, m), g = this.Mi(r, p) * n, d = c * e.width, v = l * e.height, A = d + 0.5 * e.width, x = v + 0.5 * e.height, y = Math.round(A - 0.5 * e.width), U = Math.round(x - 0.5 * s), T = y + 0.5 * (e.width - g), R = U + r.hhea.ascender * n;
1421
+ const m = f.codePointAt(0) || 0, p = this.Ci.li(r, m), g = this.Mi(r, p) * n, d = c * e.width, v = l * e.height, A = d + 0.5 * e.width, x = v + 0.5 * e.height, y = Math.round(A - 0.5 * e.width), L = Math.round(x - 0.5 * s), T = y + 0.5 * (e.width - g), R = L + r.hhea.ascender * n;
1422
1422
  this.Fi(u, T, R, n);
1423
1423
  }
1424
1424
  }
@@ -1440,39 +1440,39 @@ class It {
1440
1440
  if (!t || !t.xs || t.noc === 0) return;
1441
1441
  const { xs: r, ys: n, endPts: o, flags: c } = t;
1442
1442
  if (!(r && n && o && c)) return;
1443
- this.yi.beginPath();
1443
+ this.Ai.beginPath();
1444
1444
  let l = 0;
1445
1445
  for (let f = 0; f < o.length; f++) {
1446
1446
  const u = o[f];
1447
1447
  if (!(u < l)) {
1448
1448
  if (u >= l) {
1449
1449
  const m = e + r[l] * s, p = i - n[l] * s;
1450
- this.yi.moveTo(m, p);
1450
+ this.Ai.moveTo(m, p);
1451
1451
  let g = l + 1;
1452
1452
  for (; g <= u; )
1453
1453
  if (1 & c[g]) {
1454
1454
  const d = e + r[g] * s, v = i - n[g] * s;
1455
- this.yi.lineTo(d, v), g++;
1455
+ this.Ai.lineTo(d, v), g++;
1456
1456
  } else {
1457
1457
  const d = e + r[g] * s, v = i - n[g] * s;
1458
1458
  let A = g + 1 > u ? l : g + 1;
1459
1459
  if (1 & c[A]) {
1460
1460
  const x = e + r[A] * s, y = i - n[A] * s;
1461
- this.yi.quadraticCurveTo(d, v, x, y), g = A + 1;
1461
+ this.Ai.quadraticCurveTo(d, v, x, y), g = A + 1;
1462
1462
  } else {
1463
1463
  const x = (d + (e + r[A] * s)) / 2, y = (v + (i - n[A] * s)) / 2;
1464
- this.yi.quadraticCurveTo(d, v, x, y), g = A;
1464
+ this.Ai.quadraticCurveTo(d, v, x, y), g = A;
1465
1465
  }
1466
1466
  }
1467
- this.yi.closePath();
1467
+ this.Ai.closePath();
1468
1468
  }
1469
1469
  l = u + 1;
1470
1470
  }
1471
1471
  }
1472
- this.yi.fill();
1472
+ this.Ai.fill();
1473
1473
  }
1474
1474
  }
1475
- class zt {
1475
+ class Nt {
1476
1476
  constructor() {
1477
1477
  h(this, "zi");
1478
1478
  this.zi = new Z();
@@ -1481,9 +1481,9 @@ class zt {
1481
1481
  let s = 0;
1482
1482
  const r = this.zi.mi(i, e), n = r.lineHeight;
1483
1483
  for (const o of t) {
1484
- const c = this.zi._i(i, o);
1484
+ const c = this.zi.pi(i, o);
1485
1485
  if (c === 0) continue;
1486
- const l = this.zi.pi(i, c) * r.scale;
1486
+ const l = this.zi._i(i, c) * r.scale;
1487
1487
  s = Math.max(s, l);
1488
1488
  }
1489
1489
  return { width: Math.ceil(s), height: Math.ceil(n) };
@@ -1492,7 +1492,7 @@ class zt {
1492
1492
  this.zi.gi();
1493
1493
  }
1494
1494
  }
1495
- class Nt {
1495
+ class zt {
1496
1496
  constructor() {
1497
1497
  h(this, "Ci");
1498
1498
  this.Ci = new Z();
@@ -1512,12 +1512,12 @@ class Nt {
1512
1512
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1513
1513
  }
1514
1514
  Pi(t, e) {
1515
- if (!N.m(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1515
+ if (!z.v(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1516
1516
  const i = e.find((s) => s.character === t);
1517
1517
  return i ? i.color : [0, 0, 0];
1518
1518
  }
1519
1519
  Si(t, e) {
1520
- return N.m(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Pi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1520
+ return z.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((i) => this.Pi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1521
1521
  }
1522
1522
  }
1523
1523
  class Gt {
@@ -1527,16 +1527,17 @@ class Gt {
1527
1527
  h(this, "Di");
1528
1528
  h(this, "ki", 16);
1529
1529
  h(this, "Bi", 0);
1530
- h(this, "Li", 0);
1531
- h(this, "Oi", { width: 0, height: 0 });
1532
- h(this, "Gi");
1530
+ h(this, "Oi", 0);
1531
+ h(this, "Li", { width: 0, height: 0 });
1533
1532
  h(this, "Hi");
1533
+ h(this, "Gi", /* @__PURE__ */ new Map());
1534
1534
  h(this, "Ii");
1535
1535
  h(this, "Ni");
1536
1536
  h(this, "Xi");
1537
- this.ki = e, this.Hi = new St(), this.Ii = new It(t), this.Ni = new zt(), this.Xi = new Nt();
1537
+ h(this, "Wi");
1538
+ this.ki = e, this.Ii = new Ot(), this.Ni = new It(t), this.Xi = new Nt(), this.Wi = new zt();
1538
1539
  }
1539
- async Wi(t) {
1540
+ async Ki(t) {
1540
1541
  let e;
1541
1542
  if (t) {
1542
1543
  const i = await fetch(t);
@@ -1544,20 +1545,20 @@ class Gt {
1544
1545
  e = await i.arrayBuffer();
1545
1546
  } else
1546
1547
  e = await (await fetch("data:font/woff;base64,d09GRgABAAAAABbwAAoAAAAAfywAAQABAAAAAAAAAAAAAAAAAAAAAAAAAABjbWFwAAAA9AAAAbsAAAkgIO8lSWdseWYAAAKwAAAOfgAAaLS4ctN0aGVhZAAAETAAAAAsAAAAOCi8/PVoaGVhAAARXAAAABkAAAAkCwEFAmhtdHgAABF4AAAAhQAABAQEAIOAbG9jYQAAEgAAAAKUAAAECAAy54BtYXhwAAAUlAAAABgAAAAgASIAgm5hbWUAABSsAAAB5wAAA6RWz85KT1MvMgAAFpQAAABFAAAAYM+QEyRwb3N0AAAW3AAAABQAAAAgAGkANHja7dRPSFRRFMfx38wdXblw4cJC7M0bz60gWlULGUFctWgR0UIQQkmDyn27kpAQaaEO2jhWJuafiQFtcDJtSqGhiFZtot5x3jzEVQQhlRJcOb0khiRc1+J94R64uw8cOADCAJT/avwZAiIpRCK3/P999KAS9biOSUxhBhlksYjnWMFrvME7vMca1vEF37ANAwkNqYRKqkk1rdLqscqpVVVQryzbils3rJnocHTWPmgfso/ap+0OuysWjlXHogQKUxVVUw3VUh010DE6QXHqph7qpT66TQmaoAxlaZnyVKC39FHHdbNu0e36or6kr4r4TgsTu75HmEcOy76vUPaVsIFNbOHHX74F3/fyD9+A7ztg1//2de76rH18Z8u+AXqwx/dBN5Z9XfqKiKzLqqzIC8nLkixKThZkXuZkVh7KuNyTuzImKRmVO1KxU7ETMtvmu/lqPptPxjOuKXo3vcveYQ+l2lKlO+Im3H632z3vnis+KaaLKc7zM87yHGc4zdM8zkke5H6+xp3cwRe4jVv5DLdwE5/ik3ycj3Cdk3eWnKfOmDPqJJ3hX9sOCvpPC65QcIWCgv5pPwGY9ak7AHja3V07ryQ5FT62axjQaDWsVmiCFQJpA4QINiAgICDYgICAgICAgICAgICAgIAA//AuF9Xlsn2etqv67iIY6apv3+6yj31e33nYA95FiD4uAAHeA7jyLzoA2Paf/Lp/Dun5W8x/Be/AxyCfO79fnj+e25/ZZzlewcM+3wIhwpfwE/Sc9e8YDyLU1ycF5XUD+to+L98O/An8VKQj0lnOtYdM776OJ71fTVC8//N1rLKDGsXl863OjSl5/iyIUu0HjJ+d+uO3rX3rXd33d/DjfR0/h6/n1iK5kWf36Hf2AxpVa6zU7ZLTnt3Q3wN7+tK6MVcBjUP/3vj56diHuT3YxVbKSvl9FdJHeFE4jfmJn2DSSOS9fuJ27SH7umuoL3oLWGOLxh3f2b8bnn/5Ql8n5SEYFD33q/0lKXxwjQfDOZtGgyEz+W8X5txl2zVb9MXO2S8HfD3ncbHousP6WPV2i/R7C+c06HK5ye/lfdl3Bj5Q2qitaLYhgLQWZY+fr/65A9Ly1r10jI783HOffJWZJ6ee8uuB0nmMXeSqWvRz5Dx/tiWf7H0OF+1DuK7vhy4ffP8An/doofqbQNXTqmlNT1c0v4/Eqpy29eBMLHty0PKZoCMW6VqRlDXNwvbD4RW2MYfyjNdXV3LaJuEdKgXcHvX2nHiz27RxHmC9w/qn0AbS+mJbSeX8pO1zlbbogPK7zJxAs3iFtrV8W/LHsHVZvxJ6Rlt7gum1nvjpnHNO4gFJqaoBWOKFVwKqAangorb2j5KKvG5N31O1ownZdhcZH7FuT9nznoxRv4ylrbfvzA9D88GO8uGDtgN0/1O09ntFlv3YhbIf/ml3/dPGqvi6rCMw6jNd53PM07BnK2eCJXmnzxrruI8ObOuxmZ/dxbd5nS77U7I/xaMdLm5/DXzuLLcwXlOLIVQ0an722pou6raGnpp/QYiwR0V5nwDL0Gk/f2TSUalIGOkSvfNAcVNCesV9a2q675FtsVAk4c5GPEfZT27XVqT9PmpxXtVn0577KO3MGrkXs+xKkHZk6EMUS440uO01t+Ark8yGYYjtsleqoPQksLuF0kOd/7TtbZ3XvNalNRNLqK+90fEDTAfy1FWWOBcT9fkTmrExe+viDNccYF+JqHeIbyBtlYxhStbmSc8DSX9/rICoXkkGSMfEJR7QsYAjNlhgn6iNS7T0AtakNnvaJ+W1TeQdeIxHaHtXaMtU+GP3CL5v+2RqHfc5JC6k9DJ6HhFaHHfu9Lc1Z5HlB5JWNOc8NupiUSlpa/7NIx0W0Ra10YcOVWnDfqhodmgI1CM5nrJS1DYKlMmyeAmoZaLrQnmNSRxAV7qZ0u0sr2Q8WbzUrRivE200nZ+x371Yj+idQH+bsOAFD16woZXuheBJI85UYyA+Ht17bJsTKLHHG+tuQpJX/AGX4eu2lq+vh8gQPgaLUpk1h7fcb1SJ4LEnGb+rdUHRHw96riVV36L5EgdqHNByqCTy82hnkrSSk3k5KTNWnJZ/buTlOvQngiceAkd4OHPz0K+tdOmGUYwJht2kcuBEntSRPOmZfyc40tFqD40IQeb2goGZvKIVzW4G5DMcQ4qOY3zVRzpmo1sMg+U1VemumtLofjFeCcxqJIUnM2vJuQeCHiOOwx4ss7pF6u+PtXxmZApbjCti22JtA+hVxUw7z6Xs2sSzMkeklSLPfwalYkjjt/0bHye4gKkXeaig5MpILVRiAd1vCrtP5Aj5uaN2PF1zxrE7koOgaY2PPL9FkccCKlprUZGr+zr0tw56iCvwGBTs+MFFxVbWeTaCQTj2WCBM1NnoWNxOBpBZU8f00hPsFDr+15wPevNsJG4IN+OGwKyWzKnW8S/GDUHZOd+44SsvbDvCuhYUTQSaQSFeWtoR4Xc833VimVzRvgm58QwZFQTthQ+awgQTeuVI7gLrF638Yixi+ot4RVZ5niDPFxBediyXNj++jUWDgkU3Zc96fDKwv4iiylyA4nalMkLX9C1hf24DNNkZyNDkflOPF4BqwdYbv1vLG9VX03W96PVKiCq+A01i5utY2d9YfSMP0qvQ7eFQUHSKvNfpCl21nqNafqf1UQksqfVe1PEPPNiJpY81iZoP119ZTUHojdpseMYqec5zr/2Jgo695rmycZWzSgOpXzMpbFrHu1Zmq/xA8pX3cgEQZU1/YzaexuQbXIoxF9THdaEzz9VaE5fgNVIPR/sIS8fQyipam9JXqHdOtPEIRllqzP7Ewh9063Z2IYH+GiLNUPFXJIcEM4RYc7bEkjwQL4/1fx+aHL8/62Of5vo3y+p92QX2fh18zrNFcPX9sfZAdBDZu8vxCM4clX31Qr9RrLPkDDDau8v8LZRar2N8lSOj1NGsLJeBZam1TIuwpzwepL3CJAvyANsPnj3BAzsD3a5X6ydEaZUSs50b7g2JrYcyG2lRL+xl+jD+Gfod33w82P0FTuYREa3c70CRS82XCtxIueJHXuIMB6tMt+x7lf7m5U4tyK9L3smuLrxqDxYPI30rYzk2h2NzgPXqAvPrQdqUxvdWF2zVwDrHCq0RoI0Hcrzcn9D8BMxYEMszZBzooqa/jsTxSeTthXTm9FC2n+pYEh8uVqyL9436quMD6pnK7njZM6msy4uYsunVquBSi4clVn8gblYc96TFyF04ll2oqCB300cDIbPxrZoqXZ1DHWvNh2irrNxstSaZYa2VB333tOr9mRcx7ETmXKmSFz6GkidstKjZFE8qIX26eG8KoS/b9uij9GFOiwFIVj5NyErT8rZGstdmD4lc4/xaNevd1uwOPCLX7Ems2TTc81MrUVmzyqdOr1v1PCPat9jmQfUYJEEbzNCSse4DevSYCIXal+bDCC3I2+EeTFKd7ltnFNN0sGLIfRcGfSWKD0BPANWTQIqcNtsaAON/1A/BeywPGhybs2ZEA1sH9FbgDMpTQx5L5k4fN/RR8lBHvif2ftB7oa8isVdrdWDxp/Hp6N8MsdUgqdS0M12EZrhC7TpJZZLZOZelRdeDUyffq3s6xPhztK4Xd9h6f4pIieNu4lI/jEN1XEMjbafK6lry/jkOYedyVMyp2vaHGlM8zBjCkdi28NdrNldgLa/a0orYtN6OwoMh7vPAsxb9eNTDrOdJBWuXsb6En8Evb5yTrJw1Y1XTHnmCFNtPkhHnuN+8QwHGi3JUJf4zeaTJsBpFdnik5V4fZq510ifEHMf7M55f2fteR1DJ73gzf4vyO42Or3Z5mZcWdlY6wb3sRvd0olKfGeaCWm5yGEtDwzLH6yPS95wmcVb2BBrYzig5tGb7Bvb5fkyfvW2nRhlxF3cyz8qGOF//eVLXq7P4oQTop9UASTKPr91h1zu5wu753DbqtXUO8pOT6wzdnQfWn2X3Csr5ktxP4FUmlBHHPThBO0mQ6wTFVxbM5mPCeXWP7ha4YDf8BdvAeaGd/XntlgHlW2eMFAR2CBPYAQzPrGeVy1ieYCOQdtpXGZyss4F2rkr5W8tJh06NTd/HGi+1vbiPN6JTeSfP5k0ihAhRQwgad9wQ1dhoKAntU87DfZy/K8SuEsPg82VQRU5xUGU+ZVrp8SMYtOHiwFC+Z1jLG2dqRuhAw01cZ2qeXBk/ROjaAS1TIuKHVp+Fi5YMrHqqahlY3YbJ0E/N2uUTq/0Cvt717Vfwa/gNfAO/hd/B7+EP8Ef4E/wZ/gJ/hb/B3+Ef8E/4F/z7nla+5T+Afp1wHdQRH/F/+/lF6VrSbuP4v/18VHMVmm7q6TX/Czha0mxJrf+YyNyOfRcYeKSap3+b8UufB8GnJSdec6Iu+toF6nHkaeZxvJ5h4PVgj3ILMz5teArdxnr8/PPoCXqiuvR91zoh2pvS8b0SqUD1FLPubHPaK9Q5lU+GzwI3PgfCOsB9NORgqm5OqfVxLMd1L9+A/s2s+0/0a93MTd3NNRHapruGQLnhZTSzpBMuYFNaz7N5RffPo/MnV2zac3wfRX6Vng0As1cTmE5M38U0eS+H0rvZxXtg6460jlQTZ3Snxw+pO9TKz+mOB5vffTs6umGj+UjMb3/QKfndvlP47UsVAO9Drzo11h+T/rF09Po0st98jHsKh31Ruj2UnbYWLuEd/pM9wOwpZ+KqccfWNZsc4F6c3jtf2ou7Ca6akqXRPThzsadua+/4hq7vgmn6uqux6bXw6AjnLMJbXMM5Ixwi8mR2rc3AOfg2nrs4zZlnDFaChbCtk/bwilwMfBxc0iMYy0MX40x2o/ft9D2Znn9Kl+3MO90HUb747jnzjpyCKVeTuij6DllsctyiUzXN0dgE9We1yK54WBffFqtew9TXpbYfy7dILWH/SXxmqeg4zlvRsZfIbuFnic0SHfRtfj4vsaVq532jl/QpYBykzpe/jec7n1uOmhuETi2xzM5vfy01xQC0vkp6PiKpDd07x6qcUc719K0A1YZjpvLivftqNpzxV/tDtXPTWFrbaowzXj+czsG+nmMt/bQspzj7fnvxeeuG4O/s/Xe412VW3+5VuPT+EV97/r++14Gc3ZvQRHrXMz91IrWHZ4FnK7WOVGjJPfAO3R0BczdLKuevQd5LPVsXd/X8PK6Ll2jK0/NM7P4V1PuI51FvsEMV+KhV4T2+22IQF85a0FlLWXs/IHTOX1B5CGCeEDh6V2ZiTK+eee/dnNjOa2xXz2zndd7sq+XYEZ/Gx/exoK5PoOceWNdnef9W9KCT9EYXqkrPxuhC9GA7faMXpHef1smLTDe1qaDY1N4ozLI4fqsHlwpf+3Cu9F1E/Z4AajG3V8430/6bCdq8QQs9b4OqJyQa1+6BACWaTPI8zrROa//7QGJ19U4tHeTTtePNqu3PnVhXJFSjzZFz4eo3Ndqidi/O6J5Z7X+VsS3cYki51T35Iv+merFeuGe69cbJM3Jq1Fn4kUA5rze4o9CRs22iy5jMsYLMS8g5/wOjbDW/AAB42mNgZGBgAOIzT9tXxvPbfGVgYGEAgZokCXVkmgUizsHABFLNwAAACJYG1HjaY2BkYGBhAAEIyc7AwMiAAhgZAQHPABQAAAB42r1TwRaAIAgD88P59PRA0hxUlw578mBDQOwi0i+oDUzb7nC/xyKH8SuwHH/jSx83jnE745c1RO44G9E1WTE14AQtYvKO6PN6BXRW5EONgCazSS4VXiere+sp7F7cQeSp7Pe2YkaxN7fVFhg/8z/1hfnfaBXnZ8k7wNzp/y13+wRWwErCAAAAeNpl0ylUVVEUBuCtoiKgoiIzAjIIMj9mZBZYMsmMjwcuBhEIBoPBYDAYDAaDwWA0GAwGgsFgMBgMBoPBYDAYDAaDweBnlrX+9e6955x/2oeI//664HbEgTL4HnHwZ8Sh1/AlIm0W3kUc3oN9+BFxJBva4E3E0SvwLCIdR/qniGO98Coiw3vG04hMv5n/fj9GZBUD3iz8xx9FnMiBJxEn0+E+/IrIppNt/VQzvITfEadH4HnEmUG4BV8jchaBn7NZgCMXdy7uXGfzeMjjKZ/PfBwF9hTYU/AhotC5QtpFtIt4K7oLnyOK6RXTKP4TUcJDCe5zNXAHcJTiKOWxlEZZPeAo00U5b+XyltM9vw24KvBWyFzpTOWLiCr5qu6BPdV0qx+Cni+sAc4a3mvw1nqu/RZxsRJkrEsDWeo2wAzq8dY/iGgwpwbfGvTdaA6NOmnUb5PnpiTY00S3SXfN/DU/BustdFrMq8VagqcE/YReEjK3+t4qayuPbTTbdNH2PqJdL+06a5e33VoHjg7vHdY7cXTK2ekedPHWha+b5279ddPo1ndPPuDrkbkH3yX5e/XXy3OvzH34+sy132+//P14B/AO6GuA3qBOB3U6hH/It2Haw2Y2rI9hHV6WdcSsR6eAl1GZx3Qwpr9xcxv3PqGDCbyTvE3KM+muT+lwypkpe6bNaZqfaX6v8j7D8wyNGbwzbyNmdTMrzxxfc9bndDFn5vM8zds37x4smMeCHhf5WTKHJb0uuc/L/C7bs4zrGr2kO5m0ntRZkv8VfazIkvI9RSelg5ReUrKvOrvqHq7p4Lr5retx3fcN/5Mb+Dfs25RpE/8mji0etqzfwLHteZufmzrZobfj/K5ednna0/fe/l+Pca7seNpjYGRgYGRkaGBQYAABJgY0AAAP+ACmeNp1ksFO20AQhv8NgRJaUApSy61LDxVc4uAjNxoJReoNKdCrYy8hZb1rrTcIuPMKfaY+QM899RH6AP3tDJEKqlcefzvzz/xrywD21ScoLK9N3ktW5E3hDl6hL7zG7HvhLrMfhNfxGonwBjUnwj2uz8JbzH4R3sZbPArvIMV34T28wQ+6qG6Puz5+Civyb+EOO/4Ir6GvOsJdaLUrvI53KhXeoGYs3MOu+iq8hai+CW/jo/olvIOiA+E97HeKw/xIp8M0nYQ6O/MunpvZwmbhafv01JK/MKGee6ePB8N/JCFzN6dO+8o4bee5cbnRM+NMyKyuFqHytdHR3MXSF0ZfNQOn93rVORoNm4l64ua3NMjsdYxVfZIkeTBZZC73ZeldPfBhllSLKR0KX2ZzlzyY4BO2JmNjrdeXPtjiAIfIcQTNbz/knWKCgBoZzuDhEHEOgxkWsMyFF9Xne/1Mf8Fdo5i3dY1jDOjz/ymB0eEGp63ao2J/Q5YT8pabqOnQsGn1lvuKjoHRc05Tj4x3jCUzRZu5Wp1winvGl54jruHqjI3C0fVW3qDxuWZ/pEvNPzjhylkxrETR5fQoW09HzYDPwJMm7emm8g5Fq8nIjpWHdronLV0TjJmxXJ4nuGwnWPYcAH8BoeumrAB42mNgYmFgnMDAysDCxMDEAAIQGoiNGc6A+CwMENDAwNDNwFDwGMpliHT00WNwYFBQy4aogJCMgSCSGcJTYGAAAEBYBpIAAAB42mNgZoCANAZjIMnIgAYADecAng==")).arrayBuffer();
1547
- await this.Ki(e), this.Ei = P.parse(e)[0], await this.Yi();
1548
+ await this.ji(e), this.Ei = P.parse(e)[0], await this.Yi();
1548
1549
  }
1549
- ji(t) {
1550
+ Vi(t) {
1550
1551
  if (t === void 0) return this.ki;
1551
- this.ki = t, this.Oi = this.Ni.Ri(this.$i.map((i) => i.character), this.ki, this.Ei);
1552
- const e = this.Ii.createTextureAtlas(this.$i, this.Oi, this.ki, this.Ei);
1553
- this.Di = e.framebuffer, this.Bi = e.columns, this.Li = e.rows;
1552
+ this.ki = t, this.Li = this.Xi.Ri(this.$i.map((i) => i.character), this.ki, this.Ei);
1553
+ const e = this.Ni.createTextureAtlas(this.$i, this.Li, this.ki, this.Ei);
1554
+ this.Di = e.framebuffer, this.Bi = e.columns, this.Oi = e.rows;
1554
1555
  }
1555
- async Vi(t) {
1556
+ async qi(t) {
1556
1557
  try {
1557
1558
  const e = await fetch(t);
1558
1559
  if (!e.ok) throw new C(`Failed to load font file: ${e.status} ${e.statusText}`);
1559
1560
  const i = await e.arrayBuffer();
1560
- await this.Ki(i);
1561
+ await this.ji(i);
1561
1562
  const s = P.parse(i);
1562
1563
  if (!s || s.length === 0) throw Error("Failed to parse font file");
1563
1564
  this.Ei = s[0], await this.Yi();
@@ -1565,24 +1566,58 @@ class Gt {
1565
1566
  throw new C("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1566
1567
  }
1567
1568
  }
1568
- async Ki(t) {
1569
+ async ji(t) {
1569
1570
  const e = Date.now();
1570
- this.Gi = new FontFace("CustomFont_" + e, t), await this.Gi.load(), document.fonts.add(this.Gi);
1571
+ this.Hi = new FontFace("CustomFont_" + e, t), await this.Hi.load(), document.fonts.add(this.Hi);
1571
1572
  }
1572
1573
  async Yi() {
1573
- const t = this.Hi.ei(this.Ei), e = this.Hi.ni(t);
1574
- this.$i = this.Xi.createCharacterObjects(e, this.Ei), this.Oi = this.Ni.Ri(e, this.ki, this.Ei);
1575
- const i = this.Ii.createTextureAtlas(this.$i, this.Oi, this.ki, this.Ei);
1576
- this.Di = i.framebuffer, this.Bi = i.columns, this.Li = i.rows;
1574
+ const t = this.Ii.ei(this.Ei), e = this.Ii.ni(t);
1575
+ this.Gi.clear(), this.$i = this.Wi.createCharacterObjects(e, this.Ei), this.Li = this.Xi.Ri(e, this.ki, this.Ei);
1576
+ const i = this.Ni.createTextureAtlas(this.$i, this.Li, this.ki, this.Ei);
1577
+ this.Di = i.framebuffer, this.Bi = i.columns, this.Oi = i.rows;
1577
1578
  }
1578
1579
  Pi(t) {
1579
- return this.Xi.Pi(t, this.$i);
1580
+ return this.Wi.Pi(t, this.$i);
1580
1581
  }
1581
1582
  Si(t) {
1582
- return this.Xi.Si(t, this.$i);
1583
+ return this.Wi.Si(t, this.$i);
1584
+ }
1585
+ getGlyphData(t) {
1586
+ if (!Number.isFinite(t)) return null;
1587
+ const e = this.Gi.get(t);
1588
+ if (e !== void 0) return e;
1589
+ const i = this.Zi(t);
1590
+ if (i < 0) return this.Gi.set(t, null), null;
1591
+ const s = this.Ei.glyf;
1592
+ if (!s) return this.Gi.set(t, null), null;
1593
+ let r = s[i] ?? null;
1594
+ return r == null && (r = P.T.glyf.Qe(this.Ei, i) ?? null, s[i] = r), this.Gi.set(t, r), r;
1595
+ }
1596
+ Zi(t) {
1597
+ const e = this.Ei.cmap;
1598
+ for (const i of e.tables) if (i.format === 4) {
1599
+ const s = i;
1600
+ for (let r = 0; r < s.startCount.length; r++) if (t >= s.startCount[r] && t <= s.endCount[r]) {
1601
+ if (s.idRangeOffset[r] === 0) return t + s.idDelta[r] & 65535;
1602
+ {
1603
+ const n = s.idRangeOffset[r] / 2 + (t - s.startCount[r]) - (s.startCount.length - r);
1604
+ if (n >= 0 && n < s.glyphIdArray.length) {
1605
+ const o = s.glyphIdArray[n];
1606
+ if (o !== 0) return o + s.idDelta[r] & 65535;
1607
+ }
1608
+ }
1609
+ }
1610
+ } else if (i.format === 12) {
1611
+ const s = i;
1612
+ for (let r = 0; r < s.groups.length; r += 3) {
1613
+ const n = s.groups[r], o = s.groups[r + 1], c = s.groups[r + 2];
1614
+ if (t >= n && t <= o) return c + (t - n);
1615
+ }
1616
+ }
1617
+ return 0;
1583
1618
  }
1584
1619
  Dt() {
1585
- this.Di.Dt(), document.fonts.delete(this.Gi);
1620
+ this.Di.Dt(), document.fonts.delete(this.Hi);
1586
1621
  }
1587
1622
  get fontFramebuffer() {
1588
1623
  return this.Di;
@@ -1594,10 +1629,10 @@ class Gt {
1594
1629
  return this.Bi;
1595
1630
  }
1596
1631
  get textureRows() {
1597
- return this.Li;
1632
+ return this.Oi;
1598
1633
  }
1599
1634
  get maxGlyphDimensions() {
1600
- return this.Oi;
1635
+ return this.Li;
1601
1636
  }
1602
1637
  get fontSize() {
1603
1638
  return this.ki;
@@ -1606,36 +1641,36 @@ class Gt {
1606
1641
  return this.Ei;
1607
1642
  }
1608
1643
  }
1609
- class Xt {
1644
+ class Ht {
1610
1645
  constructor(t, e, i) {
1611
- h(this, "qi");
1612
- h(this, "Zi");
1613
- h(this, "dt");
1614
- h(this, "_t");
1615
1646
  h(this, "Qi");
1616
1647
  h(this, "Ji");
1648
+ h(this, "dt");
1649
+ h(this, "_t");
1617
1650
  h(this, "tr");
1618
1651
  h(this, "sr");
1619
1652
  h(this, "er");
1620
- this.tr = t, this.sr = e, this.er = i, this.ir();
1653
+ h(this, "ir");
1654
+ h(this, "rr");
1655
+ this.er = t, this.ir = e, this.rr = i, this.nr();
1621
1656
  }
1622
- ir() {
1623
- this.qi = Math.floor(this.tr.width / this.sr), this.Zi = Math.floor(this.tr.height / this.er), this.dt = this.qi * this.sr, this._t = this.Zi * this.er, this.Qi = Math.floor((this.tr.width - this.dt) / 2), this.Ji = Math.floor((this.tr.height - this._t) / 2);
1657
+ nr() {
1658
+ this.Qi = Math.floor(this.er.width / this.ir), this.Ji = Math.floor(this.er.height / this.rr), this.dt = this.Qi * this.ir, this._t = this.Ji * this.rr, this.tr = Math.floor((this.er.width - this.dt) / 2), this.sr = Math.floor((this.er.height - this._t) / 2);
1624
1659
  }
1625
- rr(t, e) {
1626
- this.sr = t, this.er = e, this.ir();
1660
+ hr(t, e) {
1661
+ this.ir = t, this.rr = e, this.nr();
1627
1662
  }
1628
1663
  get cellWidth() {
1629
- return this.sr;
1664
+ return this.ir;
1630
1665
  }
1631
1666
  get cellHeight() {
1632
- return this.er;
1667
+ return this.rr;
1633
1668
  }
1634
1669
  get cols() {
1635
- return this.qi;
1670
+ return this.Qi;
1636
1671
  }
1637
1672
  get rows() {
1638
- return this.Zi;
1673
+ return this.Ji;
1639
1674
  }
1640
1675
  get width() {
1641
1676
  return this.dt;
@@ -1644,140 +1679,140 @@ class Xt {
1644
1679
  return this._t;
1645
1680
  }
1646
1681
  get offsetX() {
1647
- return this.Qi;
1682
+ return this.tr;
1648
1683
  }
1649
1684
  get offsetY() {
1650
- return this.Ji;
1685
+ return this.sr;
1651
1686
  }
1652
1687
  }
1653
- class Yt {
1688
+ class Xt {
1654
1689
  constructor(t = {}) {
1655
- h(this, "tr");
1656
- h(this, "nr", null);
1657
- h(this, "hr", !1);
1658
- h(this, "ar");
1659
- h(this, "cr");
1660
- this.hr = t.overlay ?? !1, this.hr && t.canvas ? (this.nr = t.canvas, this.tr = this.lr(), this.cr = !0, this.ur()) : t.canvas ? (this.tr = t.canvas, this.cr = !1) : (this.tr = this.dr(t.width, t.height), this.cr = !0), this.tr.style.imageRendering = "pixelated";
1690
+ h(this, "er");
1691
+ h(this, "ar", null);
1692
+ h(this, "cr", !1);
1693
+ h(this, "lr");
1694
+ h(this, "ur");
1695
+ this.cr = t.overlay ?? !1, this.cr && t.canvas ? (this.ar = t.canvas, this.er = this.dr(), this.ur = !0, this.pr()) : t.canvas ? (this.er = t.canvas, this.ur = !1) : (this.er = this._r(t.width, t.height), this.ur = !0), this.er.style.imageRendering = "pixelated";
1661
1696
  }
1662
- dr(t, e) {
1697
+ _r(t, e) {
1663
1698
  const i = document.createElement("canvas");
1664
1699
  return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1665
1700
  }
1666
- lr() {
1701
+ dr() {
1667
1702
  const t = document.createElement("canvas");
1668
1703
  t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
1669
- const e = this.nr.getBoundingClientRect();
1704
+ const e = this.ar.getBoundingClientRect();
1670
1705
  let i = Math.round(e.width), s = Math.round(e.height);
1671
- if (this.nr instanceof HTMLVideoElement) {
1672
- const o = this.nr;
1706
+ if (this.ar instanceof HTMLVideoElement) {
1707
+ const o = this.ar;
1673
1708
  (i === 0 || s === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, s = o.videoHeight);
1674
1709
  }
1675
1710
  t.width = i, t.height = s, t.style.position = "absolute", t.style.pointerEvents = "none";
1676
- const r = window.getComputedStyle(this.nr);
1711
+ const r = window.getComputedStyle(this.ar);
1677
1712
  let n = parseInt(r.zIndex || "0", 10);
1678
1713
  return isNaN(n) && (n = 0), t.style.zIndex = "" + (n + 1), t;
1679
1714
  }
1680
- ur() {
1715
+ pr() {
1681
1716
  var t;
1682
- this._r(), (t = this.nr.parentNode) == null || t.insertBefore(this.tr, this.nr.nextSibling), window.ResizeObserver && (this.ar = new ResizeObserver(() => {
1683
- this.pr();
1684
- }), this.ar.observe(this.nr)), window.addEventListener("resize", () => {
1685
- this.pr();
1717
+ this.mr(), (t = this.ar.parentNode) == null || t.insertBefore(this.er, this.ar.nextSibling), window.ResizeObserver && (this.lr = new ResizeObserver(() => {
1718
+ this.vr();
1719
+ }), this.lr.observe(this.ar)), window.addEventListener("resize", () => {
1720
+ this.vr();
1686
1721
  });
1687
1722
  }
1688
- _r() {
1689
- if (!this.nr) return;
1690
- const t = this.nr.getBoundingClientRect();
1691
- let e = this.nr.offsetParent;
1723
+ mr() {
1724
+ if (!this.ar) return;
1725
+ const t = this.ar.getBoundingClientRect();
1726
+ let e = this.ar.offsetParent;
1692
1727
  if (e && e !== document.body) {
1693
1728
  const i = e.getBoundingClientRect();
1694
- this.tr.style.top = t.top - i.top + "px", this.tr.style.left = t.left - i.left + "px";
1695
- } else this.tr.style.top = t.top + window.scrollY + "px", this.tr.style.left = t.left + window.scrollX + "px";
1729
+ this.er.style.top = t.top - i.top + "px", this.er.style.left = t.left - i.left + "px";
1730
+ } else this.er.style.top = t.top + window.scrollY + "px", this.er.style.left = t.left + window.scrollX + "px";
1696
1731
  }
1697
- pr(t, e) {
1698
- if (this.hr) {
1699
- const i = this.nr.getBoundingClientRect();
1732
+ vr(t, e) {
1733
+ if (this.cr) {
1734
+ const i = this.ar.getBoundingClientRect();
1700
1735
  let s = Math.round(i.width), r = Math.round(i.height);
1701
- if (this.nr instanceof HTMLVideoElement) {
1702
- const n = this.nr;
1736
+ if (this.ar instanceof HTMLVideoElement) {
1737
+ const n = this.ar;
1703
1738
  (s === 0 || r === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, r = n.videoHeight);
1704
1739
  }
1705
- this.tr.width = s, this.tr.height = r, this._r();
1706
- } else this.tr.width = t ?? this.tr.width, this.tr.height = e ?? this.tr.height;
1740
+ this.er.width = s, this.er.height = r, this.mr();
1741
+ } else this.er.width = t ?? this.er.width, this.er.height = e ?? this.er.height;
1707
1742
  }
1708
- vr() {
1709
- const t = this.tr.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1743
+ gr() {
1744
+ const t = this.er.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1710
1745
  if (!t) throw new C("`textmode.js` requires WebGL2 support.");
1711
1746
  return t;
1712
1747
  }
1713
1748
  Dt() {
1714
- this.ar && this.ar.disconnect();
1715
- const t = this.tr.getContext("webgl") || this.tr.getContext("webgl2");
1749
+ this.lr && this.lr.disconnect();
1750
+ const t = this.er.getContext("webgl") || this.er.getContext("webgl2");
1716
1751
  if (t) {
1717
1752
  const e = t.getExtension("WEBGL_lose_context");
1718
1753
  e && e.loseContext();
1719
1754
  }
1720
- this.cr && this.tr.parentNode && this.tr.parentNode.removeChild(this.tr);
1755
+ this.ur && this.er.parentNode && this.er.parentNode.removeChild(this.er);
1721
1756
  }
1722
1757
  get canvas() {
1723
- return this.tr;
1758
+ return this.er;
1724
1759
  }
1725
1760
  get targetCanvas() {
1726
- return this.nr;
1761
+ return this.ar;
1727
1762
  }
1728
1763
  get width() {
1729
- return this.tr.width;
1764
+ return this.er.width;
1730
1765
  }
1731
1766
  get height() {
1732
- return this.tr.height;
1767
+ return this.er.height;
1733
1768
  }
1734
1769
  }
1735
1770
  class G {
1736
1771
  constructor(t, e, i, s) {
1737
- h(this, "mr");
1772
+ h(this, "yr");
1738
1773
  h(this, "dt");
1739
1774
  h(this, "_t");
1740
1775
  h(this, "gt");
1741
1776
  h(this, "k", 0);
1742
1777
  h(this, "K", 0);
1743
- h(this, "Y", 0);
1744
- h(this, "L", [0, 0]);
1745
- h(this, "gr", "sampled");
1746
- h(this, "Ar", "fixed");
1778
+ h(this, "j", 0);
1779
+ h(this, "O", [0, 0]);
1780
+ h(this, "Ar", "sampled");
1781
+ h(this, "Cr", "fixed");
1747
1782
  h(this, "V", [1, 1, 1, 1]);
1748
1783
  h(this, "q", [0, 0, 0, 1]);
1749
- h(this, "yr", [0, 0, 0, 1]);
1750
- h(this, "Cr", [[0.1, 0, 0]]);
1751
- h(this, "wr");
1752
- this.gt = t, this.mr = e, this.dt = i, this._t = s;
1784
+ h(this, "wr", [0, 0, 0, 1]);
1785
+ h(this, "br", [[0.1, 0, 0]]);
1786
+ h(this, "Mr");
1787
+ this.gt = t, this.yr = e, this.dt = i, this._t = s;
1753
1788
  }
1754
1789
  Dt() {
1755
- this.gt.deleteTexture(this.mr);
1790
+ this.gt.deleteTexture(this.yr);
1756
1791
  }
1757
- br(t) {
1792
+ Fr(t) {
1758
1793
  return typeof t == "boolean" ? t ? 1 : 0 : (t == null ? 0 : Number(t)) > 0 ? 1 : 0;
1759
1794
  }
1760
1795
  invert(t = !0) {
1761
- return this.k = this.br(t), this;
1796
+ return this.k = this.Fr(t), this;
1762
1797
  }
1763
1798
  flipX(t = !0) {
1764
- return this.K = this.br(t), this;
1799
+ return this.K = this.Fr(t), this;
1765
1800
  }
1766
1801
  flipY(t = !0) {
1767
- return this.Y = this.br(t), this;
1802
+ return this.j = this.Fr(t), this;
1768
1803
  }
1769
1804
  charRotation(t) {
1770
1805
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
1771
- return this.L = [i, s], this;
1806
+ return this.O = [i, s], this;
1772
1807
  }
1773
- He() {
1774
- return { texture: this.mr, invert: this.k, flipX: this.K, flipY: this.Y, charRotation: this.L, charColorFixed: this.gr === "fixed", charColor: this.V, cellColorFixed: this.Ar === "fixed", cellColor: this.q, backgroundColor: this.yr, charCount: this.Cr.length, charList: this.Cr };
1808
+ Ge() {
1809
+ return { texture: this.yr, invert: this.k, flipX: this.K, flipY: this.j, charRotation: this.O, charColorFixed: this.Ar === "fixed", charColor: this.V, cellColorFixed: this.Cr === "fixed", cellColor: this.q, backgroundColor: this.wr, charCount: this.br.length, charList: this.br };
1775
1810
  }
1776
1811
  charColorMode(t) {
1777
- return this.gr = t, this;
1812
+ return this.Ar = t, this;
1778
1813
  }
1779
1814
  cellColorMode(t) {
1780
- return this.Ar = t, this;
1815
+ return this.Cr = t, this;
1781
1816
  }
1782
1817
  charColor(t, e, i, s) {
1783
1818
  return this.V = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
@@ -1786,20 +1821,20 @@ class G {
1786
1821
  return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1787
1822
  }
1788
1823
  background(t, e, i, s) {
1789
- return this.yr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1824
+ return this.wr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1790
1825
  }
1791
1826
  characters(t) {
1792
- const e = this.wr(t).filter((i) => Array.isArray(i)).slice(0, 64);
1793
- return this.Cr = e, this;
1827
+ const e = this.Mr(t).filter((i) => Array.isArray(i)).slice(0, 64);
1828
+ return this.br = e, this;
1794
1829
  }
1795
- static Mr(t, e, i) {
1830
+ static zr(t, e, i) {
1796
1831
  const s = t.context, r = s.createTexture();
1797
1832
  s.bindTexture(s.TEXTURE_2D, r), s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, 1), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, s.RGBA, s.UNSIGNED_BYTE, e), s.bindTexture(s.TEXTURE_2D, null);
1798
1833
  const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new G(s, r, n, o);
1799
- return c.wr = i, c;
1834
+ return c.Mr = i, c;
1800
1835
  }
1801
1836
  get texture() {
1802
- return this.mr;
1837
+ return this.yr;
1803
1838
  }
1804
1839
  get width() {
1805
1840
  return this.dt;
@@ -1808,289 +1843,287 @@ class G {
1808
1843
  return this._t;
1809
1844
  }
1810
1845
  }
1811
- class Wt {
1846
+ class Yt {
1812
1847
  constructor(t = 60) {
1813
- h(this, "Fr");
1814
- h(this, "zr");
1815
- h(this, "Rr", null);
1816
- h(this, "Tr", 0);
1817
- h(this, "Pr", !0);
1848
+ h(this, "Rr");
1849
+ h(this, "Tr");
1850
+ h(this, "Pr", null);
1818
1851
  h(this, "Sr", 0);
1819
- h(this, "Er", 0);
1820
- h(this, "$r", []);
1821
- h(this, "Dr", 10);
1822
- h(this, "kr", 0);
1823
- this.Fr = t, this.zr = 1e3 / t;
1852
+ h(this, "Er", !0);
1853
+ h(this, "$r", 0);
1854
+ h(this, "Dr", 0);
1855
+ h(this, "kr", []);
1856
+ h(this, "Br", 10);
1857
+ h(this, "Or", 0);
1858
+ this.Rr = t, this.Tr = 1e3 / t;
1824
1859
  }
1825
1860
  start(t) {
1826
- if (!this.Pr) return;
1827
- this.Tr = performance.now();
1861
+ if (!this.Er) return;
1862
+ this.Sr = performance.now();
1828
1863
  const e = (i) => {
1829
- if (!this.Pr) return void (this.Rr = null);
1830
- const s = i - this.Tr;
1831
- s >= this.zr && (t(), this.Tr = i - s % this.zr), this.Pr && (this.Rr = requestAnimationFrame(e));
1864
+ if (!this.Er) return void (this.Pr = null);
1865
+ const s = i - this.Sr;
1866
+ s >= this.Tr && (t(), this.Sr = i - s % this.Tr), this.Er && (this.Pr = requestAnimationFrame(e));
1832
1867
  };
1833
- this.Rr = requestAnimationFrame(e);
1868
+ this.Pr = requestAnimationFrame(e);
1834
1869
  }
1835
1870
  stop() {
1836
- this.Rr && (cancelAnimationFrame(this.Rr), this.Rr = null);
1871
+ this.Pr && (cancelAnimationFrame(this.Pr), this.Pr = null);
1837
1872
  }
1838
1873
  pause() {
1839
- this.Pr && (this.Pr = !1, this.stop());
1874
+ this.Er && (this.Er = !1, this.stop());
1840
1875
  }
1841
1876
  resume(t) {
1842
- this.Pr || (this.Pr = !0, this.start(t));
1877
+ this.Er || (this.Er = !0, this.start(t));
1843
1878
  }
1844
1879
  frameRate(t, e) {
1845
- if (t === void 0) return this.Sr;
1846
- this.Fr = t, this.zr = 1e3 / t, this.Pr && e && (this.stop(), this.start(e));
1880
+ if (t === void 0) return this.$r;
1881
+ this.Rr = t, this.Tr = 1e3 / t, this.Er && e && (this.stop(), this.start(e));
1847
1882
  }
1848
1883
  measureFrameRate() {
1849
1884
  const t = performance.now();
1850
- if (this.Er > 0) {
1851
- const e = t - this.Er;
1852
- this.$r.push(e), this.$r.length > this.Dr && this.$r.shift();
1853
- const i = this.$r.reduce((s, r) => s + r, 0) / this.$r.length;
1854
- this.Sr = 1e3 / i;
1885
+ if (this.Dr > 0) {
1886
+ const e = t - this.Dr;
1887
+ this.kr.push(e), this.kr.length > this.Br && this.kr.shift();
1888
+ const i = this.kr.reduce((s, r) => s + r, 0) / this.kr.length;
1889
+ this.$r = 1e3 / i;
1855
1890
  }
1856
- this.Er = t;
1891
+ this.Dr = t;
1857
1892
  }
1858
1893
  get isLooping() {
1859
- return this.Pr;
1894
+ return this.Er;
1860
1895
  }
1861
1896
  get frameRateLimit() {
1862
- return this.Fr;
1897
+ return this.Rr;
1863
1898
  }
1864
1899
  get currentFrameRate() {
1865
- return this.Sr;
1900
+ return this.$r;
1866
1901
  }
1867
1902
  get frameCount() {
1868
- return this.kr;
1903
+ return this.Or;
1869
1904
  }
1870
1905
  set frameCount(t) {
1871
- this.kr = t;
1906
+ this.Or = t;
1872
1907
  }
1873
1908
  incrementFrame() {
1874
- this.kr++;
1909
+ this.Or++;
1875
1910
  }
1876
1911
  resetFrameCount() {
1877
- this.kr = 0;
1912
+ this.Or = 0;
1878
1913
  }
1879
1914
  }
1880
1915
  class rt {
1881
1916
  constructor(t) {
1882
- h(this, "tr");
1883
- h(this, "Br");
1884
- h(this, "Lr", { x: -1, y: -1 });
1885
- h(this, "Or", { x: -1, y: -1 });
1886
- h(this, "Gr", null);
1887
- h(this, "Hr", 0);
1888
- h(this, "Ir");
1889
- h(this, "Nr");
1917
+ h(this, "er");
1918
+ h(this, "Lr");
1919
+ h(this, "Hr", { x: -1, y: -1 });
1920
+ h(this, "Gr", { x: -1, y: -1 });
1921
+ h(this, "Ir", null);
1922
+ h(this, "Nr", 0);
1890
1923
  h(this, "Xr");
1891
1924
  h(this, "Wr");
1892
1925
  h(this, "Kr");
1926
+ h(this, "jr");
1893
1927
  h(this, "Yr");
1894
- h(this, "jr", !1);
1895
1928
  h(this, "Vr");
1896
- h(this, "qr");
1929
+ h(this, "qr", !1);
1897
1930
  h(this, "Zr");
1898
1931
  h(this, "Qr");
1899
1932
  h(this, "Jr");
1900
- this.tr = t;
1933
+ h(this, "tn");
1934
+ h(this, "sn");
1935
+ this.er = t;
1901
1936
  }
1902
- tn(t) {
1937
+ en(t) {
1903
1938
  const e = performance.now() + Math.max(0, t);
1904
- e > this.Hr && (this.Hr = e);
1939
+ e > this.Nr && (this.Nr = e);
1905
1940
  }
1906
- sn() {
1907
- return performance.now() < this.Hr;
1941
+ rn() {
1942
+ return performance.now() < this.Nr;
1908
1943
  }
1909
- en(t) {
1910
- const e = this.tr.canvas;
1944
+ nn(t) {
1945
+ const e = this.er.canvas;
1911
1946
  e.style.cursor = t == null || t === "" ? "" : t;
1912
1947
  }
1913
- Wi(t) {
1914
- this.Br = t, this.rn();
1915
- }
1916
- nn() {
1917
- if (this.jr) return;
1918
- const t = this.tr.canvas;
1919
- this.Ir = (e) => {
1920
- this.hn(e), this.an(e);
1921
- }, this.Nr = () => {
1922
- this.Or = { ...this.Lr }, this.Lr.x = -1, this.Lr.y = -1, this.Gr = null;
1923
- }, this.Xr = (e) => {
1924
- this.hn(e), this.cn(e);
1925
- }, this.Wr = (e) => {
1926
- this.hn(e), this.ln(e);
1948
+ Ki(t) {
1949
+ this.Lr = t, this.hn();
1950
+ }
1951
+ an() {
1952
+ if (this.qr) return;
1953
+ const t = this.er.canvas;
1954
+ this.Xr = (e) => {
1955
+ this.cn(e), this.ln(e);
1956
+ }, this.Wr = () => {
1957
+ this.Gr = { ...this.Hr }, this.Hr.x = -1, this.Hr.y = -1, this.Ir = null;
1927
1958
  }, this.Kr = (e) => {
1928
- this.hn(e), this.un(e);
1959
+ this.cn(e), this.un(e);
1960
+ }, this.jr = (e) => {
1961
+ this.cn(e), this.fn(e);
1929
1962
  }, this.Yr = (e) => {
1930
- this.hn(e), this.fn(e);
1931
- }, t.addEventListener("mousemove", this.Ir, { passive: !0 }), t.addEventListener("mouseleave", this.Nr, { passive: !0 }), t.addEventListener("mousedown", this.Xr, { passive: !0 }), t.addEventListener("mouseup", this.Wr, { passive: !0 }), t.addEventListener("click", this.Kr, { passive: !0 }), t.addEventListener("wheel", this.Yr, { passive: !1 }), this.jr = !0;
1932
- }
1933
- dn() {
1934
- if (!this.jr) return;
1935
- const t = this.tr.canvas;
1936
- t.removeEventListener("mousemove", this.Ir), t.removeEventListener("mouseleave", this.Nr), t.removeEventListener("mousedown", this.Xr), t.removeEventListener("mouseup", this.Wr), t.removeEventListener("click", this.Kr), t.removeEventListener("wheel", this.Yr), this.jr = !1;
1937
- }
1938
- rn() {
1939
- if (this.jr) try {
1940
- if (this.Gr) {
1941
- const t = new MouseEvent("mousemove", { clientX: this.Gr.x, clientY: this.Gr.y, bubbles: !1, cancelable: !1 });
1942
- this.hn(t);
1943
- } else this.Lr.x !== -1 && this.Lr.y !== -1 && (this.Lr.x >= this.Br.cols || this.Lr.y >= this.Br.rows) && (this.Lr.x = -1, this.Lr.y = -1);
1963
+ this.cn(e), this.dn(e);
1964
+ }, this.Vr = (e) => {
1965
+ this.cn(e), this.pn(e);
1966
+ }, t.addEventListener("mousemove", this.Xr, { passive: !0 }), t.addEventListener("mouseleave", this.Wr, { passive: !0 }), t.addEventListener("mousedown", this.Kr, { passive: !0 }), t.addEventListener("mouseup", this.jr, { passive: !0 }), t.addEventListener("click", this.Yr, { passive: !0 }), t.addEventListener("wheel", this.Vr, { passive: !1 }), this.qr = !0;
1967
+ }
1968
+ _n() {
1969
+ if (!this.qr) return;
1970
+ const t = this.er.canvas;
1971
+ t.removeEventListener("mousemove", this.Xr), t.removeEventListener("mouseleave", this.Wr), t.removeEventListener("mousedown", this.Kr), t.removeEventListener("mouseup", this.jr), t.removeEventListener("click", this.Yr), t.removeEventListener("wheel", this.Vr), this.qr = !1;
1972
+ }
1973
+ hn() {
1974
+ if (this.qr) try {
1975
+ if (this.Ir) {
1976
+ const t = new MouseEvent("mousemove", { clientX: this.Ir.x, clientY: this.Ir.y, bubbles: !1, cancelable: !1 });
1977
+ this.cn(t);
1978
+ } else this.Hr.x !== -1 && this.Hr.y !== -1 && (this.Hr.x >= this.Lr.cols || this.Hr.y >= this.Lr.rows) && (this.Hr.x = -1, this.Hr.y = -1);
1944
1979
  } catch {
1945
- this.Lr.x = -1, this.Lr.y = -1;
1980
+ this.Hr.x = -1, this.Hr.y = -1;
1946
1981
  }
1947
1982
  }
1948
- _n(t) {
1949
- this.Vr = t;
1950
- }
1951
- pn(t) {
1952
- this.qr = t;
1953
- }
1954
- vn(t) {
1983
+ mn(t) {
1955
1984
  this.Zr = t;
1956
1985
  }
1957
- mn(t) {
1986
+ vn(t) {
1958
1987
  this.Qr = t;
1959
1988
  }
1960
1989
  gn(t) {
1961
1990
  this.Jr = t;
1962
1991
  }
1963
- An() {
1964
- return { x: this.Lr.x, y: this.Lr.y };
1992
+ yn(t) {
1993
+ this.tn = t;
1965
1994
  }
1966
- an(t) {
1967
- if (this.Qr && !this.sn()) {
1968
- const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, originalEvent: t };
1969
- this.Qr(e);
1970
- }
1995
+ An(t) {
1996
+ this.sn = t;
1971
1997
  }
1972
- cn(t) {
1973
- if (this.qr && !this.sn()) {
1974
- const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
1975
- this.qr(e);
1976
- }
1998
+ Cn() {
1999
+ return { x: this.Hr.x, y: this.Hr.y };
1977
2000
  }
1978
2001
  ln(t) {
1979
- if (this.Zr && !this.sn()) {
1980
- const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
1981
- this.Zr(e);
2002
+ if (this.tn && !this.rn()) {
2003
+ const e = { position: { ...this.Hr }, previousPosition: { ...this.Gr }, originalEvent: t };
2004
+ this.tn(e);
1982
2005
  }
1983
2006
  }
1984
2007
  un(t) {
1985
- if (this.Vr && !this.sn()) {
1986
- const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, button: t.button, originalEvent: t };
1987
- this.Vr(e);
2008
+ if (this.Qr && !this.rn()) {
2009
+ const e = { position: { ...this.Hr }, previousPosition: { ...this.Gr }, button: t.button, originalEvent: t };
2010
+ this.Qr(e);
1988
2011
  }
1989
2012
  }
1990
2013
  fn(t) {
1991
- if (this.Jr && !this.sn()) {
1992
- const e = { position: { ...this.Lr }, previousPosition: { ...this.Or }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2014
+ if (this.Jr && !this.rn()) {
2015
+ const e = { position: { ...this.Hr }, previousPosition: { ...this.Gr }, button: t.button, originalEvent: t };
1993
2016
  this.Jr(e);
1994
2017
  }
1995
2018
  }
1996
- hn(t) {
1997
- const e = this.tr.canvas;
1998
- this.Or = { ...this.Lr }, this.Gr = { x: t.clientX, y: t.clientY };
1999
- const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.Br.offsetX, l = o - this.Br.offsetY, f = Math.floor(c / this.Br.cellWidth), u = Math.floor(l / this.Br.cellHeight);
2000
- f >= 0 && f < this.Br.cols && u >= 0 && u < this.Br.rows ? (this.Lr.x = f, this.Lr.y = u) : (this.Lr.x = -1, this.Lr.y = -1);
2019
+ dn(t) {
2020
+ if (this.Zr && !this.rn()) {
2021
+ const e = { position: { ...this.Hr }, previousPosition: { ...this.Gr }, button: t.button, originalEvent: t };
2022
+ this.Zr(e);
2023
+ }
2024
+ }
2025
+ pn(t) {
2026
+ if (this.sn && !this.rn()) {
2027
+ const e = { position: { ...this.Hr }, previousPosition: { ...this.Gr }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2028
+ this.sn(e);
2029
+ }
2030
+ }
2031
+ cn(t) {
2032
+ const e = this.er.canvas;
2033
+ this.Gr = { ...this.Hr }, this.Ir = { x: t.clientX, y: t.clientY };
2034
+ const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.Lr.offsetX, l = o - this.Lr.offsetY, f = Math.floor(c / this.Lr.cellWidth), u = Math.floor(l / this.Lr.cellHeight);
2035
+ f >= 0 && f < this.Lr.cols && u >= 0 && u < this.Lr.rows ? (this.Hr.x = f, this.Hr.y = u) : (this.Hr.x = -1, this.Hr.y = -1);
2001
2036
  }
2002
2037
  }
2003
- const Ht = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: rt }, Symbol.toStringTag, { value: "Module" }));
2038
+ const Wt = Object.freeze(Object.defineProperty({ __proto__: null, MouseManager: rt }, Symbol.toStringTag, { value: "Module" }));
2004
2039
  class nt {
2005
2040
  constructor() {
2006
- h(this, "yn", /* @__PURE__ */ new Map());
2007
- h(this, "Cn", null);
2008
- h(this, "wn", null);
2009
- h(this, "bn");
2010
- h(this, "xn");
2011
- h(this, "jr", !1);
2041
+ h(this, "wn", /* @__PURE__ */ new Map());
2042
+ h(this, "bn", null);
2043
+ h(this, "xn", null);
2012
2044
  h(this, "Mn");
2013
2045
  h(this, "Fn");
2014
- h(this, "zn", { 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" });
2046
+ h(this, "qr", !1);
2047
+ h(this, "zn");
2048
+ h(this, "Rn");
2049
+ h(this, "Tn", { ArrowUp: "UP_ARROW", ArrowDown: "DOWN_ARROW", ArrowLeft: "LEFT_ARROW", ArrowRight: "RIGHT_ARROW", F1: "F1", F2: "F2", F3: "F3", F4: "F4", F5: "F5", F6: "F6", F7: "F7", F8: "F8", F9: "F9", F10: "F10", F11: "F11", F12: "F12", Enter: "ENTER", Return: "RETURN", Tab: "TAB", Escape: "ESCAPE", Backspace: "BACKSPACE", Delete: "DELETE", Insert: "INSERT", Home: "HOME", End: "END", PageUp: "PAGE_UP", PageDown: "PAGE_DOWN", Shift: "SHIFT", Control: "CONTROL", Alt: "ALT", Meta: "META", " ": "SPACE" });
2015
2050
  }
2016
- nn() {
2017
- this.jr || (this.bn = (t) => {
2018
- this.Rn(t);
2019
- }, this.xn = (t) => {
2020
- this.Tn(t);
2021
- }, window.addEventListener("keydown", this.bn, { passive: !1 }), window.addEventListener("keyup", this.xn, { passive: !1 }), this.jr = !0);
2051
+ an() {
2052
+ this.qr || (this.Mn = (t) => {
2053
+ this.Pn(t);
2054
+ }, this.Fn = (t) => {
2055
+ this.Sn(t);
2056
+ }, window.addEventListener("keydown", this.Mn, { passive: !1 }), window.addEventListener("keyup", this.Fn, { passive: !1 }), this.qr = !0);
2022
2057
  }
2023
- dn() {
2024
- this.jr && (window.removeEventListener("keydown", this.bn), window.removeEventListener("keyup", this.xn), this.jr = !1, this.yn.clear(), this.Cn = null, this.wn = null);
2025
- }
2026
- pn(t) {
2027
- this.Mn = t;
2058
+ _n() {
2059
+ this.qr && (window.removeEventListener("keydown", this.Mn), window.removeEventListener("keyup", this.Fn), this.qr = !1, this.wn.clear(), this.bn = null, this.xn = null);
2028
2060
  }
2029
2061
  vn(t) {
2030
- this.Fn = t;
2062
+ this.zn = t;
2031
2063
  }
2032
- Pn(t) {
2033
- const e = this.Sn(t), i = this.yn.get(t) || this.yn.get(e);
2064
+ gn(t) {
2065
+ this.Rn = t;
2066
+ }
2067
+ En(t) {
2068
+ const e = this.$n(t), i = this.wn.get(t) || this.wn.get(e);
2034
2069
  return (i == null ? void 0 : i.isPressed) || !1;
2035
2070
  }
2036
- En() {
2037
- return this.Cn;
2071
+ Dn() {
2072
+ return this.bn;
2038
2073
  }
2039
- $n() {
2040
- return this.wn;
2074
+ kn() {
2075
+ return this.xn;
2041
2076
  }
2042
- Dn() {
2077
+ Bn() {
2043
2078
  const t = [];
2044
- for (const [e, i] of this.yn) i.isPressed && t.push(e);
2079
+ for (const [e, i] of this.wn) i.isPressed && t.push(e);
2045
2080
  return t;
2046
2081
  }
2047
- kn() {
2048
- return { ctrl: this.Pn("Control"), shift: this.Pn("Shift"), alt: this.Pn("Alt"), meta: this.Pn("Meta") };
2082
+ On() {
2083
+ return { ctrl: this.En("Control"), shift: this.En("Shift"), alt: this.En("Alt"), meta: this.En("Meta") };
2049
2084
  }
2050
- Bn() {
2051
- this.yn.clear(), this.Cn = null, this.wn = null;
2085
+ Ln() {
2086
+ this.wn.clear(), this.bn = null, this.xn = null;
2052
2087
  }
2053
- Rn(t) {
2088
+ Pn(t) {
2054
2089
  const e = t.key, i = Date.now();
2055
- this.yn.has(e) || this.yn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2056
- const s = this.yn.get(e);
2057
- if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.Cn = e, this.Mn)) {
2090
+ this.wn.has(e) || this.wn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2091
+ const s = this.wn.get(e);
2092
+ if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.bn = e, this.zn)) {
2058
2093
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
2059
- this.Mn(r);
2094
+ this.zn(r);
2060
2095
  }
2061
2096
  }
2062
- Tn(t) {
2097
+ Sn(t) {
2063
2098
  const e = t.key, i = Date.now();
2064
- this.yn.has(e) || this.yn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2065
- const s = this.yn.get(e);
2066
- if (s.isPressed = !1, s.lastReleaseTime = i, this.wn = e, this.Fn) {
2099
+ this.wn.has(e) || this.wn.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
2100
+ const s = this.wn.get(e);
2101
+ if (s.isPressed = !1, s.lastReleaseTime = i, this.xn = e, this.Rn) {
2067
2102
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
2068
- this.Fn(r);
2103
+ this.Rn(r);
2069
2104
  }
2070
2105
  }
2071
- Sn(t) {
2072
- return this.zn[t] || t.toLowerCase();
2106
+ $n(t) {
2107
+ return this.Tn[t] || t.toLowerCase();
2073
2108
  }
2074
2109
  }
2075
- const jt = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: nt }, Symbol.toStringTag, { value: "Module" }));
2110
+ const kt = Object.freeze(Object.defineProperty({ __proto__: null, KeyboardManager: nt }, Symbol.toStringTag, { value: "Module" }));
2076
2111
  class ot {
2077
2112
  constructor(t, e) {
2078
- h(this, "tr");
2079
- h(this, "Ln");
2080
- h(this, "Br");
2081
- h(this, "On", /* @__PURE__ */ new Map());
2113
+ h(this, "er");
2114
+ h(this, "Hn");
2115
+ h(this, "Lr");
2082
2116
  h(this, "Gn", /* @__PURE__ */ new Map());
2083
- h(this, "Hn", /* @__PURE__ */ new Map());
2084
- h(this, "In", null);
2085
- h(this, "Nn");
2086
- h(this, "Xn");
2117
+ h(this, "In", /* @__PURE__ */ new Map());
2118
+ h(this, "Nn", /* @__PURE__ */ new Map());
2119
+ h(this, "Xn", null);
2087
2120
  h(this, "Wn");
2088
2121
  h(this, "Kn");
2089
- h(this, "Yn");
2090
2122
  h(this, "jn");
2091
- h(this, "jr", !1);
2123
+ h(this, "Yn");
2092
2124
  h(this, "Vn");
2093
2125
  h(this, "qn");
2126
+ h(this, "qr", !1);
2094
2127
  h(this, "Zn");
2095
2128
  h(this, "Qn");
2096
2129
  h(this, "Jn");
@@ -2099,67 +2132,63 @@ class ot {
2099
2132
  h(this, "io");
2100
2133
  h(this, "ro");
2101
2134
  h(this, "no");
2102
- h(this, "oo", 320);
2103
- h(this, "ho", 350);
2104
- h(this, "ao", 10);
2105
- h(this, "co", 550);
2106
- h(this, "lo", 14);
2107
- h(this, "uo", 48);
2108
- h(this, "fo", 650);
2109
- h(this, "do", 0.02);
2110
- h(this, "_o", 2);
2111
- h(this, "po", 600);
2112
- h(this, "vo", 0);
2113
- h(this, "mo", null);
2114
- this.tr = t, this.Ln = e;
2115
- const i = this.tr.canvas;
2116
- this.Nn = i.style.touchAction, this.Xn = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2117
- }
2118
- Wi(t) {
2119
- this.Br = t, this.Ao();
2120
- }
2121
- nn() {
2122
- if (this.jr) return;
2123
- const t = this.tr.canvas;
2124
- this.Wn = (e) => {
2125
- this.yo(e);
2126
- }, this.Kn = (e) => {
2127
- this.Co(e);
2128
- }, this.Yn = (e) => {
2135
+ h(this, "oo");
2136
+ h(this, "ho");
2137
+ h(this, "ao", 320);
2138
+ h(this, "co", 350);
2139
+ h(this, "lo", 10);
2140
+ h(this, "uo", 550);
2141
+ h(this, "fo", 14);
2142
+ h(this, "do", 48);
2143
+ h(this, "po", 650);
2144
+ h(this, "_o", 0.02);
2145
+ h(this, "mo", 2);
2146
+ h(this, "vo", 600);
2147
+ h(this, "yo", 0);
2148
+ h(this, "Ao", null);
2149
+ this.er = t, this.Hn = e;
2150
+ const i = this.er.canvas;
2151
+ this.Wn = i.style.touchAction, this.Kn = i.style.userSelect, i.style.touchAction || (i.style.touchAction = "none"), i.style.userSelect || (i.style.userSelect = "none");
2152
+ }
2153
+ Ki(t) {
2154
+ this.Lr = t, this.Co();
2155
+ }
2156
+ an() {
2157
+ if (this.qr) return;
2158
+ const t = this.er.canvas;
2159
+ this.jn = (e) => {
2129
2160
  this.wo(e);
2130
- }, this.jn = (e) => {
2161
+ }, this.Yn = (e) => {
2131
2162
  this.bo(e);
2132
- }, t.addEventListener("touchstart", this.Wn, { passive: !1 }), t.addEventListener("touchmove", this.Kn, { passive: !1 }), t.addEventListener("touchend", this.Yn, { passive: !1 }), t.addEventListener("touchcancel", this.jn, { passive: !1 }), this.jr = !0;
2133
- }
2134
- dn() {
2135
- if (!this.jr) return;
2136
- const t = this.tr.canvas;
2137
- t.removeEventListener("touchstart", this.Wn), t.removeEventListener("touchmove", this.Kn), t.removeEventListener("touchend", this.Yn), t.removeEventListener("touchcancel", this.jn), this.jr = !1, this.In = null, this.On.clear(), this.Gn.clear(), this.Hn.forEach((e) => {
2163
+ }, this.Vn = (e) => {
2164
+ this.xo(e);
2165
+ }, this.qn = (e) => {
2166
+ this.Mo(e);
2167
+ }, t.addEventListener("touchstart", this.jn, { passive: !1 }), t.addEventListener("touchmove", this.Yn, { passive: !1 }), t.addEventListener("touchend", this.Vn, { passive: !1 }), t.addEventListener("touchcancel", this.qn, { passive: !1 }), this.qr = !0;
2168
+ }
2169
+ _n() {
2170
+ if (!this.qr) return;
2171
+ const t = this.er.canvas;
2172
+ t.removeEventListener("touchstart", this.jn), t.removeEventListener("touchmove", this.Yn), t.removeEventListener("touchend", this.Vn), t.removeEventListener("touchcancel", this.qn), this.qr = !1, this.Xn = null, this.Gn.clear(), this.In.clear(), this.Nn.forEach((e) => {
2138
2173
  e.longPressTimer !== null && window.clearTimeout(e.longPressTimer);
2139
- }), this.Hn.clear(), this.mo = null, this.vo = 0, t.style.touchAction = this.Nn, t.style.userSelect = this.Xn;
2174
+ }), this.Nn.clear(), this.Ao = null, this.yo = 0, t.style.touchAction = this.Wn, t.style.userSelect = this.Kn;
2140
2175
  }
2141
- Ao() {
2142
- if (!this.Br || this.On.size === 0) return;
2176
+ Co() {
2177
+ if (!this.Lr || this.Gn.size === 0) return;
2143
2178
  const t = /* @__PURE__ */ new Map();
2144
- for (const e of this.On.values()) {
2145
- const i = this.xo(e.clientX, e.clientY, e.id, e);
2179
+ for (const e of this.Gn.values()) {
2180
+ const i = this.Fo(e.clientX, e.clientY, e.id, e);
2146
2181
  t.set(e.id, i);
2147
2182
  }
2148
- this.On = t;
2183
+ this.Gn = t;
2149
2184
  }
2150
- Mo() {
2151
- return Array.from(this.On.values()).map((t) => ({ ...t }));
2185
+ zo() {
2186
+ return Array.from(this.Gn.values()).map((t) => ({ ...t }));
2152
2187
  }
2153
- Fo(t) {
2154
- this.Vn = t;
2155
- }
2156
- mn(t) {
2157
- this.qn = t;
2158
- }
2159
- zo(t) {
2188
+ Ro(t) {
2160
2189
  this.Zn = t;
2161
2190
  }
2162
- Ro(t) {
2191
+ yn(t) {
2163
2192
  this.Qn = t;
2164
2193
  }
2165
2194
  To(t) {
@@ -2180,118 +2209,124 @@ class ot {
2180
2209
  Do(t) {
2181
2210
  this.no = t;
2182
2211
  }
2183
- yo(t) {
2212
+ ko(t) {
2213
+ this.oo = t;
2214
+ }
2215
+ Bo(t) {
2216
+ this.ho = t;
2217
+ }
2218
+ wo(t) {
2184
2219
  var s;
2185
- if (!this.Br) return;
2186
- t.preventDefault(), (s = this.Ln) == null || s.tn(this.po);
2187
- const e = performance.now(), i = this.ko(t.changedTouches);
2220
+ if (!this.Lr) return;
2221
+ t.preventDefault(), (s = this.Hn) == null || s.en(this.vo);
2222
+ const e = performance.now(), i = this.Oo(t.changedTouches);
2188
2223
  for (const r of i) {
2189
- const n = this.On.get(r.id);
2190
- n && this.Gn.set(r.id, this.Bo(n)), this.On.set(r.id, r);
2224
+ const n = this.Gn.get(r.id);
2225
+ n && this.In.set(r.id, this.Lo(n)), this.Gn.set(r.id, r);
2191
2226
  const o = { id: r.id, startPosition: r, lastPosition: r, startTime: e, lastTime: e, longPressTimer: null, longPressFired: !1 };
2192
- this.eo && (o.longPressTimer = window.setTimeout(() => {
2193
- const c = this.On.get(r.id);
2194
- c && (o.longPressFired = !0, this.eo({ touch: this.Bo(c), duration: performance.now() - o.startTime, originalEvent: t }));
2195
- }, this.co)), this.Hn.set(r.id, o), this.Vn && this.Vn(this.Lo(r, t, void 0, e));
2227
+ this.ro && (o.longPressTimer = window.setTimeout(() => {
2228
+ const c = this.Gn.get(r.id);
2229
+ c && (o.longPressFired = !0, this.ro({ touch: this.Lo(c), duration: performance.now() - o.startTime, originalEvent: t }));
2230
+ }, this.uo)), this.Nn.set(r.id, o), this.Zn && this.Zn(this.Ho(r, t, void 0, e));
2196
2231
  }
2197
- this.On.size === 2 && this.Oo();
2232
+ this.Gn.size === 2 && this.Go();
2198
2233
  }
2199
- Co(t) {
2234
+ bo(t) {
2200
2235
  var s;
2201
- if (!this.Br) return;
2202
- t.preventDefault(), (s = this.Ln) == null || s.tn(this.po);
2203
- const e = performance.now(), i = this.ko(t.changedTouches);
2236
+ if (!this.Lr) return;
2237
+ t.preventDefault(), (s = this.Hn) == null || s.en(this.vo);
2238
+ const e = performance.now(), i = this.Oo(t.changedTouches);
2204
2239
  for (const r of i) {
2205
- const n = this.On.get(r.id), o = n ? this.Bo(n) : void 0;
2206
- o && this.Gn.set(r.id, o), this.On.set(r.id, r);
2207
- const c = this.Hn.get(r.id);
2208
- c && (c.lastPosition = r, c.lastTime = e, o) && this.Go(o, r, !0) > this.lo && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.qn && this.qn(this.Lo(r, t, o, e));
2240
+ const n = this.Gn.get(r.id), o = n ? this.Lo(n) : void 0;
2241
+ o && this.In.set(r.id, o), this.Gn.set(r.id, r);
2242
+ const c = this.Nn.get(r.id);
2243
+ c && (c.lastPosition = r, c.lastTime = e, o) && this.Io(o, r, !0) > this.fo && c.longPressTimer !== null && (window.clearTimeout(c.longPressTimer), c.longPressTimer = null), this.Qn && this.Qn(this.Ho(r, t, o, e));
2209
2244
  }
2210
- this.On.size === 2 ? this.Ho(t) : this.In = null;
2245
+ this.Gn.size === 2 ? this.No(t) : this.Xn = null;
2211
2246
  }
2212
- wo(t) {
2213
- if (!this.Br) return;
2247
+ xo(t) {
2248
+ if (!this.Lr) return;
2214
2249
  t.preventDefault();
2215
- const e = performance.now(), i = this.ko(t.changedTouches);
2250
+ const e = performance.now(), i = this.Oo(t.changedTouches);
2216
2251
  for (const s of i) {
2217
- const r = this.On.get(s.id), n = r ? this.Bo(r) : void 0, o = this.Hn.get(s.id);
2218
- o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Zn && this.Zn(this.Lo(s, t, n, e)), o && this.Io(o, t), this.Hn.delete(s.id), this.Gn.delete(s.id), this.On.delete(s.id);
2252
+ const r = this.Gn.get(s.id), n = r ? this.Lo(r) : void 0, o = this.Nn.get(s.id);
2253
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Jn && this.Jn(this.Ho(s, t, n, e)), o && this.Xo(o, t), this.Nn.delete(s.id), this.In.delete(s.id), this.Gn.delete(s.id);
2219
2254
  }
2220
- this.On.size < 2 && (this.In = null);
2255
+ this.Gn.size < 2 && (this.Xn = null);
2221
2256
  }
2222
- bo(t) {
2223
- if (!this.Br) return;
2257
+ Mo(t) {
2258
+ if (!this.Lr) return;
2224
2259
  t.preventDefault();
2225
- const e = performance.now(), i = this.ko(t.changedTouches);
2260
+ const e = performance.now(), i = this.Oo(t.changedTouches);
2226
2261
  for (const s of i) {
2227
- const r = this.On.get(s.id), n = r ? this.Bo(r) : void 0, o = this.Hn.get(s.id);
2228
- o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.Qn && this.Qn(this.Lo(s, t, n, e)), this.Hn.delete(s.id), this.Gn.delete(s.id), this.On.delete(s.id);
2262
+ const r = this.Gn.get(s.id), n = r ? this.Lo(r) : void 0, o = this.Nn.get(s.id);
2263
+ o && o.longPressTimer !== null && (window.clearTimeout(o.longPressTimer), o.longPressTimer = null), this.so && this.so(this.Ho(s, t, n, e)), this.Nn.delete(s.id), this.In.delete(s.id), this.Gn.delete(s.id);
2229
2264
  }
2230
- this.On.size < 2 && (this.In = null);
2265
+ this.Gn.size < 2 && (this.Xn = null);
2231
2266
  }
2232
- ko(t) {
2267
+ Oo(t) {
2233
2268
  const e = [];
2234
2269
  for (let i = 0; i < t.length; i += 1) {
2235
2270
  const s = t.item(i);
2236
- s && e.push(this.No(s));
2271
+ s && e.push(this.Wo(s));
2237
2272
  }
2238
2273
  return e;
2239
2274
  }
2240
- No(t) {
2241
- return this.xo(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 });
2275
+ Wo(t) {
2276
+ return this.Fo(t.clientX, t.clientY, t.identifier, { id: t.identifier, x: -1, y: -1, clientX: t.clientX, clientY: t.clientY, pressure: t.force, radiusX: t.radiusX, radiusY: t.radiusY, rotationAngle: t.rotationAngle });
2242
2277
  }
2243
- xo(t, e, i, s) {
2244
- const r = this.tr.canvas, n = r.getBoundingClientRect(), o = t - n.left, c = e - n.top, l = r.width / n.width, f = c * (r.height / n.height), u = o * l - this.Br.offsetX, m = f - this.Br.offsetY, p = Math.floor(u / this.Br.cellWidth), g = Math.floor(m / this.Br.cellHeight), d = p >= 0 && p < this.Br.cols && g >= 0 && g < this.Br.rows;
2278
+ Fo(t, e, i, s) {
2279
+ const r = this.er.canvas, n = r.getBoundingClientRect(), o = t - n.left, c = e - n.top, l = r.width / n.width, f = c * (r.height / n.height), u = o * l - this.Lr.offsetX, m = f - this.Lr.offsetY, p = Math.floor(u / this.Lr.cellWidth), g = Math.floor(m / this.Lr.cellHeight), d = p >= 0 && p < this.Lr.cols && g >= 0 && g < this.Lr.rows;
2245
2280
  return { id: i, x: d ? p : -1, y: d ? g : -1, clientX: t, clientY: e, pressure: s.pressure, radiusX: s.radiusX, radiusY: s.radiusY, rotationAngle: s.rotationAngle };
2246
2281
  }
2247
- Lo(t, e, i, s) {
2248
- const r = this.Hn.get(t.id), n = Array.from(this.Gn.values()).map((l) => this.Bo(l)), o = Array.from(this.On.values()).map((l) => this.Bo(l)), c = this.ko(e.changedTouches);
2249
- return { touch: this.Bo(t), previousTouch: i ? this.Bo(i) : void 0, touches: o, previousTouches: n, changedTouches: c, deltaTime: r ? s - r.lastTime : 0, originalEvent: e };
2282
+ Ho(t, e, i, s) {
2283
+ const r = this.Nn.get(t.id), n = Array.from(this.In.values()).map((l) => this.Lo(l)), o = Array.from(this.Gn.values()).map((l) => this.Lo(l)), c = this.Oo(e.changedTouches);
2284
+ return { touch: this.Lo(t), previousTouch: i ? this.Lo(i) : void 0, touches: o, previousTouches: n, changedTouches: c, deltaTime: r ? s - r.lastTime : 0, originalEvent: e };
2250
2285
  }
2251
- Oo() {
2252
- if (this.On.size !== 2) return void (this.In = null);
2253
- const t = Array.from(this.On.values()), [e, i] = t, s = this.Go(e, i, !1), r = this.Xo(e, i);
2254
- this.In = { ids: [e.id, i.id], initialDistance: Math.max(s, 1e-4), initialAngle: r, lastScale: 1, lastRotation: 0 };
2286
+ Go() {
2287
+ if (this.Gn.size !== 2) return void (this.Xn = null);
2288
+ const t = Array.from(this.Gn.values()), [e, i] = t, s = this.Io(e, i, !1), r = this.Ko(e, i);
2289
+ this.Xn = { ids: [e.id, i.id], initialDistance: Math.max(s, 1e-4), initialAngle: r, lastScale: 1, lastRotation: 0 };
2255
2290
  }
2256
- Ho(t) {
2257
- if (this.In || this.Oo(), !this.In) return;
2258
- const [e, i] = this.In.ids, s = this.On.get(e), r = this.On.get(i);
2291
+ No(t) {
2292
+ if (this.Xn || this.Go(), !this.Xn) return;
2293
+ const [e, i] = this.Xn.ids, s = this.Gn.get(e), r = this.Gn.get(i);
2259
2294
  if (!s || !r) return;
2260
- const n = this.Go(s, r, !1) / this.In.initialDistance, o = n - this.In.lastScale;
2261
- this.ro && Math.abs(o) > this.do && (this.ro({ touches: [this.Bo(s), this.Bo(r)], scale: n, deltaScale: o, center: this.Wo(s, r), originalEvent: t }), this.In.lastScale = n);
2262
- let c = this.Xo(s, r) - this.In.initialAngle;
2295
+ const n = this.Io(s, r, !1) / this.Xn.initialDistance, o = n - this.Xn.lastScale;
2296
+ this.oo && Math.abs(o) > this._o && (this.oo({ touches: [this.Lo(s), this.Lo(r)], scale: n, deltaScale: o, center: this.jo(s, r), originalEvent: t }), this.Xn.lastScale = n);
2297
+ let c = this.Ko(s, r) - this.Xn.initialAngle;
2263
2298
  c = (c + 180) % 360 - 180;
2264
- const l = c - this.In.lastRotation;
2265
- this.no && Math.abs(l) > this._o && (this.no({ touches: [this.Bo(s), this.Bo(r)], rotation: c, deltaRotation: l, center: this.Wo(s, r), originalEvent: t }), this.In.lastRotation = c);
2299
+ const l = c - this.Xn.lastRotation;
2300
+ this.ho && Math.abs(l) > this.mo && (this.ho({ touches: [this.Lo(s), this.Lo(r)], rotation: c, deltaRotation: l, center: this.jo(s, r), originalEvent: t }), this.Xn.lastRotation = c);
2266
2301
  }
2267
- Wo(t, e) {
2268
- const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.xo(i, s, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: s });
2302
+ jo(t, e) {
2303
+ const i = (t.clientX + e.clientX) / 2, s = (t.clientY + e.clientY) / 2, r = this.Fo(i, s, -1, { id: -1, x: -1, y: -1, clientX: i, clientY: s });
2269
2304
  return { x: r.x, y: r.y };
2270
2305
  }
2271
- Io(t, e) {
2272
- const i = performance.now(), s = i - t.startTime, r = this.Go(t.startPosition, t.lastPosition, !0);
2273
- if (!t.longPressFired && s <= this.oo && r <= this.ao)
2274
- this.Ko(t.lastPosition, i) && this.so ? this.so({ touch: this.Bo(t.lastPosition), taps: 2, originalEvent: e }) : this.Jn && this.Jn({ touch: this.Bo(t.lastPosition), taps: 1, originalEvent: e });
2275
- else if (!t.longPressFired && s <= this.fo && r >= this.uo) {
2306
+ Xo(t, e) {
2307
+ const i = performance.now(), s = i - t.startTime, r = this.Io(t.startPosition, t.lastPosition, !0);
2308
+ if (!t.longPressFired && s <= this.ao && r <= this.lo)
2309
+ this.Yo(t.lastPosition, i) && this.io ? this.io({ touch: this.Lo(t.lastPosition), taps: 2, originalEvent: e }) : this.eo && this.eo({ touch: this.Lo(t.lastPosition), taps: 1, originalEvent: e });
2310
+ else if (!t.longPressFired && s <= this.po && r >= this.do) {
2276
2311
  const n = { x: t.lastPosition.clientX - t.startPosition.clientX, y: t.lastPosition.clientY - t.startPosition.clientY }, o = Math.max(Math.hypot(n.x, n.y), 1e-4), c = { x: n.x / o, y: n.y / o }, l = { x: n.x / s, y: n.y / s };
2277
- this.io && this.io({ touch: this.Bo(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2312
+ this.no && this.no({ touch: this.Lo(t.lastPosition), direction: c, distance: o, velocity: l, originalEvent: e });
2278
2313
  }
2279
- this.vo = i, this.mo = this.Bo(t.lastPosition);
2314
+ this.yo = i, this.Ao = this.Lo(t.lastPosition);
2280
2315
  }
2281
- Ko(t, e) {
2282
- return !this.mo || e - this.vo > this.ho ? !1 : this.Go(t, this.mo, !0) <= this.ao;
2316
+ Yo(t, e) {
2317
+ return !this.Ao || e - this.yo > this.co ? !1 : this.Io(t, this.Ao, !0) <= this.lo;
2283
2318
  }
2284
- Bo(t) {
2319
+ Lo(t) {
2285
2320
  return { ...t };
2286
2321
  }
2287
- Go(t, e, i) {
2322
+ Io(t, e, i) {
2288
2323
  return i ? Math.hypot(t.clientX - e.clientX, t.clientY - e.clientY) : Math.hypot(t.x - e.x, t.y - e.y);
2289
2324
  }
2290
- Xo(t, e) {
2325
+ Ko(t, e) {
2291
2326
  return 180 * Math.atan2(e.clientY - t.clientY, e.clientX - t.clientX) / Math.PI;
2292
2327
  }
2293
2328
  }
2294
- const kt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), Vt = (a) => class extends a {
2329
+ const Vt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager: ot }, Symbol.toStringTag, { value: "Module" })), qt = (a) => class extends a {
2295
2330
  rotate(t = 0, e = 0, i = 0) {
2296
2331
  this.xt.state.st(t), this.xt.state.et(e), this.xt.state.it(i);
2297
2332
  }
@@ -2305,7 +2340,7 @@ const kt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2305
2340
  this.xt.state.it(t);
2306
2341
  }
2307
2342
  push() {
2308
- this.xt.state.H();
2343
+ this.xt.state.G();
2309
2344
  }
2310
2345
  pop() {
2311
2346
  this.xt.state.Z();
@@ -2356,7 +2391,7 @@ const kt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2356
2391
  this.xt.Ke(t, e, i, s, r, n);
2357
2392
  }
2358
2393
  bezierCurve(t, e, i, s, r, n, o, c) {
2359
- this.xt.Ye(t, e, i, s, r, n, o, c);
2394
+ this.xt.je(t, e, i, s, r, n, o, c);
2360
2395
  }
2361
2396
  arc(t, e, i, s, r, n) {
2362
2397
  this.xt.Ve(t, e, i, s, r, n);
@@ -2368,43 +2403,43 @@ const kt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2368
2403
  this.xt.Kt(t, e);
2369
2404
  }
2370
2405
  setUniforms(t) {
2371
- this.xt.Le(t);
2406
+ this.xt.Oe(t);
2372
2407
  }
2373
2408
  createFilterShader(t) {
2374
2409
  return this.xt.hs(t);
2375
2410
  }
2376
2411
  createFramebuffer(t) {
2377
- return this.xt.je(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2412
+ return this.xt.Ye(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2378
2413
  }
2379
2414
  image(t, e, i, s, r) {
2380
2415
  if (t.textures) {
2381
2416
  const n = t;
2382
- this.xt.Oe(n, e, i, s ?? n.width, r ?? n.height);
2417
+ this.xt.Le(n, e, i, s ?? n.width, r ?? n.height);
2383
2418
  } else {
2384
2419
  const n = t;
2385
- this.xt.Ge(n, e, i, s ?? Math.floor(this.Br.cols / 2), r ?? Math.floor(this.Br.rows / 2));
2420
+ this.xt.He(n, e, i, s ?? Math.floor(this.Lr.cols / 2), r ?? Math.floor(this.Lr.rows / 2));
2386
2421
  }
2387
2422
  }
2388
2423
  async loadImage(t) {
2389
- if (typeof t != "string") return G.Mr(this.xt, t, (s) => this.Ei.Si(s));
2424
+ if (typeof t != "string") return G.zr(this.xt, t, (s) => this.Ei.Si(s));
2390
2425
  const e = t, i = await new Promise((s, r) => {
2391
2426
  const n = new Image();
2392
2427
  n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
2393
2428
  });
2394
- return G.Mr(this.xt, i, (s) => this.Ei.Si(s));
2429
+ return G.zr(this.xt, i, (s) => this.Ei.Si(s));
2395
2430
  }
2396
- }, qt = (a) => class extends a {
2431
+ }, Kt = (a) => class extends a {
2397
2432
  async loadFont(t) {
2398
- return this.Ei.Vi(t).then(() => {
2433
+ return this.Ei.qi(t).then(() => {
2399
2434
  const e = this.Ei.maxGlyphDimensions;
2400
- this.Br.rr(e.width, e.height), this.Yo.resize(this.Br.cols, this.Br.rows), this.xt.Ze(), this.Ln.rn();
2435
+ this.Lr.hr(e.width, e.height), this.Vo.resize(this.Lr.cols, this.Lr.rows), this.xt.Ze(), this.Hn.hn();
2401
2436
  });
2402
2437
  }
2403
2438
  fontSize(t) {
2404
- if (!N.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ei.fontSize === t) return;
2405
- this.Ei.ji(t);
2439
+ if (!z.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ei.fontSize === t) return;
2440
+ this.Ei.Vi(t);
2406
2441
  const e = this.Ei.maxGlyphDimensions;
2407
- this.Br.rr(e.width, e.height), this.Yo.resize(this.Br.cols, this.Br.rows), this.xt.Ze(), this.Ln.rn();
2442
+ this.Lr.hr(e.width, e.height), this.Vo.resize(this.Lr.cols, this.Lr.rows), this.xt.Ze(), this.Hn.hn();
2408
2443
  }
2409
2444
  glyphColor(t) {
2410
2445
  return this.Ei.Pi(t);
@@ -2412,265 +2447,334 @@ const kt = Object.freeze(Object.defineProperty({ __proto__: null, TouchManager:
2412
2447
  glyphColors(t) {
2413
2448
  return this.Ei.Si(t);
2414
2449
  }
2415
- }, Kt = (a) => class extends a {
2450
+ }, jt = (a) => class extends a {
2416
2451
  get frameCount() {
2417
- return this.jo.frameCount;
2452
+ return this.qo.frameCount;
2418
2453
  }
2419
2454
  set frameCount(t) {
2420
- this.jo.frameCount = t;
2455
+ this.qo.frameCount = t;
2421
2456
  }
2422
2457
  frameRate(t) {
2423
- return t === void 0 ? this.jo.currentFrameRate : this.jo.frameRate(t, () => this.Vo());
2458
+ return t === void 0 ? this.qo.currentFrameRate : this.qo.frameRate(t, () => this.Zo());
2424
2459
  }
2425
2460
  noLoop() {
2426
- this.jo.pause();
2461
+ this.qo.pause();
2427
2462
  }
2428
2463
  loop() {
2429
- this.jo.resume(() => this.Vo());
2464
+ this.qo.resume(() => this.Zo());
2430
2465
  }
2431
2466
  redraw(t = 1) {
2432
- if (N.m(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.Vo();
2467
+ if (z.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.Zo();
2433
2468
  }
2434
2469
  isLooping() {
2435
- return this.jo.isLooping;
2470
+ return this.qo.isLooping;
2436
2471
  }
2437
2472
  }, Zt = (a) => class extends a {
2438
2473
  constructor(...t) {
2439
2474
  super(...t);
2440
2475
  }
2441
2476
  mouseClicked(t) {
2442
- this.Ln._n(t);
2477
+ this.Hn.mn(t);
2443
2478
  }
2444
2479
  mousePressed(t) {
2445
- this.Ln.pn(t);
2480
+ this.Hn.vn(t);
2446
2481
  }
2447
2482
  mouseReleased(t) {
2448
- this.Ln.vn(t);
2483
+ this.Hn.gn(t);
2449
2484
  }
2450
2485
  mouseMoved(t) {
2451
- this.Ln.mn(t);
2486
+ this.Hn.yn(t);
2452
2487
  }
2453
2488
  mouseScrolled(t) {
2454
- this.Ln.gn(t);
2489
+ this.Hn.An(t);
2455
2490
  }
2456
2491
  get mouse() {
2457
- return this.Ln.An();
2492
+ return this.Hn.Cn();
2458
2493
  }
2459
2494
  cursor(t) {
2460
- this.Ln.en(t);
2495
+ this.Hn.nn(t);
2461
2496
  }
2462
2497
  }, Qt = (a) => class extends a {
2463
2498
  constructor(...t) {
2464
2499
  super(...t);
2465
2500
  }
2466
2501
  touchStarted(t) {
2467
- this.qo.Fo(t);
2502
+ this.Qo.Ro(t);
2468
2503
  }
2469
2504
  touchMoved(t) {
2470
- this.qo.mn(t);
2505
+ this.Qo.yn(t);
2471
2506
  }
2472
2507
  touchEnded(t) {
2473
- this.qo.zo(t);
2508
+ this.Qo.To(t);
2474
2509
  }
2475
2510
  touchCancelled(t) {
2476
- this.qo.Ro(t);
2511
+ this.Qo.Po(t);
2477
2512
  }
2478
2513
  tap(t) {
2479
- this.qo.To(t);
2514
+ this.Qo.So(t);
2480
2515
  }
2481
2516
  doubleTap(t) {
2482
- this.qo.Po(t);
2517
+ this.Qo.Eo(t);
2483
2518
  }
2484
2519
  longPress(t) {
2485
- this.qo.So(t);
2520
+ this.Qo.$o(t);
2486
2521
  }
2487
2522
  swipe(t) {
2488
- this.qo.Eo(t);
2523
+ this.Qo.Do(t);
2489
2524
  }
2490
2525
  pinch(t) {
2491
- this.qo.$o(t);
2526
+ this.Qo.ko(t);
2492
2527
  }
2493
2528
  rotateGesture(t) {
2494
- this.qo.Do(t);
2529
+ this.Qo.Bo(t);
2495
2530
  }
2496
2531
  get touches() {
2497
- return this.qo.Mo();
2532
+ return this.Qo.zo();
2498
2533
  }
2499
2534
  }, Jt = (a) => class extends a {
2500
2535
  constructor(...t) {
2501
2536
  super(...t);
2502
2537
  }
2503
2538
  keyPressed(t) {
2504
- this.Zo.pn(t);
2539
+ this.Jo.vn(t);
2505
2540
  }
2506
2541
  keyReleased(t) {
2507
- this.Zo.vn(t);
2542
+ this.Jo.gn(t);
2508
2543
  }
2509
2544
  isKeyPressed(t) {
2510
- return this.Zo.Pn(t);
2545
+ return this.Jo.En(t);
2511
2546
  }
2512
2547
  get lastKeyPressed() {
2513
- return this.Zo.En();
2548
+ return this.Jo.Dn();
2514
2549
  }
2515
2550
  get lastKeyReleased() {
2516
- return this.Zo.$n();
2551
+ return this.Jo.kn();
2517
2552
  }
2518
2553
  get pressedKeys() {
2519
- return this.Zo.Dn();
2554
+ return this.Jo.Bn();
2520
2555
  }
2521
2556
  get modifierState() {
2522
- return this.Zo.kn();
2557
+ return this.Jo.On();
2523
2558
  }
2524
2559
  };
2525
2560
  class $t {
2561
+ constructor(t) {
2562
+ h(this, "th");
2563
+ h(this, "sh", /* @__PURE__ */ new Map());
2564
+ h(this, "eh", []);
2565
+ h(this, "ih", /* @__PURE__ */ new Map());
2566
+ h(this, "rh", /* @__PURE__ */ new Map());
2567
+ this.th = t;
2568
+ }
2569
+ async installMany(t) {
2570
+ for (const e of t) await this.use(e);
2571
+ }
2572
+ async use(t) {
2573
+ if (this.sh.has(t.name)) return void console.warn(`[textmode.js] Plugin "${t.name}" is already installed.`);
2574
+ const e = this.nh(t.name);
2575
+ try {
2576
+ await t.install(this.th, e);
2577
+ } catch (i) {
2578
+ throw this.oh(t.name), i;
2579
+ }
2580
+ this.sh.set(t.name, t), this.eh.push(t.name);
2581
+ }
2582
+ async unuse(t) {
2583
+ const e = this.sh.get(t);
2584
+ if (!e) return;
2585
+ const i = this.nh(t);
2586
+ if (e.uninstall) try {
2587
+ await e.uninstall(this.th, i);
2588
+ } catch (s) {
2589
+ console.error(`[textmode.js] Error while uninstalling plugin "${t}":`, s);
2590
+ }
2591
+ this.sh.delete(t), this.eh.splice(this.eh.indexOf(t), 1), this.oh(t);
2592
+ }
2593
+ has(t) {
2594
+ return this.sh.has(t);
2595
+ }
2596
+ runPreDrawHooks() {
2597
+ this.hh(this.ih, "preDraw");
2598
+ }
2599
+ runPostDrawHooks() {
2600
+ this.hh(this.rh, "postDraw");
2601
+ }
2602
+ async disposeAll() {
2603
+ const t = [...this.sh.keys()];
2604
+ for (const e of t) await this.unuse(e);
2605
+ }
2606
+ nh(t) {
2607
+ return { ...this.th.ah(), registerPreDrawHook: (e) => this.uh(this.ih, t, e), registerPostDrawHook: (e) => this.uh(this.rh, t, e) };
2608
+ }
2609
+ uh(t, e, i) {
2610
+ const s = t.get(e) ?? /* @__PURE__ */ new Set();
2611
+ return s.add(i), t.set(e, s), () => {
2612
+ const r = t.get(e);
2613
+ r && (r.delete(i), r.size === 0 && t.delete(e));
2614
+ };
2615
+ }
2616
+ oh(t) {
2617
+ this.ih.delete(t), this.rh.delete(t);
2618
+ }
2619
+ hh(t, e) {
2620
+ for (const i of this.eh) {
2621
+ const s = t.get(i);
2622
+ if (s) for (const r of s) try {
2623
+ r();
2624
+ } catch (n) {
2625
+ console.error(`[textmode.js] Plugin "${i}" ${e} hook failed:`, n);
2626
+ }
2627
+ }
2628
+ }
2629
+ }
2630
+ class te {
2526
2631
  constructor() {
2527
2632
  h(this, "xt");
2528
2633
  h(this, "Ei");
2529
- h(this, "tr");
2530
- h(this, "Br");
2531
- h(this, "jo");
2532
- h(this, "Ln");
2634
+ h(this, "er");
2635
+ h(this, "Lr");
2533
2636
  h(this, "qo");
2534
- h(this, "Zo");
2637
+ h(this, "Hn");
2535
2638
  h(this, "Qo");
2536
- h(this, "Yo");
2537
2639
  h(this, "Jo");
2538
- h(this, "th");
2539
- h(this, "sh");
2640
+ h(this, "fh");
2641
+ h(this, "Vo");
2642
+ h(this, "dh");
2643
+ h(this, "ph");
2644
+ h(this, "_h");
2540
2645
  }
2541
- Vo() {
2646
+ Zo() {
2542
2647
  }
2543
2648
  }
2544
- class te extends function(e, ...i) {
2649
+ class ee extends function(e, ...i) {
2545
2650
  return i.reduce((s, r) => r(s), e);
2546
- }($t, Vt, qt, Kt, Zt, Qt, Jt) {
2651
+ }(te, qt, Kt, jt, Zt, Qt, Jt) {
2547
2652
  constructor(e = {}) {
2548
2653
  var i;
2549
2654
  super();
2550
- h(this, "eh", /* @__PURE__ */ new Map());
2551
- h(this, "ih");
2552
- h(this, "rh", !1);
2553
- h(this, "nh", !1);
2554
- h(this, "oh", () => {
2655
+ h(this, "mh");
2656
+ h(this, "gh");
2657
+ h(this, "yh", !1);
2658
+ h(this, "Ah", !1);
2659
+ h(this, "Ch", () => {
2555
2660
  });
2556
- h(this, "hh", () => {
2661
+ h(this, "wh", () => {
2557
2662
  });
2558
- h(this, "ah", () => {
2663
+ h(this, "bh", () => {
2559
2664
  });
2560
- h(this, "uh");
2561
- h(this, "ar");
2562
- h(this, "hr", !1);
2563
- h(this, "fh");
2564
- this.ih = ((i = e.plugins) == null ? void 0 : i.slice()) ?? [], this.hr = e.overlay ?? !1, this.tr = new Yt(e), this.xt = new Ut(this.tr.vr()), this.Ei = new Gt(this.xt, e.fontSize ?? 16), this.jo = new Wt(e.frameRate ?? 60), this.Ln = new rt(this.tr), this.qo = new ot(this.tr, this.Ln), this.Zo = new nt(), this.Qo = this.xt.Pt(), this.Jo = this.xt.rs(), this.dh(e);
2565
- }
2566
- async dh(e) {
2567
- await this.Ei.Wi(e.fontSource);
2665
+ h(this, "xh");
2666
+ h(this, "lr");
2667
+ h(this, "cr", !1);
2668
+ h(this, "Mh");
2669
+ this.mh = new $t(this), this.gh = ((i = e.plugins) == null ? void 0 : i.slice()) ?? [], this.cr = e.overlay ?? !1, this.er = new Xt(e), this.xt = new Lt(this.er.gr()), this.Ei = new Gt(this.xt, e.fontSize ?? 16), this.qo = new Yt(e.frameRate ?? 60), this.Hn = new rt(this.er), this.Qo = new ot(this.er, this.Hn), this.Jo = new nt(), this.fh = this.xt.Pt(), this.dh = this.xt.rs(), this.Fh(e);
2670
+ }
2671
+ async Fh(e) {
2672
+ await this.Ei.Ki(e.fontSource);
2568
2673
  const i = this.Ei.maxGlyphDimensions;
2569
- this.Br = new Xt(this.tr.canvas, i.width, i.height), this.Ln.Wi(this.Br), this.qo.Wi(this.Br), this.Yo = this.xt.je(this.Br.cols, this.Br.rows, 5), this.th = this.xt.je(this.Br.width, this.Br.height, 1), this.hr && (this.fh = G.Mr(this.xt, this.tr.targetCanvas, (s) => this.Ei.Si(s))), this.sh = this.xt.cs(st, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this._h(), await this.ph(this.ih), this.ih = [], this.rh = !0, this.oh(), this.jo.start(() => this.Vo());
2570
- }
2571
- async ph(e) {
2572
- if (e.length) for (const i of e) this.eh.has(i.name) ? console.warn(`[textmode.js] Plugin "${i.name}" is already installed.`) : (await i.install(this, this.mh()), this.eh.set(i.name, i));
2573
- }
2574
- async gh(e) {
2575
- const i = this.eh.get(e);
2576
- i && (i.uninstall && await i.uninstall(this, this.mh()), this.eh.delete(e));
2674
+ this.Lr = new Ht(this.er.canvas, i.width, i.height), this.Hn.Ki(this.Lr), this.Qo.Ki(this.Lr), this.Vo = this.xt.Ye(this.Lr.cols, this.Lr.rows, 5), this.ph = this.xt.Ye(this.Lr.width, this.Lr.height, 1), this.cr && (this.Mh = G.zr(this.xt, this.er.targetCanvas, (s) => this.Ei.Si(s))), this._h = this.xt.cs(st, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.zh(), await this.mh.installMany(this.gh), this.gh = [], this.yh = !0, this.Ch(), this.qo.start(() => this.Zo());
2577
2675
  }
2578
2676
  async use(e) {
2579
- return this.rh ? await this.ph([e]) : this.ih.push(e), this;
2677
+ return this.yh ? await this.mh.use(e) : this.gh.push(e), this;
2580
2678
  }
2581
2679
  async unuse(e) {
2582
- return this.rh ? (await this.gh(e), this) : (this.ih = this.ih.filter((i) => i.name !== e), this);
2680
+ return this.yh ? (await this.mh.unuse(e), this) : (this.gh = this.gh.filter((i) => i.name !== e), this);
2583
2681
  }
2584
2682
  hasPlugin(e) {
2585
- return this.rh ? this.eh.has(e) : this.ih.some((i) => i.name === e) || this.eh.has(e);
2683
+ return this.yh ? this.mh.has(e) : this.gh.some((i) => i.name === e);
2586
2684
  }
2587
- mh() {
2588
- return { renderer: this.xt, font: this.Ei, grid: this.Br, canvas: this.tr, drawFramebuffer: this.Yo, asciiFramebuffer: this.th, flushDrawCommands: () => {
2589
- this.xt.St(this.Qo);
2685
+ ah() {
2686
+ return { renderer: this.xt, font: this.Ei, grid: this.Lr, canvas: this.er, drawFramebuffer: this.Vo, asciiFramebuffer: this.ph, flushDrawCommands: () => {
2687
+ this.xt.St(this.fh);
2590
2688
  } };
2591
2689
  }
2592
- _h() {
2593
- this.uh = () => {
2594
- this.hr && this.resizeCanvas(this.tr.targetCanvas.width, this.tr.targetCanvas.height), this.ah();
2595
- }, window.addEventListener("resize", this.uh), this.Ln.nn(), this.qo.nn(), this.Zo.nn(), window.addEventListener("blur", () => {
2596
- this.Zo.Bn();
2597
- }), window.ResizeObserver && this.hr && (this.ar = new ResizeObserver(() => {
2598
- this.resizeCanvas(this.tr.targetCanvas.width, this.tr.targetCanvas.height);
2599
- }), this.ar.observe(this.tr.targetCanvas));
2600
- }
2601
- Vo() {
2602
- if (this.jo.measureFrameRate(), this.jo.incrementFrame(), this.nh) return;
2603
- if (this.hr) {
2690
+ zh() {
2691
+ this.xh = () => {
2692
+ this.cr && this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height), this.bh();
2693
+ }, window.addEventListener("resize", this.xh), this.Hn.an(), this.Qo.an(), this.Jo.an(), window.addEventListener("blur", () => {
2694
+ this.Jo.Ln();
2695
+ }), window.ResizeObserver && this.cr && (this.lr = new ResizeObserver(() => {
2696
+ this.resizeCanvas(this.er.targetCanvas.width, this.er.targetCanvas.height);
2697
+ }), this.lr.observe(this.er.targetCanvas));
2698
+ }
2699
+ Zo() {
2700
+ if (this.qo.measureFrameRate(), this.qo.incrementFrame(), this.Ah) return;
2701
+ if (this.cr) {
2604
2702
  const i = this.xt.context;
2605
- i.bindTexture(i.TEXTURE_2D, this.fh.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.tr.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2703
+ i.bindTexture(i.TEXTURE_2D, this.Mh.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.er.targetCanvas), i.bindTexture(i.TEXTURE_2D, null);
2606
2704
  }
2607
- this.Yo.begin(), this.xt.ke(this.Qo), this.hh(), this.xt.St(this.Qo), this.Yo.end(), this.th.begin(), this.xt.ke(this.Jo), this.Jo.Wt({ U0: this.Ei.fontFramebuffer, U1: [this.Ei.textureColumns, this.Ei.textureRows], U2: this.Yo.textures[0], U3: this.Yo.textures[1], U4: this.Yo.textures[2], U5: this.Yo.textures[4], U6: this.Yo.textures[3], U7: [this.Br.cols, this.Br.rows], U8: [this.th.width, this.th.height], U9: this.th.width / this.th.height }), this.xt.Ie(0, 0, this.tr.width, this.tr.height), this.th.end();
2705
+ this.mh.runPreDrawHooks(), this.Vo.begin(), this.xt.ke(this.fh), this.wh(), this.xt.St(this.fh), this.Vo.end(), this.ph.begin(), this.xt.ke(this.dh), this.dh.Wt({ U0: this.Ei.fontFramebuffer, U1: [this.Ei.textureColumns, this.Ei.textureRows], U2: this.Vo.textures[0], U3: this.Vo.textures[1], U4: this.Vo.textures[2], U5: this.Vo.textures[4], U6: this.Vo.textures[3], U7: [this.Lr.cols, this.Lr.rows], U8: [this.ph.width, this.ph.height], U9: this.ph.width / this.ph.height }), this.xt.Ie(0, 0, this.er.width, this.er.height), this.ph.end();
2608
2706
  const e = this.xt.state.canvasBackgroundColor;
2609
- this.xt.js(e[0], e[1], e[2], e[3]), this.xt.ke(this.sh), this.sh.Wt({ Ua: this.th.textures[0], Ub: [this.th.width, this.th.height], Uc: [this.Br.offsetX, this.Br.offsetY], Ud: [this.Br.width, this.Br.height] }), this.xt.Ie(this.Br.offsetX, this.Br.offsetY, this.Br.width, this.Br.height);
2707
+ this.xt.Ys(e[0], e[1], e[2], e[3]), this.xt.ke(this._h), this._h.Wt({ Ua: this.ph.textures[0], Ub: [this.ph.width, this.ph.height], Uc: [this.Lr.offsetX, this.Lr.offsetY], Ud: [this.Lr.width, this.Lr.height] }), this.xt.Ie(this.Lr.offsetX, this.Lr.offsetY, this.Lr.width, this.Lr.height), this.mh.runPostDrawHooks();
2610
2708
  }
2611
2709
  setup(e) {
2612
- this.oh = e;
2710
+ this.Ch = e;
2613
2711
  }
2614
2712
  draw(e) {
2615
- this.hh = e;
2713
+ this.wh = e;
2616
2714
  }
2617
2715
  windowResized(e) {
2618
- this.ah = e;
2716
+ this.bh = e;
2619
2717
  }
2620
2718
  resizeCanvas(e, i) {
2621
- this.tr.pr(e, i), this.Br.ir(), this.Yo.resize(this.Br.cols, this.Br.rows), this.th.resize(this.Br.width, this.Br.height), this.xt.Ze(), this.Ln.rn(), this.qo.Ao(), this.Vo();
2719
+ this.er.vr(e, i), this.Lr.nr(), this.Vo.resize(this.Lr.cols, this.Lr.rows), this.ph.resize(this.Lr.width, this.Lr.height), this.xt.Ze(), this.Hn.hn(), this.Qo.Co(), this.Zo();
2622
2720
  }
2623
2721
  destroy() {
2624
- this.nh || (this.jo.stop(), window.removeEventListener("resize", this.uh), this.Ln.dn(), this.qo.dn(), this.Zo.dn(), this.Ei.Dt(), this.xt.Dt(), this.th.Dt(), this.sh.Dt(), this.fh && this.fh.Dt(), this.nh = !0);
2722
+ this.Ah || (this.qo.stop(), this.mh.disposeAll().catch((e) => {
2723
+ console.error("[textmode.js] Error while disposing plugins:", e);
2724
+ }), window.removeEventListener("resize", this.xh), this.Hn._n(), this.Qo._n(), this.Jo._n(), this.Ei.Dt(), this.xt.Dt(), this.ph.Dt(), this._h.Dt(), this.Mh && this.Mh.Dt(), this.Ah = !0);
2625
2725
  }
2626
2726
  get grid() {
2627
- return this.Br;
2727
+ return this.Lr;
2628
2728
  }
2629
2729
  get font() {
2630
2730
  return this.Ei;
2631
2731
  }
2632
2732
  get width() {
2633
- return this.tr.width;
2733
+ return this.er.width;
2634
2734
  }
2635
2735
  get height() {
2636
- return this.tr.height;
2736
+ return this.er.height;
2637
2737
  }
2638
2738
  get canvas() {
2639
- return this.tr.canvas;
2739
+ return this.er.canvas;
2740
+ }
2741
+ get drawFramebuffer() {
2742
+ return this.Vo;
2640
2743
  }
2641
2744
  get isDisposed() {
2642
- return this.nh;
2745
+ return this.Ah;
2643
2746
  }
2644
2747
  get overlay() {
2645
- return this.fh;
2748
+ return this.Mh;
2646
2749
  }
2647
2750
  }
2648
2751
  class Q {
2649
2752
  constructor() {
2650
2753
  }
2651
2754
  static create(t = {}) {
2652
- return new te(t);
2755
+ return new ee(t);
2653
2756
  }
2654
2757
  static setErrorLevel(t) {
2655
- N.A(t);
2758
+ z.A(t);
2656
2759
  }
2657
2760
  static get version() {
2658
- return "0.3.2-beta.2";
2761
+ return "0.3.2-beta.3";
2659
2762
  }
2660
2763
  }
2661
- const ie = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), se = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: jt, mouse: Ht, touch: kt }, Symbol.toStringTag, { value: "Module" })), re = Q.create, ne = Q.setErrorLevel, oe = Q.version;
2764
+ const se = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), re = Object.freeze(Object.defineProperty({ __proto__: null, keyboard: kt, mouse: Wt, touch: Vt }, Symbol.toStringTag, { value: "Module" })), ne = Q.create, oe = Q.setErrorLevel, he = Q.version;
2662
2765
  export {
2663
- Yt as TextmodeCanvas,
2766
+ $t as PluginManager,
2767
+ Xt as TextmodeCanvas,
2664
2768
  ct as TextmodeErrorLevel,
2665
2769
  Gt as TextmodeFont,
2666
- K as TextmodeFramebuffer,
2667
- Xt as TextmodeGrid,
2770
+ j as TextmodeFramebuffer,
2771
+ Ht as TextmodeGrid,
2668
2772
  G as TextmodeImage,
2669
- te as Textmodifier,
2670
- re as create,
2671
- ie as export,
2672
- se as input,
2673
- ne as setErrorLevel,
2773
+ ee as Textmodifier,
2774
+ ne as create,
2775
+ se as export,
2776
+ re as input,
2777
+ oe as setErrorLevel,
2674
2778
  Q as textmode,
2675
- oe as version
2779
+ he as version
2676
2780
  };