textmode.js 0.2.1-beta.3 → 0.2.1-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/textmode.esm.js +2145 -1808
  2. package/dist/textmode.esm.min.js +1715 -1377
  3. package/dist/textmode.umd.js +9 -9
  4. package/dist/textmode.umd.min.js +8 -7
  5. package/dist/types/assets/shaders-minified/frag/image-to-mrt.d.ts +14 -0
  6. package/dist/types/assets/shaders-minified/frag/present.d.ts +14 -0
  7. package/dist/types/assets/shaders-minified/index.d.ts +2 -0
  8. package/dist/types/index.d.ts +1 -0
  9. package/dist/types/rendering/index.d.ts +0 -2
  10. package/dist/types/rendering/webgl/DrawQueue.d.ts +9 -7
  11. package/dist/types/rendering/webgl/InstanceData.d.ts +15 -15
  12. package/dist/types/rendering/webgl/RenderPipeline.d.ts +1 -0
  13. package/dist/types/rendering/webgl/RenderState.d.ts +13 -19
  14. package/dist/types/rendering/webgl/Renderer.d.ts +13 -2
  15. package/dist/types/rendering/webgl/Shader.d.ts +20 -5
  16. package/dist/types/rendering/webgl/ShaderManager.d.ts +12 -11
  17. package/dist/types/rendering/webgl/geometries/BaseGeometry.d.ts +2 -1
  18. package/dist/types/rendering/webgl/types/DrawCommand.d.ts +2 -2
  19. package/dist/types/textmode/Canvas.d.ts +6 -0
  20. package/dist/types/textmode/TextmodeImage.d.ts +92 -0
  21. package/dist/types/textmode/Textmodifier.d.ts +17 -2
  22. package/dist/types/textmode/font/CharacterExtractor.d.ts +14 -14
  23. package/dist/types/textmode/font/MetricsCalculator.d.ts +1 -21
  24. package/dist/types/textmode/font/typr/Typr.d.ts +2 -0
  25. package/dist/types/textmode/font/typr/types.d.ts +6 -0
  26. package/dist/types/textmode/font/utils/index.d.ts +0 -1
  27. package/dist/types/textmode/mixins/AnimationMixin.d.ts +8 -0
  28. package/dist/types/textmode/mixins/FontMixin.d.ts +43 -3
  29. package/dist/types/textmode/mixins/KeyboardMixin.d.ts +2 -3
  30. package/dist/types/textmode/mixins/MouseMixin.d.ts +6 -6
  31. package/dist/types/textmode/mixins/RenderingMixin.d.ts +23 -5
  32. package/package.json +1 -1
  33. package/dist/types/rendering/webgl/types/ShaderTypes.d.ts +0 -35
  34. package/dist/types/textmode/font/utils/CmapParser.d.ts +0 -47
