textmode.js 0.2.0-beta.1 → 0.2.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,77 +1,77 @@
1
- var J = Object.defineProperty;
2
- var q = (a, t, e) => t in a ? J(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var c = (a, t, e) => q(a, typeof t != "symbol" ? t + "" : t, e);
4
- class C extends Error {
1
+ var q = Object.defineProperty;
2
+ var Z = (a, t, e) => t in a ? q(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var c = (a, t, e) => Z(a, typeof t != "symbol" ? t + "" : t, e);
4
+ class y extends Error {
5
5
  constructor(t, e = {}) {
6
- super(C.i(t, e)), this.name = "TextmodeError";
6
+ super(y.i(t, e)), this.name = "TextmodeError";
7
7
  }
8
8
  static i(t, e) {
9
- let s = t;
9
+ let i = t;
10
10
  if (e && Object.keys(e).length > 0) {
11
- s += `
11
+ i += `
12
12
 
13
13
  📋 Context:`;
14
- for (const [r, i] of Object.entries(e))
15
- s += `
16
- - ${r}: ${C.o(i)}`;
14
+ for (const [r, s] of Object.entries(e))
15
+ i += `
16
+ - ${r}: ${y.o(s)}`;
17
17
  }
18
- return s += `
18
+ return i += `
19
19
 
20
- `, s += "↓".repeat(24) + `
21
- `, s;
20
+ `, i += "↓".repeat(24) + `
21
+ `, i;
22
22
  }
23
23
  static o(t) {
24
24
  if (t === null) return "null";
25
25
  if (t === void 0) return "undefined";
26
26
  if (typeof t == "string") return `"${t}"`;
27
27
  if (typeof t == "number" || typeof t == "boolean") return t + "";
28
- if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => C.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => C.o(e)).join(", ")}, ... +${t.length - 3} more]`;
28
+ if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => y.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => y.o(e)).join(", ")}, ... +${t.length - 3} more]`;
29
29
  if (typeof t == "object") {
30
30
  const e = Object.keys(t);
31
- return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((s) => `${s}: ${C.o(t[s])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((s) => `${s}: ${C.o(t[s])}`).join(", ")}, ... +${e.length - 2} more }`;
31
+ return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${y.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${y.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
32
32
  }
33
33
  return t + "";
34
34
  }
35
35
  }
36
- var Z = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(Z || {});
37
- const w = class w {
36
+ var Q = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(Q || {});
37
+ const _ = class _ {
38
38
  constructor() {
39
39
  c(this, "l", { globalLevel: 3 });
40
40
  }
41
41
  static u() {
42
- return w.h || (w.h = new w()), w.h;
42
+ return _.h || (_.h = new _()), _.h;
43
43
  }
44
44
  p(t, e) {
45
- const s = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", r = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
45
+ const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", r = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
46
46
  switch (this.l.globalLevel) {
47
47
  case 0:
48
48
  return !1;
49
49
  case 1:
50
- return console.group(s, r), console.warn(C.i(t, e)), console.groupEnd(), !1;
50
+ return console.group(i, r), console.warn(y.i(t, e)), console.groupEnd(), !1;
51
51
  case 2:
52
- return console.group(s, r), console.error(C.i(t, e)), console.groupEnd(), !1;
52
+ return console.group(i, r), console.error(y.i(t, e)), console.groupEnd(), !1;
53
53
  default:
54
- throw new C(t, e);
54
+ throw new y(t, e);
55
55
  }
56
56
  }
57
- _(t, e, s) {
58
- return !!t || (this.p(e, s), !1);
57
+ _(t, e, i) {
58
+ return !!t || (this.p(e, i), !1);
59
59
  }
60
60
  m(t) {
61
61
  this.l.globalLevel = t;
62
62
  }
63
63
  };
64
- c(w, "h", null);
65
- let z = w;
66
- const I = z.u(), X = /* @__PURE__ */ new WeakMap();
67
- function D(a, t) {
64
+ c(_, "h", null);
65
+ let B = _;
66
+ const M = B.u(), X = /* @__PURE__ */ new WeakMap();
67
+ function U(a, t) {
68
68
  X.set(a, t);
69
69
  }
70
- function L(a) {
70
+ function I(a) {
71
71
  return X.get(a);
72
72
  }
73
- class Y {
74
- constructor(t, e, s = e, r = 1, i = {}) {
73
+ class j {
74
+ constructor(t, e, i = e, r = 1, s = {}) {
75
75
  c(this, "v");
76
76
  c(this, "C");
77
77
  c(this, "l");
@@ -82,15 +82,15 @@ class Y {
82
82
  c(this, "A");
83
83
  c(this, "P", null);
84
84
  c(this, "F", []);
85
- this.v = e, this.C = s, this.l = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...i }, this.R = t, this.A = Math.min(Math.max(1, r), 8);
85
+ this.v = e, this.C = i, this.l = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...s }, this.R = t, this.A = Math.min(Math.max(1, r), 8);
86
86
  const n = t.getParameter(t.MAX_DRAW_BUFFERS), o = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
87
87
  this.A = Math.min(this.A, n, o), this.M = t.createFramebuffer(), this.G(), this.D(), this.F = Array(this.A).fill(null);
88
88
  }
89
89
  G() {
90
- const t = this.R, e = this.l.filter === "linear" ? t.LINEAR : t.NEAREST, s = this.l.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, r = this.l.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
91
- for (let i = 0; i < this.A; i++) {
90
+ const t = this.R, e = this.l.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.l.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, r = this.l.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
91
+ for (let s = 0; s < this.A; s++) {
92
92
  const n = t.createTexture();
93
- t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, s), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, s), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.v, this.C, 0, t.RGBA, r, null), this.S.push(n);
93
+ t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.v, this.C, 0, t.RGBA, r, null), this.S.push(n);
94
94
  }
95
95
  t.bindTexture(t.TEXTURE_2D, null);
96
96
  }
@@ -98,12 +98,12 @@ class Y {
98
98
  const t = this.R;
99
99
  if (t.bindFramebuffer(t.FRAMEBUFFER, this.M), this.A === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.S[0], 0);
100
100
  else {
101
- const s = [];
101
+ const i = [];
102
102
  for (let r = 0; r < this.A; r++) {
103
- const i = t.COLOR_ATTACHMENT0 + r;
104
- t.framebufferTexture2D(t.FRAMEBUFFER, i, t.TEXTURE_2D, this.S[r], 0), s.push(i);
103
+ const s = t.COLOR_ATTACHMENT0 + r;
104
+ t.framebufferTexture2D(t.FRAMEBUFFER, s, t.TEXTURE_2D, this.S[r], 0), i.push(s);
105
105
  }
106
- t.drawBuffers(s);
106
+ t.drawBuffers(i);
107
107
  }
108
108
  const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
109
109
  e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
@@ -114,20 +114,20 @@ class Y {
114
114
  }
115
115
  L(t, e) {
116
116
  this.v = t, this.C = e, this.$ = null, this.F = Array(this.A).fill(null);
117
- const s = this.R, r = this.l.type === "float" ? s.FLOAT : s.UNSIGNED_BYTE;
118
- for (const i of this.S) s.bindTexture(s.TEXTURE_2D, i), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, this.v, this.C, 0, s.RGBA, r, null);
119
- s.bindTexture(s.TEXTURE_2D, null);
117
+ const i = this.R, r = this.l.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
118
+ for (const s of this.S) i.bindTexture(i.TEXTURE_2D, s), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.v, this.C, 0, i.RGBA, r, null);
119
+ i.bindTexture(i.TEXTURE_2D, null);
120
120
  }
121
121
  W(t) {
122
122
  const e = this.R;
123
123
  if (t < 0 || t >= this.A) throw Error(`GLFramebuffer: attachment index ${t} out of range (count=${this.A})`);
124
- const s = this.F[t];
125
- if (s) return s;
126
- const r = this.v, i = this.C, n = new Uint8Array(r * i * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
127
- e.bindFramebuffer(e.READ_FRAMEBUFFER, this.M), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, r, i, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
124
+ const i = this.F[t];
125
+ if (i) return i;
126
+ const r = this.v, s = this.C, n = new Uint8Array(r * s * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
127
+ e.bindFramebuffer(e.READ_FRAMEBUFFER, this.M), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, r, s, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
128
128
  const h = 4 * r, l = new Uint8Array(n.length);
129
- for (let u = 0; u < i; u++) {
130
- const f = (i - 1 - u) * h, d = u * h;
129
+ for (let u = 0; u < s; u++) {
130
+ const f = (s - 1 - u) * h, d = u * h;
131
131
  l.set(n.subarray(f, f + h), d);
132
132
  }
133
133
  return this.F[t] = l, l;
@@ -139,12 +139,12 @@ class Y {
139
139
  const t = this.R;
140
140
  this.P = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.M), this.F = Array(this.A).fill(null);
141
141
  for (let e = 0; e < this.A; e++) t.clearBufferfv(t.COLOR, e, new Float32Array([0, 0, 0, 0]));
142
- t.viewport(0, 0, this.v, this.C), D(t, [0, 0, this.v, this.C]);
142
+ t.viewport(0, 0, this.v, this.C), U(t, [0, 0, this.v, this.C]);
143
143
  }
144
144
  O() {
145
145
  if (!this.P) return;
146
146
  const t = this.R;
147
- t.bindFramebuffer(t.FRAMEBUFFER, this.P.framebuffer), t.viewport(...this.P.viewport), D(t, this.P.viewport), this.P = null;
147
+ t.bindFramebuffer(t.FRAMEBUFFER, this.P.framebuffer), t.viewport(...this.P.viewport), U(t, this.P.viewport), this.P = null;
148
148
  }
149
149
  U() {
150
150
  const t = this.R;
@@ -180,41 +180,41 @@ class Y {
180
180
  return this.F[t] ?? null;
181
181
  }
182
182
  }
183
- class K {
184
- constructor(t, e, s) {
183
+ class J {
184
+ constructor(t, e, i) {
185
185
  c(this, "R");
186
186
  c(this, "j");
187
187
  c(this, "H", /* @__PURE__ */ new Map());
188
188
  c(this, "q", /* @__PURE__ */ new Map());
189
189
  c(this, "N", 0);
190
190
  c(this, "X");
191
- this.R = t, this.j = this.Y(e, s), this.X = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.Z();
191
+ this.R = t, this.j = this.Y(e, i), this.X = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS), this.Z();
192
192
  }
193
193
  Z() {
194
194
  const t = this.R.getProgramParameter(this.j, this.R.ACTIVE_UNIFORMS);
195
195
  for (let e = 0; e < t; e++) {
196
- const s = this.R.getActiveUniform(this.j, e);
197
- if (s) {
198
- const r = this.R.getUniformLocation(this.j, s.name);
199
- r && (this.H.set(s.name, r), this.q.set(s.name, s.type));
196
+ const i = this.R.getActiveUniform(this.j, e);
197
+ if (i) {
198
+ const r = this.R.getUniformLocation(this.j, i.name);
199
+ r && (this.H.set(i.name, r), this.q.set(i.name, i.type));
200
200
  }
201
201
  }
202
202
  }
203
203
  Y(t, e) {
204
- const s = this.J(this.R.VERTEX_SHADER, t), r = this.J(this.R.FRAGMENT_SHADER, e), i = this.R.createProgram();
205
- if (this.R.attachShader(i, s), this.R.attachShader(i, r), this.R.linkProgram(i), !this.R.getProgramParameter(i, this.R.LINK_STATUS)) {
206
- const n = this.R.getProgramInfoLog(i);
204
+ const i = this.J(this.R.VERTEX_SHADER, t), r = this.J(this.R.FRAGMENT_SHADER, e), s = this.R.createProgram();
205
+ if (this.R.attachShader(s, i), this.R.attachShader(s, r), this.R.linkProgram(s), !this.R.getProgramParameter(s, this.R.LINK_STATUS)) {
206
+ const n = this.R.getProgramInfoLog(s);
207
207
  throw Error("Shader program link error: " + n);
208
208
  }
209
- return this.R.deleteShader(s), this.R.deleteShader(r), i;
209
+ return this.R.deleteShader(i), this.R.deleteShader(r), s;
210
210
  }
211
211
  J(t, e) {
212
- const s = this.R.createShader(t);
213
- if (this.R.shaderSource(s, e), this.R.compileShader(s), !this.R.getShaderParameter(s, this.R.COMPILE_STATUS)) {
214
- const r = this.R.getShaderInfoLog(s);
215
- throw this.R.deleteShader(s), Error("Shader compilation error: " + r);
212
+ const i = this.R.createShader(t);
213
+ if (this.R.shaderSource(i, e), this.R.compileShader(i), !this.R.getShaderParameter(i, this.R.COMPILE_STATUS)) {
214
+ const r = this.R.getShaderInfoLog(i);
215
+ throw this.R.deleteShader(i), Error("Shader compilation error: " + r);
216
216
  }
217
- return s;
217
+ return i;
218
218
  }
219
219
  K() {
220
220
  this.R.useProgram(this.j), this.tt();
@@ -223,34 +223,34 @@ class K {
223
223
  this.N = 0;
224
224
  }
225
225
  et(t) {
226
- for (const [e, s] of Object.entries(t)) this.st(e, s);
226
+ for (const [e, i] of Object.entries(t)) this.st(e, i);
227
227
  }
228
228
  st(t, e) {
229
- const s = this.H.get(t);
230
- if (s) if (typeof e == "number") this.R.uniform1f(s, e);
231
- else if (typeof e == "boolean") this.R.uniform1i(s, e ? 1 : 0);
229
+ const i = this.H.get(t);
230
+ if (i) if (typeof e == "number") this.R.uniform1f(i, e);
231
+ else if (typeof e == "boolean") this.R.uniform1i(i, e ? 1 : 0);
232
232
  else if (Array.isArray(e)) switch (e.length) {
233
233
  case 2:
234
- this.R.uniform2f(s, e[0], e[1]);
234
+ this.R.uniform2f(i, e[0], e[1]);
235
235
  break;
236
236
  case 3:
237
- this.R.uniform3f(s, e[0], e[1], e[2]);
237
+ this.R.uniform3f(i, e[0], e[1], e[2]);
238
238
  break;
239
239
  case 4:
240
- this.R.uniform4f(s, e[0], e[1], e[2], e[3]);
240
+ this.R.uniform4f(i, e[0], e[1], e[2], e[3]);
241
241
  break;
242
242
  default:
243
243
  console.warn(`Unsupported array length ${e.length} for uniform '${t}'`);
244
244
  }
245
245
  else if (e instanceof WebGLTexture) {
246
246
  const r = this.it();
247
- this.R.uniform1i(s, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e);
248
- } else if (e instanceof Y) {
247
+ this.R.uniform1i(i, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e);
248
+ } else if (e instanceof j) {
249
249
  const r = this.it();
250
- this.R.uniform1i(s, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e.texture);
250
+ this.R.uniform1i(i, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e.texture);
251
251
  } else if (typeof e == "object" && "texture" in e) {
252
252
  const r = this.it();
253
- this.R.uniform1i(s, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e.texture);
253
+ this.R.uniform1i(i, r), this.R.activeTexture(this.R.TEXTURE0 + r), this.R.bindTexture(this.R.TEXTURE_2D, e.texture);
254
254
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
255
255
  }
256
256
  it() {
@@ -263,7 +263,7 @@ class K {
263
263
  this.R.deleteProgram(this.j);
264
264
  }
265
265
  }
266
- class Q {
266
+ class K {
267
267
  constructor() {
268
268
  c(this, "nt", 1);
269
269
  c(this, "ot", 0);
@@ -274,147 +274,130 @@ class Q {
274
274
  c(this, "ft", !1);
275
275
  c(this, "dt", !1);
276
276
  c(this, "gt", [0, 0]);
277
- c(this, "_t", []);
278
- }
279
- vt() {
280
- this._t.push({ lineWeight: this.nt, rotation: this.ot, charRotation: [...this.gt], flipHorizontally: this.ut, flipVertically: this.ft, invert: this.dt, character: [...this.ht], charColor: [...this.ct], cellColor: [...this.lt] });
277
+ c(this, "_t", [0, 0, 0, 1]);
278
+ c(this, "vt", []);
281
279
  }
282
280
  xt() {
283
- const t = this._t.pop();
284
- t ? (this.nt = t.lineWeight, this.ot = t.rotation, this.gt = t.charRotation, this.ut = t.flipHorizontally, this.ft = t.flipVertically, this.dt = t.invert, this.ht = t.character, this.ct = t.charColor, this.lt = t.cellColor) : console.warn("pop() called without matching push()");
281
+ this.vt.push({ lineWeight: this.nt, rotation: this.ot, charRotation: [...this.gt], flipHorizontally: this.ut, flipVertically: this.ft, invert: this.dt, character: [...this.ht], charColor: [...this.ct], cellColor: [...this.lt] });
285
282
  }
286
283
  Ct() {
287
- this._t = [], this.ot = 0;
284
+ const t = this.vt.pop();
285
+ t ? (this.nt = t.lineWeight, this.ot = t.rotation, this.gt = t.charRotation, this.ut = t.flipHorizontally, this.ft = t.flipVertically, this.dt = t.invert, this.ht = t.character, this.ct = t.charColor, this.lt = t.cellColor) : console.warn("pop() called without matching push()");
288
286
  }
289
- yt(t) {
287
+ yt() {
288
+ this.vt = [], this.ot = 0;
289
+ }
290
+ wt(t) {
290
291
  t.lineWeight = this.nt, t.rotation = this.ot, t.character[0] = this.ht[0], t.character[1] = this.ht[1], t.character[2] = this.ht[2], t.charColor[0] = this.ct[0], t.charColor[1] = this.ct[1], t.charColor[2] = this.ct[2], t.charColor[3] = this.ct[3], t.bgColor[0] = this.lt[0], t.bgColor[1] = this.lt[1], t.bgColor[2] = this.lt[2], t.bgColor[3] = this.lt[3], t.flipHorizontally = this.ut, t.flipVertically = this.ft, t.invert = this.dt, t.charRotation[0] = this.gt[0], t.charRotation[1] = this.gt[1];
291
292
  }
292
293
  get lineWeight() {
293
294
  return this.nt;
294
295
  }
295
- get rotation() {
296
- return this.ot;
296
+ get canvasBackgroundColor() {
297
+ return this._t;
297
298
  }
298
- get character() {
299
- return this.ht;
300
- }
301
- get charColor() {
302
- return this.ct;
303
- }
304
- get bgColor() {
305
- return this.lt;
306
- }
307
- get flipHorizontally() {
308
- return this.ut;
309
- }
310
- get flipVertically() {
311
- return this.ft;
312
- }
313
- get invert() {
314
- return this.dt;
315
- }
316
- get charRotation() {
317
- return this.gt;
318
- }
319
- wt(t) {
299
+ $t(t) {
320
300
  this.nt = Math.abs(t);
321
301
  }
322
- $t(t) {
302
+ bt(t) {
323
303
  this.ot = t;
324
304
  }
325
- bt(t) {
305
+ Tt(t) {
326
306
  this.ht = t;
327
307
  }
328
- Tt(t, e, s, r = 255) {
329
- this.ct = [t / 255, e / 255, s / 255, r / 255];
308
+ zt(t, e, i, r = 255) {
309
+ this.ct = [t / 255, e / 255, i / 255, r / 255];
330
310
  }
331
- zt(t, e, s, r = 255) {
332
- this.lt = [t / 255, e / 255, s / 255, r / 255];
311
+ Rt(t, e, i, r = 255) {
312
+ this.lt = [t / 255, e / 255, i / 255, r / 255];
333
313
  }
334
- Rt(t) {
314
+ Mt(t) {
335
315
  this.ut = t;
336
316
  }
337
- Mt(t) {
317
+ St(t) {
338
318
  this.ft = t;
339
319
  }
340
- St(t) {
320
+ At(t) {
341
321
  this.dt = t;
342
322
  }
343
- At(t) {
344
- const e = 255 * t / 360, s = Math.floor(e) / 255, r = Math.round(e - Math.floor(e));
345
- this.gt = [s, r];
323
+ Pt(t) {
324
+ const e = 255 * t / 360, i = Math.floor(e) / 255, r = Math.round(e - Math.floor(e));
325
+ this.gt = [i, r];
326
+ }
327
+ Ft(t, e, i, r) {
328
+ this._t = [t / 255, e / 255, i / 255, r / 255];
346
329
  }
347
330
  }
348
331
  var R = ((a) => (a.RECTANGLE = "rectangle", a.LINE = "line", a.ELLIPSE = "ellipse", a.ARC = "arc", a.TRIANGLE = "triangle", a.BEZIER_CURVE = "bezier_curve", a.CUSTOM = "custom", a))(R || {});
349
332
  class tt {
350
333
  constructor(t) {
351
334
  c(this, "R");
352
- c(this, "Pt", /* @__PURE__ */ new Map());
335
+ c(this, "Gt", /* @__PURE__ */ new Map());
353
336
  this.R = t;
354
337
  }
355
- Ft(t, e, s, r) {
356
- const i = this.R;
357
- let n = this.Pt.get(t);
358
- n || (n = /* @__PURE__ */ new Map(), this.Pt.set(t, n));
338
+ Dt(t, e, i, r) {
339
+ const s = this.R;
340
+ let n = this.Gt.get(t);
341
+ n || (n = /* @__PURE__ */ new Map(), this.Gt.set(t, n));
359
342
  let o = n.get(e) || null;
360
343
  if (!o) {
361
- o = i.createVertexArray(), n.set(e, o), i.bindVertexArray(o), i.bindBuffer(i.ARRAY_BUFFER, r);
362
- const h = i.getAttribLocation(t, "a_position");
363
- h !== -1 && (i.enableVertexAttribArray(h), i.vertexAttribPointer(h, s.attributes.position.size, i.FLOAT, !1, s.stride, s.attributes.position.offset), i.vertexAttribDivisor(h, 0));
364
- const l = i.getAttribLocation(t, "a_texCoord");
365
- l !== -1 && (i.enableVertexAttribArray(l), i.vertexAttribPointer(l, s.attributes.texCoord.size, i.FLOAT, !1, s.stride, s.attributes.texCoord.offset), i.vertexAttribDivisor(l, 0));
344
+ o = s.createVertexArray(), n.set(e, o), s.bindVertexArray(o), s.bindBuffer(s.ARRAY_BUFFER, r);
345
+ const h = s.getAttribLocation(t, "a_position");
346
+ h !== -1 && (s.enableVertexAttribArray(h), s.vertexAttribPointer(h, i.attributes.position.size, s.FLOAT, !1, i.stride, i.attributes.position.offset), s.vertexAttribDivisor(h, 0));
347
+ const l = s.getAttribLocation(t, "a_texCoord");
348
+ l !== -1 && (s.enableVertexAttribArray(l), s.vertexAttribPointer(l, i.attributes.texCoord.size, s.FLOAT, !1, i.stride, i.attributes.texCoord.offset), s.vertexAttribDivisor(l, 0));
366
349
  }
367
- i.bindVertexArray(o);
350
+ s.bindVertexArray(o);
368
351
  }
369
- Gt() {
352
+ It() {
370
353
  this.R.bindVertexArray(null);
371
354
  }
372
355
  U() {
373
356
  const t = this.R;
374
- for (const [, e] of this.Pt) for (const [, s] of e) s && t.deleteVertexArray(s);
375
- this.Pt.clear();
357
+ for (const [, e] of this.Gt) for (const [, i] of e) i && t.deleteVertexArray(i);
358
+ this.Gt.clear();
376
359
  }
377
360
  }
378
361
  class et {
379
362
  constructor(t) {
380
- c(this, "Dt");
363
+ c(this, "Bt");
381
364
  c(this, "R");
382
- this.R = t, this.Dt = new tt(t);
365
+ this.R = t, this.Bt = new tt(t);
383
366
  }
384
- It(t, e, s) {
385
- const { shader: r } = t, i = L(this.R) || this.R.getParameter(this.R.VIEWPORT);
386
- r.et({ u_aspectRatio: i[2] / i[3], u_viewportSize: [i[2], i[3]] });
367
+ Lt(t, e, i) {
368
+ const { shader: r } = t, s = I(this.R) || this.R.getParameter(this.R.VIEWPORT);
369
+ r.et({ u_aspectRatio: s[2] / s[3], u_viewportSize: [s[2], s[3]] });
387
370
  const n = (l) => {
388
- if (!l || !l.Bt()) return;
371
+ if (!l || !l.Et()) return;
389
372
  const u = l.unitGeometry, f = l.unitBuffer;
390
373
  try {
391
- this.Dt.Ft(r.rt, l.type + "", u, f), l.batch.Lt(r), l.batch.Et(u.primitiveType, u.vertexCount);
374
+ this.Bt.Dt(r.rt, l.type + "", u, f), l.batch.Wt(r), l.batch.kt(u.primitiveType, u.vertexCount);
392
375
  } finally {
393
- l.batch.Wt(r), this.Dt.Gt(), l.kt();
376
+ l.batch.Vt(r), this.Bt.It(), l.Ot();
394
377
  }
395
378
  };
396
379
  let o = null, h = null;
397
380
  for (const l of e) {
398
381
  o !== null && l.type !== o && (n(h), o = null, h = null);
399
382
  let u = h;
400
- u && l.type === o || (u = s.get(l.type) || null, h = u, o = l.type), u && u.Vt(l.params, l.state);
383
+ u && l.type === o || (u = i.get(l.type) || null, h = u, o = l.type), u && u.Ut(l.params, l.state);
401
384
  }
402
385
  n(h);
403
386
  }
404
387
  }
405
- class st {
388
+ class it {
406
389
  constructor() {
407
- c(this, "Ot", []);
408
- c(this, "Ut", 1);
409
- c(this, "jt", 0);
410
- }
411
- Ht(t) {
412
- if (this.jt >= this.Ot.length) {
413
- const s = { id: this.Ut++, type: t, params: {}, state: { lineWeight: 1, rotation: 0, character: [0, 0, 0], charColor: [1, 1, 1, 1], bgColor: [0, 0, 0, 1], flipHorizontally: !1, flipVertically: !1, invert: !1, charRotation: [0, 0] } };
414
- this.Ot.push(s);
390
+ c(this, "jt", []);
391
+ c(this, "Ht", 1);
392
+ c(this, "qt", 0);
393
+ }
394
+ Nt(t) {
395
+ if (this.qt >= this.jt.length) {
396
+ const i = { id: this.Ht++, type: t, params: {}, state: { lineWeight: 1, rotation: 0, character: [0, 0, 0], charColor: [1, 1, 1, 1], bgColor: [0, 0, 0, 1], flipHorizontally: !1, flipVertically: !1, invert: !1, charRotation: [0, 0] } };
397
+ this.jt.push(i);
415
398
  }
416
- const e = this.Ot[this.jt];
417
- switch (e.id = this.Ut++, e.type = t, t) {
399
+ const e = this.jt[this.qt];
400
+ switch (e.id = this.Ht++, e.type = t, t) {
418
401
  case R.RECTANGLE:
419
402
  case R.ELLIPSE:
420
403
  e.params && "width" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0 });
@@ -434,208 +417,208 @@ class st {
434
417
  default:
435
418
  e.params || (e.params = {});
436
419
  }
437
- return this.jt++, e;
420
+ return this.qt++, e;
438
421
  }
439
- qt(t, e, s, r, i) {
440
- const n = this.Ht(R.RECTANGLE);
441
- return n.params.x = t, n.params.y = e, n.params.width = s, n.params.height = r, i.yt(n.state), n.id;
422
+ Xt(t, e, i, r, s) {
423
+ const n = this.Nt(R.RECTANGLE);
424
+ return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = r, s.wt(n.state), n.id;
442
425
  }
443
- Nt(t, e, s, r, i, n) {
444
- const o = this.Ht(R.LINE);
445
- return o.params.x1 = t, o.params.y1 = e, o.params.x2 = s, o.params.y2 = r, o.params.thickness = i, n.yt(o.state), o.id;
426
+ Yt(t, e, i, r, s, n) {
427
+ const o = this.Nt(R.LINE);
428
+ return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = r, o.params.thickness = s, n.wt(o.state), o.id;
446
429
  }
447
- Xt(t, e, s, r, i) {
448
- const n = this.Ht(R.ELLIPSE);
449
- return n.params.x = t, n.params.y = e, n.params.width = s, n.params.height = r, i.yt(n.state), n.id;
430
+ Qt(t, e, i, r, s) {
431
+ const n = this.Nt(R.ELLIPSE);
432
+ return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = r, s.wt(n.state), n.id;
450
433
  }
451
- Yt(t, e, s, r, i, n, o) {
452
- const h = this.Ht(R.ARC);
453
- return h.params.x = t, h.params.y = e, h.params.width = s, h.params.height = r, h.params.start = i, h.params.stop = n, o.yt(h.state), h.id;
434
+ Zt(t, e, i, r, s, n, o) {
435
+ const h = this.Nt(R.ARC);
436
+ return h.params.x = t, h.params.y = e, h.params.width = i, h.params.height = r, h.params.start = s, h.params.stop = n, o.wt(h.state), h.id;
454
437
  }
455
- Qt(t, e, s, r, i, n, o) {
456
- const h = this.Ht(R.TRIANGLE);
457
- return h.params.x1 = t, h.params.y1 = e, h.params.x2 = s, h.params.y2 = r, h.params.x3 = i, h.params.y3 = n, o.yt(h.state), h.id;
438
+ Jt(t, e, i, r, s, n, o) {
439
+ const h = this.Nt(R.TRIANGLE);
440
+ return h.params.x1 = t, h.params.y1 = e, h.params.x2 = i, h.params.y2 = r, h.params.x3 = s, h.params.y3 = n, o.wt(h.state), h.id;
458
441
  }
459
- Zt(t, e, s, r, i, n, o, h, l, u) {
460
- const f = this.Ht(R.BEZIER_CURVE);
461
- return f.params.x1 = t, f.params.y1 = e, f.params.cp1x = s, f.params.cp1y = r, f.params.cp2x = i, f.params.cp2y = n, f.params.x2 = o, f.params.y2 = h, f.params.thickness = l, u.yt(f.state), f.id;
442
+ Kt(t, e, i, r, s, n, o, h, l, u) {
443
+ const f = this.Nt(R.BEZIER_CURVE);
444
+ return f.params.x1 = t, f.params.y1 = e, f.params.cp1x = i, f.params.cp1y = r, f.params.cp2x = s, f.params.cp2y = n, f.params.x2 = o, f.params.y2 = h, f.params.thickness = l, u.wt(f.state), f.id;
462
445
  }
463
446
  get length() {
464
- return this.jt;
447
+ return this.qt;
465
448
  }
466
449
  get isEmpty() {
467
- return this.jt === 0;
450
+ return this.qt === 0;
468
451
  }
469
- Jt() {
470
- this.jt = 0;
452
+ te() {
453
+ this.qt = 0;
471
454
  }
472
455
  [Symbol.iterator]() {
473
456
  let t = 0;
474
- const e = this.jt, s = this.Ot;
475
- return { next: () => t < e ? { value: s[t++], done: !1 } : { value: void 0, done: !0 } };
457
+ const e = this.qt, i = this.jt;
458
+ return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
476
459
  }
477
460
  }
478
461
  const A = class A {
479
- static Kt(t, e, s = 0) {
480
- var n, o, h, l, u, f, d, p, g, m;
462
+ static ee(t, e, i = 0) {
463
+ var n, o, h, l, u, f, d, g, p, m;
481
464
  const r = e || new Float32Array(A.FLOATS_PER_INSTANCE);
482
- let i = s;
483
- return r[i++] = t.position[0], r[i++] = t.position[1], r[i++] = t.size[0], r[i++] = t.size[1], r[i++] = t.character[0], r[i++] = t.character[1], r[i++] = t.character[2], r[i++] = t.primaryColor[0], r[i++] = t.primaryColor[1], r[i++] = t.primaryColor[2], r[i++] = t.primaryColor[3], r[i++] = t.secondaryColor[0], r[i++] = t.secondaryColor[1], r[i++] = t.secondaryColor[2], r[i++] = t.secondaryColor[3], r[i++] = t.rotation[0], r[i++] = t.rotation[1], r[i++] = t.transform[0], r[i++] = t.transform[1], r[i++] = t.transform[2], r[i++] = t.globalRotation, r[i++] = t.rotationCenter[0], r[i++] = t.rotationCenter[1], r[i++] = ((n = t.arcAngles) == null ? void 0 : n[0]) || 0, r[i++] = ((o = t.arcAngles) == null ? void 0 : o[1]) || 0, r[i++] = ((h = t.bezierControlPoint1) == null ? void 0 : h[0]) || 0, r[i++] = ((l = t.bezierControlPoint1) == null ? void 0 : l[1]) || 0, r[i++] = ((u = t.bezierControlPoint2) == null ? void 0 : u[0]) || 0, r[i++] = ((f = t.bezierControlPoint2) == null ? void 0 : f[1]) || 0, r[i++] = ((d = t.bezierStartPoint) == null ? void 0 : d[0]) || 0, r[i++] = ((p = t.bezierStartPoint) == null ? void 0 : p[1]) || 0, r[i++] = ((g = t.bezierEndPoint) == null ? void 0 : g[0]) || 0, r[i++] = ((m = t.bezierEndPoint) == null ? void 0 : m[1]) || 0, r;
465
+ let s = i;
466
+ return r[s++] = t.position[0], r[s++] = t.position[1], r[s++] = t.size[0], r[s++] = t.size[1], r[s++] = t.character[0], r[s++] = t.character[1], r[s++] = t.character[2], r[s++] = t.primaryColor[0], r[s++] = t.primaryColor[1], r[s++] = t.primaryColor[2], r[s++] = t.primaryColor[3], r[s++] = t.secondaryColor[0], r[s++] = t.secondaryColor[1], r[s++] = t.secondaryColor[2], r[s++] = t.secondaryColor[3], r[s++] = t.rotation[0], r[s++] = t.rotation[1], r[s++] = t.transform[0], r[s++] = t.transform[1], r[s++] = t.transform[2], r[s++] = t.globalRotation, r[s++] = t.rotationCenter[0], r[s++] = t.rotationCenter[1], r[s++] = ((n = t.arcAngles) == null ? void 0 : n[0]) || 0, r[s++] = ((o = t.arcAngles) == null ? void 0 : o[1]) || 0, r[s++] = ((h = t.bezierControlPoint1) == null ? void 0 : h[0]) || 0, r[s++] = ((l = t.bezierControlPoint1) == null ? void 0 : l[1]) || 0, r[s++] = ((u = t.bezierControlPoint2) == null ? void 0 : u[0]) || 0, r[s++] = ((f = t.bezierControlPoint2) == null ? void 0 : f[1]) || 0, r[s++] = ((d = t.bezierStartPoint) == null ? void 0 : d[0]) || 0, r[s++] = ((g = t.bezierStartPoint) == null ? void 0 : g[1]) || 0, r[s++] = ((p = t.bezierEndPoint) == null ? void 0 : p[0]) || 0, r[s++] = ((m = t.bezierEndPoint) == null ? void 0 : m[1]) || 0, r;
484
467
  }
485
- static te(t) {
486
- const e = t.length * A.FLOATS_PER_INSTANCE, s = new Float32Array(e);
468
+ static se(t) {
469
+ const e = t.length * A.FLOATS_PER_INSTANCE, i = new Float32Array(e);
487
470
  for (let r = 0; r < t.length; r++) {
488
- const i = r * A.FLOATS_PER_INSTANCE;
489
- A.Kt(t[r], s, i);
471
+ const s = r * A.FLOATS_PER_INSTANCE;
472
+ A.ee(t[r], i, s);
490
473
  }
491
- return s;
474
+ return i;
492
475
  }
493
476
  };
494
477
  c(A, "BYTES_PER_INSTANCE", 132), c(A, "FLOATS_PER_INSTANCE", 33);
495
- let P = A;
478
+ let S = A;
496
479
  const x = class x {
497
480
  };
498
- c(x, "STRIDE", P.BYTES_PER_INSTANCE), c(x, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 1, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 84, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 92, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 124, divisor: 1 } });
499
- let M = x;
481
+ c(x, "STRIDE", S.BYTES_PER_INSTANCE), c(x, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 1, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 84, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 92, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: x.STRIDE, offset: 124, divisor: 1 } });
482
+ let D = x;
500
483
  class rt {
501
- constructor(t, e = 1e3, s = 1.5) {
484
+ constructor(t, e = 1e3, i = 1.5) {
502
485
  c(this, "R");
503
- c(this, "ee", []);
504
- c(this, "se");
505
- c(this, "ie");
506
- c(this, "re", null);
507
- c(this, "ne", !0);
508
- c(this, "oe", 0);
509
- c(this, "ae", /* @__PURE__ */ new Map());
510
- c(this, "he", null);
511
- this.R = t, this.se = e, this.ie = s, this.ce();
512
- }
513
- Vt(t) {
514
- const e = this.ee.length;
515
- return this.ee.push(t), this.ne = !0, e;
486
+ c(this, "ie", []);
487
+ c(this, "re");
488
+ c(this, "ne");
489
+ c(this, "oe", null);
490
+ c(this, "ae", !0);
491
+ c(this, "he", 0);
492
+ c(this, "ce", /* @__PURE__ */ new Map());
493
+ c(this, "le", null);
494
+ this.R = t, this.re = e, this.ne = i, this.ue();
495
+ }
496
+ Ut(t) {
497
+ const e = this.ie.length;
498
+ return this.ie.push(t), this.ae = !0, e;
516
499
  }
517
500
  get count() {
518
- return this.ee.length;
501
+ return this.ie.length;
519
502
  }
520
503
  get isEmpty() {
521
- return this.ee.length === 0;
504
+ return this.ie.length === 0;
522
505
  }
523
506
  clear() {
524
- this.ee.length = 0, this.ne = !0;
525
- }
526
- le(t) {
527
- if (t <= this.se) return;
528
- const e = Math.ceil(t * this.ie);
529
- this.se = e, this.ce(), console.log(`InstanceBatch: Grew buffer capacity to ${e} instances`);
507
+ this.ie.length = 0, this.ae = !0;
530
508
  }
531
- ce() {
532
- const t = this.R;
533
- if (this.re && t.deleteBuffer(this.re), this.re = t.createBuffer(), !this.re) throw Error("Failed to create instance buffer");
534
- const e = this.se * P.BYTES_PER_INSTANCE;
535
- t.bindBuffer(t.ARRAY_BUFFER, this.re), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ne = !0, this.oe = 0;
509
+ fe(t) {
510
+ if (t <= this.re) return;
511
+ const e = Math.ceil(t * this.ne);
512
+ this.re = e, this.ue(), console.log(`InstanceBatch: Grew buffer capacity to ${e} instances`);
536
513
  }
537
514
  ue() {
538
- if (!this.ne || this.ee.length === 0) return;
539
- const t = this.R, e = this.ee.length;
540
- this.le(e), (!this.he || this.he.length < e * P.FLOATS_PER_INSTANCE) && (this.he = new Float32Array(e * P.FLOATS_PER_INSTANCE));
541
- const s = P.te(this.ee);
542
- t.bindBuffer(t.ARRAY_BUFFER, this.re), e <= this.oe ? t.bufferSubData(t.ARRAY_BUFFER, 0, s) : t.bufferData(t.ARRAY_BUFFER, s, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ne = !1, this.oe = e;
543
- }
544
- fe(t) {
545
- let e = this.ae.get(t);
515
+ const t = this.R;
516
+ if (this.oe && t.deleteBuffer(this.oe), this.oe = t.createBuffer(), !this.oe) throw Error("Failed to create instance buffer");
517
+ const e = this.re * S.BYTES_PER_INSTANCE;
518
+ t.bindBuffer(t.ARRAY_BUFFER, this.oe), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !0, this.he = 0;
519
+ }
520
+ de() {
521
+ if (!this.ae || this.ie.length === 0) return;
522
+ const t = this.R, e = this.ie.length;
523
+ this.fe(e), (!this.le || this.le.length < e * S.FLOATS_PER_INSTANCE) && (this.le = new Float32Array(e * S.FLOATS_PER_INSTANCE));
524
+ const i = S.se(this.ie);
525
+ t.bindBuffer(t.ARRAY_BUFFER, this.oe), e <= this.he ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.ae = !1, this.he = e;
526
+ }
527
+ pe(t) {
528
+ let e = this.ce.get(t);
546
529
  if (!e) {
547
530
  e = /* @__PURE__ */ new Map();
548
- const s = this.R;
549
- for (const r in M.ATTRIBUTES) {
550
- const i = s.getAttribLocation(t, r);
551
- i !== -1 && e.set(r, i);
531
+ const i = this.R;
532
+ for (const r in D.ATTRIBUTES) {
533
+ const s = i.getAttribLocation(t, r);
534
+ s !== -1 && e.set(r, s);
552
535
  }
553
- this.ae.set(t, e);
536
+ this.ce.set(t, e);
554
537
  }
555
538
  return e;
556
539
  }
557
- Lt(t) {
558
- if (!this.re || this.ee.length === 0) return;
559
- const e = this.R, s = t.rt;
560
- if (!s) return void console.warn("InstanceBatch: Cannot bind attributes - invalid shader program");
561
- this.ue();
562
- const r = this.fe(s);
563
- e.bindBuffer(e.ARRAY_BUFFER, this.re);
564
- for (const [i, n] of r) {
565
- const o = M.ATTRIBUTES[i];
540
+ Wt(t) {
541
+ if (!this.oe || this.ie.length === 0) return;
542
+ const e = this.R, i = t.rt;
543
+ if (!i) return void console.warn("InstanceBatch: Cannot bind attributes - invalid shader program");
544
+ this.de();
545
+ const r = this.pe(i);
546
+ e.bindBuffer(e.ARRAY_BUFFER, this.oe);
547
+ for (const [s, n] of r) {
548
+ const o = D.ATTRIBUTES[s];
566
549
  o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
567
550
  }
568
551
  }
569
- Wt(t) {
570
- const e = this.R, s = this.fe(t.rt);
571
- for (const [, r] of s) e.disableVertexAttribArray(r), e.vertexAttribDivisor(r, 0);
552
+ Vt(t) {
553
+ const e = this.R, i = this.pe(t.rt);
554
+ for (const [, r] of i) e.disableVertexAttribArray(r), e.vertexAttribDivisor(r, 0);
572
555
  }
573
- Et(t, e) {
574
- this.ee.length !== 0 && this.R.drawArraysInstanced(t, 0, e, this.ee.length);
556
+ kt(t, e) {
557
+ this.ie.length !== 0 && this.R.drawArraysInstanced(t, 0, e, this.ie.length);
575
558
  }
576
559
  U() {
577
560
  const t = this.R;
578
- this.re && (t.deleteBuffer(this.re), this.re = null), this.ee.length = 0, this.ae.clear(), this.he = null;
561
+ this.oe && (t.deleteBuffer(this.oe), this.oe = null), this.ie.length = 0, this.ce.clear(), this.le = null;
579
562
  }
580
563
  }
581
564
  class F {
582
- constructor(t, e, s, r) {
565
+ constructor(t, e, i, r) {
583
566
  c(this, "R");
584
- c(this, "de");
585
- c(this, "pe");
586
567
  c(this, "ge");
587
- c(this, "_e", null);
588
- this.R = t, this.de = e, this.pe = s, this.ge = r;
589
- const i = this.R.createBuffer();
590
- if (!i) throw Error("Failed to create unit geometry buffer");
591
- this.R.bindBuffer(this.R.ARRAY_BUFFER, i), this.R.bufferData(this.R.ARRAY_BUFFER, this.ge.vertices, this.R.STATIC_DRAW), this.R.bindBuffer(this.R.ARRAY_BUFFER, null), this._e = i;
568
+ c(this, "_e");
569
+ c(this, "me");
570
+ c(this, "ve", null);
571
+ this.R = t, this.ge = e, this._e = i, this.me = r;
572
+ const s = this.R.createBuffer();
573
+ if (!s) throw Error("Failed to create unit geometry buffer");
574
+ this.R.bindBuffer(this.R.ARRAY_BUFFER, s), this.R.bufferData(this.R.ARRAY_BUFFER, this.me.vertices, this.R.STATIC_DRAW), this.R.bindBuffer(this.R.ARRAY_BUFFER, null), this.ve = s;
592
575
  }
593
576
  get type() {
594
- return this.pe;
577
+ return this._e;
595
578
  }
596
579
  get unitGeometry() {
597
- return this.ge;
580
+ return this.me;
598
581
  }
599
582
  get unitBuffer() {
600
- return this._e;
583
+ return this.ve;
601
584
  }
602
585
  get batch() {
603
- return this.de;
586
+ return this.ge;
604
587
  }
605
- kt() {
606
- this.de.clear();
588
+ Ot() {
589
+ this.ge.clear();
607
590
  }
608
- Bt() {
609
- return !this.de.isEmpty;
591
+ Et() {
592
+ return !this.ge.isEmpty;
610
593
  }
611
594
  U() {
612
- this.de.U(), this._e && (this.R.deleteBuffer(this._e), this._e = null);
595
+ this.ge.U(), this.ve && (this.R.deleteBuffer(this.ve), this.ve = null);
613
596
  }
614
- me(t, e, s, r, i) {
615
- const n = this.ve(t, e, s, r, i.rotation || 0);
616
- return { position: [t, e], size: [s, r], character: i.character || [0, 0, 0], primaryColor: i.charColor || [1, 1, 1, 1], secondaryColor: i.bgColor || [0, 0, 0, 1], rotation: i.charRotation || [0, 0], transform: [i.invert ? 1 : 0, i.flipHorizontally ? 1 : 0, i.flipVertically ? 1 : 0], globalRotation: n.radians, rotationCenter: [n.centerX, n.centerY] };
597
+ xe(t, e, i, r, s) {
598
+ const n = this.Ce(t, e, i, r, s.rotation || 0);
599
+ return { position: [t, e], size: [i, r], character: s.character || [0, 0, 0], primaryColor: s.charColor || [1, 1, 1, 1], secondaryColor: s.bgColor || [0, 0, 0, 1], rotation: s.charRotation || [0, 0], transform: [s.invert ? 1 : 0, s.flipHorizontally ? 1 : 0, s.flipVertically ? 1 : 0], globalRotation: n.radians, rotationCenter: [n.centerX, n.centerY] };
617
600
  }
618
- xe(t, e) {
619
- const s = L(this.R) || [0, 0, this.R.canvas.width, this.R.canvas.height];
620
- return { nx: t / s[2] * 2 - 1, ny: 1 - e / s[3] * 2 };
601
+ ye(t, e) {
602
+ const i = I(this.R) || [0, 0, this.R.canvas.width, this.R.canvas.height];
603
+ return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
621
604
  }
622
- Ce(t, e, s) {
623
- const r = this.xe(e, s);
605
+ we(t, e, i) {
606
+ const r = this.ye(e, i);
624
607
  t.rotationCenter = [r.nx, r.ny];
625
608
  }
626
- ve(t, e, s, r, i) {
627
- const n = L(this.R) || [0, 0, this.R.canvas.width, this.R.canvas.height], o = n[2], h = n[3];
628
- return { centerX: (t + s / 2) / o * 2 - 1, centerY: 1 - (e + r / 2) / h * 2, radians: -i * Math.PI / 180, aspectRatio: o / h };
609
+ Ce(t, e, i, r, s) {
610
+ const n = I(this.R) || [0, 0, this.R.canvas.width, this.R.canvas.height], o = n[2], h = n[3];
611
+ return { centerX: (t + i / 2) / o * 2 - 1, centerY: 1 - (e + r / 2) / h * 2, radians: -s * Math.PI / 180, aspectRatio: o / h };
629
612
  }
630
613
  }
631
- const it = { vertices: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
614
+ const st = { vertices: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
632
615
  class nt extends F {
633
616
  constructor(t, e) {
634
- super(t, e, R.RECTANGLE, it);
617
+ super(t, e, R.RECTANGLE, st);
635
618
  }
636
- Vt(t, e) {
637
- const s = this.me(t.x, t.y, t.width, t.height, e);
638
- return this.de.Vt(s);
619
+ Ut(t, e) {
620
+ const i = this.xe(t.x, t.y, t.width, t.height, e);
621
+ return this.ge.Ut(i);
639
622
  }
640
623
  }
641
624
  const ot = { vertices: new Float32Array([0, -0.5, 0, 0, 1, -0.5, 1, 0, 0, 0.5, 0, 1, 0, 0.5, 0, 1, 1, -0.5, 1, 0, 1, 0.5, 1, 1]), vertexCount: 6, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
@@ -643,16 +626,16 @@ class at extends F {
643
626
  constructor(t, e) {
644
627
  super(t, e, R.LINE, ot);
645
628
  }
646
- Vt(t, e) {
647
- const s = t.x2 - t.x1, r = t.y2 - t.y1, i = Math.hypot(s, r), n = Math.atan2(r, s), o = t.thickness || e.lineWeight || 1, h = t.x1 + s / 2, l = t.y1 + r / 2, u = h - i / 2, f = l, d = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotation: (e.rotation || 0) + 180 * n / Math.PI, lineWeight: o }, p = this.me(u, f, i, o, d);
648
- return this.Ce(p, h, l), this.de.Vt(p);
629
+ Ut(t, e) {
630
+ const i = t.x2 - t.x1, r = t.y2 - t.y1, s = Math.hypot(i, r), n = Math.atan2(r, i), o = t.thickness || e.lineWeight || 1, h = t.x1 + i / 2, l = t.y1 + r / 2, u = h - s / 2, f = l, d = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotation: (e.rotation || 0) + 180 * n / Math.PI, lineWeight: o }, g = this.xe(u, f, s, o, d);
631
+ return this.we(g, h, l), this.ge.Ut(g);
649
632
  }
650
633
  }
651
634
  const ht = { vertices: function(a = 32) {
652
635
  const t = [], e = 2 * Math.PI / a;
653
- for (let s = 0; s < a; s++) {
654
- const r = s * e, i = (s + 1) % a * e, n = Math.cos(r), o = Math.sin(r), h = 0.5 * (n + 1), l = 0.5 * (o + 1), u = Math.cos(i), f = Math.sin(i), d = 0.5 * (u + 1), p = 0.5 * (f + 1);
655
- t.push(0, 0, 0.5, 0.5, n, o, h, l, u, f, d, p);
636
+ for (let i = 0; i < a; i++) {
637
+ const r = i * e, s = (i + 1) % a * e, n = Math.cos(r), o = Math.sin(r), h = 0.5 * (n + 1), l = 0.5 * (o + 1), u = Math.cos(s), f = Math.sin(s), d = 0.5 * (u + 1), g = 0.5 * (f + 1);
638
+ t.push(0, 0, 0.5, 0.5, n, o, h, l, u, f, d, g);
656
639
  }
657
640
  return new Float32Array(t);
658
641
  }(32), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
@@ -660,16 +643,16 @@ class ct extends F {
660
643
  constructor(t, e) {
661
644
  super(t, e, R.ELLIPSE, ht);
662
645
  }
663
- Vt(t, e) {
664
- const s = this.me(t.x, t.y, t.width, t.height, e);
665
- return this.Ce(s, t.x, t.y), this.de.Vt(s);
646
+ Ut(t, e) {
647
+ const i = this.xe(t.x, t.y, t.width, t.height, e);
648
+ return this.we(i, t.x, t.y), this.ge.Ut(i);
666
649
  }
667
650
  }
668
651
  let lt = { vertices: function(a) {
669
652
  const t = [];
670
653
  for (let e = 0; e < a; e++) {
671
- const s = e / a, r = (e + 1) / a;
672
- t.push(s, 0, s, 0, s, 1, s, 1, r, 1, r, 1);
654
+ const i = e / a, r = (e + 1) / a;
655
+ t.push(i, 0, i, 0, i, 1, i, 1, r, 1, r, 1);
673
656
  }
674
657
  return new Float32Array(t);
675
658
  }(32), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
@@ -677,9 +660,9 @@ class ut extends F {
677
660
  constructor(t, e) {
678
661
  super(t, e, R.ARC, lt);
679
662
  }
680
- Vt(t, e) {
681
- const s = t.x - t.width / 2, r = t.y - t.height / 2, i = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.me(s, r, t.width, t.height, e);
682
- return this.Ce(o, t.x, t.y), o.arcAngles = [i, n], this.de.Vt(o);
663
+ Ut(t, e) {
664
+ const i = t.x - t.width / 2, r = t.y - t.height / 2, s = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.xe(i, r, t.width, t.height, e);
665
+ return this.we(o, t.x, t.y), o.arcAngles = [s, n], this.ge.Ut(o);
683
666
  }
684
667
  }
685
668
  const ft = { vertices: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), vertexCount: 3, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
@@ -687,361 +670,361 @@ class dt extends F {
687
670
  constructor(t, e) {
688
671
  super(t, e, R.TRIANGLE, ft);
689
672
  }
690
- Vt(t, e) {
691
- const s = Math.min(t.x1, t.x2, t.x3), r = Math.max(t.x1, t.x2, t.x3), i = Math.min(t.y1, t.y2, t.y3), n = r - s, o = Math.max(t.y1, t.y2, t.y3) - i, h = this.me(s, i, n, o, e), l = s + 0.5 * n, u = i + o * (1 / 3);
692
- return this.Ce(h, l, u), this.de.Vt(h);
673
+ Ut(t, e) {
674
+ const i = Math.min(t.x1, t.x2, t.x3), r = Math.max(t.x1, t.x2, t.x3), s = Math.min(t.y1, t.y2, t.y3), n = r - i, o = Math.max(t.y1, t.y2, t.y3) - s, h = this.xe(i, s, n, o, e), l = i + 0.5 * n, u = s + o * (1 / 3);
675
+ return this.we(h, l, u), this.ge.Ut(h);
693
676
  }
694
677
  }
695
- function W(a, t, e, s, r) {
696
- const i = 1 - a, n = i * i, o = a * a;
697
- return n * i * t + 3 * n * a * e + 3 * i * o * s + o * a * r;
678
+ function W(a, t, e, i, r) {
679
+ const s = 1 - a, n = s * s, o = a * a;
680
+ return n * s * t + 3 * n * a * e + 3 * s * o * i + o * a * r;
698
681
  }
699
- const gt = { vertices: function(a = 16) {
682
+ const pt = { vertices: function(a = 16) {
700
683
  const t = [];
701
684
  for (let e = 0; e < a; e++) {
702
- const s = e / a, r = (e + 1) / a;
703
- t.push(s, -0.5, s, 0), t.push(r, -0.5, r, 0), t.push(s, 0.5, s, 1), t.push(s, 0.5, s, 1), t.push(r, -0.5, r, 0), t.push(r, 0.5, r, 1);
685
+ const i = e / a, r = (e + 1) / a;
686
+ t.push(i, -0.5, i, 0), t.push(r, -0.5, r, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(r, -0.5, r, 0), t.push(r, 0.5, r, 1);
704
687
  }
705
688
  return new Float32Array(t);
706
689
  }(16), vertexCount: 96, primitiveType: WebGL2RenderingContext.TRIANGLES, stride: 16, attributes: { position: { size: 2, offset: 0 }, texCoord: { size: 2, offset: 8 } } };
707
- class pt extends F {
690
+ class gt extends F {
708
691
  constructor(t, e) {
709
- super(t, e, R.BEZIER_CURVE, gt);
692
+ super(t, e, R.BEZIER_CURVE, pt);
710
693
  }
711
- Vt(t, e) {
712
- const s = e.lineWeight || 1, r = W(0.5, t.x1, t.cp1x, t.cp2x, t.x2), i = W(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotation: e.rotation || 0, lineWeight: s }, o = this.me(0, 0, 1, s, n);
713
- return this.Ce(o, r, i), o.bezierStartPoint = [t.x1, t.y1], o.bezierControlPoint1 = [t.cp1x, t.cp1y], o.bezierControlPoint2 = [t.cp2x, t.cp2y], o.bezierEndPoint = [t.x2, t.y2], this.de.Vt(o);
694
+ Ut(t, e) {
695
+ const i = e.lineWeight || 1, r = W(0.5, t.x1, t.cp1x, t.cp2x, t.x2), s = W(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotation: e.rotation || 0, lineWeight: i }, o = this.xe(0, 0, 1, i, n);
696
+ return this.we(o, r, s), o.bezierStartPoint = [t.x1, t.y1], o.bezierControlPoint1 = [t.cp1x, t.cp1y], o.bezierControlPoint2 = [t.cp2x, t.cp2y], o.bezierEndPoint = [t.x2, t.y2], this.ge.Ut(o);
714
697
  }
715
698
  }
716
699
  class mt {
717
700
  constructor(t) {
718
701
  c(this, "R");
719
- c(this, "ye", null);
720
- c(this, "we", null);
721
702
  c(this, "$e", null);
722
- c(this, "be", /* @__PURE__ */ new Map());
723
- c(this, "Te");
724
- c(this, "ze");
703
+ c(this, "be", null);
704
+ c(this, "Te", null);
705
+ c(this, "ze", /* @__PURE__ */ new Map());
725
706
  c(this, "Re");
726
- this.R = t, this.Re = new Q(), this.Te = new et(t), this.ze = new st(), this.we = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this.we), t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, -1, 1, 0, 1, 1, 1, 1, -1, 1, 0, 1]), t.STATIC_DRAW), this.$e = t.createBuffer(), this.R.enable(this.R.BLEND), this.R.blendEquation(this.R.FUNC_ADD), this.R.blendFunc(this.R.ONE, this.R.ONE_MINUS_SRC_ALPHA), D(this.R, [0, 0, this.R.canvas.width, this.R.canvas.height]);
707
+ c(this, "Me");
708
+ c(this, "Se");
709
+ this.R = t, this.Se = new K(), this.Re = new et(t), this.Me = new it(), this.be = t.createBuffer(), t.bindBuffer(t.ARRAY_BUFFER, this.be), t.bufferData(t.ARRAY_BUFFER, new Float32Array([-1, -1, 0, 0, 1, -1, 1, 0, -1, 1, 0, 1, 1, -1, 1, 0, 1, 1, 1, 1, -1, 1, 0, 1]), t.STATIC_DRAW), this.Te = t.createBuffer(), U(this.R, [0, 0, this.R.canvas.width, this.R.canvas.height]);
727
710
  }
728
- Me(t) {
729
- let e = this.be.get(t);
711
+ Ae(t) {
712
+ let e = this.ze.get(t);
730
713
  if (e) return e;
731
- const s = new rt(this.R);
732
- return e = (0, { [R.RECTANGLE]: () => new nt(this.R, s), [R.LINE]: () => new at(this.R, s), [R.ELLIPSE]: () => new ct(this.R, s), [R.ARC]: () => new ut(this.R, s), [R.TRIANGLE]: () => new dt(this.R, s), [R.BEZIER_CURVE]: () => new pt(this.R, s) }[t])(), this.be.set(t, e), e;
714
+ const i = new rt(this.R);
715
+ return e = (0, { [R.RECTANGLE]: () => new nt(this.R, i), [R.LINE]: () => new at(this.R, i), [R.ELLIPSE]: () => new ct(this.R, i), [R.ARC]: () => new ut(this.R, i), [R.TRIANGLE]: () => new dt(this.R, i), [R.BEZIER_CURVE]: () => new gt(this.R, i) }[t])(), this.ze.set(t, e), e;
733
716
  }
734
- Se(t) {
735
- this.ye !== t && (this.ye = t, t.K());
717
+ Pe(t) {
718
+ this.$e !== t && (this.$e = t, t.K());
736
719
  }
737
- Ae(t, e) {
738
- return new K(this.R, t, e);
720
+ Fe(t, e) {
721
+ return new J(this.R, t, e);
739
722
  }
740
- Pe(t, e, s, r) {
723
+ Ge(t, e, i, r) {
741
724
  var m;
742
- const i = this.R, n = i.canvas.width, o = i.canvas.height, h = t / n * 2 - 1, l = (t + s) / n * 2 - 1, u = 1 - e / o * 2, f = 1 - (e + r) / o * 2, d = new Float32Array([h, f, l, f, h, u, l, f, l, u, h, u]);
743
- i.bindBuffer(i.ARRAY_BUFFER, this.$e), i.bufferData(i.ARRAY_BUFFER, d, i.DYNAMIC_DRAW);
744
- const p = ((m = this.ye) == null ? void 0 : m.rt) || i.getParameter(i.CURRENT_PROGRAM), g = p ? i.getAttribLocation(p, "a_position") : -1;
745
- g !== -1 && (i.enableVertexAttribArray(g), i.vertexAttribPointer(g, 2, i.FLOAT, !1, 8, 0)), i.drawArrays(i.TRIANGLES, 0, 6), g !== -1 && i.disableVertexAttribArray(g);
725
+ const s = this.R, n = s.canvas.width, o = s.canvas.height, h = t / n * 2 - 1, l = (t + i) / n * 2 - 1, u = 1 - e / o * 2, f = 1 - (e + r) / o * 2, d = new Float32Array([h, f, l, f, h, u, l, f, l, u, h, u]);
726
+ s.bindBuffer(s.ARRAY_BUFFER, this.Te), s.bufferData(s.ARRAY_BUFFER, d, s.DYNAMIC_DRAW);
727
+ const g = ((m = this.$e) == null ? void 0 : m.rt) || s.getParameter(s.CURRENT_PROGRAM), p = g ? s.getAttribLocation(g, "a_position") : -1;
728
+ p !== -1 && (s.enableVertexAttribArray(p), s.vertexAttribPointer(p, 2, s.FLOAT, !1, 8, 0)), s.drawArrays(s.TRIANGLES, 0, 6), p !== -1 && s.disableVertexAttribArray(p);
746
729
  }
747
- Fe(t, e, s, r) {
748
- this.ze.qt(t, e, s, r, this.Re);
730
+ De(t, e, i, r) {
731
+ this.Me.Xt(t, e, i, r, this.Se);
749
732
  }
750
- Ge(t, e, s, r) {
751
- this.ze.Nt(t, e, s, r, this.Re.lineWeight, this.Re);
733
+ Ie(t, e, i, r) {
734
+ this.Me.Yt(t, e, i, r, this.Se.lineWeight, this.Se);
752
735
  }
753
- De(t, e, s, r) {
754
- this.ze.Xt(t, e, s, r, this.Re);
736
+ Be(t, e, i, r) {
737
+ this.Me.Qt(t, e, i, r, this.Se);
755
738
  }
756
- Ie(t, e, s, r, i, n) {
757
- this.ze.Qt(t, e, s, r, i, n, this.Re);
739
+ Le(t, e, i, r, s, n) {
740
+ this.Me.Jt(t, e, i, r, s, n, this.Se);
758
741
  }
759
- Be(t, e, s, r, i, n, o, h) {
760
- const l = this.Re.lineWeight;
761
- this.ze.Zt(t, e, s, r, i, n, o, h, l, this.Re);
742
+ Ee(t, e, i, r, s, n, o, h) {
743
+ const l = this.Se.lineWeight;
744
+ this.Me.Kt(t, e, i, r, s, n, o, h, l, this.Se);
762
745
  }
763
- Le(t, e, s = 1, r = {}) {
764
- return new Y(this.R, t, e, s, r);
746
+ We(t, e, i = 1, r = {}) {
747
+ return new j(this.R, t, e, i, r);
765
748
  }
766
- Ee(t, e, s, r, i, n) {
767
- this.ze.Yt(t, e, s, r, i, n, this.Re);
749
+ ke(t, e, i, r, s, n) {
750
+ this.Me.Zt(t, e, i, r, s, n, this.Se);
768
751
  }
769
- We(t, e = t, s = t, r = 255) {
770
- this.Jt(t / 255, e / 255, s / 255, r / 255);
752
+ Ve(t, e = t, i = t, r = 255) {
753
+ this.state.Ft(t, e, i, r), this.te(t / 255, e / 255, i / 255, r / 255);
771
754
  }
772
- Jt(t = 0, e = 0, s = 0, r = 0) {
773
- this.R.clearColor(t, e, s, r), this.R.clear(this.R.COLOR_BUFFER_BIT);
755
+ te(t = 0, e = 0, i = 0, r = 0) {
756
+ this.R.clearColor(t, e, i, r), this.R.clear(this.R.COLOR_BUFFER_BIT);
774
757
  }
775
- ke() {
776
- this.R.viewport(0, 0, this.R.canvas.width, this.R.canvas.height), D(this.R, [0, 0, this.R.canvas.width, this.R.canvas.height]);
758
+ Oe() {
759
+ this.R.viewport(0, 0, this.R.canvas.width, this.R.canvas.height), U(this.R, [0, 0, this.R.canvas.width, this.R.canvas.height]);
777
760
  }
778
761
  get context() {
779
762
  return this.R;
780
763
  }
781
764
  get state() {
782
- return this.Re;
765
+ return this.Se;
783
766
  }
784
- Ve(t) {
785
- const e = L(this.R) ?? this.R.getParameter(this.R.VIEWPORT), s = { shader: t, gl: this.R, viewport: e }, r = /* @__PURE__ */ new Set();
786
- for (const i of this.ze) r.add(i.type);
787
- for (const i of r) this.Me(i);
788
- this.Te.It(s, this.ze, this.be), this.ze.Jt();
767
+ Ue(t) {
768
+ const e = I(this.R) ?? this.R.getParameter(this.R.VIEWPORT), i = { shader: t, gl: this.R, viewport: e }, r = /* @__PURE__ */ new Set();
769
+ for (const s of this.Me) r.add(s.type);
770
+ for (const s of r) this.Ae(s);
771
+ this.Re.Lt(i, this.Me, this.ze), this.Me.te();
789
772
  }
790
773
  U() {
791
- this.R.deleteBuffer(this.we), this.R.deleteBuffer(this.$e), this.ze.Jt();
792
- for (const t of this.be.values()) t.U();
774
+ this.R.deleteBuffer(this.be), this.R.deleteBuffer(this.Te), this.Me.te();
775
+ for (const t of this.ze.values()) t.U();
793
776
  }
794
777
  }
795
- 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) {
796
- const s = [];
797
- for (let r = 0; r < e; r++) s.push(y.readUshort(a, t + 2 * r));
798
- return s;
778
+ const v = { readShort: (a, t) => (v.t.uint16[0] = a[t] << 8 | a[t + 1], v.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
779
+ const i = [];
780
+ for (let r = 0; r < e; r++) i.push(v.readUshort(a, t + 2 * r));
781
+ return i;
799
782
  }, readUint(a, t) {
800
- const e = y.t.uint8;
801
- return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], y.t.uint32[0];
783
+ const e = v.t.uint8;
784
+ return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], v.t.uint32[0];
802
785
  }, readASCII(a, t, e) {
803
- let s = "";
804
- for (let r = 0; r < e; r++) s += String.fromCharCode(a[t + r]);
805
- return s;
786
+ let i = "";
787
+ for (let r = 0; r < e; r++) i += String.fromCharCode(a[t + r]);
788
+ return i;
806
789
  }, t: (() => {
807
790
  const a = new ArrayBuffer(8);
808
791
  return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
809
792
  })() }, Rt = { parseTab(a, t, e) {
810
- const s = { tables: [], ids: {}, off: t };
793
+ const i = { tables: [], ids: {}, off: t };
811
794
  a = new Uint8Array(a.buffer, t, e), t = 0;
812
- const r = y, i = r.readUshort, n = i(a, t += 2);
795
+ const r = v, s = r.readUshort, n = s(a, t += 2);
813
796
  t += 2;
814
797
  const o = [];
815
798
  for (let h = 0; h < n; h++) {
816
- const l = i(a, t), u = i(a, t += 2);
799
+ const l = s(a, t), u = s(a, t += 2);
817
800
  t += 2;
818
801
  const f = r.readUint(a, t);
819
802
  t += 4;
820
803
  const d = `p${l}e${u}`;
821
- let p = o.indexOf(f);
822
- if (p === -1) {
823
- let g;
824
- p = s.tables.length, o.push(f);
825
- const m = i(a, f);
826
- g = m === 4 ? this.parse4(a, f) : m === 12 ? this.parse12(a, f) : { format: m }, s.tables.push(g);
804
+ let g = o.indexOf(f);
805
+ if (g === -1) {
806
+ let p;
807
+ g = i.tables.length, o.push(f);
808
+ const m = s(a, f);
809
+ p = m === 4 ? this.parse4(a, f) : m === 12 ? this.parse12(a, f) : { format: m }, i.tables.push(p);
827
810
  }
828
- s.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), s.ids[d] = p;
811
+ i.ids[d] != null && console.warn("Multiple tables for one platform+encoding: " + d), i.ids[d] = g;
829
812
  }
830
- return s;
813
+ return i;
831
814
  }, parse4(a, t) {
832
- const e = y, s = e.readUshort, r = e.readUshorts, i = t, n = s(a, t += 2);
815
+ const e = v, i = e.readUshort, r = e.readUshorts, s = t, n = i(a, t += 2);
833
816
  t += 2;
834
- const o = s(a, t += 2) >>> 1, h = { format: 4, searchRange: s(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
835
- t += 2, h.entrySelector = s(a, t), t += 2, h.rangeShift = s(a, t), t += 2, h.endCount = r(a, t, o), t += 2 * o, t += 2, h.startCount = r(a, t, o), t += 2 * o;
817
+ const o = i(a, t += 2) >>> 1, h = { format: 4, searchRange: i(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
818
+ t += 2, h.entrySelector = i(a, t), t += 2, h.rangeShift = i(a, t), t += 2, h.endCount = r(a, t, o), t += 2 * o, t += 2, h.startCount = r(a, t, o), t += 2 * o;
836
819
  for (let l = 0; l < o; l++) h.idDelta.push(e.readShort(a, t)), t += 2;
837
- return h.idRangeOffset = r(a, t, o), t += 2 * o, h.glyphIdArray = r(a, t, i + n - t >> 1), h;
820
+ return h.idRangeOffset = r(a, t, o), t += 2 * o, h.glyphIdArray = r(a, t, s + n - t >> 1), h;
838
821
  }, parse12(a, t) {
839
- const e = y.readUint;
822
+ const e = v.readUint;
840
823
  e(a, t += 4), e(a, t += 4);
841
- const s = e(a, t += 4);
824
+ const i = e(a, t += 4);
842
825
  t += 4;
843
- const r = new Uint32Array(3 * s);
844
- for (let i = 0; i < 3 * s; i += 3) r[i] = e(a, t + (i << 2)), r[i + 1] = e(a, t + (i << 2) + 4), r[i + 2] = e(a, t + (i << 2) + 8);
826
+ const r = new Uint32Array(3 * i);
827
+ for (let s = 0; s < 3 * i; s += 3) r[s] = e(a, t + (s << 2)), r[s + 1] = e(a, t + (s << 2) + 4), r[s + 2] = e(a, t + (s << 2) + 8);
845
828
  return { format: 12, groups: r };
846
829
  } }, xt = { parseTab(a, t, e) {
847
- const s = y;
830
+ const i = v;
848
831
  t += 18;
849
- const r = s.readUshort(a, t);
832
+ const r = i.readUshort(a, t);
850
833
  t += 2, t += 16;
851
- const i = s.readShort(a, t);
834
+ const s = i.readShort(a, t);
852
835
  t += 2;
853
- const n = s.readShort(a, t);
836
+ const n = i.readShort(a, t);
854
837
  t += 2;
855
- const o = s.readShort(a, t);
838
+ const o = i.readShort(a, t);
856
839
  t += 2;
857
- const h = s.readShort(a, t);
858
- return t += 2, t += 6, { unitsPerEm: r, xMin: i, yMin: n, xMax: o, yMax: h, indexToLocFormat: s.readShort(a, t) };
859
- } }, Ct = { parseTab(a, t, e) {
860
- const s = y;
840
+ const h = i.readShort(a, t);
841
+ return t += 2, t += 6, { unitsPerEm: r, xMin: s, yMin: n, xMax: o, yMax: h, indexToLocFormat: i.readShort(a, t) };
842
+ } }, yt = { parseTab(a, t, e) {
843
+ const i = v;
861
844
  t += 4;
862
- const r = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], i = {};
845
+ const r = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], s = {};
863
846
  for (let n = 0; n < r.length; n++) {
864
- const o = r[n], h = o === "advanceWidthMax" || o === "numberOfHMetrics" ? s.readUshort : s.readShort;
865
- i[o] = h(a, t + 2 * n);
847
+ const o = r[n], h = o === "advanceWidthMax" || o === "numberOfHMetrics" ? i.readUshort : i.readShort;
848
+ s[o] = h(a, t + 2 * n);
866
849
  }
867
- return i;
868
- } }, yt = { parseTab(a, t, e, s) {
869
- const r = y, i = [], n = [], o = s.maxp.numGlyphs, h = s.hhea.numberOfHMetrics;
850
+ return s;
851
+ } }, vt = { parseTab(a, t, e, i) {
852
+ const r = v, s = [], n = [], o = i.maxp.numGlyphs, h = i.hhea.numberOfHMetrics;
870
853
  let l = 0, u = 0, f = 0;
871
- for (; f < h; ) l = r.readUshort(a, t + (f << 2)), u = r.readShort(a, t + (f << 2) + 2), i.push(l), n.push(u), f++;
872
- for (; f < o; ) i.push(l), n.push(u), f++;
873
- return { aWidth: i, lsBearing: n };
874
- } }, G = { cmap: Rt, head: xt, hhea: Ct, maxp: { parseTab(a, t, e) {
875
- const s = y;
876
- return s.readUint(a, t), t += 4, { numGlyphs: s.readUshort(a, t) };
877
- } }, hmtx: yt, loca: { parseTab(a, t, e, s) {
878
- const r = y, i = [], n = s.head.indexToLocFormat, o = s.maxp.numGlyphs + 1;
879
- if (n === 0) for (let h = 0; h < o; h++) i.push(r.readUshort(a, t + (h << 1)) << 1);
880
- else if (n === 1) for (let h = 0; h < o; h++) i.push(r.readUint(a, t + (h << 2)));
881
- return i;
882
- } }, glyf: { parseTab(a, t, e, s) {
883
- const r = [], i = s.maxp.numGlyphs;
884
- for (let n = 0; n < i; n++) r.push(null);
854
+ for (; f < h; ) l = r.readUshort(a, t + (f << 2)), u = r.readShort(a, t + (f << 2) + 2), s.push(l), n.push(u), f++;
855
+ for (; f < o; ) s.push(l), n.push(u), f++;
856
+ return { aWidth: s, lsBearing: n };
857
+ } }, O = { cmap: Rt, head: xt, hhea: yt, maxp: { parseTab(a, t, e) {
858
+ const i = v;
859
+ return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
860
+ } }, hmtx: vt, loca: { parseTab(a, t, e, i) {
861
+ const r = v, s = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
862
+ if (n === 0) for (let h = 0; h < o; h++) s.push(r.readUshort(a, t + (h << 1)) << 1);
863
+ else if (n === 1) for (let h = 0; h < o; h++) s.push(r.readUint(a, t + (h << 2)));
864
+ return s;
865
+ } }, glyf: { parseTab(a, t, e, i) {
866
+ const r = [], s = i.maxp.numGlyphs;
867
+ for (let n = 0; n < s; n++) r.push(null);
885
868
  return r;
886
- }, Oe(a, t) {
887
- const e = y, s = a.Ue, r = a.loca;
869
+ }, je(a, t) {
870
+ const e = v, i = a.He, r = a.loca;
888
871
  if (r[t] === r[t + 1]) return null;
889
- const i = E.findTable(s, "glyf", a.je);
890
- if (!i) return null;
891
- let n = i[0] + r[t];
872
+ const s = E.findTable(i, "glyf", a.qe);
873
+ if (!s) return null;
874
+ let n = s[0] + r[t];
892
875
  const o = {};
893
- if (o.noc = e.readShort(s, n), n += 2, o.xMin = e.readShort(s, n), n += 2, o.yMin = e.readShort(s, n), n += 2, o.xMax = e.readShort(s, n), n += 2, o.yMax = e.readShort(s, n), n += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
876
+ if (o.noc = e.readShort(i, n), n += 2, o.xMin = e.readShort(i, n), n += 2, o.yMin = e.readShort(i, n), n += 2, o.xMax = e.readShort(i, n), n += 2, o.yMax = e.readShort(i, n), n += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
894
877
  if (o.noc > 0) {
895
878
  o.endPts = [];
896
- for (let d = 0; d < o.noc; d++) o.endPts.push(e.readUshort(s, n)), n += 2;
897
- const h = e.readUshort(s, n);
898
- if (n += 2, s.length - n < h) return null;
879
+ for (let d = 0; d < o.noc; d++) o.endPts.push(e.readUshort(i, n)), n += 2;
880
+ const h = e.readUshort(i, n);
881
+ if (n += 2, i.length - n < h) return null;
899
882
  n += h;
900
883
  const l = o.endPts[o.noc - 1] + 1;
901
884
  o.flags = [];
902
885
  for (let d = 0; d < l; d++) {
903
- const p = s[n];
904
- if (n++, o.flags.push(p), 8 & p) {
905
- const g = s[n];
886
+ const g = i[n];
887
+ if (n++, o.flags.push(g), 8 & g) {
888
+ const p = i[n];
906
889
  n++;
907
- for (let m = 0; m < g; m++) o.flags.push(p), d++;
890
+ for (let m = 0; m < p; m++) o.flags.push(g), d++;
908
891
  }
909
892
  }
910
893
  o.xs = [];
911
894
  for (let d = 0; d < l; d++) {
912
- const p = o.flags[d], g = !!(16 & p);
913
- 2 & p ? (o.xs.push(g ? s[n] : -s[n]), n++) : g ? o.xs.push(0) : (o.xs.push(e.readShort(s, n)), n += 2);
895
+ const g = o.flags[d], p = !!(16 & g);
896
+ 2 & g ? (o.xs.push(p ? i[n] : -i[n]), n++) : p ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
914
897
  }
915
898
  o.ys = [];
916
899
  for (let d = 0; d < l; d++) {
917
- const p = o.flags[d], g = !!(32 & p);
918
- 4 & p ? (o.ys.push(g ? s[n] : -s[n]), n++) : g ? o.ys.push(0) : (o.ys.push(e.readShort(s, n)), n += 2);
900
+ const g = o.flags[d], p = !!(32 & g);
901
+ 4 & g ? (o.ys.push(p ? i[n] : -i[n]), n++) : p ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
919
902
  }
920
903
  let u = 0, f = 0;
921
904
  for (let d = 0; d < l; d++) u += o.xs[d], f += o.ys[d], o.xs[d] = u, o.ys[d] = f;
922
905
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
923
906
  return o;
924
- } } }, E = { parse: (a) => [((t, e, s, r) => {
925
- const i = G, n = { Ue: t, He: e, je: s };
926
- for (const o in i) {
927
- const h = o, l = E.findTable(t, h, s);
907
+ } } }, E = { parse: (a) => [((t, e, i, r) => {
908
+ const s = O, n = { He: t, Ne: e, qe: i };
909
+ for (const o in s) {
910
+ const h = o, l = E.findTable(t, h, i);
928
911
  if (l) {
929
912
  const [u, f] = l;
930
913
  let d = r[u];
931
- d == null && (d = i[h].parseTab(t, u, f, n), r[u] = d), n[h] = d;
914
+ d == null && (d = s[h].parseTab(t, u, f, n), r[u] = d), n[h] = d;
932
915
  }
933
916
  }
934
917
  return n;
935
918
  })(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
936
- const s = y, r = s.readUshort(a, e + 4);
937
- let i = e + 12;
919
+ const i = v, r = i.readUshort(a, e + 4);
920
+ let s = e + 12;
938
921
  for (let n = 0; n < r; n++) {
939
- const o = s.readASCII(a, i, 4);
940
- s.readUint(a, i + 4);
941
- const h = s.readUint(a, i + 8), l = s.readUint(a, i + 12);
922
+ const o = i.readASCII(a, s, 4);
923
+ i.readUint(a, s + 4);
924
+ const h = i.readUint(a, s + 8), l = i.readUint(a, s + 12);
942
925
  if (o === t) return [h, l];
943
- i += 16;
926
+ s += 16;
944
927
  }
945
928
  return null;
946
- }, T: G, B: y };
947
- class U {
929
+ }, T: O, B: v };
930
+ class L {
948
931
  constructor() {
949
- c(this, "qe", /* @__PURE__ */ new Map());
950
- c(this, "Ne", /* @__PURE__ */ new Map());
932
+ c(this, "Xe", /* @__PURE__ */ new Map());
933
+ c(this, "Ye", /* @__PURE__ */ new Map());
951
934
  }
952
- Xe(t, e) {
953
- const s = `${this.Ye(t)}_${e}`;
954
- if (this.qe.has(s)) return this.qe.get(s);
935
+ Qe(t, e) {
936
+ const i = `${this.Ze(t)}_${e}`;
937
+ if (this.Xe.has(i)) return this.Xe.get(i);
955
938
  const r = t.cmap;
956
- if (!r || !r.tables) return this.qe.set(s, 0), 0;
957
- let i = 0;
958
- for (const n of r.tables) if (n.format === 4 ? i = this.Qe(e, n) : n.format === 12 && (i = this.Ze(e, n)), i > 0) break;
959
- return this.qe.set(s, i), i;
939
+ if (!r || !r.tables) return this.Xe.set(i, 0), 0;
940
+ let s = 0;
941
+ for (const n of r.tables) if (n.format === 4 ? s = this.Je(e, n) : n.format === 12 && (s = this.Ke(e, n)), s > 0) break;
942
+ return this.Xe.set(i, s), s;
960
943
  }
961
- Je(t, e) {
962
- const s = e.codePointAt(0);
963
- return s === void 0 ? 0 : this.Xe(t, s);
944
+ ts(t, e) {
945
+ const i = e.codePointAt(0);
946
+ return i === void 0 ? 0 : this.Qe(t, i);
964
947
  }
965
- Ke(t, e) {
966
- const s = t.hmtx;
967
- return s && s.aWidth && s.aWidth.length !== 0 ? e < s.aWidth.length ? s.aWidth[e] : s.aWidth[s.aWidth.length - 1] : 0;
948
+ es(t, e) {
949
+ const i = t.hmtx;
950
+ return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
968
951
  }
969
- ts(t, e) {
970
- const s = e / t.head.unitsPerEm, r = t.hhea.ascender * s, i = t.hhea.descender * s, n = t.hhea.lineGap * s;
971
- return { ascender: r, descender: i, lineGap: n, lineHeight: r - i + n, unitsPerEm: t.head.unitsPerEm, scale: s };
952
+ ss(t, e) {
953
+ const i = e / t.head.unitsPerEm, r = t.hhea.ascender * i, s = t.hhea.descender * i, n = t.hhea.lineGap * i;
954
+ return { ascender: r, descender: s, lineGap: n, lineHeight: r - s + n, unitsPerEm: t.head.unitsPerEm, scale: i };
972
955
  }
973
- es() {
974
- this.qe.clear(), this.Ne.clear();
956
+ rs() {
957
+ this.Xe.clear(), this.Ye.clear();
975
958
  }
976
- Ye(t) {
977
- return `${t.je}_${t.Ue.length}`;
959
+ Ze(t) {
960
+ return `${t.qe}_${t.He.length}`;
978
961
  }
979
- Qe(t, e) {
980
- const s = e.endCount.length;
962
+ Je(t, e) {
963
+ const i = e.endCount.length;
981
964
  let r = -1;
982
- for (let i = 0; i < s; i++) if (t <= e.endCount[i]) {
983
- r = i;
965
+ for (let s = 0; s < i; s++) if (t <= e.endCount[s]) {
966
+ r = s;
984
967
  break;
985
968
  }
986
969
  if (r === -1 || t < e.startCount[r]) return 0;
987
970
  if (e.idRangeOffset[r] === 0) return t + e.idDelta[r] & 65535;
988
971
  {
989
- const i = e.idRangeOffset[r] / 2 + (t - e.startCount[r]) - (s - r);
990
- if (i >= 0 && i < e.glyphIdArray.length) {
991
- const n = e.glyphIdArray[i];
972
+ const s = e.idRangeOffset[r] / 2 + (t - e.startCount[r]) - (i - r);
973
+ if (s >= 0 && s < e.glyphIdArray.length) {
974
+ const n = e.glyphIdArray[s];
992
975
  return n === 0 ? 0 : n + e.idDelta[r] & 65535;
993
976
  }
994
977
  }
995
978
  return 0;
996
979
  }
997
- Ze(t, e) {
998
- const s = e.groups.length / 3;
999
- for (let r = 0; r < s; r++) {
1000
- const i = e.groups[3 * r], n = e.groups[3 * r + 1], o = e.groups[3 * r + 2];
1001
- if (t >= i && t <= n) return o + (t - i);
980
+ Ke(t, e) {
981
+ const i = e.groups.length / 3;
982
+ for (let r = 0; r < i; r++) {
983
+ const s = e.groups[3 * r], n = e.groups[3 * r + 1], o = e.groups[3 * r + 2];
984
+ if (t >= s && t <= n) return o + (t - s);
1002
985
  }
1003
986
  return 0;
1004
987
  }
1005
988
  }
1006
- class vt {
989
+ class Ct {
1007
990
  constructor(t) {
1008
- c(this, "ss");
1009
- this.ss = t;
991
+ c(this, "ns");
992
+ this.ns = t;
1010
993
  }
1011
- rs(t) {
1012
- var s;
994
+ hs(t) {
995
+ var i;
1013
996
  const e = [];
1014
- return (s = t.cmap) != null && s.tables ? (t.cmap.tables.forEach((r) => {
997
+ return (i = t.cmap) != null && i.tables ? (t.cmap.tables.forEach((r) => {
1015
998
  if (r.format === 4) {
1016
- const i = this.ns(r);
1017
- e.push(...i);
999
+ const s = this.cs(r);
1000
+ e.push(...s);
1018
1001
  } else if (r.format === 12) {
1019
- const i = this.hs(r);
1020
- e.push(...i);
1002
+ const s = this.ls(r);
1003
+ e.push(...s);
1021
1004
  }
1022
1005
  }), [...new Set(e)]) : [];
1023
1006
  }
1024
- cs(t, e) {
1025
- return this.ss.Je(t, e) > 0;
1007
+ us(t, e) {
1008
+ return this.ns.ts(t, e) > 0;
1026
1009
  }
1027
- ls(t, e) {
1028
- for (const s of e) if (!this.cs(t, s)) return !1;
1010
+ fs(t, e) {
1011
+ for (const i of e) if (!this.us(t, i)) return !1;
1029
1012
  return !0;
1030
1013
  }
1031
- us(t, e) {
1032
- return e.filter((s) => this.cs(t, s));
1014
+ ds(t, e) {
1015
+ return e.filter((i) => this.us(t, i));
1033
1016
  }
1034
- fs(t) {
1035
- return t.filter((e) => this.ds(e));
1017
+ ps(t) {
1018
+ return t.filter((e) => this.gs(e));
1036
1019
  }
1037
- ns(t) {
1020
+ cs(t) {
1038
1021
  const e = [];
1039
1022
  if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
1040
- for (let s = 0; s < t.startCount.length; s++) {
1041
- const r = t.startCount[s], i = t.endCount[s];
1042
- if (r !== 65535 || i !== 65535) {
1043
- for (let n = r; n <= i; n++)
1044
- if (this.ps(t, n, s) > 0) try {
1023
+ for (let i = 0; i < t.startCount.length; i++) {
1024
+ const r = t.startCount[i], s = t.endCount[i];
1025
+ if (r !== 65535 || s !== 65535) {
1026
+ for (let n = r; n <= s; n++)
1027
+ if (this._s(t, n, i) > 0) try {
1045
1028
  const o = String.fromCodePoint(n);
1046
1029
  e.push(o);
1047
1030
  } catch {
@@ -1050,12 +1033,12 @@ class vt {
1050
1033
  }
1051
1034
  return e;
1052
1035
  }
1053
- hs(t) {
1036
+ ls(t) {
1054
1037
  const e = [];
1055
1038
  if (!t.groups) return e;
1056
- for (let s = 0; s < t.groups.length; s += 3) {
1057
- const r = t.groups[s], i = t.groups[s + 1], n = t.groups[s + 2];
1058
- for (let o = r; o <= i; o++)
1039
+ for (let i = 0; i < t.groups.length; i += 3) {
1040
+ const r = t.groups[i], s = t.groups[i + 1], n = t.groups[i + 2];
1041
+ for (let o = r; o <= s; o++)
1059
1042
  if (n + (o - r) > 0) try {
1060
1043
  const h = String.fromCodePoint(o);
1061
1044
  e.push(h);
@@ -1064,288 +1047,288 @@ class vt {
1064
1047
  }
1065
1048
  return e;
1066
1049
  }
1067
- ps(t, e, s) {
1068
- if (t.idRangeOffset[s] === 0) return e + t.idDelta[s] & 65535;
1050
+ _s(t, e, i) {
1051
+ if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
1069
1052
  {
1070
- const r = t.idRangeOffset[s] / 2 + (e - t.startCount[s]) - (t.startCount.length - s);
1053
+ const r = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
1071
1054
  if (r >= 0 && t.glyphIdArray && r < t.glyphIdArray.length) {
1072
- const i = t.glyphIdArray[r];
1073
- if (i !== 0) return i + t.idDelta[s] & 65535;
1055
+ const s = t.glyphIdArray[r];
1056
+ if (s !== 0) return s + t.idDelta[i] & 65535;
1074
1057
  }
1075
1058
  }
1076
1059
  return 0;
1077
1060
  }
1078
- ds(t) {
1061
+ gs(t) {
1079
1062
  const e = t.codePointAt(0) || 0;
1080
1063
  return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
1081
1064
  }
1082
1065
  }
1083
- class Tt {
1066
+ class wt {
1084
1067
  constructor() {
1085
- c(this, "gs");
1086
- const t = new U();
1087
- this.gs = new vt(t);
1068
+ c(this, "vs");
1069
+ const t = new L();
1070
+ this.vs = new Ct(t);
1088
1071
  }
1089
1072
  extractCharacters(t) {
1090
- return this.gs.rs(t);
1073
+ return this.vs.hs(t);
1091
1074
  }
1092
1075
  filterProblematicCharacters(t) {
1093
- return this.gs.fs(t);
1076
+ return this.vs.ps(t);
1094
1077
  }
1095
1078
  characterExists(t, e) {
1096
- return this.gs.cs(t, e);
1079
+ return this.vs.us(t, e);
1097
1080
  }
1098
1081
  allCharactersExist(t, e) {
1099
- return this.gs.ls(t, e);
1082
+ return this.vs.fs(t, e);
1100
1083
  }
1101
1084
  }
1102
- class bt {
1085
+ class Tt {
1103
1086
  constructor(t) {
1104
- c(this, "_s");
1105
- c(this, "vs");
1106
1087
  c(this, "Cs");
1107
1088
  c(this, "ws");
1108
- this.Cs = t, this.ws = new U(), this._s = document.createElement("canvas"), this.vs = this._s.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1089
+ c(this, "$s");
1090
+ c(this, "bs");
1091
+ this.$s = t, this.bs = new L(), this.Cs = document.createElement("canvas"), this.ws = this.Cs.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1109
1092
  }
1110
- createTextureAtlas(t, e, s, r) {
1111
- const i = t.length, n = Math.ceil(Math.sqrt(i)), o = Math.ceil(i / n), h = e.width * n, l = e.height * o, u = typeof r == "object" ? r : null;
1112
- this.$s(h, l), this.bs(t, e, n, s, u);
1113
- const f = this.Cs.Le(h, l, 1, { filter: "nearest" });
1114
- return f.I(this._s), { framebuffer: f, columns: n, rows: o };
1093
+ createTextureAtlas(t, e, i, r) {
1094
+ const s = t.length, n = Math.ceil(Math.sqrt(s)), o = Math.ceil(s / n), h = e.width * n, l = e.height * o, u = typeof r == "object" ? r : null;
1095
+ this.Ts(h, l), this.zs(t, e, n, i, u);
1096
+ const f = this.$s.We(h, l, 1, { filter: "nearest" });
1097
+ return f.I(this.Cs), { framebuffer: f, columns: n, rows: o };
1115
1098
  }
1116
- $s(t, e) {
1117
- this._s.width = t, this._s.height = e, this._s.style.width = t + "px", this._s.style.height = t + "px", this.vs.imageSmoothingEnabled = !1, this._s.style.imageRendering = "pixelated", this.vs.fillStyle = "black", this.vs.fillRect(0, 0, t, e), this.vs.textBaseline = "top", this.vs.textAlign = "left", this.vs.fillStyle = "white";
1099
+ Ts(t, e) {
1100
+ this.Cs.width = t, this.Cs.height = e, this.Cs.style.width = t + "px", this.Cs.style.height = t + "px", this.ws.imageSmoothingEnabled = !1, this.Cs.style.imageRendering = "pixelated", this.ws.fillStyle = "black", this.ws.fillRect(0, 0, t, e), this.ws.textBaseline = "top", this.ws.textAlign = "left", this.ws.fillStyle = "white";
1118
1101
  }
1119
- bs(t, e, s, r, i) {
1120
- const n = r / i.head.unitsPerEm;
1102
+ zs(t, e, i, r, s) {
1103
+ const n = r / s.head.unitsPerEm;
1121
1104
  for (let o = 0; o < t.length; o++) {
1122
- const h = o % s, l = Math.floor(o / s), u = t[o].character, f = this.Ts(i, u);
1105
+ const h = o % i, l = Math.floor(o / i), u = t[o].character, f = this.Rs(s, u);
1123
1106
  if (!f) continue;
1124
- const d = u.codePointAt(0) || 0, p = this.ws.Xe(i, d), g = this.zs(i, p) * n, m = h * e.width, T = l * e.height, v = m + 0.5 * e.width, b = T + 0.5 * e.height, _ = Math.round(v - 0.5 * e.width), S = Math.round(b - 0.5 * r), j = _ + 0.5 * (e.width - g), H = S + i.hhea.ascender * n;
1125
- this.Rs(f, j, H, n);
1107
+ const d = u.codePointAt(0) || 0, g = this.bs.Qe(s, d), p = this.Ms(s, g) * n, m = h * e.width, w = l * e.height, C = m + 0.5 * e.width, T = w + 0.5 * e.height, b = Math.round(C - 0.5 * e.width), P = Math.round(T - 0.5 * r), Y = b + 0.5 * (e.width - p), H = P + s.hhea.ascender * n;
1108
+ this.Ss(f, Y, H, n);
1126
1109
  }
1127
1110
  }
1128
- Ts(t, e) {
1129
- const s = e.codePointAt(0) || 0, r = this.ws.Xe(t, s);
1111
+ Rs(t, e) {
1112
+ const i = e.codePointAt(0) || 0, r = this.bs.Qe(t, i);
1130
1113
  if (r === 0) return null;
1131
1114
  if (t.glyf && t.glyf[r] !== null) return t.glyf[r];
1132
1115
  if (E && E.T && E.T.glyf) {
1133
- const i = E.T.glyf.Oe(t, r);
1134
- return t.glyf && i && (t.glyf[r] = i), i;
1116
+ const s = E.T.glyf.je(t, r);
1117
+ return t.glyf && s && (t.glyf[r] = s), s;
1135
1118
  }
1136
1119
  return null;
1137
1120
  }
1138
- zs(t, e) {
1139
- const s = t.hmtx;
1140
- return s && s.aWidth ? e < s.aWidth.length ? s.aWidth[e] : s.aWidth[s.aWidth.length - 1] : 0;
1121
+ Ms(t, e) {
1122
+ const i = t.hmtx;
1123
+ return i && i.aWidth ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1141
1124
  }
1142
- Rs(t, e, s, r) {
1125
+ Ss(t, e, i, r) {
1143
1126
  if (!t || !t.xs || t.noc === 0) return;
1144
- const { xs: i, ys: n, endPts: o, flags: h } = t;
1145
- if (!(i && n && o && h)) return;
1146
- this.vs.beginPath();
1127
+ const { xs: s, ys: n, endPts: o, flags: h } = t;
1128
+ if (!(s && n && o && h)) return;
1129
+ this.ws.beginPath();
1147
1130
  let l = 0;
1148
1131
  for (let u = 0; u < o.length; u++) {
1149
1132
  const f = o[u];
1150
1133
  if (!(f < l)) {
1151
1134
  if (f >= l) {
1152
- const d = e + i[l] * r, p = s - n[l] * r;
1153
- this.vs.moveTo(d, p);
1154
- let g = l + 1;
1155
- for (; g <= f; )
1156
- if (1 & h[g]) {
1157
- const m = e + i[g] * r, T = s - n[g] * r;
1158
- this.vs.lineTo(m, T), g++;
1135
+ const d = e + s[l] * r, g = i - n[l] * r;
1136
+ this.ws.moveTo(d, g);
1137
+ let p = l + 1;
1138
+ for (; p <= f; )
1139
+ if (1 & h[p]) {
1140
+ const m = e + s[p] * r, w = i - n[p] * r;
1141
+ this.ws.lineTo(m, w), p++;
1159
1142
  } else {
1160
- const m = e + i[g] * r, T = s - n[g] * r;
1161
- let v = g + 1 > f ? l : g + 1;
1162
- if (1 & h[v]) {
1163
- const b = e + i[v] * r, _ = s - n[v] * r;
1164
- this.vs.quadraticCurveTo(m, T, b, _), g = v + 1;
1143
+ const m = e + s[p] * r, w = i - n[p] * r;
1144
+ let C = p + 1 > f ? l : p + 1;
1145
+ if (1 & h[C]) {
1146
+ const T = e + s[C] * r, b = i - n[C] * r;
1147
+ this.ws.quadraticCurveTo(m, w, T, b), p = C + 1;
1165
1148
  } else {
1166
- const b = (m + (e + i[v] * r)) / 2, _ = (T + (s - n[v] * r)) / 2;
1167
- this.vs.quadraticCurveTo(m, T, b, _), g = v;
1149
+ const T = (m + (e + s[C] * r)) / 2, b = (w + (i - n[C] * r)) / 2;
1150
+ this.ws.quadraticCurveTo(m, w, T, b), p = C;
1168
1151
  }
1169
1152
  }
1170
- this.vs.closePath();
1153
+ this.ws.closePath();
1171
1154
  }
1172
1155
  l = f + 1;
1173
1156
  }
1174
1157
  }
1175
- this.vs.fill();
1158
+ this.ws.fill();
1176
1159
  }
1177
1160
  }
1178
- class _t {
1161
+ class bt {
1179
1162
  constructor() {
1180
- c(this, "ss");
1181
- this.ss = new U();
1163
+ c(this, "ns");
1164
+ this.ns = new L();
1182
1165
  }
1183
- calculateMaxGlyphDimensions(t, e, s) {
1166
+ calculateMaxGlyphDimensions(t, e, i) {
1184
1167
  let r = 0;
1185
- const i = this.ss.ts(s, e), n = i.lineHeight;
1168
+ const s = this.ns.ss(i, e), n = s.lineHeight;
1186
1169
  for (const o of t) {
1187
- const h = this.ss.Je(s, o);
1170
+ const h = this.ns.ts(i, o);
1188
1171
  if (h === 0) continue;
1189
- const l = this.ss.Ke(s, h) * i.scale;
1172
+ const l = this.ns.es(i, h) * s.scale;
1190
1173
  r = Math.max(r, l);
1191
1174
  }
1192
1175
  return { width: Math.ceil(r), height: Math.ceil(n) };
1193
1176
  }
1194
- getCharacterAdvanceWidth(t, e, s) {
1195
- const r = this.ss.ts(s, e), i = this.ss.Je(s, t);
1196
- return this.ss.Ke(s, i) * r.scale;
1177
+ getCharacterAdvanceWidth(t, e, i) {
1178
+ const r = this.ns.ss(i, e), s = this.ns.ts(i, t);
1179
+ return this.ns.es(i, s) * r.scale;
1197
1180
  }
1198
1181
  getFontMetrics(t, e) {
1199
- return this.ss.ts(e, t);
1182
+ return this.ns.ss(e, t);
1200
1183
  }
1201
- es() {
1202
- this.ss.es();
1184
+ rs() {
1185
+ this.ns.rs();
1203
1186
  }
1204
1187
  }
1205
1188
  class Et {
1206
1189
  constructor() {
1207
- c(this, "ws");
1208
- this.ws = new U();
1190
+ c(this, "bs");
1191
+ this.bs = new L();
1209
1192
  }
1210
1193
  createCharacterObjects(t, e) {
1211
- return t.map((s, r) => {
1212
- const i = s.codePointAt(0) || 0, n = this.Ms(r);
1194
+ return t.map((i, r) => {
1195
+ const s = i.codePointAt(0) || 0, n = this.As(r);
1213
1196
  let o = 0;
1214
1197
  if (e.hmtx && e.hmtx.aWidth) {
1215
- const h = this.ws.Xe(e, i);
1198
+ const h = this.bs.Qe(e, s);
1216
1199
  h > 0 && e.hmtx.aWidth[h] !== void 0 && (o = e.hmtx.aWidth[h]);
1217
1200
  }
1218
- return { character: s, unicode: i, color: n, advanceWidth: o };
1201
+ return { character: i, unicode: s, color: n, advanceWidth: o };
1219
1202
  });
1220
1203
  }
1221
- Ms(t) {
1204
+ As(t) {
1222
1205
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1223
1206
  }
1224
- Ss(t, e) {
1225
- if (!I._(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1226
- const s = e.find((r) => r.character === t);
1227
- return s ? s.color : [0, 0, 0];
1207
+ Ps(t, e) {
1208
+ if (!M._(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1209
+ const i = e.find((r) => r.character === t);
1210
+ return i ? i.color : [0, 0, 0];
1228
1211
  }
1229
- As(t, e) {
1230
- return I._(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((s) => this.Ss(s, e) || [0, 0, 0]) : [[0, 0, 0]];
1212
+ Fs(t, e) {
1213
+ return M._(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.Ps(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1231
1214
  }
1232
1215
  }
1233
1216
  class At {
1234
1217
  constructor(t, e = 16) {
1235
- c(this, "Ps");
1236
- c(this, "Fs", []);
1237
1218
  c(this, "Gs");
1238
- c(this, "Ds", 16);
1239
- c(this, "Is", 0);
1240
- c(this, "Bs", 0);
1241
- c(this, "Ls", { width: 0, height: 0 });
1242
- c(this, "Es");
1243
- c(this, "Ws");
1219
+ c(this, "Ds", []);
1220
+ c(this, "Is");
1221
+ c(this, "Bs", 16);
1222
+ c(this, "Ls", 0);
1223
+ c(this, "Es", 0);
1224
+ c(this, "Ws", { width: 0, height: 0 });
1244
1225
  c(this, "ks");
1245
1226
  c(this, "Vs");
1246
1227
  c(this, "Os");
1247
- this.Ds = e, this.Ws = new Tt(), this.ks = new bt(t), this.Vs = new _t(), this.Os = new Et();
1228
+ c(this, "Us");
1229
+ c(this, "js");
1230
+ this.Bs = e, this.Vs = new wt(), this.Os = new Tt(t), this.Us = new bt(), this.js = new Et();
1248
1231
  }
1249
- async Us(t) {
1232
+ async Hs(t) {
1250
1233
  let e;
1251
- if (!t) throw new C("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1234
+ if (!t) throw new y("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1252
1235
  {
1253
- const s = await fetch(t);
1254
- if (!s.ok) throw new C(`Failed to load font file: ${s.status} ${s.statusText}`);
1255
- e = await s.arrayBuffer();
1236
+ const i = await fetch(t);
1237
+ if (!i.ok) throw new y(`Failed to load font file: ${i.status} ${i.statusText}`);
1238
+ e = await i.arrayBuffer();
1256
1239
  }
1257
- await this.js(e), this.Ps = E.parse(e)[0], await this.Hs();
1240
+ await this.qs(e), this.Gs = E.parse(e)[0], await this.Ns();
1258
1241
  }
1259
- qs(t) {
1260
- if (t === void 0) return this.Ds;
1261
- this.Ds = t, this.Ls = this.Vs.calculateMaxGlyphDimensions(this.Fs.map((s) => s.character), this.Ds, this.Ps);
1262
- const e = this.ks.createTextureAtlas(this.Fs, this.Ls, this.Ds, this.Ps);
1263
- this.Gs = e.framebuffer, this.Is = e.columns, this.Bs = e.rows;
1242
+ Xs(t) {
1243
+ if (t === void 0) return this.Bs;
1244
+ this.Bs = t, this.Ws = this.Us.calculateMaxGlyphDimensions(this.Ds.map((i) => i.character), this.Bs, this.Gs);
1245
+ const e = this.Os.createTextureAtlas(this.Ds, this.Ws, this.Bs, this.Gs);
1246
+ this.Is = e.framebuffer, this.Ls = e.columns, this.Es = e.rows;
1264
1247
  }
1265
- async Ns(t) {
1248
+ async Ys(t) {
1266
1249
  try {
1267
1250
  const e = await fetch(t);
1268
- if (!e.ok) throw new C(`Failed to load font file: ${e.status} ${e.statusText}`);
1269
- const s = await e.arrayBuffer();
1270
- await this.js(s);
1271
- const r = E.parse(s);
1251
+ if (!e.ok) throw new y(`Failed to load font file: ${e.status} ${e.statusText}`);
1252
+ const i = await e.arrayBuffer();
1253
+ await this.qs(i);
1254
+ const r = E.parse(i);
1272
1255
  if (!r || r.length === 0) throw Error("Failed to parse font file");
1273
- this.Ps = r[0], await this.Hs();
1256
+ this.Gs = r[0], await this.Ns();
1274
1257
  } catch (e) {
1275
- throw new C("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1258
+ throw new y("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1276
1259
  }
1277
1260
  }
1278
- async js(t) {
1261
+ async qs(t) {
1279
1262
  const e = Date.now();
1280
- this.Es = new FontFace("CustomFont_" + e, t), await this.Es.load(), document.fonts.add(this.Es);
1263
+ this.ks = new FontFace("CustomFont_" + e, t), await this.ks.load(), document.fonts.add(this.ks);
1281
1264
  }
1282
- async Hs() {
1283
- const t = this.Ws.extractCharacters(this.Ps), e = this.Ws.filterProblematicCharacters(t);
1284
- this.Fs = this.Os.createCharacterObjects(e, this.Ps), this.Ls = this.Vs.calculateMaxGlyphDimensions(e, this.Ds, this.Ps);
1285
- const s = this.ks.createTextureAtlas(this.Fs, this.Ls, this.Ds, this.Ps);
1286
- this.Gs = s.framebuffer, this.Is = s.columns, this.Bs = s.rows;
1265
+ async Ns() {
1266
+ const t = this.Vs.extractCharacters(this.Gs), e = this.Vs.filterProblematicCharacters(t);
1267
+ this.Ds = this.js.createCharacterObjects(e, this.Gs), this.Ws = this.Us.calculateMaxGlyphDimensions(e, this.Bs, this.Gs);
1268
+ const i = this.Os.createTextureAtlas(this.Ds, this.Ws, this.Bs, this.Gs);
1269
+ this.Is = i.framebuffer, this.Ls = i.columns, this.Es = i.rows;
1287
1270
  }
1288
- Ss(t) {
1289
- return this.Os.Ss(t, this.Fs);
1271
+ Ps(t) {
1272
+ return this.js.Ps(t, this.Ds);
1290
1273
  }
1291
- As(t) {
1292
- return this.Os.As(t, this.Fs);
1274
+ Fs(t) {
1275
+ return this.js.Fs(t, this.Ds);
1293
1276
  }
1294
1277
  U() {
1295
- this.Gs.U(), document.fonts.delete(this.Es);
1278
+ this.Is.U(), document.fonts.delete(this.ks);
1296
1279
  }
1297
1280
  get fontFramebuffer() {
1298
- return this.Gs;
1281
+ return this.Is;
1299
1282
  }
1300
1283
  get characters() {
1301
- return this.Fs;
1284
+ return this.Ds;
1302
1285
  }
1303
1286
  get textureColumns() {
1304
- return this.Is;
1287
+ return this.Ls;
1305
1288
  }
1306
1289
  get textureRows() {
1307
- return this.Bs;
1290
+ return this.Es;
1308
1291
  }
1309
1292
  get maxGlyphDimensions() {
1310
- return this.Ls;
1293
+ return this.Ws;
1311
1294
  }
1312
1295
  get fontSize() {
1313
- return this.Ds;
1296
+ return this.Bs;
1314
1297
  }
1315
1298
  get font() {
1316
- return this.Ps;
1299
+ return this.Gs;
1317
1300
  }
1318
1301
  }
1319
- class wt {
1320
- constructor(t, e, s) {
1321
- c(this, "Xs");
1322
- c(this, "Ys");
1323
- c(this, "v");
1324
- c(this, "C");
1302
+ class _t {
1303
+ constructor(t, e, i) {
1325
1304
  c(this, "Qs");
1326
1305
  c(this, "Zs");
1306
+ c(this, "v");
1307
+ c(this, "C");
1327
1308
  c(this, "Js");
1328
1309
  c(this, "Ks");
1329
1310
  c(this, "ti");
1330
- this.Js = t, this.Ks = e, this.ti = s, this.Ct();
1311
+ c(this, "ei");
1312
+ c(this, "si");
1313
+ this.ti = t, this.ei = e, this.si = i, this.yt();
1331
1314
  }
1332
- Ct() {
1333
- this.Xs = Math.floor(this.Js.width / this.Ks), this.Ys = Math.floor(this.Js.height / this.ti), this.v = this.Xs * this.Ks, this.C = this.Ys * this.ti, this.Qs = Math.floor((this.Js.width - this.v) / 2), this.Zs = Math.floor((this.Js.height - this.C) / 2);
1315
+ yt() {
1316
+ this.Qs = Math.floor(this.ti.width / this.ei), this.Zs = Math.floor(this.ti.height / this.si), this.v = this.Qs * this.ei, this.C = this.Zs * this.si, this.Js = Math.floor((this.ti.width - this.v) / 2), this.Ks = Math.floor((this.ti.height - this.C) / 2);
1334
1317
  }
1335
- ei(t, e) {
1336
- this.Ks = t, this.ti = e, this.Ct();
1318
+ ii(t, e) {
1319
+ this.ei = t, this.si = e, this.yt();
1337
1320
  }
1338
1321
  get cellWidth() {
1339
- return this.Ks;
1322
+ return this.ei;
1340
1323
  }
1341
1324
  get cellHeight() {
1342
- return this.ti;
1325
+ return this.si;
1343
1326
  }
1344
1327
  get cols() {
1345
- return this.Xs;
1328
+ return this.Qs;
1346
1329
  }
1347
1330
  get rows() {
1348
- return this.Ys;
1331
+ return this.Zs;
1349
1332
  }
1350
1333
  get width() {
1351
1334
  return this.v;
@@ -1354,294 +1337,294 @@ class wt {
1354
1337
  return this.C;
1355
1338
  }
1356
1339
  get offsetX() {
1357
- return this.Qs;
1340
+ return this.Js;
1358
1341
  }
1359
1342
  get offsetY() {
1360
- return this.Zs;
1343
+ return this.Ks;
1361
1344
  }
1362
1345
  }
1363
- class Pt {
1346
+ class St {
1364
1347
  constructor(t = {}) {
1365
- c(this, "Js");
1366
- c(this, "si");
1367
- c(this, "ii");
1368
- t.canvas ? (this.Js = t.canvas, this.ii = !1) : (this.Js = this.ri(t.width, t.height), this.ii = !0), this.Js.style.imageRendering = "pixelated";
1348
+ c(this, "ti");
1349
+ c(this, "ri");
1350
+ c(this, "ni");
1351
+ t.canvas ? (this.ti = t.canvas, this.ni = !1) : (this.ti = this.oi(t.width, t.height), this.ni = !0), this.ti.style.imageRendering = "pixelated";
1369
1352
  }
1370
- ri(t, e) {
1371
- const s = document.createElement("canvas");
1372
- return s.className = "textmodeCanvas", s.style.imageRendering = "pixelated", s.width = t || 800, s.height = e || 600, document.body.appendChild(s), s;
1353
+ oi(t, e) {
1354
+ const i = document.createElement("canvas");
1355
+ return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1373
1356
  }
1374
1357
  L(t, e) {
1375
- this.Js.width = t ?? this.Js.width, this.Js.height = e ?? this.Js.height;
1358
+ this.ti.width = t ?? this.ti.width, this.ti.height = e ?? this.ti.height;
1376
1359
  }
1377
- ni() {
1378
- const t = this.Js.getContext("webgl2", { alpha: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1379
- if (!t) throw new C("`textmode.js` requires WebGL2 support.");
1360
+ ai() {
1361
+ const t = this.ti.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1362
+ if (!t) throw new y("`textmode.js` requires WebGL2 support.");
1380
1363
  return t;
1381
1364
  }
1382
1365
  U() {
1383
- this.si && this.si.disconnect();
1384
- const t = this.Js.getContext("webgl") || this.Js.getContext("webgl2");
1366
+ this.ri && this.ri.disconnect();
1367
+ const t = this.ti.getContext("webgl") || this.ti.getContext("webgl2");
1385
1368
  if (t) {
1386
1369
  const e = t.getExtension("WEBGL_lose_context");
1387
1370
  e && e.loseContext();
1388
1371
  }
1389
- this.ii && this.Js.parentNode && this.Js.parentNode.removeChild(this.Js);
1372
+ this.ni && this.ti.parentNode && this.ti.parentNode.removeChild(this.ti);
1390
1373
  }
1391
1374
  get canvas() {
1392
- return this.Js;
1375
+ return this.ti;
1393
1376
  }
1394
1377
  get width() {
1395
- return this.Js.width;
1378
+ return this.ti.width;
1396
1379
  }
1397
1380
  get height() {
1398
- return this.Js.height;
1381
+ return this.ti.height;
1399
1382
  }
1400
1383
  }
1401
1384
  class Ft {
1402
1385
  constructor(t = 60) {
1403
- c(this, "oi");
1404
- c(this, "ai");
1405
- c(this, "hi", null);
1406
- c(this, "ci", 0);
1407
- c(this, "li", !0);
1386
+ c(this, "hi");
1387
+ c(this, "ci");
1388
+ c(this, "li", null);
1408
1389
  c(this, "ui", 0);
1409
- c(this, "fi", 0);
1410
- c(this, "di", []);
1411
- c(this, "pi", 10);
1412
- c(this, "gi", 0);
1413
- this.oi = t, this.ai = 1e3 / t;
1390
+ c(this, "fi", !0);
1391
+ c(this, "di", 0);
1392
+ c(this, "pi", 0);
1393
+ c(this, "gi", []);
1394
+ c(this, "_i", 10);
1395
+ c(this, "mi", 0);
1396
+ this.hi = t, this.ci = 1e3 / t;
1414
1397
  }
1415
1398
  start(t) {
1416
- if (!this.li) return;
1417
- this.ci = performance.now();
1418
- const e = (s) => {
1419
- if (!this.li) return void (this.hi = null);
1420
- const r = s - this.ci;
1421
- r >= this.ai && (t(), this.ci = s - r % this.ai), this.li && (this.hi = requestAnimationFrame(e));
1399
+ if (!this.fi) return;
1400
+ this.ui = performance.now();
1401
+ const e = (i) => {
1402
+ if (!this.fi) return void (this.li = null);
1403
+ const r = i - this.ui;
1404
+ r >= this.ci && (t(), this.ui = i - r % this.ci), this.fi && (this.li = requestAnimationFrame(e));
1422
1405
  };
1423
- this.hi = requestAnimationFrame(e);
1406
+ this.li = requestAnimationFrame(e);
1424
1407
  }
1425
1408
  stop() {
1426
- this.hi && (cancelAnimationFrame(this.hi), this.hi = null);
1409
+ this.li && (cancelAnimationFrame(this.li), this.li = null);
1427
1410
  }
1428
1411
  pause() {
1429
- this.li && (this.li = !1, this.stop());
1412
+ this.fi && (this.fi = !1, this.stop());
1430
1413
  }
1431
1414
  resume(t) {
1432
- this.li || (this.li = !0, this.start(t));
1415
+ this.fi || (this.fi = !0, this.start(t));
1433
1416
  }
1434
1417
  frameRate(t, e) {
1435
- if (t === void 0) return this.ui;
1436
- this.oi = t, this.ai = 1e3 / t, this.li && e && (this.stop(), this.start(e));
1418
+ if (t === void 0) return this.di;
1419
+ this.hi = t, this.ci = 1e3 / t, this.fi && e && (this.stop(), this.start(e));
1437
1420
  }
1438
1421
  measureFrameRate() {
1439
1422
  const t = performance.now();
1440
- if (this.fi > 0) {
1441
- const e = t - this.fi;
1442
- this.di.push(e), this.di.length > this.pi && this.di.shift();
1443
- const s = this.di.reduce((r, i) => r + i, 0) / this.di.length;
1444
- this.ui = 1e3 / s;
1423
+ if (this.pi > 0) {
1424
+ const e = t - this.pi;
1425
+ this.gi.push(e), this.gi.length > this._i && this.gi.shift();
1426
+ const i = this.gi.reduce((r, s) => r + s, 0) / this.gi.length;
1427
+ this.di = 1e3 / i;
1445
1428
  }
1446
- this.fi = t;
1429
+ this.pi = t;
1447
1430
  }
1448
1431
  get isLooping() {
1449
- return this.li;
1432
+ return this.fi;
1450
1433
  }
1451
1434
  get frameRateLimit() {
1452
- return this.oi;
1435
+ return this.hi;
1453
1436
  }
1454
1437
  get currentFrameRate() {
1455
- return this.ui;
1438
+ return this.di;
1456
1439
  }
1457
1440
  get frameCount() {
1458
- return this.gi;
1441
+ return this.mi;
1459
1442
  }
1460
1443
  set frameCount(t) {
1461
- this.gi = t;
1444
+ this.mi = t;
1462
1445
  }
1463
1446
  incrementFrame() {
1464
- this.gi++;
1447
+ this.mi++;
1465
1448
  }
1466
1449
  resetFrameCount() {
1467
- this.gi = 0;
1450
+ this.mi = 0;
1468
1451
  }
1469
1452
  }
1470
- const St = (a) => class extends a {
1453
+ const Pt = (a) => class extends a {
1471
1454
  rotate(t) {
1472
- this.Cs.state.$t(t);
1455
+ this.$s.state.bt(t);
1473
1456
  }
1474
1457
  push() {
1475
- this.Cs.state.vt();
1458
+ this.$s.state.xt();
1476
1459
  }
1477
1460
  pop() {
1478
- this.Cs.state.xt();
1461
+ this.$s.state.Ct();
1479
1462
  }
1480
- rect(t, e, s = 1, r = 1) {
1481
- this.Cs.Fe(t, e, s, r);
1463
+ rect(t, e, i = 1, r = 1) {
1464
+ this.$s.De(t, e, i, r);
1482
1465
  }
1483
- line(t, e, s, r) {
1484
- this.Cs.Ge(t, e, s, r);
1466
+ line(t, e, i, r) {
1467
+ this.$s.Ie(t, e, i, r);
1485
1468
  }
1486
1469
  lineWeight(t) {
1487
- this.Cs.state.wt(t);
1470
+ this.$s.state.$t(t);
1488
1471
  }
1489
- background(t, e = t, s = t, r = 255) {
1490
- this.Cs.We(t, e, s, r);
1472
+ background(t, e = t, i = t, r = 255) {
1473
+ this.$s.Ve(t, e, i, r);
1491
1474
  }
1492
1475
  char(t) {
1493
- this.Cs.state.bt(this.Ps.Ss(t));
1476
+ this.$s.state.Tt(this.Gs.Ps(t));
1494
1477
  }
1495
- charColor(t, e, s, r) {
1496
- this.Cs.state.Tt(t, e, s, r);
1478
+ charColor(t, e, i) {
1479
+ this.$s.state.zt(t, e, i);
1497
1480
  }
1498
- cellColor(t, e, s, r) {
1499
- this.Cs.state.zt(t, e, s, r);
1481
+ cellColor(t, e, i) {
1482
+ this.$s.state.Rt(t, e, i);
1500
1483
  }
1501
1484
  flipHorizontally(t) {
1502
- this.Cs.state.Rt(t);
1485
+ this.$s.state.Mt(t);
1503
1486
  }
1504
1487
  flipVertically(t) {
1505
- this.Cs.state.Mt(t);
1488
+ this.$s.state.St(t);
1506
1489
  }
1507
1490
  charRotation(t) {
1508
- this.Cs.state.At(t);
1491
+ this.$s.state.Pt(t);
1509
1492
  }
1510
1493
  invert(t) {
1511
- this.Cs.state.St(t);
1494
+ this.$s.state.At(t);
1512
1495
  }
1513
1496
  clear() {
1514
- this.Cs.Jt();
1497
+ this.$s.Ve(0, 0, 0, 0);
1515
1498
  }
1516
- ellipse(t, e, s, r) {
1517
- this.Cs.De(t, e, s / 2, r / 2);
1499
+ ellipse(t, e, i, r) {
1500
+ this.$s.Be(t, e, i / 2, r / 2);
1518
1501
  }
1519
- triangle(t, e, s, r, i, n) {
1520
- this.Cs.Ie(t, e, s, r, i, n);
1502
+ triangle(t, e, i, r, s, n) {
1503
+ this.$s.Le(t, e, i, r, s, n);
1521
1504
  }
1522
- bezierCurve(t, e, s, r, i, n, o, h) {
1523
- this.Cs.Be(t, e, s, r, i, n, o, h);
1505
+ bezierCurve(t, e, i, r, s, n, o, h) {
1506
+ this.$s.Ee(t, e, i, r, s, n, o, h);
1524
1507
  }
1525
- arc(t, e, s, r, i, n) {
1526
- this.Cs.Ee(t, e, s, r, i, n);
1508
+ arc(t, e, i, r, s, n) {
1509
+ this.$s.ke(t, e, i, r, s, n);
1527
1510
  }
1528
1511
  };
1529
- class B {
1530
- _i(t) {
1531
- const e = t.W(0), s = t.W(1), r = t.W(2), i = t.W(3);
1532
- return { characterPixels: e, primaryColorPixels: s, secondaryColorPixels: r, transformPixels: t.W(4), rotationPixels: i };
1512
+ class $ {
1513
+ xi(t) {
1514
+ const e = t.W(0), i = t.W(1), r = t.W(2), s = t.W(3);
1515
+ return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: r, transformPixels: t.W(4), rotationPixels: s };
1533
1516
  }
1534
- mi(t, e) {
1517
+ Ci(t, e) {
1535
1518
  return t[e] + (t[e + 1] << 8);
1536
1519
  }
1537
- xi(t, e) {
1520
+ yi(t, e) {
1538
1521
  return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
1539
1522
  }
1540
1523
  }
1541
- class O {
1542
- Ci(t, e) {
1524
+ class z {
1525
+ wi(t, e) {
1543
1526
  return new Blob([t], { type: e });
1544
1527
  }
1545
- yi(t, e, s) {
1528
+ $i(t, e, i) {
1546
1529
  try {
1547
- const r = this.Ci(t, s), i = URL.createObjectURL(r), n = document.createElement("a");
1548
- 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);
1530
+ const r = this.wi(t, i), s = URL.createObjectURL(r), n = document.createElement("a");
1531
+ n.href = s, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(s);
1549
1532
  } catch (r) {
1550
1533
  throw console.error("Failed to download file:", r), Error("File download failed: " + (r instanceof Error ? r.message : "Unknown error"));
1551
1534
  }
1552
1535
  }
1553
- wi() {
1536
+ bi() {
1554
1537
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
1555
1538
  }
1556
- $i() {
1539
+ Ti() {
1557
1540
  const t = /* @__PURE__ */ new Date();
1558
1541
  return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
1559
1542
  }
1560
- bi(t) {
1543
+ zi(t) {
1561
1544
  return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
1562
1545
  }
1563
- Ti() {
1564
- return "'textmode-export'-" + this.wi();
1546
+ Ri() {
1547
+ return "'textmode-export'-" + this.bi();
1565
1548
  }
1566
1549
  }
1567
- class It extends B {
1568
- zi(t, e, s) {
1569
- const r = t[s] === 255, i = t[s + 1] === 255, n = t[s + 2] === 255, o = e[s], h = e[s + 1];
1570
- return { isInverted: r, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * (o + h / 255) / 255 * 100) / 100 };
1550
+ class Mt extends $ {
1551
+ Mi(t, e, i) {
1552
+ const r = t[i] === 255, s = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], h = e[i + 1];
1553
+ return { isInverted: r, flipHorizontal: s, flipVertical: n, rotation: Math.round(360 * (o + h / 255) / 255 * 100) / 100 };
1571
1554
  }
1572
- Ri(t, e, s) {
1573
- return { x: t, y: e, cellX: t * s.cellWidth, cellY: e * s.cellHeight };
1555
+ Si(t, e, i) {
1556
+ return { x: t, y: e, cellX: t * i.cellWidth, cellY: e * i.cellHeight };
1574
1557
  }
1575
- Mi(t, e) {
1576
- const s = [];
1558
+ Ai(t, e) {
1559
+ const i = [];
1577
1560
  let r = 0;
1578
- for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
1579
- const o = 4 * r, h = this.mi(t.characterPixels, o);
1580
- let l = this.xi(t.primaryColorPixels, o), u = this.xi(t.secondaryColorPixels, o);
1581
- const f = this.zi(t.transformPixels, t.rotationPixels, o);
1561
+ for (let s = 0; s < e.rows; s++) for (let n = 0; n < e.cols; n++) {
1562
+ const o = 4 * r, h = this.Ci(t.characterPixels, o);
1563
+ let l = this.yi(t.primaryColorPixels, o), u = this.yi(t.secondaryColorPixels, o);
1564
+ const f = this.Mi(t.transformPixels, t.rotationPixels, o);
1582
1565
  if (f.isInverted) {
1583
- const p = l;
1584
- l = u, u = p;
1566
+ const g = l;
1567
+ l = u, u = g;
1585
1568
  }
1586
- const d = this.Ri(n, i, e);
1587
- s.push({ charIndex: h, primaryColor: l, secondaryColor: u, transform: f, position: d }), r++;
1569
+ const d = this.Si(n, s, e);
1570
+ i.push({ charIndex: h, primaryColor: l, secondaryColor: u, transform: f, position: d }), r++;
1588
1571
  }
1589
- return s;
1572
+ return i;
1590
1573
  }
1591
1574
  }
1592
- class Dt {
1593
- Si(t, e) {
1594
- const s = t.cmap;
1595
- for (const r of s.tables) if (r.format === 4) {
1596
- const i = r;
1597
- for (let n = 0; n < i.startCount.length; n++) if (e >= i.startCount[n] && e <= i.endCount[n]) {
1598
- if (i.idRangeOffset[n] === 0) return e + i.idDelta[n] & 65535;
1575
+ class Ut {
1576
+ Pi(t, e) {
1577
+ const i = t.cmap;
1578
+ for (const r of i.tables) if (r.format === 4) {
1579
+ const s = r;
1580
+ for (let n = 0; n < s.startCount.length; n++) if (e >= s.startCount[n] && e <= s.endCount[n]) {
1581
+ if (s.idRangeOffset[n] === 0) return e + s.idDelta[n] & 65535;
1599
1582
  {
1600
- const o = i.idRangeOffset[n] / 2 + (e - i.startCount[n]) - (i.startCount.length - n);
1601
- if (o >= 0 && o < i.glyphIdArray.length) {
1602
- const h = i.glyphIdArray[o];
1603
- if (h !== 0) return h + i.idDelta[n] & 65535;
1583
+ const o = s.idRangeOffset[n] / 2 + (e - s.startCount[n]) - (s.startCount.length - n);
1584
+ if (o >= 0 && o < s.glyphIdArray.length) {
1585
+ const h = s.glyphIdArray[o];
1586
+ if (h !== 0) return h + s.idDelta[n] & 65535;
1604
1587
  }
1605
1588
  }
1606
1589
  }
1607
1590
  } else if (r.format === 12) {
1608
- const i = r;
1609
- for (let n = 0; n < i.groups.length; n += 3) {
1610
- const o = i.groups[n], h = i.groups[n + 1], l = i.groups[n + 2];
1591
+ const s = r;
1592
+ for (let n = 0; n < s.groups.length; n += 3) {
1593
+ const o = s.groups[n], h = s.groups[n + 1], l = s.groups[n + 2];
1611
1594
  if (e >= o && e <= h) return l + (e - o);
1612
1595
  }
1613
1596
  }
1614
1597
  return 0;
1615
1598
  }
1616
- Ai(t, e, s, r, i) {
1617
- const n = i / t.head.unitsPerEm;
1618
- return { getBoundingBox: () => ({ x1: s + e.xMin * n, y1: r + -e.yMax * n, x2: s + e.xMax * n, y2: r + -e.yMin * n }), toSVG: () => this.Pi(e, s, r, n) };
1599
+ Fi(t, e, i, r, s) {
1600
+ const n = s / t.head.unitsPerEm;
1601
+ return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: r + -e.yMax * n, x2: i + e.xMax * n, y2: r + -e.yMin * n }), toSVG: () => this.Gi(e, i, r, n) };
1619
1602
  }
1620
- Pi(t, e, s, r) {
1603
+ Gi(t, e, i, r) {
1621
1604
  if (!t || !t.xs) return "";
1622
- const { xs: i, ys: n, endPts: o, flags: h } = t;
1623
- if (!(i && n && o && h)) return "";
1605
+ const { xs: s, ys: n, endPts: o, flags: h } = t;
1606
+ if (!(s && n && o && h)) return "";
1624
1607
  let l = "", u = 0;
1625
1608
  for (let f = 0; f < o.length; f++) {
1626
1609
  const d = o[f];
1627
1610
  if (!(d < u)) {
1628
1611
  if (d >= u) {
1629
- const p = e + i[u] * r, g = s - n[u] * r;
1630
- l += `M${p.toFixed(2)},${g.toFixed(2)}`;
1612
+ const g = e + s[u] * r, p = i - n[u] * r;
1613
+ l += `M${g.toFixed(2)},${p.toFixed(2)}`;
1631
1614
  let m = u + 1;
1632
1615
  for (; m <= d; )
1633
1616
  if (1 & h[m]) {
1634
- const T = e + i[m] * r, v = s - n[m] * r;
1635
- l += `L${T.toFixed(2)},${v.toFixed(2)}`, m++;
1617
+ const w = e + s[m] * r, C = i - n[m] * r;
1618
+ l += `L${w.toFixed(2)},${C.toFixed(2)}`, m++;
1636
1619
  } else {
1637
- const T = e + i[m] * r, v = s - n[m] * r;
1638
- let b = m + 1 > d ? u : m + 1;
1639
- if (1 & h[b]) {
1640
- const _ = e + i[b] * r, S = s - n[b] * r;
1641
- l += `Q${T.toFixed(2)},${v.toFixed(2)} ${_.toFixed(2)},${S.toFixed(2)}`, m = b + 1;
1620
+ const w = e + s[m] * r, C = i - n[m] * r;
1621
+ let T = m + 1 > d ? u : m + 1;
1622
+ if (1 & h[T]) {
1623
+ const b = e + s[T] * r, P = i - n[T] * r;
1624
+ l += `Q${w.toFixed(2)},${C.toFixed(2)} ${b.toFixed(2)},${P.toFixed(2)}`, m = T + 1;
1642
1625
  } else {
1643
- const _ = (T + (e + i[b] * r)) / 2, S = (v + (s - n[b] * r)) / 2;
1644
- l += `Q${T.toFixed(2)},${v.toFixed(2)} ${_.toFixed(2)},${S.toFixed(2)}`, m = b;
1626
+ const b = (w + (e + s[T] * r)) / 2, P = (C + (i - n[T] * r)) / 2;
1627
+ l += `Q${w.toFixed(2)},${C.toFixed(2)} ${b.toFixed(2)},${P.toFixed(2)}`, m = T;
1645
1628
  }
1646
1629
  }
1647
1630
  l += "Z";
@@ -1651,22 +1634,22 @@ class Dt {
1651
1634
  }
1652
1635
  return l;
1653
1636
  }
1654
- Fi(t, e, s, r, i) {
1655
- const n = t.codePointAt(0) || 0, o = this.Si(e, n);
1637
+ Di(t, e, i, r, s) {
1638
+ const n = t.codePointAt(0) || 0, o = this.Pi(e, n);
1656
1639
  let h = null;
1657
- return e.glyf && e.glyf[o] !== null ? h = e.glyf[o] : (h = E.T.glyf.Oe(e, o), e.glyf[o] = h), this.Ai(e, h, s, r, i);
1640
+ return e.glyf && e.glyf[o] !== null ? h = e.glyf[o] : (h = E.T.glyf.je(e, o), e.glyf[o] = h), this.Fi(e, h, i, r, s);
1658
1641
  }
1659
- Gi(t, e, s, r, i, n, o, h) {
1660
- const l = s + (i - h * (o / e.head.unitsPerEm)) / 2, u = r + (n + 0.7 * o) / 2;
1661
- return this.Fi(t, e, l, u, o).toSVG() || null;
1642
+ Ii(t, e, i, r, s, n, o, h) {
1643
+ const l = i + (s - h * (o / e.head.unitsPerEm)) / 2, u = r + (n + 0.7 * o) / 2;
1644
+ return this.Di(t, e, l, u, o).toSVG() || null;
1662
1645
  }
1663
1646
  }
1664
- class Lt {
1647
+ class It {
1665
1648
  constructor() {
1666
- c(this, "Di");
1667
- this.Di = new Dt();
1649
+ c(this, "Bi");
1650
+ this.Bi = new Ut();
1668
1651
  }
1669
- Ii(t) {
1652
+ Li(t) {
1670
1653
  return `<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1671
1654
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
1672
1655
  <svg width="${t.width}" height="${t.height}" viewBox="0 0 ${t.width} ${t.height}"
@@ -1674,173 +1657,173 @@ class Lt {
1674
1657
  <title>textmode art generated via textmode.js</title>
1675
1658
  <desc>textmode art visualization generated by textmode.js library</desc>`;
1676
1659
  }
1677
- Bi() {
1660
+ Ei() {
1678
1661
  return `
1679
1662
  </g>
1680
1663
  </svg>`;
1681
1664
  }
1682
- Li(t, e) {
1665
+ Wi(t, e) {
1683
1666
  if (!e.includeBackgroundRectangles) return "";
1684
- const s = e.backgroundColor, r = `rgba(${s[0]},${s[1]},${s[2]},${s[3] / 255})`;
1667
+ const i = e.backgroundColor, r = `rgba(${i[0]},${i[1]},${i[2]},${i[3] / 255})`;
1685
1668
  return `
1686
1669
  <rect width="${t.width}" height="${t.height}" fill="${r}" />`;
1687
1670
  }
1688
- Ei(t) {
1671
+ ki(t) {
1689
1672
  return `rgba(${t.r},${t.g},${t.b},${t.a / 255})`;
1690
1673
  }
1691
- Wi(t, e) {
1692
- const { transform: s, position: r } = t, i = r.cellX + e.cellWidth / 2, n = r.cellY + e.cellHeight / 2, o = [];
1693
- if (s.flipHorizontal || s.flipVertical) {
1694
- const h = s.flipHorizontal ? -1 : 1, l = s.flipVertical ? -1 : 1;
1695
- o.push(`translate(${i} ${n})`), o.push(`scale(${h} ${l})`), o.push(`translate(${-i} ${-n})`);
1674
+ Vi(t, e) {
1675
+ const { transform: i, position: r } = t, s = r.cellX + e.cellWidth / 2, n = r.cellY + e.cellHeight / 2, o = [];
1676
+ if (i.flipHorizontal || i.flipVertical) {
1677
+ const h = i.flipHorizontal ? -1 : 1, l = i.flipVertical ? -1 : 1;
1678
+ o.push(`translate(${s} ${n})`), o.push(`scale(${h} ${l})`), o.push(`translate(${-s} ${-n})`);
1696
1679
  }
1697
- return s.rotation && o.push(`rotate(${s.rotation} ${i} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
1698
- }
1699
- ki(t, e, s) {
1700
- if (!s.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
1701
- const { position: r } = t, i = this.Ei(t.secondaryColor);
1702
- return s.drawMode === "stroke" ? `
1703
- <rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${i}" fill="none" stroke-width="${s.strokeWidth}" />` : `
1704
- <rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${i}" />`;
1705
- }
1706
- Fi(t, e, s, r) {
1707
- const i = s.characters[t.charIndex];
1708
- if (!i) return "";
1709
- const n = this.Di.Gi(i.character, s.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, s.fontSize, i.advanceWidth);
1680
+ return i.rotation && o.push(`rotate(${i.rotation} ${s} ${n})`), o.length ? ` transform="${o.join(" ")}"` : "";
1681
+ }
1682
+ Oi(t, e, i) {
1683
+ if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
1684
+ const { position: r } = t, s = this.ki(t.secondaryColor);
1685
+ return i.drawMode === "stroke" ? `
1686
+ <rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${s}" fill="none" stroke-width="${i.strokeWidth}" />` : `
1687
+ <rect x="${r.cellX}" y="${r.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${s}" />`;
1688
+ }
1689
+ Di(t, e, i, r) {
1690
+ const s = i.characters[t.charIndex];
1691
+ if (!s) return "";
1692
+ const n = this.Bi.Ii(s.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, s.advanceWidth);
1710
1693
  if (!n) return "";
1711
- const o = this.Ei(t.primaryColor);
1694
+ const o = this.ki(t.primaryColor);
1712
1695
  return r.drawMode === "stroke" ? `
1713
1696
  <path id="${`path-${t.charIndex}-${t.position.cellX}-${t.position.cellY}`.replace(/\./g, "-")}" d="${n}" stroke="${o}" stroke-width="${r.strokeWidth}" fill="none" />` : `
1714
1697
  <path d="${n}" fill="${o}" />`;
1715
1698
  }
1716
- Vi(t, e, s, r) {
1717
- let i = "";
1718
- i += this.ki(t, e, r);
1719
- const n = this.Wi(t, e), o = this.Fi(t, e, s, r);
1720
- return o && (n ? (i += `
1721
- <g${n}>`, i += o, i += `
1722
- </g>`) : i += o), i;
1723
- }
1724
- Oi(t, e, s, r) {
1725
- let i = this.Ii(e);
1726
- i += this.Li(e, r), i += `
1699
+ Ui(t, e, i, r) {
1700
+ let s = "";
1701
+ s += this.Oi(t, e, r);
1702
+ const n = this.Vi(t, e), o = this.Di(t, e, i, r);
1703
+ return o && (n ? (s += `
1704
+ <g${n}>`, s += o, s += `
1705
+ </g>`) : s += o), s;
1706
+ }
1707
+ ji(t, e, i, r) {
1708
+ let s = this.Li(e);
1709
+ s += this.Wi(e, r), s += `
1727
1710
  <g id="ascii-cells">`;
1728
- for (const n of t) i += this.Vi(n, e, s, r);
1729
- return i += this.Bi(), i;
1711
+ for (const n of t) s += this.Ui(n, e, i, r);
1712
+ return s += this.Ei(), s;
1730
1713
  }
1731
- Ui(t) {
1714
+ Hi(t) {
1732
1715
  return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\n\s*\n/g, `
1733
1716
  `).replace(/[ \t]+$/gm, "");
1734
1717
  }
1735
1718
  }
1736
- class Mt extends O {
1737
- ji(t) {
1738
- return this.Ci(t, "image/svg+xml;charset=utf-8");
1719
+ class Dt extends z {
1720
+ qi(t) {
1721
+ return this.wi(t, "image/svg+xml;charset=utf-8");
1739
1722
  }
1740
- Hi(t, e) {
1741
- this.yi(t, this.bi(e) + ".svg", "image/svg+xml;charset=utf-8");
1723
+ Ni(t, e) {
1724
+ this.$i(t, this.zi(e) + ".svg", "image/svg+xml;charset=utf-8");
1742
1725
  }
1743
- qi(t, e) {
1744
- this.Hi(t, e || this.Ti());
1726
+ Xi(t, e) {
1727
+ this.Ni(t, e || this.Ri());
1745
1728
  }
1746
1729
  }
1747
1730
  class N {
1748
1731
  constructor() {
1749
- c(this, "Ni");
1750
- c(this, "Xi");
1751
1732
  c(this, "Yi");
1752
- this.Ni = new It(), this.Xi = new Lt(), this.Yi = new Mt();
1733
+ c(this, "Qi");
1734
+ c(this, "Zi");
1735
+ this.Yi = new Mt(), this.Qi = new It(), this.Zi = new Dt();
1753
1736
  }
1754
- Qi(t) {
1755
- return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Yi.Ti() };
1737
+ Ji(t) {
1738
+ return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Zi.Ri() };
1756
1739
  }
1757
- Zi(t, e = {}) {
1758
- const s = this.Ni.Mi(this.Ni._i(t.pipeline), t.grid), r = this.Xi.Oi(s, t.grid, t.font, this.Qi(e));
1759
- return this.Xi.Ui(r);
1740
+ Ki(t, e = {}) {
1741
+ const i = this.Yi.Ai(this.Yi.xi(t.pipeline), t.grid), r = this.Qi.ji(i, t.grid, t.font, this.Ji(e));
1742
+ return this.Qi.Hi(r);
1760
1743
  }
1761
- qi(t, e = {}) {
1762
- this.Yi.qi(this.Zi(t, e), e.filename);
1744
+ Xi(t, e = {}) {
1745
+ this.Zi.Xi(this.Ki(t, e), e.filename);
1763
1746
  }
1764
1747
  }
1765
- class Ut extends B {
1766
- Ji(t, e, s, r = " ") {
1748
+ class Lt extends $ {
1749
+ tr(t, e, i, r = " ") {
1767
1750
  var o;
1768
- const i = [];
1751
+ const s = [];
1769
1752
  let n = 0;
1770
1753
  for (let h = 0; h < e.rows; h++) {
1771
1754
  const l = [];
1772
1755
  for (let u = 0; u < e.cols; u++) {
1773
- const f = 4 * n, d = this.mi(t.characterPixels, f), p = ((o = s.characters[d]) == null ? void 0 : o.character) || r;
1774
- l.push(p), n++;
1756
+ const f = 4 * n, d = this.Ci(t.characterPixels, f), g = ((o = i.characters[d]) == null ? void 0 : o.character) || r;
1757
+ l.push(g), n++;
1775
1758
  }
1776
- i.push(l);
1759
+ s.push(l);
1777
1760
  }
1778
- return i;
1761
+ return s;
1779
1762
  }
1780
1763
  }
1781
- class zt {
1782
- Ki(t, e) {
1783
- const s = [];
1784
- for (const i of t) {
1785
- let n = i.join("");
1786
- e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), s.push(n);
1764
+ class Bt {
1765
+ er(t, e) {
1766
+ const i = [];
1767
+ for (const s of t) {
1768
+ let n = s.join("");
1769
+ e.preserveTrailingSpaces || (n = n.replace(/\s+$/, "")), i.push(n);
1787
1770
  }
1788
1771
  const r = e.lineEnding === "crlf" ? `\r
1789
1772
  ` : `
1790
1773
  `;
1791
- return s.join(r);
1774
+ return i.join(r);
1792
1775
  }
1793
1776
  }
1794
- class Bt extends O {
1795
- tr(t, e) {
1796
- const s = this.er(e);
1797
- this.yi(t, s, "text/plain;charset=utf-8");
1777
+ class $t extends z {
1778
+ sr(t, e) {
1779
+ const i = this.ir(e);
1780
+ this.$i(t, i, "text/plain;charset=utf-8");
1798
1781
  }
1799
- er(t) {
1800
- let e = this.bi(t);
1801
- return e === ".txt" || e.length <= 4 ? this.Ti() : e;
1782
+ ir(t) {
1783
+ let e = this.zi(t);
1784
+ return e === ".txt" || e.length <= 4 ? this.Ri() : e;
1802
1785
  }
1803
1786
  }
1804
- class V {
1787
+ class k {
1805
1788
  constructor() {
1806
- c(this, "Ni");
1807
- c(this, "Xi");
1808
1789
  c(this, "Yi");
1809
- this.Ni = new Ut(), this.Xi = new zt(), this.Yi = new Bt();
1790
+ c(this, "Qi");
1791
+ c(this, "Zi");
1792
+ this.Yi = new Lt(), this.Qi = new Bt(), this.Zi = new $t();
1810
1793
  }
1811
- Qi(t) {
1812
- return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Yi.Ti() };
1794
+ Ji(t) {
1795
+ return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Zi.Ri() };
1813
1796
  }
1814
- sr(t, e = {}) {
1815
- const s = this.Qi(e), r = this.Ni.Ji(this.Ni._i(t.pipeline), t.grid, t.font, s.emptyCharacter);
1816
- return this.Xi.Ki(r, s);
1797
+ rr(t, e = {}) {
1798
+ const i = this.Ji(e), r = this.Yi.tr(this.Yi.xi(t.pipeline), t.grid, t.font, i.emptyCharacter);
1799
+ return this.Qi.er(r, i);
1817
1800
  }
1818
- tr(t, e = {}) {
1819
- this.Yi.tr(this.sr(t, e), e.filename);
1801
+ sr(t, e = {}) {
1802
+ this.Zi.sr(this.rr(t, e), e.filename);
1820
1803
  }
1821
1804
  }
1822
- class Ot extends B {
1823
- ir(t, e = 1, s = "transparent") {
1805
+ class zt extends $ {
1806
+ nr(t, e = 1, i = "transparent") {
1824
1807
  const r = t.canvas;
1825
- if (e === 1 && s === "transparent") return r;
1826
- const i = document.createElement("canvas"), n = i.getContext("2d"), o = Math.round(r.width * e), h = Math.round(r.height * e);
1827
- return i.width = o, i.height = h, s !== "transparent" && (n.fillStyle = s, n.fillRect(0, 0, o, h)), n.imageSmoothingEnabled = !1, n.drawImage(r, 0, 0, r.width, r.height, 0, 0, o, h), i;
1808
+ if (e === 1 && i === "transparent") return r;
1809
+ const s = document.createElement("canvas"), n = s.getContext("2d"), o = Math.round(r.width * e), h = Math.round(r.height * e);
1810
+ return s.width = o, s.height = h, i !== "transparent" && (n.fillStyle = i, n.fillRect(0, 0, o, h)), n.imageSmoothingEnabled = !1, n.drawImage(r, 0, 0, r.width, r.height, 0, 0, o, h), s;
1828
1811
  }
1829
1812
  }
1830
- class $t {
1831
- rr(t, e) {
1832
- const s = this.nr(e.format);
1833
- return e.format === "png" ? t.toDataURL(s) : t.toDataURL(s, e.quality);
1834
- }
1835
- async ar(t, e) {
1836
- return new Promise((s, r) => {
1837
- const i = this.nr(e.format), n = (o) => {
1838
- o ? s(o) : r(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
1813
+ class Gt {
1814
+ ar(t, e) {
1815
+ const i = this.hr(e.format);
1816
+ return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
1817
+ }
1818
+ async cr(t, e) {
1819
+ return new Promise((i, r) => {
1820
+ const s = this.hr(e.format), n = (o) => {
1821
+ o ? i(o) : r(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
1839
1822
  };
1840
- e.format === "png" ? t.toBlob(n, i) : t.toBlob(n, i, e.quality);
1823
+ e.format === "png" ? t.toBlob(n, s) : t.toBlob(n, s, e.quality);
1841
1824
  });
1842
1825
  }
1843
- nr(t) {
1826
+ hr(t) {
1844
1827
  switch (t) {
1845
1828
  case "png":
1846
1829
  return "image/png";
@@ -1853,208 +1836,211 @@ class $t {
1853
1836
  }
1854
1837
  }
1855
1838
  }
1856
- const Wt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, k = { png: ".png", jpg: ".jpg", webp: ".webp" };
1857
- class Gt extends O {
1858
- hr(t, e, s) {
1859
- this.cr(t, this.bi(e) + k[s]);
1839
+ const Wt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, V = { png: ".png", jpg: ".jpg", webp: ".webp" };
1840
+ class Ot extends z {
1841
+ lr(t, e, i) {
1842
+ this.ur(t, this.zi(e) + V[i]);
1860
1843
  }
1861
- cr(t, e) {
1862
- const s = URL.createObjectURL(t);
1844
+ ur(t, e) {
1845
+ const i = URL.createObjectURL(t);
1863
1846
  try {
1864
1847
  const r = document.createElement("a");
1865
- r.href = s, r.download = e, r.style.display = "none", r.rel = "noopener", document.body.appendChild(r), r.click(), document.body.removeChild(r);
1848
+ r.href = i, r.download = e, r.style.display = "none", r.rel = "noopener", document.body.appendChild(r), r.click(), document.body.removeChild(r);
1866
1849
  } finally {
1867
- URL.revokeObjectURL(s);
1850
+ URL.revokeObjectURL(i);
1868
1851
  }
1869
1852
  }
1870
- lr(t) {
1871
- return t in Wt && t in k;
1853
+ dr(t) {
1854
+ return t in Wt && t in V;
1872
1855
  }
1873
1856
  }
1874
1857
  class Nt {
1875
1858
  constructor() {
1876
- c(this, "Ni");
1877
- c(this, "Xi");
1878
1859
  c(this, "Yi");
1879
- this.Ni = new Ot(), this.Xi = new $t(), this.Yi = new Gt();
1860
+ c(this, "Qi");
1861
+ c(this, "Zi");
1862
+ this.Yi = new zt(), this.Qi = new Gt(), this.Zi = new Ot();
1880
1863
  }
1881
- Qi(t) {
1882
- return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Yi.Ti() };
1864
+ Ji(t) {
1865
+ return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Zi.Ri() };
1883
1866
  }
1884
- ur(t) {
1885
- if (!this.Yi.lr(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
1867
+ pr(t) {
1868
+ if (!this.Zi.dr(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
1886
1869
  if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
1887
1870
  if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
1888
1871
  t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
1889
1872
  }
1890
- async ar(t, e) {
1891
- if (e.scale === 1 && e.backgroundColor === "transparent") return await this.Xi.ar(t.canvas, e);
1892
- const s = this.Ni.ir(t, e.scale, e.backgroundColor);
1893
- return await this.Xi.ar(s, e);
1873
+ async cr(t, e) {
1874
+ if (e.scale === 1 && e.backgroundColor === "transparent") return await this.Qi.cr(t.canvas, e);
1875
+ const i = this.Yi.nr(t, e.scale, e.backgroundColor);
1876
+ return await this.Qi.cr(i, e);
1894
1877
  }
1895
- async hr(t, e = {}) {
1896
- const s = this.Qi(e);
1897
- this.ur(s);
1898
- const r = await this.ar(t, s);
1899
- this.Yi.hr(r, s.filename, s.format);
1878
+ async lr(t, e = {}) {
1879
+ const i = this.Ji(e);
1880
+ this.pr(i);
1881
+ const r = await this.cr(t, i);
1882
+ this.Zi.lr(r, i.filename, i.format);
1900
1883
  }
1901
1884
  }
1902
- const Vt = (a) => class extends a {
1903
- dr() {
1904
- this.Cs.Ve(this.pr);
1885
+ const kt = (a) => class extends a {
1886
+ gr() {
1887
+ this.$s.Ue(this._r);
1905
1888
  }
1906
1889
  toString(t = {}) {
1907
- return this.dr(), new V().sr({ pipeline: this.gr, grid: this._r, font: this.Ps }, t);
1890
+ return this.gr(), new k().rr({ pipeline: this.mr, grid: this.vr, font: this.Gs }, t);
1908
1891
  }
1909
1892
  saveStrings(t = {}) {
1910
- this.dr(), new V().tr({ pipeline: this.gr, grid: this._r, font: this.Ps }, t);
1893
+ this.gr(), new k().sr({ pipeline: this.mr, grid: this.vr, font: this.Gs }, t);
1911
1894
  }
1912
1895
  toSVG(t = {}) {
1913
- return this.dr(), new N().Zi(this, t);
1896
+ return this.gr(), new N().Ki(this, t);
1914
1897
  }
1915
1898
  saveSVG(t = {}) {
1916
- this.dr(), new N().qi(this, t);
1899
+ this.gr(), new N().Xi(this, t);
1917
1900
  }
1918
1901
  async saveCanvas(t = {}) {
1919
- await new Nt().hr(this.Js, t);
1902
+ await new Nt().lr(this.ti, t);
1920
1903
  }
1921
- }, kt = (a) => class extends a {
1904
+ }, Vt = (a) => class extends a {
1922
1905
  async loadFont(t) {
1923
- return this.Ps.Ns(t).then(() => {
1924
- const e = this.Ps.maxGlyphDimensions;
1925
- this._r.ei(e.width, e.height), this.Cs.ke();
1906
+ return this.Gs.Ys(t).then(() => {
1907
+ const e = this.Gs.maxGlyphDimensions;
1908
+ this.vr.ii(e.width, e.height), this.$s.Oe();
1926
1909
  });
1927
1910
  }
1928
1911
  fontSize(t) {
1929
- if (!I._(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ps.fontSize === t) return;
1930
- this.Ps.qs(t);
1931
- const e = this.Ps.maxGlyphDimensions;
1932
- this._r.ei(e.width, e.height), this.Cs.ke();
1912
+ if (!M._(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Gs.fontSize === t) return;
1913
+ this.Gs.Xs(t);
1914
+ const e = this.Gs.maxGlyphDimensions;
1915
+ this.vr.ii(e.width, e.height), this.$s.Oe();
1933
1916
  }
1934
1917
  }, Xt = (a) => class extends a {
1935
1918
  get frameCount() {
1936
- return this.mr.frameCount;
1919
+ return this.Cr.frameCount;
1937
1920
  }
1938
1921
  set frameCount(t) {
1939
- this.mr.frameCount = t;
1922
+ this.Cr.frameCount = t;
1940
1923
  }
1941
1924
  frameRate(t) {
1942
- return t === void 0 ? this.mr.currentFrameRate : this.mr.frameRate(t, () => this.vr());
1925
+ return t === void 0 ? this.Cr.currentFrameRate : this.Cr.frameRate(t, () => this.yr());
1943
1926
  }
1944
1927
  noLoop() {
1945
- this.mr.pause();
1928
+ this.Cr.pause();
1946
1929
  }
1947
1930
  loop() {
1948
- this.mr.resume(() => this.vr());
1931
+ this.Cr.resume(() => this.yr());
1949
1932
  }
1950
1933
  redraw(t = 1) {
1951
- if (I._(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.vr();
1934
+ if (M._(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.yr();
1952
1935
  }
1953
1936
  isLooping() {
1954
- return this.mr.isLooping;
1937
+ return this.Cr.isLooping;
1955
1938
  }
1956
1939
  };
1957
- class Yt {
1940
+ class jt {
1958
1941
  constructor() {
1959
- c(this, "Cs");
1960
- c(this, "Ps");
1961
- c(this, "Js");
1942
+ c(this, "$s");
1943
+ c(this, "Gs");
1944
+ c(this, "ti");
1945
+ c(this, "vr");
1946
+ c(this, "Cr");
1962
1947
  c(this, "_r");
1963
1948
  c(this, "mr");
1964
- c(this, "pr");
1965
- c(this, "gr");
1966
- c(this, "Cr");
1949
+ c(this, "wr");
1967
1950
  }
1968
- vr() {
1951
+ yr() {
1969
1952
  }
1970
1953
  }
1971
- class jt extends function(e, ...s) {
1972
- return s.reduce((r, i) => i(r), e);
1973
- }(Yt, St, Vt, kt, Xt) {
1954
+ class Yt extends function(e, ...i) {
1955
+ return i.reduce((r, s) => s(r), e);
1956
+ }(jt, Pt, kt, Vt, Xt) {
1974
1957
  constructor(e = {}) {
1975
1958
  super();
1976
- c(this, "yr", !1);
1977
- c(this, "wr", () => {
1959
+ c(this, "$r", !1);
1960
+ c(this, "br", () => {
1978
1961
  });
1979
- c(this, "$r", () => {
1962
+ c(this, "Tr", () => {
1980
1963
  });
1981
- c(this, "br");
1982
- this.Js = new Pt(e), this.Cs = new mt(this.Js.ni()), this.Ps = new At(this.Cs, e.fontSize ?? 16), this.mr = new Ft(e.frameRate ?? 60), this.pr = this.Cs.Ae(`#version 300 es
1964
+ c(this, "zr");
1965
+ this.ti = new St(e), this.$s = new mt(this.ti.ai()), this.Gs = new At(this.$s, e.fontSize ?? 16), this.Cr = new Ft(e.frameRate ?? 60), this._r = this.$s.Fe(`#version 300 es
1983
1966
  in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in float a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float u_aspectRatio;uniform vec2 u_viewportSize;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat2 rotate2D(float angle){float s=sin(angle);float c=cos(angle);return mat2(c,-s,s,c);}vec2 evaluateBezier(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float oneMinusT=1.0-t;float oneMinusT2=oneMinusT*oneMinusT;float oneMinusT3=oneMinusT2*oneMinusT;float t2=t*t;float t3=t2*t;return oneMinusT3*p0+3.0*oneMinusT2*t*p1+3.0*oneMinusT*t2*p2+t3*p3;}vec2 evaluateBezierDerivative(float t,vec2 p0,vec2 p1,vec2 p2,vec2 p3){float oneMinusT=1.0-t;float oneMinusT2=oneMinusT*oneMinusT;float t2=t*t;return-3.0*oneMinusT2*p0+3.0*oneMinusT2*p1-6.0*oneMinusT*t*p1+6.0*oneMinusT*t*p2-3.0*t2*p2+3.0*t2*p3;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 worldPosition;bool isBezierCurve=length(a_instanceBezierCP1)>0.0||length(a_instanceBezierCP2)>0.0||length(a_instanceBezierStart)>0.0||length(a_instanceBezierEnd)>0.0;bool isArc=a_instanceArcAngles.x!=0.0||a_instanceArcAngles.y!=0.0;if(isBezierCurve){float t=a_position.x;float thicknessOffset=a_position.y;vec2 curvePoint=evaluateBezier(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 tangent=evaluateBezierDerivative(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float tangentLength=length(tangent);if(tangentLength>0.0){tangent=tangent/tangentLength;}else{tangent=vec2(1.0,0.0);}vec2 normal=vec2(-tangent.y,tangent.x);float thickness=a_instanceSize.y;vec2 thicknessVector=normal*thicknessOffset*thickness;worldPosition=curvePoint+thicknessVector;}else if(isArc){float startA=a_instanceArcAngles.x;float stopA=a_instanceArcAngles.y;float TWO_PI=6.28318530718;startA=mod(startA,TWO_PI);if(startA<0.0)startA+=TWO_PI;stopA=mod(stopA,TWO_PI);if(stopA<0.0)stopA+=TWO_PI;float cwDelta=startA-stopA;if(cwDelta<=0.0)cwDelta+=TWO_PI;float angle=startA-a_position.x*cwDelta;float r=a_position.y;vec2 local=vec2(cos(angle),sin(angle))*r;vec2 scaledPosition=local*a_instanceSize*0.5+vec2(a_instanceSize.x*0.5,a_instanceSize.y*0.5);worldPosition=scaledPosition+a_instancePosition;}else{vec2 scaledPosition=a_position*a_instanceSize;worldPosition=scaledPosition+a_instancePosition;}vec2 ndc=(worldPosition/u_viewportSize)*2.0-1.0;ndc.y=-ndc.y;if(a_instanceGlobalRotation!=0.0){ndc-=a_instanceRotationCenter;ndc.x*=u_aspectRatio;ndc=rotate2D(-a_instanceGlobalRotation)*ndc;ndc.x/=u_aspectRatio;ndc+=a_instanceRotationCenter;}gl_Position=vec4(ndc,0.0,1.0);}`, `#version 300 es
1984
- precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.0);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.0,1.0);o_transform=vec4(v_transform,1.0);}`), this.Cr = this.Cs.Ae("attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.0,1.0);}", "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 vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetPixels;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_gridOffsetPixels)/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);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);}");
1967
+ precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.0);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.0,1.0);o_transform=vec4(v_transform,1.0);}`), this.wr = this.$s.Fe("attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.0,1.0);}", "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 vec2 u_gridCellDimensions;uniform vec2 u_gridPixelDimensions;uniform vec2 u_gridOffsetPixels;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_gridOffsetPixels)/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);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);}");
1985
1968
  }
1986
1969
  static async create(e = {}) {
1987
- const s = new this(e);
1988
- await s.Ps.Us(e.fontSource);
1989
- const r = s.Ps.maxGlyphDimensions;
1990
- return s._r = new wt(s.Js.canvas, r.width, r.height), s.gr = s.Cs.Le(s._r.cols, s._r.rows, 5), s.Tr(), s.mr.start(() => s.vr()), s;
1991
- }
1992
- Tr() {
1993
- this.br = () => {
1994
- this.$r();
1995
- }, window.addEventListener("resize", this.br);
1996
- }
1997
- vr() {
1998
- this.mr.measureFrameRate(), this.mr.incrementFrame(), this.yr || (this.gr.V(), this.Cs.Se(this.pr), this.wr(), this.Cs.Ve(this.pr), this.gr.O(), this.Cs.We(0), this.Cs.Se(this.Cr), this.Cr.et({ u_characterTexture: this.Ps.fontFramebuffer, u_charsetDimensions: [this.Ps.textureColumns, this.Ps.textureRows], u_asciiCharacterTexture: this.gr.textures[0], u_primaryColorTexture: this.gr.textures[1], u_secondaryColorTexture: this.gr.textures[2], u_transformTexture: this.gr.textures[4], u_rotationTexture: this.gr.textures[3], u_gridCellDimensions: [this._r.cols, this._r.rows], u_gridPixelDimensions: [this._r.width, this._r.height], u_gridOffsetPixels: [this._r.offsetX, this._r.offsetY], u_aspectRatio: this._r.width / this._r.height }), this.Cs.Pe(this._r.offsetX, this._r.offsetY, this._r.width, this._r.height));
1970
+ const i = new this(e);
1971
+ await i.Gs.Hs(e.fontSource);
1972
+ const r = i.Gs.maxGlyphDimensions;
1973
+ return i.vr = new _t(i.ti.canvas, r.width, r.height), i.mr = i.$s.We(i.vr.cols, i.vr.rows, 5), i.Rr(), i.Cr.start(() => i.yr()), i;
1974
+ }
1975
+ Rr() {
1976
+ this.zr = () => {
1977
+ this.Tr();
1978
+ }, window.addEventListener("resize", this.zr);
1979
+ }
1980
+ yr() {
1981
+ if (this.Cr.measureFrameRate(), this.Cr.incrementFrame(), this.$r) return;
1982
+ this.mr.V(), this.$s.Pe(this._r), this.br(), this.$s.Ue(this._r), this.mr.O();
1983
+ const e = this.$s.state.canvasBackgroundColor;
1984
+ this.$s.te(e[0], e[1], e[2], e[3]), this.$s.Pe(this.wr), this.wr.et({ u_characterTexture: this.Gs.fontFramebuffer, u_charsetDimensions: [this.Gs.textureColumns, this.Gs.textureRows], u_asciiCharacterTexture: this.mr.textures[0], u_primaryColorTexture: this.mr.textures[1], u_secondaryColorTexture: this.mr.textures[2], u_transformTexture: this.mr.textures[4], u_rotationTexture: this.mr.textures[3], u_gridCellDimensions: [this.vr.cols, this.vr.rows], u_gridPixelDimensions: [this.vr.width, this.vr.height], u_gridOffsetPixels: [this.vr.offsetX, this.vr.offsetY], u_aspectRatio: this.vr.width / this.vr.height }), this.$s.Ge(this.vr.offsetX, this.vr.offsetY, this.vr.width, this.vr.height);
1999
1985
  }
2000
1986
  draw(e) {
2001
- this.wr = e;
1987
+ this.br = e;
2002
1988
  }
2003
1989
  windowResized(e) {
2004
- this.$r = e;
1990
+ this.Tr = e;
2005
1991
  }
2006
- resizeCanvas(e, s) {
2007
- this.Js.L(e, s), this._r.Ct(), this.gr.L(this._r.cols, this._r.rows), this.Cs.ke(), this.vr();
1992
+ resizeCanvas(e, i) {
1993
+ this.ti.L(e, i), this.vr.yt(), this.mr.L(this.vr.cols, this.vr.rows), this.$s.Oe(), this.yr();
2008
1994
  }
2009
1995
  destroy() {
2010
- this.yr || (this.mr.stop(), window.removeEventListener("resize", this.br), this.Ps.U(), this.Cs.U(), this.yr = !0);
1996
+ this.$r || (this.Cr.stop(), window.removeEventListener("resize", this.zr), this.Gs.U(), this.$s.U(), this.$r = !0);
2011
1997
  }
2012
1998
  get grid() {
2013
- return this._r;
1999
+ return this.vr;
2014
2000
  }
2015
2001
  get font() {
2016
- return this.Ps;
2002
+ return this.Gs;
2017
2003
  }
2018
2004
  get width() {
2019
- return this.Js.width;
2005
+ return this.ti.width;
2020
2006
  }
2021
2007
  get height() {
2022
- return this.Js.height;
2008
+ return this.ti.height;
2023
2009
  }
2024
2010
  get canvas() {
2025
- return this.Js.canvas;
2011
+ return this.ti.canvas;
2026
2012
  }
2027
2013
  get isDisposed() {
2028
- return this.yr;
2014
+ return this.$r;
2029
2015
  }
2030
2016
  get drawFramebuffer() {
2031
- return this.gr;
2017
+ return this.mr;
2032
2018
  }
2033
2019
  }
2034
- class $ {
2020
+ class G {
2035
2021
  constructor() {
2036
- throw new C("Textmode is a static class and cannot be instantiated.");
2022
+ throw new y("Textmode is a static class and cannot be instantiated.");
2037
2023
  }
2038
2024
  static async create(t) {
2039
- return jt.create(t);
2025
+ return Yt.create(t);
2040
2026
  }
2041
2027
  static setErrorLevel(t) {
2042
- I.m(t);
2028
+ M.m(t);
2043
2029
  }
2044
2030
  static get version() {
2045
- return "0.2.0-beta.1";
2031
+ return "0.2.0-beta.2";
2046
2032
  }
2047
2033
  }
2048
- const Jt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), qt = $.create, Zt = $.setErrorLevel, Kt = $.version;
2034
+ const qt = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), Zt = G.create, Qt = G.setErrorLevel, Jt = G.version;
2049
2035
  export {
2050
- Pt as TextmodeCanvas,
2051
- Z as TextmodeErrorLevel,
2036
+ St as TextmodeCanvas,
2037
+ Q as TextmodeErrorLevel,
2052
2038
  At as TextmodeFont,
2053
- wt as TextmodeGrid,
2054
- jt as Textmodifier,
2055
- qt as create,
2056
- Jt as export,
2057
- Zt as setErrorLevel,
2058
- $ as textmode,
2059
- Kt as version
2039
+ _t as TextmodeGrid,
2040
+ Yt as Textmodifier,
2041
+ Zt as create,
2042
+ qt as export,
2043
+ Qt as setErrorLevel,
2044
+ G as textmode,
2045
+ Jt as version
2060
2046
  };