textmode.js 0.1.9-beta.4 → 0.1.9-beta.5

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.
@@ -41,7 +41,7 @@ const M = class M {
41
41
  static u() {
42
42
  return M.h || (M.h = new M()), M.h;
43
43
  }
44
- m(t, e) {
44
+ p(t, e) {
45
45
  const r = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
46
46
  switch (this.l.globalLevel) {
47
47
  case 0:
@@ -54,8 +54,8 @@ const M = class M {
54
54
  throw new w(t, e);
55
55
  }
56
56
  }
57
- p(t, e, r) {
58
- return !!t || (this.m(e, r), !1);
57
+ m(t, e, r) {
58
+ return !!t || (this.p(e, r), !1);
59
59
  }
60
60
  _(t) {
61
61
  this.l.globalLevel = t;
@@ -63,14 +63,14 @@ const M = class M {
63
63
  };
64
64
  h(M, "h", null);
65
65
  let k = M;
66
- const x = k.u(), q = /* @__PURE__ */ new WeakMap();
66
+ const v = k.u(), Q = /* @__PURE__ */ new WeakMap();
67
67
  function I(a, t) {
68
- q.set(a, t);
68
+ Q.set(a, t);
69
69
  }
70
- function Z(a) {
71
- return q.get(a);
70
+ function q(a) {
71
+ return Q.get(a);
72
72
  }
73
- class J {
73
+ class Z {
74
74
  constructor(t, e, r = e, s = {}) {
75
75
  h(this, "v");
76
76
  h(this, "C");
@@ -135,21 +135,21 @@ class J {
135
135
  get(t, e, r, s) {
136
136
  const { v: i } = this;
137
137
  if (t === void 0 && e === void 0) {
138
- const n = new Uint8Array(this.F * this.M * 4);
139
- return this.k(() => (i.readPixels(0, 0, this.F, this.M, i.RGBA, i.UNSIGNED_BYTE, n), n));
138
+ const o = new Uint8Array(this.F * this.M * 4);
139
+ return this.k(() => (i.readPixels(0, 0, this.F, this.M, i.RGBA, i.UNSIGNED_BYTE, o), o));
140
140
  }
141
141
  if (r === void 0 && s === void 0) {
142
142
  (t < 0 || e < 0 || t >= this.F || e >= this.M) && (console.warn("The x and y values passed to Framebuffer.get are outside of its range and will be clamped."), t = Math.max(0, Math.min(t, this.F - 1)), e = Math.max(0, Math.min(e, this.M - 1)));
143
- const n = new Uint8Array(4);
144
- return this.k(() => (i.readPixels(t, e, 1, 1, i.RGBA, i.UNSIGNED_BYTE, n), [n[0], n[1], n[2], n[3]]));
143
+ const o = new Uint8Array(4);
144
+ return this.k(() => (i.readPixels(t, e, 1, 1, i.RGBA, i.UNSIGNED_BYTE, o), [o[0], o[1], o[2], o[3]]));
145
145
  }
146
146
  {
147
147
  t = Math.max(0, Math.min(t, this.F - 1)), e = Math.max(0, Math.min(e, this.M - 1)), r = Math.max(1, Math.min(r, this.F - t)), s = Math.max(1, Math.min(s, this.M - e));
148
- const n = new Uint8Array(r * s * 4);
149
- return this.k(() => (i.readPixels(t, e, r, s, i.RGBA, i.UNSIGNED_BYTE, n), n));
148
+ const o = new Uint8Array(r * s * 4);
149
+ return this.k(() => (i.readPixels(t, e, r, s, i.RGBA, i.UNSIGNED_BYTE, o), o));
150
150
  }
151
151
  }
152
- G() {
152
+ P() {
153
153
  this.C && this.v.deleteFramebuffer(this.C), this.$ && this.v.deleteTexture(this.$);
154
154
  }
155
155
  get framebuffer() {
@@ -171,19 +171,19 @@ class J {
171
171
  class R {
172
172
  constructor(t, e, r) {
173
173
  h(this, "v");
174
- h(this, "P");
174
+ h(this, "G");
175
175
  h(this, "A", /* @__PURE__ */ new Map());
176
176
  h(this, "U", /* @__PURE__ */ new Map());
177
177
  h(this, "L", 0);
178
178
  h(this, "H");
179
- this.v = t, this.P = this.j(e, r), this.H = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.O();
179
+ this.v = t, this.G = this.j(e, r), this.H = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.O();
180
180
  }
181
181
  O() {
182
- const t = this.v.getProgramParameter(this.P, this.v.ACTIVE_UNIFORMS);
182
+ const t = this.v.getProgramParameter(this.G, this.v.ACTIVE_UNIFORMS);
183
183
  for (let e = 0; e < t; e++) {
184
- const r = this.v.getActiveUniform(this.P, e);
184
+ const r = this.v.getActiveUniform(this.G, e);
185
185
  if (r) {
186
- const s = this.v.getUniformLocation(this.P, r.name);
186
+ const s = this.v.getUniformLocation(this.G, r.name);
187
187
  s && (this.A.set(r.name, s), this.U.set(r.name, r.type));
188
188
  }
189
189
  }
@@ -191,8 +191,8 @@ class R {
191
191
  j(t, e) {
192
192
  const r = this.W(this.v.VERTEX_SHADER, t), s = this.W(this.v.FRAGMENT_SHADER, e), i = this.v.createProgram();
193
193
  if (this.v.attachShader(i, r), this.v.attachShader(i, s), this.v.linkProgram(i), !this.v.getProgramParameter(i, this.v.LINK_STATUS)) {
194
- const n = this.v.getProgramInfoLog(i);
195
- throw Error("Shader program link error: " + n);
194
+ const o = this.v.getProgramInfoLog(i);
195
+ throw Error("Shader program link error: " + o);
196
196
  }
197
197
  return this.v.deleteShader(r), this.v.deleteShader(s), i;
198
198
  }
@@ -205,7 +205,7 @@ class R {
205
205
  return r;
206
206
  }
207
207
  N() {
208
- this.v.useProgram(this.P), this.X();
208
+ this.v.useProgram(this.G), this.X();
209
209
  }
210
210
  setUniform(t, e) {
211
211
  const r = this.A.get(t);
@@ -228,7 +228,7 @@ class R {
228
228
  else if (e instanceof WebGLTexture) {
229
229
  const s = this.Y();
230
230
  this.v.uniform1i(r, s), this.v.activeTexture(this.v.TEXTURE0 + s), this.v.bindTexture(this.v.TEXTURE_2D, e);
231
- } else if (e instanceof J) {
231
+ } else if (e instanceof Z) {
232
232
  const s = this.Y();
233
233
  this.v.uniform1i(r, s), this.v.activeTexture(this.v.TEXTURE0 + s), this.v.bindTexture(this.v.TEXTURE_2D, e.texture);
234
234
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
@@ -241,16 +241,16 @@ class R {
241
241
  return !!e && (e === this.v.INT || e === this.v.INT_VEC2 || e === this.v.INT_VEC3 || e === this.v.INT_VEC4 || e === this.v.SAMPLER_2D || e === this.v.SAMPLER_CUBE);
242
242
  }
243
243
  get glProgram() {
244
- return this.P;
244
+ return this.G;
245
245
  }
246
- G() {
247
- this.v.deleteProgram(this.P);
246
+ P() {
247
+ this.v.deleteProgram(this.G);
248
248
  }
249
249
  X() {
250
250
  this.L = 0;
251
251
  }
252
252
  }
253
- class Q {
253
+ class J {
254
254
  constructor(t) {
255
255
  h(this, "v");
256
256
  h(this, "Z", null);
@@ -268,59 +268,59 @@ class Q {
268
268
  let r = this.K.get(e);
269
269
  return r || (r = { a_position: t.getAttribLocation(e, "a_position"), a_texCoord: t.getAttribLocation(e, "a_texCoord") }, this.K.set(e, r)), t.enableVertexAttribArray(r.a_position), t.vertexAttribPointer(r.a_position, 2, t.FLOAT, !1, this.J, 0), t.enableVertexAttribArray(r.a_texCoord), t.vertexAttribPointer(r.a_texCoord, 2, t.FLOAT, !1, this.J, 8), { positionLoc: r.a_position, texLoc: r.a_texCoord };
270
270
  }
271
- rt(t, e) {
271
+ st(t, e) {
272
272
  const r = this.v;
273
273
  r.disableVertexAttribArray(t), r.disableVertexAttribArray(e);
274
274
  }
275
- st(t, e) {
276
- const r = this.v, s = Z(r) || [0, 0, r.canvas.width, r.canvas.height];
275
+ rt(t, e) {
276
+ const r = this.v, s = q(r) || [0, 0, r.canvas.width, r.canvas.height];
277
277
  return { nx: t / s[2] * 2 - 1, ny: 1 - e / s[3] * 2 };
278
278
  }
279
279
  it(t, e, r, s) {
280
280
  const i = this.v;
281
281
  this.tt(), i.bindBuffer(i.ARRAY_BUFFER, this.Z);
282
- const n = new Float32Array([t, s, 0, 0, r, s, 1, 0, t, e, 0, 1, t, e, 0, 1, r, s, 1, 0, r, e, 1, 1]);
283
- i.bufferData(i.ARRAY_BUFFER, n, i.DYNAMIC_DRAW);
282
+ const o = new Float32Array([t, s, 0, 0, r, s, 1, 0, t, e, 0, 1, t, e, 0, 1, r, s, 1, 0, r, e, 1, 1]);
283
+ i.bufferData(i.ARRAY_BUFFER, o, i.DYNAMIC_DRAW);
284
284
  }
285
- G() {
285
+ P() {
286
286
  this.Z && this.v.deleteBuffer(this.Z);
287
287
  }
288
288
  }
289
- class st extends Q {
289
+ class st extends J {
290
290
  constructor(t) {
291
291
  super(t);
292
292
  }
293
293
  nt(t, e, r, s) {
294
- const i = this.st(t, e), n = this.st(t + r, e + s);
295
- this.it(i.nx, i.ny, n.nx, n.ny);
296
- const o = this.et();
297
- this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(o.positionLoc, o.texLoc);
294
+ const i = this.rt(t, e), o = this.rt(t + r, e + s);
295
+ this.it(i.nx, i.ny, o.nx, o.ny);
296
+ const n = this.et();
297
+ this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.st(n.positionLoc, n.texLoc);
298
298
  }
299
299
  ot(t, e, r, s, i) {
300
300
  this.nt(t, e, r, i), this.nt(t + r - i, e, i, s), this.nt(t, e + s - i, r, i), this.nt(t, e, i, s);
301
301
  }
302
302
  }
303
- class it extends Q {
303
+ class it extends J {
304
304
  constructor(t) {
305
305
  super(t);
306
306
  }
307
307
  ht(t, e, r, s, i) {
308
- const n = r - t, o = s - e, l = Math.hypot(n, o);
308
+ const o = r - t, n = s - e, l = Math.hypot(o, n);
309
309
  if (l === 0) {
310
- const u = i / 2, f = this.st(t - u, e - u), d = this.st(t + u, e + u);
310
+ const u = i / 2, f = this.rt(t - u, e - u), d = this.rt(t + u, e + u);
311
311
  this.it(f.nx, f.ny, d.nx, d.ny);
312
312
  } else {
313
- const u = -o / l, f = n / l, d = i / 2, v = t + u * d, p = e + f * d, g = t - u * d, C = e - f * d, m = r + u * d, b = s + f * d, T = r - u * d, E = s - f * d, A = this.st(v, p), F = this.st(g, C), U = this.st(m, b), V = this.st(T, E), S = this.v;
313
+ const u = -n / l, f = o / l, d = i / 2, m = t + u * d, p = e + f * d, g = t - u * d, C = e - f * d, x = r + u * d, b = s + f * d, E = r - u * d, T = s - f * d, A = this.rt(m, p), F = this.rt(g, C), P = this.rt(x, b), V = this.rt(E, T), S = this.v;
314
314
  this.tt(), S.bindBuffer(S.ARRAY_BUFFER, this.Z);
315
- const K = new Float32Array([A.nx, A.ny, 0, 0, F.nx, F.ny, 0, 1, U.nx, U.ny, 1, 0, F.nx, F.ny, 0, 1, V.nx, V.ny, 1, 1, U.nx, U.ny, 1, 0]);
315
+ const K = new Float32Array([A.nx, A.ny, 0, 0, F.nx, F.ny, 0, 1, P.nx, P.ny, 1, 0, F.nx, F.ny, 0, 1, V.nx, V.ny, 1, 1, P.nx, P.ny, 1, 0]);
316
316
  S.bufferData(S.ARRAY_BUFFER, K, S.DYNAMIC_DRAW);
317
317
  }
318
318
  const c = this.et();
319
- this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.rt(c.positionLoc, c.texLoc);
319
+ this.v.drawArrays(this.v.TRIANGLES, 0, 6), this.st(c.positionLoc, c.texLoc);
320
320
  }
321
321
  }
322
322
  var $ = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}";
323
- class nt {
323
+ class ot {
324
324
  constructor(t) {
325
325
  h(this, "v");
326
326
  h(this, "lt");
@@ -383,68 +383,74 @@ class nt {
383
383
  kt() {
384
384
  this.ut = null, this.Ct = [], this.wt = 0;
385
385
  }
386
- It(t, e) {
386
+ It(t) {
387
+ const e = t.replace(/\/\*[\s\S]*?\*\//g, "").replace(/\/\/.*$/gm, "").trim().match(/^#version\s+(\d+)\s+(es)?/i);
388
+ return e ? parseInt(e[1], 10) >= 300 : !1;
389
+ }
390
+ Pt(t, e) {
387
391
  return new R(this.v, t, e);
388
392
  }
389
393
  zt(t) {
390
- return new R(this.v, $, t);
394
+ const e = this.It(t) ? `#version 300 es
395
+ in vec2 a_position;in vec2 a_texCoord;out vec2 v_uv;uniform float u_rotation;uniform vec2 u_center;uniform float u_aspectRatio;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){v_uv=a_texCoord;vec2 pos=a_position;pos-=u_center;pos.x*=u_aspectRatio;pos=rotate2D(-u_rotation)*pos;pos.x/=u_aspectRatio;pos+=u_center;gl_Position=vec4(pos,0.0,1.0);}` : $;
396
+ return new R(this.v, e, t);
391
397
  }
392
398
  Et(t, e) {
393
399
  this.ut.setUniform(t, e);
394
400
  }
395
401
  Gt(t, e, r, s) {
396
402
  if (this.ut !== null) {
397
- const { centerX: f, centerY: d, radians: v, aspectRatio: p } = this.Pt(t, e, r, s);
398
- return this.Et("u_rotation", v), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p), this.ft.nt(t, e, r, s), void (this.ut = null);
403
+ const { centerX: f, centerY: d, radians: m, aspectRatio: p } = this.At(t, e, r, s);
404
+ return this.Et("u_rotation", m), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p), this.ft.nt(t, e, r, s), void (this.ut = null);
399
405
  }
400
406
  const i = this.ct;
401
- let n = 0, o = 0, l = 0, c = 1;
402
- const u = this.Pt(t, e, r, s);
403
- n = u.centerX, o = u.centerY, l = u.radians, c = u.aspectRatio, this._t && (this.yt(i), this.Et("u_color", this.gt), this.Et("u_rotation", l), this.Et("u_center", [n, o]), this.Et("u_aspectRatio", c), this.ft.nt(t, e, r, s)), this.bt && this.xt > 0 && (this.yt(i), this.Et("u_color", this.vt), this.Et("u_rotation", l), this.Et("u_center", [n, o]), this.Et("u_aspectRatio", c), this.ft.ot(t, e, r, s, this.xt)), this.ut = null;
407
+ let o = 0, n = 0, l = 0, c = 1;
408
+ const u = this.At(t, e, r, s);
409
+ o = u.centerX, n = u.centerY, l = u.radians, c = u.aspectRatio, this._t && (this.yt(i), this.Et("u_color", this.gt), this.Et("u_rotation", l), this.Et("u_center", [o, n]), this.Et("u_aspectRatio", c), this.ft.nt(t, e, r, s)), this.bt && this.xt > 0 && (this.yt(i), this.Et("u_color", this.vt), this.Et("u_rotation", l), this.Et("u_center", [o, n]), this.Et("u_aspectRatio", c), this.ft.ot(t, e, r, s, this.xt)), this.ut = null;
404
410
  }
405
- At(t, e, r, s) {
411
+ Ut(t, e, r, s) {
406
412
  if (this.ut !== null) {
407
- const g = (t + r) / 2, C = (e + s) / 2, m = Math.abs(r - t) || 1, b = Math.abs(s - e) || 1, { centerX: T, centerY: E, radians: A, aspectRatio: F } = this.Pt(g - m / 2, C - b / 2, m, b);
408
- this.Et("u_rotation", A), this.Et("u_center", [T, E]), this.Et("u_aspectRatio", F);
409
- const U = this.xt > 0 ? this.xt : 1;
410
- return this.dt.ht(t, e, r, s, U), void (this.ut = null);
413
+ const g = (t + r) / 2, C = (e + s) / 2, x = Math.abs(r - t) || 1, b = Math.abs(s - e) || 1, { centerX: E, centerY: T, radians: A, aspectRatio: F } = this.At(g - x / 2, C - b / 2, x, b);
414
+ this.Et("u_rotation", A), this.Et("u_center", [E, T]), this.Et("u_aspectRatio", F);
415
+ const P = this.xt > 0 ? this.xt : 1;
416
+ return this.dt.ht(t, e, r, s, P), void (this.ut = null);
411
417
  }
412
418
  if (!this.bt || this.xt <= 0) return;
413
- const i = this.ct, n = (t + r) / 2, o = (e + s) / 2, l = Math.abs(r - t) || 1, c = Math.abs(s - e) || 1, u = this.wt !== 0;
414
- let f = 0, d = 0, v = 0, p = 1;
419
+ const i = this.ct, o = (t + r) / 2, n = (e + s) / 2, l = Math.abs(r - t) || 1, c = Math.abs(s - e) || 1, u = this.wt !== 0;
420
+ let f = 0, d = 0, m = 0, p = 1;
415
421
  if (u) {
416
- const g = this.Pt(n - l / 2, o - c / 2, l, c);
417
- f = g.centerX, d = g.centerY, v = g.radians, p = g.aspectRatio;
422
+ const g = this.At(o - l / 2, n - c / 2, l, c);
423
+ f = g.centerX, d = g.centerY, m = g.radians, p = g.aspectRatio;
418
424
  }
419
- this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation", v), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p)), this.dt.ht(t, e, r, s, this.xt);
425
+ this.yt(i), this.Et("u_color", this.vt), u && (this.Et("u_rotation", m), this.Et("u_center", [f, d]), this.Et("u_aspectRatio", p)), this.dt.ht(t, e, r, s, this.xt);
420
426
  }
421
- Pt(t, e, r, s) {
422
- const i = Z(this.v) || [0, 0, this.v.canvas.width, this.v.canvas.height], n = i[2], o = i[3], l = n / o;
423
- return { centerX: (t + r / 2) / n * 2 - 1, centerY: 1 - (e + s / 2) / o * 2, radians: this.wt * Math.PI / 180, aspectRatio: l };
427
+ At(t, e, r, s) {
428
+ const i = q(this.v) || [0, 0, this.v.canvas.width, this.v.canvas.height], o = i[2], n = i[3], l = o / n;
429
+ return { centerX: (t + r / 2) / o * 2 - 1, centerY: 1 - (e + s / 2) / n * 2, radians: this.wt * Math.PI / 180, aspectRatio: l };
424
430
  }
425
- Ut(t, e, r = {}) {
426
- return new J(this.v, t, e, r);
431
+ Lt(t, e, r = {}) {
432
+ return new Z(this.v, t, e, r);
427
433
  }
428
- Lt(t, e = t, r = t, s = 255) {
429
- this.Ht(t / 255, e / 255, r / 255, s / 255);
434
+ Ht(t, e = t, r = t, s = 255) {
435
+ this.jt(t / 255, e / 255, r / 255, s / 255);
430
436
  }
431
- Ht(t = 0, e = 0, r = 0, s = 0) {
437
+ jt(t = 0, e = 0, r = 0, s = 0) {
432
438
  this.v.clearColor(t, e, r, s), this.v.clear(this.v.COLOR_BUFFER_BIT);
433
439
  }
434
- jt() {
440
+ Bt() {
435
441
  this.v.viewport(0, 0, this.v.canvas.width, this.v.canvas.height), I(this.v, [0, 0, this.v.canvas.width, this.v.canvas.height]);
436
442
  }
437
443
  get context() {
438
444
  return this.v;
439
445
  }
440
- G() {
441
- this.lt.G(), this.ct.G(), this.ft.G(), this.dt.G();
446
+ P() {
447
+ this.lt.P(), this.ct.P(), this.ft.P(), this.dt.P();
442
448
  }
443
- Bt(t, e, r, s, i) {
444
- const n = this.v, o = s ?? t.width, l = i ?? t.height;
449
+ Ot(t, e, r, s, i) {
450
+ const o = this.v, n = s ?? t.width, l = i ?? t.height;
445
451
  this.yt(this.lt), this.Et("u_texture", t.texture);
446
- const c = this.Pt(e, r, o, l);
447
- this.Et("u_rotation", c.radians), this.Et("u_center", [c.centerX, c.centerY]), this.Et("u_aspectRatio", c.aspectRatio), this.ft.nt(e, r, o, l), n.bindTexture(n.TEXTURE_2D, null), this.ut = null;
452
+ const c = this.At(e, r, n, l);
453
+ this.Et("u_rotation", c.radians), this.Et("u_center", [c.centerX, c.centerY]), this.Et("u_aspectRatio", c.aspectRatio), this.ft.nt(e, r, n, l), o.bindTexture(o.TEXTURE_2D, null), this.ut = null;
448
454
  }
449
455
  }
450
456
  const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
@@ -461,35 +467,35 @@ const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int1
461
467
  }, t: (() => {
462
468
  const a = new ArrayBuffer(8);
463
469
  return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
464
- })() }, ot = { parseTab(a, t, e) {
470
+ })() }, nt = { parseTab(a, t, e) {
465
471
  const r = { tables: [], ids: {}, off: t };
466
472
  a = new Uint8Array(a.buffer, t, e), t = 0;
467
- const s = y, i = s.readUshort, n = i(a, t += 2);
473
+ const s = y, i = s.readUshort, o = i(a, t += 2);
468
474
  t += 2;
469
- const o = [];
470
- for (let l = 0; l < n; l++) {
475
+ const n = [];
476
+ for (let l = 0; l < o; l++) {
471
477
  const c = i(a, t), u = i(a, t += 2);
472
478
  t += 2;
473
479
  const f = s.readUint(a, t);
474
480
  t += 4;
475
481
  const d = `p${c}e${u}`;
476
- let v = o.indexOf(f);
477
- if (v === -1) {
482
+ let m = n.indexOf(f);
483
+ if (m === -1) {
478
484
  let p;
479
- v = r.tables.length, o.push(f);
485
+ m = r.tables.length, n.push(f);
480
486
  const g = i(a, f);
481
487
  p = g === 4 ? this.parse4(a, f) : g === 12 ? this.parse12(a, f) : { format: g }, r.tables.push(p);
482
488
  }
483
- r.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), r.ids[d] = v;
489
+ r.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), r.ids[d] = m;
484
490
  }
485
491
  return r;
486
492
  }, parse4(a, t) {
487
- const e = y, r = e.readUshort, s = e.readUshorts, i = t, n = r(a, t += 2);
493
+ const e = y, r = e.readUshort, s = e.readUshorts, i = t, o = r(a, t += 2);
488
494
  t += 2;
489
- const o = r(a, t += 2) >>> 1, l = { format: 4, searchRange: r(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
490
- t += 2, l.entrySelector = r(a, t), t += 2, l.rangeShift = r(a, t), t += 2, l.endCount = s(a, t, o), t += 2 * o, t += 2, l.startCount = s(a, t, o), t += 2 * o;
491
- for (let c = 0; c < o; c++) l.idDelta.push(e.readShort(a, t)), t += 2;
492
- return l.idRangeOffset = s(a, t, o), t += 2 * o, l.glyphIdArray = s(a, t, i + n - t >> 1), l;
495
+ const n = r(a, t += 2) >>> 1, l = { format: 4, searchRange: r(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
496
+ t += 2, l.entrySelector = r(a, t), t += 2, l.rangeShift = r(a, t), t += 2, l.endCount = s(a, t, n), t += 2 * n, t += 2, l.startCount = s(a, t, n), t += 2 * n;
497
+ for (let c = 0; c < n; c++) l.idDelta.push(e.readShort(a, t)), t += 2;
498
+ return l.idRangeOffset = s(a, t, n), t += 2 * n, l.glyphIdArray = s(a, t, i + o - t >> 1), l;
493
499
  }, parse12(a, t) {
494
500
  const e = y.readUint;
495
501
  e(a, t += 4), e(a, t += 4);
@@ -505,148 +511,148 @@ const y = { readShort: (a, t) => (y.t.uint16[0] = a[t] << 8 | a[t + 1], y.t.int1
505
511
  t += 2, t += 16;
506
512
  const i = r.readShort(a, t);
507
513
  t += 2;
508
- const n = r.readShort(a, t);
509
- t += 2;
510
514
  const o = r.readShort(a, t);
511
515
  t += 2;
516
+ const n = r.readShort(a, t);
517
+ t += 2;
512
518
  const l = r.readShort(a, t);
513
- return t += 2, t += 6, { unitsPerEm: s, xMin: i, yMin: n, xMax: o, yMax: l, indexToLocFormat: r.readShort(a, t) };
519
+ return t += 2, t += 6, { unitsPerEm: s, xMin: i, yMin: o, xMax: n, yMax: l, indexToLocFormat: r.readShort(a, t) };
514
520
  } }, ht = { parseTab(a, t, e) {
515
521
  const r = y;
516
522
  t += 4;
517
523
  const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], i = {};
518
- for (let n = 0; n < s.length; n++) {
519
- const o = s[n], l = o === "advanceWidthMax" || o === "numberOfHMetrics" ? r.readUshort : r.readShort;
520
- i[o] = l(a, t + 2 * n);
524
+ for (let o = 0; o < s.length; o++) {
525
+ const n = s[o], l = n === "advanceWidthMax" || n === "numberOfHMetrics" ? r.readUshort : r.readShort;
526
+ i[n] = l(a, t + 2 * o);
521
527
  }
522
528
  return i;
523
529
  } }, lt = { parseTab(a, t, e, r) {
524
530
  if (!r) throw Error("Font object required for hmtx parsing");
525
- const s = y, i = [], n = [], o = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics;
531
+ const s = y, i = [], o = [], n = r.maxp.numGlyphs, l = r.hhea.numberOfHMetrics;
526
532
  let c = 0, u = 0, f = 0;
527
- for (; f < l; ) c = s.readUshort(a, t + (f << 2)), u = s.readShort(a, t + (f << 2) + 2), i.push(c), n.push(u), f++;
528
- for (; f < o; ) i.push(c), n.push(u), f++;
529
- return { aWidth: i, lsBearing: n };
530
- } }, O = { cmap: ot, head: at, hhea: ht, maxp: { parseTab(a, t, e) {
533
+ for (; f < l; ) c = s.readUshort(a, t + (f << 2)), u = s.readShort(a, t + (f << 2) + 2), i.push(c), o.push(u), f++;
534
+ for (; f < n; ) i.push(c), o.push(u), f++;
535
+ return { aWidth: i, lsBearing: o };
536
+ } }, W = { cmap: nt, head: at, hhea: ht, maxp: { parseTab(a, t, e) {
531
537
  const r = y;
532
538
  return r.readUint(a, t), t += 4, { numGlyphs: r.readUshort(a, t) };
533
539
  } }, hmtx: lt, loca: { parseTab(a, t, e, r) {
534
540
  if (!r) throw Error("Font object required for loca parsing");
535
- const s = y, i = [], n = r.head.indexToLocFormat, o = r.maxp.numGlyphs + 1;
536
- if (n === 0) for (let l = 0; l < o; l++) i.push(s.readUshort(a, t + (l << 1)) << 1);
537
- else if (n === 1) for (let l = 0; l < o; l++) i.push(s.readUint(a, t + (l << 2)));
541
+ const s = y, i = [], o = r.head.indexToLocFormat, n = r.maxp.numGlyphs + 1;
542
+ if (o === 0) for (let l = 0; l < n; l++) i.push(s.readUshort(a, t + (l << 1)) << 1);
543
+ else if (o === 1) for (let l = 0; l < n; l++) i.push(s.readUint(a, t + (l << 2)));
538
544
  return i;
539
545
  } }, glyf: { parseTab(a, t, e, r) {
540
546
  if (!r) throw Error("Font object required for glyf parsing");
541
547
  const s = [], i = r.maxp.numGlyphs;
542
- for (let n = 0; n < i; n++) s.push(null);
548
+ for (let o = 0; o < i; o++) s.push(null);
543
549
  return s;
544
- }, Ot(a, t) {
545
- const e = y, r = a.Wt, s = a.loca;
550
+ }, Wt(a, t) {
551
+ const e = y, r = a.Nt, s = a.loca;
546
552
  if (s[t] === s[t + 1]) return null;
547
- const i = _.findTable(r, "glyf", a.Nt);
553
+ const i = _.findTable(r, "glyf", a.Xt);
548
554
  if (!i) return null;
549
- let n = i[0] + s[t];
550
- const o = {};
551
- if (o.noc = e.readShort(r, n), n += 2, o.xMin = e.readShort(r, n), n += 2, o.yMin = e.readShort(r, n), n += 2, o.xMax = e.readShort(r, n), n += 2, o.yMax = e.readShort(r, n), n += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
552
- if (o.noc > 0) {
553
- o.endPts = [];
554
- for (let d = 0; d < o.noc; d++) o.endPts.push(e.readUshort(r, n)), n += 2;
555
- const l = e.readUshort(r, n);
556
- if (n += 2, r.length - n < l) return null;
557
- n += l;
558
- const c = o.endPts[o.noc - 1] + 1;
559
- o.flags = [];
555
+ let o = i[0] + s[t];
556
+ const n = {};
557
+ if (n.noc = e.readShort(r, o), o += 2, n.xMin = e.readShort(r, o), o += 2, n.yMin = e.readShort(r, o), o += 2, n.xMax = e.readShort(r, o), o += 2, n.yMax = e.readShort(r, o), o += 2, n.xMin >= n.xMax || n.yMin >= n.yMax) return null;
558
+ if (n.noc > 0) {
559
+ n.endPts = [];
560
+ for (let d = 0; d < n.noc; d++) n.endPts.push(e.readUshort(r, o)), o += 2;
561
+ const l = e.readUshort(r, o);
562
+ if (o += 2, r.length - o < l) return null;
563
+ o += l;
564
+ const c = n.endPts[n.noc - 1] + 1;
565
+ n.flags = [];
560
566
  for (let d = 0; d < c; d++) {
561
- const v = r[n];
562
- if (n++, o.flags.push(v), 8 & v) {
563
- const p = r[n];
564
- n++;
565
- for (let g = 0; g < p; g++) o.flags.push(v), d++;
567
+ const m = r[o];
568
+ if (o++, n.flags.push(m), 8 & m) {
569
+ const p = r[o];
570
+ o++;
571
+ for (let g = 0; g < p; g++) n.flags.push(m), d++;
566
572
  }
567
573
  }
568
- o.xs = [];
574
+ n.xs = [];
569
575
  for (let d = 0; d < c; d++) {
570
- const v = o.flags[d], p = !!(16 & v);
571
- 2 & v ? (o.xs.push(p ? r[n] : -r[n]), n++) : p ? o.xs.push(0) : (o.xs.push(e.readShort(r, n)), n += 2);
576
+ const m = n.flags[d], p = !!(16 & m);
577
+ 2 & m ? (n.xs.push(p ? r[o] : -r[o]), o++) : p ? n.xs.push(0) : (n.xs.push(e.readShort(r, o)), o += 2);
572
578
  }
573
- o.ys = [];
579
+ n.ys = [];
574
580
  for (let d = 0; d < c; d++) {
575
- const v = o.flags[d], p = !!(32 & v);
576
- 4 & v ? (o.ys.push(p ? r[n] : -r[n]), n++) : p ? o.ys.push(0) : (o.ys.push(e.readShort(r, n)), n += 2);
581
+ const m = n.flags[d], p = !!(32 & m);
582
+ 4 & m ? (n.ys.push(p ? r[o] : -r[o]), o++) : p ? n.ys.push(0) : (n.ys.push(e.readShort(r, o)), o += 2);
577
583
  }
578
584
  let u = 0, f = 0;
579
- for (let d = 0; d < c; d++) u += o.xs[d], f += o.ys[d], o.xs[d] = u, o.ys[d] = f;
580
- } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
581
- return o;
585
+ for (let d = 0; d < c; d++) u += n.xs[d], f += n.ys[d], n.xs[d] = u, n.ys[d] = f;
586
+ } else n.parts = [], n.endPts = [], n.flags = [], n.xs = [], n.ys = [];
587
+ return n;
582
588
  } } }, _ = { parse: (a) => [((t, e, r, s) => {
583
- const i = O, n = { Wt: t, Xt: e, Nt: r };
584
- for (const o in i) {
585
- const l = o, c = _.findTable(t, l, r);
589
+ const i = W, o = { Nt: t, qt: e, Xt: r };
590
+ for (const n in i) {
591
+ const l = n, c = _.findTable(t, l, r);
586
592
  if (c) {
587
593
  const [u, f] = c;
588
594
  let d = s[u];
589
- d == null && (d = i[l].parseTab(t, u, f, n), s[u] = d), n[l] = d;
595
+ d == null && (d = i[l].parseTab(t, u, f, o), s[u] = d), o[l] = d;
590
596
  }
591
597
  }
592
- return n;
598
+ return o;
593
599
  })(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
594
600
  const r = y, s = r.readUshort(a, e + 4);
595
601
  let i = e + 12;
596
- for (let n = 0; n < s; n++) {
597
- const o = r.readASCII(a, i, 4);
602
+ for (let o = 0; o < s; o++) {
603
+ const n = r.readASCII(a, i, 4);
598
604
  r.readUint(a, i + 4);
599
605
  const l = r.readUint(a, i + 8), c = r.readUint(a, i + 12);
600
- if (o === t) return [l, c];
606
+ if (n === t) return [l, c];
601
607
  i += 16;
602
608
  }
603
609
  return null;
604
- }, T: O, B: y };
605
- class G {
610
+ }, T: W, B: y };
611
+ class L {
606
612
  constructor() {
607
- h(this, "qt", /* @__PURE__ */ new Map());
608
613
  h(this, "Yt", /* @__PURE__ */ new Map());
614
+ h(this, "Qt", /* @__PURE__ */ new Map());
609
615
  }
610
- Qt(t) {
611
- const e = this.Zt(t);
612
- if (this.Yt.has(e)) return this.Yt.get(e);
616
+ Zt(t) {
617
+ const e = this.Jt(t);
618
+ if (this.Qt.has(e)) return this.Qt.get(e);
613
619
  const r = t.cmap;
614
- if (!r || !r.tables) return this.Yt.set(e, null), null;
620
+ if (!r || !r.tables) return this.Qt.set(e, null), null;
615
621
  const s = ["p3e1", "p3e10", "p0e3", "p0e4"];
616
- for (const n of s) if (r.ids[n] !== void 0) {
617
- const o = r.tables[r.ids[n]];
618
- return this.Yt.set(e, o), o;
622
+ for (const o of s) if (r.ids[o] !== void 0) {
623
+ const n = r.tables[r.ids[o]];
624
+ return this.Qt.set(e, n), n;
619
625
  }
620
626
  const i = r.tables[0] || null;
621
- return this.Yt.set(e, i), i;
627
+ return this.Qt.set(e, i), i;
622
628
  }
623
- Jt(t, e) {
624
- const r = `${this.Zt(t)}_${e}`;
625
- if (this.qt.has(r)) return this.qt.get(r);
626
- const s = this.Qt(t);
627
- if (!s) return this.qt.set(r, 0), 0;
629
+ Kt(t, e) {
630
+ const r = `${this.Jt(t)}_${e}`;
631
+ if (this.Yt.has(r)) return this.Yt.get(r);
632
+ const s = this.Zt(t);
633
+ if (!s) return this.Yt.set(r, 0), 0;
628
634
  let i = 0;
629
- return s.format === 4 ? i = this.Kt(e, s) : s.format === 12 && (i = this.te(e, s)), this.qt.set(r, i), i;
635
+ return s.format === 4 ? i = this.te(e, s) : s.format === 12 && (i = this.ee(e, s)), this.Yt.set(r, i), i;
630
636
  }
631
- ee(t, e) {
637
+ se(t, e) {
632
638
  const r = e.codePointAt(0);
633
- return r === void 0 ? 0 : this.Jt(t, r);
639
+ return r === void 0 ? 0 : this.Kt(t, r);
634
640
  }
635
641
  re(t, e) {
636
642
  const r = t.hmtx;
637
643
  return r && r.aWidth && r.aWidth.length !== 0 ? e < r.aWidth.length ? r.aWidth[e] : r.aWidth[r.aWidth.length - 1] : 0;
638
644
  }
639
- se(t, e) {
640
- const r = e / t.head.unitsPerEm, s = t.hhea.ascender * r, i = t.hhea.descender * r, n = t.hhea.lineGap * r;
641
- return { ascender: s, descender: i, lineGap: n, lineHeight: s - i + n, unitsPerEm: t.head.unitsPerEm, scale: r };
645
+ ie(t, e) {
646
+ const r = e / t.head.unitsPerEm, s = t.hhea.ascender * r, i = t.hhea.descender * r, o = t.hhea.lineGap * r;
647
+ return { ascender: s, descender: i, lineGap: o, lineHeight: s - i + o, unitsPerEm: t.head.unitsPerEm, scale: r };
642
648
  }
643
- ie() {
644
- this.qt.clear(), this.Yt.clear();
649
+ ne() {
650
+ this.Yt.clear(), this.Qt.clear();
645
651
  }
646
- Zt(t) {
647
- return `${t.Nt}_${t.Wt.length}`;
652
+ Jt(t) {
653
+ return `${t.Xt}_${t.Nt.length}`;
648
654
  }
649
- Kt(t, e) {
655
+ te(t, e) {
650
656
  const r = e.endCount.length;
651
657
  let s = -1;
652
658
  for (let i = 0; i < r; i++) if (t <= e.endCount[i]) {
@@ -658,76 +664,76 @@ class G {
658
664
  {
659
665
  const i = e.idRangeOffset[s] / 2 + (t - e.startCount[s]) - (r - s);
660
666
  if (i >= 0 && i < e.glyphIdArray.length) {
661
- const n = e.glyphIdArray[i];
662
- return n === 0 ? 0 : n + e.idDelta[s] & 65535;
667
+ const o = e.glyphIdArray[i];
668
+ return o === 0 ? 0 : o + e.idDelta[s] & 65535;
663
669
  }
664
670
  }
665
671
  return 0;
666
672
  }
667
- te(t, e) {
673
+ ee(t, e) {
668
674
  const r = e.groups.length / 3;
669
675
  for (let s = 0; s < r; s++) {
670
- const i = e.groups[3 * s], n = e.groups[3 * s + 1], o = e.groups[3 * s + 2];
671
- if (t >= i && t <= n) return o + (t - i);
676
+ const i = e.groups[3 * s], o = e.groups[3 * s + 1], n = e.groups[3 * s + 2];
677
+ if (t >= i && t <= o) return n + (t - i);
672
678
  }
673
679
  return 0;
674
680
  }
675
681
  }
676
682
  class ct {
677
683
  constructor(t) {
678
- h(this, "ne");
679
- this.ne = t;
684
+ h(this, "oe");
685
+ this.oe = t;
680
686
  }
681
- oe(t) {
687
+ ae(t) {
682
688
  var r;
683
689
  const e = [];
684
690
  return (r = t == null ? void 0 : t.cmap) != null && r.tables ? (t.cmap.tables.forEach((s) => {
685
691
  if (s.format === 4) {
686
- const i = this.ae(s);
692
+ const i = this.he(s);
687
693
  e.push(...i);
688
694
  } else if (s.format === 12) {
689
- const i = this.he(s);
695
+ const i = this.le(s);
690
696
  e.push(...i);
691
697
  }
692
698
  }), [...new Set(e)]) : [];
693
699
  }
694
- le(t, e) {
695
- return this.ne.ee(t, e) > 0;
696
- }
697
700
  ce(t, e) {
698
- for (const r of e) if (!this.le(t, r)) return !1;
699
- return !0;
701
+ return this.oe.se(t, e) > 0;
700
702
  }
701
703
  ue(t, e) {
702
- return e.filter((r) => this.le(t, r));
704
+ for (const r of e) if (!this.ce(t, r)) return !1;
705
+ return !0;
703
706
  }
704
- fe(t) {
705
- return t.filter((e) => this.de(e));
707
+ fe(t, e) {
708
+ return e.filter((r) => this.ce(t, r));
706
709
  }
707
- ae(t) {
710
+ de(t) {
711
+ return t.filter((e) => this.pe(e));
712
+ }
713
+ he(t) {
708
714
  const e = [];
709
715
  if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
710
716
  for (let r = 0; r < t.startCount.length; r++) {
711
717
  const s = t.startCount[r], i = t.endCount[r];
712
718
  if (s !== 65535 || i !== 65535) {
713
- for (let n = s; n <= i; n++)
714
- if (this.me(t, n, r) > 0) try {
715
- const o = String.fromCodePoint(n);
716
- e.push(o);
719
+ for (let o = s; o <= i; o++)
720
+ if (this.me(t, o, r) > 0) try {
721
+ const n = String.fromCodePoint(o);
722
+ e.push(n);
717
723
  } catch {
718
724
  }
719
725
  }
720
726
  }
721
727
  return e;
722
728
  }
723
- he(t) {
729
+ le(t) {
724
730
  const e = [];
725
731
  if (!t.groups) return e;
726
732
  for (let r = 0; r < t.groups.length; r += 3) {
727
- const s = t.groups[r], i = t.groups[r + 1], n = t.groups[r + 2];
728
- for (let o = s; o <= i; o++)
729
- if (n + (o - s) > 0) try {
730
- const l = String.fromCodePoint(o);
733
+ const s = t.groups[r], i = t.groups[r + 1], o = t.groups[r + 2];
734
+ for (let n = s; n <= i; n++)
735
+ if (o + (n - s) > 0) try {
736
+ const l = String.fromCodePoint(n);
731
737
  e.push(l);
732
738
  } catch {
733
739
  }
@@ -745,179 +751,179 @@ class ct {
745
751
  }
746
752
  return 0;
747
753
  }
748
- de(t) {
754
+ pe(t) {
749
755
  const e = t.codePointAt(0) || 0;
750
756
  return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
751
757
  }
752
758
  }
753
759
  class ut {
754
760
  constructor() {
755
- h(this, "pe");
756
- const t = new G();
757
- this.pe = new ct(t);
761
+ h(this, "ge");
762
+ const t = new L();
763
+ this.ge = new ct(t);
758
764
  }
759
765
  extractCharacters(t) {
760
- return this.pe.oe(t);
766
+ return this.ge.ae(t);
761
767
  }
762
768
  filterProblematicCharacters(t) {
763
- return this.pe.fe(t);
769
+ return this.ge.de(t);
764
770
  }
765
771
  characterExists(t, e) {
766
- return this.pe.le(t, e);
772
+ return this.ge.ce(t, e);
767
773
  }
768
774
  allCharactersExist(t, e) {
769
- return this.pe.ce(t, e);
775
+ return this.ge.ue(t, e);
770
776
  }
771
777
  }
772
778
  class dt {
773
779
  constructor(t) {
774
- h(this, "ge");
775
780
  h(this, "_e");
776
781
  h(this, "ve");
777
782
  h(this, "xe");
778
- this.ve = t, this.xe = new G(), this.ge = document.createElement("canvas"), this._e = this.ge.getContext("2d", { willReadFrequently: !0, alpha: !1 });
783
+ h(this, "be");
784
+ this.xe = t, this.be = new L(), this._e = document.createElement("canvas"), this.ve = this._e.getContext("2d", { willReadFrequently: !0, alpha: !1 });
779
785
  }
780
786
  createTextureAtlas(t, e, r, s) {
781
- const i = t.length, n = Math.ceil(Math.sqrt(i)), o = Math.ceil(i / n), l = e.width * n, c = e.height * o, u = typeof s == "object" ? s : null;
782
- this.be(l, c), this.we(t, e, n, r, u);
783
- const f = this.ve.Ut(l, c, { filter: "nearest" });
784
- return f.update(this.ge), { framebuffer: f, columns: n, rows: o };
785
- }
786
- be(t, e) {
787
- this.ge.width = t, this.ge.height = e, this.ge.style.width = t + "px", this.ge.style.height = t + "px", this._e.imageSmoothingEnabled = !1, this.ge.style.imageRendering = "pixelated", this._e.fillStyle = "black", this._e.fillRect(0, 0, t, e), this._e.textBaseline = "top", this._e.textAlign = "left", this._e.fillStyle = "white";
788
- }
789
- we(t, e, r, s, i) {
790
- const n = s / i.head.unitsPerEm;
791
- for (let o = 0; o < t.length; o++) {
792
- const l = o % r, c = Math.floor(o / r), u = t[o].character, f = this.Ce(i, u);
787
+ const i = t.length, o = Math.ceil(Math.sqrt(i)), n = Math.ceil(i / o), l = e.width * o, c = e.height * n, u = typeof s == "object" ? s : null;
788
+ this.we(l, c), this.Ce(t, e, o, r, u);
789
+ const f = this.xe.Lt(l, c, { filter: "nearest" });
790
+ return f.update(this._e), { framebuffer: f, columns: o, rows: n };
791
+ }
792
+ we(t, e) {
793
+ this._e.width = t, this._e.height = e, this._e.style.width = t + "px", this._e.style.height = t + "px", this.ve.imageSmoothingEnabled = !1, this._e.style.imageRendering = "pixelated", this.ve.fillStyle = "black", this.ve.fillRect(0, 0, t, e), this.ve.textBaseline = "top", this.ve.textAlign = "left", this.ve.fillStyle = "white";
794
+ }
795
+ Ce(t, e, r, s, i) {
796
+ const o = s / i.head.unitsPerEm;
797
+ for (let n = 0; n < t.length; n++) {
798
+ const l = n % r, c = Math.floor(n / r), u = t[n].character, f = this.ye(i, u);
793
799
  if (!f) continue;
794
- const d = u.codePointAt(0) || 0, v = this.xe.Jt(i, d), p = this.ye(i, v) * n, g = l * e.width, C = c * e.height, m = g + 0.5 * e.width, b = C + 0.5 * e.height, T = Math.round(m - 0.5 * e.width), E = Math.round(b - 0.5 * s), A = T + 0.5 * (e.width - p), F = E + i.hhea.ascender * n;
795
- this.$e(f, A, F, n);
800
+ const d = u.codePointAt(0) || 0, m = this.be.Kt(i, d), p = this.$e(i, m) * o, g = l * e.width, C = c * e.height, x = g + 0.5 * e.width, b = C + 0.5 * e.height, E = Math.round(x - 0.5 * e.width), T = Math.round(b - 0.5 * s), A = E + 0.5 * (e.width - p), F = T + i.hhea.ascender * o;
801
+ this.Fe(f, A, F, o);
796
802
  }
797
803
  }
798
- Ce(t, e) {
799
- const r = e.codePointAt(0) || 0, s = this.xe.Jt(t, r);
804
+ ye(t, e) {
805
+ const r = e.codePointAt(0) || 0, s = this.be.Kt(t, r);
800
806
  if (s === 0) return null;
801
807
  if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
802
- if (_ && _.T && _.T.glyf && _.T.glyf.Ot) {
803
- const i = _.T.glyf.Ot(t, s);
808
+ if (_ && _.T && _.T.glyf && _.T.glyf.Wt) {
809
+ const i = _.T.glyf.Wt(t, s);
804
810
  return t.glyf && i && (t.glyf[s] = i), i;
805
811
  }
806
812
  return null;
807
813
  }
808
- ye(t, e) {
814
+ $e(t, e) {
809
815
  const r = t.hmtx;
810
816
  return r && r.aWidth ? e < r.aWidth.length ? r.aWidth[e] : r.aWidth[r.aWidth.length - 1] : 0;
811
817
  }
812
- $e(t, e, r, s) {
818
+ Fe(t, e, r, s) {
813
819
  if (!t || !t.xs || t.noc === 0) return;
814
- const { xs: i, ys: n, endPts: o, flags: l } = t;
815
- if (!(i && n && o && l)) return;
816
- this._e.beginPath();
820
+ const { xs: i, ys: o, endPts: n, flags: l } = t;
821
+ if (!(i && o && n && l)) return;
822
+ this.ve.beginPath();
817
823
  let c = 0;
818
- for (let u = 0; u < o.length; u++) {
819
- const f = o[u];
824
+ for (let u = 0; u < n.length; u++) {
825
+ const f = n[u];
820
826
  if (!(f < c)) {
821
827
  if (f >= c) {
822
- const d = e + i[c] * s, v = r - n[c] * s;
823
- this._e.moveTo(d, v);
828
+ const d = e + i[c] * s, m = r - o[c] * s;
829
+ this.ve.moveTo(d, m);
824
830
  let p = c + 1;
825
831
  for (; p <= f; )
826
832
  if (1 & l[p]) {
827
- const g = e + i[p] * s, C = r - n[p] * s;
828
- this._e.lineTo(g, C), p++;
833
+ const g = e + i[p] * s, C = r - o[p] * s;
834
+ this.ve.lineTo(g, C), p++;
829
835
  } else {
830
- const g = e + i[p] * s, C = r - n[p] * s;
831
- let m = p + 1 > f ? c : p + 1;
832
- if (1 & l[m]) {
833
- const b = e + i[m] * s, T = r - n[m] * s;
834
- this._e.quadraticCurveTo(g, C, b, T), p = m + 1;
836
+ const g = e + i[p] * s, C = r - o[p] * s;
837
+ let x = p + 1 > f ? c : p + 1;
838
+ if (1 & l[x]) {
839
+ const b = e + i[x] * s, E = r - o[x] * s;
840
+ this.ve.quadraticCurveTo(g, C, b, E), p = x + 1;
835
841
  } else {
836
- const b = (g + (e + i[m] * s)) / 2, T = (C + (r - n[m] * s)) / 2;
837
- this._e.quadraticCurveTo(g, C, b, T), p = m;
842
+ const b = (g + (e + i[x] * s)) / 2, E = (C + (r - o[x] * s)) / 2;
843
+ this.ve.quadraticCurveTo(g, C, b, E), p = x;
838
844
  }
839
845
  }
840
- this._e.closePath();
846
+ this.ve.closePath();
841
847
  }
842
848
  c = f + 1;
843
849
  }
844
850
  }
845
- this._e.fill();
851
+ this.ve.fill();
846
852
  }
847
853
  }
848
854
  class ft {
849
855
  constructor() {
850
- h(this, "ne");
851
- this.ne = new G();
856
+ h(this, "oe");
857
+ this.oe = new L();
852
858
  }
853
859
  calculateMaxGlyphDimensions(t, e, r) {
854
860
  let s = 0;
855
- const i = this.ne.se(r, e), n = i.lineHeight;
856
- for (const o of t) {
857
- const l = this.ne.ee(r, o);
861
+ const i = this.oe.ie(r, e), o = i.lineHeight;
862
+ for (const n of t) {
863
+ const l = this.oe.se(r, n);
858
864
  if (l === 0) continue;
859
- const c = this.ne.re(r, l) * i.scale;
865
+ const c = this.oe.re(r, l) * i.scale;
860
866
  s = Math.max(s, c);
861
867
  }
862
- return { width: Math.ceil(s), height: Math.ceil(n) };
868
+ return { width: Math.ceil(s), height: Math.ceil(o) };
863
869
  }
864
870
  getCharacterAdvanceWidth(t, e, r) {
865
- const s = this.ne.se(r, e), i = this.ne.ee(r, t);
866
- return this.ne.re(r, i) * s.scale;
871
+ const s = this.oe.ie(r, e), i = this.oe.se(r, t);
872
+ return this.oe.re(r, i) * s.scale;
867
873
  }
868
874
  getFontMetrics(t, e) {
869
- return this.ne.se(e, t);
875
+ return this.oe.ie(e, t);
870
876
  }
871
- ie() {
872
- this.ne.ie();
877
+ ne() {
878
+ this.oe.ne();
873
879
  }
874
880
  }
875
881
  class gt {
876
882
  constructor() {
877
- h(this, "xe");
878
- this.xe = new G();
883
+ h(this, "be");
884
+ this.be = new L();
879
885
  }
880
886
  createCharacterObjects(t, e) {
881
887
  return t.map((r, s) => {
882
- const i = r.codePointAt(0) || 0, n = this.Fe(s);
883
- let o = 0;
888
+ const i = r.codePointAt(0) || 0, o = this.Te(s);
889
+ let n = 0;
884
890
  if (e.hmtx && e.hmtx.aWidth) {
885
- const l = this.xe.Jt(e, i);
886
- l > 0 && e.hmtx.aWidth[l] !== void 0 && (o = e.hmtx.aWidth[l]);
891
+ const l = this.be.Kt(e, i);
892
+ l > 0 && e.hmtx.aWidth[l] !== void 0 && (n = e.hmtx.aWidth[l]);
887
893
  }
888
- return { character: r, unicode: i, color: n, advanceWidth: o };
894
+ return { character: r, unicode: i, color: o, advanceWidth: n };
889
895
  });
890
896
  }
891
- Fe(t) {
897
+ Te(t) {
892
898
  return [t % 256, Math.floor(t / 256) % 256, Math.floor(t / 65536) % 256];
893
899
  }
894
900
  getCharacterColor(t, e) {
895
- if (!x.p(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
901
+ if (!v.m(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
896
902
  const r = e.find((s) => s.character === t);
897
903
  return r ? r.color : [0, 0, 0];
898
904
  }
899
905
  getCharacterColors(t, e) {
900
- return x.p(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? t.split("").map((r) => this.getCharacterColor(r, e) || [0, 0, 0]) : [[0, 0, 0]];
906
+ return v.m(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? t.split("").map((r) => this.getCharacterColor(r, e) || [0, 0, 0]) : [[0, 0, 0]];
901
907
  }
902
908
  }
903
909
  class pt {
904
910
  constructor(t, e = 16) {
905
- h(this, "Te");
906
- h(this, "Me", []);
907
- h(this, "De");
908
- h(this, "Se", 16);
909
- h(this, "Re", 0);
911
+ h(this, "Me");
912
+ h(this, "De", []);
913
+ h(this, "Se");
914
+ h(this, "Re", 16);
910
915
  h(this, "Ve", 0);
911
- h(this, "ke", { width: 0, height: 0 });
912
- h(this, "Ie");
916
+ h(this, "ke", 0);
917
+ h(this, "Ie", { width: 0, height: 0 });
918
+ h(this, "Pe");
913
919
  h(this, "ze", "UrsaFont");
914
920
  h(this, "Ee");
915
921
  h(this, "Ge");
916
- h(this, "Pe");
917
922
  h(this, "Ae");
918
- this.Se = e, this.Ee = new ut(), this.Ge = new dt(t), this.Pe = new ft(), this.Ae = new gt();
923
+ h(this, "Ue");
924
+ this.Re = e, this.Ee = new ut(), this.Ge = new dt(t), this.Ae = new ft(), this.Ue = new gt();
919
925
  }
920
- async Ue(t) {
926
+ async Le(t) {
921
927
  let e;
922
928
  if (!t) throw new w("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
923
929
  {
@@ -925,121 +931,121 @@ class pt {
925
931
  if (!r.ok) throw new w(`Failed to load font file: ${r.status} ${r.statusText}`);
926
932
  e = await r.arrayBuffer();
927
933
  }
928
- await this.Le(e), this.Te = _.parse(e)[0], await this.He();
934
+ await this.He(e), this.Me = _.parse(e)[0], await this.je();
929
935
  }
930
- je(t) {
931
- if (t === void 0) return this.Se;
932
- this.Se = t, this.ke = this.Pe.calculateMaxGlyphDimensions(this.Me.map((r) => r.character), this.Se, this.Te);
933
- const e = this.Ge.createTextureAtlas(this.Me, this.ke, this.Se, this.Te);
934
- this.De = e.framebuffer, this.Re = e.columns, this.Ve = e.rows;
936
+ Be(t) {
937
+ if (t === void 0) return this.Re;
938
+ this.Re = t, this.Ie = this.Ae.calculateMaxGlyphDimensions(this.De.map((r) => r.character), this.Re, this.Me);
939
+ const e = this.Ge.createTextureAtlas(this.De, this.Ie, this.Re, this.Me);
940
+ this.Se = e.framebuffer, this.Ve = e.columns, this.ke = e.rows;
935
941
  }
936
- async Be(t) {
942
+ async Oe(t) {
937
943
  try {
938
944
  const e = await fetch(t);
939
945
  if (!e.ok) throw new w(`Failed to load font file: ${e.status} ${e.statusText}`);
940
946
  const r = await e.arrayBuffer();
941
- await this.Le(r);
947
+ await this.He(r);
942
948
  const s = _.parse(r);
943
949
  if (!s || s.length === 0) throw Error("Failed to parse font file");
944
- this.Te = s[0], await this.He();
950
+ this.Me = s[0], await this.je();
945
951
  } catch (e) {
946
952
  throw new w("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
947
953
  }
948
954
  }
949
- async Le(t) {
955
+ async He(t) {
950
956
  const e = Date.now();
951
- this.ze = this.ze === "UrsaFont" ? "UrsaFont" : "CustomFont_" + e, this.Ie = new FontFace(this.ze, t), await this.Ie.load(), document.fonts.add(this.Ie);
957
+ this.ze = this.ze === "UrsaFont" ? "UrsaFont" : "CustomFont_" + e, this.Pe = new FontFace(this.ze, t), await this.Pe.load(), document.fonts.add(this.Pe);
952
958
  }
953
- async He() {
954
- const t = this.Ee.extractCharacters(this.Te), e = this.Ee.filterProblematicCharacters(t);
955
- this.Me = this.Ae.createCharacterObjects(e, this.Te), this.ke = this.Pe.calculateMaxGlyphDimensions(e, this.Se, this.Te);
956
- const r = this.Ge.createTextureAtlas(this.Me, this.ke, this.Se, this.Te);
957
- this.De = r.framebuffer, this.Re = r.columns, this.Ve = r.rows;
959
+ async je() {
960
+ const t = this.Ee.extractCharacters(this.Me), e = this.Ee.filterProblematicCharacters(t);
961
+ this.De = this.Ue.createCharacterObjects(e, this.Me), this.Ie = this.Ae.calculateMaxGlyphDimensions(e, this.Re, this.Me);
962
+ const r = this.Ge.createTextureAtlas(this.De, this.Ie, this.Re, this.Me);
963
+ this.Se = r.framebuffer, this.Ve = r.columns, this.ke = r.rows;
958
964
  }
959
965
  getCharacterColor(t) {
960
- return this.Ae.getCharacterColor(t, this.Me);
966
+ return this.Ue.getCharacterColor(t, this.De);
961
967
  }
962
968
  getCharacterColors(t) {
963
- return this.Ae.getCharacterColors(t, this.Me);
969
+ return this.Ue.getCharacterColors(t, this.De);
964
970
  }
965
971
  hasAllCharacters(t) {
966
972
  if (typeof t != "string" || t.length === 0) return !1;
967
- const e = new Set(this.Me.map((r) => r.character));
973
+ const e = new Set(this.De.map((r) => r.character));
968
974
  for (const r of t) if (!e.has(r)) return !1;
969
975
  return !0;
970
976
  }
971
- G() {
972
- this.De.G(), document.fonts.delete(this.Ie);
977
+ P() {
978
+ this.Se.P(), document.fonts.delete(this.Pe);
973
979
  }
974
980
  get fontFramebuffer() {
975
- return this.De;
981
+ return this.Se;
976
982
  }
977
983
  get characters() {
978
- return this.Me;
984
+ return this.De;
979
985
  }
980
986
  get textureColumns() {
981
- return this.Re;
987
+ return this.Ve;
982
988
  }
983
989
  get textureRows() {
984
- return this.Ve;
990
+ return this.ke;
985
991
  }
986
992
  get maxGlyphDimensions() {
987
- return this.ke;
993
+ return this.Ie;
988
994
  }
989
995
  get fontSize() {
990
- return this.Se;
996
+ return this.Re;
991
997
  }
992
998
  get font() {
993
- return this.Te;
999
+ return this.Me;
994
1000
  }
995
1001
  }
996
- class vt {
1002
+ class mt {
997
1003
  constructor(t, e, r) {
998
- h(this, "Oe");
999
1004
  h(this, "We");
1005
+ h(this, "Ne");
1000
1006
  h(this, "F");
1001
1007
  h(this, "M");
1002
- h(this, "Ne");
1003
1008
  h(this, "Xe");
1004
- h(this, "qe", !1);
1005
- h(this, "Ye");
1009
+ h(this, "qe");
1010
+ h(this, "Ye", !1);
1006
1011
  h(this, "Qe");
1007
1012
  h(this, "Ze");
1008
- this.Ye = t, this.Qe = e, this.Ze = r, this.kt();
1013
+ h(this, "Je");
1014
+ this.Qe = t, this.Ze = e, this.Je = r, this.kt();
1009
1015
  }
1010
1016
  kt() {
1011
- this.qe || (this.Oe = Math.floor(this.Ye.width / this.Qe), this.We = Math.floor(this.Ye.height / this.Ze)), this.Je();
1017
+ this.Ye || (this.We = Math.floor(this.Qe.width / this.Ze), this.Ne = Math.floor(this.Qe.height / this.Je)), this.Ke();
1012
1018
  }
1013
- Je() {
1014
- this.F = this.Oe * this.Qe, this.M = this.We * this.Ze, this.Ne = Math.floor((this.Ye.width - this.F) / 2), this.Xe = Math.floor((this.Ye.height - this.M) / 2);
1019
+ Ke() {
1020
+ this.F = this.We * this.Ze, this.M = this.Ne * this.Je, this.Xe = Math.floor((this.Qe.width - this.F) / 2), this.qe = Math.floor((this.Qe.height - this.M) / 2);
1015
1021
  }
1016
- Ke(t, e) {
1017
- this.Qe = t, this.Ze = e, this.kt();
1022
+ ts(t, e) {
1023
+ this.Ze = t, this.Je = e, this.kt();
1018
1024
  }
1019
- tr(t, e) {
1020
- this.qe = !0, this.Oe = t, this.We = e, this.Je();
1025
+ es(t, e) {
1026
+ this.Ye = !0, this.We = t, this.Ne = e, this.Ke();
1021
1027
  }
1022
- er() {
1023
- this.qe = !1, this.kt();
1028
+ ss() {
1029
+ this.Ye = !1, this.kt();
1024
1030
  }
1025
- rr() {
1026
- this.qe ? this.Je() : this.kt();
1031
+ rs() {
1032
+ this.Ye ? this.Ke() : this.kt();
1027
1033
  }
1028
- sr(t) {
1029
- if (t === void 0) return this.qe;
1030
- this.qe = t;
1034
+ ns(t) {
1035
+ if (t === void 0) return this.Ye;
1036
+ this.Ye = t;
1031
1037
  }
1032
1038
  get cellWidth() {
1033
- return this.Qe;
1039
+ return this.Ze;
1034
1040
  }
1035
1041
  get cellHeight() {
1036
- return this.Ze;
1042
+ return this.Je;
1037
1043
  }
1038
1044
  get cols() {
1039
- return this.Oe;
1045
+ return this.We;
1040
1046
  }
1041
1047
  get rows() {
1042
- return this.We;
1048
+ return this.Ne;
1043
1049
  }
1044
1050
  get width() {
1045
1051
  return this.F;
@@ -1048,112 +1054,112 @@ class vt {
1048
1054
  return this.M;
1049
1055
  }
1050
1056
  get offsetX() {
1051
- return this.Ne;
1057
+ return this.Xe;
1052
1058
  }
1053
1059
  get offsetY() {
1054
- return this.Xe;
1060
+ return this.qe;
1055
1061
  }
1056
1062
  }
1057
- class mt {
1063
+ class xt {
1058
1064
  constructor(t, e = !1, r = {}) {
1059
- h(this, "Ye");
1060
- h(this, "ir");
1061
- h(this, "nr");
1062
- h(this, "ar");
1065
+ h(this, "Qe");
1066
+ h(this, "hs");
1067
+ h(this, "ls");
1068
+ h(this, "cs");
1063
1069
  h(this, "onTransformChange");
1064
- this.ir = t, this.nr = e, this.Ye = this.hr(r.width, r.height), e && this.setupTransformObserver();
1070
+ this.hs = t, this.ls = e, this.Qe = this.us(r.width, r.height), e && this.setupTransformObserver();
1065
1071
  }
1066
- hr(t, e) {
1072
+ us(t, e) {
1067
1073
  var s;
1068
1074
  const r = document.createElement("canvas");
1069
- if (r.className = "textmodeCanvas", r.style.imageRendering = "pixelated", this.nr) r.width = t || 800, r.height = e || 600, document.body.appendChild(r);
1075
+ if (r.className = "textmodeCanvas", r.style.imageRendering = "pixelated", this.ls) r.width = t || 800, r.height = e || 600, document.body.appendChild(r);
1070
1076
  else {
1071
- const i = this.ir.getBoundingClientRect();
1072
- let n = Math.round(i.width), o = Math.round(i.height);
1073
- if (this.ir instanceof HTMLVideoElement) {
1074
- const u = this.ir;
1075
- (n === 0 || o === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (n = u.videoWidth, o = u.videoHeight);
1077
+ const i = this.hs.getBoundingClientRect();
1078
+ let o = Math.round(i.width), n = Math.round(i.height);
1079
+ if (this.hs instanceof HTMLVideoElement) {
1080
+ const u = this.hs;
1081
+ (o === 0 || n === 0) && u.videoWidth > 0 && u.videoHeight > 0 && (o = u.videoWidth, n = u.videoHeight);
1076
1082
  }
1077
- r.width = n, r.height = o, r.style.position = "absolute", r.style.pointerEvents = "none";
1078
- const l = window.getComputedStyle(this.ir);
1083
+ r.width = o, r.height = n, r.style.position = "absolute", r.style.pointerEvents = "none";
1084
+ const l = window.getComputedStyle(this.hs);
1079
1085
  let c = parseInt(l.zIndex || "0", 10);
1080
- isNaN(c) && (c = 0), r.style.zIndex = "" + (c + 1), this.lr(r), (s = this.ir.parentNode) == null || s.insertBefore(r, this.ir.nextSibling);
1086
+ isNaN(c) && (c = 0), r.style.zIndex = "" + (c + 1), this.fs(r), (s = this.hs.parentNode) == null || s.insertBefore(r, this.hs.nextSibling);
1081
1087
  }
1082
1088
  return r;
1083
1089
  }
1084
- lr(t) {
1085
- const e = this.ir.getBoundingClientRect();
1086
- let r = this.ir.offsetParent;
1090
+ fs(t) {
1091
+ const e = this.hs.getBoundingClientRect();
1092
+ let r = this.hs.offsetParent;
1087
1093
  if (r && r !== document.body) {
1088
1094
  const s = r.getBoundingClientRect();
1089
1095
  t.style.top = e.top - s.top + "px", t.style.left = e.left - s.left + "px";
1090
1096
  } else t.style.top = e.top + window.scrollY + "px", t.style.left = e.left + window.scrollX + "px";
1091
1097
  }
1092
- rr(t, e) {
1093
- if (this.nr) this.Ye.width = t ?? this.Ye.width, this.Ye.height = e ?? this.Ye.height;
1098
+ rs(t, e) {
1099
+ if (this.ls) this.Qe.width = t ?? this.Qe.width, this.Qe.height = e ?? this.Qe.height;
1094
1100
  else {
1095
- const r = this.ir.getBoundingClientRect();
1101
+ const r = this.hs.getBoundingClientRect();
1096
1102
  let s = Math.round(r.width), i = Math.round(r.height);
1097
- if (this.ir instanceof HTMLVideoElement) {
1098
- const n = this.ir;
1099
- (s === 0 || i === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, i = n.videoHeight);
1103
+ if (this.hs instanceof HTMLVideoElement) {
1104
+ const o = this.hs;
1105
+ (s === 0 || i === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (s = o.videoWidth, i = o.videoHeight);
1100
1106
  }
1101
- this.Ye.width = s, this.Ye.height = i, this.lr(this.Ye);
1107
+ this.Qe.width = s, this.Qe.height = i, this.fs(this.Qe);
1102
1108
  }
1103
1109
  }
1104
- cr() {
1105
- const t = { alpha: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" }, e = this.Ye.getContext("webgl2", t) || this.Ye.getContext("webgl", t);
1110
+ ds() {
1111
+ const t = { alpha: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" }, e = this.Qe.getContext("webgl2", t) || this.Qe.getContext("webgl", t);
1106
1112
  if (!e) throw new w("WebGL context could not be created. Ensure your browser supports WebGL.");
1107
1113
  return e;
1108
1114
  }
1109
1115
  setupTransformObserver() {
1110
- this.ar = new ResizeObserver((t) => {
1116
+ this.cs = new ResizeObserver((t) => {
1111
1117
  for (const e of t) {
1112
1118
  const r = e.contentRect;
1113
- !this.onTransformChange || Math.round(r.width) === this.Ye.width && Math.round(r.height) === this.Ye.height || this.onTransformChange();
1119
+ !this.onTransformChange || Math.round(r.width) === this.Qe.width && Math.round(r.height) === this.Qe.height || this.onTransformChange();
1114
1120
  }
1115
- }), this.ar.observe(this.Ye);
1121
+ }), this.cs.observe(this.Qe);
1116
1122
  }
1117
- G() {
1118
- this.ar && this.ar.disconnect();
1119
- const t = this.Ye.getContext("webgl") || this.Ye.getContext("webgl2");
1123
+ P() {
1124
+ this.cs && this.cs.disconnect();
1125
+ const t = this.Qe.getContext("webgl") || this.Qe.getContext("webgl2");
1120
1126
  if (t) {
1121
1127
  const e = t.getExtension("WEBGL_lose_context");
1122
1128
  e && e.loseContext();
1123
1129
  }
1124
- this.Ye.parentNode && this.Ye.parentNode.removeChild(this.Ye);
1130
+ this.Qe.parentNode && this.Qe.parentNode.removeChild(this.Qe);
1125
1131
  }
1126
1132
  get canvas() {
1127
- return this.Ye;
1133
+ return this.Qe;
1128
1134
  }
1129
1135
  get width() {
1130
- return this.Ye.width;
1136
+ return this.Qe.width;
1131
1137
  }
1132
1138
  get height() {
1133
- return this.Ye.height;
1139
+ return this.Qe.height;
1134
1140
  }
1135
1141
  }
1136
1142
  class D {
1137
1143
  constructor(t, e, r, s = {}) {
1138
- h(this, "ve");
1139
- h(this, "ur");
1140
- h(this, "dr");
1141
- h(this, "mr");
1142
- h(this, "pr");
1143
- h(this, "gr");
1144
- h(this, "_r");
1145
- h(this, "vr");
1144
+ h(this, "xe");
1145
+ h(this, "ps");
1146
+ h(this, "gs");
1147
+ h(this, "_s");
1148
+ h(this, "vs");
1149
+ h(this, "bs");
1150
+ h(this, "ws");
1151
+ h(this, "Cs");
1146
1152
  h(this, "l");
1147
- this.ve = t, this.ur = e, this.dr = r, this.l = s;
1148
- const i = this.dr.cols, n = this.dr.rows;
1149
- this.mr = this.ve.Ut(i, n), this.pr = this.ve.Ut(i, n), this.gr = this.ve.Ut(i, n), this._r = this.ve.Ut(i, n), this.vr = this.ve.Ut(i, n);
1153
+ this.xe = t, this.ps = e, this.gs = r, this.l = s;
1154
+ const i = this.gs.cols, o = this.gs.rows;
1155
+ this._s = this.xe.Lt(i, o), this.vs = this.xe.Lt(i, o), this.bs = this.xe.Lt(i, o), this.ws = this.xe.Lt(i, o), this.Cs = this.xe.Lt(i, o);
1150
1156
  }
1151
- rr() {
1152
- const t = this.dr.cols, e = this.dr.rows;
1153
- this.mr.resize(t, e), this.pr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
1157
+ rs() {
1158
+ const t = this.gs.cols, e = this.gs.rows;
1159
+ this._s.resize(t, e), this.vs.resize(t, e), this.bs.resize(t, e), this.ws.resize(t, e), this.Cs.resize(t, e);
1154
1160
  }
1155
1161
  enabled(t) {
1156
- x.p(typeof t == "boolean" || typeof t == "number" && Number.isInteger(t), "Enabled must be a boolean value or an integer (0 for false, any other number for true).", { method: "enabled", providedValue: t }) && (this.l.enabled = !!t);
1162
+ v.m(typeof t == "boolean" || typeof t == "number" && Number.isInteger(t), "Enabled must be a boolean value or an integer (0 for false, any other number for true).", { method: "enabled", providedValue: t }) && (this.l.enabled = !!t);
1157
1163
  }
1158
1164
  enable() {
1159
1165
  this.enabled(!0);
@@ -1161,52 +1167,52 @@ class D {
1161
1167
  disable() {
1162
1168
  this.enabled(!1);
1163
1169
  }
1164
- G() {
1165
- this.mr.G(), this.pr.G(), this.gr.G(), this._r.G(), this.vr.G();
1170
+ P() {
1171
+ this._s.P(), this.vs.P(), this.bs.P(), this.ws.P(), this.Cs.P();
1166
1172
  }
1167
1173
  get characterFramebuffer() {
1168
- return this.mr;
1174
+ return this._s;
1169
1175
  }
1170
1176
  get primaryColorFramebuffer() {
1171
- return this.pr;
1177
+ return this.vs;
1172
1178
  }
1173
1179
  get secondaryColorFramebuffer() {
1174
- return this.gr;
1180
+ return this.bs;
1175
1181
  }
1176
1182
  get rotationFramebuffer() {
1177
- return this._r;
1183
+ return this.ws;
1178
1184
  }
1179
1185
  get transformFramebuffer() {
1180
- return this.vr;
1186
+ return this.Cs;
1181
1187
  }
1182
1188
  get options() {
1183
1189
  return this.l;
1184
1190
  }
1185
1191
  }
1186
- class xt {
1192
+ class vt {
1187
1193
  constructor(t, e) {
1188
1194
  h(this, "C");
1189
- h(this, "ve");
1190
- h(this, "br");
1191
- this.ve = t, this.br = e;
1192
- const r = Math.max(this.br.length, 1);
1193
- this.C = this.ve.Ut(r, 1), this.wr();
1195
+ h(this, "xe");
1196
+ h(this, "$s");
1197
+ this.xe = t, this.$s = e;
1198
+ const r = Math.max(this.$s.length, 1);
1199
+ this.C = this.xe.Lt(r, 1), this.Fs();
1194
1200
  }
1195
- wr() {
1196
- const t = this.br.length;
1201
+ Fs() {
1202
+ const t = this.$s.length;
1197
1203
  this.C.width !== t && this.C.resize(t, 1);
1198
1204
  const e = new Uint8Array(1 * t * 4);
1199
1205
  for (let r = 0; r < t; r++) {
1200
- const s = this.br[r], i = 4 * r;
1206
+ const s = this.$s[r], i = 4 * r;
1201
1207
  e[i] = s[0], e[i + 1] = s[1], e[i + 2] = s[2], e[i + 3] = 255;
1202
1208
  }
1203
1209
  this.C.updatePixels(e, t, 1);
1204
1210
  }
1205
1211
  setColors(t) {
1206
- this.br = t, this.wr();
1212
+ this.$s = t, this.Fs();
1207
1213
  }
1208
1214
  get colors() {
1209
- return this.br;
1215
+ return this.$s;
1210
1216
  }
1211
1217
  get framebuffer() {
1212
1218
  return this.C;
@@ -1215,64 +1221,64 @@ class xt {
1215
1221
  return this.C.texture;
1216
1222
  }
1217
1223
  }
1218
- class Y extends D {
1224
+ class G extends D {
1219
1225
  constructor(e, r, s, i = {}) {
1220
1226
  super(e, r, s, i);
1221
- h(this, "Cr");
1222
- this.Cr = new xt(this.ve, this.ur.getCharacterColors(" .:-=+*%@#"));
1227
+ h(this, "Ts");
1228
+ this.Ts = new vt(this.xe, this.ps.getCharacterColors(" .:-=+*%@#"));
1223
1229
  }
1224
1230
  characters(e) {
1225
- x.p(this.ur.hasAllCharacters(e), "One or more characters do not exist in the current font.", { method: "characters", providedValue: e }) && (this.l.characters = e, this.Cr.setColors(this.ur.getCharacterColors(e)));
1231
+ v.m(this.ps.hasAllCharacters(e), "One or more characters do not exist in the current font.", { method: "characters", providedValue: e }) && (this.l.characters = e, this.Ts.setColors(this.ps.getCharacterColors(e)));
1226
1232
  }
1227
1233
  characterColor(e, r, s, i = 255) {
1228
- const n = this.yr(e, "characterColor", r, s, i);
1229
- n && (this.l.characterColor = n);
1234
+ const o = this.Ms(e, "characterColor", r, s, i);
1235
+ o && (this.l.characterColor = o);
1230
1236
  }
1231
1237
  characterColorMode(e) {
1232
- this.$r(e, "characterColorMode");
1238
+ this.Ds(e, "characterColorMode");
1233
1239
  }
1234
1240
  cellColor(e, r, s, i = 255) {
1235
- const n = this.yr(e, "cellColor", r, s, i);
1236
- n && (this.l.cellColor = n);
1241
+ const o = this.Ms(e, "cellColor", r, s, i);
1242
+ o && (this.l.cellColor = o);
1237
1243
  }
1238
1244
  cellColorMode(e) {
1239
- this.$r(e, "cellColorMode");
1245
+ this.Ds(e, "cellColorMode");
1240
1246
  }
1241
1247
  invert(e) {
1242
- this.Fr(e, "invert", "Invert");
1248
+ this.Ss(e, "invert", "Invert");
1243
1249
  }
1244
1250
  rotation(e) {
1245
- if (!x.p(typeof e == "number", "Rotation angle must be a number.", { method: "rotation", providedValue: e })) return;
1251
+ if (!v.m(typeof e == "number", "Rotation angle must be a number.", { method: "rotation", providedValue: e })) return;
1246
1252
  (e %= 360) < 0 && (e += 360);
1247
1253
  const r = 255 * e / 360, s = Math.floor(r) / 255, i = Math.round(r - s);
1248
1254
  this.l.rotation = [s, i, 0, 1];
1249
1255
  }
1250
1256
  flipHorizontally(e) {
1251
- this.Fr(e, "flipHorizontally", "Flip horizontally");
1257
+ this.Ss(e, "flipHorizontally", "Flip horizontally");
1252
1258
  }
1253
1259
  flipVertically(e) {
1254
- this.Fr(e, "flipVertically", "Flip vertically");
1260
+ this.Ss(e, "flipVertically", "Flip vertically");
1255
1261
  }
1256
- yr(e, r, s, i, n = 255) {
1257
- let o, l, c, u;
1262
+ Ms(e, r, s, i, o = 255) {
1263
+ let n, l, c, u;
1258
1264
  if (typeof e == "string") {
1259
- const f = this.Tr(e);
1260
- if (!f) return x.p(!1, "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.", { method: r, providedValue: e }), null;
1261
- [o, l, c, u] = f;
1262
- } else if (o = e, l = s !== void 0 ? s : e, c = i !== void 0 ? i : e, u = n, !x.p([o, l, c, u].every((f) => f >= 0 && f <= 255), r.charAt(0).toUpperCase() + r.slice(1) + " color values must be between 0 and 255", { method: r, providedValues: { r: o, g: l, b: c, a: u } })) return null;
1263
- return [o / 255, l / 255, c / 255, u / 255];
1265
+ const f = this.Rs(e);
1266
+ if (!f) return v.m(!1, "Invalid hex color format. Use '#FF0000', '#F00', 'FF0000', or 'F00'.", { method: r, providedValue: e }), null;
1267
+ [n, l, c, u] = f;
1268
+ } else if (n = e, l = s !== void 0 ? s : e, c = i !== void 0 ? i : e, u = o, !v.m([n, l, c, u].every((f) => f >= 0 && f <= 255), r.charAt(0).toUpperCase() + r.slice(1) + " color values must be between 0 and 255", { method: r, providedValues: { r: n, g: l, b: c, a: u } })) return null;
1269
+ return [n / 255, l / 255, c / 255, u / 255];
1264
1270
  }
1265
- $r(e, r) {
1266
- x.p(["sampled", "fixed"].includes(e), "Invalid color mode. Must be 'sampled' or 'fixed'.", { method: r, providedValue: e }) && (this.l[r] = e);
1271
+ Ds(e, r) {
1272
+ v.m(["sampled", "fixed"].includes(e), "Invalid color mode. Must be 'sampled' or 'fixed'.", { method: r, providedValue: e }) && (this.l[r] = e);
1267
1273
  }
1268
- Fr(e, r, s) {
1269
- x.p(typeof e == "boolean" || typeof e == "number" && Number.isInteger(e), s + " must be a boolean value or an integer (0 for false, any other number for true).", { method: r, providedValue: e }) && (this.l[r] = !!e);
1274
+ Ss(e, r, s) {
1275
+ v.m(typeof e == "boolean" || typeof e == "number" && Number.isInteger(e), s + " must be a boolean value or an integer (0 for false, any other number for true).", { method: r, providedValue: e }) && (this.l[r] = !!e);
1270
1276
  }
1271
- Tr(e) {
1277
+ Rs(e) {
1272
1278
  return e = e.replace(/^#/, ""), /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(e) ? (e.length === 3 && (e = e.split("").map((r) => r + r).join("")), [parseInt(e.slice(0, 2), 16), parseInt(e.slice(2, 4), 16), parseInt(e.slice(4, 6), 16), 255]) : null;
1273
1279
  }
1274
1280
  }
1275
- const P = `attribute vec2 a_position;\r
1281
+ const U = `attribute vec2 a_position;\r
1276
1282
  attribute vec2 a_texCoord;\r
1277
1283
  varying vec2 v_uv;\r
1278
1284
  \r
@@ -1311,287 +1317,287 @@ void main() {\r
1311
1317
  gl_Position = vec4(pos, 0.0, 1.0);\r
1312
1318
  }\r
1313
1319
  `, bt = { enabled: !0, characters: " .:-=+*%@#", characterColor: [1, 1, 1, 1], characterColorMode: "sampled", cellColor: [0, 0, 0, 1], cellColorMode: "fixed", invert: !1, rotation: [0, 0, 0, 255], flipHorizontally: !1, flipVertically: !1, brightnessRange: [0, 255] };
1314
- class B extends Y {
1320
+ class B extends G {
1315
1321
  constructor(e, r, s) {
1316
1322
  super(e, r, s, { ...bt });
1317
- h(this, "Mr");
1318
- h(this, "Dr");
1319
- h(this, "Sr");
1320
- h(this, "Rr");
1321
- h(this, "Vr");
1322
- h(this, "kr");
1323
- this.Mr = new R(e.context, P, "precision lowp float;uniform sampler2D u_sketchTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec2 cellCenter=(floor(v_uv*u_gridCellDimensions)+vec2(0.5))/u_gridCellDimensions;vec4 color=texture2D(u_sketchTexture,cellCenter);float brightness=dot(color.rgb,vec3(0.299,0.587,0.114));float brightnessValue=brightness*255.0;if(brightnessValue>=u_brightnessRange.x&&brightnessValue<=u_brightnessRange.y){gl_FragColor=color;}else{gl_FragColor=vec4(0.0);}}"), this.Dr = new R(e.context, P, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_fillColor;uniform bool u_useFixedColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){if(u_useFixedColor){gl_FragColor=u_fillColor;}else{gl_FragColor=sampleColor;}}else{gl_FragColor=vec4(0.0);}}"), this.Rr = new R(e.context, P, "precision lowp float;uniform sampler2D u_sampleTexture;uniform bool u_invert;uniform bool u_flipHorizontally;uniform bool u_flipVertically;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){float invertValue=u_invert ? 1.0 : 0.0;float flipHValue=u_flipHorizontally ? 1.0 : 0.0;float flipVValue=u_flipVertically ? 1.0 : 0.0;gl_FragColor=vec4(invertValue,flipHValue,flipVValue,1.0);}else{gl_FragColor=vec4(0.0);}}"), this.Vr = new R(e.context, P, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_rotationColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){gl_FragColor=u_rotationColor;}else{gl_FragColor=vec4(0.0);}}"), this.Sr = new R(e.context, P, "precision lowp float;uniform sampler2D u_colorSampleFramebuffer;uniform sampler2D u_charPaletteTexture;uniform vec2 u_charPaletteSize;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec4 color=texture2D(u_colorSampleFramebuffer,v_uv);if(color.a==0.0){gl_FragColor=vec4(0.0);return;}float brightness=dot(color.rgb,vec3(0.299,0.587,0.114))*255.0;vec2 range=u_brightnessRange;if(brightness<range.x||brightness>range.y){gl_FragColor=vec4(0.0);return;}float t=(brightness-range.x)/(range.y-range.x);float idx=clamp(floor(t*u_charPaletteSize.x),0.0,u_charPaletteSize.x-1.0);vec3 charColor=texture2D(u_charPaletteTexture,vec2((idx+0.5)/u_charPaletteSize.x,0.0)).rgb;gl_FragColor=vec4(charColor,1.0);}"), this.kr = this.ve.Ut(this.dr.cols, this.dr.rows);
1323
+ h(this, "Vs");
1324
+ h(this, "ks");
1325
+ h(this, "Is");
1326
+ h(this, "Ps");
1327
+ h(this, "zs");
1328
+ h(this, "Es");
1329
+ this.Vs = new R(e.context, U, "precision lowp float;uniform sampler2D u_sketchTexture;uniform vec2 u_gridCellDimensions;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec2 cellCenter=(floor(v_uv*u_gridCellDimensions)+vec2(0.5))/u_gridCellDimensions;vec4 color=texture2D(u_sketchTexture,cellCenter);float brightness=dot(color.rgb,vec3(0.299,0.587,0.114));float brightnessValue=brightness*255.0;if(brightnessValue>=u_brightnessRange.x&&brightnessValue<=u_brightnessRange.y){gl_FragColor=color;}else{gl_FragColor=vec4(0.0);}}"), this.ks = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_fillColor;uniform bool u_useFixedColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){if(u_useFixedColor){gl_FragColor=u_fillColor;}else{gl_FragColor=sampleColor;}}else{gl_FragColor=vec4(0.0);}}"), this.Ps = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform bool u_invert;uniform bool u_flipHorizontally;uniform bool u_flipVertically;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){float invertValue=u_invert ? 1.0 : 0.0;float flipHValue=u_flipHorizontally ? 1.0 : 0.0;float flipVValue=u_flipVertically ? 1.0 : 0.0;gl_FragColor=vec4(invertValue,flipHValue,flipVValue,1.0);}else{gl_FragColor=vec4(0.0);}}"), this.zs = new R(e.context, U, "precision lowp float;uniform sampler2D u_sampleTexture;uniform vec4 u_rotationColor;varying vec2 v_uv;void main(){vec4 sampleColor=texture2D(u_sampleTexture,v_uv);if(sampleColor.a>0.0){gl_FragColor=u_rotationColor;}else{gl_FragColor=vec4(0.0);}}"), this.Is = new R(e.context, U, "precision lowp float;uniform sampler2D u_colorSampleFramebuffer;uniform sampler2D u_charPaletteTexture;uniform vec2 u_charPaletteSize;uniform vec2 u_brightnessRange;varying vec2 v_uv;void main(){vec4 color=texture2D(u_colorSampleFramebuffer,v_uv);if(color.a==0.0){gl_FragColor=vec4(0.0);return;}float brightness=dot(color.rgb,vec3(0.299,0.587,0.114))*255.0;vec2 range=u_brightnessRange;if(brightness<range.x||brightness>range.y){gl_FragColor=vec4(0.0);return;}float t=(brightness-range.x)/(range.y-range.x);float idx=clamp(floor(t*u_charPaletteSize.x),0.0,u_charPaletteSize.x-1.0);vec3 charColor=texture2D(u_charPaletteTexture,vec2((idx+0.5)/u_charPaletteSize.x,0.0)).rgb;gl_FragColor=vec4(charColor,1.0);}"), this.Es = this.xe.Lt(this.gs.cols, this.gs.rows);
1324
1330
  }
1325
- Ir(e) {
1326
- const r = this.dr.cols, s = this.dr.rows;
1327
- this.kr.begin(), this.ve.Ht(), this.ve.yt(this.Mr), this.ve.Et("u_sketchTexture", e), this.ve.Et("u_gridCellDimensions", [r, s]), this.ve.Et("u_brightnessRange", this.l.brightnessRange), this.ve.Gt(0, 0, r, s), this.kr.end(), this.pr.begin(), this.ve.Ht(), this.ve.yt(this.Dr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_fillColor", this.l.characterColor), this.ve.Et("u_useFixedColor", this.l.characterColorMode === "fixed"), this.ve.Gt(0, 0, r, s), this.pr.end(), this.gr.begin(), this.ve.Ht(), this.ve.yt(this.Dr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_fillColor", this.l.cellColor), this.ve.Et("u_useFixedColor", this.l.cellColorMode === "fixed"), this.ve.Gt(0, 0, r, s), this.gr.end(), this.vr.begin(), this.ve.Ht(), this.ve.yt(this.Rr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_invert", this.l.invert), this.ve.Et("u_flipHorizontally", this.l.flipHorizontally), this.ve.Et("u_flipVertically", this.l.flipVertically), this.ve.Gt(0, 0, r, s), this.vr.end(), this._r.begin(), this.ve.Ht(), this.ve.yt(this.Vr), this.ve.Et("u_sampleTexture", this.kr), this.ve.Et("u_rotationColor", this.l.rotation), this.ve.Gt(0, 0, r, s), this._r.end(), this.mr.begin(), this.ve.Ht(), this.ve.yt(this.Sr), this.ve.Et("u_colorSampleFramebuffer", this.kr), this.ve.Et("u_charPaletteTexture", this.Cr.texture), this.ve.Et("u_charPaletteSize", [this.Cr.colors.length, 1]), this.ve.Et("u_brightnessRange", this.l.brightnessRange), this.ve.Gt(0, 0, r, s), this.mr.end();
1331
+ Gs(e) {
1332
+ const r = this.gs.cols, s = this.gs.rows;
1333
+ this.Es.begin(), this.xe.jt(), this.xe.yt(this.Vs), this.xe.Et("u_sketchTexture", e), this.xe.Et("u_gridCellDimensions", [r, s]), this.xe.Et("u_brightnessRange", this.l.brightnessRange), this.xe.Gt(0, 0, r, s), this.Es.end(), this.vs.begin(), this.xe.jt(), this.xe.yt(this.ks), this.xe.Et("u_sampleTexture", this.Es), this.xe.Et("u_fillColor", this.l.characterColor), this.xe.Et("u_useFixedColor", this.l.characterColorMode === "fixed"), this.xe.Gt(0, 0, r, s), this.vs.end(), this.bs.begin(), this.xe.jt(), this.xe.yt(this.ks), this.xe.Et("u_sampleTexture", this.Es), this.xe.Et("u_fillColor", this.l.cellColor), this.xe.Et("u_useFixedColor", this.l.cellColorMode === "fixed"), this.xe.Gt(0, 0, r, s), this.bs.end(), this.Cs.begin(), this.xe.jt(), this.xe.yt(this.Ps), this.xe.Et("u_sampleTexture", this.Es), this.xe.Et("u_invert", this.l.invert), this.xe.Et("u_flipHorizontally", this.l.flipHorizontally), this.xe.Et("u_flipVertically", this.l.flipVertically), this.xe.Gt(0, 0, r, s), this.Cs.end(), this.ws.begin(), this.xe.jt(), this.xe.yt(this.zs), this.xe.Et("u_sampleTexture", this.Es), this.xe.Et("u_rotationColor", this.l.rotation), this.xe.Gt(0, 0, r, s), this.ws.end(), this._s.begin(), this.xe.jt(), this.xe.yt(this.Is), this.xe.Et("u_colorSampleFramebuffer", this.Es), this.xe.Et("u_charPaletteTexture", this.Ts.texture), this.xe.Et("u_charPaletteSize", [this.Ts.colors.length, 1]), this.xe.Et("u_brightnessRange", this.l.brightnessRange), this.xe.Gt(0, 0, r, s), this._s.end();
1328
1334
  }
1329
- rr() {
1330
- super.rr(), this.kr.resize(this.dr.cols, this.dr.rows);
1335
+ rs() {
1336
+ super.rs(), this.Es.resize(this.gs.cols, this.gs.rows);
1331
1337
  }
1332
1338
  brightnessRange(e) {
1333
- x.p(Array.isArray(e) && e.length === 2 && e.every((r) => typeof r == "number" && r >= 0 && r <= 255), "Brightness range must be an array of two numbers between 0 and 255.", { method: "brightnessRange", providedValue: e }) && (this.l.brightnessRange = e);
1339
+ v.m(Array.isArray(e) && e.length === 2 && e.every((r) => typeof r == "number" && r >= 0 && r <= 255), "Brightness range must be an array of two numbers between 0 and 255.", { method: "brightnessRange", providedValue: e }) && (this.l.brightnessRange = e);
1334
1340
  }
1335
1341
  }
1336
- const Yt = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeBrightnessConverter: B, TextmodeConverter: D, TextmodeFeatureConverter: Y }, Symbol.toStringTag, { value: "Module" }));
1342
+ const Gt = Object.freeze(Object.defineProperty({ __proto__: null, TextmodeBrightnessConverter: B, TextmodeConverter: D, TextmodeFeatureConverter: G }, Symbol.toStringTag, { value: "Module" }));
1337
1343
  class wt {
1338
1344
  constructor(t, e, r) {
1339
- h(this, "ve");
1340
- h(this, "Te");
1341
- h(this, "dr");
1342
- h(this, "zr");
1343
- h(this, "Er");
1344
- h(this, "Gr");
1345
- h(this, "Pr");
1346
- h(this, "Ar");
1347
- h(this, "mr");
1348
- h(this, "pr");
1349
- h(this, "gr");
1350
- h(this, "_r");
1351
- h(this, "vr");
1352
- this.ve = t, this.Te = e, this.dr = r, this.Ar = this.ve.It($, "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform sampler2D u_captureTexture;uniform vec2 u_captureDimensions;uniform int u_backgroundMode;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=gl_FragCoord.xy/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);if(encodedIndexVec.a<0.01){gl_FragColor=(u_backgroundMode==0)? vec4(0.0):texture2D(u_captureTexture,gl_FragCoord.xy/u_captureDimensions);return;}int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);float flippedRow=(u_charsetDimensions.y-1.0)-float(charRow);vec2 charCoord=vec2(float(charCol),flippedRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}"), this.Er = new B(t, e, r), this.Gr = new D(t, e, r), this.zr = [this.Er, this.Gr], this.mr = this.ve.Ut(r.cols, r.rows), this.pr = this.ve.Ut(r.cols, r.rows), this.gr = this.ve.Ut(r.cols, r.rows), this._r = this.ve.Ut(r.cols, r.rows), this.vr = this.ve.Ut(r.cols, r.rows), this.Pr = this.ve.Ut(this.dr.width, this.dr.height);
1345
+ h(this, "xe");
1346
+ h(this, "Me");
1347
+ h(this, "gs");
1348
+ h(this, "As");
1349
+ h(this, "Us");
1350
+ h(this, "Ls");
1351
+ h(this, "Hs");
1352
+ h(this, "js");
1353
+ h(this, "_s");
1354
+ h(this, "vs");
1355
+ h(this, "bs");
1356
+ h(this, "ws");
1357
+ h(this, "Cs");
1358
+ this.xe = t, this.Me = e, this.gs = r, this.js = this.xe.Pt($, "precision mediump float;uniform sampler2D u_characterTexture;uniform vec2 u_charsetDimensions;uniform sampler2D u_primaryColorTexture;uniform sampler2D u_secondaryColorTexture;uniform sampler2D u_transformTexture;uniform sampler2D u_asciiCharacterTexture;uniform sampler2D u_rotationTexture;uniform sampler2D u_captureTexture;uniform vec2 u_captureDimensions;uniform int u_backgroundMode;uniform vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}void main(){vec2 adjustedCoord=gl_FragCoord.xy/u_gridPixelDimensions;vec2 gridCoord=adjustedCoord*u_gridCellDimensions;vec2 cellCoord=floor(gridCoord);vec2 charIndexTexCoord=(cellCoord+0.5)/u_gridCellDimensions;vec4 primaryColor=texture2D(u_primaryColorTexture,charIndexTexCoord);vec4 secondaryColor=texture2D(u_secondaryColorTexture,charIndexTexCoord);vec4 transformColor=texture2D(u_transformTexture,charIndexTexCoord);bool isInverted=transformColor.r>0.5;bool flipHorizontal=transformColor.g>0.5;bool flipVertical=transformColor.b>0.5;vec4 encodedIndexVec=texture2D(u_asciiCharacterTexture,charIndexTexCoord);if(encodedIndexVec.a<0.01){gl_FragColor=(u_backgroundMode==0)? vec4(0.0):texture2D(u_captureTexture,gl_FragCoord.xy/u_captureDimensions);return;}int charIndex=int(encodedIndexVec.r*255.0+0.5)+int(encodedIndexVec.g*255.0+0.5)*256;int charCol=int(mod(float(charIndex),u_charsetDimensions.x));int charRow=charIndex/int(u_charsetDimensions.x);float flippedRow=(u_charsetDimensions.y-1.0)-float(charRow);vec2 charCoord=vec2(float(charCol),flippedRow)/u_charsetDimensions;vec4 rotationColor=texture2D(u_rotationTexture,charIndexTexCoord);float scaledAngle=rotationColor.r*255.0+rotationColor.g;float rotationAngle=(scaledAngle*360.0/255.0)*0.017453292;vec2 fractionalPart=fract(gridCoord)-0.5;if(flipHorizontal)fractionalPart.x=-fractionalPart.x;if(flipVertical)fractionalPart.y=-fractionalPart.y;fractionalPart=rotate2D(rotationAngle)*fractionalPart+0.5;vec2 cellSize=1.0/u_charsetDimensions;vec2 texCoord=charCoord+fractionalPart*cellSize;vec2 cellMax=charCoord+cellSize;if(any(lessThan(texCoord,charCoord))||any(greaterThan(texCoord,cellMax))){gl_FragColor=isInverted ? primaryColor : secondaryColor;return;}vec4 charTexel=texture2D(u_characterTexture,texCoord);if(isInverted)charTexel.rgb=1.0-charTexel.rgb;gl_FragColor=mix(secondaryColor,primaryColor,charTexel);}"), this.Us = new B(t, e, r), this.Ls = new D(t, e, r), this.As = [this.Us, this.Ls], this._s = this.xe.Lt(r.cols, r.rows), this.vs = this.xe.Lt(r.cols, r.rows), this.bs = this.xe.Lt(r.cols, r.rows), this.ws = this.xe.Lt(r.cols, r.rows), this.Cs = this.xe.Lt(r.cols, r.rows), this.Hs = this.xe.Lt(this.gs.width, this.gs.height);
1353
1359
  }
1354
- Ur(t) {
1355
- for (const r of this.zr) r.options.enabled && r instanceof Y && r.Ir(t);
1360
+ Bs(t) {
1361
+ for (const r of this.As) r.options.enabled && r instanceof G && r.Gs(t);
1356
1362
  const e = (r, s) => {
1357
- r.begin(), this.ve.Ht();
1358
- for (const i of this.zr) i.options.enabled && this.ve.Bt(s(i), 0, 0);
1363
+ r.begin(), this.xe.jt();
1364
+ for (const i of this.As) i.options.enabled && this.xe.Ot(s(i), 0, 0);
1359
1365
  r.end();
1360
1366
  };
1361
- e(this.mr, (r) => r.characterFramebuffer), e(this.pr, (r) => r.primaryColorFramebuffer), e(this.gr, (r) => r.secondaryColorFramebuffer), e(this._r, (r) => r.rotationFramebuffer), e(this.vr, (r) => r.transformFramebuffer), this.Pr.begin(), this.ve.Ht(), this.ve.yt(this.Ar), this.ve.Et("u_characterTexture", this.Te.fontFramebuffer), this.ve.Et("u_charsetDimensions", [this.Te.textureColumns, this.Te.textureRows]), this.ve.Et("u_asciiCharacterTexture", this.mr.texture), this.ve.Et("u_primaryColorTexture", this.pr.texture), this.ve.Et("u_secondaryColorTexture", this.gr.texture), this.ve.Et("u_transformTexture", this.vr.texture), this.ve.Et("u_rotationTexture", this._r.texture), this.ve.Et("u_captureTexture", t.texture), this.ve.Et("u_backgroundMode", !1), this.ve.Et("u_captureDimensions", [t.width, t.height]), this.ve.Et("u_gridCellDimensions", [this.dr.cols, this.dr.rows]), this.ve.Et("u_gridPixelDimensions", [this.dr.width, this.dr.height]), this.ve.Gt(0, 0, this.Pr.width, this.Pr.height), this.Pr.end();
1367
+ e(this._s, (r) => r.characterFramebuffer), e(this.vs, (r) => r.primaryColorFramebuffer), e(this.bs, (r) => r.secondaryColorFramebuffer), e(this.ws, (r) => r.rotationFramebuffer), e(this.Cs, (r) => r.transformFramebuffer), this.Hs.begin(), this.xe.jt(), this.xe.yt(this.js), this.xe.Et("u_characterTexture", this.Me.fontFramebuffer), this.xe.Et("u_charsetDimensions", [this.Me.textureColumns, this.Me.textureRows]), this.xe.Et("u_asciiCharacterTexture", this._s.texture), this.xe.Et("u_primaryColorTexture", this.vs.texture), this.xe.Et("u_secondaryColorTexture", this.bs.texture), this.xe.Et("u_transformTexture", this.Cs.texture), this.xe.Et("u_rotationTexture", this.ws.texture), this.xe.Et("u_captureTexture", t.texture), this.xe.Et("u_backgroundMode", !1), this.xe.Et("u_captureDimensions", [t.width, t.height]), this.xe.Et("u_gridCellDimensions", [this.gs.cols, this.gs.rows]), this.xe.Et("u_gridPixelDimensions", [this.gs.width, this.gs.height]), this.xe.Gt(0, 0, this.Hs.width, this.Hs.height), this.Hs.end();
1362
1368
  }
1363
1369
  add(t) {
1364
- if (!x.p(t === "brightness" || t === "custom", 'Converter type must be either "brightness" or "custom".', { method: "add", providedValue: t })) return;
1370
+ if (!v.m(t === "brightness" || t === "custom", 'Converter type must be either "brightness" or "custom".', { method: "add", providedValue: t })) return;
1365
1371
  let e;
1366
- return e = t === "brightness" ? new B(this.ve, this.Te, this.dr) : new D(this.ve, this.Te, this.dr), this.zr.push(e), e;
1372
+ return e = t === "brightness" ? new B(this.xe, this.Me, this.gs) : new D(this.xe, this.Me, this.gs), this.As.push(e), e;
1367
1373
  }
1368
1374
  remove(t) {
1369
- if (!x.p(t instanceof D, "Parameter must be a TextmodeConverter instance.", { method: "remove", providedValue: t })) return;
1370
- const e = this.zr.indexOf(t);
1371
- x.p(e !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: t, convertersCount: this.zr.length }) && this.zr.splice(e, 1);
1375
+ if (!v.m(t instanceof D, "Parameter must be a TextmodeConverter instance.", { method: "remove", providedValue: t })) return;
1376
+ const e = this.As.indexOf(t);
1377
+ v.m(e !== -1, "Converter instance not found in pipeline.", { method: "remove", providedValue: t, convertersCount: this.As.length }) && this.As.splice(e, 1);
1372
1378
  }
1373
1379
  swap(t, e) {
1374
- const r = (o, l) => {
1375
- if (typeof o == "number") return x.p(Number.isInteger(o) && o >= 0 && o < this.zr.length, l + " index must be a valid integer within the converter array bounds.", { method: "swap", providedValue: o, convertersCount: this.zr.length }) ? o : null;
1376
- if (o instanceof D) {
1377
- const c = this.zr.indexOf(o);
1378
- return x.p(c !== -1, l + " converter instance not found in pipeline.", { method: "swap", providedValue: o, convertersCount: this.zr.length }) ? c : null;
1380
+ const r = (n, l) => {
1381
+ if (typeof n == "number") return v.m(Number.isInteger(n) && n >= 0 && n < this.As.length, l + " index must be a valid integer within the converter array bounds.", { method: "swap", providedValue: n, convertersCount: this.As.length }) ? n : null;
1382
+ if (n instanceof D) {
1383
+ const c = this.As.indexOf(n);
1384
+ return v.m(c !== -1, l + " converter instance not found in pipeline.", { method: "swap", providedValue: n, convertersCount: this.As.length }) ? c : null;
1379
1385
  }
1380
- return x.p(!1, l + " parameter must be either an integer index or a TextmodeConverter instance.", { method: "swap", providedValue: o }), null;
1386
+ return v.m(!1, l + " parameter must be either an integer index or a TextmodeConverter instance.", { method: "swap", providedValue: n }), null;
1381
1387
  }, s = r(t, "First"), i = r(e, "Second");
1382
- if (s === null || i === null || !x.p(s !== i, "Cannot swap a converter with itself.", { method: "swap", firstIndex: s, secondIndex: i })) return;
1383
- const n = this.zr[s];
1384
- this.zr[s] = this.zr[i], this.zr[i] = n;
1388
+ if (s === null || i === null || !v.m(s !== i, "Cannot swap a converter with itself.", { method: "swap", firstIndex: s, secondIndex: i })) return;
1389
+ const o = this.As[s];
1390
+ this.As[s] = this.As[i], this.As[i] = o;
1385
1391
  }
1386
- rr() {
1387
- this.Pr.resize(this.dr.width, this.dr.height);
1388
- const t = this.dr.cols, e = this.dr.rows;
1389
- this.mr.resize(t, e), this.pr.resize(t, e), this.gr.resize(t, e), this._r.resize(t, e), this.vr.resize(t, e);
1390
- for (const r of this.zr) r.rr();
1392
+ rs() {
1393
+ this.Hs.resize(this.gs.width, this.gs.height);
1394
+ const t = this.gs.cols, e = this.gs.rows;
1395
+ this._s.resize(t, e), this.vs.resize(t, e), this.bs.resize(t, e), this.ws.resize(t, e), this.Cs.resize(t, e);
1396
+ for (const r of this.As) r.rs();
1391
1397
  }
1392
1398
  hasEnabledConverters() {
1393
- return this.zr.some((t) => t.options.enabled);
1399
+ return this.As.some((t) => t.options.enabled);
1394
1400
  }
1395
1401
  disable() {
1396
- for (const t of this.zr) t.disable();
1402
+ for (const t of this.As) t.disable();
1397
1403
  }
1398
1404
  enable() {
1399
- for (const t of this.zr) t.enable();
1405
+ for (const t of this.As) t.enable();
1400
1406
  }
1401
- G() {
1402
- for (const t of this.zr) t.G();
1403
- this.mr.G(), this.pr.G(), this.gr.G(), this._r.G(), this.vr.G(), this.Pr.G(), this.Ar.G();
1407
+ P() {
1408
+ for (const t of this.As) t.P();
1409
+ this._s.P(), this.vs.P(), this.bs.P(), this.ws.P(), this.Cs.P(), this.Hs.P(), this.js.P();
1404
1410
  }
1405
1411
  get texture() {
1406
- return this.Pr;
1412
+ return this.Hs;
1407
1413
  }
1408
1414
  get characterFramebuffer() {
1409
- return this.mr;
1415
+ return this._s;
1410
1416
  }
1411
1417
  get primaryColorFramebuffer() {
1412
- return this.pr;
1418
+ return this.vs;
1413
1419
  }
1414
1420
  get secondaryColorFramebuffer() {
1415
- return this.gr;
1421
+ return this.bs;
1416
1422
  }
1417
1423
  get rotationFramebuffer() {
1418
- return this._r;
1424
+ return this.ws;
1419
1425
  }
1420
1426
  get transformFramebuffer() {
1421
- return this.vr;
1427
+ return this.Cs;
1422
1428
  }
1423
1429
  get brightness() {
1424
- return this.Er;
1430
+ return this.Us;
1425
1431
  }
1426
1432
  get custom() {
1427
- return this.Gr;
1433
+ return this.Ls;
1428
1434
  }
1429
1435
  }
1430
1436
  const Ct = (a) => class extends a {
1431
1437
  fill(t, e, r, s) {
1432
- this.ve.$t(t, e, r, s);
1438
+ this.xe.$t(t, e, r, s);
1433
1439
  }
1434
1440
  stroke(t, e, r, s) {
1435
- this.ve.Ft(t, e, r, s);
1441
+ this.xe.Ft(t, e, r, s);
1436
1442
  }
1437
1443
  strokeWeight(t) {
1438
- this.ve.Tt(t);
1444
+ this.xe.Tt(t);
1439
1445
  }
1440
1446
  noStroke() {
1441
- this.ve.Mt();
1447
+ this.xe.Mt();
1442
1448
  }
1443
1449
  noFill() {
1444
- this.ve.Dt();
1450
+ this.xe.Dt();
1445
1451
  }
1446
1452
  rotate(t) {
1447
- this.ve.St(t);
1453
+ this.xe.St(t);
1448
1454
  }
1449
1455
  push() {
1450
- this.ve.Rt();
1456
+ this.xe.Rt();
1451
1457
  }
1452
1458
  pop() {
1453
- this.ve.Vt();
1459
+ this.xe.Vt();
1454
1460
  }
1455
1461
  rect(t, e, r = 1, s = 1) {
1456
- this.ve.Gt(t, e, r, s);
1462
+ this.xe.Gt(t, e, r, s);
1457
1463
  }
1458
1464
  line(t, e, r, s) {
1459
- this.ve.At(t, e, r, s);
1465
+ this.xe.Ut(t, e, r, s);
1460
1466
  }
1461
1467
  background(t, e = t, r = t, s = 255) {
1462
- this.ve.Lt(t, e, r, s);
1468
+ this.xe.Ht(t, e, r, s);
1463
1469
  }
1464
1470
  createShader(t, e) {
1465
- return this.ve.It(t, e);
1471
+ return this.xe.Pt(t, e);
1466
1472
  }
1467
1473
  createFilterShader(t) {
1468
- return this.ve.zt(t);
1474
+ return this.xe.zt(t);
1469
1475
  }
1470
1476
  shader(t) {
1471
- this.ve.yt(t);
1477
+ this.xe.yt(t);
1472
1478
  }
1473
1479
  setUniform(t, e) {
1474
- this.ve.Et(t, e);
1480
+ this.xe.Et(t, e);
1475
1481
  }
1476
1482
  image(t, e, r, s, i) {
1477
- this.ve.Bt(t, e, r, s, i);
1483
+ this.xe.Ot(t, e, r, s, i);
1478
1484
  }
1479
1485
  clear() {
1480
- this.ve.Ht();
1486
+ this.xe.jt();
1481
1487
  }
1482
1488
  createFramebuffer(t, e, r = {}) {
1483
- return this.ve.Ut(t, e, r);
1489
+ return this.xe.Lt(t, e, r);
1484
1490
  }
1485
1491
  };
1486
- class z {
1487
- Lr(t) {
1488
- const e = t.characterFramebuffer, r = t.primaryColorFramebuffer, s = t.secondaryColorFramebuffer, i = t.transformFramebuffer, n = t.rotationFramebuffer;
1489
- return e == null || e.loadPixels(), r == null || r.loadPixels(), s == null || s.loadPixels(), i == null || i.loadPixels(), n == null || n.loadPixels(), { characterPixels: (e == null ? void 0 : e.pixels) || new Uint8Array(0), primaryColorPixels: (r == null ? void 0 : r.pixels) || new Uint8Array(0), secondaryColorPixels: (s == null ? void 0 : s.pixels) || new Uint8Array(0), transformPixels: (i == null ? void 0 : i.pixels) || new Uint8Array(0), rotationPixels: (n == null ? void 0 : n.pixels) || new Uint8Array(0) };
1492
+ class N {
1493
+ Os(t) {
1494
+ const e = t.characterFramebuffer, r = t.primaryColorFramebuffer, s = t.secondaryColorFramebuffer, i = t.transformFramebuffer, o = t.rotationFramebuffer;
1495
+ return e == null || e.loadPixels(), r == null || r.loadPixels(), s == null || s.loadPixels(), i == null || i.loadPixels(), o == null || o.loadPixels(), { characterPixels: (e == null ? void 0 : e.pixels) || new Uint8Array(0), primaryColorPixels: (r == null ? void 0 : r.pixels) || new Uint8Array(0), secondaryColorPixels: (s == null ? void 0 : s.pixels) || new Uint8Array(0), transformPixels: (i == null ? void 0 : i.pixels) || new Uint8Array(0), rotationPixels: (o == null ? void 0 : o.pixels) || new Uint8Array(0) };
1490
1496
  }
1491
- Hr(t, e) {
1497
+ Ws(t, e) {
1492
1498
  return t[e] + (t[e + 1] << 8);
1493
1499
  }
1494
- jr(t, e) {
1500
+ Ns(t, e) {
1495
1501
  return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
1496
1502
  }
1497
1503
  }
1498
- class L {
1499
- Br(t, e) {
1504
+ class j {
1505
+ Xs(t, e) {
1500
1506
  return new Blob([t], { type: e });
1501
1507
  }
1502
- Or(t, e, r) {
1508
+ qs(t, e, r) {
1503
1509
  try {
1504
- const s = this.Br(t, r), i = URL.createObjectURL(s), n = document.createElement("a");
1505
- n.href = i, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(i);
1510
+ const s = this.Xs(t, r), i = URL.createObjectURL(s), o = document.createElement("a");
1511
+ o.href = i, o.download = e, o.style.display = "none", o.rel = "noopener", document.body.appendChild(o), o.click(), document.body.removeChild(o), URL.revokeObjectURL(i);
1506
1512
  } catch (s) {
1507
1513
  throw console.error("Failed to download file:", s), Error("File download failed: " + (s instanceof Error ? s.message : "Unknown error"));
1508
1514
  }
1509
1515
  }
1510
- Wr() {
1516
+ Ys() {
1511
1517
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
1512
1518
  }
1513
- Nr() {
1519
+ Qs() {
1514
1520
  const t = /* @__PURE__ */ new Date();
1515
1521
  return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
1516
1522
  }
1517
- Xr(t) {
1523
+ Zs(t) {
1518
1524
  return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
1519
1525
  }
1520
- qr() {
1521
- return "'textmode-export'-" + this.Wr();
1526
+ Js() {
1527
+ return "'textmode-export'-" + this.Ys();
1522
1528
  }
1523
1529
  }
1524
- class yt extends z {
1525
- Yr(t, e, r) {
1526
- const s = t[r] === 255, i = t[r + 1] === 255, n = t[r + 2] === 255, o = e[r], l = e[r + 1];
1527
- return { isInverted: s, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * (o + l / 255) / 255 * 100) / 100 };
1530
+ class yt extends N {
1531
+ Ks(t, e, r) {
1532
+ const s = t[r] === 255, i = t[r + 1] === 255, o = t[r + 2] === 255, n = e[r], l = e[r + 1];
1533
+ return { isInverted: s, flipHorizontal: i, flipVertical: o, rotation: Math.round(360 * (n + l / 255) / 255 * 100) / 100 };
1528
1534
  }
1529
- Qr(t, e, r) {
1535
+ tr(t, e, r) {
1530
1536
  return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
1531
1537
  }
1532
- Zr(t, e) {
1538
+ er(t, e) {
1533
1539
  const r = [];
1534
1540
  let s = 0;
1535
- for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
1536
- const o = 4 * s, l = this.Hr(t.characterPixels, o);
1537
- let c = this.jr(t.primaryColorPixels, o), u = this.jr(t.secondaryColorPixels, o);
1538
- const f = this.Yr(t.transformPixels, t.rotationPixels, o);
1541
+ for (let i = 0; i < e.rows; i++) for (let o = 0; o < e.cols; o++) {
1542
+ const n = 4 * s, l = this.Ws(t.characterPixels, n);
1543
+ let c = this.Ns(t.primaryColorPixels, n), u = this.Ns(t.secondaryColorPixels, n);
1544
+ const f = this.Ks(t.transformPixels, t.rotationPixels, n);
1539
1545
  if (f.isInverted) {
1540
- const v = c;
1541
- c = u, u = v;
1546
+ const m = c;
1547
+ c = u, u = m;
1542
1548
  }
1543
- const d = this.Qr(n, i, e);
1549
+ const d = this.tr(o, i, e);
1544
1550
  r.push({ charIndex: l, primaryColor: c, secondaryColor: u, transform: f, position: d }), s++;
1545
1551
  }
1546
1552
  return r;
1547
1553
  }
1548
1554
  }
1549
1555
  class _t {
1550
- Jr(t, e) {
1556
+ sr(t, e) {
1551
1557
  const r = t.cmap;
1552
1558
  for (const s of r.tables) if (s.format === 4) {
1553
1559
  for (let i = 0; i < s.startCount.length; i++) if (e >= s.startCount[i] && e <= s.endCount[i]) {
1554
1560
  if (s.idRangeOffset[i] === 0) return e + s.idDelta[i] & 65535;
1555
1561
  {
1556
- const n = s.idRangeOffset[i] / 2 + (e - s.startCount[i]) - (s.startCount.length - i);
1557
- if (n >= 0 && n < s.glyphIdArray.length) {
1558
- const o = s.glyphIdArray[n];
1559
- if (o !== 0) return o + s.idDelta[i] & 65535;
1562
+ const o = s.idRangeOffset[i] / 2 + (e - s.startCount[i]) - (s.startCount.length - i);
1563
+ if (o >= 0 && o < s.glyphIdArray.length) {
1564
+ const n = s.glyphIdArray[o];
1565
+ if (n !== 0) return n + s.idDelta[i] & 65535;
1560
1566
  }
1561
1567
  }
1562
1568
  }
1563
1569
  }
1564
1570
  return 0;
1565
1571
  }
1566
- Kr(t, e, r, s, i) {
1567
- const n = i / t.head.unitsPerEm;
1568
- return { getBoundingBox: () => ({ x1: r + e.xMin * n, y1: s + -e.yMax * n, x2: r + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.ts(e, r, s, n) };
1572
+ rr(t, e, r, s, i) {
1573
+ const o = i / t.head.unitsPerEm;
1574
+ return { getBoundingBox: () => ({ x1: r + e.xMin * o, y1: s + -e.yMax * o, x2: r + e.xMax * o, y2: s + -e.yMin * o }), toSVG: () => this.ir(e, r, s, o) };
1569
1575
  }
1570
- ts(t, e, r, s) {
1576
+ ir(t, e, r, s) {
1571
1577
  if (!t || !t.xs) return "";
1572
- const { xs: i, ys: n, endPts: o, flags: l } = t;
1573
- if (!(i && n && o && l)) return "";
1578
+ const { xs: i, ys: o, endPts: n, flags: l } = t;
1579
+ if (!(i && o && n && l)) return "";
1574
1580
  let c = "", u = 0;
1575
- for (let f = 0; f < o.length; f++) {
1576
- const d = o[f];
1581
+ for (let f = 0; f < n.length; f++) {
1582
+ const d = n[f];
1577
1583
  if (!(d < u)) {
1578
1584
  if (d >= u) {
1579
- const v = e + i[u] * s, p = r - n[u] * s;
1580
- c += `M${v.toFixed(2)},${p.toFixed(2)}`;
1585
+ const m = e + i[u] * s, p = r - o[u] * s;
1586
+ c += `M${m.toFixed(2)},${p.toFixed(2)}`;
1581
1587
  let g = u + 1;
1582
1588
  for (; g <= d; )
1583
1589
  if (1 & l[g]) {
1584
- const C = e + i[g] * s, m = r - n[g] * s;
1585
- c += `L${C.toFixed(2)},${m.toFixed(2)}`, g++;
1590
+ const C = e + i[g] * s, x = r - o[g] * s;
1591
+ c += `L${C.toFixed(2)},${x.toFixed(2)}`, g++;
1586
1592
  } else {
1587
- const C = e + i[g] * s, m = r - n[g] * s;
1593
+ const C = e + i[g] * s, x = r - o[g] * s;
1588
1594
  let b = g + 1 > d ? u : g + 1;
1589
1595
  if (1 & l[b]) {
1590
- const T = e + i[b] * s, E = r - n[b] * s;
1591
- c += `Q${C.toFixed(2)},${m.toFixed(2)} ${T.toFixed(2)},${E.toFixed(2)}`, g = b + 1;
1596
+ const E = e + i[b] * s, T = r - o[b] * s;
1597
+ c += `Q${C.toFixed(2)},${x.toFixed(2)} ${E.toFixed(2)},${T.toFixed(2)}`, g = b + 1;
1592
1598
  } else {
1593
- const T = (C + (e + i[b] * s)) / 2, E = (m + (r - n[b] * s)) / 2;
1594
- c += `Q${C.toFixed(2)},${m.toFixed(2)} ${T.toFixed(2)},${E.toFixed(2)}`, g = b;
1599
+ const E = (C + (e + i[b] * s)) / 2, T = (x + (r - o[b] * s)) / 2;
1600
+ c += `Q${C.toFixed(2)},${x.toFixed(2)} ${E.toFixed(2)},${T.toFixed(2)}`, g = b;
1595
1601
  }
1596
1602
  }
1597
1603
  c += "Z";
@@ -1601,22 +1607,22 @@ class _t {
1601
1607
  }
1602
1608
  return c;
1603
1609
  }
1604
- es(t, e, r, s, i) {
1605
- const n = t.codePointAt(0) || 0, o = this.Jr(e, n);
1610
+ nr(t, e, r, s, i) {
1611
+ const o = t.codePointAt(0) || 0, n = this.sr(e, o);
1606
1612
  let l = null;
1607
- return e.glyf && e.glyf[o] !== null ? l = e.glyf[o] : _ && _.T && _.T.glyf && _.T.glyf.Ot && (l = _.T.glyf.Ot(e, o), e.glyf && l && (e.glyf[o] = l)), this.Kr(e, l, r, s, i);
1613
+ return e.glyf && e.glyf[n] !== null ? l = e.glyf[n] : _ && _.T && _.T.glyf && _.T.glyf.Wt && (l = _.T.glyf.Wt(e, n), e.glyf && l && (e.glyf[n] = l)), this.rr(e, l, r, s, i);
1608
1614
  }
1609
- rs(t, e, r, s, i, n, o, l) {
1610
- const c = r + (i - l * (o / e.head.unitsPerEm)) / 2, u = s + (n + 0.7 * o) / 2;
1611
- return this.es(t, e, c, u, o).toSVG() || null;
1615
+ ar(t, e, r, s, i, o, n, l) {
1616
+ const c = r + (i - l * (n / e.head.unitsPerEm)) / 2, u = s + (o + 0.7 * n) / 2;
1617
+ return this.nr(t, e, c, u, n).toSVG() || null;
1612
1618
  }
1613
1619
  }
1614
- class Tt {
1620
+ class Et {
1615
1621
  constructor() {
1616
- h(this, "ss");
1617
- this.ss = new _t();
1622
+ h(this, "hr");
1623
+ this.hr = new _t();
1618
1624
  }
1619
- ns(t) {
1625
+ lr(t) {
1620
1626
  return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1621
1627
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
1622
1628
  <svg width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}"
@@ -1624,105 +1630,105 @@ class Tt {
1624
1630
  <title>textmode art generated via textmode.js</title>
1625
1631
  <desc>textmode art visualization generated by textmode.js library</desc>`;
1626
1632
  }
1627
- hs() {
1633
+ cr() {
1628
1634
  return `
1629
1635
  </g>
1630
1636
  </svg>`;
1631
1637
  }
1632
- ls(t, e) {
1638
+ ur(t, e) {
1633
1639
  if (!e.includeBackgroundRectangles) return "";
1634
1640
  const r = e.backgroundColor, s = `rgba(${r[0]},${r[1]},${r[2]},${r[3] / 255})`;
1635
1641
  return `
1636
1642
  <rect width="${t.width}" height="${t.height}" fill="${s}" />`;
1637
1643
  }
1638
- cs(t) {
1644
+ dr(t) {
1639
1645
  return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
1640
1646
  }
1641
- us(t, e) {
1642
- const { transform: r, position: s } = t, i = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
1647
+ pr(t, e) {
1648
+ const { transform: r, position: s } = t, i = s.cellX + e.cellWidth / 2, o = s.cellY + e.cellHeight / 2, n = [];
1643
1649
  if (r.flipHorizontal || r.flipVertical) {
1644
1650
  const l = r.flipHorizontal ? -1 : 1, c = r.flipVertical ? -1 : 1;
1645
- o.push(`translate(${i} ${n})`), o.push(`scale(${l} ${c})`), o.push(`translate(${-i} ${-n})`);
1651
+ n.push(`translate(${i} ${o})`), n.push(`scale(${l} ${c})`), n.push(`translate(${-i} ${-o})`);
1646
1652
  }
1647
- return r.rotation && o.push(`rotate(${r.rotation} ${i} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
1653
+ return r.rotation && n.push(`rotate(${r.rotation} ${i} ${o})`), n.length ? ` transform="${n.join(" ")}"` : "";
1648
1654
  }
1649
- fs(t, e, r) {
1655
+ mr(t, e, r) {
1650
1656
  if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
1651
- const { position: s } = t, i = this.cs(t.secondaryColor);
1657
+ const { position: s } = t, i = this.dr(t.secondaryColor);
1652
1658
  return r.drawMode === "stroke" ? `
1653
1659
  <rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${i}" fill="none" stroke-width="${r.strokeWidth}" />` : `
1654
1660
  <rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${i}" />`;
1655
1661
  }
1656
- es(t, e, r, s) {
1662
+ nr(t, e, r, s) {
1657
1663
  const i = r.characters[t.charIndex];
1658
1664
  if (!i) return "";
1659
- const n = this.ss.rs(i.character, r.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.advanceWidth);
1660
- if (!n) return "";
1661
- const o = this.cs(t.primaryColor);
1665
+ const o = this.hr.ar(i.character, r.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.advanceWidth);
1666
+ if (!o) return "";
1667
+ const n = this.dr(t.primaryColor);
1662
1668
  return s.drawMode === "stroke" ? `
1663
- <path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${o}" stroke-width="${s.strokeWidth}" fill="none" />` : `
1664
- <path d="${n}" fill="${o}" />`;
1669
+ <path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${o}" stroke="${n}" stroke-width="${s.strokeWidth}" fill="none" />` : `
1670
+ <path d="${o}" fill="${n}" />`;
1665
1671
  }
1666
- ds(t, e, r, s) {
1672
+ gr(t, e, r, s) {
1667
1673
  let i = "";
1668
- i += this.fs(t, e, s);
1669
- const n = this.us(t, e), o = this.es(t, e, r, s);
1670
- return o && (n ? (i += `
1671
- <g${n}>`, i += o, i += `
1672
- </g>`) : i += o), i;
1673
- }
1674
- ps(t, e, r, s) {
1675
- let i = this.ns(e);
1676
- i += this.ls(e, s), i += `
1674
+ i += this.mr(t, e, s);
1675
+ const o = this.pr(t, e), n = this.nr(t, e, r, s);
1676
+ return n && (o ? (i += `
1677
+ <g${o}>`, i += n, i += `
1678
+ </g>`) : i += n), i;
1679
+ }
1680
+ _r(t, e, r, s) {
1681
+ let i = this.lr(e);
1682
+ i += this.ur(e, s), i += `
1677
1683
  <g id="ascii-cells">`;
1678
- for (const n of t) i += this.ds(n, e, r, s);
1679
- return i += this.hs(), i;
1684
+ for (const o of t) i += this.gr(o, e, r, s);
1685
+ return i += this.cr(), i;
1680
1686
  }
1681
- gs(t) {
1687
+ vr(t) {
1682
1688
  return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\n\s*\n/g, `
1683
1689
  `).replace(/[ \t]+$/gm, "");
1684
1690
  }
1685
1691
  }
1686
- class Et extends L {
1687
- _s(t) {
1688
- return this.Br(t, "image/svg+xml;charset=utf-8");
1692
+ class Tt extends j {
1693
+ br(t) {
1694
+ return this.Xs(t, "image/svg+xml;charset=utf-8");
1689
1695
  }
1690
- vs(t, e) {
1691
- this.Or(t, this.Xr(e) + ".svg", "image/svg+xml;charset=utf-8");
1696
+ wr(t, e) {
1697
+ this.qs(t, this.Zs(e) + ".svg", "image/svg+xml;charset=utf-8");
1692
1698
  }
1693
- bs(t, e) {
1694
- this.vs(t, e || this.qr());
1699
+ Cr(t, e) {
1700
+ this.wr(t, e || this.Js());
1695
1701
  }
1696
1702
  }
1697
- class W {
1703
+ class z {
1698
1704
  constructor() {
1699
- h(this, "ws");
1700
- h(this, "Cs");
1701
- h(this, "$s");
1702
- this.ws = new yt(), this.Cs = new Tt(), this.$s = new Et();
1705
+ h(this, "yr");
1706
+ h(this, "$r");
1707
+ h(this, "Fr");
1708
+ this.yr = new yt(), this.$r = new Et(), this.Fr = new Tt();
1703
1709
  }
1704
- Fs(t) {
1710
+ Tr(t) {
1705
1711
  return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0] };
1706
1712
  }
1707
- Ts(t, e = {}) {
1708
- const r = this.Fs(e), s = this.ws.Lr(t.pipeline), i = this.ws.Zr(s, t.grid), n = this.Cs.ps(i, t.grid, t.font, r);
1709
- return this.Cs.gs(n);
1713
+ Mr(t, e = {}) {
1714
+ const r = this.Tr(e), s = this.yr.Os(t.pipeline), i = this.yr.er(s, t.grid), o = this.$r._r(i, t.grid, t.font, r);
1715
+ return this.$r.vr(o);
1710
1716
  }
1711
- bs(t, e = {}) {
1712
- const r = this.Ts(t, e), s = e.filename || this.$s.qr();
1713
- this.$s.bs(r, s);
1717
+ Cr(t, e = {}) {
1718
+ const r = this.Mr(t, e), s = e.filename || this.Fr.Js();
1719
+ this.Fr.Cr(r, s);
1714
1720
  }
1715
1721
  }
1716
- class Rt extends z {
1717
- Ms(t, e, r, s = " ") {
1718
- var o;
1722
+ class Rt extends N {
1723
+ Dr(t, e, r, s = " ") {
1724
+ var n;
1719
1725
  const i = [];
1720
- let n = 0;
1726
+ let o = 0;
1721
1727
  for (let l = 0; l < e.rows; l++) {
1722
1728
  const c = [];
1723
1729
  for (let u = 0; u < e.cols; u++) {
1724
- const f = 4 * n, d = this.Hr(t.characterPixels, f), v = ((o = r.characters[d]) == null ? void 0 : o.character) || s;
1725
- c.push(v), n++;
1730
+ const f = 4 * o, d = this.Ws(t.characterPixels, f), m = ((n = r.characters[d]) == null ? void 0 : n.character) || s;
1731
+ c.push(m), o++;
1726
1732
  }
1727
1733
  i.push(c);
1728
1734
  }
@@ -1730,11 +1736,11 @@ class Rt extends z {
1730
1736
  }
1731
1737
  }
1732
1738
  class Ft {
1733
- Ds(t, e) {
1739
+ Sr(t, e) {
1734
1740
  const r = [];
1735
1741
  for (const i of t) {
1736
- let n = i.join("");
1737
- e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), r.push(n);
1742
+ let o = i.join("");
1743
+ e.preserveTrailingSpaces || (o = o.replace(/\s+$/, "")), r.push(o);
1738
1744
  }
1739
1745
  const s = e.lineEnding === "crlf" ? `\r
1740
1746
  ` : `
@@ -1742,57 +1748,57 @@ class Ft {
1742
1748
  return r.join(s);
1743
1749
  }
1744
1750
  }
1745
- class Mt extends L {
1746
- Ss(t, e) {
1747
- const r = this.Rs(e);
1748
- this.Or(t, r, "text/plain;charset=utf-8");
1751
+ class Mt extends j {
1752
+ Rr(t, e) {
1753
+ const r = this.Vr(e);
1754
+ this.qs(t, r, "text/plain;charset=utf-8");
1749
1755
  }
1750
- Rs(t) {
1751
- let e = this.Xr(t);
1752
- return e === ".txt" || e.length <= 4 ? this.qr() : e;
1756
+ Vr(t) {
1757
+ let e = this.Zs(t);
1758
+ return e === ".txt" || e.length <= 4 ? this.Js() : e;
1753
1759
  }
1754
1760
  }
1755
- class N {
1761
+ class H {
1756
1762
  constructor() {
1757
- h(this, "ws");
1758
- h(this, "Cs");
1759
- h(this, "$s");
1760
- this.ws = new Rt(), this.Cs = new Ft(), this.$s = new Mt();
1763
+ h(this, "yr");
1764
+ h(this, "$r");
1765
+ h(this, "Fr");
1766
+ this.yr = new Rt(), this.$r = new Ft(), this.Fr = new Mt();
1761
1767
  }
1762
- Fs(t) {
1768
+ Tr(t) {
1763
1769
  return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " " };
1764
1770
  }
1765
- Vs(t, e = {}) {
1766
- const r = this.Fs(e), s = this.ws.Lr(t.pipeline), i = this.ws.Ms(s, t.grid, t.font, r.emptyCharacter);
1767
- return this.Cs.Ds(i, r);
1771
+ kr(t, e = {}) {
1772
+ const r = this.Tr(e), s = this.yr.Os(t.pipeline), i = this.yr.Dr(s, t.grid, t.font, r.emptyCharacter);
1773
+ return this.$r.Sr(i, r);
1768
1774
  }
1769
- Ss(t, e = {}) {
1770
- const r = this.Vs(t, e), s = e.filename || this.$s.qr();
1771
- this.$s.Ss(r, s);
1775
+ Rr(t, e = {}) {
1776
+ const r = this.kr(t, e), s = e.filename || this.Fr.Js();
1777
+ this.Fr.Rr(r, s);
1772
1778
  }
1773
1779
  }
1774
- class At extends z {
1775
- ks(t, e = 1, r = "transparent") {
1780
+ class At extends N {
1781
+ Ir(t, e = 1, r = "transparent") {
1776
1782
  const s = t.canvas;
1777
1783
  if (e === 1 && r === "transparent") return s;
1778
- const i = document.createElement("canvas"), n = i.getContext("2d"), o = Math.round(s.width * e), l = Math.round(s.height * e);
1779
- return i.width = o, i.height = l, r !== "transparent" && (n.fillStyle = r, n.fillRect(0, 0, o, l)), n.imageSmoothingEnabled = !1, n.drawImage(s, 0, 0, s.width, s.height, 0, 0, o, l), i;
1784
+ const i = document.createElement("canvas"), o = i.getContext("2d"), n = Math.round(s.width * e), l = Math.round(s.height * e);
1785
+ return i.width = n, i.height = l, r !== "transparent" && (o.fillStyle = r, o.fillRect(0, 0, n, l)), o.imageSmoothingEnabled = !1, o.drawImage(s, 0, 0, s.width, s.height, 0, 0, n, l), i;
1780
1786
  }
1781
1787
  }
1782
- class Ut {
1783
- Is(t, e) {
1784
- const r = this.zs(e.format);
1788
+ class Pt {
1789
+ Pr(t, e) {
1790
+ const r = this.zr(e.format);
1785
1791
  return e.format === "png" ? t.toDataURL(r) : t.toDataURL(r, e.quality);
1786
1792
  }
1787
- async Es(t, e) {
1793
+ async Er(t, e) {
1788
1794
  return new Promise((r, s) => {
1789
- const i = this.zs(e.format), n = (o) => {
1790
- o ? r(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
1795
+ const i = this.zr(e.format), o = (n) => {
1796
+ n ? r(n) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
1791
1797
  };
1792
- e.format === "png" ? t.toBlob(n, i) : t.toBlob(n, i, e.quality);
1798
+ e.format === "png" ? t.toBlob(o, i) : t.toBlob(o, i, e.quality);
1793
1799
  });
1794
1800
  }
1795
- zs(t) {
1801
+ zr(t) {
1796
1802
  switch (t) {
1797
1803
  case "png":
1798
1804
  return "image/png";
@@ -1805,12 +1811,12 @@ class Ut {
1805
1811
  }
1806
1812
  }
1807
1813
  }
1808
- const Dt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, j = { png: ".png", jpg: ".jpg", webp: ".webp" };
1809
- class St extends L {
1810
- Gs(t, e, r) {
1811
- this.Ps(t, this.Xr(e) + j[r]);
1814
+ const Dt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, Y = { png: ".png", jpg: ".jpg", webp: ".webp" };
1815
+ class St extends j {
1816
+ Gr(t, e, r) {
1817
+ this.Ar(t, this.Zs(e) + Y[r]);
1812
1818
  }
1813
- Ps(t, e) {
1819
+ Ar(t, e) {
1814
1820
  const r = URL.createObjectURL(t);
1815
1821
  try {
1816
1822
  const s = document.createElement("a");
@@ -1819,226 +1825,226 @@ class St extends L {
1819
1825
  URL.revokeObjectURL(r);
1820
1826
  }
1821
1827
  }
1822
- As(t) {
1823
- return t in Dt && t in j;
1828
+ Ur(t) {
1829
+ return t in Dt && t in Y;
1824
1830
  }
1825
1831
  }
1826
- class Pt {
1832
+ class Ut {
1827
1833
  constructor() {
1828
- h(this, "ws");
1829
- h(this, "Cs");
1830
- h(this, "$s");
1831
- this.ws = new At(), this.Cs = new Ut(), this.$s = new St();
1834
+ h(this, "yr");
1835
+ h(this, "$r");
1836
+ h(this, "Fr");
1837
+ this.yr = new At(), this.$r = new Pt(), this.Fr = new St();
1832
1838
  }
1833
- Fs(t) {
1839
+ Tr(t) {
1834
1840
  return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent" };
1835
1841
  }
1836
- Us(t) {
1837
- if (console.log("Validating image export options:", t), !this.$s.As(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
1842
+ Lr(t) {
1843
+ if (console.log("Validating image export options:", t), !this.Fr.Ur(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
1838
1844
  if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
1839
1845
  if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
1840
1846
  t.scale > 10 && console.warn("Large scale factors may result in very large files and slow performance"), t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
1841
1847
  }
1842
- Ls(t, e = {}) {
1843
- const r = this.Fs(e);
1844
- if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return this.Cs.Is(t.canvas, r);
1845
- const s = this.ws.ks(t, r.scale, r.backgroundColor);
1846
- return this.Cs.Is(s, r);
1848
+ Hr(t, e = {}) {
1849
+ const r = this.Tr(e);
1850
+ if (this.Lr(r), r.scale === 1 && r.backgroundColor === "transparent") return this.$r.Pr(t.canvas, r);
1851
+ const s = this.yr.Ir(t, r.scale, r.backgroundColor);
1852
+ return this.$r.Pr(s, r);
1847
1853
  }
1848
- async Es(t, e = {}) {
1849
- const r = this.Fs(e);
1850
- if (this.Us(r), r.scale === 1 && r.backgroundColor === "transparent") return await this.Cs.Es(t.canvas, r);
1851
- const s = this.ws.ks(t, r.scale, r.backgroundColor);
1852
- return await this.Cs.Es(s, r);
1854
+ async Er(t, e = {}) {
1855
+ const r = this.Tr(e);
1856
+ if (this.Lr(r), r.scale === 1 && r.backgroundColor === "transparent") return await this.$r.Er(t.canvas, r);
1857
+ const s = this.yr.Ir(t, r.scale, r.backgroundColor);
1858
+ return await this.$r.Er(s, r);
1853
1859
  }
1854
- async Gs(t, e = {}) {
1855
- const r = await this.Es(t, e), s = e.format ?? "png", i = e.filename || this.$s.qr();
1856
- this.$s.Gs(r, i, s);
1860
+ async Gr(t, e = {}) {
1861
+ const r = await this.Er(t, e), s = e.format ?? "png", i = e.filename || this.Fr.Js();
1862
+ this.Fr.Gr(r, i, s);
1857
1863
  }
1858
1864
  }
1859
1865
  const $t = (a) => class extends a {
1860
1866
  toString(t = {}) {
1861
- return new N().Vs({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
1867
+ return new H().kr({ pipeline: this.jr, grid: this.gs, font: this.Me }, t);
1862
1868
  }
1863
1869
  saveStrings(t = {}) {
1864
- new N().Ss({ pipeline: this.Hs, grid: this.dr, font: this.Te }, t);
1870
+ new H().Rr({ pipeline: this.jr, grid: this.gs, font: this.Me }, t);
1865
1871
  }
1866
1872
  toSVG(t = {}) {
1867
- return new W().Ts(this, t);
1873
+ return new z().Mr(this, t);
1868
1874
  }
1869
1875
  saveSVG(t = {}) {
1870
- new W().bs(this, t);
1876
+ new z().Cr(this, t);
1871
1877
  }
1872
1878
  async saveCanvas(t, e = "png", r = {}) {
1873
- await new Pt().Gs(this.Ye, { ...r, filename: t, format: e });
1879
+ await new Ut().Gr(this.Qe, { ...r, filename: t, format: e });
1874
1880
  }
1875
1881
  }, It = (a) => class extends a {
1876
1882
  async loadFont(t) {
1877
- return this.Te.Be(t).then(() => {
1878
- const e = this.Te.maxGlyphDimensions;
1879
- this.dr.Ke(e.width, e.height), this.Hs.rr();
1883
+ return this.Me.Oe(t).then(() => {
1884
+ const e = this.Me.maxGlyphDimensions;
1885
+ this.gs.ts(e.width, e.height), this.jr.rs();
1880
1886
  });
1881
1887
  }
1882
1888
  fontSize(t) {
1883
- if (!x.p(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Te.fontSize === t) return;
1884
- this.Te.je(t);
1885
- const e = this.Te.maxGlyphDimensions;
1886
- this.dr.Ke(e.width, e.height), this.Hs.rr(), this.ve.jt();
1889
+ if (!v.m(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Me.fontSize === t) return;
1890
+ this.Me.Be(t);
1891
+ const e = this.Me.maxGlyphDimensions;
1892
+ this.gs.ts(e.width, e.height), this.jr.rs(), this.xe.Bt();
1887
1893
  }
1888
- }, Gt = (a) => class extends a {
1894
+ }, Lt = (a) => class extends a {
1889
1895
  addConverter(t) {
1890
- return this.Hs.add(t);
1896
+ return this.jr.add(t);
1891
1897
  }
1892
1898
  removeConverter(t) {
1893
- this.Hs.remove(t);
1899
+ this.jr.remove(t);
1894
1900
  }
1895
1901
  };
1896
1902
  class kt {
1897
1903
  constructor() {
1898
- h(this, "ve");
1899
- h(this, "Te");
1900
- h(this, "Hs");
1901
- h(this, "Ye");
1902
- h(this, "dr");
1904
+ h(this, "xe");
1905
+ h(this, "Me");
1906
+ h(this, "jr");
1907
+ h(this, "Qe");
1908
+ h(this, "gs");
1903
1909
  }
1904
1910
  }
1905
1911
  class X extends function(e, ...r) {
1906
1912
  return r.reduce((s, i) => i(s), e);
1907
- }(kt, Ct, $t, It, Gt) {
1913
+ }(kt, Ct, $t, It, Lt) {
1908
1914
  constructor(e = null, r = {}) {
1909
1915
  super();
1910
- h(this, "ir");
1911
- h(this, "js");
1912
- h(this, "ar");
1913
- h(this, "Bs");
1914
- h(this, "Os");
1915
- h(this, "Ws", null);
1916
- h(this, "Ns", 0);
1917
- h(this, "Xs");
1918
- h(this, "qs", !0);
1919
- h(this, "Ys", 0);
1920
- h(this, "Qs", 0);
1921
- h(this, "Zs", 0);
1922
- h(this, "Js", []);
1923
- h(this, "Ks", 10);
1924
- h(this, "ti", !1);
1916
+ h(this, "hs");
1917
+ h(this, "Br");
1918
+ h(this, "cs");
1919
+ h(this, "Or");
1920
+ h(this, "Wr");
1921
+ h(this, "Nr", null);
1922
+ h(this, "Xr", 0);
1923
+ h(this, "qr");
1924
+ h(this, "Yr", !0);
1925
+ h(this, "Qr", 0);
1926
+ h(this, "Zr", 0);
1927
+ h(this, "Jr", 0);
1928
+ h(this, "Kr", []);
1929
+ h(this, "ti", 10);
1925
1930
  h(this, "ei", !1);
1931
+ h(this, "si", !1);
1926
1932
  h(this, "ri", () => {
1927
1933
  });
1928
- h(this, "si", () => {
1934
+ h(this, "ii", () => {
1929
1935
  });
1930
- h(this, "ii");
1931
- this.ir = e, this.ei = e === null, this.Bs = r.renderMode ?? "auto", this.Os = r.frameRate ?? 60, this.Xs = 1e3 / this.Os;
1936
+ h(this, "ni");
1937
+ this.hs = e, this.si = e === null, this.Or = r.renderMode ?? "auto", this.Wr = r.frameRate ?? 60, this.qr = 1e3 / this.Wr;
1932
1938
  }
1933
1939
  static async create(e = null, r = {}) {
1934
- const s = new this(e, r), i = s.ei ? r : void 0;
1935
- let n, o;
1936
- s.Ye = new mt(s.ir, s.ei, i), s.ve = new nt(s.Ye.cr()), s.ei ? (n = r.width || 800, o = r.height || 600) : (n = s.Ye.width || 800, o = s.Ye.height || 600), s.js = s.ve.Ut(n, o), s.Te = new pt(s.ve, r.fontSize ?? 16), await s.Te.Ue(r.fontSource);
1937
- const l = s.Te.maxGlyphDimensions;
1938
- return s.dr = new vt(s.Ye.canvas, l.width, l.height), s.Hs = new wt(s.ve, s.Te, s.dr), s.ni(), s.oi(), s;
1939
- }
1940
- ni() {
1941
- this.ii = () => {
1942
- this.ei ? this.si() : this.ai();
1943
- }, window.addEventListener("resize", this.ii), window.ResizeObserver && this.ir && !this.ei && (this.ar = new ResizeObserver(() => {
1944
- this.ai();
1945
- }), this.ar.observe(this.ir));
1940
+ const s = new this(e, r), i = s.si ? r : void 0;
1941
+ let o, n;
1942
+ s.Qe = new xt(s.hs, s.si, i), s.xe = new ot(s.Qe.ds()), s.si ? (o = r.width || 800, n = r.height || 600) : (o = s.Qe.width || 800, n = s.Qe.height || 600), s.Br = s.xe.Lt(o, n), s.Me = new pt(s.xe, r.fontSize ?? 16), await s.Me.Le(r.fontSource);
1943
+ const l = s.Me.maxGlyphDimensions;
1944
+ return s.gs = new mt(s.Qe.canvas, l.width, l.height), s.jr = new wt(s.xe, s.Me, s.gs), s.oi(), s.ai(), s;
1945
+ }
1946
+ oi() {
1947
+ this.ni = () => {
1948
+ this.si ? this.ii() : this.hi();
1949
+ }, window.addEventListener("resize", this.ni), window.ResizeObserver && this.hs && !this.si && (this.cs = new ResizeObserver(() => {
1950
+ this.hi();
1951
+ }), this.cs.observe(this.hs));
1946
1952
  }
1947
1953
  render() {
1948
- this.hi(), this.Zs++, this.ti ? console.warn("Cannot render: Required resources have been disposed") : (this.ei ? (this.js.begin(), this.ri(), this.js.end()) : this.js.update(this.ir), this.Hs.hasEnabledConverters() ? (this.Hs.Ur(this.js), this.ve.Lt(0), this.ve.Bt(this.Hs.texture, this.dr.offsetX, this.dr.offsetY, this.Hs.texture.width, this.Hs.texture.height)) : (this.ve.Ht(), this.ve.Bt(this.js, this.dr.offsetX, this.dr.offsetY, this.js.width, this.js.height)));
1954
+ this.li(), this.Jr++, this.ei ? console.warn("Cannot render: Required resources have been disposed") : (this.si ? (this.Br.begin(), this.ri(), this.Br.end()) : this.Br.update(this.hs), this.jr.hasEnabledConverters() ? (this.jr.Bs(this.Br), this.xe.Ht(0), this.xe.Ot(this.jr.texture, this.gs.offsetX, this.gs.offsetY, this.jr.texture.width, this.jr.texture.height)) : (this.xe.jt(), this.xe.Ot(this.Br, this.gs.offsetX, this.gs.offsetY, this.Br.width, this.Br.height)));
1949
1955
  }
1950
- ai() {
1951
- this.Ye.rr(), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.jt(), this.Bs !== "manual" && this.render();
1956
+ hi() {
1957
+ this.Qe.rs(), this.Br.resize(this.Qe.width, this.Qe.height), this.gs.rs(), this.jr.rs(), this.xe.Bt(), this.Or !== "manual" && this.render();
1952
1958
  }
1953
- oi() {
1954
- if (this.Bs !== "auto" || !this.qs) return;
1955
- this.Ns = performance.now();
1959
+ ai() {
1960
+ if (this.Or !== "auto" || !this.Yr) return;
1961
+ this.Xr = performance.now();
1956
1962
  const e = (r) => {
1957
- if (!this.qs) return void (this.Ws = null);
1958
- const s = r - this.Ns;
1959
- s >= this.Xs && (this.render(), this.Ns = r - s % this.Xs), this.qs && (this.Ws = requestAnimationFrame(e));
1963
+ if (!this.Yr) return void (this.Nr = null);
1964
+ const s = r - this.Xr;
1965
+ s >= this.qr && (this.render(), this.Xr = r - s % this.qr), this.Yr && (this.Nr = requestAnimationFrame(e));
1960
1966
  };
1961
- this.Ws = requestAnimationFrame(e);
1967
+ this.Nr = requestAnimationFrame(e);
1962
1968
  }
1963
- hi() {
1969
+ li() {
1964
1970
  const e = performance.now();
1965
- if (this.Qs > 0) {
1966
- const r = e - this.Qs;
1967
- this.Js.push(r), this.Js.length > this.Ks && this.Js.shift();
1968
- const s = this.Js.reduce((i, n) => i + n, 0) / this.Js.length;
1969
- this.Ys = 1e3 / s;
1971
+ if (this.Zr > 0) {
1972
+ const r = e - this.Zr;
1973
+ this.Kr.push(r), this.Kr.length > this.ti && this.Kr.shift();
1974
+ const s = this.Kr.reduce((i, o) => i + o, 0) / this.Kr.length;
1975
+ this.Qr = 1e3 / s;
1970
1976
  }
1971
- this.Qs = e;
1977
+ this.Zr = e;
1972
1978
  }
1973
- li() {
1974
- this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null);
1979
+ ci() {
1980
+ this.Nr && (cancelAnimationFrame(this.Nr), this.Nr = null);
1975
1981
  }
1976
1982
  renderMode(e) {
1977
- this.Bs !== e && (this.li(), this.Bs = e, e === "auto" && this.qs && this.oi());
1983
+ this.Or !== e && (this.ci(), this.Or = e, e === "auto" && this.Yr && this.ai());
1978
1984
  }
1979
1985
  frameRate(e) {
1980
- if (e === void 0) return this.Ys;
1981
- this.Os = e, this.Xs = 1e3 / e, this.Bs === "auto" && this.qs && (this.li(), this.oi());
1986
+ if (e === void 0) return this.Qr;
1987
+ this.Wr = e, this.qr = 1e3 / e, this.Or === "auto" && this.Yr && (this.ci(), this.ai());
1982
1988
  }
1983
1989
  noLoop() {
1984
- this.qs && (this.qs = !1, this.Ws && (cancelAnimationFrame(this.Ws), this.Ws = null));
1990
+ this.Yr && (this.Yr = !1, this.Nr && (cancelAnimationFrame(this.Nr), this.Nr = null));
1985
1991
  }
1986
1992
  loop() {
1987
- this.qs || (this.qs = !0, this.Bs === "auto" && this.oi());
1993
+ this.Yr || (this.Yr = !0, this.Or === "auto" && this.ai());
1988
1994
  }
1989
1995
  redraw(e = 1) {
1990
- if (x.p(typeof e == "number" && e > 0 && Number.isInteger(e), "Redraw count must be a positive integer.", { method: "redraw", providedValue: e })) for (let r = 0; r < e; r++) this.render();
1996
+ if (v.m(typeof e == "number" && e > 0 && Number.isInteger(e), "Redraw count must be a positive integer.", { method: "redraw", providedValue: e })) for (let r = 0; r < e; r++) this.render();
1991
1997
  }
1992
1998
  isLooping() {
1993
- return this.Bs === "auto" && this.qs;
1999
+ return this.Or === "auto" && this.Yr;
1994
2000
  }
1995
2001
  draw(e) {
1996
2002
  this.ri = e;
1997
2003
  }
1998
2004
  windowResized(e) {
1999
- this.si = e;
2005
+ this.ii = e;
2000
2006
  }
2001
2007
  resizeCanvas(e, r) {
2002
- this.ei && (this.Ye.rr(e, r), this.js.resize(this.Ye.width, this.Ye.height), this.dr.rr(), this.Hs.rr(), this.ve.jt(), this.Bs !== "manual" && this.render());
2008
+ this.si && (this.Qe.rs(e, r), this.Br.resize(this.Qe.width, this.Qe.height), this.gs.rs(), this.jr.rs(), this.xe.Bt(), this.Or !== "manual" && this.render());
2003
2009
  }
2004
2010
  destroy() {
2005
- this.ti || (this.li(), window.removeEventListener("resize", this.ii), this.ar && this.ar.disconnect(), this.Hs.G(), this.Te.G(), this.js.G(), this.ve.G(), this.ti = !0);
2011
+ this.ei || (this.ci(), window.removeEventListener("resize", this.ni), this.cs && this.cs.disconnect(), this.jr.P(), this.Me.P(), this.Br.P(), this.xe.P(), this.ei = !0);
2006
2012
  }
2007
2013
  get grid() {
2008
- return this.dr;
2014
+ return this.gs;
2009
2015
  }
2010
2016
  get font() {
2011
- return this.Te;
2017
+ return this.Me;
2012
2018
  }
2013
2019
  get mode() {
2014
- return this.Bs;
2020
+ return this.Or;
2015
2021
  }
2016
2022
  get pipeline() {
2017
- return this.Hs;
2023
+ return this.jr;
2018
2024
  }
2019
2025
  get frameCount() {
2020
- return this.Zs;
2026
+ return this.Jr;
2021
2027
  }
2022
2028
  get renderer() {
2023
- return this.ve;
2029
+ return this.xe;
2024
2030
  }
2025
2031
  set frameCount(e) {
2026
- this.Zs = e;
2032
+ this.Jr = e;
2027
2033
  }
2028
2034
  get width() {
2029
- return this.Ye.width;
2035
+ return this.Qe.width;
2030
2036
  }
2031
2037
  get height() {
2032
- return this.Ye.height;
2038
+ return this.Qe.height;
2033
2039
  }
2034
2040
  get canvas() {
2035
- return this.Ye;
2041
+ return this.Qe;
2036
2042
  }
2037
2043
  get isDisposed() {
2038
- return this.ti;
2044
+ return this.ei;
2039
2045
  }
2040
2046
  }
2041
- class H {
2047
+ class O {
2042
2048
  constructor() {
2043
2049
  throw new w("Textmode is a static class and cannot be instantiated.");
2044
2050
  }
@@ -2052,26 +2058,26 @@ class H {
2052
2058
  }
2053
2059
  }
2054
2060
  static setErrorLevel(t) {
2055
- x._(t);
2061
+ v._(t);
2056
2062
  }
2057
2063
  static get version() {
2058
- return "0.1.9-beta.4";
2064
+ return "0.1.9-beta.5";
2059
2065
  }
2060
2066
  }
2061
- const zt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Lt = H.create, Ht = H.setErrorLevel, Vt = H.version;
2067
+ const Nt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), jt = O.create, Ot = O.setErrorLevel, Vt = O.version;
2062
2068
  export {
2063
- mt as TextmodeCanvas,
2064
- xt as TextmodeColorPalette,
2069
+ xt as TextmodeCanvas,
2070
+ vt as TextmodeColorPalette,
2065
2071
  wt as TextmodeConversionPipeline,
2066
2072
  rt as TextmodeErrorLevel,
2067
2073
  pt as TextmodeFont,
2068
- vt as TextmodeGrid,
2074
+ mt as TextmodeGrid,
2069
2075
  X as Textmodifier,
2070
- Yt as converters,
2071
- Lt as create,
2072
- H as default,
2073
- zt as export,
2074
- Ht as setErrorLevel,
2075
- H as textmode,
2076
+ Gt as converters,
2077
+ jt as create,
2078
+ O as default,
2079
+ Nt as export,
2080
+ Ot as setErrorLevel,
2081
+ O as textmode,
2076
2082
  Vt as version
2077
2083
  };