@@ -1,1152 +1,1304 @@
1
- var Q = Object.defineProperty;
2
- var tt = (a, t, e) => t in a ? Q(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
- var h = (a, t, e) => tt(a, typeof t != "symbol" ? t + "" : t, e);
4
- class v extends Error {
1
+ var ct = Object.defineProperty;
2
+ var lt = (h, t, e) => t in h ? ct(h, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[t] = e;
3
+ var a = (h, t, e) => lt(h, typeof t != "symbol" ? t + "" : t, e);
4
+ class U extends Error {
5
5
  constructor(t, e = {}) {
6
- super(v.u(t, e)), this.name = "TextmodeError";
6
+ super(U.i(t, e)), this.name = "TextmodeError";
7
7
  }
8
- static u(t, e) {
8
+ static i(t, e) {
9
9
  return `${t}${e && Object.keys(e).length > 0 ? `
10
10
 
11
11
  📋 Context:` + Object.entries(e).map(([i, s]) => `
12
- - ${i}: ${v._(s)}`).join("") : ""}
12
+ - ${i}: ${U.o(s)}`).join("") : ""}
13
13
 
14
14
  ${"↓".repeat(24)}
15
15
  `;
16
16
  }
17
- static _(t) {
17
+ static o(t) {
18
18
  if (t === null) return "null";
19
19
  if (t === void 0) return "undefined";
20
20
  if (typeof t == "string") return `"${t}"`;
21
21
  if (typeof t == "number" || typeof t == "boolean") return t + "";
22
- if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => v._(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => v._(e)).join(", ")}, ... +${t.length - 3} more]`;
22
+ if (Array.isArray(t)) return t.length === 0 ? "[]" : t.length <= 5 ? `[${t.map((e) => U.o(e)).join(", ")}]` : `[${t.slice(0, 3).map((e) => U.o(e)).join(", ")}, ... +${t.length - 3} more]`;
23
23
  if (typeof t == "object") {
24
24
  const e = Object.keys(t);
25
- return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${v._(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${v._(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
25
+ return e.length === 0 ? "{}" : e.length <= 3 ? `{ ${e.map((i) => `${i}: ${U.o(t[i])}`).join(", ")} }` : `{ ${e.slice(0, 2).map((i) => `${i}: ${U.o(t[i])}`).join(", ")}, ... +${e.length - 2} more }`;
26
26
  }
27
27
  return t + "";
28
28
  }
29
29
  }
30
- var et = ((a) => (a[a.SILENT = 0] = "SILENT", a[a.WARNING = 1] = "WARNING", a[a.ERROR = 2] = "ERROR", a[a.THROW = 3] = "THROW", a))(et || {});
31
- const _ = class _ {
30
+ var ut = ((h) => (h[h.SILENT = 0] = "SILENT", h[h.WARNING = 1] = "WARNING", h[h.ERROR = 2] = "ERROR", h[h.THROW = 3] = "THROW", h))(ut || {});
31
+ const I = class I {
32
32
  constructor() {
33
- h(this, "C", { globalLevel: 3 });
33
+ a(this, "u", { globalLevel: 3 });
34
34
  }
35
- static $() {
36
- return _.v || (_.v = new _()), _.v;
35
+ static _() {
36
+ return I.l || (I.l = new I()), I.l;
37
37
  }
38
- R(t, e) {
38
+ m(t, e) {
39
39
  const i = "%c[textmode.js] Oops! (╯°□°)╯︵ Something went wrong in your code.", s = "color: #f44336; font-weight: bold; background: #ffebee; padding: 2px 6px; border-radius: 3px;";
40
- switch (this.C.globalLevel) {
40
+ switch (this.u.globalLevel) {
41
41
  case 0:
42
42
  return !1;
43
43
  case 1:
44
- return console.group(i, s), console.warn(v.u(t, e)), console.groupEnd(), !1;
44
+ return console.group(i, s), console.warn(U.i(t, e)), console.groupEnd(), !1;
45
45
  case 2:
46
- return console.group(i, s), console.error(v.u(t, e)), console.groupEnd(), !1;
46
+ return console.group(i, s), console.error(U.i(t, e)), console.groupEnd(), !1;
47
47
  default:
48
- throw new v(t, e);
48
+ throw new U(t, e);
49
49
  }
50
50
  }
51
- M(t, e, i) {
52
- return !!t || (this.R(e, i), !1);
51
+ v(t, e, i) {
52
+ return !!t || (this.m(e, i), !1);
53
53
  }
54
- S(t) {
55
- this.C.globalLevel = t;
54
+ C(t) {
55
+ this.u.globalLevel = t;
56
56
  }
57
57
  };
58
- h(_, "v", null);
59
- let z = _;
60
- const L = z.$(), K = /* @__PURE__ */ new WeakMap();
61
- function U(a, t) {
62
- K.set(a, t);
58
+ a(I, "l", null);
59
+ let j = I;
60
+ const $ = j._(), ot = /* @__PURE__ */ new WeakMap();
61
+ function W(h, t) {
62
+ ot.set(h, t);
63
63
  }
64
- function B(a) {
65
- return K.get(a);
64
+ function X(h) {
65
+ return ot.get(h);
66
66
  }
67
- class Z {
67
+ class ht {
68
68
  constructor() {
69
- h(this, "F", 1);
70
- h(this, "P", 0);
71
- h(this, "G", 0);
72
- h(this, "A", 0);
73
- h(this, "L", [0, 0, 0]);
74
- h(this, "D", [1, 1, 1, 1]);
75
- h(this, "W", [0, 0, 0, 1]);
76
- h(this, "I", !1);
77
- h(this, "U", !1);
78
- h(this, "O", !1);
79
- h(this, "V", [0, 0]);
80
- h(this, "H", [0, 0, 0, 1]);
81
- h(this, "K", []);
82
- }
83
- N() {
84
- this.K.push({ X: this.F, Y: this.P, Z: this.G, J: this.A, V: [...this.V], I: this.I, U: this.U, O: this.O, tt: [...this.L], et: [...this.D], st: [...this.W] });
85
- }
86
- it() {
87
- const t = this.K.pop();
88
- t ? (this.F = t.X, this.P = t.Y, this.G = t.Z, this.A = t.J, this.V = t.V, this.I = t.I, this.U = t.U, this.O = t.O, this.L = t.tt, this.D = t.et, this.W = t.st) : console.warn("pop() called without matching push()");
89
- }
90
- rt() {
91
- this.K = [], this.P = 0, this.G = 0, this.A = 0;
92
- }
93
- nt(t) {
94
- t.lineWeight = this.F, t.rotationX = this.P, t.rotationY = this.G, t.rotationZ = this.A, t.character[0] = this.L[0], t.character[1] = this.L[1], t.character[2] = this.L[2], t.charColor[0] = this.D[0], t.charColor[1] = this.D[1], t.charColor[2] = this.D[2], t.charColor[3] = this.D[3], t.bgColor[0] = this.W[0], t.bgColor[1] = this.W[1], t.bgColor[2] = this.W[2], t.bgColor[3] = this.W[3], t.flipHorizontally = this.I, t.flipVertically = this.U, t.invert = this.O, t.charRotation[0] = this.V[0], t.charRotation[1] = this.V[1];
69
+ a(this, "$", 1);
70
+ a(this, "U", 0);
71
+ a(this, "F", 0);
72
+ a(this, "M", 0);
73
+ a(this, "R", [0, 0, 0]);
74
+ a(this, "S", [1, 1, 1, 1]);
75
+ a(this, "A", [0, 0, 0, 1]);
76
+ a(this, "L", !1);
77
+ a(this, "k", !1);
78
+ a(this, "P", !1);
79
+ a(this, "G", [0, 0]);
80
+ a(this, "D", [0, 0, 0, 1]);
81
+ a(this, "I", []);
82
+ }
83
+ W() {
84
+ this.I.push({ O: this.$, H: this.U, V: this.F, K: this.M, G: [...this.G], N: this.L, X: this.k, P: this.P, j: [...this.R], Y: [...this.S], q: [...this.A] });
85
+ }
86
+ Z() {
87
+ const t = this.I.pop();
88
+ t ? (this.$ = t.O, this.U = t.H, this.F = t.V, this.M = t.K, this.G = t.G, this.L = t.N, this.k = t.X, this.P = t.P, this.R = t.j, this.S = t.Y, this.A = t.q) : console.warn("pop() called without matching push()");
89
+ }
90
+ J(t) {
91
+ t.O = this.$, t.H = this.U, t.V = this.F, t.K = this.M, t.j[0] = this.R[0], t.j[1] = this.R[1], t.j[2] = this.R[2], t.Y[0] = this.S[0], t.Y[1] = this.S[1], t.Y[2] = this.S[2], t.Y[3] = this.S[3], t.q[0] = this.A[0], t.q[1] = this.A[1], t.q[2] = this.A[2], t.q[3] = this.A[3], t.N = this.L, t.X = this.k, t.P = this.P, t.G[0] = this.G[0], t.G[1] = this.G[1];
95
92
  }
96
93
  get lineWeight() {
97
- return this.F;
94
+ return this.$;
98
95
  }
99
96
  get canvasBackgroundColor() {
100
- return this.H;
97
+ return this.D;
101
98
  }
102
- ot(t) {
103
- this.F = Math.abs(t);
99
+ tt(t) {
100
+ this.$ = Math.abs(t);
104
101
  }
105
- ht(t) {
106
- this.P = t;
102
+ et(t) {
103
+ this.U = t;
107
104
  }
108
- ct(t) {
109
- this.G = t;
105
+ st(t) {
106
+ this.F = t;
110
107
  }
111
- lt(t) {
112
- this.A = t;
108
+ it(t) {
109
+ this.M = t;
113
110
  }
114
- ut(t) {
115
- this.L = t;
111
+ rt(t) {
112
+ this.R = t;
116
113
  }
117
- ft(t, e, i, s = 255) {
118
- this.D = [t / 255, e / 255, i / 255, s / 255];
114
+ nt(t, e, i, s = 255) {
115
+ this.S = [t / 255, e / 255, i / 255, s / 255];
119
116
  }
120
- dt(t, e, i, s = 255) {
121
- this.W = [t / 255, e / 255, i / 255, s / 255];
117
+ ot(t, e, i, s = 255) {
118
+ this.A = [t / 255, e / 255, i / 255, s / 255];
122
119
  }
123
- _t(t) {
124
- this.I = t;
120
+ ht(t) {
121
+ this.L = t;
125
122
  }
126
- gt(t) {
127
- this.U = t;
123
+ ct(t) {
124
+ this.k = t;
128
125
  }
129
- vt(t) {
130
- this.O = t;
126
+ lt(t) {
127
+ this.P = t;
131
128
  }
132
- yt(t) {
129
+ ut(t) {
133
130
  const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
134
- this.V = [i, s];
131
+ this.G = [i, s];
135
132
  }
136
- Ct(t, e, i, s) {
137
- this.H = [t / 255, e / 255, i / 255, s / 255];
133
+ ft(t, e, i, s) {
134
+ this.D = [t / 255, e / 255, i / 255, s / 255];
138
135
  }
139
136
  }
140
- class G {
137
+ class K {
141
138
  constructor(t, e, i = e, s = 1, r = {}, n = null, o = !1) {
142
- h(this, "$t");
143
- h(this, "wt");
144
- h(this, "C");
145
- h(this, "xt", null);
146
- h(this, "bt");
147
- h(this, "Rt");
148
- h(this, "Mt", []);
149
- h(this, "St");
150
- h(this, "Ft", null);
151
- h(this, "zt", []);
152
- h(this, "Pt", null);
153
- h(this, "kt", !1);
154
- h(this, "Tt", null);
155
- this.$t = e, this.wt = i, this.C = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.bt = t, this.St = Math.min(Math.max(1, s), 8), this.Pt = n, this.kt = !!o, this.Tt = this.kt ? new Z() : null;
139
+ a(this, "dt");
140
+ a(this, "_t");
141
+ a(this, "u");
142
+ a(this, "gt", null);
143
+ a(this, "vt");
144
+ a(this, "yt");
145
+ a(this, "Ct", []);
146
+ a(this, "wt");
147
+ a(this, "$t", null);
148
+ a(this, "bt", []);
149
+ a(this, "xt", null);
150
+ a(this, "Ft", !1);
151
+ a(this, "Mt", null);
152
+ this.dt = e, this._t = i, this.u = { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte", ...r }, this.vt = t, this.wt = Math.min(Math.max(1, s), 8), this.xt = n, this.Ft = !!o, this.Mt = this.Ft ? new ht() : null;
156
153
  const c = t.getParameter(t.MAX_DRAW_BUFFERS), l = t.getParameter(t.MAX_COLOR_ATTACHMENTS);
157
- this.St = Math.min(this.St, c, l), this.Rt = t.createFramebuffer(), this.Gt(), this.At(), this.zt = Array(this.St).fill(null);
154
+ this.wt = Math.min(this.wt, c, l), this.yt = t.createFramebuffer(), this.Rt(), this.St(), this.bt = Array(this.wt).fill(null);
158
155
  }
159
- Gt() {
160
- const t = this.bt, e = this.C.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.C.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, s = this.C.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
161
- for (let r = 0; r < this.St; r++) {
156
+ Rt() {
157
+ const t = this.vt, e = this.u.filter === "linear" ? t.LINEAR : t.NEAREST, i = this.u.wrap === "repeat" ? t.REPEAT : t.CLAMP_TO_EDGE, s = this.u.type === "float" ? t.FLOAT : t.UNSIGNED_BYTE;
158
+ for (let r = 0; r < this.wt; r++) {
162
159
  const n = t.createTexture();
163
- 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.$t, this.wt, 0, t.RGBA, s, null), this.Mt.push(n);
160
+ t.bindTexture(t.TEXTURE_2D, n), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MIN_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_MAG_FILTER, e), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_S, i), t.texParameteri(t.TEXTURE_2D, t.TEXTURE_WRAP_T, i), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, this.dt, this._t, 0, t.RGBA, s, null), this.Ct.push(n);
164
161
  }
165
162
  t.bindTexture(t.TEXTURE_2D, null);
166
163
  }
167
- At() {
168
- const t = this.bt;
169
- if (t.bindFramebuffer(t.FRAMEBUFFER, this.Rt), this.St === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.Mt[0], 0);
164
+ St() {
165
+ const t = this.vt;
166
+ if (t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.wt === 1) t.framebufferTexture2D(t.FRAMEBUFFER, t.COLOR_ATTACHMENT0, t.TEXTURE_2D, this.Ct[0], 0);
170
167
  else {
171
168
  const i = [];
172
- for (let s = 0; s < this.St; s++) {
169
+ for (let s = 0; s < this.wt; s++) {
173
170
  const r = t.COLOR_ATTACHMENT0 + s;
174
- t.framebufferTexture2D(t.FRAMEBUFFER, r, t.TEXTURE_2D, this.Mt[s], 0), i.push(r);
171
+ t.framebufferTexture2D(t.FRAMEBUFFER, r, t.TEXTURE_2D, this.Ct[s], 0), i.push(r);
175
172
  }
176
173
  t.drawBuffers(i);
177
174
  }
178
175
  const e = t.checkFramebufferStatus(t.FRAMEBUFFER);
179
176
  e !== t.FRAMEBUFFER_COMPLETE && console.error("GLFramebuffer is not complete:", e), t.bindFramebuffer(t.FRAMEBUFFER, null);
180
177
  }
181
- Lt(t) {
182
- const e = this.bt;
183
- e.bindTexture(e.TEXTURE_2D, this.Mt[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
178
+ At(t) {
179
+ const e = this.vt;
180
+ e.bindTexture(e.TEXTURE_2D, this.Ct[0]), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, 1), e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, t), e.bindTexture(e.TEXTURE_2D, null);
184
181
  }
185
182
  resize(t, e) {
186
- this.$t = t, this.wt = e, this.xt = null, this.zt = Array(this.St).fill(null);
187
- const i = this.bt, s = this.C.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
188
- for (const r of this.Mt) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.$t, this.wt, 0, i.RGBA, s, null);
183
+ this.dt = t, this._t = e, this.gt = null, this.bt = Array(this.wt).fill(null);
184
+ const i = this.vt, s = this.u.type === "float" ? i.FLOAT : i.UNSIGNED_BYTE;
185
+ for (const r of this.Ct) i.bindTexture(i.TEXTURE_2D, r), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, this.dt, this._t, 0, i.RGBA, s, null);
189
186
  i.bindTexture(i.TEXTURE_2D, null);
190
187
  }
191
- Et(t) {
192
- const e = this.bt, i = this.zt[t];
188
+ zt(t) {
189
+ const e = this.vt, i = this.bt[t];
193
190
  if (i) return i;
194
- const s = this.$t, r = this.wt, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
195
- e.bindFramebuffer(e.READ_FRAMEBUFFER, this.Rt), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
191
+ const s = this.dt, r = this._t, n = new Uint8Array(s * r * 4), o = e.getParameter(e.READ_FRAMEBUFFER_BINDING);
192
+ e.bindFramebuffer(e.READ_FRAMEBUFFER, this.yt), e.readBuffer(e.COLOR_ATTACHMENT0 + t), e.readPixels(0, 0, s, r, e.RGBA, e.UNSIGNED_BYTE, n), e.bindFramebuffer(e.READ_FRAMEBUFFER, o);
196
193
  const c = 4 * s, l = new Uint8Array(n.length);
197
194
  for (let f = 0; f < r; f++) {
198
- const u = (r - 1 - f) * c, d = f * c;
199
- l.set(n.subarray(u, u + c), d);
195
+ const u = (r - 1 - f) * c, g = f * c;
196
+ l.set(n.subarray(u, u + c), g);
200
197
  }
201
- return this.zt[t] = l, l;
198
+ return this.bt[t] = l, l;
202
199
  }
203
200
  begin() {
204
201
  var e, i, s, r;
205
- const t = this.bt;
206
- if (this.Pt) {
207
- const n = ((i = (e = this.Pt).Bt) == null ? void 0 : i.call(e)) ?? null;
208
- n && this.Pt.Dt(n), this.kt && this.Tt && ((r = (s = this.Pt).Wt) == null || r.call(s, this.Tt));
202
+ const t = this.vt;
203
+ if (this.xt) {
204
+ const n = ((i = (e = this.xt).Tt) == null ? void 0 : i.call(e)) ?? null;
205
+ n && this.xt.Et(n), this.Ft && this.Mt && ((r = (s = this.xt).Lt) == null || r.call(s, this.Mt));
209
206
  }
210
- this.Ft = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.Rt), this.zt = Array(this.St).fill(null);
211
- for (let n = 0; n < this.St; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
212
- t.viewport(0, 0, this.$t, this.wt), U(t, [0, 0, this.$t, this.wt]);
207
+ this.$t = { framebuffer: t.getParameter(t.FRAMEBUFFER_BINDING), viewport: t.getParameter(t.VIEWPORT) }, t.bindFramebuffer(t.FRAMEBUFFER, this.yt), this.bt = Array(this.wt).fill(null);
208
+ for (let n = 0; n < this.wt; n++) t.clearBufferfv(t.COLOR, n, new Float32Array([0, 0, 0, 0]));
209
+ t.viewport(0, 0, this.dt, this._t), W(t, [0, 0, this.dt, this._t]);
213
210
  }
214
211
  end() {
215
212
  var e, i, s, r;
216
- if (!this.Ft) return;
217
- const t = this.bt;
218
- if (this.Pt) {
219
- const n = ((i = (e = this.Pt).Bt) == null ? void 0 : i.call(e)) ?? null;
220
- n && this.Pt.Dt(n);
213
+ if (!this.$t) return;
214
+ const t = this.vt;
215
+ if (this.xt) {
216
+ const n = ((i = (e = this.xt).Tt) == null ? void 0 : i.call(e)) ?? null;
217
+ n && this.xt.Et(n);
221
218
  }
222
- t.bindFramebuffer(t.FRAMEBUFFER, this.Ft.framebuffer), t.viewport(...this.Ft.viewport), U(t, this.Ft.viewport), this.Ft = null, this.Pt && this.kt && this.Tt && ((r = (s = this.Pt).It) == null || r.call(s));
219
+ t.bindFramebuffer(t.FRAMEBUFFER, this.$t.framebuffer), t.viewport(...this.$t.viewport), W(t, this.$t.viewport), this.$t = null, this.xt && this.Ft && this.Mt && ((r = (s = this.xt).kt) == null || r.call(s));
223
220
  }
224
- Ut() {
225
- const t = this.bt;
226
- t.deleteFramebuffer(this.Rt);
227
- for (const e of this.Mt) t.deleteTexture(e);
221
+ Pt() {
222
+ const t = this.vt;
223
+ t.deleteFramebuffer(this.yt);
224
+ for (const e of this.Ct) t.deleteTexture(e);
228
225
  }
229
226
  get width() {
230
- return this.$t;
227
+ return this.dt;
231
228
  }
232
229
  get height() {
233
- return this.wt;
230
+ return this._t;
234
231
  }
235
232
  get textures() {
236
- return [...this.Mt];
233
+ return [...this.Ct];
237
234
  }
238
235
  }
239
- function k(a) {
240
- return typeof a == "string" ? a : a.sourceCode;
241
- }
242
236
  class M {
243
237
  constructor(t, e, i) {
244
- h(this, "bt");
245
- h(this, "Ot");
246
- h(this, "Vt", /* @__PURE__ */ new Map());
247
- h(this, "Ht", 0);
248
- this.bt = t, this.Ot = this.Kt(k(e), k(i)), this.Nt();
249
- }
250
- Nt() {
251
- const t = this.bt.getProgramParameter(this.Ot, this.bt.ACTIVE_UNIFORMS);
238
+ a(this, "vt");
239
+ a(this, "Gt");
240
+ a(this, "Bt", /* @__PURE__ */ new Map());
241
+ a(this, "Dt", /* @__PURE__ */ new Map());
242
+ a(this, "It", 0);
243
+ this.vt = t, this.Gt = this.Wt(e, i), this.Ot();
244
+ }
245
+ Ot() {
246
+ const t = this.vt.getProgramParameter(this.Gt, this.vt.ACTIVE_UNIFORMS);
252
247
  for (let e = 0; e < t; e++) {
253
- const i = this.bt.getActiveUniform(this.Ot, e);
248
+ const i = this.vt.getActiveUniform(this.Gt, e);
254
249
  if (i) {
255
- const s = this.bt.getUniformLocation(this.Ot, i.name);
256
- s && this.Vt.set(i.name, s);
250
+ const s = this.vt.getUniformLocation(this.Gt, i.name);
251
+ if (s && (this.Bt.set(i.name, s), this.Dt.set(i.name, { type: i.type, size: i.size }), i.size > 1)) {
252
+ const r = i.name.replace(/\[.*\]$/, "");
253
+ this.Bt.has(r) || (this.Bt.set(r, s), this.Dt.set(r, { type: i.type, size: i.size }));
254
+ }
257
255
  }
258
256
  }
259
257
  }
260
- Kt(t, e) {
261
- const i = this.Xt(this.bt.VERTEX_SHADER, t), s = this.Xt(this.bt.FRAGMENT_SHADER, e), r = this.bt.createProgram();
262
- if (this.bt.attachShader(r, i), this.bt.attachShader(r, s), this.bt.linkProgram(r), !this.bt.getProgramParameter(r, this.bt.LINK_STATUS)) {
263
- const n = this.bt.getProgramInfoLog(r);
258
+ Wt(t, e) {
259
+ const i = this.Ht(this.vt.VERTEX_SHADER, t), s = this.Ht(this.vt.FRAGMENT_SHADER, e), r = this.vt.createProgram();
260
+ if (this.vt.attachShader(r, i), this.vt.attachShader(r, s), this.vt.linkProgram(r), !this.vt.getProgramParameter(r, this.vt.LINK_STATUS)) {
261
+ const n = this.vt.getProgramInfoLog(r);
264
262
  throw Error("Shader program link error: " + n);
265
263
  }
266
- return this.bt.deleteShader(i), this.bt.deleteShader(s), r;
264
+ return this.vt.deleteShader(i), this.vt.deleteShader(s), r;
267
265
  }
268
- Xt(t, e) {
269
- const i = this.bt.createShader(t);
270
- if (this.bt.shaderSource(i, e), this.bt.compileShader(i), !this.bt.getShaderParameter(i, this.bt.COMPILE_STATUS)) {
271
- const s = this.bt.getShaderInfoLog(i);
272
- throw this.bt.deleteShader(i), Error("Shader compilation error: " + s);
266
+ Ht(t, e) {
267
+ const i = this.vt.createShader(t);
268
+ if (this.vt.shaderSource(i, e), this.vt.compileShader(i), !this.vt.getShaderParameter(i, this.vt.COMPILE_STATUS)) {
269
+ const s = this.vt.getShaderInfoLog(i);
270
+ throw this.vt.deleteShader(i), Error("Shader compilation error: " + s);
273
271
  }
274
272
  return i;
275
273
  }
276
- jt() {
277
- this.bt.useProgram(this.Ot), this.Yt();
274
+ Vt() {
275
+ this.vt.useProgram(this.Gt), this.Kt();
278
276
  }
279
- Yt() {
280
- this.Ht = 0;
277
+ Kt() {
278
+ this.It = 0;
281
279
  }
282
- qt(t) {
283
- for (const [e, i] of Object.entries(t)) this.Zt(e, i);
280
+ Nt(t) {
281
+ for (const [e, i] of Object.entries(t)) this.Xt(e, i);
284
282
  }
285
- Jt(t) {
286
- return this.Vt.has(t);
283
+ jt(t) {
284
+ return this.Bt.has(t);
287
285
  }
288
- Zt(t, e) {
289
- var s;
290
- const i = this.Vt.get(t);
291
- if (i) if (typeof e == "number") this.bt.uniform1f(i, e);
292
- else if (typeof e == "boolean") this.bt.uniform1i(i, e ? 1 : 0);
286
+ Yt(t) {
287
+ return this.Dt.get(t) || null;
288
+ }
289
+ qt() {
290
+ const t = [];
291
+ for (const [e, i] of this.Dt.entries()) t.push({ name: e, ...i });
292
+ return t;
293
+ }
294
+ Xt(t, e) {
295
+ var c;
296
+ const i = this.Bt.get(t);
297
+ if (!i) return;
298
+ const s = this.Dt.get(t);
299
+ if (!s) return void console.warn(`No type information found for uniform '${t}'`);
300
+ const { type: r, size: n } = s, o = this.vt;
301
+ if (typeof e == "number") switch (r) {
302
+ case o.INT:
303
+ case o.BOOL:
304
+ o.uniform1i(i, e);
305
+ break;
306
+ case o.FLOAT:
307
+ o.uniform1f(i, e);
308
+ break;
309
+ default:
310
+ console.warn(`Unexpected uniform type for scalar '${t}': ${r}`), o.uniform1f(i, e);
311
+ }
312
+ else if (typeof e == "boolean") o.uniform1i(i, e ? 1 : 0);
293
313
  else if (Array.isArray(e)) if (Array.isArray(e[0])) {
294
- const r = e, n = ((s = r[0]) == null ? void 0 : s.length) || 0, o = r.flat();
295
- switch (n) {
296
- case 2:
297
- this.bt.uniform2fv(i, o);
314
+ const l = e, f = ((c = l[0]) == null ? void 0 : c.length) || 0, u = l.flat();
315
+ switch (r) {
316
+ case o.FLOAT_VEC2:
317
+ f === 2 ? o.uniform2fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 2, got ${f}`);
298
318
  break;
299
- case 3:
300
- this.bt.uniform3fv(i, o);
319
+ case o.FLOAT_VEC3:
320
+ f === 3 ? o.uniform3fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 3, got ${f}`);
301
321
  break;
302
- case 4:
303
- this.bt.uniform4fv(i, o);
322
+ case o.FLOAT_VEC4:
323
+ f === 4 ? o.uniform4fv(i, u) : console.warn(`Vector length mismatch for '${t}': expected 4, got ${f}`);
304
324
  break;
305
325
  default:
306
- return void console.warn(`Unsupported vector array length for '${t}': ${n}`);
326
+ console.warn(`Unsupported uniform type for vector array '${t}': ${r}`);
307
327
  }
308
- } else switch (e.length) {
309
- case 2:
310
- this.bt.uniform2f(i, e[0], e[1]);
328
+ } else switch (r) {
329
+ case o.FLOAT_VEC2:
330
+ e.length === 2 ? o.uniform2f(i, e[0], e[1]) : console.warn(`Vector length mismatch for '${t}': expected 2, got ${e.length}`);
331
+ break;
332
+ case o.FLOAT_VEC3:
333
+ e.length === 3 ? o.uniform3f(i, e[0], e[1], e[2]) : console.warn(`Vector length mismatch for '${t}': expected 3, got ${e.length}`);
311
334
  break;
312
- case 3:
313
- this.bt.uniform3f(i, e[0], e[1], e[2]);
335
+ case o.FLOAT_VEC4:
336
+ e.length === 4 ? o.uniform4f(i, e[0], e[1], e[2], e[3]) : console.warn(`Vector length mismatch for '${t}': expected 4, got ${e.length}`);
314
337
  break;
315
- case 4:
316
- this.bt.uniform4f(i, e[0], e[1], e[2], e[3]);
338
+ case o.INT:
339
+ n > 1 ? o.uniform1iv(i, e) : console.warn(`Array provided for scalar uniform '${t}'`);
340
+ break;
341
+ case o.FLOAT:
342
+ n > 1 ? o.uniform1fv(i, e) : console.warn(`Array provided for scalar uniform '${t}'`);
317
343
  break;
318
344
  default:
319
- return;
345
+ console.warn(`Unsupported uniform type for array '${t}': ${r}`);
320
346
  }
321
347
  else if (e instanceof WebGLTexture) {
322
- const r = this.Qt();
323
- this.bt.uniform1i(i, r), this.bt.activeTexture(this.bt.TEXTURE0 + r), this.bt.bindTexture(this.bt.TEXTURE_2D, e);
324
- } else if (e instanceof G) {
325
- const r = this.Qt();
326
- this.bt.uniform1i(i, r), this.bt.activeTexture(this.bt.TEXTURE0 + r), this.bt.bindTexture(this.bt.TEXTURE_2D, e.textures[0]);
348
+ const l = this.Zt();
349
+ o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e);
350
+ } else if (e instanceof K) {
351
+ const l = this.Zt();
352
+ o.uniform1i(i, l), o.activeTexture(o.TEXTURE0 + l), o.bindTexture(o.TEXTURE_2D, e.textures[0]);
327
353
  } else console.warn(`Unsupported uniform type for '${t}':`, typeof e);
328
354
  }
329
- Qt() {
330
- return this.Ht++;
355
+ Zt() {
356
+ return this.It++;
331
357
  }
332
- get te() {
333
- return this.Ot;
358
+ get Jt() {
359
+ return this.Gt;
334
360
  }
335
- Ut() {
336
- this.bt.deleteProgram(this.Ot);
361
+ Pt() {
362
+ this.vt.deleteProgram(this.Gt);
337
363
  }
338
364
  }
339
- const N = `#version 300 es
340
- in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float k;uniform vec2 t;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float t,vec2 H,vec2 I,vec2 J,vec2 K){float L=1.-t,M=L*L,N=t*t;return M*L*H+3.*M*t*I+3.*L*N*J+N*t*K;}vec2 O(float t,vec2 H,vec2 I,vec2 J,vec2 K){float L=1.-t,M=L*L,N=t*t;return-3.*M*H+3.*M*I-6.*L*t*I+6.*L*t*J-3.*N*J+3.*N*K;}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 P;bool Q=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool R=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(Q){float t=a_position.x;vec2 S=G(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 T=O(t,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float U=length(T);T=U>0.?T/U:vec2(1,0);P=S+vec2(-T.y,T.x)*a_position.y*a_instanceSize.y;}else if(R){float C=a_instanceArcAngles.x,V=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;V=mod(V,6.28318530718);if(V<0.)V+=6.28318530718;float W=C-V;if(W<=0.)W+=6.28318530718;float X=C-a_position.x*W;vec2 Y=vec2(cos(X),sin(X))*a_position.y;P=Y*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{P=a_position*a_instanceSize+a_instancePosition;}vec2 Z=(P/t)*2.-1.;Z.y=-Z.y;if(length(a_instanceGlobalRotation)>0.){vec3 a=vec3(Z-a_instanceRotationCenter,0);a.x*=k;if(a_instanceGlobalRotation.x!=0.)a=A(-a_instanceGlobalRotation.x)*a;if(a_instanceGlobalRotation.y!=0.)a=E(-a_instanceGlobalRotation.y)*a;if(a_instanceGlobalRotation.z!=0.)a=F(-a_instanceGlobalRotation.z)*a;a.x/=k;Z=a.xy+a_instanceRotationCenter;}gl_Position=vec4(Z,0,1);}`;
341
- class it {
365
+ const k = `#version 300 es
366
+ in vec2 a_position;in vec2 a_texCoord;in vec2 a_instancePosition;in vec2 a_instanceSize;in vec3 a_instanceCharacter;in vec4 a_instancePrimaryColor;in vec4 a_instanceSecondaryColor;in vec2 a_instanceRotation;in vec3 a_instanceTransform;in vec3 a_instanceGlobalRotation;in vec2 a_instanceRotationCenter;in vec2 a_instanceBezierCP1;in vec2 a_instanceBezierCP2;in vec2 a_instanceBezierStart;in vec2 a_instanceBezierEnd;in vec2 a_instanceArcAngles;uniform float U9;uniform vec2 Uw;out vec2 v_uv;out vec3 v_character;out vec4 v_primaryColor;out vec4 v_secondaryColor;out vec2 v_rotation;out vec3 v_transform;mat3 A(float B){float C=sin(B),D=cos(B);return mat3(1,0,0,0,D,-C,0,C,D);}mat3 E(float B){float C=sin(B),D=cos(B);return mat3(D,0,C,0,1,0,-C,0,D);}mat3 F(float B){float C=sin(B),D=cos(B);return mat3(D,-C,0,C,D,0,0,0,1);}vec2 G(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return N*M*I+3.*N*H*J+3.*M*O*K+O*H*L;}vec2 P(float H,vec2 I,vec2 J,vec2 K,vec2 L){float M=1.-H,N=M*M,O=H*H;return-3.*N*I+3.*N*J-6.*M*H*J+6.*M*H*K-3.*O*K+3.*O*L;}void main(){v_uv=a_texCoord;v_character=a_instanceCharacter;v_primaryColor=a_instancePrimaryColor;v_secondaryColor=a_instanceSecondaryColor;v_rotation=a_instanceRotation;v_transform=a_instanceTransform;vec2 Q;bool R=length(a_instanceBezierCP1)+length(a_instanceBezierCP2)+length(a_instanceBezierStart)+length(a_instanceBezierEnd)>0.;bool S=a_instanceArcAngles.x!=0.||a_instanceArcAngles.y!=0.;if(R){float H=a_position.x;vec2 T=G(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);vec2 U=P(H,a_instanceBezierStart,a_instanceBezierCP1,a_instanceBezierCP2,a_instanceBezierEnd);float V=length(U);U=V>0.?U/V:vec2(1,0);Q=T+vec2(-U.y,U.x)*a_position.y*a_instanceSize.y;}else if(S){float C=a_instanceArcAngles.x,W=a_instanceArcAngles.y;C=mod(C,6.28318530718);if(C<0.)C+=6.28318530718;W=mod(W,6.28318530718);if(W<0.)W+=6.28318530718;float X=C-W;if(X<=0.)X+=6.28318530718;float Y=C-a_position.x*X;vec2 Z=vec2(cos(Y),sin(Y))*a_position.y;Q=Z*a_instanceSize*.5+a_instanceSize*.5+a_instancePosition;}else{Q=a_position*a_instanceSize+a_instancePosition;}vec2 a=(Q/Uw)*2.-1.;a.y=-a.y;if(length(a_instanceGlobalRotation)>0.){vec3 b=vec3(a-a_instanceRotationCenter,0);b.x*=U9;if(a_instanceGlobalRotation.x!=0.)b=A(-a_instanceGlobalRotation.x)*b;if(a_instanceGlobalRotation.y!=0.)b=E(-a_instanceGlobalRotation.y)*b;if(a_instanceGlobalRotation.z!=0.)b=F(-a_instanceGlobalRotation.z)*b;b.x/=U9;a=b.xy+a_instanceRotationCenter;}gl_Position=vec4(a,0,1);}`, at = "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}";
367
+ class ft {
342
368
  constructor(t) {
343
- h(this, "ee", /* @__PURE__ */ new Map());
344
- h(this, "bt");
345
- this.bt = t;
346
- }
347
- se(t, e) {
348
- if (!this.ee.has(t)) {
349
- const i = e();
350
- this.ee.set(t, i);
351
- }
352
- return this.ee.get(t);
369
+ a(this, "vt");
370
+ a(this, "Qt");
371
+ a(this, "te");
372
+ a(this, "ee");
373
+ a(this, "se");
374
+ this.vt = t, this.te = new M(this.vt, k, `#version 300 es
375
+ precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`), this.Qt = new M(this.vt, k, `#version 300 es
376
+ precision highp float;in vec2 v_uv;uniform sampler2D Ue;uniform sampler2D Uf;uniform sampler2D Ug;uniform sampler2D Uh;uniform sampler2D Ui;uniform vec2 Uj;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*Uj;vec2 C=(floor(B)+0.5f)/Uj;vec4 D=texture(Ue,C);vec4 E=texture(Uf,C);if(E.a==0.){discard;}vec4 F=texture(Ug,C);vec4 G=texture(Uh,C);vec4 H=texture(Ui,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`), this.ee = new M(this.vt, at, "precision mediump float;uniform sampler2D U0;uniform vec2 U1;uniform sampler2D U3;uniform sampler2D U4;uniform sampler2D U5;uniform sampler2D U2;uniform sampler2D U6;uniform vec2 U7;uniform vec2 U8;mat2 A(float B){float C=sin(B);float D=cos(B);return mat2(D,-C,C,D);}void main(){vec2 E=gl_FragCoord.xy/U8;vec2 F=E*U7;vec2 G=floor(F);vec2 H=(G+0.5)/U7;vec4 I=texture2D(U3,H);vec4 J=texture2D(U4,H);vec4 K=texture2D(U5,H);bool L=K.r>0.5;bool M=K.g>0.5;bool N=K.b>0.5;vec4 O=texture2D(U2,H);int P=int(O.r*255.+0.5)+int(O.g*255.+0.5)*256;int Q=int(mod(float(P),U1.x));int R=P/int(U1.x);float S=(U1.y-1.)-float(R);vec2 T=vec2(float(Q),S)/U1;vec4 U=texture2D(U6,H);float V=U.r*255.+U.g;float W=-(V*360./255.)*0.017453292;vec2 X=fract(F)-0.5;if(M)X.x=-X.x;if(N)X.y=-X.y;X=A(W)*X+0.5;vec2 Y=1./U1;vec2 Z=T+X*Y;vec2 a=T+Y;if(any(lessThan(Z,T))||any(greaterThan(Z,a))){gl_FragColor=L?I:J;return;}vec4 b=texture2D(U0,Z);if(L)b.rgb=1.-b.rgb;gl_FragColor=mix(J,I,b);}"), this.se = new M(this.vt, k, `#version 300 es
377
+ precision highp float;in vec2 v_uv;uniform sampler2D Uk;uniform bool Ul;uniform bool Um;uniform bool Un;uniform vec2 Uo;uniform bool Up;uniform vec3 Uq;uniform bool Ur;uniform vec3 Us;uniform vec4 Ut;uniform int Uu;uniform vec3 Uv[64];layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;float A(vec3 B){return dot(B,vec3(0.299,0.587,0.114));}void main(){vec2 C=vec2(v_uv.x,1.-v_uv.y);vec4 D=texture(Uk,C);float E=A(D.rgb);if(Uu>0){float F=float(Uu);float G=clamp(E*(F-1.),0.,F-1.);int H=int(floor(G+0.5));vec3 I=Uv[H];o_character=vec4(I,1.);}else{o_character=vec4(E,0.,0.,1.);}vec3 J=D.rgb;vec3 K=Up?Uq:J;vec3 L=Ur?Us:J;float M=Up?1.:D.a;float N;if(D.a<0.01){K=Ut.rgb;L=Ut.rgb;M=Ut.a;N=Ut.a;}else{N=Ur?1.:D.a;}o_primaryColor=vec4(K,M);o_secondaryColor=vec4(L,N);o_rotation=vec4(Uo.xy,0.,1.);o_transform=vec4(float(Ul),float(Um),float(Un),1.);}`);
353
378
  }
354
379
  ie() {
355
- return this.se("mrt-copy", () => new M(this.bt, N, `#version 300 es
356
- precision highp float;in vec2 v_uv;uniform sampler2D l;uniform sampler2D m;uniform sampler2D n;uniform sampler2D o;uniform sampler2D p;uniform vec2 q;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){vec2 A=vec2(v_uv.x,1.-v_uv.y);vec2 B=A*q;vec2 C=(floor(B)+0.5f)/q;vec4 D=texture(l,C);vec4 E=texture(m,C);if(E.a==0.){discard;}vec4 F=texture(n,C);vec4 G=texture(o,C);vec4 H=texture(p,C);o_character=D;o_primaryColor=E;o_secondaryColor=F;o_rotation=G;o_transform=H;}`));
380
+ return this.Qt;
357
381
  }
358
- Bt() {
359
- return this.se("mrt-draw", () => new M(this.bt, N, `#version 300 es
360
- precision highp float;in vec2 v_uv;in vec3 v_character;in vec4 v_primaryColor;in vec4 v_secondaryColor;in vec2 v_rotation;in vec3 v_transform;layout(location=0)out vec4 o_character;layout(location=1)out vec4 o_primaryColor;layout(location=2)out vec4 o_secondaryColor;layout(location=3)out vec4 o_rotation;layout(location=4)out vec4 o_transform;void main(){o_character=vec4(v_character,1.);o_primaryColor=v_primaryColor;o_secondaryColor=v_secondaryColor;o_rotation=vec4(v_rotation,0.,1.);o_transform=vec4(v_transform,1.);}`));
382
+ Tt() {
383
+ return this.te;
361
384
  }
362
385
  re() {
363
- return this.se("ascii-conversion", () => new M(this.bt, "attribute vec2 a_position;attribute vec2 a_texCoord;varying vec2 v_uv;void main(){v_uv=a_texCoord;gl_Position=vec4(a_position,0.,1.);}", "precision mediump float;uniform sampler2D a;uniform vec2 b;uniform sampler2D d;uniform sampler2D e;uniform sampler2D f;uniform sampler2D c;uniform sampler2D g;uniform vec2 h;uniform vec2 i;uniform vec2 j;mat2 A(float B){float C=sin(B);float c=cos(B);return mat2(c,-C,C,c);}void main(){vec2 D=(gl_FragCoord.xy-j)/i;vec2 E=D*h;vec2 F=floor(E);vec2 G=(F+0.5)/h;vec4 H=texture2D(d,G);vec4 I=texture2D(e,G);vec4 J=texture2D(f,G);bool K=J.r>0.5;bool L=J.g>0.5;bool M=J.b>0.5;vec4 N=texture2D(c,G);int O=int(N.r*255.+0.5)+int(N.g*255.+0.5)*256;int P=int(mod(float(O),b.x));int Q=O/int(b.x);float R=(b.y-1.)-float(Q);vec2 S=vec2(float(P),R)/b;vec4 T=texture2D(g,G);float U=T.r*255.+T.g;float V=-(U*360./255.)*0.017453292;vec2 W=fract(E)-0.5;if(L)W.x=-W.x;if(M)W.y=-W.y;W=A(V)*W+0.5;vec2 X=1./b;vec2 Y=S+W*X;vec2 Z=S+X;if(any(lessThan(Y,S))||any(greaterThan(Y,Z))){gl_FragColor=K?H:I;return;}vec4 a=texture2D(a,Y);if(K)a.rgb=1.-a.rgb;gl_FragColor=mix(I,H,a);}"));
386
+ return this.ee;
364
387
  }
365
- ne(t) {
366
- return new M(this.bt, N, t);
388
+ ne() {
389
+ return this.se;
367
390
  }
368
- oe(t, e) {
369
- return new M(this.bt, t, e);
391
+ oe(t) {
392
+ return new M(this.vt, k, t);
370
393
  }
371
- Ut() {
372
- for (const t of this.ee.values()) t.Ut();
373
- this.ee.clear();
394
+ ae(t, e) {
395
+ return new M(this.vt, t, e);
396
+ }
397
+ Pt() {
398
+ this.Qt.Pt(), this.te.Pt(), this.ee.Pt(), this.se.Pt();
374
399
  }
375
400
  }
376
- var b = ((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))(b || {});
377
- class st {
401
+ var w = ((h) => (h.RECTANGLE = "rectangle", h.LINE = "line", h.ELLIPSE = "ellipse", h.ARC = "arc", h.TRIANGLE = "triangle", h.BEZIER_CURVE = "bezier_curve", h.CUSTOM = "custom", h))(w || {});
402
+ class dt {
378
403
  constructor(t) {
379
- h(this, "bt");
380
- h(this, "ae", /* @__PURE__ */ new Map());
381
- this.bt = t;
382
- }
383
- he(t, e, i, s) {
384
- const r = this.bt;
385
- let n = this.ae.get(t);
386
- n || (n = /* @__PURE__ */ new Map(), this.ae.set(t, n));
404
+ a(this, "vt");
405
+ a(this, "he", /* @__PURE__ */ new Map());
406
+ this.vt = t;
407
+ }
408
+ ce(t, e, i, s) {
409
+ const r = this.vt;
410
+ let n = this.he.get(t);
411
+ n || (n = /* @__PURE__ */ new Map(), this.he.set(t, n));
387
412
  let o = n.get(e) || null;
388
413
  if (!o) {
389
414
  o = r.createVertexArray(), n.set(e, o), r.bindVertexArray(o), r.bindBuffer(r.ARRAY_BUFFER, s);
390
415
  const c = r.getAttribLocation(t, "a_position");
391
- c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.le.ce.size, r.FLOAT, !1, i.ue, i.le.ce.offset), r.vertexAttribDivisor(c, 0));
416
+ c !== -1 && (r.enableVertexAttribArray(c), r.vertexAttribPointer(c, i.ue.le.size, r.FLOAT, !1, i.fe, i.ue.le.offset), r.vertexAttribDivisor(c, 0));
392
417
  const l = r.getAttribLocation(t, "a_texCoord");
393
- l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.le.fe.size, r.FLOAT, !1, i.ue, i.le.fe.offset), r.vertexAttribDivisor(l, 0));
418
+ l !== -1 && (r.enableVertexAttribArray(l), r.vertexAttribPointer(l, i.ue.de.size, r.FLOAT, !1, i.fe, i.ue.de.offset), r.vertexAttribDivisor(l, 0));
394
419
  }
395
420
  r.bindVertexArray(o);
396
421
  }
397
- de() {
398
- this.bt.bindVertexArray(null);
422
+ _e() {
423
+ this.vt.bindVertexArray(null);
399
424
  }
400
- Ut() {
401
- const t = this.bt;
402
- for (const [, e] of this.ae) for (const [, i] of e) i && t.deleteVertexArray(i);
403
- this.ae.clear();
425
+ Pt() {
426
+ for (const [, t] of this.he) for (const [, e] of t) e && this.vt.deleteVertexArray(e);
404
427
  }
405
428
  }
406
- class rt {
429
+ class gt {
407
430
  constructor(t, e) {
408
- h(this, "_e");
409
- h(this, "bt");
410
- h(this, "Pt");
411
- h(this, "pe", null);
412
- h(this, "ge", null);
413
- this.bt = t, this._e = new st(t), this.Pt = e;
414
- }
415
- me(t, e, i) {
416
- const { shader: s } = t, r = B(this.bt) || this.bt.getParameter(this.bt.VIEWPORT);
417
- s.qt({ k: r[2] / r[3], t: [r[2], r[3]] });
431
+ a(this, "pe");
432
+ a(this, "vt");
433
+ a(this, "xt");
434
+ a(this, "me", null);
435
+ a(this, "ge", null);
436
+ this.vt = t, this.pe = new dt(t), this.xt = e;
437
+ }
438
+ ve(t, e, i) {
439
+ const { shader: s } = t, r = X(this.vt) || this.vt.getParameter(this.vt.VIEWPORT);
440
+ s.Nt({ U9: r[2] / r[3], Uw: [r[2], r[3]] });
418
441
  const n = (l) => {
419
- if (!l || !l.ve()) return;
442
+ if (!l || !l.ye()) return;
420
443
  const f = l.unitGeometry, u = l.unitBuffer;
421
444
  try {
422
- this._e.he(s.te, l.type + "", f, u), l.batch.ye(s), l.batch.Ce(f.$e, f.we);
445
+ this.pe.ce(s.Jt, l.type + "", f, u), l.batch.Ce(s), l.batch.we(f.$e, f.be);
423
446
  } finally {
424
- l.batch.xe(s), this._e.de(), l.be();
447
+ l.batch.xe(s), this.pe._e(), l.Fe();
425
448
  }
426
449
  };
427
450
  let o = null, c = null;
428
451
  for (const l of e) {
429
- if (l.type === b.CUSTOM) {
430
- c && (n(c), o = null, c = null), this.Re(t, l.params, l.state, i.get(b.RECTANGLE));
452
+ if (l.type === w.CUSTOM) {
453
+ c && (n(c), o = null, c = null), this.Me(t, l.params, l.state, i.get(w.RECTANGLE));
431
454
  continue;
432
455
  }
433
456
  o !== null && l.type !== o && (n(c), o = null, c = null);
434
457
  let f = c;
435
- f && l.type === o || (f = i.get(l.type) || null, c = f, o = l.type), f && f.Me(l.params, l.state);
458
+ f && l.type === o || (f = i.get(l.type) || null, c = f, o = l.type), f && f.Re(l.params, l.state);
436
459
  }
437
460
  n(c);
438
461
  }
439
- Re(t, e, i, s) {
440
- const { x: r, y: n, width: o, height: c, shader: l, uniforms: f } = e;
441
- if (l === this.Se()) return this.Fe(s, l, f, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), void t.shader.jt();
442
- const u = this.ze(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
443
- u.begin(), this.Fe(s, l, f, 0, 0, u.width, u.height, {}), u.end();
444
- const d = this.Se(), p = { l: u.textures[0], m: u.textures[1], n: u.textures[2], o: u.textures[3], p: u.textures[4], q: [u.width, u.height] };
445
- this.Fe(s, d, p, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.jt();
446
- }
447
- Fe(t, e, i, s, r, n, o, c) {
448
- e.jt(), e.qt(i);
449
- const l = this.bt.getParameter(this.bt.VIEWPORT);
450
- if (e.qt({ k: l[2] / l[3], t: [l[2], l[3]] }), t.be(), t.Me({ x: s, y: r, width: n, height: o }, c), t.ve()) {
462
+ Me(t, e, i, s) {
463
+ const { x: r, y: n, width: o, height: c, shader: l, uniforms: f } = e, u = this.Se(Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)));
464
+ u.begin(), this.Ae(s, l, f, 0, 0, u.width, u.height, {}), u.end();
465
+ const g = this.ze(), v = { Ue: u.textures[0], Uf: u.textures[1], Ug: u.textures[2], Uh: u.textures[3], Ui: u.textures[4], Uj: [u.width, u.height] };
466
+ this.Ae(s, g, v, Math.floor(r), Math.floor(n), Math.max(1, Math.floor(o)), Math.max(1, Math.floor(c)), i), t.shader.Vt();
467
+ }
468
+ Ae(t, e, i, s, r, n, o, c) {
469
+ e.Vt(), e.Nt(i);
470
+ const l = this.vt.getParameter(this.vt.VIEWPORT);
471
+ if (e.Nt({ U9: l[2] / l[3], Uw: [l[2], l[3]] }), t.Fe(), t.Re({ x: s, y: r, width: n, height: o }, c), t.ye()) {
451
472
  const f = t.unitGeometry, u = t.unitBuffer;
452
473
  try {
453
- this._e.he(e.te, t.type + "", f, u), t.batch.ye(e), t.batch.Ce(f.$e, f.we);
474
+ this.pe.ce(e.Jt, t.type + "", f, u), t.batch.Ce(e), t.batch.we(f.$e, f.be);
454
475
  } finally {
455
- t.batch.xe(e), this._e.de(), t.be();
476
+ t.batch.xe(e), this.pe._e(), t.Fe();
456
477
  }
457
478
  }
458
479
  }
459
- Se() {
460
- return this.Pt.ie();
480
+ ze() {
481
+ return this.xt.ie();
461
482
  }
462
- ze(t, e) {
463
- return this.pe && this.ge && this.ge.w === t && this.ge.h === e || (this.pe && this.pe.Ut(), this.pe = new G(this.bt, t, e, 5), this.ge = { w: t, h: e }), this.pe;
483
+ Se(t, e) {
484
+ return this.me && this.ge && this.ge.w === t && this.ge.h === e || (this.me && this.me.Pt(), this.me = new K(this.vt, t, e, 5), this.ge = { w: t, h: e }), this.me;
485
+ }
486
+ Pt() {
487
+ this.pe.Pt(), this.me && this.me.Pt();
464
488
  }
465
489
  }
466
- class nt {
490
+ class pt {
467
491
  constructor() {
468
- h(this, "Pe", []);
469
- h(this, "ke", 1);
470
- h(this, "Te", 0);
471
- }
472
- Ge(t) {
473
- if (this.Te >= this.Pe.length) {
474
- const i = { id: this.ke++, type: t, params: {}, state: { X: 1, Y: 0, Z: 0, J: 0, character: [0, 0, 0], charColor: [1, 1, 1, 1], bgColor: [0, 0, 0, 1], flipHorizontally: !1, flipVertically: !1, invert: !1, charRotation: [0, 0] } };
475
- this.Pe.push(i);
476
- }
477
- const e = this.Pe[this.Te];
478
- switch (e.id = this.ke++, e.type = t, t) {
479
- case b.RECTANGLE:
480
- case b.ELLIPSE:
481
- e.params && "width" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0 });
482
- break;
483
- case b.CUSTOM:
484
- e.params && "shader" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, shader: void 0, uniforms: {} });
485
- break;
486
- case b.ARC:
487
- e.params && "start" in e.params || (e.params = { x: 0, y: 0, width: 0, height: 0, start: 0, stop: 0 });
488
- break;
489
- case b.LINE:
490
- e.params && "x2" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, thickness: void 0 });
491
- break;
492
- case b.TRIANGLE:
493
- e.params && "x3" in e.params || (e.params = { x1: 0, y1: 0, x2: 0, y2: 0, x3: 0, y3: 0 });
494
- break;
495
- case b.BEZIER_CURVE:
496
- e.params && "cp2y" in e.params || (e.params = { x1: 0, y1: 0, cp1x: 0, cp1y: 0, cp2x: 0, cp2y: 0, x2: 0, y2: 0, thickness: void 0 });
497
- break;
498
- default:
499
- e.params || (e.params = {});
492
+ a(this, "Te", []);
493
+ a(this, "Ee", 1);
494
+ a(this, "Le", 0);
495
+ }
496
+ ke(t) {
497
+ if (this.Le >= this.Te.length) {
498
+ const i = { id: this.Ee++, type: t, params: {}, state: { O: 1, H: 0, V: 0, K: 0, j: [0, 0, 0], Y: [1, 1, 1, 1], q: [0, 0, 0, 1], N: !1, X: !1, P: !1, G: [0, 0] } };
499
+ this.Te.push(i);
500
500
  }
501
- return this.Te++, e;
501
+ const e = this.Te[this.Le];
502
+ return e.id = this.Ee++, e.type = t, this.Le++, e;
502
503
  }
503
- Ae(t, e, i, s, r) {
504
- const n = this.Ge(b.RECTANGLE);
505
- return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.nt(n.state), n.id;
504
+ Pe(t, e, i, s, r) {
505
+ const n = this.ke(w.RECTANGLE);
506
+ return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
506
507
  }
507
- Le(t, e, i, s, r, n, o) {
508
- const c = this.Ge(b.CUSTOM);
509
- return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.shader = r, c.params.uniforms = n, o.nt(c.state), c.id;
508
+ Ge(t, e, i, s, r, n, o) {
509
+ const c = this.ke(w.CUSTOM);
510
+ return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.shader = r, c.params.uniforms = n, o.J(c.state), c.id;
510
511
  }
511
- Ee(t, e, i, s, r, n) {
512
- const o = this.Ge(b.LINE);
513
- return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.nt(o.state), o.id;
512
+ Be(t, e, i, s, r, n) {
513
+ const o = this.ke(w.LINE);
514
+ return o.params.x1 = t, o.params.y1 = e, o.params.x2 = i, o.params.y2 = s, o.params.thickness = r, n.J(o.state), o.id;
514
515
  }
515
- Be(t, e, i, s, r) {
516
- const n = this.Ge(b.ELLIPSE);
517
- return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.nt(n.state), n.id;
516
+ De(t, e, i, s, r) {
517
+ const n = this.ke(w.ELLIPSE);
518
+ return n.params.x = t, n.params.y = e, n.params.width = i, n.params.height = s, r.J(n.state), n.id;
518
519
  }
519
- De(t, e, i, s, r, n, o) {
520
- const c = this.Ge(b.ARC);
521
- return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.start = r, c.params.stop = n, o.nt(c.state), c.id;
520
+ Ie(t, e, i, s, r, n, o) {
521
+ const c = this.ke(w.ARC);
522
+ return c.params.x = t, c.params.y = e, c.params.width = i, c.params.height = s, c.params.start = r, c.params.stop = n, o.J(c.state), c.id;
522
523
  }
523
524
  We(t, e, i, s, r, n, o) {
524
- const c = this.Ge(b.TRIANGLE);
525
- return c.params.x1 = t, c.params.y1 = e, c.params.x2 = i, c.params.y2 = s, c.params.x3 = r, c.params.y3 = n, o.nt(c.state), c.id;
525
+ const c = this.ke(w.TRIANGLE);
526
+ return c.params.x1 = t, c.params.y1 = e, c.params.x2 = i, c.params.y2 = s, c.params.x3 = r, c.params.y3 = n, o.J(c.state), c.id;
526
527
  }
527
- Ie(t, e, i, s, r, n, o, c, l, f) {
528
- const u = this.Ge(b.BEZIER_CURVE);
529
- return u.params.x1 = t, u.params.y1 = e, u.params.cp1x = i, u.params.cp1y = s, u.params.cp2x = r, u.params.cp2y = n, u.params.x2 = o, u.params.y2 = c, u.params.thickness = l, f.nt(u.state), u.id;
528
+ Oe(t, e, i, s, r, n, o, c, l, f) {
529
+ const u = this.ke(w.BEZIER_CURVE);
530
+ return u.params.x1 = t, u.params.y1 = e, u.params.cp1x = i, u.params.cp1y = s, u.params.cp2x = r, u.params.cp2y = n, u.params.x2 = o, u.params.y2 = c, u.params.thickness = l, f.J(u.state), u.id;
530
531
  }
531
532
  get length() {
532
- return this.Te;
533
+ return this.Le;
533
534
  }
534
535
  get isEmpty() {
535
- return this.Te === 0;
536
+ return this.Le === 0;
536
537
  }
537
- Ue() {
538
- this.Te = 0;
538
+ He() {
539
+ this.Le = 0;
539
540
  }
540
541
  [Symbol.iterator]() {
541
542
  let t = 0;
542
- const e = this.Te, i = this.Pe;
543
+ const e = this.Le, i = this.Te;
543
544
  return { next: () => t < e ? { value: i[t++], done: !1 } : { value: void 0, done: !0 } };
544
545
  }
545
546
  }
546
- const T = class T {
547
- static Oe(t, e, i = 0) {
548
- var n, o, c, l, f, u, d, p, g, m;
549
- const s = e || new Float32Array(T.FLOATS_PER_INSTANCE);
547
+ const P = class P {
548
+ static Ve(t, e, i = 0) {
549
+ var n, o, c, l, f, u, g, v, m, d;
550
+ const s = e || new Float32Array(P.FLOATS_PER_INSTANCE);
550
551
  let r = i;
551
- return s[r++] = t.position[0], s[r++] = t.position[1], s[r++] = t.size[0], s[r++] = t.size[1], s[r++] = t.tt[0], s[r++] = t.tt[1], s[r++] = t.tt[2], s[r++] = t.primaryColor[0], s[r++] = t.primaryColor[1], s[r++] = t.primaryColor[2], s[r++] = t.primaryColor[3], s[r++] = t.secondaryColor[0], s[r++] = t.secondaryColor[1], s[r++] = t.secondaryColor[2], s[r++] = t.secondaryColor[3], s[r++] = t.rotation[0], s[r++] = t.rotation[1], s[r++] = t.transform[0], s[r++] = t.transform[1], s[r++] = t.transform[2], s[r++] = t.globalRotationX, s[r++] = t.globalRotationY, s[r++] = t.globalRotationZ, s[r++] = t.rotationCenter[0], s[r++] = t.rotationCenter[1], s[r++] = ((n = t.arcAngles) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.arcAngles) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.bezierControlPoint1) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.bezierControlPoint1) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.bezierControlPoint2) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.bezierControlPoint2) == null ? void 0 : u[1]) || 0, s[r++] = ((d = t.bezierStartPoint) == null ? void 0 : d[0]) || 0, s[r++] = ((p = t.bezierStartPoint) == null ? void 0 : p[1]) || 0, s[r++] = ((g = t.bezierEndPoint) == null ? void 0 : g[0]) || 0, s[r++] = ((m = t.bezierEndPoint) == null ? void 0 : m[1]) || 0, s;
552
+ return s[r++] = t.le[0], s[r++] = t.le[1], s[r++] = t.Le[0], s[r++] = t.Le[1], s[r++] = t.j[0], s[r++] = t.j[1], s[r++] = t.j[2], s[r++] = t.Y[0], s[r++] = t.Y[1], s[r++] = t.Y[2], s[r++] = t.Y[3], s[r++] = t.q[0], s[r++] = t.q[1], s[r++] = t.q[2], s[r++] = t.q[3], s[r++] = t.G[0], s[r++] = t.G[1], s[r++] = t.Ke[0], s[r++] = t.Ke[1], s[r++] = t.Ke[2], s[r++] = t.H, s[r++] = t.V, s[r++] = t.K, s[r++] = t.Ne[0], s[r++] = t.Ne[1], s[r++] = ((n = t.Xe) == null ? void 0 : n[0]) || 0, s[r++] = ((o = t.Xe) == null ? void 0 : o[1]) || 0, s[r++] = ((c = t.je) == null ? void 0 : c[0]) || 0, s[r++] = ((l = t.je) == null ? void 0 : l[1]) || 0, s[r++] = ((f = t.Ye) == null ? void 0 : f[0]) || 0, s[r++] = ((u = t.Ye) == null ? void 0 : u[1]) || 0, s[r++] = ((g = t.qe) == null ? void 0 : g[0]) || 0, s[r++] = ((v = t.qe) == null ? void 0 : v[1]) || 0, s[r++] = ((m = t.Ze) == null ? void 0 : m[0]) || 0, s[r++] = ((d = t.Ze) == null ? void 0 : d[1]) || 0, s;
552
553
  }
553
- static Ve(t) {
554
- const e = t.length * T.FLOATS_PER_INSTANCE, i = new Float32Array(e);
554
+ static Je(t) {
555
+ const e = t.length * P.FLOATS_PER_INSTANCE, i = new Float32Array(e);
555
556
  for (let s = 0; s < t.length; s++) {
556
- const r = s * T.FLOATS_PER_INSTANCE;
557
- T.Oe(t[s], i, r);
557
+ const r = s * P.FLOATS_PER_INSTANCE;
558
+ P.Ve(t[s], i, r);
558
559
  }
559
560
  return i;
560
561
  }
561
562
  };
562
- h(T, "BYTES_PER_INSTANCE", 140), h(T, "FLOATS_PER_INSTANCE", 35);
563
- let P = T;
564
- const y = class y {
563
+ a(P, "BYTES_PER_INSTANCE", 140), a(P, "FLOATS_PER_INSTANCE", 35);
564
+ let B = P;
565
+ const T = class T {
565
566
  };
566
- h(y, "STRIDE", P.BYTES_PER_INSTANCE), h(y, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: y.STRIDE, offset: 132, divisor: 1 } });
567
- let D = y;
568
- class ot {
567
+ a(T, "STRIDE", B.BYTES_PER_INSTANCE), a(T, "ATTRIBUTES", { a_instancePosition: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 0, divisor: 1 }, a_instanceSize: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 8, divisor: 1 }, a_instanceCharacter: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 16, divisor: 1 }, a_instancePrimaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 28, divisor: 1 }, a_instanceSecondaryColor: { location: -1, size: 4, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 44, divisor: 1 }, a_instanceRotation: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 60, divisor: 1 }, a_instanceTransform: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 68, divisor: 1 }, a_instanceGlobalRotation: { location: -1, size: 3, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 80, divisor: 1 }, a_instanceRotationCenter: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 92, divisor: 1 }, a_instanceArcAngles: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 100, divisor: 1 }, a_instanceBezierCP1: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 108, divisor: 1 }, a_instanceBezierCP2: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 116, divisor: 1 }, a_instanceBezierStart: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 124, divisor: 1 }, a_instanceBezierEnd: { location: -1, size: 2, type: WebGL2RenderingContext.FLOAT, normalized: !1, stride: T.STRIDE, offset: 132, divisor: 1 } });
568
+ let H = T;
569
+ class mt {
569
570
  constructor(t, e = 1e3, i = 1.5) {
570
- h(this, "bt");
571
- h(this, "He", []);
572
- h(this, "Ke");
573
- h(this, "Ne");
574
- h(this, "Xe", null);
575
- h(this, "je", !0);
576
- h(this, "Ye", 0);
577
- h(this, "qe", /* @__PURE__ */ new Map());
578
- h(this, "Ze", null);
579
- this.bt = t, this.Ke = e, this.Ne = i, this.Je();
580
- }
581
- Me(t) {
582
- const e = this.He.length;
583
- return this.He.push(t), this.je = !0, e;
571
+ a(this, "vt");
572
+ a(this, "Qe", []);
573
+ a(this, "ts");
574
+ a(this, "es");
575
+ a(this, "ss", null);
576
+ a(this, "rs", !0);
577
+ a(this, "ns", 0);
578
+ a(this, "hs", /* @__PURE__ */ new Map());
579
+ a(this, "cs", null);
580
+ this.vt = t, this.ts = e, this.es = i, this.ls();
581
+ }
582
+ Re(t) {
583
+ const e = this.Qe.length;
584
+ return this.Qe.push(t), this.rs = !0, e;
584
585
  }
585
586
  get count() {
586
- return this.He.length;
587
+ return this.Qe.length;
587
588
  }
588
589
  get isEmpty() {
589
- return this.He.length === 0;
590
+ return this.Qe.length === 0;
590
591
  }
591
592
  clear() {
592
- this.He.length = 0, this.je = !0;
593
- }
594
- Qe(t) {
595
- if (t <= this.Ke) return;
596
- const e = Math.ceil(t * this.Ne);
597
- this.Ke = e, this.Je();
598
- }
599
- Je() {
600
- const t = this.bt;
601
- this.Xe && t.deleteBuffer(this.Xe), this.Xe = t.createBuffer();
602
- const e = this.Ke * P.BYTES_PER_INSTANCE;
603
- t.bindBuffer(t.ARRAY_BUFFER, this.Xe), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.je = !0, this.Ye = 0;
604
- }
605
- ts() {
606
- if (!this.je || this.He.length === 0) return;
607
- const t = this.bt, e = this.He.length;
608
- this.Qe(e), (!this.Ze || this.Ze.length < e * P.FLOATS_PER_INSTANCE) && (this.Ze = new Float32Array(e * P.FLOATS_PER_INSTANCE));
609
- const i = P.Ve(this.He);
610
- t.bindBuffer(t.ARRAY_BUFFER, this.Xe), e <= this.Ye ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.je = !1, this.Ye = e;
611
- }
612
- es(t) {
613
- let e = this.qe.get(t);
593
+ this.Qe.length = 0, this.rs = !0;
594
+ }
595
+ us(t) {
596
+ if (t <= this.ts) return;
597
+ const e = Math.ceil(t * this.es);
598
+ this.ts = e, this.ls();
599
+ }
600
+ ls() {
601
+ const t = this.vt;
602
+ this.ss && t.deleteBuffer(this.ss), this.ss = t.createBuffer();
603
+ const e = this.ts * B.BYTES_PER_INSTANCE;
604
+ t.bindBuffer(t.ARRAY_BUFFER, this.ss), t.bufferData(t.ARRAY_BUFFER, e, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.rs = !0, this.ns = 0;
605
+ }
606
+ fs() {
607
+ if (!this.rs || this.Qe.length === 0) return;
608
+ const t = this.vt, e = this.Qe.length;
609
+ this.us(e), (!this.cs || this.cs.length < e * B.FLOATS_PER_INSTANCE) && (this.cs = new Float32Array(e * B.FLOATS_PER_INSTANCE));
610
+ const i = B.Je(this.Qe);
611
+ t.bindBuffer(t.ARRAY_BUFFER, this.ss), e <= this.ns ? t.bufferSubData(t.ARRAY_BUFFER, 0, i) : t.bufferData(t.ARRAY_BUFFER, i, t.DYNAMIC_DRAW), t.bindBuffer(t.ARRAY_BUFFER, null), this.rs = !1, this.ns = e;
612
+ }
613
+ ds(t) {
614
+ let e = this.hs.get(t);
614
615
  if (!e) {
615
616
  e = /* @__PURE__ */ new Map();
616
- const i = this.bt;
617
- for (const s in D.ATTRIBUTES) {
617
+ const i = this.vt;
618
+ for (const s in H.ATTRIBUTES) {
618
619
  const r = i.getAttribLocation(t, s);
619
620
  r !== -1 && e.set(s, r);
620
621
  }
621
- this.qe.set(t, e);
622
+ this.hs.set(t, e);
622
623
  }
623
624
  return e;
624
625
  }
625
- ye(t) {
626
- if (!this.Xe || this.He.length === 0) return;
627
- const e = this.bt, i = t.te;
628
- this.ts();
629
- const s = this.es(i);
630
- e.bindBuffer(e.ARRAY_BUFFER, this.Xe);
626
+ Ce(t) {
627
+ if (!this.ss || this.Qe.length === 0) return;
628
+ const e = this.vt, i = t.Jt;
629
+ this.fs();
630
+ const s = this.ds(i);
631
+ e.bindBuffer(e.ARRAY_BUFFER, this.ss);
631
632
  for (const [r, n] of s) {
632
- const o = D.ATTRIBUTES[r];
633
+ const o = H.ATTRIBUTES[r];
633
634
  o && (e.enableVertexAttribArray(n), e.vertexAttribPointer(n, o.size, o.type, o.normalized, o.stride, o.offset), e.vertexAttribDivisor(n, o.divisor));
634
635
  }
635
636
  }
636
637
  xe(t) {
637
- const e = this.bt, i = this.es(t.te);
638
+ const e = this.vt, i = this.ds(t.Jt);
638
639
  for (const [, s] of i) e.disableVertexAttribArray(s), e.vertexAttribDivisor(s, 0);
639
640
  }
640
- Ce(t, e) {
641
- this.He.length !== 0 && this.bt.drawArraysInstanced(t, 0, e, this.He.length);
641
+ we(t, e) {
642
+ this.Qe.length !== 0 && this.vt.drawArraysInstanced(t, 0, e, this.Qe.length);
642
643
  }
643
- Ut() {
644
- const t = this.bt;
645
- this.Xe && (t.deleteBuffer(this.Xe), this.Xe = null), this.He.length = 0, this.qe.clear(), this.Ze = null;
644
+ Pt() {
645
+ this.ss && this.vt.deleteBuffer(this.ss);
646
646
  }
647
647
  }
648
- class F {
648
+ class D {
649
649
  constructor(t, e, i, s) {
650
- h(this, "bt");
651
- h(this, "ss");
652
- h(this, "rs");
653
- h(this, "ns");
654
- h(this, "hs", null);
655
- this.bt = t, this.ss = e, this.rs = i, this.ns = s;
656
- const r = this.bt.createBuffer();
650
+ a(this, "vt");
651
+ a(this, "_s");
652
+ a(this, "ps");
653
+ a(this, "gs");
654
+ a(this, "vs", null);
655
+ this.vt = t, this._s = e, this.ps = i, this.gs = s;
656
+ const r = this.vt.createBuffer();
657
657
  if (!r) throw Error("Failed to create unit geometry buffer");
658
- this.bt.bindBuffer(this.bt.ARRAY_BUFFER, r), this.bt.bufferData(this.bt.ARRAY_BUFFER, this.ns.cs, this.bt.STATIC_DRAW), this.bt.bindBuffer(this.bt.ARRAY_BUFFER, null), this.hs = r;
658
+ this.vt.bindBuffer(this.vt.ARRAY_BUFFER, r), this.vt.bufferData(this.vt.ARRAY_BUFFER, this.gs.Cs, this.vt.STATIC_DRAW), this.vt.bindBuffer(this.vt.ARRAY_BUFFER, null), this.vs = r;
659
659
  }
660
660
  get type() {
661
- return this.rs;
661
+ return this.ps;
662
662
  }
663
663
  get unitGeometry() {
664
- return this.ns;
664
+ return this.gs;
665
665
  }
666
666
  get unitBuffer() {
667
- return this.hs;
667
+ return this.vs;
668
668
  }
669
669
  get batch() {
670
- return this.ss;
670
+ return this._s;
671
671
  }
672
- be() {
673
- this.ss.clear();
672
+ Fe() {
673
+ this._s.clear();
674
674
  }
675
- ve() {
676
- return !this.ss.isEmpty;
675
+ ye() {
676
+ return !this._s.isEmpty;
677
677
  }
678
- Ut() {
679
- this.ss.Ut(), this.hs && (this.bt.deleteBuffer(this.hs), this.hs = null);
678
+ Pt() {
679
+ this._s.Pt(), this.vt.deleteBuffer(this.vs);
680
680
  }
681
- ls(t, e, i, s, r) {
682
- const n = this.us(t, e, i, s, r.rotationX || 0, r.rotationY || 0, r.rotationZ || 0);
683
- return { position: [t, e], size: [i, s], tt: r.character || [0, 0, 0], primaryColor: r.charColor || [1, 1, 1, 1], secondaryColor: r.bgColor || [0, 0, 0, 1], rotation: r.charRotation || [0, 0], transform: [r.invert ? 1 : 0, r.flipHorizontally ? 1 : 0, r.flipVertically ? 1 : 0], globalRotationX: n.radiansX, globalRotationY: n.radiansY, globalRotationZ: n.radiansZ, rotationCenter: [n.centerX, n.centerY] };
681
+ ws(t, e, i, s, r) {
682
+ const n = this.$s(t, e, i, s, r.H || 0, r.V || 0, r.K || 0);
683
+ return { le: [t, e], Le: [i, s], j: r.j || [0, 0, 0], Y: r.Y || [1, 1, 1, 1], q: r.q || [0, 0, 0, 1], G: r.G || [0, 0], Ke: [r.P ? 1 : 0, r.N ? 1 : 0, r.X ? 1 : 0], H: n.radiansX, V: n.radiansY, K: n.radiansZ, Ne: [n.centerX, n.centerY] };
684
684
  }
685
- fs(t, e) {
686
- const i = B(this.bt) || [0, 0, this.bt.canvas.width, this.bt.canvas.height];
685
+ bs(t, e) {
686
+ const i = X(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height];
687
687
  return { nx: t / i[2] * 2 - 1, ny: 1 - e / i[3] * 2 };
688
688
  }
689
- ds(t, e, i) {
690
- const s = this.fs(e, i);
691
- t.rotationCenter = [s.nx, s.ny];
689
+ Fs(t, e, i) {
690
+ const s = this.bs(e, i);
691
+ t.Ne = [s.nx, s.ny];
692
692
  }
693
- us(t, e, i, s, r, n, o) {
694
- const c = B(this.bt) || [0, 0, this.bt.canvas.width, this.bt.canvas.height], l = c[2], f = c[3];
693
+ $s(t, e, i, s, r, n, o) {
694
+ const c = X(this.vt) || [0, 0, this.vt.canvas.width, this.vt.canvas.height], l = c[2], f = c[3];
695
695
  return { centerX: (t + i / 2) / l * 2 - 1, centerY: 1 - (e + s / 2) / f * 2, radiansX: -r * Math.PI / 180, radiansY: -n * Math.PI / 180, radiansZ: -o * Math.PI / 180, aspectRatio: l / f };
696
696
  }
697
697
  }
698
- const at = { cs: 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]), we: 6, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
699
- class ht extends F {
698
+ const vt = { Cs: 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]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
699
+ class xt extends D {
700
700
  constructor(t, e) {
701
- super(t, e, b.RECTANGLE, at);
701
+ super(t, e, w.RECTANGLE, vt);
702
702
  }
703
- Me(t, e) {
704
- const i = this.ls(t.x, t.y, t.width, t.height, e);
705
- return this.ss.Me(i);
703
+ Re(t, e) {
704
+ const i = this.ws(t.x, t.y, t.width, t.height, e);
705
+ return this._s.Re(i);
706
706
  }
707
707
  }
708
- const ct = { cs: 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]), we: 6, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
709
- class lt extends F {
708
+ const yt = { Cs: 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]), be: 6, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
709
+ class Et extends D {
710
710
  constructor(t, e) {
711
- super(t, e, b.LINE, ct);
711
+ super(t, e, w.LINE, yt);
712
712
  }
713
- Me(t, e) {
714
- const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = Math.atan2(s, i), o = t.thickness || e.lineWeight || 1, c = t.x1 + i / 2, l = t.y1 + s / 2, f = c - r / 2, u = l, d = { character: e.character, charColor: e.charColor, bgColor: e.bgColor, charRotation: e.charRotation, flipHorizontally: e.flipHorizontally, flipVertically: e.flipVertically, invert: e.invert, rotationX: e.rotationX || 0, rotationY: e.rotationY || 0, rotationZ: (e.rotationZ || 0) + 180 * n / Math.PI, lineWeight: o }, p = this.ls(f, u, r, o, d);
715
- return this.ds(p, c, l), this.ss.Me(p);
713
+ Re(t, e) {
714
+ const i = t.x2 - t.x1, s = t.y2 - t.y1, r = Math.hypot(i, s), n = t.thickness || e.O || 1, o = t.x1 + i / 2, c = t.y1 + s / 2, l = o - r / 2, f = c, u = this.ws(l, f, r, n, e);
715
+ return this.Fs(u, o, c), this._s.Re(u);
716
716
  }
717
717
  }
718
- const ut = { cs: function(a = 32) {
719
- const t = [], e = 2 * Math.PI / a;
720
- for (let i = 0; i < a; i++) {
721
- const s = i * e, r = (i + 1) % a * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), f = Math.cos(r), u = Math.sin(r), d = 0.5 * (f + 1), p = 0.5 * (u + 1);
722
- t.push(0, 0, 0.5, 0.5, n, o, c, l, f, u, d, p);
718
+ const wt = { Cs: function(h = 32) {
719
+ const t = [], e = 2 * Math.PI / h;
720
+ for (let i = 0; i < h; i++) {
721
+ const s = i * e, r = (i + 1) % h * e, n = Math.cos(s), o = Math.sin(s), c = 0.5 * (n + 1), l = 0.5 * (o + 1), f = Math.cos(r), u = Math.sin(r), g = 0.5 * (f + 1), v = 0.5 * (u + 1);
722
+ t.push(0, 0, 0.5, 0.5, n, o, c, l, f, u, g, v);
723
723
  }
724
724
  return new Float32Array(t);
725
- }(32), we: 96, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
726
- class ft extends F {
725
+ }(32), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
726
+ class Rt extends D {
727
727
  constructor(t, e) {
728
- super(t, e, b.ELLIPSE, ut);
728
+ super(t, e, w.ELLIPSE, wt);
729
729
  }
730
- Me(t, e) {
731
- const i = this.ls(t.x, t.y, t.width, t.height, e);
732
- return this.ds(i, t.x, t.y), this.ss.Me(i);
730
+ Re(t, e) {
731
+ const i = this.ws(t.x, t.y, t.width, t.height, e);
732
+ return this.Fs(i, t.x, t.y), this._s.Re(i);
733
733
  }
734
734
  }
735
- let dt = { cs: function(a) {
735
+ let bt = { Cs: function(h) {
736
736
  const t = [];
737
- for (let e = 0; e < a; e++) {
738
- const i = e / a, s = (e + 1) / a;
737
+ for (let e = 0; e < h; e++) {
738
+ const i = e / h, s = (e + 1) / h;
739
739
  t.push(i, 0, i, 0, i, 1, i, 1, s, 1, s, 1);
740
740
  }
741
741
  return new Float32Array(t);
742
- }(32), we: 96, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
743
- class pt extends F {
742
+ }(32), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
743
+ class At extends D {
744
744
  constructor(t, e) {
745
- super(t, e, b.ARC, dt);
745
+ super(t, e, w.ARC, bt);
746
746
  }
747
- Me(t, e) {
748
- const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.ls(i, s, t.width, t.height, e);
749
- return this.ds(o, t.x, t.y), o.arcAngles = [r, n], this.ss.Me(o);
747
+ Re(t, e) {
748
+ const i = t.x - t.width / 2, s = t.y - t.height / 2, r = t.start * Math.PI / 180, n = t.stop * Math.PI / 180, o = this.ws(i, s, t.width, t.height, e);
749
+ return this.Fs(o, t.x, t.y), o.Xe = [r, n], this._s.Re(o);
750
750
  }
751
751
  }
752
- const gt = { cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), we: 3, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
753
- class mt extends F {
752
+ const Tt = { Cs: new Float32Array([0, 0, 0, 0, 1, 0, 1, 0, 0.5, 1, 0.5, 1]), be: 3, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
753
+ class Ct extends D {
754
754
  constructor(t, e) {
755
- super(t, e, b.TRIANGLE, gt);
755
+ super(t, e, w.TRIANGLE, Tt);
756
756
  }
757
- Me(t, e) {
758
- const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.ls(i, r, n, o, e), l = i + 0.5 * n, f = r + o * (1 / 3);
759
- return this.ds(c, l, f), this.ss.Me(c);
757
+ Re(t, e) {
758
+ const i = Math.min(t.x1, t.x2, t.x3), s = Math.max(t.x1, t.x2, t.x3), r = Math.min(t.y1, t.y2, t.y3), n = s - i, o = Math.max(t.y1, t.y2, t.y3) - r, c = this.ws(i, r, n, o, e), l = i + 0.5 * n, f = r + o * (1 / 3);
759
+ return this.Fs(c, l, f), this._s.Re(c);
760
760
  }
761
761
  }
762
- function X(a, t, e, i, s) {
763
- const r = 1 - a, n = r * r, o = a * a;
764
- return n * r * t + 3 * n * a * e + 3 * r * o * i + o * a * s;
762
+ function et(h, t, e, i, s) {
763
+ const r = 1 - h, n = r * r, o = h * h;
764
+ return n * r * t + 3 * n * h * e + 3 * r * o * i + o * h * s;
765
765
  }
766
- const bt = { cs: function(a = 16) {
766
+ const Ut = { Cs: function(h = 16) {
767
767
  const t = [];
768
- for (let e = 0; e < a; e++) {
769
- const i = e / a, s = (e + 1) / a;
768
+ for (let e = 0; e < h; e++) {
769
+ const i = e / h, s = (e + 1) / h;
770
770
  t.push(i, -0.5, i, 0), t.push(s, -0.5, s, 0), t.push(i, 0.5, i, 1), t.push(i, 0.5, i, 1), t.push(s, -0.5, s, 0), t.push(s, 0.5, s, 1);
771
771
  }
772
772
  return new Float32Array(t);
773
- }(16), we: 96, $e: WebGL2RenderingContext.TRIANGLES, ue: 16, le: { ce: { size: 2, offset: 0 }, fe: { size: 2, offset: 8 } } };
774
- class yt extends F {
773
+ }(16), be: 96, $e: WebGL2RenderingContext.TRIANGLES, fe: 16, ue: { le: { size: 2, offset: 0 }, de: { size: 2, offset: 8 } } };
774
+ class _t extends D {
775
775
  constructor(t, e) {
776
- super(t, e, b.BEZIER_CURVE, bt);
776
+ super(t, e, w.BEZIER_CURVE, Ut);
777
777
  }
778
- Me(t, e) {
779
- const i = e.lineWeight || 1, s = X(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = X(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, rotationX: e.rotationX || 0, rotationY: e.rotationY || 0, rotationZ: e.rotationZ || 0, lineWeight: i }, o = this.ls(0, 0, 1, i, n);
780
- return this.ds(o, s, r), 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.ss.Me(o);
778
+ Re(t, e) {
779
+ const i = e.O || 1, s = et(0.5, t.x1, t.cp1x, t.cp2x, t.x2), r = et(0.5, t.y1, t.cp1y, t.cp2y, t.y2), n = this.ws(0, 0, 1, i, e);
780
+ return this.Fs(n, s, r), n.qe = [t.x1, t.y1], n.je = [t.cp1x, t.cp1y], n.Ye = [t.cp2x, t.cp2y], n.Ze = [t.x2, t.y2], this._s.Re(n);
781
781
  }
782
782
  }
783
- class Et {
783
+ class Ft {
784
784
  constructor(t) {
785
- h(this, "bt");
786
- h(this, "_s", null);
787
- h(this, "ps");
788
- h(this, "gs", null);
789
- h(this, "vs", {});
790
- h(this, "Cs", null);
791
- h(this, "$s", /* @__PURE__ */ new Map());
792
- h(this, "ws");
793
- h(this, "bs");
794
- h(this, "Rs");
795
- h(this, "K", []);
796
- this.bt = t, this.ps = new it(t), this.Rs = new Z(), this.ws = new rt(t, this), this.bs = new nt(), this.Cs = t.createBuffer(), U(this.bt, [0, 0, this.bt.canvas.width, this.bt.canvas.height]);
797
- }
798
- Ms(t) {
799
- let e = this.$s.get(t);
785
+ a(this, "vt");
786
+ a(this, "Ms", null);
787
+ a(this, "Rs");
788
+ a(this, "Ss", null);
789
+ a(this, "As", {});
790
+ a(this, "zs", null);
791
+ a(this, "Ts", /* @__PURE__ */ new Map());
792
+ a(this, "Es");
793
+ a(this, "Ls");
794
+ a(this, "ks");
795
+ a(this, "I", []);
796
+ this.vt = t, this.Rs = new ft(t), this.ks = new ht(), this.Es = new gt(t, this), this.Ls = new pt(), this.zs = t.createBuffer(), W(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
797
+ }
798
+ Ps(t) {
799
+ let e = this.Ts.get(t);
800
800
  if (e) return e;
801
- const i = new ot(this.bt);
802
- return e = (0, { [b.RECTANGLE]: () => new ht(this.bt, i), [b.LINE]: () => new lt(this.bt, i), [b.ELLIPSE]: () => new ft(this.bt, i), [b.ARC]: () => new pt(this.bt, i), [b.TRIANGLE]: () => new mt(this.bt, i), [b.BEZIER_CURVE]: () => new yt(this.bt, i) }[t])(), this.$s.set(t, e), e;
801
+ const i = new mt(this.vt);
802
+ return e = (0, { [w.RECTANGLE]: () => new xt(this.vt, i), [w.LINE]: () => new Et(this.vt, i), [w.ELLIPSE]: () => new Rt(this.vt, i), [w.ARC]: () => new At(this.vt, i), [w.TRIANGLE]: () => new Ct(this.vt, i), [w.BEZIER_CURVE]: () => new _t(this.vt, i) }[t])(), this.Ts.set(t, e), e;
803
803
  }
804
- Ss(t) {
805
- this._s !== t && (this._s = t, t.jt());
804
+ Gs(t) {
805
+ this.Ms !== t && (this.Ms = t, t.Vt());
806
806
  }
807
- Fs(t, e) {
808
- return this.ps.oe(t, e);
807
+ ae(t, e) {
808
+ return this.Rs.ae(t, e);
809
809
  }
810
810
  ie() {
811
- return this.ps.ie();
811
+ return this.Rs.ie();
812
812
  }
813
- Bt() {
814
- return this.ps.Bt();
813
+ Tt() {
814
+ return this.Rs.Tt();
815
815
  }
816
816
  re() {
817
- return this.ps.re();
817
+ return this.Rs.re();
818
818
  }
819
- zs(t) {
820
- this.gs = t, t && (this.vs = {});
819
+ ne() {
820
+ return this.Rs.ne();
821
821
  }
822
- Zt(t, e) {
823
- this.vs[t] = e;
822
+ Bs(t) {
823
+ this.Ss = t, t && (this.As = {});
824
824
  }
825
- Ps(t) {
826
- Object.assign(this.vs, t);
825
+ Xt(t, e) {
826
+ this.As[t] = e;
827
+ }
828
+ Ds(t) {
829
+ Object.assign(this.As, t);
827
830
  }
828
- ne(t) {
829
- return this.ps.ne(t);
831
+ oe(t) {
832
+ return this.Rs.oe(t);
830
833
  }
831
- ks(t, e, i, s, r) {
832
- const n = this.ie(), o = { l: t.textures[0], m: t.textures[1], n: t.textures[2], o: t.textures[3], p: t.textures[4], q: [t.width, t.height] };
833
- this.bs.Le(e, i, s, r, n, o, this.Rs);
834
+ Is(t, e, i, s, r) {
835
+ const n = this.ie(), o = { Ue: t.textures[0], Uf: t.textures[1], Ug: t.textures[2], Uh: t.textures[3], Ui: t.textures[4], Uj: [t.width, t.height] };
836
+ this.Ls.Ge(e, i, s, r, n, o, this.ks);
834
837
  }
835
- Ts(t, e, i, s) {
836
- var m;
837
- const r = this.bt, n = r.canvas.width, o = r.canvas.height, c = t / n * 2 - 1, l = (t + i) / n * 2 - 1, f = 1 - e / o * 2, u = 1 - (e + s) / o * 2, d = new Float32Array([c, u, l, u, c, f, l, u, l, f, c, f]);
838
- r.bindBuffer(r.ARRAY_BUFFER, this.Cs), r.bufferData(r.ARRAY_BUFFER, d, r.DYNAMIC_DRAW);
839
- const p = ((m = this._s) == null ? void 0 : m.te) || r.getParameter(r.CURRENT_PROGRAM), g = p ? r.getAttribLocation(p, "a_position") : -1;
840
- g !== -1 && (r.enableVertexAttribArray(g), r.vertexAttribPointer(g, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), g !== -1 && r.disableVertexAttribArray(g);
838
+ Ws(t, e, i, s, r) {
839
+ const n = this.ne(), o = t.texture, c = t.flags, l = t.charRotationRG, f = [l[0], l[1]], u = t.colorUniforms ?? { charColorFixed: !1, Y: [1, 1, 1], cellColorFixed: !1, cellColor: [0, 0, 0], backgroundColor: [0, 0, 0, 1] }, g = t.characterListUniforms, v = { Uk: o, Ul: !!c.invert, Um: !!c.flipX, Un: !!c.flipY, Uo: f, Up: !!u.charColorFixed, Uq: u.Y, Ur: !!u.cellColorFixed, Us: u.cellColor, Ut: u.backgroundColor, Uu: g.count, Uv: g.list };
840
+ this.Ls.Ge(e, i, s, r, n, v, this.ks);
841
841
  }
842
- Gs(t, e, i, s) {
843
- this.gs ? (this.bs.Le(t, e, i, s, this.gs, { ...this.vs }, this.Rs), this.gs = null, this.vs = {}) : this.bs.Ae(t, e, i, s, this.Rs);
842
+ Os(t, e, i, s) {
843
+ var d;
844
+ const r = this.vt, n = r.canvas.width, o = r.canvas.height, c = t / n * 2 - 1, l = (t + i) / n * 2 - 1, f = 1 - e / o * 2, u = 1 - (e + s) / o * 2, g = new Float32Array([c, u, l, u, c, f, l, u, l, f, c, f]);
845
+ r.bindBuffer(r.ARRAY_BUFFER, this.zs), r.bufferData(r.ARRAY_BUFFER, g, r.DYNAMIC_DRAW);
846
+ const v = ((d = this.Ms) == null ? void 0 : d.Jt) || r.getParameter(r.CURRENT_PROGRAM), m = v ? r.getAttribLocation(v, "a_position") : -1;
847
+ m !== -1 && (r.enableVertexAttribArray(m), r.vertexAttribPointer(m, 2, r.FLOAT, !1, 8, 0)), r.drawArrays(r.TRIANGLES, 0, 6), m !== -1 && r.disableVertexAttribArray(m);
844
848
  }
845
- As(t, e, i, s) {
846
- this.bs.Ee(t, e, i, s, this.Rs.lineWeight, this.Rs);
849
+ Hs(t, e, i, s) {
850
+ this.Ss ? (this.Ls.Ge(t, e, i, s, this.Ss, { ...this.As }, this.ks), this.Ss = null, this.As = {}) : this.Ls.Pe(t, e, i, s, this.ks);
847
851
  }
848
- Ls(t, e, i, s) {
849
- this.bs.Be(t, e, i, s, this.Rs);
852
+ Vs(t, e, i, s) {
853
+ this.Ls.Be(t, e, i, s, this.ks.lineWeight, this.ks);
850
854
  }
851
- Es(t, e, i, s, r, n) {
852
- this.bs.We(t, e, i, s, r, n, this.Rs);
855
+ Ks(t, e, i, s) {
856
+ this.Ls.De(t, e, i, s, this.ks);
853
857
  }
854
- Bs(t, e, i, s, r, n, o, c) {
855
- const l = this.Rs.lineWeight;
856
- this.bs.Ie(t, e, i, s, r, n, o, c, l, this.Rs);
858
+ Ns(t, e, i, s, r, n) {
859
+ this.Ls.We(t, e, i, s, r, n, this.ks);
857
860
  }
858
- Ds(t, e, i = 1, s = {}) {
859
- return new G(this.bt, t, e, i, s, this, !0);
861
+ Xs(t, e, i, s, r, n, o, c) {
862
+ const l = this.ks.lineWeight;
863
+ this.Ls.Oe(t, e, i, s, r, n, o, c, l, this.ks);
860
864
  }
861
- Ws(t, e, i, s, r, n) {
862
- this.bs.De(t, e, i, s, r, n, this.Rs);
865
+ js(t, e, i = 1, s = {}) {
866
+ return new K(this.vt, t, e, i, s, this, !0);
863
867
  }
864
- Is(t, e = t, i = t, s = 255) {
865
- this.state.Ct(t, e, i, s), this.Ue(t / 255, e / 255, i / 255, s / 255);
868
+ Ys(t, e, i, s, r, n) {
869
+ this.Ls.Ie(t, e, i, s, r, n, this.ks);
866
870
  }
867
- Ue(t = 0, e = 0, i = 0, s = 0) {
868
- this.bt.clearColor(t, e, i, s), this.bt.clear(this.bt.COLOR_BUFFER_BIT);
871
+ qs(t, e = t, i = t, s = 255) {
872
+ this.state.ft(t, e, i, s), this.He(t / 255, e / 255, i / 255, s / 255);
869
873
  }
870
- Us() {
871
- this.bt.viewport(0, 0, this.bt.canvas.width, this.bt.canvas.height), U(this.bt, [0, 0, this.bt.canvas.width, this.bt.canvas.height]);
874
+ He(t = 0, e = 0, i = 0, s = 0) {
875
+ this.vt.clearColor(t, e, i, s), this.vt.clear(this.vt.COLOR_BUFFER_BIT);
876
+ }
877
+ Zs() {
878
+ this.vt.viewport(0, 0, this.vt.canvas.width, this.vt.canvas.height), W(this.vt, [0, 0, this.vt.canvas.width, this.vt.canvas.height]);
872
879
  }
873
880
  get context() {
874
- return this.bt;
881
+ return this.vt;
875
882
  }
876
883
  get state() {
877
- return this.Rs;
884
+ return this.ks;
878
885
  }
879
- Wt(t) {
880
- this.K.push(this.Rs), this.Rs = t;
886
+ Lt(t) {
887
+ this.I.push(this.ks), this.ks = t;
881
888
  }
882
- It() {
883
- const t = this.K.pop();
884
- t && (this.Rs = t);
889
+ kt() {
890
+ const t = this.I.pop();
891
+ t && (this.ks = t);
885
892
  }
886
- Dt(t) {
887
- const e = t, i = B(this.bt) ?? this.bt.getParameter(this.bt.VIEWPORT), s = { shader: e, gl: this.bt, viewport: i };
888
- this.Ss(e);
893
+ Et(t) {
894
+ const e = t, i = X(this.vt) ?? this.vt.getParameter(this.vt.VIEWPORT), s = { shader: e, gl: this.vt, viewport: i };
895
+ this.Gs(e);
889
896
  const r = /* @__PURE__ */ new Set();
890
- for (const n of this.bs) n.type === b.CUSTOM ? r.add(b.RECTANGLE) : r.add(n.type);
891
- for (const n of r) n !== b.CUSTOM && this.Ms(n);
892
- this.ws.me(s, this.bs, this.$s), this.bs.Ue();
897
+ for (const n of this.Ls) n.type === w.CUSTOM ? r.add(w.RECTANGLE) : r.add(n.type);
898
+ for (const n of r) n !== w.CUSTOM && this.Ps(n);
899
+ this.Es.ve(s, this.Ls, this.Ts), this.Ls.He();
893
900
  }
894
- Ut() {
895
- this.bt.deleteBuffer(this.Cs), this.bs.Ue();
896
- for (const t of this.$s.values()) t.Ut();
897
- this.ps.Ut();
901
+ Pt() {
902
+ this.vt.deleteBuffer(this.zs), this.Ls.He();
903
+ for (const t of this.Ts.values()) t.Pt();
904
+ this.Rs.Pt(), this.Es.Pt();
898
905
  }
899
906
  }
900
- const E = { readShort: (a, t) => (E.t.uint16[0] = a[t] << 8 | a[t + 1], E.t.int16[0]), readUshort: (a, t) => a[t] << 8 | a[t + 1], readUshorts(a, t, e) {
907
+ const R = { readShort: (h, t) => (R.t.uint16[0] = h[t] << 8 | h[t + 1], R.t.int16[0]), readUshort: (h, t) => h[t] << 8 | h[t + 1], readUshorts(h, t, e) {
901
908
  const i = [];
902
- for (let s = 0; s < e; s++) i.push(E.readUshort(a, t + 2 * s));
909
+ for (let s = 0; s < e; s++) i.push(R.readUshort(h, t + 2 * s));
903
910
  return i;
904
- }, readUint(a, t) {
905
- const e = E.t.uint8;
906
- return e[3] = a[t], e[2] = a[t + 1], e[1] = a[t + 2], e[0] = a[t + 3], E.t.uint32[0];
907
- }, readASCII(a, t, e) {
911
+ }, readUint(h, t) {
912
+ const e = R.t.uint8;
913
+ return e[3] = h[t], e[2] = h[t + 1], e[1] = h[t + 2], e[0] = h[t + 3], R.t.uint32[0];
914
+ }, readASCII(h, t, e) {
908
915
  let i = "";
909
- for (let s = 0; s < e; s++) i += String.fromCharCode(a[t + s]);
916
+ for (let s = 0; s < e; s++) i += String.fromCharCode(h[t + s]);
910
917
  return i;
918
+ }, writeUshort(h, t, e) {
919
+ h[t] = e >>> 8 & 255, h[t + 1] = 255 & e;
920
+ }, writeUint(h, t, e) {
921
+ h[t] = e >>> 24 & 255, h[t + 1] = e >>> 16 & 255, h[t + 2] = e >>> 8 & 255, h[t + 3] = 255 & e;
922
+ }, writeASCII(h, t, e) {
923
+ for (let i = 0; i < e.length; i++) h[t + i] = 255 & e.charCodeAt(i);
911
924
  }, t: (() => {
912
- const a = new ArrayBuffer(8);
913
- return { uint8: new Uint8Array(a), int16: new Int16Array(a), uint16: new Uint16Array(a), uint32: new Uint32Array(a) };
914
- })() }, Rt = { parseTab(a, t, e) {
925
+ const h = new ArrayBuffer(8);
926
+ return { uint8: new Uint8Array(h), int16: new Int16Array(h), uint16: new Uint16Array(h), uint32: new Uint32Array(h) };
927
+ })() };
928
+ function N(h) {
929
+ return h + 3 & -4;
930
+ }
931
+ function Y(h, t, e) {
932
+ const i = t + e;
933
+ let s = 0;
934
+ const r = R.t;
935
+ for (let n = t; n < i; n += 4) r.uint8[3] = h[n] || 0, r.uint8[2] = h[n + 1] || 0, r.uint8[1] = h[n + 2] || 0, r.uint8[0] = h[n + 3] || 0, s = s + (r.uint32[0] >>> 0) >>> 0;
936
+ return s >>> 0;
937
+ }
938
+ class Lt {
939
+ constructor(t) {
940
+ a(this, "b");
941
+ a(this, "p", 0);
942
+ a(this, "bitbuf", 0);
943
+ a(this, "bitcnt", 0);
944
+ this.b = t;
945
+ }
946
+ readBits(t) {
947
+ for (; this.bitcnt < t; ) {
948
+ const i = this.b[this.p++] || 0;
949
+ this.bitbuf |= i << this.bitcnt, this.bitcnt += 8;
950
+ }
951
+ const e = this.bitbuf & (1 << t) - 1;
952
+ return this.bitbuf >>>= t, this.bitcnt -= t, e;
953
+ }
954
+ alignToByte() {
955
+ this.bitbuf = 0, this.bitcnt = 0;
956
+ }
957
+ get offset() {
958
+ return this.p;
959
+ }
960
+ }
961
+ function O(h) {
962
+ let t = 32, e = 0;
963
+ for (const o of h) o && (o < t && (t = o), o > e && (e = o));
964
+ if (e === 0) return { min: 0, max: 0, table: /* @__PURE__ */ new Map() };
965
+ const i = new Uint32Array(e + 1);
966
+ for (const o of h) o && i[o]++;
967
+ const s = new Uint32Array(e + 1);
968
+ let r = 0;
969
+ i[0] = 0;
970
+ for (let o = 1; o <= e; o++) r = r + i[o - 1] << 1, s[o] = r;
971
+ const n = /* @__PURE__ */ new Map();
972
+ for (let o = 0; o < h.length; o++) {
973
+ const c = h[o];
974
+ if (!c) continue;
975
+ const l = s[c]++;
976
+ let f = n.get(c);
977
+ f || (f = [], n.set(c, f)), f[Pt(l, c)] = o;
978
+ }
979
+ return { min: t, max: e, table: n };
980
+ }
981
+ function V(h, t) {
982
+ let e = 0;
983
+ for (let i = 1; i <= t.max; i++) {
984
+ e |= h.readBits(1) << i - 1;
985
+ const s = t.table.get(i);
986
+ if (s && e < s.length) {
987
+ const r = s[e];
988
+ if (r !== void 0) return r;
989
+ }
990
+ }
991
+ throw Error("Invalid Huffman code");
992
+ }
993
+ function Pt(h, t) {
994
+ let e = 0;
995
+ for (let i = 0; i < t; i++) e = e << 1 | 1 & h, h >>>= 1;
996
+ return e >>> 0;
997
+ }
998
+ function St(h) {
999
+ if (h.length < 2) throw Error("ZLIB data too short");
1000
+ const t = h[0], e = h[1];
1001
+ if ((15 & t) != 8) throw Error("Unsupported ZLIB compression method");
1002
+ if (((t << 8) + e) % 31 != 0) throw Error("Bad ZLIB header check");
1003
+ let i = 2;
1004
+ 32 & e && (i += 4);
1005
+ const s = [];
1006
+ return function(r, n) {
1007
+ const o = [3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258], c = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0], l = [1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577], f = [0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13];
1008
+ let u = 0;
1009
+ for (; !u; ) {
1010
+ u = r.readBits(1);
1011
+ const g = r.readBits(2);
1012
+ if (g === 0) {
1013
+ r.alignToByte();
1014
+ const v = r.readBits(16);
1015
+ if ((65535 & (65535 ^ v)) !== r.readBits(16)) throw Error("DEFLATE uncompressed LEN/NLEN mismatch");
1016
+ for (let m = 0; m < v; m++) n.push(r.readBits(8));
1017
+ } else {
1018
+ if (g !== 1 && g !== 2) throw Error("Unsupported DEFLATE type");
1019
+ {
1020
+ let v, m;
1021
+ if (g === 1) {
1022
+ const d = Array(288).fill(0);
1023
+ for (let x = 0; x <= 143; x++) d[x] = 8;
1024
+ for (let x = 144; x <= 255; x++) d[x] = 9;
1025
+ for (let x = 256; x <= 279; x++) d[x] = 7;
1026
+ for (let x = 280; x <= 287; x++) d[x] = 8;
1027
+ v = O(d), m = O(Array(32).fill(5));
1028
+ } else {
1029
+ const d = r.readBits(5) + 257, x = r.readBits(5) + 1, p = r.readBits(4) + 4, E = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15], y = Array(19).fill(0);
1030
+ for (let _ = 0; _ < p; _++) y[E[_]] = r.readBits(3);
1031
+ const C = O(y), b = [];
1032
+ for (; b.length < d + x; ) {
1033
+ const _ = V(r, C);
1034
+ if (_ <= 15) b.push(_);
1035
+ else if (_ === 16) {
1036
+ const G = r.readBits(2) + 3, S = b[b.length - 1] || 0;
1037
+ for (let tt = 0; tt < G; tt++) b.push(S);
1038
+ } else if (_ === 17) {
1039
+ const G = r.readBits(3) + 3;
1040
+ for (let S = 0; S < G; S++) b.push(0);
1041
+ } else {
1042
+ if (_ !== 18) throw Error("Invalid code length symbol");
1043
+ {
1044
+ const G = r.readBits(7) + 11;
1045
+ for (let S = 0; S < G; S++) b.push(0);
1046
+ }
1047
+ }
1048
+ }
1049
+ const A = b.slice(0, d), F = b.slice(d, d + x);
1050
+ v = O(A), m = O(F);
1051
+ }
1052
+ for (; ; ) {
1053
+ const d = V(r, v);
1054
+ if (d < 256) n.push(d);
1055
+ else {
1056
+ if (d === 256) break;
1057
+ if (d > 256 && d < 286) {
1058
+ const x = d - 257;
1059
+ let p = o[x];
1060
+ const E = c[x];
1061
+ E && (p += r.readBits(E));
1062
+ const y = V(r, m);
1063
+ if (y >= 30) throw Error("Invalid distance symbol");
1064
+ let C = l[y];
1065
+ const b = f[y];
1066
+ b && (C += r.readBits(b));
1067
+ const A = n.length - C;
1068
+ if (A < 0) throw Error("Invalid distance");
1069
+ for (let F = 0; F < p; F++) n.push(n[A + F] || 0);
1070
+ } else if (d === 286 || d === 287) throw Error("Reserved length symbol");
1071
+ }
1072
+ }
1073
+ }
1074
+ }
1075
+ }
1076
+ }(new Lt(h.subarray(i)), s), new Uint8Array(s);
1077
+ }
1078
+ function It(h) {
1079
+ const t = R, e = new Uint8Array(h);
1080
+ if (t.readASCII(e, 0, 4) !== "wOFF") throw Error("Invalid WOFF signature");
1081
+ const i = t.readUint(e, 4), s = t.readUshort(e, 12), r = t.readUint(e, 16), n = [];
1082
+ let o = 44;
1083
+ for (let p = 0; p < s; p++) {
1084
+ const E = t.readASCII(e, o, 4), y = t.readUint(e, o + 4), C = t.readUint(e, o + 8), b = t.readUint(e, o + 12), A = t.readUint(e, o + 16);
1085
+ n.push({ tag: E, offset: y, compLength: C, origLength: b, checksum: A }), o += 20;
1086
+ }
1087
+ for (const p of n) {
1088
+ const E = new Uint8Array(e.buffer, p.offset, p.compLength);
1089
+ if (p.compLength === p.origLength) p.data = new Uint8Array(E);
1090
+ else if (p.data = St(E), p.data.length !== p.origLength) if (p.data.length < p.origLength) {
1091
+ const y = new Uint8Array(p.origLength);
1092
+ y.set(p.data), p.data = y;
1093
+ } else p.data = p.data.subarray(0, p.origLength);
1094
+ }
1095
+ const c = s;
1096
+ let l = 1, f = 0;
1097
+ for (; l << 1 <= c; ) l <<= 1, f++;
1098
+ const u = 16 * l, g = 16 * c - u;
1099
+ let v = 12 + 16 * c;
1100
+ const m = {};
1101
+ for (const p of n) m[p.tag] = v, v = N(v + p.data.length);
1102
+ const d = new Uint8Array(Math.max(r || 0, v));
1103
+ t.writeUint(d, 0, i), t.writeUshort(d, 4, c), t.writeUshort(d, 6, u), t.writeUshort(d, 8, f), t.writeUshort(d, 10, g);
1104
+ let x = 12;
1105
+ for (const p of n) {
1106
+ t.writeASCII(d, x, p.tag), x += 4;
1107
+ let E = p.data;
1108
+ if (p.tag === "head" && E.length >= 12) {
1109
+ const y = new Uint8Array(E);
1110
+ t.writeUint(y, 8, 0);
1111
+ const C = Y(y, 0, N(y.length));
1112
+ t.writeUint(d, x, C), x += 4;
1113
+ } else {
1114
+ const y = Y(E, 0, N(E.length));
1115
+ t.writeUint(d, x, y), x += 4;
1116
+ }
1117
+ t.writeUint(d, x, m[p.tag]), x += 4, t.writeUint(d, x, p.data.length), x += 4;
1118
+ }
1119
+ for (const p of n) {
1120
+ const E = m[p.tag];
1121
+ d.set(p.data, E);
1122
+ }
1123
+ if (n.find((p) => p.tag === "head")) {
1124
+ const p = m.head, E = function(y, C) {
1125
+ const b = R, A = C + 8, F = [y[A], y[A + 1], y[A + 2], y[A + 3]];
1126
+ b.writeUint(y, A, 0);
1127
+ const _ = 2981146554 - (Y(y, 0, N(y.length)) >>> 0) >>> 0;
1128
+ return y[A] = F[0], y[A + 1] = F[1], y[A + 2] = F[2], y[A + 3] = F[3], _ >>> 0;
1129
+ }(d, p);
1130
+ t.writeUint(d, p + 8, E);
1131
+ }
1132
+ return d.buffer;
1133
+ }
1134
+ const Bt = { parseTab(h, t, e) {
915
1135
  const i = { tables: [], ids: {}, off: t };
916
- a = new Uint8Array(a.buffer, t, e), t = 0;
917
- const s = E, r = s.readUshort, n = r(a, t += 2);
1136
+ h = new Uint8Array(h.buffer, t, e), t = 0;
1137
+ const s = R, r = s.readUshort, n = r(h, t += 2);
918
1138
  t += 2;
919
1139
  const o = [];
920
1140
  for (let c = 0; c < n; c++) {
921
- const l = r(a, t), f = r(a, t += 2);
1141
+ const l = r(h, t), f = r(h, t += 2);
922
1142
  t += 2;
923
- const u = s.readUint(a, t);
1143
+ const u = s.readUint(h, t);
924
1144
  t += 4;
925
- const d = `p${l}e${f}`;
926
- let p = o.indexOf(u);
927
- if (p === -1) {
928
- let g;
929
- p = i.tables.length, o.push(u);
930
- const m = r(a, u);
931
- g = m === 4 ? this.parse4(a, u) : m === 12 ? this.parse12(a, u) : { format: m }, i.tables.push(g);
1145
+ const g = `p${l}e${f}`;
1146
+ let v = o.indexOf(u);
1147
+ if (v === -1) {
1148
+ let m;
1149
+ v = i.tables.length, o.push(u);
1150
+ const d = r(h, u);
1151
+ m = d === 4 ? this.parse4(h, u) : d === 12 ? this.parse12(h, u) : { format: d }, i.tables.push(m);
932
1152
  }
933
- i.ids[d] = p;
1153
+ i.ids[g] = v;
934
1154
  }
935
1155
  return i;
936
- }, parse4(a, t) {
937
- const e = E, i = e.readUshort, s = e.readUshorts, r = t, n = i(a, t += 2);
1156
+ }, parse4(h, t) {
1157
+ const e = R, i = e.readUshort, s = e.readUshorts, r = t, n = i(h, t += 2);
938
1158
  t += 2;
939
- const o = i(a, t += 2) >>> 1, c = { format: 4, searchRange: i(a, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
940
- t += 2, c.entrySelector = i(a, t), t += 2, c.rangeShift = i(a, t), t += 2, c.endCount = s(a, t, o), t += 2 * o, t += 2, c.startCount = s(a, t, o), t += 2 * o;
941
- for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(a, t)), t += 2;
942
- return c.idRangeOffset = s(a, t, o), t += 2 * o, c.glyphIdArray = s(a, t, r + n - t >> 1), c;
943
- }, parse12(a, t) {
944
- const e = E.readUint;
945
- e(a, t += 4), e(a, t += 4);
946
- const i = e(a, t += 4);
1159
+ const o = i(h, t += 2) >>> 1, c = { format: 4, searchRange: i(h, t += 2), entrySelector: 0, rangeShift: 0, endCount: [], startCount: [], idDelta: [], idRangeOffset: [], glyphIdArray: [] };
1160
+ t += 2, c.entrySelector = i(h, t), t += 2, c.rangeShift = i(h, t), t += 2, c.endCount = s(h, t, o), t += 2 * o, t += 2, c.startCount = s(h, t, o), t += 2 * o;
1161
+ for (let l = 0; l < o; l++) c.idDelta.push(e.readShort(h, t)), t += 2;
1162
+ return c.idRangeOffset = s(h, t, o), t += 2 * o, c.glyphIdArray = s(h, t, r + n - t >> 1), c;
1163
+ }, parse12(h, t) {
1164
+ const e = R.readUint;
1165
+ e(h, t += 4), e(h, t += 4);
1166
+ const i = e(h, t += 4);
947
1167
  t += 4;
948
1168
  const s = new Uint32Array(3 * i);
949
- for (let r = 0; r < 3 * i; r += 3) s[r] = e(a, t + (r << 2)), s[r + 1] = e(a, t + (r << 2) + 4), s[r + 2] = e(a, t + (r << 2) + 8);
1169
+ for (let r = 0; r < 3 * i; r += 3) s[r] = e(h, t + (r << 2)), s[r + 1] = e(h, t + (r << 2) + 4), s[r + 2] = e(h, t + (r << 2) + 8);
950
1170
  return { format: 12, groups: s };
951
- } }, vt = { parseTab(a, t, e) {
952
- const i = E;
1171
+ } }, Mt = { parseTab(h, t, e) {
1172
+ const i = R;
953
1173
  t += 18;
954
- const s = i.readUshort(a, t);
1174
+ const s = i.readUshort(h, t);
955
1175
  t += 2, t += 16;
956
- const r = i.readShort(a, t);
1176
+ const r = i.readShort(h, t);
957
1177
  t += 2;
958
- const n = i.readShort(a, t);
1178
+ const n = i.readShort(h, t);
959
1179
  t += 2;
960
- const o = i.readShort(a, t);
1180
+ const o = i.readShort(h, t);
961
1181
  t += 2;
962
- const c = i.readShort(a, t);
963
- return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(a, t) };
964
- } }, xt = { parseTab(a, t, e) {
965
- const i = E;
1182
+ const c = i.readShort(h, t);
1183
+ return t += 2, t += 6, { unitsPerEm: s, xMin: r, yMin: n, xMax: o, yMax: c, indexToLocFormat: i.readShort(h, t) };
1184
+ } }, Dt = { parseTab(h, t, e) {
1185
+ const i = R;
966
1186
  t += 4;
967
1187
  const s = ["ascender", "descender", "lineGap", "advanceWidthMax", "minLeftSideBearing", "minRightSideBearing", "xMaxExtent", "caretSlopeRise", "caretSlopeRun", "caretOffset", "res0", "res1", "res2", "res3", "metricDataFormat", "numberOfHMetrics"], r = {};
968
1188
  for (let n = 0; n < s.length; n++) {
969
1189
  const o = s[n], c = o === "advanceWidthMax" || o === "numberOfHMetrics" ? i.readUshort : i.readShort;
970
- r[o] = c(a, t + 2 * n);
1190
+ r[o] = c(h, t + 2 * n);
971
1191
  }
972
1192
  return r;
973
- } }, wt = { parseTab(a, t, e, i) {
974
- const s = E, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
1193
+ } }, Gt = { parseTab(h, t, e, i) {
1194
+ const s = R, r = [], n = [], o = i.maxp.numGlyphs, c = i.hhea.numberOfHMetrics;
975
1195
  let l = 0, f = 0, u = 0;
976
- for (; u < c; ) l = s.readUshort(a, t + (u << 2)), f = s.readShort(a, t + (u << 2) + 2), r.push(l), n.push(f), u++;
1196
+ for (; u < c; ) l = s.readUshort(h, t + (u << 2)), f = s.readShort(h, t + (u << 2) + 2), r.push(l), n.push(f), u++;
977
1197
  for (; u < o; ) r.push(l), n.push(f), u++;
978
1198
  return { aWidth: r, lsBearing: n };
979
- } }, Y = { cmap: Rt, head: vt, hhea: xt, maxp: { parseTab(a, t, e) {
980
- const i = E;
981
- return i.readUint(a, t), t += 4, { numGlyphs: i.readUshort(a, t) };
982
- } }, hmtx: wt, loca: { parseTab(a, t, e, i) {
983
- const s = E, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
984
- if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(a, t + (c << 1)) << 1);
985
- else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(a, t + (c << 2)));
1199
+ } }, it = { cmap: Bt, head: Mt, hhea: Dt, maxp: { parseTab(h, t, e) {
1200
+ const i = R;
1201
+ return i.readUint(h, t), t += 4, { numGlyphs: i.readUshort(h, t) };
1202
+ } }, hmtx: Gt, loca: { parseTab(h, t, e, i) {
1203
+ const s = R, r = [], n = i.head.indexToLocFormat, o = i.maxp.numGlyphs + 1;
1204
+ if (n === 0) for (let c = 0; c < o; c++) r.push(s.readUshort(h, t + (c << 1)) << 1);
1205
+ else if (n === 1) for (let c = 0; c < o; c++) r.push(s.readUint(h, t + (c << 2)));
986
1206
  return r;
987
- } }, glyf: { parseTab(a, t, e, i) {
1207
+ } }, glyf: { parseTab(h, t, e, i) {
988
1208
  const s = [], r = i.maxp.numGlyphs;
989
1209
  for (let n = 0; n < r; n++) s.push(null);
990
1210
  return s;
991
- }, Os(a, t) {
992
- const e = E, i = a.Vs, s = a.loca;
1211
+ }, Js(h, t) {
1212
+ const e = R, i = h.Qs, s = h.loca;
993
1213
  if (s[t] === s[t + 1]) return null;
994
- const r = A.findTable(i, "glyf", a.Hs);
1214
+ const r = L.findTable(i, "glyf", h.ti);
995
1215
  if (!r) return null;
996
1216
  let n = r[0] + s[t];
997
1217
  const o = {};
998
1218
  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;
999
1219
  if (o.noc > 0) {
1000
1220
  o.endPts = [];
1001
- for (let d = 0; d < o.noc; d++) o.endPts.push(e.readUshort(i, n)), n += 2;
1221
+ for (let g = 0; g < o.noc; g++) o.endPts.push(e.readUshort(i, n)), n += 2;
1002
1222
  const c = e.readUshort(i, n);
1003
1223
  if (n += 2, i.length - n < c) return null;
1004
1224
  n += c;
1005
1225
  const l = o.endPts[o.noc - 1] + 1;
1006
1226
  o.flags = [];
1007
- for (let d = 0; d < l; d++) {
1008
- const p = i[n];
1009
- if (n++, o.flags.push(p), 8 & p) {
1010
- const g = i[n];
1227
+ for (let g = 0; g < l; g++) {
1228
+ const v = i[n];
1229
+ if (n++, o.flags.push(v), 8 & v) {
1230
+ const m = i[n];
1011
1231
  n++;
1012
- for (let m = 0; m < g; m++) o.flags.push(p), d++;
1232
+ for (let d = 0; d < m; d++) o.flags.push(v), g++;
1013
1233
  }
1014
1234
  }
1015
1235
  o.xs = [];
1016
- for (let d = 0; d < l; d++) {
1017
- const p = o.flags[d], g = !!(16 & p);
1018
- 2 & p ? (o.xs.push(g ? i[n] : -i[n]), n++) : g ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
1236
+ for (let g = 0; g < l; g++) {
1237
+ const v = o.flags[g], m = !!(16 & v);
1238
+ 2 & v ? (o.xs.push(m ? i[n] : -i[n]), n++) : m ? o.xs.push(0) : (o.xs.push(e.readShort(i, n)), n += 2);
1019
1239
  }
1020
1240
  o.ys = [];
1021
- for (let d = 0; d < l; d++) {
1022
- const p = o.flags[d], g = !!(32 & p);
1023
- 4 & p ? (o.ys.push(g ? i[n] : -i[n]), n++) : g ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
1241
+ for (let g = 0; g < l; g++) {
1242
+ const v = o.flags[g], m = !!(32 & v);
1243
+ 4 & v ? (o.ys.push(m ? i[n] : -i[n]), n++) : m ? o.ys.push(0) : (o.ys.push(e.readShort(i, n)), n += 2);
1024
1244
  }
1025
1245
  let f = 0, u = 0;
1026
- for (let d = 0; d < l; d++) f += o.xs[d], u += o.ys[d], o.xs[d] = f, o.ys[d] = u;
1246
+ for (let g = 0; g < l; g++) f += o.xs[g], u += o.ys[g], o.xs[g] = f, o.ys[g] = u;
1027
1247
  } else o.parts = [], o.endPts = [], o.flags = [], o.xs = [], o.ys = [];
1028
1248
  return o;
1029
- } } }, A = { parse: (a) => [((t, e, i, s) => {
1030
- const r = Y, n = { Vs: t, Ks: e, Hs: i };
1031
- for (const o in r) {
1032
- const c = o, l = A.findTable(t, c, i);
1033
- if (l) {
1034
- const [f, u] = l;
1035
- let d = s[f];
1036
- d == null && (d = r[c].parseTab(t, f, u, n), s[f] = d), n[c] = d;
1249
+ } } }, L = { parse(h) {
1250
+ const t = new Uint8Array(h), e = R.readASCII(t, 0, 4);
1251
+ if (e === "wOFF") h = It(h);
1252
+ else if (e === "wOF2") throw Error("WOFF2 is not supported in this build (Brotli + WOFF2 transforms required)");
1253
+ return [((i, s, r, n) => {
1254
+ const o = it, c = { Qs: i, ei: s, ti: r };
1255
+ for (const l in o) {
1256
+ const f = l, u = L.findTable(i, f, r);
1257
+ if (u) {
1258
+ const [g, v] = u;
1259
+ let m = n[g];
1260
+ m == null && (m = o[f].parseTab(i, g, v, c), n[g] = m), c[f] = m;
1261
+ }
1037
1262
  }
1038
- }
1039
- return n;
1040
- })(new Uint8Array(a), 0, 0, {})], findTable(a, t, e) {
1041
- const i = E, s = i.readUshort(a, e + 4);
1263
+ return c;
1264
+ })(new Uint8Array(h), 0, 0, {})];
1265
+ }, findTable(h, t, e) {
1266
+ const i = R, s = i.readUshort(h, e + 4);
1042
1267
  let r = e + 12;
1043
1268
  for (let n = 0; n < s; n++) {
1044
- const o = i.readASCII(a, r, 4);
1045
- i.readUint(a, r + 4);
1046
- const c = i.readUint(a, r + 8), l = i.readUint(a, r + 12);
1269
+ const o = i.readASCII(h, r, 4);
1270
+ i.readUint(h, r + 4);
1271
+ const c = i.readUint(h, r + 8), l = i.readUint(h, r + 12);
1047
1272
  if (o === t) return [c, l];
1048
1273
  r += 16;
1049
1274
  }
1050
1275
  return null;
1051
- }, T: Y, B: E };
1052
- class I {
1053
- constructor() {
1054
- h(this, "Ns", /* @__PURE__ */ new Map());
1055
- h(this, "Xs", /* @__PURE__ */ new Map());
1056
- }
1057
- js(t, e) {
1058
- const i = `${this.Ys(t)}_${e}`;
1059
- if (this.Ns.has(i)) return this.Ns.get(i);
1060
- const s = t.cmap;
1061
- if (!s || !s.tables) return this.Ns.set(i, 0), 0;
1062
- let r = 0;
1063
- for (const n of s.tables) if (n.format === 4 ? r = this.qs(e, n) : n.format === 12 && (r = this.Zs(e, n)), r > 0) break;
1064
- return this.Ns.set(i, r), r;
1065
- }
1066
- Js(t, e) {
1067
- const i = e.codePointAt(0);
1068
- return i === void 0 ? 0 : this.js(t, i);
1069
- }
1070
- Qs(t, e) {
1071
- const i = t.hmtx;
1072
- return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1073
- }
1074
- ti(t, e) {
1075
- const i = e / t.head.unitsPerEm, s = t.hhea.ascender * i, r = t.hhea.descender * i, n = t.hhea.lineGap * i;
1076
- return { ascender: s, descender: r, lineGap: n, lineHeight: s - r + n, unitsPerEm: t.head.unitsPerEm, scale: i };
1077
- }
1078
- ei() {
1079
- this.Ns.clear(), this.Xs.clear();
1080
- }
1081
- Ys(t) {
1082
- return `${t.Hs}_${t.Vs.length}`;
1083
- }
1084
- qs(t, e) {
1085
- const i = e.endCount.length;
1086
- let s = -1;
1087
- for (let r = 0; r < i; r++) if (t <= e.endCount[r]) {
1088
- s = r;
1089
- break;
1090
- }
1091
- if (s === -1 || t < e.startCount[s]) return 0;
1092
- if (e.idRangeOffset[s] === 0) return t + e.idDelta[s] & 65535;
1093
- {
1094
- const r = e.idRangeOffset[s] / 2 + (t - e.startCount[s]) - (i - s);
1095
- if (r >= 0 && r < e.glyphIdArray.length) {
1096
- const n = e.glyphIdArray[r];
1097
- return n === 0 ? 0 : n + e.idDelta[s] & 65535;
1098
- }
1099
- }
1100
- return 0;
1101
- }
1102
- Zs(t, e) {
1103
- const i = e.groups.length / 3;
1104
- for (let s = 0; s < i; s++) {
1105
- const r = e.groups[3 * s], n = e.groups[3 * s + 1], o = e.groups[3 * s + 2];
1106
- if (t >= r && t <= n) return o + (t - r);
1107
- }
1108
- return 0;
1109
- }
1110
- }
1111
- class Ct {
1112
- constructor(t) {
1113
- h(this, "si");
1114
- this.si = t;
1115
- }
1116
- ii(t) {
1276
+ }, T: it, B: R };
1277
+ class Ot {
1278
+ si(t) {
1117
1279
  var i;
1118
1280
  const e = [];
1119
1281
  return (i = t.cmap) != null && i.tables ? (t.cmap.tables.forEach((s) => {
1120
1282
  if (s.format === 4) {
1121
- const r = this.ri(s);
1283
+ const r = this.ii(s);
1122
1284
  e.push(...r);
1123
1285
  } else if (s.format === 12) {
1124
- const r = this.ni(s);
1286
+ const r = this.ri(s);
1125
1287
  e.push(...r);
1126
1288
  }
1127
1289
  }), [...new Set(e)]) : [];
1128
1290
  }
1129
- oi(t, e) {
1130
- return this.si.Js(t, e) > 0;
1131
- }
1132
- ai(t, e) {
1133
- for (const i of e) if (!this.oi(t, i)) return !1;
1134
- return !0;
1135
- }
1136
- hi(t, e) {
1137
- return e.filter((i) => this.oi(t, i));
1138
- }
1139
- ci(t) {
1140
- return t.filter((e) => this.li(e));
1291
+ ni(t) {
1292
+ return t.filter((e) => this.oi(e));
1141
1293
  }
1142
- ri(t) {
1294
+ ii(t) {
1143
1295
  const e = [];
1144
1296
  if (!(t.startCount && t.endCount && t.idRangeOffset && t.idDelta)) return e;
1145
1297
  for (let i = 0; i < t.startCount.length; i++) {
1146
1298
  const s = t.startCount[i], r = t.endCount[i];
1147
1299
  if (s !== 65535 || r !== 65535) {
1148
1300
  for (let n = s; n <= r; n++)
1149
- if (this.ui(t, n, i) > 0) try {
1301
+ if (this.ai(t, n, i) > 0) try {
1150
1302
  const o = String.fromCodePoint(n);
1151
1303
  e.push(o);
1152
1304
  } catch {
@@ -1155,7 +1307,7 @@ class Ct {
1155
1307
  }
1156
1308
  return e;
1157
1309
  }
1158
- ni(t) {
1310
+ ri(t) {
1159
1311
  const e = [];
1160
1312
  if (!t.groups) return e;
1161
1313
  for (let i = 0; i < t.groups.length; i += 3) {
@@ -1169,7 +1321,7 @@ class Ct {
1169
1321
  }
1170
1322
  return e;
1171
1323
  }
1172
- ui(t, e, i) {
1324
+ ai(t, e, i) {
1173
1325
  if (t.idRangeOffset[i] === 0) return e + t.idDelta[i] & 65535;
1174
1326
  {
1175
1327
  const s = t.idRangeOffset[i] / 2 + (e - t.startCount[i]) - (t.startCount.length - i);
@@ -1180,734 +1332,905 @@ class Ct {
1180
1332
  }
1181
1333
  return 0;
1182
1334
  }
1183
- li(t) {
1335
+ oi(t) {
1184
1336
  const e = t.codePointAt(0) || 0;
1185
1337
  return !(e >= 0 && e <= 31 && e !== 9 && e !== 10 && e !== 13 || e >= 127 && e <= 159);
1186
1338
  }
1187
1339
  }
1188
- class At {
1340
+ class q {
1189
1341
  constructor() {
1190
- h(this, "fi");
1191
- const t = new I();
1192
- this.fi = new Ct(t);
1342
+ a(this, "hi", /* @__PURE__ */ new Map());
1343
+ a(this, "ci", /* @__PURE__ */ new Map());
1193
1344
  }
1194
- extractCharacters(t) {
1195
- return this.fi.ii(t);
1345
+ li(t, e) {
1346
+ const i = `${this.ui(t)}_${e}`;
1347
+ if (this.hi.has(i)) return this.hi.get(i);
1348
+ const s = t.cmap;
1349
+ if (!s || !s.tables) return this.hi.set(i, 0), 0;
1350
+ let r = 0;
1351
+ for (const n of s.tables) if (n.format === 4 ? r = this.fi(e, n) : n.format === 12 && (r = this.di(e, n)), r > 0) break;
1352
+ return this.hi.set(i, r), r;
1196
1353
  }
1197
- filterProblematicCharacters(t) {
1198
- return this.fi.ci(t);
1354
+ _i(t, e) {
1355
+ const i = e.codePointAt(0);
1356
+ return i === void 0 ? 0 : this.li(t, i);
1199
1357
  }
1200
- characterExists(t, e) {
1201
- return this.fi.oi(t, e);
1358
+ pi(t, e) {
1359
+ const i = t.hmtx;
1360
+ return i && i.aWidth && i.aWidth.length !== 0 ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1361
+ }
1362
+ mi(t, e) {
1363
+ const i = e / t.head.unitsPerEm, s = t.hhea.ascender * i, r = t.hhea.descender * i, n = t.hhea.lineGap * i;
1364
+ return { ascender: s, descender: r, lineGap: n, lineHeight: s - r + n, unitsPerEm: t.head.unitsPerEm, scale: i };
1202
1365
  }
1203
- allCharactersExist(t, e) {
1204
- return this.fi.ai(t, e);
1366
+ gi() {
1367
+ this.hi.clear(), this.ci.clear();
1368
+ }
1369
+ ui(t) {
1370
+ return `${t.ti}_${t.Qs.length}`;
1371
+ }
1372
+ fi(t, e) {
1373
+ const i = e.endCount.length;
1374
+ let s = -1;
1375
+ for (let r = 0; r < i; r++) if (t <= e.endCount[r]) {
1376
+ s = r;
1377
+ break;
1378
+ }
1379
+ if (s === -1 || t < e.startCount[s]) return 0;
1380
+ if (e.idRangeOffset[s] === 0) return t + e.idDelta[s] & 65535;
1381
+ {
1382
+ const r = e.idRangeOffset[s] / 2 + (t - e.startCount[s]) - (i - s);
1383
+ if (r >= 0 && r < e.glyphIdArray.length) {
1384
+ const n = e.glyphIdArray[r];
1385
+ return n === 0 ? 0 : n + e.idDelta[s] & 65535;
1386
+ }
1387
+ }
1388
+ return 0;
1389
+ }
1390
+ di(t, e) {
1391
+ const i = e.groups.length / 3;
1392
+ for (let s = 0; s < i; s++) {
1393
+ const r = e.groups[3 * s], n = e.groups[3 * s + 1], o = e.groups[3 * s + 2];
1394
+ if (t >= r && t <= n) return o + (t - r);
1395
+ }
1396
+ return 0;
1205
1397
  }
1206
1398
  }
1207
- class Tt {
1399
+ class $t {
1208
1400
  constructor(t) {
1209
- h(this, "di");
1210
- h(this, "_i");
1211
- h(this, "Pt");
1212
- h(this, "pi");
1213
- this.Pt = t, this.pi = new I(), this.di = document.createElement("canvas"), this._i = this.di.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1401
+ a(this, "yi");
1402
+ a(this, "Ci");
1403
+ a(this, "xt");
1404
+ a(this, "wi");
1405
+ this.xt = t, this.wi = new q(), this.yi = document.createElement("canvas"), this.Ci = this.yi.getContext("2d", { willReadFrequently: !0, alpha: !1 });
1214
1406
  }
1215
1407
  createTextureAtlas(t, e, i, s) {
1216
1408
  const r = t.length, n = Math.ceil(Math.sqrt(r)), o = Math.ceil(r / n), c = e.width * n, l = e.height * o, f = typeof s == "object" ? s : null;
1217
- this.gi(c, l), this.mi(t, e, n, i, f);
1218
- const u = this.Pt.Ds(c, l, 1, { filter: "nearest" });
1219
- return u.Lt(this.di), { framebuffer: u, columns: n, rows: o };
1409
+ this.$i(c, l), this.bi(t, e, n, i, f);
1410
+ const u = this.xt.js(c, l, 1, { filter: "nearest" });
1411
+ return u.At(this.yi), { framebuffer: u, columns: n, rows: o };
1220
1412
  }
1221
- gi(t, e) {
1222
- this.di.width = t, this.di.height = e, this.di.style.width = t + "px", this.di.style.height = t + "px", this._i.imageSmoothingEnabled = !1, this.di.style.imageRendering = "pixelated", this._i.fillStyle = "black", this._i.fillRect(0, 0, t, e), this._i.textBaseline = "top", this._i.textAlign = "left", this._i.fillStyle = "white";
1413
+ $i(t, e) {
1414
+ this.yi.width = t, this.yi.height = e, this.yi.style.width = t + "px", this.yi.style.height = t + "px", this.Ci.imageSmoothingEnabled = !1, this.yi.style.imageRendering = "pixelated", this.Ci.fillStyle = "black", this.Ci.fillRect(0, 0, t, e), this.Ci.textBaseline = "top", this.Ci.textAlign = "left", this.Ci.fillStyle = "white";
1223
1415
  }
1224
- mi(t, e, i, s, r) {
1416
+ bi(t, e, i, s, r) {
1225
1417
  const n = s / r.head.unitsPerEm;
1226
1418
  for (let o = 0; o < t.length; o++) {
1227
- const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.yi(r, f);
1419
+ const c = o % i, l = Math.floor(o / i), f = t[o].character, u = this.xi(r, f);
1228
1420
  if (!u) continue;
1229
- const d = f.codePointAt(0) || 0, p = this.pi.js(r, d), g = this.Ci(r, p) * n, m = c * e.width, x = l * e.height, R = m + 0.5 * e.width, w = x + 0.5 * e.height, C = Math.round(R - 0.5 * e.width), S = Math.round(w - 0.5 * s), q = C + 0.5 * (e.width - g), J = S + r.hhea.ascender * n;
1230
- this.$i(u, q, J, n);
1421
+ const g = f.codePointAt(0) || 0, v = this.wi.li(r, g), m = this.Fi(r, v) * n, d = c * e.width, x = l * e.height, p = d + 0.5 * e.width, E = x + 0.5 * e.height, y = Math.round(p - 0.5 * e.width), C = Math.round(E - 0.5 * s), b = y + 0.5 * (e.width - m), A = C + r.hhea.ascender * n;
1422
+ this.Mi(u, b, A, n);
1231
1423
  }
1232
1424
  }
1233
- yi(t, e) {
1234
- const i = e.codePointAt(0) || 0, s = this.pi.js(t, i);
1425
+ xi(t, e) {
1426
+ const i = e.codePointAt(0) || 0, s = this.wi.li(t, i);
1235
1427
  if (s === 0) return null;
1236
1428
  if (t.glyf && t.glyf[s] !== null) return t.glyf[s];
1237
- if (A && A.T && A.T.glyf) {
1238
- const r = A.T.glyf.Os(t, s);
1429
+ if (L && L.T && L.T.glyf) {
1430
+ const r = L.T.glyf.Js(t, s);
1239
1431
  return t.glyf && r && (t.glyf[s] = r), r;
1240
1432
  }
1241
1433
  return null;
1242
1434
  }
1243
- Ci(t, e) {
1435
+ Fi(t, e) {
1244
1436
  const i = t.hmtx;
1245
1437
  return i && i.aWidth ? e < i.aWidth.length ? i.aWidth[e] : i.aWidth[i.aWidth.length - 1] : 0;
1246
1438
  }
1247
- $i(t, e, i, s) {
1439
+ Mi(t, e, i, s) {
1248
1440
  if (!t || !t.xs || t.noc === 0) return;
1249
1441
  const { xs: r, ys: n, endPts: o, flags: c } = t;
1250
1442
  if (!(r && n && o && c)) return;
1251
- this._i.beginPath();
1443
+ this.Ci.beginPath();
1252
1444
  let l = 0;
1253
1445
  for (let f = 0; f < o.length; f++) {
1254
1446
  const u = o[f];
1255
1447
  if (!(u < l)) {
1256
1448
  if (u >= l) {
1257
- const d = e + r[l] * s, p = i - n[l] * s;
1258
- this._i.moveTo(d, p);
1259
- let g = l + 1;
1260
- for (; g <= u; )
1261
- if (1 & c[g]) {
1262
- const m = e + r[g] * s, x = i - n[g] * s;
1263
- this._i.lineTo(m, x), g++;
1449
+ const g = e + r[l] * s, v = i - n[l] * s;
1450
+ this.Ci.moveTo(g, v);
1451
+ let m = l + 1;
1452
+ for (; m <= u; )
1453
+ if (1 & c[m]) {
1454
+ const d = e + r[m] * s, x = i - n[m] * s;
1455
+ this.Ci.lineTo(d, x), m++;
1264
1456
  } else {
1265
- const m = e + r[g] * s, x = i - n[g] * s;
1266
- let R = g + 1 > u ? l : g + 1;
1267
- if (1 & c[R]) {
1268
- const w = e + r[R] * s, C = i - n[R] * s;
1269
- this._i.quadraticCurveTo(m, x, w, C), g = R + 1;
1457
+ const d = e + r[m] * s, x = i - n[m] * s;
1458
+ let p = m + 1 > u ? l : m + 1;
1459
+ if (1 & c[p]) {
1460
+ const E = e + r[p] * s, y = i - n[p] * s;
1461
+ this.Ci.quadraticCurveTo(d, x, E, y), m = p + 1;
1270
1462
  } else {
1271
- const w = (m + (e + r[R] * s)) / 2, C = (x + (i - n[R] * s)) / 2;
1272
- this._i.quadraticCurveTo(m, x, w, C), g = R;
1463
+ const E = (d + (e + r[p] * s)) / 2, y = (x + (i - n[p] * s)) / 2;
1464
+ this.Ci.quadraticCurveTo(d, x, E, y), m = p;
1273
1465
  }
1274
1466
  }
1275
- this._i.closePath();
1467
+ this.Ci.closePath();
1276
1468
  }
1277
1469
  l = u + 1;
1278
1470
  }
1279
1471
  }
1280
- this._i.fill();
1472
+ this.Ci.fill();
1281
1473
  }
1282
1474
  }
1283
- class _t {
1475
+ class zt {
1284
1476
  constructor() {
1285
- h(this, "si");
1286
- this.si = new I();
1477
+ a(this, "Ri");
1478
+ this.Ri = new q();
1287
1479
  }
1288
- calculateMaxGlyphDimensions(t, e, i) {
1480
+ Si(t, e, i) {
1289
1481
  let s = 0;
1290
- const r = this.si.ti(i, e), n = r.lineHeight;
1482
+ const r = this.Ri.mi(i, e), n = r.lineHeight;
1291
1483
  for (const o of t) {
1292
- const c = this.si.Js(i, o);
1484
+ const c = this.Ri._i(i, o);
1293
1485
  if (c === 0) continue;
1294
- const l = this.si.Qs(i, c) * r.scale;
1486
+ const l = this.Ri.pi(i, c) * r.scale;
1295
1487
  s = Math.max(s, l);
1296
1488
  }
1297
1489
  return { width: Math.ceil(s), height: Math.ceil(n) };
1298
1490
  }
1299
- getCharacterAdvanceWidth(t, e, i) {
1300
- const s = this.si.ti(i, e), r = this.si.Js(i, t);
1301
- return this.si.Qs(i, r) * s.scale;
1302
- }
1303
- getFontMetrics(t, e) {
1304
- return this.si.ti(e, t);
1305
- }
1306
- ei() {
1307
- this.si.ei();
1491
+ gi() {
1492
+ this.Ri.gi();
1308
1493
  }
1309
1494
  }
1310
- class Pt {
1495
+ class kt {
1311
1496
  constructor() {
1312
- h(this, "pi");
1313
- this.pi = new I();
1497
+ a(this, "wi");
1498
+ this.wi = new q();
1314
1499
  }
1315
1500
  createCharacterObjects(t, e) {
1316
1501
  return t.map((i, s) => {
1317
- const r = i.codePointAt(0) || 0, n = this.wi(s);
1502
+ const r = i.codePointAt(0) || 0, n = this.Ai(s);
1318
1503
  let o = 0;
1319
1504
  if (e.hmtx && e.hmtx.aWidth) {
1320
- const c = this.pi.js(e, r);
1505
+ const c = this.wi.li(e, r);
1321
1506
  c > 0 && e.hmtx.aWidth[c] !== void 0 && (o = e.hmtx.aWidth[c]);
1322
1507
  }
1323
1508
  return { character: i, unicode: r, color: n, advanceWidth: o };
1324
1509
  });
1325
1510
  }
1326
- wi(t) {
1511
+ Ai(t) {
1327
1512
  return [t % 256 / 255, Math.floor(t / 256) % 256 / 255, Math.floor(t / 65536) % 256 / 255];
1328
1513
  }
1329
- xi(t, e) {
1330
- if (!L.M(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1514
+ zi(t, e) {
1515
+ if (!$.v(typeof t == "string", "Character must be a string.", { method: "getCharacterColor", providedValue: t })) return [0, 0, 0];
1331
1516
  const i = e.find((s) => s.character === t);
1332
1517
  return i ? i.color : [0, 0, 0];
1333
1518
  }
1334
- bi(t, e) {
1335
- return L.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.xi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1519
+ Ti(t, e) {
1520
+ return $.v(typeof t == "string" && t.length > 0, "Characters must be a string with at least one character.", { method: "getCharacterColors", providedValue: t }) ? Array.from(t).map((i) => this.zi(i, e) || [0, 0, 0]) : [[0, 0, 0]];
1336
1521
  }
1337
1522
  }
1338
- class Ft {
1523
+ class Nt {
1339
1524
  constructor(t, e = 16) {
1340
- h(this, "Ri");
1341
- h(this, "Mi", []);
1342
- h(this, "Si");
1343
- h(this, "Fi", 16);
1344
- h(this, "zi", 0);
1345
- h(this, "Pi", 0);
1346
- h(this, "ki", { width: 0, height: 0 });
1347
- h(this, "Ti");
1348
- h(this, "Gi");
1349
- h(this, "Ai");
1350
- h(this, "Li");
1351
- h(this, "Ei");
1352
- this.Fi = e, this.Gi = new At(), this.Ai = new Tt(t), this.Li = new _t(), this.Ei = new Pt();
1353
- }
1354
- async Bi(t) {
1525
+ a(this, "Ei");
1526
+ a(this, "Li", []);
1527
+ a(this, "ki");
1528
+ a(this, "Pi", 16);
1529
+ a(this, "Gi", 0);
1530
+ a(this, "Bi", 0);
1531
+ a(this, "Di", { width: 0, height: 0 });
1532
+ a(this, "Ii");
1533
+ a(this, "Wi");
1534
+ a(this, "Oi");
1535
+ a(this, "Hi");
1536
+ a(this, "Vi");
1537
+ this.Pi = e, this.Wi = new Ot(), this.Oi = new $t(t), this.Hi = new zt(), this.Vi = new kt();
1538
+ }
1539
+ async Ki(t) {
1355
1540
  let e;
1356
- if (!t) throw new v("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1541
+ if (!t) throw new U("Embedded font not available. This appears to be a minified build - please provide `fontSource`.");
1357
1542
  {
1358
1543
  const i = await fetch(t);
1359
- if (!i.ok) throw new v(`Failed to load font file: ${i.status} ${i.statusText}`);
1544
+ if (!i.ok) throw new U(`Failed to load font file: ${i.status} ${i.statusText}`);
1360
1545
  e = await i.arrayBuffer();
1361
1546
  }
1362
- await this.Di(e), this.Ri = A.parse(e)[0], await this.Wi();
1547
+ await this.Ni(e), this.Ei = L.parse(e)[0], await this.Xi();
1363
1548
  }
1364
- Ii(t) {
1365
- if (t === void 0) return this.Fi;
1366
- this.Fi = t, this.ki = this.Li.calculateMaxGlyphDimensions(this.Mi.map((i) => i.character), this.Fi, this.Ri);
1367
- const e = this.Ai.createTextureAtlas(this.Mi, this.ki, this.Fi, this.Ri);
1368
- this.Si = e.framebuffer, this.zi = e.columns, this.Pi = e.rows;
1549
+ ji(t) {
1550
+ if (t === void 0) return this.Pi;
1551
+ this.Pi = t, this.Di = this.Hi.Si(this.Li.map((i) => i.character), this.Pi, this.Ei);
1552
+ const e = this.Oi.createTextureAtlas(this.Li, this.Di, this.Pi, this.Ei);
1553
+ this.ki = e.framebuffer, this.Gi = e.columns, this.Bi = e.rows;
1369
1554
  }
1370
- async Ui(t) {
1555
+ async Yi(t) {
1371
1556
  try {
1372
1557
  const e = await fetch(t);
1373
- if (!e.ok) throw new v(`Failed to load font file: ${e.status} ${e.statusText}`);
1558
+ if (!e.ok) throw new U(`Failed to load font file: ${e.status} ${e.statusText}`);
1374
1559
  const i = await e.arrayBuffer();
1375
- await this.Di(i);
1376
- const s = A.parse(i);
1560
+ await this.Ni(i);
1561
+ const s = L.parse(i);
1377
1562
  if (!s || s.length === 0) throw Error("Failed to parse font file");
1378
- this.Ri = s[0], await this.Wi();
1563
+ this.Ei = s[0], await this.Xi();
1379
1564
  } catch (e) {
1380
- throw new v("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1565
+ throw new U("Failed to load font: " + (e instanceof Error ? e.message : "Unknown error"), e);
1381
1566
  }
1382
1567
  }
1383
- async Di(t) {
1568
+ async Ni(t) {
1384
1569
  const e = Date.now();
1385
- this.Ti = new FontFace("CustomFont_" + e, t), await this.Ti.load(), document.fonts.add(this.Ti);
1570
+ this.Ii = new FontFace("CustomFont_" + e, t), await this.Ii.load(), document.fonts.add(this.Ii);
1386
1571
  }
1387
- async Wi() {
1388
- const t = this.Gi.extractCharacters(this.Ri), e = this.Gi.filterProblematicCharacters(t);
1389
- this.Mi = this.Ei.createCharacterObjects(e, this.Ri), this.ki = this.Li.calculateMaxGlyphDimensions(e, this.Fi, this.Ri);
1390
- const i = this.Ai.createTextureAtlas(this.Mi, this.ki, this.Fi, this.Ri);
1391
- this.Si = i.framebuffer, this.zi = i.columns, this.Pi = i.rows;
1572
+ async Xi() {
1573
+ const t = this.Wi.si(this.Ei), e = this.Wi.ni(t);
1574
+ this.Li = this.Vi.createCharacterObjects(e, this.Ei), this.Di = this.Hi.Si(e, this.Pi, this.Ei);
1575
+ const i = this.Oi.createTextureAtlas(this.Li, this.Di, this.Pi, this.Ei);
1576
+ this.ki = i.framebuffer, this.Gi = i.columns, this.Bi = i.rows;
1392
1577
  }
1393
- xi(t) {
1394
- return this.Ei.xi(t, this.Mi);
1578
+ zi(t) {
1579
+ return this.Vi.zi(t, this.Li);
1395
1580
  }
1396
- bi(t) {
1397
- return this.Ei.bi(t, this.Mi);
1581
+ Ti(t) {
1582
+ return this.Vi.Ti(t, this.Li);
1398
1583
  }
1399
- Ut() {
1400
- this.Si.Ut(), document.fonts.delete(this.Ti);
1584
+ Pt() {
1585
+ this.ki.Pt(), document.fonts.delete(this.Ii);
1401
1586
  }
1402
1587
  get fontFramebuffer() {
1403
- return this.Si;
1588
+ return this.ki;
1404
1589
  }
1405
1590
  get characters() {
1406
- return this.Mi;
1591
+ return this.Li;
1407
1592
  }
1408
1593
  get textureColumns() {
1409
- return this.zi;
1594
+ return this.Gi;
1410
1595
  }
1411
1596
  get textureRows() {
1412
- return this.Pi;
1597
+ return this.Bi;
1413
1598
  }
1414
1599
  get maxGlyphDimensions() {
1415
- return this.ki;
1600
+ return this.Di;
1416
1601
  }
1417
1602
  get fontSize() {
1418
- return this.Fi;
1603
+ return this.Pi;
1419
1604
  }
1420
1605
  get font() {
1421
- return this.Ri;
1606
+ return this.Ei;
1422
1607
  }
1423
1608
  }
1424
- class St {
1609
+ class Wt {
1425
1610
  constructor(t, e, i) {
1426
- h(this, "Oi");
1427
- h(this, "Vi");
1428
- h(this, "$t");
1429
- h(this, "wt");
1430
- h(this, "Hi");
1431
- h(this, "Ki");
1432
- h(this, "Ni");
1433
- h(this, "Xi");
1434
- h(this, "ji");
1435
- this.Ni = t, this.Xi = e, this.ji = i, this.rt();
1436
- }
1437
- rt() {
1438
- this.Oi = Math.floor(this.Ni.width / this.Xi), this.Vi = Math.floor(this.Ni.height / this.ji), this.$t = this.Oi * this.Xi, this.wt = this.Vi * this.ji, this.Hi = Math.floor((this.Ni.width - this.$t) / 2), this.Ki = Math.floor((this.Ni.height - this.wt) / 2);
1439
- }
1440
- Yi(t, e) {
1441
- this.Xi = t, this.ji = e, this.rt();
1611
+ a(this, "qi");
1612
+ a(this, "Zi");
1613
+ a(this, "dt");
1614
+ a(this, "_t");
1615
+ a(this, "Ji");
1616
+ a(this, "Qi");
1617
+ a(this, "tr");
1618
+ a(this, "er");
1619
+ a(this, "sr");
1620
+ this.tr = t, this.er = e, this.sr = i, this.ir();
1621
+ }
1622
+ ir() {
1623
+ this.qi = Math.floor(this.tr.width / this.er), this.Zi = Math.floor(this.tr.height / this.sr), this.dt = this.qi * this.er, this._t = this.Zi * this.sr, this.Ji = Math.floor((this.tr.width - this.dt) / 2), this.Qi = Math.floor((this.tr.height - this._t) / 2);
1624
+ }
1625
+ rr(t, e) {
1626
+ this.er = t, this.sr = e, this.ir();
1442
1627
  }
1443
1628
  get cellWidth() {
1444
- return this.Xi;
1629
+ return this.er;
1445
1630
  }
1446
1631
  get cellHeight() {
1447
- return this.ji;
1632
+ return this.sr;
1448
1633
  }
1449
1634
  get cols() {
1450
- return this.Oi;
1635
+ return this.qi;
1451
1636
  }
1452
1637
  get rows() {
1453
- return this.Vi;
1638
+ return this.Zi;
1454
1639
  }
1455
1640
  get width() {
1456
- return this.$t;
1641
+ return this.dt;
1457
1642
  }
1458
1643
  get height() {
1459
- return this.wt;
1644
+ return this._t;
1460
1645
  }
1461
1646
  get offsetX() {
1462
- return this.Hi;
1647
+ return this.Ji;
1463
1648
  }
1464
1649
  get offsetY() {
1465
- return this.Ki;
1650
+ return this.Qi;
1466
1651
  }
1467
1652
  }
1468
- class Mt {
1653
+ class Xt {
1469
1654
  constructor(t = {}) {
1470
- h(this, "Ni");
1471
- h(this, "qi");
1472
- h(this, "Zi");
1473
- t.canvas ? (this.Ni = t.canvas, this.Zi = !1) : (this.Ni = this.Ji(t.width, t.height), this.Zi = !0), this.Ni.style.imageRendering = "pixelated";
1474
- }
1475
- Ji(t, e) {
1655
+ a(this, "tr");
1656
+ a(this, "nr", null);
1657
+ a(this, "ar", !1);
1658
+ a(this, "hr");
1659
+ a(this, "cr");
1660
+ this.ar = t.overlay ?? !1, this.ar && t.canvas ? (this.nr = t.canvas, this.tr = this.lr(), this.cr = !0, this.ur()) : t.canvas ? (this.tr = t.canvas, this.cr = !1) : (this.tr = this.dr(t.width, t.height), this.cr = !0), this.tr.style.imageRendering = "pixelated";
1661
+ }
1662
+ dr(t, e) {
1476
1663
  const i = document.createElement("canvas");
1477
1664
  return i.className = "textmodeCanvas", i.style.imageRendering = "pixelated", i.width = t || 800, i.height = e || 600, document.body.appendChild(i), i;
1478
1665
  }
1479
- Qi(t, e) {
1480
- this.Ni.width = t ?? this.Ni.width, this.Ni.height = e ?? this.Ni.height;
1666
+ lr() {
1667
+ const t = document.createElement("canvas");
1668
+ t.className = "textmodeCanvas", t.style.imageRendering = "pixelated";
1669
+ const e = this.nr.getBoundingClientRect();
1670
+ let i = Math.round(e.width), s = Math.round(e.height);
1671
+ if (this.nr instanceof HTMLVideoElement) {
1672
+ const o = this.nr;
1673
+ (i === 0 || s === 0) && o.videoWidth > 0 && o.videoHeight > 0 && (i = o.videoWidth, s = o.videoHeight);
1674
+ }
1675
+ t.width = i, t.height = s, t.style.position = "absolute", t.style.pointerEvents = "none";
1676
+ const r = window.getComputedStyle(this.nr);
1677
+ let n = parseInt(r.zIndex || "0", 10);
1678
+ return isNaN(n) && (n = 0), t.style.zIndex = "" + (n + 1), t;
1679
+ }
1680
+ ur() {
1681
+ var t;
1682
+ this._r(), (t = this.nr.parentNode) == null || t.insertBefore(this.tr, this.nr.nextSibling), window.ResizeObserver && (this.hr = new ResizeObserver(() => {
1683
+ this.pr();
1684
+ }), this.hr.observe(this.nr)), window.addEventListener("resize", () => {
1685
+ this.pr();
1686
+ });
1481
1687
  }
1482
- tr() {
1483
- const t = this.Ni.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1484
- if (!t) throw new v("`textmode.js` requires WebGL2 support.");
1688
+ _r() {
1689
+ if (!this.nr) return;
1690
+ const t = this.nr.getBoundingClientRect();
1691
+ let e = this.nr.offsetParent;
1692
+ if (e && e !== document.body) {
1693
+ const i = e.getBoundingClientRect();
1694
+ this.tr.style.top = t.top - i.top + "px", this.tr.style.left = t.left - i.left + "px";
1695
+ } else this.tr.style.top = t.top + window.scrollY + "px", this.tr.style.left = t.left + window.scrollX + "px";
1696
+ }
1697
+ pr(t, e) {
1698
+ if (this.ar) {
1699
+ const i = this.nr.getBoundingClientRect();
1700
+ let s = Math.round(i.width), r = Math.round(i.height);
1701
+ if (this.nr instanceof HTMLVideoElement) {
1702
+ const n = this.nr;
1703
+ (s === 0 || r === 0) && n.videoWidth > 0 && n.videoHeight > 0 && (s = n.videoWidth, r = n.videoHeight);
1704
+ }
1705
+ this.tr.width = s, this.tr.height = r, this._r();
1706
+ } else this.tr.width = t ?? this.tr.width, this.tr.height = e ?? this.tr.height;
1707
+ }
1708
+ mr() {
1709
+ const t = this.tr.getContext("webgl2", { alpha: !0, premultipliedAlpha: !1, preserveDrawingBuffer: !0, antialias: !1, depth: !1, stencil: !1, powerPreference: "high-performance" });
1710
+ if (!t) throw new U("`textmode.js` requires WebGL2 support.");
1485
1711
  return t;
1486
1712
  }
1487
- Ut() {
1488
- this.qi && this.qi.disconnect();
1489
- const t = this.Ni.getContext("webgl") || this.Ni.getContext("webgl2");
1713
+ Pt() {
1714
+ this.hr && this.hr.disconnect();
1715
+ const t = this.tr.getContext("webgl") || this.tr.getContext("webgl2");
1490
1716
  if (t) {
1491
1717
  const e = t.getExtension("WEBGL_lose_context");
1492
1718
  e && e.loseContext();
1493
1719
  }
1494
- this.Zi && this.Ni.parentNode && this.Ni.parentNode.removeChild(this.Ni);
1720
+ this.cr && this.tr.parentNode && this.tr.parentNode.removeChild(this.tr);
1495
1721
  }
1496
1722
  get canvas() {
1497
- return this.Ni;
1723
+ return this.tr;
1724
+ }
1725
+ get targetCanvas() {
1726
+ return this.nr;
1498
1727
  }
1499
1728
  get width() {
1500
- return this.Ni.width;
1729
+ return this.tr.width;
1501
1730
  }
1502
1731
  get height() {
1503
- return this.Ni.height;
1732
+ return this.tr.height;
1504
1733
  }
1505
1734
  }
1506
- class Lt {
1735
+ class z {
1736
+ constructor(t, e, i, s) {
1737
+ a(this, "texture");
1738
+ a(this, "width");
1739
+ a(this, "height");
1740
+ a(this, "vt");
1741
+ a(this, "P", 0);
1742
+ a(this, "N", 0);
1743
+ a(this, "X", 0);
1744
+ a(this, "G", [0, 0]);
1745
+ a(this, "gr", "sampled");
1746
+ a(this, "vr", "fixed");
1747
+ a(this, "Y", [1, 1, 1]);
1748
+ a(this, "q", [0, 0, 0]);
1749
+ a(this, "yr", [0, 0, 0, 1]);
1750
+ a(this, "Cr", [[0.1, 0, 0]]);
1751
+ a(this, "wr");
1752
+ this.vt = t, this.texture = e, this.width = i, this.height = s;
1753
+ }
1754
+ Pt() {
1755
+ this.vt.deleteTexture(this.texture);
1756
+ }
1757
+ $r(t) {
1758
+ return typeof t == "boolean" ? t ? 1 : 0 : (t == null ? 0 : Number(t)) > 0 ? 1 : 0;
1759
+ }
1760
+ invert(t = !0) {
1761
+ return this.P = this.$r(t), this;
1762
+ }
1763
+ flipX(t = !0) {
1764
+ return this.N = this.$r(t), this;
1765
+ }
1766
+ flipY(t = !0) {
1767
+ return this.X = this.$r(t), this;
1768
+ }
1769
+ charRotation(t) {
1770
+ const e = 255 * t / 360, i = Math.floor(e) / 255, s = Math.round(e - Math.floor(e));
1771
+ return this.G = [i, s], this;
1772
+ }
1773
+ get flags() {
1774
+ return { invert: this.P, flipX: this.N, flipY: this.X };
1775
+ }
1776
+ get charRotationRG() {
1777
+ return this.G;
1778
+ }
1779
+ charColorMode(t) {
1780
+ return this.gr = t, this;
1781
+ }
1782
+ cellColorMode(t) {
1783
+ return this.vr = t, this;
1784
+ }
1785
+ charColor(t, e, i) {
1786
+ return this.Y = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255], this;
1787
+ }
1788
+ cellColor(t, e, i) {
1789
+ return this.q = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255], this;
1790
+ }
1791
+ background(t, e, i, s) {
1792
+ return this.yr = [(t ?? 0) / 255, (e ?? t ?? 0) / 255, (i ?? t ?? 0) / 255, (s ?? 255) / 255], this;
1793
+ }
1794
+ charactersFromColors(t) {
1795
+ const e = t.filter((i) => Array.isArray(i)).slice(0, 64);
1796
+ return this.Cr = e, this;
1797
+ }
1798
+ characters(t) {
1799
+ const e = this.wr(t);
1800
+ return this.charactersFromColors(e), this;
1801
+ }
1802
+ get characterListUniforms() {
1803
+ return { count: this.Cr.length, list: this.Cr };
1804
+ }
1805
+ get colorUniforms() {
1806
+ return { charColorFixed: this.gr === "fixed", Y: this.Y, cellColorFixed: this.vr === "fixed", cellColor: this.q, backgroundColor: this.yr };
1807
+ }
1808
+ static fromSource(t, e, i) {
1809
+ const s = t.context, r = s.createTexture();
1810
+ s.bindTexture(s.TEXTURE_2D, r), s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL, 1), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MIN_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_MAG_FILTER, s.NEAREST), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_S, s.CLAMP_TO_EDGE), s.texParameteri(s.TEXTURE_2D, s.TEXTURE_WRAP_T, s.CLAMP_TO_EDGE), s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, s.RGBA, s.UNSIGNED_BYTE, e), s.bindTexture(s.TEXTURE_2D, null);
1811
+ const n = e.naturalWidth ?? e.width ?? e.videoWidth ?? 0, o = e.naturalHeight ?? e.height ?? e.videoHeight ?? 0, c = new z(s, r, n, o);
1812
+ return c.wr = i, c;
1813
+ }
1814
+ }
1815
+ class Ht {
1507
1816
  constructor(t = 60) {
1508
- h(this, "er");
1509
- h(this, "sr");
1510
- h(this, "ir", null);
1511
- h(this, "rr", 0);
1512
- h(this, "nr", !0);
1513
- h(this, "ar", 0);
1514
- h(this, "hr", 0);
1515
- h(this, "cr", []);
1516
- h(this, "lr", 10);
1517
- h(this, "ur", 0);
1518
- this.er = t, this.sr = 1e3 / t;
1817
+ a(this, "br");
1818
+ a(this, "Fr");
1819
+ a(this, "Mr", null);
1820
+ a(this, "Rr", 0);
1821
+ a(this, "Sr", !0);
1822
+ a(this, "Ar", 0);
1823
+ a(this, "zr", 0);
1824
+ a(this, "Tr", []);
1825
+ a(this, "Er", 10);
1826
+ a(this, "Lr", 0);
1827
+ this.br = t, this.Fr = 1e3 / t;
1519
1828
  }
1520
1829
  start(t) {
1521
- if (!this.nr) return;
1522
- this.rr = performance.now();
1830
+ if (!this.Sr) return;
1831
+ this.Rr = performance.now();
1523
1832
  const e = (i) => {
1524
- if (!this.nr) return void (this.ir = null);
1525
- const s = i - this.rr;
1526
- s >= this.sr && (t(), this.rr = i - s % this.sr), this.nr && (this.ir = requestAnimationFrame(e));
1833
+ if (!this.Sr) return void (this.Mr = null);
1834
+ const s = i - this.Rr;
1835
+ s >= this.Fr && (t(), this.Rr = i - s % this.Fr), this.Sr && (this.Mr = requestAnimationFrame(e));
1527
1836
  };
1528
- this.ir = requestAnimationFrame(e);
1837
+ this.Mr = requestAnimationFrame(e);
1529
1838
  }
1530
1839
  stop() {
1531
- this.ir && (cancelAnimationFrame(this.ir), this.ir = null);
1840
+ this.Mr && (cancelAnimationFrame(this.Mr), this.Mr = null);
1532
1841
  }
1533
1842
  pause() {
1534
- this.nr && (this.nr = !1, this.stop());
1843
+ this.Sr && (this.Sr = !1, this.stop());
1535
1844
  }
1536
1845
  resume(t) {
1537
- this.nr || (this.nr = !0, this.start(t));
1846
+ this.Sr || (this.Sr = !0, this.start(t));
1538
1847
  }
1539
1848
  frameRate(t, e) {
1540
- if (t === void 0) return this.ar;
1541
- this.er = t, this.sr = 1e3 / t, this.nr && e && (this.stop(), this.start(e));
1849
+ if (t === void 0) return this.Ar;
1850
+ this.br = t, this.Fr = 1e3 / t, this.Sr && e && (this.stop(), this.start(e));
1542
1851
  }
1543
1852
  measureFrameRate() {
1544
1853
  const t = performance.now();
1545
- if (this.hr > 0) {
1546
- const e = t - this.hr;
1547
- this.cr.push(e), this.cr.length > this.lr && this.cr.shift();
1548
- const i = this.cr.reduce((s, r) => s + r, 0) / this.cr.length;
1549
- this.ar = 1e3 / i;
1854
+ if (this.zr > 0) {
1855
+ const e = t - this.zr;
1856
+ this.Tr.push(e), this.Tr.length > this.Er && this.Tr.shift();
1857
+ const i = this.Tr.reduce((s, r) => s + r, 0) / this.Tr.length;
1858
+ this.Ar = 1e3 / i;
1550
1859
  }
1551
- this.hr = t;
1860
+ this.zr = t;
1552
1861
  }
1553
1862
  get isLooping() {
1554
- return this.nr;
1863
+ return this.Sr;
1555
1864
  }
1556
1865
  get frameRateLimit() {
1557
- return this.er;
1866
+ return this.br;
1558
1867
  }
1559
1868
  get currentFrameRate() {
1560
- return this.ar;
1869
+ return this.Ar;
1561
1870
  }
1562
1871
  get frameCount() {
1563
- return this.ur;
1872
+ return this.Lr;
1564
1873
  }
1565
1874
  set frameCount(t) {
1566
- this.ur = t;
1875
+ this.Lr = t;
1567
1876
  }
1568
1877
  incrementFrame() {
1569
- this.ur++;
1878
+ this.Lr++;
1570
1879
  }
1571
1880
  resetFrameCount() {
1572
- this.ur = 0;
1881
+ this.Lr = 0;
1573
1882
  }
1574
1883
  }
1575
- class Ut {
1884
+ class Yt {
1576
1885
  constructor() {
1577
- h(this, "dr", /* @__PURE__ */ new Map());
1578
- h(this, "_r", null);
1579
- h(this, "pr", null);
1580
- h(this, "gr");
1581
- h(this, "mr");
1582
- h(this, "vr", !1);
1583
- h(this, "yr");
1584
- h(this, "Cr");
1585
- h(this, "$r", { ArrowUp: "UP_ARROW", ArrowDown: "DOWN_ARROW", ArrowLeft: "LEFT_ARROW", ArrowRight: "RIGHT_ARROW", F1: "F1", F2: "F2", F3: "F3", F4: "F4", F5: "F5", F6: "F6", F7: "F7", F8: "F8", F9: "F9", F10: "F10", F11: "F11", F12: "F12", Enter: "ENTER", Return: "RETURN", Tab: "TAB", Escape: "ESCAPE", Backspace: "BACKSPACE", Delete: "DELETE", Insert: "INSERT", Home: "HOME", End: "END", PageUp: "PAGE_UP", PageDown: "PAGE_DOWN", Shift: "SHIFT", Control: "CONTROL", Alt: "ALT", Meta: "META", " ": "SPACE" });
1586
- }
1587
- wr() {
1588
- this.vr || (this.gr = (t) => {
1589
- this.br(t);
1590
- }, this.mr = (t) => {
1591
- this.Rr(t);
1592
- }, window.addEventListener("keydown", this.gr, { passive: !1 }), window.addEventListener("keyup", this.mr, { passive: !1 }), this.vr = !0);
1593
- }
1594
- Mr() {
1595
- this.vr && (window.removeEventListener("keydown", this.gr), window.removeEventListener("keyup", this.mr), this.vr = !1, this.dr.clear(), this._r = null, this.pr = null);
1596
- }
1597
- Sr(t) {
1598
- this.yr = t;
1599
- }
1600
- Fr(t) {
1601
- this.Cr = t;
1602
- }
1603
- zr(t) {
1604
- const e = this.Pr(t), i = this.dr.get(t) || this.dr.get(e);
1886
+ a(this, "kr", /* @__PURE__ */ new Map());
1887
+ a(this, "Pr", null);
1888
+ a(this, "Gr", null);
1889
+ a(this, "Br");
1890
+ a(this, "Dr");
1891
+ a(this, "Ir", !1);
1892
+ a(this, "Wr");
1893
+ a(this, "Or");
1894
+ a(this, "Hr", { ArrowUp: "UP_ARROW", ArrowDown: "DOWN_ARROW", ArrowLeft: "LEFT_ARROW", ArrowRight: "RIGHT_ARROW", F1: "F1", F2: "F2", F3: "F3", F4: "F4", F5: "F5", F6: "F6", F7: "F7", F8: "F8", F9: "F9", F10: "F10", F11: "F11", F12: "F12", Enter: "ENTER", Return: "RETURN", Tab: "TAB", Escape: "ESCAPE", Backspace: "BACKSPACE", Delete: "DELETE", Insert: "INSERT", Home: "HOME", End: "END", PageUp: "PAGE_UP", PageDown: "PAGE_DOWN", Shift: "SHIFT", Control: "CONTROL", Alt: "ALT", Meta: "META", " ": "SPACE" });
1895
+ }
1896
+ Vr() {
1897
+ this.Ir || (this.Br = (t) => {
1898
+ this.Kr(t);
1899
+ }, this.Dr = (t) => {
1900
+ this.Nr(t);
1901
+ }, window.addEventListener("keydown", this.Br, { passive: !1 }), window.addEventListener("keyup", this.Dr, { passive: !1 }), this.Ir = !0);
1902
+ }
1903
+ Xr() {
1904
+ this.Ir && (window.removeEventListener("keydown", this.Br), window.removeEventListener("keyup", this.Dr), this.Ir = !1, this.kr.clear(), this.Pr = null, this.Gr = null);
1905
+ }
1906
+ jr(t) {
1907
+ this.Wr = t;
1908
+ }
1909
+ Yr(t) {
1910
+ this.Or = t;
1911
+ }
1912
+ qr(t) {
1913
+ const e = this.Zr(t), i = this.kr.get(t) || this.kr.get(e);
1605
1914
  return (i == null ? void 0 : i.isPressed) || !1;
1606
1915
  }
1607
- kr() {
1608
- return this._r;
1916
+ Jr() {
1917
+ return this.Pr;
1609
1918
  }
1610
- Tr() {
1611
- return this.pr;
1919
+ Qr() {
1920
+ return this.Gr;
1612
1921
  }
1613
- Gr() {
1922
+ tn() {
1614
1923
  const t = [];
1615
- for (const [e, i] of this.dr) i.isPressed && t.push(e);
1924
+ for (const [e, i] of this.kr) i.isPressed && t.push(e);
1616
1925
  return t;
1617
1926
  }
1618
- Ar() {
1619
- return { ctrl: this.zr("Control"), shift: this.zr("Shift"), alt: this.zr("Alt"), meta: this.zr("Meta") };
1927
+ en() {
1928
+ return { ctrl: this.qr("Control"), shift: this.qr("Shift"), alt: this.qr("Alt"), meta: this.qr("Meta") };
1620
1929
  }
1621
- Lr() {
1622
- this.dr.clear(), this._r = null, this.pr = null;
1930
+ sn() {
1931
+ this.kr.clear(), this.Pr = null, this.Gr = null;
1623
1932
  }
1624
- br(t) {
1933
+ Kr(t) {
1625
1934
  const e = t.key, i = Date.now();
1626
- this.dr.has(e) || this.dr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1627
- const s = this.dr.get(e);
1628
- if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this._r = e, this.yr)) {
1935
+ this.kr.has(e) || this.kr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1936
+ const s = this.kr.get(e);
1937
+ if (!s.isPressed && (s.isPressed = !0, s.lastPressTime = i, this.Pr = e, this.Wr)) {
1629
1938
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !0, originalEvent: t };
1630
- this.yr(r);
1939
+ this.Wr(r);
1631
1940
  }
1632
1941
  }
1633
- Rr(t) {
1942
+ Nr(t) {
1634
1943
  const e = t.key, i = Date.now();
1635
- this.dr.has(e) || this.dr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1636
- const s = this.dr.get(e);
1637
- if (s.isPressed = !1, s.lastReleaseTime = i, this.pr = e, this.Cr) {
1944
+ this.kr.has(e) || this.kr.set(e, { isPressed: !1, lastPressTime: 0, lastReleaseTime: 0 });
1945
+ const s = this.kr.get(e);
1946
+ if (s.isPressed = !1, s.lastReleaseTime = i, this.Gr = e, this.Or) {
1638
1947
  const r = { key: e, keyCode: t.keyCode, ctrlKey: t.ctrlKey, shiftKey: t.shiftKey, altKey: t.altKey, metaKey: t.metaKey, isPressed: !1, originalEvent: t };
1639
- this.Cr(r);
1948
+ this.Or(r);
1640
1949
  }
1641
1950
  }
1642
- Pr(t) {
1643
- return this.$r[t] || t.toLowerCase();
1951
+ Zr(t) {
1952
+ return this.Hr[t] || t.toLowerCase();
1644
1953
  }
1645
1954
  }
1646
- class Bt {
1955
+ class Vt {
1647
1956
  constructor(t) {
1648
- h(this, "Ni");
1649
- h(this, "Er");
1650
- h(this, "Br", { x: -1, y: -1 });
1651
- h(this, "Dr", { x: -1, y: -1 });
1652
- h(this, "Wr", null);
1653
- h(this, "Ir");
1654
- h(this, "Ur");
1655
- h(this, "Or");
1656
- h(this, "Vr");
1657
- h(this, "Hr");
1658
- h(this, "Kr");
1659
- h(this, "vr", !1);
1660
- h(this, "Nr");
1661
- h(this, "Xr");
1662
- h(this, "jr");
1663
- h(this, "Yr");
1664
- h(this, "qr");
1665
- this.Ni = t;
1666
- }
1667
- Bi(t) {
1668
- this.Er = t, this.Zr();
1669
- }
1670
- wr() {
1671
- if (this.vr) return;
1672
- const t = this.Ni.canvas;
1673
- this.Ir = (e) => {
1674
- this.Jr(e), this.Qr(e);
1675
- }, this.Ur = () => {
1676
- this.Dr = { ...this.Br }, this.Br.x = -1, this.Br.y = -1, this.Wr = null;
1677
- }, this.Or = (e) => {
1678
- this.Jr(e), this.tn(e);
1679
- }, this.Vr = (e) => {
1680
- this.Jr(e), this.en(e);
1681
- }, this.Hr = (e) => {
1682
- this.Jr(e), this.sn(e);
1683
- }, this.Kr = (e) => {
1684
- this.Jr(e), this.rn(e);
1685
- }, t.addEventListener("mousemove", this.Ir, { passive: !0 }), t.addEventListener("mouseleave", this.Ur, { passive: !0 }), t.addEventListener("mousedown", this.Or, { passive: !0 }), t.addEventListener("mouseup", this.Vr, { passive: !0 }), t.addEventListener("click", this.Hr, { passive: !0 }), t.addEventListener("wheel", this.Kr, { passive: !1 }), this.vr = !0;
1686
- }
1687
- Mr() {
1688
- if (!this.vr) return;
1689
- const t = this.Ni.canvas;
1690
- t.removeEventListener("mousemove", this.Ir), t.removeEventListener("mouseleave", this.Ur), t.removeEventListener("mousedown", this.Or), t.removeEventListener("mouseup", this.Vr), t.removeEventListener("click", this.Hr), t.removeEventListener("wheel", this.Kr), this.vr = !1;
1691
- }
1692
- Zr() {
1693
- if (this.vr) try {
1694
- if (this.Wr) {
1695
- const t = new MouseEvent("mousemove", { clientX: this.Wr.x, clientY: this.Wr.y, bubbles: !1, cancelable: !1 });
1696
- this.Jr(t);
1697
- } else this.Br.x !== -1 && this.Br.y !== -1 && (this.Br.x >= this.Er.cols || this.Br.y >= this.Er.rows) && (this.Br.x = -1, this.Br.y = -1);
1957
+ a(this, "tr");
1958
+ a(this, "rn");
1959
+ a(this, "nn", { x: -1, y: -1 });
1960
+ a(this, "an", { x: -1, y: -1 });
1961
+ a(this, "hn", null);
1962
+ a(this, "cn");
1963
+ a(this, "ln");
1964
+ a(this, "un");
1965
+ a(this, "fn");
1966
+ a(this, "dn");
1967
+ a(this, "_n");
1968
+ a(this, "Ir", !1);
1969
+ a(this, "pn");
1970
+ a(this, "mn");
1971
+ a(this, "gn");
1972
+ a(this, "vn");
1973
+ a(this, "yn");
1974
+ this.tr = t;
1975
+ }
1976
+ Ki(t) {
1977
+ this.rn = t, this.Cn();
1978
+ }
1979
+ Vr() {
1980
+ if (this.Ir) return;
1981
+ const t = this.tr.canvas;
1982
+ this.cn = (e) => {
1983
+ this.wn(e), this.$n(e);
1984
+ }, this.ln = () => {
1985
+ this.an = { ...this.nn }, this.nn.x = -1, this.nn.y = -1, this.hn = null;
1986
+ }, this.un = (e) => {
1987
+ this.wn(e), this.bn(e);
1988
+ }, this.fn = (e) => {
1989
+ this.wn(e), this.xn(e);
1990
+ }, this.dn = (e) => {
1991
+ this.wn(e), this.Fn(e);
1992
+ }, this._n = (e) => {
1993
+ this.wn(e), this.Mn(e);
1994
+ }, t.addEventListener("mousemove", this.cn, { passive: !0 }), t.addEventListener("mouseleave", this.ln, { passive: !0 }), t.addEventListener("mousedown", this.un, { passive: !0 }), t.addEventListener("mouseup", this.fn, { passive: !0 }), t.addEventListener("click", this.dn, { passive: !0 }), t.addEventListener("wheel", this._n, { passive: !1 }), this.Ir = !0;
1995
+ }
1996
+ Xr() {
1997
+ if (!this.Ir) return;
1998
+ const t = this.tr.canvas;
1999
+ t.removeEventListener("mousemove", this.cn), t.removeEventListener("mouseleave", this.ln), t.removeEventListener("mousedown", this.un), t.removeEventListener("mouseup", this.fn), t.removeEventListener("click", this.dn), t.removeEventListener("wheel", this._n), this.Ir = !1;
2000
+ }
2001
+ Cn() {
2002
+ if (this.Ir) try {
2003
+ if (this.hn) {
2004
+ const t = new MouseEvent("mousemove", { clientX: this.hn.x, clientY: this.hn.y, bubbles: !1, cancelable: !1 });
2005
+ this.wn(t);
2006
+ } else this.nn.x !== -1 && this.nn.y !== -1 && (this.nn.x >= this.rn.cols || this.nn.y >= this.rn.rows) && (this.nn.x = -1, this.nn.y = -1);
1698
2007
  } catch {
1699
- this.Br.x = -1, this.Br.y = -1;
2008
+ this.nn.x = -1, this.nn.y = -1;
1700
2009
  }
1701
2010
  }
1702
- nn(t) {
1703
- this.Nr = t;
2011
+ Rn(t) {
2012
+ this.pn = t;
1704
2013
  }
1705
- Sr(t) {
1706
- this.Xr = t;
2014
+ jr(t) {
2015
+ this.mn = t;
1707
2016
  }
1708
- Fr(t) {
1709
- this.jr = t;
2017
+ Yr(t) {
2018
+ this.gn = t;
1710
2019
  }
1711
- an(t) {
1712
- this.Yr = t;
2020
+ Sn(t) {
2021
+ this.vn = t;
1713
2022
  }
1714
- hn(t) {
1715
- this.qr = t;
2023
+ An(t) {
2024
+ this.yn = t;
1716
2025
  }
1717
- cn() {
1718
- return { x: this.Br.x, y: this.Br.y };
2026
+ zn() {
2027
+ return { x: this.nn.x, y: this.nn.y };
1719
2028
  }
1720
- Qr(t) {
1721
- if (this.Yr) {
1722
- const e = { position: { ...this.Br }, previousPosition: { ...this.Dr }, originalEvent: t };
1723
- this.Yr(e);
2029
+ $n(t) {
2030
+ if (this.vn) {
2031
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, originalEvent: t };
2032
+ this.vn(e);
1724
2033
  }
1725
2034
  }
1726
- tn(t) {
1727
- if (this.Xr) {
1728
- const e = { position: { ...this.Br }, previousPosition: { ...this.Dr }, button: t.button, originalEvent: t };
1729
- this.Xr(e);
2035
+ bn(t) {
2036
+ if (this.mn) {
2037
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, button: t.button, originalEvent: t };
2038
+ this.mn(e);
1730
2039
  }
1731
2040
  }
1732
- en(t) {
1733
- if (this.jr) {
1734
- const e = { position: { ...this.Br }, previousPosition: { ...this.Dr }, button: t.button, originalEvent: t };
1735
- this.jr(e);
2041
+ xn(t) {
2042
+ if (this.gn) {
2043
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, button: t.button, originalEvent: t };
2044
+ this.gn(e);
1736
2045
  }
1737
2046
  }
1738
- sn(t) {
1739
- if (this.Nr) {
1740
- const e = { position: { ...this.Br }, previousPosition: { ...this.Dr }, button: t.button, originalEvent: t };
1741
- this.Nr(e);
2047
+ Fn(t) {
2048
+ if (this.pn) {
2049
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, button: t.button, originalEvent: t };
2050
+ this.pn(e);
1742
2051
  }
1743
2052
  }
1744
- rn(t) {
1745
- if (this.qr) {
1746
- const e = { position: { ...this.Br }, previousPosition: { ...this.Dr }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
1747
- this.qr(e);
2053
+ Mn(t) {
2054
+ if (this.yn) {
2055
+ const e = { position: { ...this.nn }, previousPosition: { ...this.an }, delta: { x: t.deltaX, y: t.deltaY }, originalEvent: t };
2056
+ this.yn(e);
1748
2057
  }
1749
2058
  }
1750
- Jr(t) {
1751
- const e = this.Ni.canvas;
1752
- this.Dr = { ...this.Br }, this.Wr = { x: t.clientX, y: t.clientY };
1753
- const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.Er.offsetX, l = o - this.Er.offsetY, f = Math.floor(c / this.Er.cellWidth), u = Math.floor(l / this.Er.cellHeight);
1754
- f >= 0 && f < this.Er.cols && u >= 0 && u < this.Er.rows ? (this.Br.x = f, this.Br.y = u) : (this.Br.x = -1, this.Br.y = -1);
2059
+ wn(t) {
2060
+ const e = this.tr.canvas;
2061
+ this.an = { ...this.nn }, this.hn = { x: t.clientX, y: t.clientY };
2062
+ const i = e.getBoundingClientRect(), s = t.clientX - i.left, r = t.clientY - i.top, n = e.width / i.width, o = r * (e.height / i.height), c = s * n - this.rn.offsetX, l = o - this.rn.offsetY, f = Math.floor(c / this.rn.cellWidth), u = Math.floor(l / this.rn.cellHeight);
2063
+ f >= 0 && f < this.rn.cols && u >= 0 && u < this.rn.rows ? (this.nn.x = f, this.nn.y = u) : (this.nn.x = -1, this.nn.y = -1);
1755
2064
  }
1756
2065
  }
1757
- const Dt = (a) => class extends a {
2066
+ const jt = (h) => class extends h {
1758
2067
  rotate(t = 0, e = 0, i = 0) {
1759
- this.Pt.state.ht(t), this.Pt.state.ct(e), this.Pt.state.lt(i);
2068
+ this.xt.state.et(t), this.xt.state.st(e), this.xt.state.it(i);
1760
2069
  }
1761
2070
  rotateX(t) {
1762
- this.Pt.state.ht(t);
2071
+ this.xt.state.et(t);
1763
2072
  }
1764
2073
  rotateY(t) {
1765
- this.Pt.state.ct(t);
2074
+ this.xt.state.st(t);
1766
2075
  }
1767
2076
  rotateZ(t) {
1768
- this.Pt.state.lt(t);
2077
+ this.xt.state.it(t);
1769
2078
  }
1770
2079
  push() {
1771
- this.Pt.state.N();
2080
+ this.xt.state.W();
1772
2081
  }
1773
2082
  pop() {
1774
- this.Pt.state.it();
2083
+ this.xt.state.Z();
1775
2084
  }
1776
2085
  rect(t, e, i = 1, s = 1) {
1777
- this.Pt.Gs(t, e, i, s);
2086
+ this.xt.Hs(t, e, i, s);
1778
2087
  }
1779
2088
  point(t, e) {
1780
- this.Pt.Gs(t, e, 1, 1);
2089
+ this.xt.Hs(t, e, 1, 1);
1781
2090
  }
1782
2091
  line(t, e, i, s) {
1783
- this.Pt.As(t, e, i, s);
2092
+ this.xt.Vs(t, e, i, s);
1784
2093
  }
1785
2094
  lineWeight(t) {
1786
- this.Pt.state.ot(t);
2095
+ this.xt.state.tt(t);
1787
2096
  }
1788
2097
  background(t, e = t, i = t, s = 255) {
1789
- this.Pt.Is(t, e, i, s);
2098
+ this.xt.qs(t, e, i, s);
1790
2099
  }
1791
2100
  char(t) {
1792
- this.Pt.state.ut(this.Ri.xi(t));
2101
+ this.xt.state.rt(this.Ei.zi(t));
1793
2102
  }
1794
2103
  charColor(t, e, i) {
1795
- this.Pt.state.ft(t, e, i);
2104
+ this.xt.state.nt(t, e, i);
1796
2105
  }
1797
2106
  cellColor(t, e, i) {
1798
- this.Pt.state.dt(t, e, i);
2107
+ this.xt.state.ot(t, e, i);
1799
2108
  }
1800
2109
  flipX(t) {
1801
- this.Pt.state._t(t);
2110
+ this.xt.state.ht(t);
1802
2111
  }
1803
2112
  flipY(t) {
1804
- this.Pt.state.gt(t);
2113
+ this.xt.state.ct(t);
1805
2114
  }
1806
2115
  charRotation(t) {
1807
- this.Pt.state.yt(t);
2116
+ this.xt.state.ut(t);
1808
2117
  }
1809
2118
  invert(t) {
1810
- this.Pt.state.vt(t);
2119
+ this.xt.state.lt(t);
1811
2120
  }
1812
2121
  clear() {
1813
- this.Pt.Is(0, 0, 0, 0);
2122
+ this.xt.qs(0, 0, 0, 0);
1814
2123
  }
1815
2124
  ellipse(t, e, i, s) {
1816
- this.Pt.Ls(t, e, i / 2, s / 2);
2125
+ this.xt.Ks(t, e, i / 2, s / 2);
1817
2126
  }
1818
2127
  triangle(t, e, i, s, r, n) {
1819
- this.Pt.Es(t, e, i, s, r, n);
2128
+ this.xt.Ns(t, e, i, s, r, n);
1820
2129
  }
1821
2130
  bezierCurve(t, e, i, s, r, n, o, c) {
1822
- this.Pt.Bs(t, e, i, s, r, n, o, c);
2131
+ this.xt.Xs(t, e, i, s, r, n, o, c);
1823
2132
  }
1824
2133
  arc(t, e, i, s, r, n) {
1825
- this.Pt.Ws(t, e, i, s, r, n);
2134
+ this.xt.Ys(t, e, i, s, r, n);
1826
2135
  }
1827
2136
  shader(t) {
1828
- this.Pt.zs(t);
2137
+ this.xt.Bs(t);
1829
2138
  }
1830
2139
  setUniform(t, e) {
1831
- this.Pt.Zt(t, e);
2140
+ this.xt.Xt(t, e);
1832
2141
  }
1833
2142
  setUniforms(t) {
1834
- this.Pt.Ps(t);
2143
+ this.xt.Ds(t);
1835
2144
  }
1836
2145
  createFilterShader(t) {
1837
- return this.Pt.ne(t);
2146
+ return this.xt.oe(t);
1838
2147
  }
1839
2148
  createFramebuffer(t) {
1840
- return this.Pt.Ds(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
2149
+ return this.xt.js(t.width, t.height, 5, { filter: "nearest", wrap: "clamp", format: "rgba", type: "unsigned_byte" });
1841
2150
  }
1842
2151
  image(t, e, i, s, r) {
1843
- this.Pt.ks(t, e, i, s ?? t.width, r ?? t.height);
2152
+ if (t.textures) {
2153
+ const n = t;
2154
+ this.xt.Is(n, e, i, s ?? n.width, r ?? n.height);
2155
+ } else {
2156
+ const n = t;
2157
+ this.xt.Ws(n, e, i, s ?? n.width, r ?? n.height);
2158
+ }
2159
+ }
2160
+ async loadImage(t) {
2161
+ if (typeof t != "string") return z.fromSource(this.xt, t, (s) => this.Ei.Ti(s));
2162
+ const e = t, i = await new Promise((s, r) => {
2163
+ const n = new Image();
2164
+ n.crossOrigin = "anonymous", n.onload = () => s(n), n.onerror = (o) => r(o), n.src = e;
2165
+ });
2166
+ return z.fromSource(this.xt, i, (s) => this.Ei.Ti(s));
1844
2167
  }
1845
2168
  };
1846
- class O {
1847
- ln(t) {
1848
- const e = t.Et(0), i = t.Et(1), s = t.Et(2), r = t.Et(3);
1849
- return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.Et(4), rotationPixels: r };
2169
+ class J {
2170
+ Tn(t) {
2171
+ const e = t.zt(0), i = t.zt(1), s = t.zt(2), r = t.zt(3);
2172
+ return { characterPixels: e, primaryColorPixels: i, secondaryColorPixels: s, transformPixels: t.zt(4), rotationPixels: r };
1850
2173
  }
1851
- un(t, e) {
2174
+ En(t, e) {
1852
2175
  return t[e] + (t[e + 1] << 8);
1853
2176
  }
1854
- fn(t, e) {
2177
+ Ln(t, e) {
1855
2178
  return { r: t[e], g: t[e + 1], b: t[e + 2], a: t[e + 3] };
1856
2179
  }
1857
2180
  }
1858
- class W {
1859
- dn(t, e) {
2181
+ class Z {
2182
+ kn(t, e) {
1860
2183
  return new Blob([t], { type: e });
1861
2184
  }
1862
- _n(t, e, i) {
2185
+ Pn(t, e, i) {
1863
2186
  try {
1864
- const s = this.dn(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
2187
+ const s = this.kn(t, i), r = URL.createObjectURL(s), n = document.createElement("a");
1865
2188
  n.href = r, n.download = e, n.style.display = "none", n.rel = "noopener", document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(r);
1866
2189
  } catch (s) {
1867
- throw console.error("Failed to download file:", s), Error("File download failed: " + (s instanceof Error ? s.message : "Unknown error"));
2190
+ console.error("Failed to download file:", s);
1868
2191
  }
1869
2192
  }
1870
- pn() {
2193
+ Gn() {
1871
2194
  return (/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-");
1872
2195
  }
1873
- gn() {
2196
+ Bn() {
1874
2197
  const t = /* @__PURE__ */ new Date();
1875
2198
  return { date: t.toISOString().split("T")[0], time: t.toTimeString().split(" ")[0].replace(/:/g, "-") };
1876
2199
  }
1877
- mn(t) {
2200
+ Dn(t) {
1878
2201
  return t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255);
1879
2202
  }
1880
- vn() {
1881
- return "textmode-export-" + this.pn();
2203
+ In() {
2204
+ return "textmode-export-" + this.Gn();
1882
2205
  }
1883
2206
  }
1884
- class It extends O {
1885
- yn(t, e, i) {
2207
+ class Kt extends J {
2208
+ Wn(t, e, i) {
1886
2209
  const s = t[i] === 255, r = t[i + 1] === 255, n = t[i + 2] === 255, o = e[i], c = e[i + 1];
1887
2210
  return { isInverted: s, flipHorizontal: r, flipVertical: n, rotation: Math.round(360 * (o + c / 255) / 255 * 100) / 100 };
1888
2211
  }
1889
- Cn(t, e, i) {
2212
+ On(t, e, i) {
1890
2213
  return { x: t, y: e, cellX: t * i.cellWidth, cellY: e * i.cellHeight };
1891
2214
  }
1892
- $n(t, e) {
2215
+ Hn(t, e) {
1893
2216
  const i = [];
1894
2217
  let s = 0;
1895
2218
  for (let r = 0; r < e.rows; r++) for (let n = 0; n < e.cols; n++) {
1896
- const o = 4 * s, c = this.un(t.characterPixels, o);
1897
- let l = this.fn(t.primaryColorPixels, o), f = this.fn(t.secondaryColorPixels, o);
1898
- const u = this.yn(t.transformPixels, t.rotationPixels, o);
2219
+ const o = 4 * s, c = this.En(t.characterPixels, o);
2220
+ let l = this.Ln(t.primaryColorPixels, o), f = this.Ln(t.secondaryColorPixels, o);
2221
+ const u = this.Wn(t.transformPixels, t.rotationPixels, o);
1899
2222
  if (u.isInverted) {
1900
- const p = l;
1901
- l = f, f = p;
2223
+ const v = l;
2224
+ l = f, f = v;
1902
2225
  }
1903
- const d = this.Cn(n, r, e);
1904
- i.push({ charIndex: c, primaryColor: l, secondaryColor: f, transform: u, position: d }), s++;
2226
+ const g = this.On(n, r, e);
2227
+ i.push({ charIndex: c, primaryColor: l, secondaryColor: f, transform: u, position: g }), s++;
1905
2228
  }
1906
2229
  return i;
1907
2230
  }
1908
2231
  }
1909
- class Nt {
1910
- wn(t, e) {
2232
+ class qt {
2233
+ Vn(t, e) {
1911
2234
  const i = t.cmap;
1912
2235
  for (const s of i.tables) if (s.format === 4) {
1913
2236
  const r = s;
@@ -1930,72 +2253,72 @@ class Nt {
1930
2253
  }
1931
2254
  return 0;
1932
2255
  }
1933
- xn(t, e, i, s, r) {
2256
+ Kn(t, e, i, s, r) {
1934
2257
  const n = r / t.head.unitsPerEm;
1935
- return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.bn(e, i, s, n) };
2258
+ return { getBoundingBox: () => ({ x1: i + e.xMin * n, y1: s + -e.yMax * n, x2: i + e.xMax * n, y2: s + -e.yMin * n }), toSVG: () => this.Nn(e, i, s, n) };
1936
2259
  }
1937
- bn(t, e, i, s) {
2260
+ Nn(t, e, i, s) {
1938
2261
  if (!t || !t.xs) return "";
1939
2262
  const { xs: r, ys: n, endPts: o, flags: c } = t;
1940
2263
  if (!(r && n && o && c)) return "";
1941
2264
  let l = "", f = 0;
1942
2265
  for (let u = 0; u < o.length; u++) {
1943
- const d = o[u];
1944
- if (!(d < f)) {
1945
- if (d >= f) {
1946
- const p = e + r[f] * s, g = i - n[f] * s;
1947
- l += `M${p.toFixed(2)},${g.toFixed(2)}`;
1948
- let m = f + 1;
1949
- for (; m <= d; )
1950
- if (1 & c[m]) {
1951
- const x = e + r[m] * s, R = i - n[m] * s;
1952
- l += `L${x.toFixed(2)},${R.toFixed(2)}`, m++;
2266
+ const g = o[u];
2267
+ if (!(g < f)) {
2268
+ if (g >= f) {
2269
+ const v = e + r[f] * s, m = i - n[f] * s;
2270
+ l += `M${v.toFixed(2)},${m.toFixed(2)}`;
2271
+ let d = f + 1;
2272
+ for (; d <= g; )
2273
+ if (1 & c[d]) {
2274
+ const x = e + r[d] * s, p = i - n[d] * s;
2275
+ l += `L${x.toFixed(2)},${p.toFixed(2)}`, d++;
1953
2276
  } else {
1954
- const x = e + r[m] * s, R = i - n[m] * s;
1955
- let w = m + 1 > d ? f : m + 1;
1956
- if (1 & c[w]) {
1957
- const C = e + r[w] * s, S = i - n[w] * s;
1958
- l += `Q${x.toFixed(2)},${R.toFixed(2)} ${C.toFixed(2)},${S.toFixed(2)}`, m = w + 1;
2277
+ const x = e + r[d] * s, p = i - n[d] * s;
2278
+ let E = d + 1 > g ? f : d + 1;
2279
+ if (1 & c[E]) {
2280
+ const y = e + r[E] * s, C = i - n[E] * s;
2281
+ l += `Q${x.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = E + 1;
1959
2282
  } else {
1960
- const C = (x + (e + r[w] * s)) / 2, S = (R + (i - n[w] * s)) / 2;
1961
- l += `Q${x.toFixed(2)},${R.toFixed(2)} ${C.toFixed(2)},${S.toFixed(2)}`, m = w;
2283
+ const y = (x + (e + r[E] * s)) / 2, C = (p + (i - n[E] * s)) / 2;
2284
+ l += `Q${x.toFixed(2)},${p.toFixed(2)} ${y.toFixed(2)},${C.toFixed(2)}`, d = E;
1962
2285
  }
1963
2286
  }
1964
2287
  l += "Z";
1965
2288
  }
1966
- f = d + 1;
2289
+ f = g + 1;
1967
2290
  }
1968
2291
  }
1969
2292
  return l;
1970
2293
  }
1971
- Rn(t, e, i, s, r) {
1972
- const n = t.codePointAt(0) || 0, o = this.wn(e, n);
2294
+ Xn(t, e, i, s, r) {
2295
+ const n = t.codePointAt(0) || 0, o = this.Vn(e, n);
1973
2296
  let c = null;
1974
- return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = A.T.glyf.Os(e, o), e.glyf[o] = c), this.xn(e, c, i, s, r);
2297
+ return e.glyf && e.glyf[o] !== null ? c = e.glyf[o] : (c = L.T.glyf.Js(e, o), e.glyf[o] = c), this.Kn(e, c, i, s, r);
1975
2298
  }
1976
- Mn(t, e, i, s, r, n, o, c) {
2299
+ jn(t, e, i, s, r, n, o, c) {
1977
2300
  const l = i + (r - c * (o / e.head.unitsPerEm)) / 2, f = s + (n + 0.7 * o) / 2;
1978
- return this.Rn(t, e, l, f, o).toSVG() || null;
2301
+ return this.Xn(t, e, l, f, o).toSVG() || null;
1979
2302
  }
1980
2303
  }
1981
- class zt {
2304
+ class Jt {
1982
2305
  constructor() {
1983
- h(this, "Sn");
1984
- this.Sn = new Nt();
2306
+ a(this, "Yn");
2307
+ this.Yn = new qt();
1985
2308
  }
1986
- Fn(t) {
2309
+ qn(t) {
1987
2310
  const { width: e, height: i } = t;
1988
2311
  return `<?xml version="1.0" encoding="UTF-8"?><svg width="${e}" height="${i}" viewBox="0 0 ${e} ${i}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
1989
2312
  }
1990
- zn() {
2313
+ Zn() {
1991
2314
  return "</g></svg>";
1992
2315
  }
1993
- Pn(t, e) {
2316
+ Jn(t, e) {
1994
2317
  if (!e.includeBackgroundRectangles) return "";
1995
2318
  const [i, s, r, n] = e.backgroundColor;
1996
2319
  return `<rect width="${t.width}" height="${t.height}" fill="rgba(${i},${s},${r},${n / 255})"/>`;
1997
2320
  }
1998
- kn(t, e) {
2321
+ Qn(t, e) {
1999
2322
  const { transform: i, position: s } = t;
2000
2323
  if (!i.flipHorizontal && !i.flipVertical && !i.rotation) return "";
2001
2324
  const r = s.cellX + e.cellWidth / 2, n = s.cellY + e.cellHeight / 2, o = [];
@@ -2005,85 +2328,85 @@ class zt {
2005
2328
  }
2006
2329
  return i.rotation && o.push(`rotate(${i.rotation} ${r} ${n})`), ` transform="${o.join(" ")}"`;
2007
2330
  }
2008
- Tn(t, e, i) {
2331
+ eo(t, e, i) {
2009
2332
  if (!i.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
2010
2333
  const { position: s } = t, { r, g: n, b: o, a: c } = t.secondaryColor, l = `rgba(${r},${n},${o},${c / 255})`;
2011
2334
  return i.drawMode === "stroke" ? `<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${l}" fill="none" stroke-width="${i.strokeWidth}"/>` : `<rect x="${s.cellX}" y="${s.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${l}"/>`;
2012
2335
  }
2013
- Rn(t, e, i, s) {
2336
+ Xn(t, e, i, s) {
2014
2337
  const r = i.characters[t.charIndex];
2015
2338
  if (!r) return "";
2016
- const n = this.Sn.Mn(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
2339
+ const n = this.Yn.jn(r.character, i.font, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, i.fontSize, r.advanceWidth);
2017
2340
  if (!n) return "";
2018
2341
  const { r: o, g: c, b: l, a: f } = t.primaryColor, u = `rgba(${o},${c},${l},${f / 255})`;
2019
2342
  return s.drawMode === "stroke" ? `<path d="${n}" stroke="${u}" stroke-width="${s.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${u}"/>`;
2020
2343
  }
2021
- Gn(t, e, i, s) {
2022
- const r = [], n = this.Tn(t, e, s);
2344
+ so(t, e, i, s) {
2345
+ const r = [], n = this.eo(t, e, s);
2023
2346
  n && r.push(n);
2024
- const o = this.Rn(t, e, i, s);
2347
+ const o = this.Xn(t, e, i, s);
2025
2348
  if (o) {
2026
- const c = this.kn(t, e);
2349
+ const c = this.Qn(t, e);
2027
2350
  r.push(c ? `<g${c}>${o}</g>` : o);
2028
2351
  }
2029
2352
  return r.join("");
2030
2353
  }
2031
- An(t, e, i, s) {
2032
- const r = [this.Fn(e), this.Pn(e, s), '<g id="ascii-cells">'];
2033
- for (const n of t) r.push(this.Gn(n, e, i, s));
2034
- return r.push(this.zn()), r.join("");
2354
+ io(t, e, i, s) {
2355
+ const r = [this.qn(e), this.Jn(e, s), '<g id="ascii-cells">'];
2356
+ for (const n of t) r.push(this.so(n, e, i, s));
2357
+ return r.push(this.Zn()), r.join("");
2035
2358
  }
2036
- Ln(t) {
2359
+ ro(t) {
2037
2360
  return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
2038
2361
  }
2039
2362
  }
2040
- class Gt extends W {
2041
- En(t) {
2042
- return this.dn(t, "image/svg+xml;charset=utf-8");
2363
+ class Zt extends Z {
2364
+ no(t) {
2365
+ return this.kn(t, "image/svg+xml;charset=utf-8");
2043
2366
  }
2044
- Bn(t, e) {
2045
- this._n(t, this.mn(e) + ".svg", "image/svg+xml;charset=utf-8");
2367
+ oo(t, e) {
2368
+ this.Pn(t, this.Dn(e) + ".svg", "image/svg+xml;charset=utf-8");
2046
2369
  }
2047
- Dn(t, e) {
2048
- this.Bn(t, e || this.vn());
2370
+ ao(t, e) {
2371
+ this.oo(t, e || this.In());
2049
2372
  }
2050
2373
  }
2051
- class V {
2374
+ class st {
2052
2375
  constructor() {
2053
- h(this, "Wn");
2054
- h(this, "In");
2055
- h(this, "Un");
2056
- this.Wn = new It(), this.In = new zt(), this.Un = new Gt();
2376
+ a(this, "ho");
2377
+ a(this, "co");
2378
+ a(this, "lo");
2379
+ this.ho = new Kt(), this.co = new Jt(), this.lo = new Zt();
2057
2380
  }
2058
- On(t) {
2059
- return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.Un.vn() };
2381
+ uo(t) {
2382
+ return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, backgroundColor: t.backgroundColor ?? [0, 0, 0, 0], filename: t.filename || this.lo.In() };
2060
2383
  }
2061
- Vn(t, e = {}) {
2062
- const i = this.Wn.$n(this.Wn.ln(t.pipeline), t.grid), s = this.In.An(i, t.grid, t.font, this.On(e));
2063
- return this.In.Ln(s);
2384
+ fo(t, e = {}) {
2385
+ const i = this.ho.Hn(this.ho.Tn(t.pipeline), t.grid), s = this.co.io(i, t.grid, t.font, this.uo(e));
2386
+ return this.co.ro(s);
2064
2387
  }
2065
- Dn(t, e = {}) {
2066
- this.Un.Dn(this.Vn(t, e), e.filename);
2388
+ ao(t, e = {}) {
2389
+ this.lo.ao(this.fo(t, e), e.filename);
2067
2390
  }
2068
2391
  }
2069
- class Ot extends O {
2070
- Hn(t, e, i, s = " ") {
2392
+ class Qt extends J {
2393
+ do(t, e, i, s = " ") {
2071
2394
  var o;
2072
2395
  const r = [];
2073
2396
  let n = 0;
2074
2397
  for (let c = 0; c < e.rows; c++) {
2075
2398
  const l = [];
2076
2399
  for (let f = 0; f < e.cols; f++) {
2077
- const u = 4 * n, d = this.un(t.characterPixels, u), p = ((o = i.characters[d]) == null ? void 0 : o.character) || s;
2078
- l.push(p), n++;
2400
+ const u = 4 * n, g = this.En(t.characterPixels, u), v = ((o = i.characters[g]) == null ? void 0 : o.character) || s;
2401
+ l.push(v), n++;
2079
2402
  }
2080
2403
  r.push(l);
2081
2404
  }
2082
2405
  return r;
2083
2406
  }
2084
2407
  }
2085
- class Wt {
2086
- Kn(t, e) {
2408
+ class te {
2409
+ _o(t, e) {
2087
2410
  const i = [];
2088
2411
  for (const r of t) {
2089
2412
  let n = r.join("");
@@ -2095,56 +2418,56 @@ class Wt {
2095
2418
  return i.join(s);
2096
2419
  }
2097
2420
  }
2098
- class $t extends W {
2099
- Nn(t, e) {
2100
- const i = this.Xn(e);
2101
- this._n(t, i, "text/plain;charset=utf-8");
2421
+ class ee extends Z {
2422
+ po(t, e) {
2423
+ const i = this.mo(e);
2424
+ this.Pn(t, i, "text/plain;charset=utf-8");
2102
2425
  }
2103
- Xn(t) {
2104
- let e = this.mn(t);
2105
- return e === ".txt" || e.length <= 4 ? this.vn() : e;
2426
+ mo(t) {
2427
+ let e = this.Dn(t);
2428
+ return e === ".txt" || e.length <= 4 ? this.In() : e;
2106
2429
  }
2107
2430
  }
2108
- class H {
2431
+ class rt {
2109
2432
  constructor() {
2110
- h(this, "Wn");
2111
- h(this, "In");
2112
- h(this, "Un");
2113
- this.Wn = new Ot(), this.In = new Wt(), this.Un = new $t();
2433
+ a(this, "ho");
2434
+ a(this, "co");
2435
+ a(this, "lo");
2436
+ this.ho = new Qt(), this.co = new te(), this.lo = new ee();
2114
2437
  }
2115
- On(t) {
2116
- return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.Un.vn() };
2438
+ uo(t) {
2439
+ return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, lineEnding: t.lineEnding ?? "lf", emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename || this.lo.In() };
2117
2440
  }
2118
- jn(t, e = {}) {
2119
- const i = this.On(e), s = this.Wn.Hn(this.Wn.ln(t.pipeline), t.grid, t.font, i.emptyCharacter);
2120
- return this.In.Kn(s, i);
2441
+ vo(t, e = {}) {
2442
+ const i = this.uo(e), s = this.ho.do(this.ho.Tn(t.pipeline), t.grid, t.font, i.emptyCharacter);
2443
+ return this.co._o(s, i);
2121
2444
  }
2122
- Nn(t, e = {}) {
2123
- this.Un.Nn(this.jn(t, e), e.filename);
2445
+ po(t, e = {}) {
2446
+ this.lo.po(this.vo(t, e), e.filename);
2124
2447
  }
2125
2448
  }
2126
- class kt extends O {
2127
- Yn(t, e = 1, i = "transparent") {
2449
+ class ie extends J {
2450
+ yo(t, e = 1, i = "transparent") {
2128
2451
  const s = t.canvas;
2129
2452
  if (e === 1 && i === "transparent") return s;
2130
2453
  const r = document.createElement("canvas"), n = r.getContext("2d"), o = Math.round(s.width * e), c = Math.round(s.height * e);
2131
2454
  return r.width = o, r.height = c, i !== "transparent" && (n.fillStyle = i, n.fillRect(0, 0, o, c)), n.imageSmoothingEnabled = !1, n.drawImage(s, 0, 0, s.width, s.height, 0, 0, o, c), r;
2132
2455
  }
2133
2456
  }
2134
- class Xt {
2135
- qn(t, e) {
2136
- const i = this.Zn(e.format);
2457
+ class se {
2458
+ Co(t, e) {
2459
+ const i = this.wo(e.format);
2137
2460
  return e.format === "png" ? t.toDataURL(i) : t.toDataURL(i, e.quality);
2138
2461
  }
2139
- async Jn(t, e) {
2462
+ async $o(t, e) {
2140
2463
  return new Promise((i, s) => {
2141
- const r = this.Zn(e.format), n = (o) => {
2464
+ const r = this.wo(e.format), n = (o) => {
2142
2465
  o ? i(o) : s(Error(`Failed to generate ${e.format.toUpperCase()} blob`));
2143
2466
  };
2144
2467
  e.format === "png" ? t.toBlob(n, r) : t.toBlob(n, r, e.quality);
2145
2468
  });
2146
2469
  }
2147
- Zn(t) {
2470
+ wo(t) {
2148
2471
  switch (t) {
2149
2472
  case "png":
2150
2473
  return "image/png";
@@ -2157,12 +2480,12 @@ class Xt {
2157
2480
  }
2158
2481
  }
2159
2482
  }
2160
- const Yt = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, j = { png: ".png", jpg: ".jpg", webp: ".webp" };
2161
- class Vt extends W {
2162
- Qn(t, e, i) {
2163
- this.eo(t, this.mn(e) + j[i]);
2483
+ const re = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, nt = { png: ".png", jpg: ".jpg", webp: ".webp" };
2484
+ class ne extends Z {
2485
+ bo(t, e, i) {
2486
+ this.xo(t, this.Dn(e) + nt[i]);
2164
2487
  }
2165
- eo(t, e) {
2488
+ xo(t, e) {
2166
2489
  const i = URL.createObjectURL(t);
2167
2490
  try {
2168
2491
  const s = document.createElement("a");
@@ -2171,250 +2494,265 @@ class Vt extends W {
2171
2494
  URL.revokeObjectURL(i);
2172
2495
  }
2173
2496
  }
2174
- so(t) {
2175
- return t in Yt && t in j;
2497
+ Fo(t) {
2498
+ return t in re && t in nt;
2176
2499
  }
2177
2500
  }
2178
- class Ht {
2501
+ class oe {
2179
2502
  constructor() {
2180
- h(this, "Wn");
2181
- h(this, "In");
2182
- h(this, "Un");
2183
- this.Wn = new kt(), this.In = new Xt(), this.Un = new Vt();
2503
+ a(this, "ho");
2504
+ a(this, "co");
2505
+ a(this, "lo");
2506
+ this.ho = new ie(), this.co = new se(), this.lo = new ne();
2184
2507
  }
2185
- On(t) {
2186
- return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.Un.vn() };
2508
+ uo(t) {
2509
+ return { format: t.format ?? "png", quality: t.quality ?? 1, scale: t.scale ?? 1, backgroundColor: t.backgroundColor ?? "transparent", filename: t.filename || this.lo.In() };
2187
2510
  }
2188
- io(t) {
2189
- if (!this.Un.so(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
2511
+ Mo(t) {
2512
+ if (!this.lo.Fo(t.format)) throw Error(`Saving '${t.format}' files is not supported`);
2190
2513
  if (t.quality < 0 || t.quality > 1) throw Error("Image quality must be between 0.0 and 1.0");
2191
2514
  if (t.scale <= 0) throw Error("Scale factor must be greater than 0");
2192
2515
  t.format === "jpg" && t.backgroundColor === "transparent" && (t.backgroundColor = "black");
2193
2516
  }
2194
- async Jn(t, e) {
2195
- if (e.scale === 1 && e.backgroundColor === "transparent") return await this.In.Jn(t.canvas, e);
2196
- const i = this.Wn.Yn(t, e.scale, e.backgroundColor);
2197
- return await this.In.Jn(i, e);
2517
+ async $o(t, e) {
2518
+ if (e.scale === 1 && e.backgroundColor === "transparent") return await this.co.$o(t.canvas, e);
2519
+ const i = this.ho.yo(t, e.scale, e.backgroundColor);
2520
+ return await this.co.$o(i, e);
2198
2521
  }
2199
- async Qn(t, e = {}) {
2200
- const i = this.On(e);
2201
- this.io(i);
2202
- const s = await this.Jn(t, i);
2203
- this.Un.Qn(s, i.filename, i.format);
2522
+ async bo(t, e = {}) {
2523
+ const i = this.uo(e);
2524
+ this.Mo(i);
2525
+ const s = await this.$o(t, i);
2526
+ this.lo.bo(s, i.filename, i.format);
2204
2527
  }
2205
2528
  }
2206
- const jt = (a) => class extends a {
2207
- ro() {
2208
- this.Pt.Dt(this.no);
2529
+ const he = (h) => class extends h {
2530
+ Ro() {
2531
+ this.xt.Et(this.So);
2209
2532
  }
2210
2533
  toString(t = {}) {
2211
- return this.ro(), new H().jn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2534
+ return this.Ro(), new rt().vo({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2212
2535
  }
2213
2536
  saveStrings(t = {}) {
2214
- this.ro(), new H().Nn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2537
+ this.Ro(), new rt().po({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2215
2538
  }
2216
2539
  toSVG(t = {}) {
2217
- return this.ro(), new V().Vn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2540
+ return this.Ro(), new st().fo({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2218
2541
  }
2219
2542
  saveSVG(t = {}) {
2220
- this.ro(), new V().Dn({ pipeline: this.oo, grid: this.Er, font: this.Ri }, t);
2543
+ this.Ro(), new st().ao({ pipeline: this.Ao, grid: this.rn, font: this.Ei }, t);
2221
2544
  }
2222
2545
  async saveCanvas(t = {}) {
2223
- await new Ht().Qn(this.Ni, t);
2546
+ await new oe().bo(this.tr, t);
2224
2547
  }
2225
- }, Kt = (a) => class extends a {
2548
+ }, ae = (h) => class extends h {
2226
2549
  async loadFont(t) {
2227
- return this.Ri.Ui(t).then(() => {
2228
- const e = this.Ri.maxGlyphDimensions;
2229
- this.Er.Yi(e.width, e.height), this.oo.resize(this.Er.cols, this.Er.rows), this.Pt.Us(), this.ao.Zr();
2550
+ return this.Ei.Yi(t).then(() => {
2551
+ const e = this.Ei.maxGlyphDimensions;
2552
+ this.rn.rr(e.width, e.height), this.Ao.resize(this.rn.cols, this.rn.rows), this.xt.Zs(), this.zo.Cn();
2230
2553
  });
2231
2554
  }
2232
2555
  fontSize(t) {
2233
- if (!L.M(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ri.fontSize === t) return;
2234
- this.Ri.Ii(t);
2235
- const e = this.Ri.maxGlyphDimensions;
2236
- this.Er.Yi(e.width, e.height), this.oo.resize(this.Er.cols, this.Er.rows), this.Pt.Us(), this.ao.Zr();
2556
+ if (!$.v(typeof t == "number" && t > 0, "Font size must be a positive number greater than 0.", { method: "fontSize", providedValue: t }) || this.Ei.fontSize === t) return;
2557
+ this.Ei.ji(t);
2558
+ const e = this.Ei.maxGlyphDimensions;
2559
+ this.rn.rr(e.width, e.height), this.Ao.resize(this.rn.cols, this.rn.rows), this.xt.Zs(), this.zo.Cn();
2560
+ }
2561
+ glyphColor(t) {
2562
+ return this.Ei.zi(t);
2563
+ }
2564
+ glyphColors(t) {
2565
+ return this.Ei.Ti(t);
2237
2566
  }
2238
- }, Zt = (a) => class extends a {
2567
+ }, ce = (h) => class extends h {
2239
2568
  get frameCount() {
2240
- return this.ho.frameCount;
2569
+ return this.To.frameCount;
2241
2570
  }
2242
2571
  set frameCount(t) {
2243
- this.ho.frameCount = t;
2572
+ this.To.frameCount = t;
2244
2573
  }
2245
2574
  frameRate(t) {
2246
- return t === void 0 ? this.ho.currentFrameRate : this.ho.frameRate(t, () => this.co());
2575
+ return t === void 0 ? this.To.currentFrameRate : this.To.frameRate(t, () => this.Eo());
2247
2576
  }
2248
2577
  noLoop() {
2249
- this.ho.pause();
2578
+ this.To.pause();
2250
2579
  }
2251
2580
  loop() {
2252
- this.ho.resume(() => this.co());
2581
+ this.To.resume(() => this.Eo());
2253
2582
  }
2254
2583
  redraw(t = 1) {
2255
- if (L.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.co();
2584
+ if ($.v(typeof t == "number" && t > 0 && Number.isInteger(t), "Redraw count must be a positive integer.", { method: "redraw", providedValue: t })) for (let e = 0; e < t; e++) this.Eo();
2256
2585
  }
2257
2586
  isLooping() {
2258
- return this.ho.isLooping;
2587
+ return this.To.isLooping;
2259
2588
  }
2260
- }, qt = (a) => class extends a {
2589
+ }, le = (h) => class extends h {
2261
2590
  constructor(...t) {
2262
2591
  super(...t);
2263
2592
  }
2264
2593
  mouseClicked(t) {
2265
- this.ao.nn(t);
2594
+ this.zo.Rn(t);
2266
2595
  }
2267
2596
  mousePressed(t) {
2268
- this.ao.Sr(t);
2597
+ this.zo.jr(t);
2269
2598
  }
2270
2599
  mouseReleased(t) {
2271
- this.ao.Fr(t);
2600
+ this.zo.Yr(t);
2272
2601
  }
2273
2602
  mouseMoved(t) {
2274
- this.ao.an(t);
2603
+ this.zo.Sn(t);
2275
2604
  }
2276
2605
  mouseScrolled(t) {
2277
- this.ao.hn(t);
2606
+ this.zo.An(t);
2278
2607
  }
2279
2608
  get mouse() {
2280
- return this.ao.cn();
2609
+ return this.zo.zn();
2281
2610
  }
2282
- }, Jt = (a) => class extends a {
2611
+ }, ue = (h) => class extends h {
2283
2612
  constructor(...t) {
2284
2613
  super(...t);
2285
2614
  }
2286
2615
  keyPressed(t) {
2287
- this.lo.Sr(t);
2616
+ this.Lo.jr(t);
2288
2617
  }
2289
2618
  keyReleased(t) {
2290
- this.lo.Fr(t);
2619
+ this.Lo.Yr(t);
2291
2620
  }
2292
2621
  isKeyPressed(t) {
2293
- return this.lo.zr(t);
2622
+ return this.Lo.qr(t);
2294
2623
  }
2295
2624
  get lastKeyPressed() {
2296
- return this.lo.kr();
2625
+ return this.Lo.Jr();
2297
2626
  }
2298
2627
  get lastKeyReleased() {
2299
- return this.lo.Tr();
2628
+ return this.Lo.Qr();
2300
2629
  }
2301
2630
  get pressedKeys() {
2302
- return this.lo.Gr();
2631
+ return this.Lo.tn();
2303
2632
  }
2304
2633
  get modifierState() {
2305
- return this.lo.Ar();
2634
+ return this.Lo.en();
2306
2635
  }
2307
2636
  };
2308
- class Qt {
2637
+ class fe {
2309
2638
  constructor() {
2310
- h(this, "Pt");
2311
- h(this, "Ri");
2312
- h(this, "Ni");
2313
- h(this, "Er");
2314
- h(this, "ho");
2315
- h(this, "ao");
2316
- h(this, "lo");
2317
- h(this, "no");
2318
- h(this, "oo");
2319
- h(this, "uo");
2320
- }
2321
- co() {
2639
+ a(this, "xt");
2640
+ a(this, "Ei");
2641
+ a(this, "tr");
2642
+ a(this, "rn");
2643
+ a(this, "To");
2644
+ a(this, "zo");
2645
+ a(this, "Lo");
2646
+ a(this, "So");
2647
+ a(this, "Ao");
2648
+ a(this, "ko");
2649
+ a(this, "Po");
2650
+ a(this, "Go");
2651
+ }
2652
+ Eo() {
2322
2653
  }
2323
2654
  }
2324
- class te extends function(e, ...i) {
2655
+ class de extends function(e, ...i) {
2325
2656
  return i.reduce((s, r) => r(s), e);
2326
- }(Qt, Dt, jt, Kt, Zt, qt, Jt) {
2657
+ }(fe, jt, he, ae, ce, le, ue) {
2327
2658
  constructor(e = {}) {
2328
2659
  super();
2329
- h(this, "fo", !1);
2330
- h(this, "do", () => {
2660
+ a(this, "Bo", !1);
2661
+ a(this, "Do", () => {
2331
2662
  });
2332
- h(this, "_o", () => {
2663
+ a(this, "Io", () => {
2333
2664
  });
2334
- h(this, "po", () => {
2665
+ a(this, "Wo", () => {
2335
2666
  });
2336
- h(this, "mo");
2337
- this.Ni = new Mt(e), this.Pt = new Et(this.Ni.tr()), this.Ri = new Ft(this.Pt, e.fontSize ?? 16), this.ho = new Lt(e.frameRate ?? 60), this.ao = new Bt(this.Ni), this.lo = new Ut(), this.no = this.Pt.Bt(), this.uo = this.Pt.re(), this.vo(e);
2338
- }
2339
- async vo(e) {
2340
- await this.Ri.Bi(e.fontSource);
2341
- const i = this.Ri.maxGlyphDimensions;
2342
- this.Er = new St(this.Ni.canvas, i.width, i.height), this.ao.Bi(this.Er), this.oo = this.Pt.Ds(this.Er.cols, this.Er.rows, 5), this.yo(), this.do(), this.ho.start(() => this.co());
2343
- }
2344
- yo() {
2345
- this.mo = () => {
2346
- this.po();
2347
- }, window.addEventListener("resize", this.mo), this.ao.wr(), this.lo.wr(), window.addEventListener("blur", () => {
2348
- this.lo.Lr();
2667
+ a(this, "Oo");
2668
+ a(this, "ar", !1);
2669
+ a(this, "Ho");
2670
+ this.ar = e.overlay ?? !1, this.tr = new Xt(e), this.xt = new Ft(this.tr.mr()), this.Ei = new Nt(this.xt, e.fontSize ?? 16), this.To = new Ht(e.frameRate ?? 60), this.zo = new Vt(this.tr), this.Lo = new Yt(), this.So = this.xt.Tt(), this.ko = this.xt.re(), this.Vo(e);
2671
+ }
2672
+ async Vo(e) {
2673
+ await this.Ei.Ki(e.fontSource);
2674
+ const i = this.Ei.maxGlyphDimensions;
2675
+ this.rn = new Wt(this.tr.canvas, i.width, i.height), this.zo.Ki(this.rn), this.Ao = this.xt.js(this.rn.cols, this.rn.rows, 5), this.Po = this.xt.js(this.rn.width, this.rn.height, 1), this.ar && (this.Ho = z.fromSource(this.xt, this.tr.targetCanvas, (s) => this.Ei.Ti(s))), this.Go = this.xt.ae(at, "precision mediump float;uniform sampler2D Ua;uniform vec2 Ub;uniform vec2 Uc;uniform vec2 Ud;void main(){vec2 A=gl_FragCoord.xy-Uc;vec2 B=A*(Ub/Ud);vec2 C=(floor(B)+0.5)/Ub;gl_FragColor=texture2D(Ua,C);}"), this.Ko(), this.Do(), this.To.start(() => this.Eo());
2676
+ }
2677
+ Ko() {
2678
+ this.Oo = () => {
2679
+ this.ar && this.resizeCanvas(this.tr.width, this.tr.height), this.Wo();
2680
+ }, window.addEventListener("resize", this.Oo), this.zo.Vr(), this.Lo.Vr(), window.addEventListener("blur", () => {
2681
+ this.Lo.sn();
2349
2682
  });
2350
2683
  }
2351
- co() {
2352
- if (this.ho.measureFrameRate(), this.ho.incrementFrame(), this.fo) return;
2353
- this.oo.begin(), this.Pt.Ss(this.no), this._o(), this.Pt.Dt(this.no), this.oo.end();
2354
- const e = this.Pt.state.canvasBackgroundColor;
2355
- this.Pt.Ue(e[0], e[1], e[2], e[3]), this.Pt.Ss(this.uo), this.uo.qt({ a: this.Ri.fontFramebuffer, b: [this.Ri.textureColumns, this.Ri.textureRows], c: this.oo.textures[0], d: this.oo.textures[1], e: this.oo.textures[2], f: this.oo.textures[4], g: this.oo.textures[3], h: [this.Er.cols, this.Er.rows], i: [this.Er.width, this.Er.height], j: [this.Er.offsetX, this.Er.offsetY], k: this.Er.width / this.Er.height }), this.Pt.Ts(this.Er.offsetX, this.Er.offsetY, this.Er.width, this.Er.height);
2684
+ Eo() {
2685
+ if (this.To.measureFrameRate(), this.To.incrementFrame(), this.Bo) return;
2686
+ if (this.ar) {
2687
+ const i = this.xt.context;
2688
+ i.bindTexture(i.TEXTURE_2D, this.Ho.texture), i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL, 1), i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, i.RGBA, i.UNSIGNED_BYTE, this.tr.targetCanvas), i.bindTexture(i.TEXTURE_2D, null), this.Ao.begin(), this.xt.Ws(this.Ho, 0, 0, this.rn.cols, this.rn.rows), this.xt.Gs(this.So), this.Io(), this.xt.Et(this.So), this.Ao.end();
2689
+ } else this.Ao.begin(), this.xt.Gs(this.So), this.Io(), this.xt.Et(this.So), this.Ao.end();
2690
+ this.Po.begin(), this.xt.Gs(this.ko), this.ko.Nt({ U0: this.Ei.fontFramebuffer, U1: [this.Ei.textureColumns, this.Ei.textureRows], U2: this.Ao.textures[0], U3: this.Ao.textures[1], U4: this.Ao.textures[2], U5: this.Ao.textures[4], U6: this.Ao.textures[3], U7: [this.rn.cols, this.rn.rows], U8: [this.Po.width, this.Po.height], U9: this.Po.width / this.Po.height }), this.xt.Os(0, 0, this.tr.width, this.tr.height), this.Po.end();
2691
+ const e = this.xt.state.canvasBackgroundColor;
2692
+ this.xt.He(e[0], e[1], e[2], e[3]), this.xt.Gs(this.Go), this.Go.Nt({ Ua: this.Po.textures[0], Ub: [this.Po.width, this.Po.height], Uc: [this.rn.offsetX, this.rn.offsetY], Ud: [this.rn.width, this.rn.height] }), this.xt.Os(this.rn.offsetX, this.rn.offsetY, this.rn.width, this.rn.height);
2356
2693
  }
2357
2694
  setup(e) {
2358
- this.do = e;
2695
+ this.Do = e;
2359
2696
  }
2360
2697
  draw(e) {
2361
- this._o = e;
2698
+ this.Io = e;
2362
2699
  }
2363
2700
  windowResized(e) {
2364
- this.po = e;
2701
+ this.Wo = e;
2365
2702
  }
2366
2703
  resizeCanvas(e, i) {
2367
- this.Ni.Qi(e, i), this.Er.rt(), this.oo.resize(this.Er.cols, this.Er.rows), this.Pt.Us(), this.ao.Zr(), this.co();
2704
+ this.tr.pr(e, i), this.rn.ir(), this.Ao.resize(this.rn.cols, this.rn.rows), this.Po.resize(this.rn.width, this.rn.height), this.xt.Zs(), this.zo.Cn(), this.Eo();
2368
2705
  }
2369
2706
  destroy() {
2370
- this.fo || (this.ho.stop(), window.removeEventListener("resize", this.mo), this.ao.Mr(), this.lo.Mr(), this.Ri.Ut(), this.Pt.Ut(), this.fo = !0);
2707
+ this.Bo || (this.To.stop(), window.removeEventListener("resize", this.Oo), this.zo.Xr(), this.Lo.Xr(), this.Ei.Pt(), this.xt.Pt(), this.Po.Pt(), this.Go.Pt(), this.Ho && this.Ho.Pt(), this.Bo = !0);
2371
2708
  }
2372
2709
  get grid() {
2373
- return this.Er;
2710
+ return this.rn;
2374
2711
  }
2375
2712
  get font() {
2376
- return this.Ri;
2713
+ return this.Ei;
2377
2714
  }
2378
2715
  get width() {
2379
- return this.Ni.width;
2716
+ return this.tr.width;
2380
2717
  }
2381
2718
  get height() {
2382
- return this.Ni.height;
2719
+ return this.tr.height;
2383
2720
  }
2384
2721
  get canvas() {
2385
- return this.Ni.canvas;
2722
+ return this.tr.canvas;
2386
2723
  }
2387
2724
  get isDisposed() {
2388
- return this.fo;
2725
+ return this.Bo;
2389
2726
  }
2390
- get drawFramebuffer() {
2391
- return this.oo;
2727
+ get overlay() {
2728
+ return this.Ho;
2392
2729
  }
2393
2730
  }
2394
- class $ {
2731
+ class Q {
2395
2732
  constructor() {
2396
2733
  }
2397
2734
  static create(t = {}) {
2398
- return new te(t);
2735
+ return new de(t);
2399
2736
  }
2400
2737
  static setErrorLevel(t) {
2401
- L.S(t);
2738
+ $.C(t);
2402
2739
  }
2403
2740
  static get version() {
2404
- return "0.2.1-beta.3";
2741
+ return "0.2.1-beta.5";
2405
2742
  }
2406
2743
  }
2407
- const ie = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), se = $.create, re = $.setErrorLevel, ne = $.version;
2744
+ const pe = Object.freeze(Object.defineProperty({ __proto__: null }, Symbol.toStringTag, { value: "Module" })), me = Q.create, ve = Q.setErrorLevel, xe = Q.version;
2408
2745
  export {
2409
- Mt as TextmodeCanvas,
2410
- et as TextmodeErrorLevel,
2411
- Ft as TextmodeFont,
2412
- G as TextmodeFramebuffer,
2413
- St as TextmodeGrid,
2414
- te as Textmodifier,
2415
- se as create,
2416
- ie as export,
2417
- re as setErrorLevel,
2418
- $ as textmode,
2419
- ne as version
2746
+ Xt as TextmodeCanvas,
2747
+ ut as TextmodeErrorLevel,
2748
+ Nt as TextmodeFont,
2749
+ K as TextmodeFramebuffer,
2750
+ Wt as TextmodeGrid,
2751
+ z as TextmodeImage,
2752
+ de as Textmodifier,
2753
+ me as create,
2754
+ pe as export,
2755
+ ve as setErrorLevel,
2756
+ Q as textmode,
2757
+ xe as version
2420
2758
  };