textmode.export.js 1.2.0 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,297 +1,289 @@
1
- class At {
2
- $extractFramebufferData(t) {
3
- return { characterPixels: t.readPixels(0), primaryColorPixels: t.readPixels(1), secondaryColorPixels: t.readPixels(2) };
1
+ class Ae {
2
+ $extractFramebufferData(e) {
3
+ return { characterPixels: e.readPixels(0), primaryColorPixels: e.readPixels(1), secondaryColorPixels: e.readPixels(2) };
4
4
  }
5
- $getCharacterIndex(t, e) {
6
- return t[e] + (t[e + 1] << 8);
5
+ $getCharacterIndex(e, t) {
6
+ return e[t] + (e[t + 1] << 8);
7
7
  }
8
8
  }
9
9
  class Q {
10
- $downloadFile(t, e) {
10
+ $downloadFile(e, t) {
11
11
  try {
12
- const r = this._sanitizeFilename(e), a = URL.createObjectURL(t), i = document.createElement("a");
12
+ const r = this._sanitizeFilename(t), a = URL.createObjectURL(e), i = document.createElement("a");
13
13
  i.href = a, i.download = r, i.style.display = "none", i.rel = "noopener", document.body.appendChild(i), i.click(), document.body.removeChild(i), URL.revokeObjectURL(a);
14
14
  } catch (r) {
15
15
  console.error("[textmode-export] Failed to download file:", r);
16
16
  }
17
17
  }
18
- _sanitizeFilename(t) {
19
- if (!t) return this._generateDefaultFilename();
20
- const e = t.trim();
21
- return e ? e.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255) || this._generateDefaultFilename() : this._generateDefaultFilename();
18
+ _sanitizeFilename(e) {
19
+ if (!e) return this._generateDefaultFilename();
20
+ const t = e.trim();
21
+ return t ? t.replace(/[<>:"/\\|?*]/g, "_").replace(/\s+/g, "_").replace(/_{2,}/g, "_").replace(/^_+|_+$/g, "").substring(0, 255) || this._generateDefaultFilename() : this._generateDefaultFilename();
22
22
  }
23
23
  _generateDefaultFilename() {
24
24
  return `textmode-export-${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19).replace(/:/g, "-")}`;
25
25
  }
26
26
  }
27
- function ft(s, t) {
28
- return { r: s[t], g: s[t + 1], b: s[t + 2], a: s[t + 3] };
27
+ function fe(o, e) {
28
+ return { r: o[e], g: o[e + 1], b: o[e + 2], a: o[e + 3] };
29
29
  }
30
- class Wt extends At {
31
- _extractTransformData(t, e) {
32
- const r = t[e + 2], a = !!(1 & r), i = !!(2 & r), n = !!(4 & r), c = t[e + 3] / 255;
33
- return { isInverted: a, flipHorizontal: i, flipVertical: n, rotation: Math.round(360 * c * 100) / 100 };
30
+ class qe extends Ae {
31
+ _extractTransformData(e, t) {
32
+ const r = e[t + 2], a = !!(1 & r), i = !!(2 & r), s = !!(4 & r), c = e[t + 3] / 255;
33
+ return { isInverted: a, flipHorizontal: i, flipVertical: s, rotation: Math.round(360 * c * 100) / 100 };
34
34
  }
35
- _calculateCellPosition(t, e, r) {
36
- return { x: t, y: e, cellX: t * r.cellWidth, cellY: e * r.cellHeight };
35
+ _calculateCellPosition(e, t, r) {
36
+ return { x: e, y: t, cellX: e * r.cellWidth, cellY: t * r.cellHeight };
37
37
  }
38
- $extractSVGCellData(t, e) {
38
+ $extractSVGCellData(e, t) {
39
39
  const r = [];
40
40
  let a = 0;
41
- for (let i = 0; i < e.rows; i++) for (let n = 0; n < e.cols; n++) {
42
- const c = 4 * a, l = this.$getCharacterIndex(t.characterPixels, c);
43
- let p = ft(t.primaryColorPixels, c), o = ft(t.secondaryColorPixels, c);
44
- const d = this._extractTransformData(t.characterPixels, c);
41
+ for (let i = 0; i < t.rows; i++) for (let s = 0; s < t.cols; s++) {
42
+ const c = 4 * a, l = this.$getCharacterIndex(e.characterPixels, c);
43
+ let p = fe(e.primaryColorPixels, c), n = fe(e.secondaryColorPixels, c);
44
+ const d = this._extractTransformData(e.characterPixels, c);
45
45
  if (d.isInverted) {
46
46
  const m = p;
47
- p = o, o = m;
47
+ p = n, n = m;
48
48
  }
49
- const u = this._calculateCellPosition(n, i, e);
50
- r.push({ charIndex: l, primaryColor: p, secondaryColor: o, transform: d, position: u }), a++;
49
+ const u = this._calculateCellPosition(s, i, t);
50
+ r.push({ charIndex: l, primaryColor: p, secondaryColor: n, transform: d, position: u }), a++;
51
51
  }
52
52
  return r;
53
53
  }
54
54
  }
55
- class qt {
56
- _createGlyphPath(t, e, r, a, i) {
57
- const n = i / t.head.unitsPerEm;
58
- return { getBoundingBox: () => ({ x1: r + e.xMin * n, y1: a + -e.yMax * n, x2: r + e.xMax * n, y2: a + -e.yMin * n }), toSVG: () => this._glyphToSVGPath(e, r, a, n) };
55
+ class He {
56
+ _createGlyphPath(e, t, r, a, i) {
57
+ const s = i / e.head.unitsPerEm;
58
+ return { getBoundingBox: () => ({ x1: r + t.xMin * s, y1: a + -t.yMax * s, x2: r + t.xMax * s, y2: a + -t.yMin * s }), toSVG: () => this._glyphToSVGPath(t, r, a, s) };
59
59
  }
60
- _glyphToSVGPath(t, e, r, a) {
61
- if (!t || !t.xs) return "";
62
- const { xs: i, ys: n, endPts: c, flags: l } = t;
63
- if (!(i && n && c && l)) return "";
64
- let p = "", o = 0;
60
+ _glyphToSVGPath(e, t, r, a) {
61
+ if (!e || !e.xs) return "";
62
+ const { xs: i, ys: s, endPts: c, flags: l } = e;
63
+ if (!(i && s && c && l)) return "";
64
+ let p = "", n = 0;
65
65
  for (let d = 0; d < c.length; d++) {
66
66
  const u = c[d];
67
- if (!(u < o)) {
68
- if (u >= o) {
69
- const m = e + i[o] * a, x = r - n[o] * a;
67
+ if (!(u < n)) {
68
+ if (u >= n) {
69
+ const m = t + i[n] * a, x = r - s[n] * a;
70
70
  p += `M${m.toFixed(2)},${x.toFixed(2)}`;
71
- let h = o + 1;
71
+ let h = n + 1;
72
72
  for (; h <= u; )
73
73
  if (1 & l[h]) {
74
- const f = e + i[h] * a, _ = r - n[h] * a;
75
- p += `L${f.toFixed(2)},${_.toFixed(2)}`, h++;
74
+ const g = t + i[h] * a, _ = r - s[h] * a;
75
+ p += `L${g.toFixed(2)},${_.toFixed(2)}`, h++;
76
76
  } else {
77
- const f = e + i[h] * a, _ = r - n[h] * a;
78
- let v = h + 1 > u ? o : h + 1;
77
+ const g = t + i[h] * a, _ = r - s[h] * a;
78
+ let v = h + 1 > u ? n : h + 1;
79
79
  if (1 & l[v]) {
80
- const g = e + i[v] * a, C = r - n[v] * a;
81
- p += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, h = v + 1;
80
+ const f = t + i[v] * a, C = r - s[v] * a;
81
+ p += `Q${g.toFixed(2)},${_.toFixed(2)} ${f.toFixed(2)},${C.toFixed(2)}`, h = v + 1;
82
82
  } else {
83
- const g = (f + (e + i[v] * a)) / 2, C = (_ + (r - n[v] * a)) / 2;
84
- p += `Q${f.toFixed(2)},${_.toFixed(2)} ${g.toFixed(2)},${C.toFixed(2)}`, h = v;
83
+ const f = (g + (t + i[v] * a)) / 2, C = (_ + (r - s[v] * a)) / 2;
84
+ p += `Q${g.toFixed(2)},${_.toFixed(2)} ${f.toFixed(2)},${C.toFixed(2)}`, h = v;
85
85
  }
86
86
  }
87
87
  p += "Z";
88
88
  }
89
- o = u + 1;
89
+ n = u + 1;
90
90
  }
91
91
  }
92
92
  return p;
93
93
  }
94
- _generateCharacterPath(t, e, r, a, i) {
95
- const n = e.characterMap.get(t).glyphData;
96
- return n ? this._createGlyphPath(e.font, n, r, a, i) : null;
94
+ _generateCharacterPath(e, t, r, a, i) {
95
+ const s = t.characterMap.get(e)?.glyphData;
96
+ return s ? this._createGlyphPath(t.font, s, r, a, i) : null;
97
97
  }
98
- $generatePositionedCharacterPath(t, e, r, a, i, n, c, l) {
98
+ $generatePositionedCharacterPath(e, t, r, a, i, s, c, l) {
99
99
  if (!l) return null;
100
- const p = c / e.font.head.unitsPerEm, o = r + (i - l.advanceWidth * p) / 2, d = a + (n + 0.7 * c) / 2, u = this._generateCharacterPath(t, e, o, d, c);
100
+ const p = c / t.font.head.unitsPerEm, n = r + (i - l.advanceWidth * p) / 2, d = a + (s + 0.7 * c) / 2, u = this._generateCharacterPath(e, t, n, d, c);
101
101
  return u && u.toSVG() || null;
102
102
  }
103
103
  }
104
- class Ht {
104
+ class je {
105
105
  _pathGenerator;
106
106
  constructor() {
107
- this._pathGenerator = new qt();
107
+ this._pathGenerator = new He();
108
108
  }
109
- $generateSVGHeader(t) {
110
- const { width: e, height: r } = t;
111
- return `<?xml version="1.0" encoding="UTF-8"?><svg width="${e}" height="${r}" viewBox="0 0 ${e} ${r}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
109
+ $generateSVGHeader(e) {
110
+ const { width: t, height: r } = e;
111
+ return `<?xml version="1.0" encoding="UTF-8"?><svg width="${t}" height="${r}" viewBox="0 0 ${t} ${r}" xmlns="http://www.w3.org/2000/svg"><title>textmode.js sketch</title>`;
112
112
  }
113
113
  $generateSVGFooter() {
114
114
  return "</g></svg>";
115
115
  }
116
- _generateTransformAttribute(t, e) {
117
- const { transform: r, position: a } = t;
116
+ _generateTransformAttribute(e, t) {
117
+ const { transform: r, position: a } = e;
118
118
  if (!r.flipHorizontal && !r.flipVertical && !r.rotation) return "";
119
- const i = a.cellX + e.cellWidth / 2, n = a.cellY + e.cellHeight / 2, c = [];
119
+ const i = a.cellX + t.cellWidth / 2, s = a.cellY + t.cellHeight / 2, c = [];
120
120
  if (r.flipHorizontal || r.flipVertical) {
121
121
  const l = r.flipHorizontal ? -1 : 1, p = r.flipVertical ? -1 : 1;
122
- c.push(`translate(${i} ${n})scale(${l} ${p})translate(${-i} ${-n})`);
122
+ c.push(`translate(${i} ${s})scale(${l} ${p})translate(${-i} ${-s})`);
123
123
  }
124
- return r.rotation && c.push(`rotate(${r.rotation} ${i} ${n})`), ` transform="${c.join(" ")}"`;
124
+ return r.rotation && c.push(`rotate(${r.rotation} ${i} ${s})`), ` transform="${c.join(" ")}"`;
125
125
  }
126
- _generateCellBackground(t, e, r) {
127
- if (!r.includeBackgroundRectangles || t.secondaryColor.a === 0) return "";
128
- const { position: a } = t, { r: i, g: n, b: c, a: l } = t.secondaryColor, p = `rgba(${i},${n},${c},${l / 255})`;
129
- return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" stroke="${p}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${e.cellWidth}" height="${e.cellHeight}" fill="${p}"/>`;
126
+ _generateCellBackground(e, t, r) {
127
+ if (!r.includeBackgroundRectangles || e.secondaryColor.a === 0) return "";
128
+ const { position: a } = e, { r: i, g: s, b: c, a: l } = e.secondaryColor, p = `rgba(${i},${s},${c},${l / 255})`;
129
+ return r.drawMode === "stroke" ? `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" stroke="${p}" fill="none" stroke-width="${r.strokeWidth}"/>` : `<rect x="${a.cellX}" y="${a.cellY}" width="${t.cellWidth}" height="${t.cellHeight}" fill="${p}"/>`;
130
130
  }
131
- _generateCharacterPath(t, e, r, a) {
132
- const i = r.characters[t.charIndex];
131
+ _generateCharacterPath(e, t, r, a) {
132
+ const i = r.characters[e.charIndex];
133
133
  if (!i) return "";
134
- const n = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, t.position.cellX, t.position.cellY, e.cellWidth, e.cellHeight, r.fontSize, i.glyphData);
135
- if (!n) return "";
136
- const { r: c, g: l, b: p, a: o } = t.primaryColor, d = `rgba(${c},${l},${p},${o / 255})`;
137
- return a.drawMode === "stroke" ? `<path d="${n}" stroke="${d}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${n}" fill="${d}"/>`;
138
- }
139
- $generateCellContent(t, e, r, a) {
140
- const i = [], n = this._generateCellBackground(t, e, a);
141
- n && i.push(n);
142
- const c = this._generateCharacterPath(t, e, r, a);
134
+ const s = this._pathGenerator.$generatePositionedCharacterPath(i.character, r, e.position.cellX, e.position.cellY, t.cellWidth, t.cellHeight, r.fontSize, i.glyphData);
135
+ if (!s) return "";
136
+ const { r: c, g: l, b: p, a: n } = e.primaryColor, d = `rgba(${c},${l},${p},${n / 255})`;
137
+ return a.drawMode === "stroke" ? `<path d="${s}" stroke="${d}" stroke-width="${a.strokeWidth}" fill="none"/>` : `<path d="${s}" fill="${d}"/>`;
138
+ }
139
+ $generateCellContent(e, t, r, a) {
140
+ const i = [], s = this._generateCellBackground(e, t, a);
141
+ s && i.push(s);
142
+ const c = this._generateCharacterPath(e, t, r, a);
143
143
  if (c) {
144
- const l = this._generateTransformAttribute(t, e);
144
+ const l = this._generateTransformAttribute(e, t);
145
145
  i.push(l ? `<g${l}>${c}</g>` : c);
146
146
  }
147
147
  return i.join("");
148
148
  }
149
- $generateSVGContent(t, e, r, a) {
150
- const i = [this.$generateSVGHeader(e), '<g id="ascii-cells">'];
151
- for (const n of t) i.push(this.$generateCellContent(n, e, r, a));
149
+ $generateSVGContent(e, t, r, a) {
150
+ const i = [this.$generateSVGHeader(t), '<g id="ascii-cells">'];
151
+ for (const s of e) i.push(this.$generateCellContent(s, t, r, a));
152
152
  return i.push(this.$generateSVGFooter()), i.join("");
153
153
  }
154
- $optimizeSVGContent(t) {
155
- return t.replace(/<path[^>]*d=""[^>]*\/>/g, "").replace(/\s+/g, " ").replace(/> </g, "><");
154
+ $optimizeSVGContent(e) {
155
+ return e.replace(/\s+/g, " ").replace(/> </g, "><");
156
156
  }
157
157
  }
158
- class gt {
159
- _applyDefaultOptions(t) {
160
- return { includeBackgroundRectangles: t.includeBackgroundRectangles ?? !0, drawMode: t.drawMode ?? "fill", strokeWidth: t.strokeWidth ?? 1, filename: t.filename };
158
+ class ge {
159
+ _applyDefaultOptions(e) {
160
+ return { includeBackgroundRectangles: e.includeBackgroundRectangles ?? !0, drawMode: e.drawMode ?? "fill", strokeWidth: e.strokeWidth ?? 1, filename: e.filename };
161
161
  }
162
- $generateSVG(t, e = {}) {
163
- const r = new Wt(), a = new Ht(), i = r.$extractSVGCellData(r.$extractFramebufferData(t.layers.base.drawFramebuffer), t.grid), n = a.$generateSVGContent(i, t.grid, t.font, this._applyDefaultOptions(e));
164
- return a.$optimizeSVGContent(n);
162
+ $generateSVG(e, t = {}) {
163
+ const r = new qe(), a = new je(), i = r.$extractSVGCellData(r.$extractFramebufferData(e.layers.base.drawFramebuffer), e.grid), s = a.$generateSVGContent(i, e.grid, e.font, this._applyDefaultOptions(t));
164
+ return a.$optimizeSVGContent(s);
165
165
  }
166
- $saveSVG(t, e = {}) {
167
- new Q().$downloadFile(new Blob([this.$generateSVG(t, e)], { type: "image/svg+xml;charset=utf-8" }), e.filename);
166
+ $saveSVG(e, t = {}) {
167
+ new Q().$downloadFile(new Blob([this.$generateSVG(e, t)], { type: "image/svg+xml;charset=utf-8" }), t.filename);
168
168
  }
169
169
  }
170
- const st = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, lt = { png: ".png", jpg: ".jpg", webp: ".webp" };
171
- class bt {
172
- _applyDefaultOptions(t) {
173
- return { format: t.format ?? "png", scale: Math.abs(t.scale ?? 1), filename: t.filename };
170
+ const se = { png: "image/png", jpg: "image/jpeg", webp: "image/webp" }, le = { png: ".png", jpg: ".jpg", webp: ".webp" };
171
+ class be {
172
+ _applyDefaultOptions(e) {
173
+ return { format: e.format ?? "png", scale: Math.abs(e.scale ?? 1), filename: e.filename };
174
174
  }
175
- _validateOptions(t) {
176
- if (!(t.format in st)) throw new Error(`Saving '${t.format}' files is not supported`);
175
+ _validateOptions(e) {
176
+ if (!(e.format in se)) throw new Error(`Saving '${e.format}' files is not supported`);
177
177
  }
178
- async $generateImageBlob(t, e) {
179
- const r = t, a = document.createElement("canvas"), i = a.getContext("2d"), n = Math.round(r.width * e.scale), c = Math.round(r.height * e.scale);
180
- return a.width = n, a.height = c, i.imageSmoothingEnabled = !1, i.clearRect(0, 0, n, c), i.drawImage(r, 0, 0, r.width, r.height, 0, 0, n, c), await new Promise((l, p) => {
181
- a.toBlob((o) => {
182
- o ? l(o) : p(new Error(`Failed to generate ${e.format.toUpperCase()} blob`));
183
- }, st[e.format]);
178
+ async $generateImageBlob(e, t) {
179
+ const r = e, a = document.createElement("canvas"), i = a.getContext("2d"), s = Math.round(r.width * t.scale), c = Math.round(r.height * t.scale);
180
+ return a.width = s, a.height = c, i.imageSmoothingEnabled = !1, i.clearRect(0, 0, s, c), i.drawImage(r, 0, 0, r.width, r.height, 0, 0, s, c), await new Promise((l, p) => {
181
+ a.toBlob((n) => {
182
+ n ? l(n) : p(new Error(`Failed to generate ${t.format.toUpperCase()} blob`));
183
+ }, se[t.format]);
184
184
  });
185
185
  }
186
- async $saveImage(t, e = {}) {
187
- const r = this._applyDefaultOptions(e);
186
+ async $saveImage(e, t = {}) {
187
+ const r = this._applyDefaultOptions(t);
188
188
  this._validateOptions(r);
189
- const a = await this.$generateImageBlob(t, r);
189
+ const a = await this.$generateImageBlob(e, r);
190
190
  new Q().$downloadFile(a, r.filename);
191
191
  }
192
- async $copyImageToClipboard(t, e = {}) {
192
+ async $copyImageToClipboard(e, t = {}) {
193
193
  if (typeof navigator > "u" || !navigator.clipboard || typeof navigator.clipboard.write != "function") throw new Error("Clipboard API is not available in this environment");
194
- const r = this._applyDefaultOptions(e);
194
+ const r = this._applyDefaultOptions(t);
195
195
  this._validateOptions(r);
196
- const a = await this.$generateImageBlob(t, r), i = new ClipboardItem({ [st[r.format]]: a });
196
+ const a = await this.$generateImageBlob(e, r), i = new ClipboardItem({ [se[r.format]]: a });
197
197
  await navigator.clipboard.write([i]);
198
198
  }
199
199
  }
200
- class vt {
201
- _applyDefaultOptions(t) {
202
- return { preserveTrailingSpaces: t.preserveTrailingSpaces ?? !1, emptyCharacter: t.emptyCharacter ?? " ", filename: t.filename };
203
- }
204
- _createTXTContent(t, e) {
205
- const r = new At();
206
- console.log(t);
207
- let a = r.$extractFramebufferData(t.layers.base.drawFramebuffer);
208
- const i = [];
209
- let n = 0;
210
- for (let l = 0; l < t.grid.rows; l++) {
211
- const p = [];
212
- for (let o = 0; o < t.grid.cols; o++) {
213
- const d = 4 * n, u = r.$getCharacterIndex(a.characterPixels, d), m = t.font.characters[u]?.character || e.emptyCharacter;
214
- p.push(m), n++;
200
+ class ve {
201
+ _applyDefaultOptions(e) {
202
+ return { preserveTrailingSpaces: e.preserveTrailingSpaces ?? !1, emptyCharacter: e.emptyCharacter ?? " ", filename: e.filename };
203
+ }
204
+ _createTXTContent(e, t) {
205
+ const r = new Ae(), a = e.layers.base.drawFramebuffer, i = r.$extractFramebufferData(a), s = [];
206
+ let c = 0;
207
+ for (let l = 0; l < e.grid.rows; l++) {
208
+ let p = "";
209
+ for (let n = 0; n < e.grid.cols; n++) {
210
+ const d = 4 * c, u = r.$getCharacterIndex(i.characterPixels, d);
211
+ p += e.font.characters[u]?.character || t.emptyCharacter, c++;
215
212
  }
216
- i.push(p);
217
- }
218
- const c = [];
219
- for (const l of i) {
220
- let p = l.join("");
221
- e.preserveTrailingSpaces || (p = p.replace(/\s+$/, "")), c.push(p);
213
+ t.preserveTrailingSpaces || (p = p.trimEnd()), s.push(p);
222
214
  }
223
- return c.join(`
215
+ return s.join(`
224
216
  `);
225
217
  }
226
- $generateTXT(t, e = {}) {
227
- return this._createTXTContent(t, this._applyDefaultOptions(e));
218
+ $generateTXT(e, t = {}) {
219
+ return this._createTXTContent(e, this._applyDefaultOptions(t));
228
220
  }
229
- $saveTXT(t, e = {}) {
230
- const r = this._applyDefaultOptions(e), a = this._createTXTContent(t, r), i = new Blob([a], { type: "text/plain;charset=utf-8" });
221
+ $saveTXT(e, t = {}) {
222
+ const r = this._applyDefaultOptions(t), a = this._createTXTContent(e, r), i = new Blob([a], { type: "text/plain;charset=utf-8" });
231
223
  new Q().$downloadFile(i, r.filename);
232
224
  }
233
225
  }
234
- class jt {
226
+ class Qe {
235
227
  _canvas;
236
228
  _ctx;
237
- async $record(t, e, r, a) {
238
- const i = Math.max(1, Math.round(e.frameRate)), n = Math.round(1e3 / i), c = Math.max(1, Math.round(e.frameCount));
229
+ async $record(e, t, r, a) {
230
+ const i = Math.max(1, Math.round(t.frameRate)), s = Math.round(1e3 / i), c = Math.max(1, Math.round(t.frameCount));
239
231
  return await new Promise((l, p) => {
240
- const o = [];
232
+ const n = [];
241
233
  let d, u = 0, m = !1;
242
234
  const x = () => {
243
235
  d && (d(), d = void 0);
244
236
  }, h = (_) => {
245
237
  m || (m = !0, x(), l(_));
246
- }, f = () => {
247
- if (u >= c) h(o);
238
+ }, g = () => {
239
+ if (u >= c) h(n);
248
240
  else try {
249
- const _ = e.scale, v = Math.max(1, Math.round(t.width * _)), g = Math.max(1, Math.round(t.height * _));
250
- this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === v && this._canvas.height === g || (this._canvas.width = v, this._canvas.height = g), this._ctx || (this._ctx = this._canvas.getContext("2d"));
241
+ const _ = t.scale, v = Math.max(1, Math.round(e.width * _)), f = Math.max(1, Math.round(e.height * _));
242
+ this._canvas || (this._canvas = document.createElement("canvas")), this._canvas.width === v && this._canvas.height === f || (this._canvas.width = v, this._canvas.height = f), this._ctx || (this._ctx = this._canvas.getContext("2d"));
251
243
  const C = this._ctx;
252
- C.imageSmoothingEnabled = !1, C.clearRect(0, 0, v, g), C.drawImage(t, 0, 0, t.width, t.height, 0, 0, v, g);
253
- const S = { imageData: C.getImageData(0, 0, v, g), width: v, height: g, delayMs: n };
254
- o.push(S), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames: c }), u >= c && h(o);
244
+ C.imageSmoothingEnabled = !1, C.clearRect(0, 0, v, f), C.drawImage(e, 0, 0, e.width, e.height, 0, 0, v, f);
245
+ const F = { imageData: C.getImageData(0, 0, v, f), width: v, height: f, delayMs: s };
246
+ n.push(F), u += 1, a?.({ state: "recording", frameIndex: u, totalFrames: c }), u >= c && h(n);
255
247
  } catch (_) {
256
248
  ((v) => {
257
249
  if (m) return;
258
250
  m = !0, x();
259
- const g = v instanceof Error ? v.message : "GIF recording failed";
260
- a?.({ state: "error", message: g }), p(v instanceof Error ? v : new Error(String(v)));
251
+ const f = v instanceof Error ? v.message : "GIF recording failed";
252
+ a?.({ state: "error", message: f }), p(v instanceof Error ? v : new Error(String(v)));
261
253
  })(_);
262
254
  }
263
255
  };
264
256
  d = r(() => {
265
- f();
257
+ g();
266
258
  }), a?.({ state: "recording", frameIndex: 0, totalFrames: c });
267
259
  });
268
260
  }
269
261
  }
270
- var Pt = Object.defineProperty, Qt = (s) => Pt(s, "__esModule", { value: !0 }), Xt = (s, t) => () => (t || s((t = { exports: {} }).exports, t), t.exports), Yt = (s, t) => {
271
- for (var e in t) Pt(s, e, { get: t[e], enumerable: !0 });
272
- }, Jt = Xt((s) => {
273
- function t(d, u, m) {
262
+ var Pe = Object.defineProperty, Xe = (o) => Pe(o, "__esModule", { value: !0 }), Ye = (o, e) => () => (e || o((e = { exports: {} }).exports, e), e.exports), Je = (o, e) => {
263
+ for (var t in e) Pe(o, t, { get: e[t], enumerable: !0 });
264
+ }, Ke = Ye((o) => {
265
+ function e(d, u, m) {
274
266
  return 0.29889531 * d + 0.58662247 * u + 0.11448223 * m;
275
267
  }
276
- function e(d, u, m) {
268
+ function t(d, u, m) {
277
269
  return 0.59597799 * d - 0.2741761 * u - 0.32180189 * m;
278
270
  }
279
271
  function r(d, u, m) {
280
272
  return 0.21147017 * d - 0.52261711 * u + 0.31114694 * m;
281
273
  }
282
274
  function a(d, u) {
283
- let m = d[0] - u[0], x = d[1] - u[1], h = d[2] - u[2], f = i(d) - i(u);
284
- return m * m * 0.5053 + x * x * 0.299 + h * h * 0.1957 + f * f;
275
+ let m = d[0] - u[0], x = d[1] - u[1], h = d[2] - u[2], g = i(d) - i(u);
276
+ return m * m * 0.5053 + x * x * 0.299 + h * h * 0.1957 + g * g;
285
277
  }
286
278
  function i(d) {
287
279
  return d[3] != null ? d[3] : 255;
288
280
  }
289
- function n(d, u) {
281
+ function s(d, u) {
290
282
  return Math.sqrt(a(d, u));
291
283
  }
292
284
  function c(d, u) {
293
- let [m, x, h] = d, [f, _, v] = u, g = t(m, x, h) - t(f, _, v), C = e(m, x, h) - e(f, _, v), S = r(m, x, h) - r(f, _, v), E = i(d) - i(u);
294
- return g * g * 0.5053 + C * C * 0.299 + S * S * 0.1957 + E * E;
285
+ let [m, x, h] = d, [g, _, v] = u, f = e(m, x, h) - e(g, _, v), C = t(m, x, h) - t(g, _, v), F = r(m, x, h) - r(g, _, v), E = i(d) - i(u);
286
+ return f * f * 0.5053 + C * C * 0.299 + F * F * 0.1957 + E * E;
295
287
  }
296
288
  function l(d, u) {
297
289
  return Math.sqrt(c(d, u));
@@ -304,60 +296,60 @@ var Pt = Object.defineProperty, Qt = (s) => Pt(s, "__esModule", { value: !0 }),
304
296
  }
305
297
  return x;
306
298
  }
307
- function o(d, u) {
299
+ function n(d, u) {
308
300
  return Math.sqrt(p(d, u));
309
301
  }
310
- Qt(s), Yt(s, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => c, colorDifferenceYIQ: () => n, colorDifferenceYIQSquared: () => a, euclideanDistance: () => o, euclideanDistanceSquared: () => p });
311
- }), Kt = { trailer: 59 };
312
- function Dt(s = 256) {
313
- let t = 0, e = new Uint8Array(s);
302
+ Xe(o), Je(o, { colorDifferenceRGBToYIQ: () => l, colorDifferenceRGBToYIQSquared: () => c, colorDifferenceYIQ: () => s, colorDifferenceYIQSquared: () => a, euclideanDistance: () => n, euclideanDistanceSquared: () => p });
303
+ }), Ze = { trailer: 59 };
304
+ function De(o = 256) {
305
+ let e = 0, t = new Uint8Array(o);
314
306
  return { get buffer() {
315
- return e.buffer;
307
+ return t.buffer;
316
308
  }, reset() {
317
- t = 0;
318
- }, bytesView: () => e.subarray(0, t), bytes: () => e.slice(0, t), writeByte(a) {
319
- r(t + 1), e[t] = a, t++;
320
- }, writeBytes(a, i = 0, n = a.length) {
321
- r(t + n);
322
- for (let c = 0; c < n; c++) e[t++] = a[c + i];
323
- }, writeBytesView(a, i = 0, n = a.byteLength) {
324
- r(t + n), e.set(a.subarray(i, i + n), t), t += n;
309
+ e = 0;
310
+ }, bytesView: () => t.subarray(0, e), bytes: () => t.slice(0, e), writeByte(a) {
311
+ r(e + 1), t[e] = a, e++;
312
+ }, writeBytes(a, i = 0, s = a.length) {
313
+ r(e + s);
314
+ for (let c = 0; c < s; c++) t[e++] = a[c + i];
315
+ }, writeBytesView(a, i = 0, s = a.byteLength) {
316
+ r(e + s), t.set(a.subarray(i, i + s), e), e += s;
325
317
  } };
326
318
  function r(a) {
327
- var i = e.length;
319
+ var i = t.length;
328
320
  if (i >= a) return;
329
321
  a = Math.max(a, i * (i < 1048576 ? 2 : 1.125) >>> 0), i != 0 && (a = Math.max(a, 256));
330
- let n = e;
331
- e = new Uint8Array(a), t > 0 && e.set(n.subarray(0, t), 0);
322
+ let s = t;
323
+ t = new Uint8Array(a), e > 0 && t.set(s.subarray(0, e), 0);
332
324
  }
333
325
  }
334
- var Z = 12, xt = 5003, Zt = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
335
- function te(s, t, e, r, a, i, n, c) {
336
- a = a || Dt(512), i = i || new Uint8Array(256), n = n || new Int32Array(xt), c = c || new Int32Array(xt);
337
- let l = n.length, p = Math.max(2, r);
326
+ var Z = 12, xe = 5003, et = [0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767, 65535];
327
+ function tt(o, e, t, r, a, i, s, c) {
328
+ a = a || De(512), i = i || new Uint8Array(256), s = s || new Int32Array(xe), c = c || new Int32Array(xe);
329
+ let l = s.length, p = Math.max(2, r);
338
330
  i.fill(0), c.fill(0), L();
339
- let o = 0, d = 0, u = p + 1, m = u, x = !1, h = m, f = D(h), _ = 1 << u - 1, v = _ + 1, g = _ + 2, C = 0, S = e[0], E = 0;
331
+ let n = 0, d = 0, u = p + 1, m = u, x = !1, h = m, g = D(h), _ = 1 << u - 1, v = _ + 1, f = _ + 2, C = 0, F = t[0], E = 0;
340
332
  for (let k = l; k < 65536; k *= 2) ++E;
341
- E = 8 - E, a.writeByte(p), O(_);
342
- for (let k = 1; k < e.length; k++) V(e[k]);
343
- return O(S), O(v), a.writeByte(0), a.bytesView();
333
+ E = 8 - E, a.writeByte(p), T(_);
334
+ for (let k = 1; k < t.length; k++) V(t[k]);
335
+ return T(F), T(v), a.writeByte(0), a.bytesView();
344
336
  function A(k) {
345
337
  i[C++] = k, C >= 254 && B();
346
338
  }
347
339
  function L() {
348
- n.fill(-1);
340
+ s.fill(-1);
349
341
  }
350
342
  function V(k) {
351
- let R = (k << Z) + S, y = k << E ^ S;
352
- if (n[y] === R) S = c[y];
343
+ let R = (k << Z) + F, y = k << E ^ F;
344
+ if (s[y] === R) F = c[y];
353
345
  else {
354
- if (n[y] >= 0) {
346
+ if (s[y] >= 0) {
355
347
  let w = y === 0 ? 1 : l - y;
356
348
  do
357
- if (y -= w, y < 0 && (y += l), n[y] === R) return void (S = c[y]);
358
- while (n[y] >= 0);
349
+ if (y -= w, y < 0 && (y += l), s[y] === R) return void (F = c[y]);
350
+ while (s[y] >= 0);
359
351
  }
360
- O(S), S = k, g < 1 << Z ? (c[y] = g++, n[y] = R) : (L(), g = _ + 2, x = !0, O(_));
352
+ T(F), F = k, f < 1 << Z ? (c[y] = f++, s[y] = R) : (L(), f = _ + 2, x = !0, T(_));
361
353
  }
362
354
  }
363
355
  function B() {
@@ -366,249 +358,250 @@ function te(s, t, e, r, a, i, n, c) {
366
358
  function D(k) {
367
359
  return (1 << k) - 1;
368
360
  }
369
- function O(k) {
370
- for (o &= Zt[d], d > 0 ? o |= k << d : o = k, d += h; d >= 8; ) A(255 & o), o >>= 8, d -= 8;
371
- if ((g > f || x) && (x ? (h = m, f = D(h), x = !1) : (++h, f = h == Z ? 1 << Z : D(h))), k == v) {
372
- for (; d > 0; ) A(255 & o), o >>= 8, d -= 8;
361
+ function T(k) {
362
+ for (n &= et[d], d > 0 ? n |= k << d : n = k, d += h; d >= 8; ) A(255 & n), n >>= 8, d -= 8;
363
+ if ((f > g || x) && (x ? (h = m, g = D(h), x = !1) : (++h, g = h == Z ? 1 << Z : D(h))), k == v) {
364
+ for (; d > 0; ) A(255 & n), n >>= 8, d -= 8;
373
365
  B();
374
366
  }
375
367
  }
376
368
  }
377
- var ee = te;
378
- function Vt(s, t, e) {
379
- return s << 8 & 63488 | t << 2 & 992 | e >> 3 & 31;
369
+ var rt = tt;
370
+ function Ve(o, e, t) {
371
+ return o << 8 & 63488 | e << 2 & 992 | t >> 3 & 31;
380
372
  }
381
- function Tt(s, t, e, r) {
382
- return s >> 4 | 240 & t | (240 & e) << 4 | (240 & r) << 8;
373
+ function Oe(o, e, t, r) {
374
+ return o >> 4 | 240 & e | (240 & t) << 4 | (240 & r) << 8;
383
375
  }
384
- function Ot(s, t, e) {
385
- return s >> 4 << 8 | t >> 4 << 4 | e >> 4;
376
+ function Te(o, e, t) {
377
+ return o >> 4 << 8 | e >> 4 << 4 | t >> 4;
386
378
  }
387
- function tt(s, t, e) {
388
- return s < t ? t : s > e ? e : s;
379
+ function ee(o, e, t) {
380
+ return o < e ? e : o > t ? t : o;
389
381
  }
390
- function at(s) {
391
- return s * s;
382
+ function ae(o) {
383
+ return o * o;
392
384
  }
393
- function yt(s, t, e) {
394
- for (var r = 0, a = 1e100, i = s[t], n = i.cnt, c = (i.ac, i.rc), l = i.gc, p = i.bc, o = i.fw; o != 0; o = s[o].fw) {
395
- var d = s[o].cnt, u = n * d / (n + d);
385
+ function ye(o, e, t) {
386
+ for (var r = 0, a = 1e100, i = o[e], s = i.cnt, c = (i.ac, i.rc), l = i.gc, p = i.bc, n = i.fw; n != 0; n = o[n].fw) {
387
+ var d = o[n].cnt, u = s * d / (s + d);
396
388
  if (!(u >= a)) {
397
389
  var m = 0;
398
- !((m += u * at(s[o].rc - c)) >= a) && !((m += u * at(s[o].gc - l)) >= a) && !((m += u * at(s[o].bc - p)) >= a) && (a = m, r = o);
390
+ !((m += u * ae(o[n].rc - c)) >= a) && !((m += u * ae(o[n].gc - l)) >= a) && !((m += u * ae(o[n].bc - p)) >= a) && (a = m, r = n);
399
391
  }
400
392
  }
401
393
  i.err = a, i.nn = r;
402
394
  }
403
- function dt() {
395
+ function de() {
404
396
  return { ac: 0, rc: 0, gc: 0, bc: 0, cnt: 0, nn: 0, fw: 0, bk: 0, tm: 0, mtm: 0, err: 0 };
405
397
  }
406
- function re(s, t) {
407
- let e = new Array(t === "rgb444" ? 4096 : 65536), r = s.length;
408
- if (t === "rgba4444") for (let a = 0; a < r; ++a) {
409
- let i = s[a], n = i >> 24 & 255, c = i >> 16 & 255, l = i >> 8 & 255, p = 255 & i, o = Tt(p, l, c, n), d = o in e ? e[o] : e[o] = dt();
410
- d.rc += p, d.gc += l, d.bc += c, d.ac += n, d.cnt++;
398
+ function at(o, e) {
399
+ let t = new Array(e === "rgb444" ? 4096 : 65536), r = o.length;
400
+ if (e === "rgba4444") for (let a = 0; a < r; ++a) {
401
+ let i = o[a], s = i >> 24 & 255, c = i >> 16 & 255, l = i >> 8 & 255, p = 255 & i, n = Oe(p, l, c, s), d = n in t ? t[n] : t[n] = de();
402
+ d.rc += p, d.gc += l, d.bc += c, d.ac += s, d.cnt++;
411
403
  }
412
- else if (t === "rgb444") for (let a = 0; a < r; ++a) {
413
- let i = s[a], n = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Ot(l, c, n), o = p in e ? e[p] : e[p] = dt();
414
- o.rc += l, o.gc += c, o.bc += n, o.cnt++;
404
+ else if (e === "rgb444") for (let a = 0; a < r; ++a) {
405
+ let i = o[a], s = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Te(l, c, s), n = p in t ? t[p] : t[p] = de();
406
+ n.rc += l, n.gc += c, n.bc += s, n.cnt++;
415
407
  }
416
408
  else for (let a = 0; a < r; ++a) {
417
- let i = s[a], n = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Vt(l, c, n), o = p in e ? e[p] : e[p] = dt();
418
- o.rc += l, o.gc += c, o.bc += n, o.cnt++;
409
+ let i = o[a], s = i >> 16 & 255, c = i >> 8 & 255, l = 255 & i, p = Ve(l, c, s), n = p in t ? t[p] : t[p] = de();
410
+ n.rc += l, n.gc += c, n.bc += s, n.cnt++;
419
411
  }
420
- return e;
412
+ return t;
421
413
  }
422
- function ae(s, t, e) {
423
- let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold: n = 0, oneBitAlpha: c = !1 } = e || {}, l = e.useSqrt !== !1, p = r === "rgba4444", o = re(s, r), d = o.length, u = d - 1, m = new Uint32Array(d + 1);
424
- for (var x = 0, h = 0; h < o.length; ++h) {
425
- let k = o[h];
414
+ function it(o, e, t) {
415
+ let { format: r = "rgb565", clearAlpha: a = !0, clearAlphaColor: i = 0, clearAlphaThreshold: s = 0, oneBitAlpha: c = !1 } = t || {}, l = t.useSqrt !== !1, p = r === "rgba4444", n = at(o, r), d = n.length, u = d - 1, m = new Uint32Array(d + 1);
416
+ for (var x = 0, h = 0; h < n.length; ++h) {
417
+ let k = n[h];
426
418
  if (k != null) {
427
- var f = 1 / k.cnt;
428
- p && (k.ac *= f), k.rc *= f, k.gc *= f, k.bc *= f, o[x++] = k;
419
+ var g = 1 / k.cnt;
420
+ p && (k.ac *= g), k.rc *= g, k.gc *= g, k.bc *= g, n[x++] = k;
429
421
  }
430
422
  }
431
- for (at(t) / x < 0.022 && (l = !1), h = 0; h < x - 1; ++h) o[h].fw = h + 1, o[h + 1].bk = h, l && (o[h].cnt = Math.sqrt(o[h].cnt));
432
- var _, v, g;
433
- for (l && (o[h].cnt = Math.sqrt(o[h].cnt)), h = 0; h < x; ++h) {
434
- yt(o, h);
435
- var C = o[h].err;
436
- for (v = ++m[0]; v > 1 && !(o[_ = m[g = v >> 1]].err <= C); v = g) m[v] = _;
423
+ for (ae(e) / x < 0.022 && (l = !1), h = 0; h < x - 1; ++h) n[h].fw = h + 1, n[h + 1].bk = h, l && (n[h].cnt = Math.sqrt(n[h].cnt));
424
+ var _, v, f;
425
+ for (l && (n[h].cnt = Math.sqrt(n[h].cnt)), h = 0; h < x; ++h) {
426
+ ye(n, h);
427
+ var C = n[h].err;
428
+ for (v = ++m[0]; v > 1 && !(n[_ = m[f = v >> 1]].err <= C); v = f) m[v] = _;
437
429
  m[v] = h;
438
430
  }
439
- var S = x - t;
440
- for (h = 0; h < S; ) {
431
+ var F = x - e;
432
+ for (h = 0; h < F; ) {
441
433
  for (var E; ; ) {
442
434
  var A = m[1];
443
- if ((E = o[A]).tm >= E.mtm && o[E.nn].mtm <= E.tm) break;
444
- for (E.mtm == u ? A = m[1] = m[m[0]--] : (yt(o, A), E.tm = h), C = o[A].err, v = 1; (g = v + v) <= m[0] && (g < m[0] && o[m[g]].err > o[m[g + 1]].err && g++, !(C <= o[_ = m[g]].err)); v = g) m[v] = _;
435
+ if ((E = n[A]).tm >= E.mtm && n[E.nn].mtm <= E.tm) break;
436
+ for (E.mtm == u ? A = m[1] = m[m[0]--] : (ye(n, A), E.tm = h), C = n[A].err, v = 1; (f = v + v) <= m[0] && (f < m[0] && n[m[f]].err > n[m[f + 1]].err && f++, !(C <= n[_ = m[f]].err)); v = f) m[v] = _;
445
437
  m[v] = A;
446
438
  }
447
- var L = o[E.nn], V = E.cnt, B = L.cnt;
448
- f = 1 / (V + B), p && (E.ac = f * (V * E.ac + B * L.ac)), E.rc = f * (V * E.rc + B * L.rc), E.gc = f * (V * E.gc + B * L.gc), E.bc = f * (V * E.bc + B * L.bc), E.cnt += L.cnt, E.mtm = ++h, o[L.bk].fw = L.fw, o[L.fw].bk = L.bk, L.mtm = u;
439
+ var L = n[E.nn], V = E.cnt, B = L.cnt;
440
+ g = 1 / (V + B), p && (E.ac = g * (V * E.ac + B * L.ac)), E.rc = g * (V * E.rc + B * L.rc), E.gc = g * (V * E.gc + B * L.gc), E.bc = g * (V * E.bc + B * L.bc), E.cnt += L.cnt, E.mtm = ++h, n[L.bk].fw = L.fw, n[L.fw].bk = L.bk, L.mtm = u;
449
441
  }
450
442
  let D = [];
451
- var O = 0;
452
- for (h = 0; ; ++O) {
453
- let k = tt(Math.round(o[h].rc), 0, 255), R = tt(Math.round(o[h].gc), 0, 255), y = tt(Math.round(o[h].bc), 0, 255), w = 255;
454
- p && (w = tt(Math.round(o[h].ac), 0, 255), c && (w = w <= (typeof c == "number" ? c : 127) ? 0 : 255), a && w <= n && (k = R = y = i, w = 0));
455
- let F = p ? [k, R, y, w] : [k, R, y];
456
- if (ie(D, F) || D.push(F), (h = o[h].fw) == 0) break;
443
+ var T = 0;
444
+ for (h = 0; ; ++T) {
445
+ let k = ee(Math.round(n[h].rc), 0, 255), R = ee(Math.round(n[h].gc), 0, 255), y = ee(Math.round(n[h].bc), 0, 255), w = 255;
446
+ p && (w = ee(Math.round(n[h].ac), 0, 255), c && (w = w <= (typeof c == "number" ? c : 127) ? 0 : 255), a && w <= s && (k = R = y = i, w = 0));
447
+ let S = p ? [k, R, y, w] : [k, R, y];
448
+ if (ot(D, S) || D.push(S), (h = n[h].fw) == 0) break;
457
449
  }
458
450
  return D;
459
451
  }
460
- function ie(s, t) {
461
- for (let e = 0; e < s.length; e++) {
462
- let r = s[e], a = r[0] === t[0] && r[1] === t[1] && r[2] === t[2], i = !(r.length >= 4 && t.length >= 4) || r[3] === t[3];
452
+ function ot(o, e) {
453
+ for (let t = 0; t < o.length; t++) {
454
+ let r = o[t], a = r[0] === e[0] && r[1] === e[1] && r[2] === e[2], i = !(r.length >= 4 && e.length >= 4) || r[3] === e[3];
463
455
  if (a && i) return !0;
464
456
  }
465
457
  return !1;
466
458
  }
467
- function oe(s, t, e) {
468
- let r = (e = e || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(s.length), i = new Array(r);
469
- if (e === "rgba4444") for (let n = 0; n < s.length; n++) {
470
- let c, l = s[n], p = l >> 24 & 255, o = l >> 16 & 255, d = l >> 8 & 255, u = 255 & l, m = Tt(u, d, o, p);
471
- i[m] != null ? c = i[m] : (c = ne(u, d, o, p, t), i[m] = c), a[n] = c;
459
+ function nt(o, e, t) {
460
+ let r = (t = t || "rgb565") === "rgb444" ? 4096 : 65536, a = new Uint8Array(o.length), i = new Array(r);
461
+ if (t === "rgba4444") for (let s = 0; s < o.length; s++) {
462
+ let c, l = o[s], p = l >> 24 & 255, n = l >> 16 & 255, d = l >> 8 & 255, u = 255 & l, m = Oe(u, d, n, p);
463
+ i[m] != null ? c = i[m] : (c = st(u, d, n, p, e), i[m] = c), a[s] = c;
472
464
  }
473
- else for (let n = 0; n < s.length; n++) {
474
- let c, l = s[n], p = l >> 16 & 255, o = l >> 8 & 255, d = 255 & l, u = e === "rgb444" ? Ot(d, o, p) : Vt(d, o, p);
475
- i[u] != null ? c = i[u] : (c = se(d, o, p, t), i[u] = c), a[n] = c;
465
+ else for (let s = 0; s < o.length; s++) {
466
+ let c, l = o[s], p = l >> 16 & 255, n = l >> 8 & 255, d = 255 & l, u = t === "rgb444" ? Te(d, n, p) : Ve(d, n, p);
467
+ i[u] != null ? c = i[u] : (c = lt(d, n, p, e), i[u] = c), a[s] = c;
476
468
  }
477
469
  return a;
478
470
  }
479
- function ne(s, t, e, r, a) {
480
- let i = 0, n = 1e100;
471
+ function st(o, e, t, r, a) {
472
+ let i = 0, s = 1e100;
481
473
  for (let c = 0; c < a.length; c++) {
482
- let l = a[c], p = l[0], o = l[1], d = l[2], u = W(l[3] - r);
483
- u > n || (u += W(p - s), !(u > n) && (u += W(o - t), !(u > n) && (u += W(d - e), !(u > n) && (n = u, i = c))));
474
+ let l = a[c], p = l[0], n = l[1], d = l[2], u = W(l[3] - r);
475
+ u > s || (u += W(p - o), !(u > s) && (u += W(n - e), !(u > s) && (u += W(d - t), !(u > s) && (s = u, i = c))));
484
476
  }
485
477
  return i;
486
478
  }
487
- function se(s, t, e, r) {
479
+ function lt(o, e, t, r) {
488
480
  let a = 0, i = 1e100;
489
- for (let n = 0; n < r.length; n++) {
490
- let c = r[n], l = c[0], p = c[1], o = c[2], d = W(l - s);
491
- d > i || (d += W(p - t), !(d > i) && (d += W(o - e), !(d > i) && (i = d, a = n)));
481
+ for (let s = 0; s < r.length; s++) {
482
+ let c = r[s], l = c[0], p = c[1], n = c[2], d = W(l - o);
483
+ d > i || (d += W(p - e), !(d > i) && (d += W(n - t), !(d > i) && (i = d, a = s)));
492
484
  }
493
485
  return a;
494
486
  }
495
- function W(s) {
496
- return s * s;
487
+ function W(o) {
488
+ return o * o;
497
489
  }
498
- function le(s = {}) {
499
- let { initialCapacity: t = 4096, auto: e = !0 } = s, r = Dt(t), a = new Uint8Array(256), i = new Int32Array(5003), n = new Int32Array(5003), c = !1;
490
+ function dt(o = {}) {
491
+ let { initialCapacity: e = 4096, auto: t = !0 } = o, r = De(e), a = new Uint8Array(256), i = new Int32Array(5003), s = new Int32Array(5003), c = !1;
500
492
  return { reset() {
501
493
  r.reset(), c = !1;
502
494
  }, finish() {
503
- r.writeByte(Kt.trailer);
495
+ r.writeByte(Ze.trailer);
504
496
  }, bytes: () => r.bytes(), bytesView: () => r.bytesView(), get buffer() {
505
497
  return r.buffer;
506
498
  }, get stream() {
507
499
  return r;
508
- }, writeHeader: l, writeFrame(p, o, d, u = {}) {
509
- let { transparent: m = !1, transparentIndex: x = 0, delay: h = 0, palette: f = null, repeat: _ = 0, colorDepth: v = 8, dispose: g = -1 } = u, C = !1;
510
- if (e ? c || (C = !0, l(), c = !0) : C = !!u.first, o = Math.max(0, Math.floor(o)), d = Math.max(0, Math.floor(d)), C) {
511
- if (!f) throw new Error("First frame must include a { palette } option");
512
- ce(r, o, d, f, v), _t(r, f), _ >= 0 && ue(r, _);
500
+ }, writeHeader: l, writeFrame(p, n, d, u = {}) {
501
+ let { transparent: m = !1, transparentIndex: x = 0, delay: h = 0, palette: g = null, repeat: _ = 0, colorDepth: v = 8, dispose: f = -1 } = u, C = !1;
502
+ if (t ? c || (C = !0, l(), c = !0) : C = !!u.first, n = Math.max(0, Math.floor(n)), d = Math.max(0, Math.floor(d)), C) {
503
+ if (!g) throw new Error("First frame must include a { palette } option");
504
+ ut(r, n, d, g, v), _e(r, g), _ >= 0 && pt(r, _);
513
505
  }
514
- let S = Math.round(h / 10);
515
- de(r, g, S, m, x);
516
- let E = !!f && !C;
517
- pe(r, o, d, E ? f : null), E && _t(r, f), he(r, p, o, d, v, a, i, n);
506
+ let F = Math.round(h / 10);
507
+ ct(r, f, F, m, x);
508
+ let E = !!g && !C;
509
+ ht(r, n, d, E ? g : null), E && _e(r, g), mt(r, p, n, d, v, a, i, s);
518
510
  } };
519
511
  function l() {
520
- Rt(r, "GIF89a");
512
+ Re(r, "GIF89a");
521
513
  }
522
514
  }
523
- function de(s, t, e, r, a) {
524
- var i, n;
525
- s.writeByte(33), s.writeByte(249), s.writeByte(4), a < 0 && (a = 0, r = !1), r ? (i = 1, n = 2) : (i = 0, n = 0), t >= 0 && (n = 7 & t), n <<= 2, s.writeByte(0 | n | i), N(s, e), s.writeByte(a || 0), s.writeByte(0);
515
+ function ct(o, e, t, r, a) {
516
+ var i, s;
517
+ o.writeByte(33), o.writeByte(249), o.writeByte(4), a < 0 && (a = 0, r = !1), r ? (i = 1, s = 2) : (i = 0, s = 0), e >= 0 && (s = 7 & e), s <<= 2, o.writeByte(0 | s | i), N(o, t), o.writeByte(a || 0), o.writeByte(0);
526
518
  }
527
- function ce(s, t, e, r, a = 8) {
528
- let i = 128 | a - 1 << 4 | ht(r.length) - 1;
529
- N(s, t), N(s, e), s.writeBytes([i, 0, 0]);
519
+ function ut(o, e, t, r, a = 8) {
520
+ let i = 128 | a - 1 << 4 | he(r.length) - 1;
521
+ N(o, e), N(o, t), o.writeBytes([i, 0, 0]);
530
522
  }
531
- function ue(s, t) {
532
- s.writeByte(33), s.writeByte(255), s.writeByte(11), Rt(s, "NETSCAPE2.0"), s.writeByte(3), s.writeByte(1), N(s, t), s.writeByte(0);
523
+ function pt(o, e) {
524
+ o.writeByte(33), o.writeByte(255), o.writeByte(11), Re(o, "NETSCAPE2.0"), o.writeByte(3), o.writeByte(1), N(o, e), o.writeByte(0);
533
525
  }
534
- function _t(s, t) {
535
- let e = 1 << ht(t.length);
536
- for (let r = 0; r < e; r++) {
526
+ function _e(o, e) {
527
+ let t = 1 << he(e.length);
528
+ for (let r = 0; r < t; r++) {
537
529
  let a = [0, 0, 0];
538
- r < t.length && (a = t[r]), s.writeByte(a[0]), s.writeByte(a[1]), s.writeByte(a[2]);
530
+ r < e.length && (a = e[r]), o.writeByte(a[0]), o.writeByte(a[1]), o.writeByte(a[2]);
539
531
  }
540
532
  }
541
- function pe(s, t, e, r) {
542
- if (s.writeByte(44), N(s, 0), N(s, 0), N(s, t), N(s, e), r) {
543
- let a = 0, i = 0, n = ht(r.length) - 1;
544
- s.writeByte(128 | a | i | n);
545
- } else s.writeByte(0);
533
+ function ht(o, e, t, r) {
534
+ if (o.writeByte(44), N(o, 0), N(o, 0), N(o, e), N(o, t), r) {
535
+ let a = 0, i = 0, s = he(r.length) - 1;
536
+ o.writeByte(128 | a | i | s);
537
+ } else o.writeByte(0);
546
538
  }
547
- function he(s, t, e, r, a = 8, i, n, c) {
548
- ee(e, r, t, a, s, i, n, c);
539
+ function mt(o, e, t, r, a = 8, i, s, c) {
540
+ rt(t, r, e, a, o, i, s, c);
549
541
  }
550
- function N(s, t) {
551
- s.writeByte(255 & t), s.writeByte(t >> 8 & 255);
542
+ function N(o, e) {
543
+ o.writeByte(255 & e), o.writeByte(e >> 8 & 255);
552
544
  }
553
- function Rt(s, t) {
554
- for (var e = 0; e < t.length; e++) s.writeByte(t.charCodeAt(e));
545
+ function Re(o, e) {
546
+ for (var t = 0; t < e.length; t++) o.writeByte(e.charCodeAt(t));
555
547
  }
556
- function ht(s) {
557
- return Math.max(Math.ceil(Math.log2(s)), 1);
548
+ function he(o) {
549
+ return Math.max(Math.ceil(Math.log2(o)), 1);
558
550
  }
559
- Jt();
560
- class me {
551
+ Ke();
552
+ class ft {
561
553
  _recorder;
562
554
  _textmodifier;
563
555
  _registerPostDrawHook;
564
- constructor(t, e) {
565
- this._recorder = new jt(), this._textmodifier = t, this._registerPostDrawHook = e;
556
+ constructor(e, t) {
557
+ this._recorder = new Qe(), this._textmodifier = e, this._registerPostDrawHook = t;
566
558
  }
567
- async $saveGIF(t = {}) {
568
- const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t), a = t.onProgress;
559
+ async $saveGIF(e = {}) {
560
+ const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e), a = e.onProgress;
569
561
  try {
570
- const i = await this._recorder.$record(e, r, this._registerPostDrawHook, a), n = le(), { repeat: c } = t;
571
- i.forEach((o, d) => {
572
- const { width: u, height: m, imageData: x, delayMs: h } = o, f = new Uint32Array(x.data.buffer.slice(0)), _ = ae(f, 256, {}), v = oe(f, _);
573
- n.writeFrame(v, u, m, { palette: _, delay: h, repeat: d === 0 ? c : -1 });
574
- }), n.finish();
575
- const l = n.bytes(), p = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
562
+ const i = await this._recorder.$record(t, r, this._registerPostDrawHook, a), s = dt(), { repeat: c } = e;
563
+ for (let n = 0; n < i.length; n++) {
564
+ const d = i[n], { width: u, height: m, imageData: x, delayMs: h } = d, g = new Uint32Array(x.data.buffer), _ = it(g, 256, {}), v = nt(g, _);
565
+ s.writeFrame(v, u, m, { palette: _, delay: h, repeat: n === 0 ? c : -1 }), n % 2 != 0 && n !== i.length - 1 || (a?.({ state: "encoding", frameIndex: n + 1, totalFrames: i.length }), await new Promise((f) => setTimeout(f, 0)));
566
+ }
567
+ s.finish();
568
+ const l = s.bytes(), p = l.buffer.slice(l.byteOffset, l.byteOffset + l.byteLength);
576
569
  new Q().$downloadFile(new Blob([p], { type: "image/gif" }), r.filename), a?.({ state: "completed", totalFrames: r.frameCount });
577
570
  } catch (i) {
578
571
  throw a?.({ state: "error", message: i instanceof Error ? i.message : "GIF export failed" }), i;
579
572
  }
580
573
  }
581
- _applyDefaultOptions(t) {
582
- const e = Math.abs(Math.round(t.frameCount ?? 300)), r = Math.abs(t.frameRate ?? 60), a = Math.abs(t.scale ?? 1), i = Math.max(-1, Math.round(t.repeat ?? 0));
583
- return { filename: t.filename, frameCount: e, frameRate: r, scale: a, repeat: i };
574
+ _applyDefaultOptions(e) {
575
+ const t = Math.abs(Math.round(e.frameCount ?? 300)), r = Math.abs(e.frameRate ?? 60), a = Math.abs(e.scale ?? 1), i = Math.max(-1, Math.round(e.repeat ?? 0));
576
+ return { filename: e.filename, frameCount: t, frameRate: r, scale: a, repeat: i };
584
577
  }
585
578
  }
586
- function fe(s) {
587
- return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
579
+ function gt(o) {
580
+ return o && o.__esModule && Object.prototype.hasOwnProperty.call(o, "default") ? o.default : o;
588
581
  }
589
- var wt, Ct = { exports: {} };
590
- function ge() {
591
- return wt || (wt = 1, s = Ct, (function() {
592
- function t(l, p) {
593
- return (function(o) {
594
- if (typeof o != "string" || !o.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
595
- return window.atob(o.substring(23));
582
+ var we, Ce = { exports: {} };
583
+ function bt() {
584
+ return we || (we = 1, o = Ce, (function() {
585
+ function e(l, p) {
586
+ return (function(n) {
587
+ if (typeof n != "string" || !n.match(/^data:image\/webp;base64,/i)) throw new Error("Failed to decode WebP Base64 URL");
588
+ return window.atob(n.substring(23));
596
589
  })(typeof l == "string" && /^data:image\/webp/.test(l) ? l : l.toDataURL("image/webp", p));
597
590
  }
598
- function e(l) {
591
+ function t(l) {
599
592
  return (l.charCodeAt(0) | l.charCodeAt(1) << 8 | l.charCodeAt(2) << 16 | l.charCodeAt(3) << 24) >>> 0;
600
593
  }
601
594
  function r(l) {
602
595
  let p = l.indexOf("VP8", 12);
603
596
  if (p === -1) throw new Error("Bad image format, does this browser support WebP?");
604
- let o = !1;
597
+ let n = !1;
605
598
  for (; p < l.length - 8; ) {
606
599
  let d, u;
607
- switch (u = l.substring(p, p + 4), p += 4, d = e(l.substring(p, p + 4)), p += 4, u) {
600
+ switch (u = l.substring(p, p + 4), p += 4, d = t(l.substring(p, p + 4)), p += 4, u) {
608
601
  case "VP8 ":
609
- return { frame: l.substring(p, p + d), hasAlpha: o };
602
+ return { frame: l.substring(p, p + d), hasAlpha: n };
610
603
  case "ALPH":
611
- o = !0;
604
+ n = !0;
612
605
  }
613
606
  p += d, 1 & d && p++;
614
607
  }
@@ -620,32 +613,32 @@ function ge() {
620
613
  function i(l) {
621
614
  this.value = l;
622
615
  }
623
- function n(l, p, o) {
624
- if (Array.isArray(o)) for (let d = 0; d < o.length; d++) n(l, p, o[d]);
625
- else if (typeof o == "string") l.writeString(o);
626
- else if (o instanceof Uint8Array) l.writeBytes(o);
616
+ function s(l, p, n) {
617
+ if (Array.isArray(n)) for (let d = 0; d < n.length; d++) s(l, p, n[d]);
618
+ else if (typeof n == "string") l.writeString(n);
619
+ else if (n instanceof Uint8Array) l.writeBytes(n);
627
620
  else {
628
- if (!o.id) throw new Error("Bad EBML datatype " + typeof o.data);
629
- if (o.offset = l.pos + p, l.writeUnsignedIntBE(o.id), Array.isArray(o.data)) {
621
+ if (!n.id) throw new Error("Bad EBML datatype " + typeof n.data);
622
+ if (n.offset = l.pos + p, l.writeUnsignedIntBE(n.id), Array.isArray(n.data)) {
630
623
  let d, u, m;
631
- o.size === -1 ? l.writeByte(255) : o.size === -2 ? (d = l.pos, l.writeBytes([15, 255, 255, 255, 255])) : (d = l.pos, l.writeBytes([0, 0, 0, 0])), u = l.pos, o.dataOffset = u + p, n(l, p, o.data), o.size !== -1 && o.size !== -2 && (m = l.pos, o.size = m - u, l.seek(d), l.writeEBMLVarIntWidth(o.size, 4), l.seek(m));
632
- } else if (typeof o.data == "string") l.writeEBMLVarInt(o.data.length), o.dataOffset = l.pos + p, l.writeString(o.data);
633
- else if (typeof o.data == "number") o.size || (o.size = l.measureUnsignedInt(o.data)), l.writeEBMLVarInt(o.size), o.dataOffset = l.pos + p, l.writeUnsignedIntBE(o.data, o.size);
634
- else if (o.data instanceof i) l.writeEBMLVarInt(8), o.dataOffset = l.pos + p, l.writeDoubleBE(o.data.value);
635
- else if (o.data instanceof a) l.writeEBMLVarInt(4), o.dataOffset = l.pos + p, l.writeFloatBE(o.data.value);
624
+ n.size === -1 ? l.writeByte(255) : n.size === -2 ? (d = l.pos, l.writeBytes([15, 255, 255, 255, 255])) : (d = l.pos, l.writeBytes([0, 0, 0, 0])), u = l.pos, n.dataOffset = u + p, s(l, p, n.data), n.size !== -1 && n.size !== -2 && (m = l.pos, n.size = m - u, l.seek(d), l.writeEBMLVarIntWidth(n.size, 4), l.seek(m));
625
+ } else if (typeof n.data == "string") l.writeEBMLVarInt(n.data.length), n.dataOffset = l.pos + p, l.writeString(n.data);
626
+ else if (typeof n.data == "number") n.size || (n.size = l.measureUnsignedInt(n.data)), l.writeEBMLVarInt(n.size), n.dataOffset = l.pos + p, l.writeUnsignedIntBE(n.data, n.size);
627
+ else if (n.data instanceof i) l.writeEBMLVarInt(8), n.dataOffset = l.pos + p, l.writeDoubleBE(n.data.value);
628
+ else if (n.data instanceof a) l.writeEBMLVarInt(4), n.dataOffset = l.pos + p, l.writeFloatBE(n.data.value);
636
629
  else {
637
- if (!(o.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof o.data);
638
- l.writeEBMLVarInt(o.data.byteLength), o.dataOffset = l.pos + p, l.writeBytes(o.data);
630
+ if (!(n.data instanceof Uint8Array)) throw new Error("Bad EBML datatype " + typeof n.data);
631
+ l.writeEBMLVarInt(n.data.byteLength), n.dataOffset = l.pos + p, l.writeBytes(n.data);
639
632
  }
640
633
  }
641
634
  }
642
635
  let c = function(l, p) {
643
- return function(o) {
644
- let d, u, m = !1, x = 0, h = 0, f = null, _ = null, v = null, g = [], C = 0, S = 0, E = { quality: 0.95, transparent: !1, alphaQuality: void 0, fileWriter: null, fd: null, frameDuration: null, frameRate: null }, A = { Cues: { id: new Uint8Array([28, 83, 187, 107]), positionEBML: null }, SegmentInfo: { id: new Uint8Array([21, 73, 169, 102]), positionEBML: null }, Tracks: { id: new Uint8Array([22, 84, 174, 107]), positionEBML: null } }, L = { id: 17545, data: new i(0) }, V = [], B = new p(o.fileWriter || o.fd);
636
+ return function(n) {
637
+ let d, u, m = !1, x = 0, h = 0, g = null, _ = null, v = null, f = [], C = 0, F = 0, E = { quality: 0.95, transparent: !1, alphaQuality: void 0, fileWriter: null, fd: null, frameDuration: null, frameRate: null }, A = { Cues: { id: new Uint8Array([28, 83, 187, 107]), positionEBML: null }, SegmentInfo: { id: new Uint8Array([21, 73, 169, 102]), positionEBML: null }, Tracks: { id: new Uint8Array([22, 84, 174, 107]), positionEBML: null } }, L = { id: 17545, data: new i(0) }, V = [], B = new p(n.fileWriter || n.fd);
645
638
  function D(y) {
646
639
  return y - d.dataOffset;
647
640
  }
648
- function O() {
641
+ function T() {
649
642
  u = (function() {
650
643
  let M = { id: 21420, size: 5, data: 0 }, U = { id: 290298740, data: [] };
651
644
  for (let I in A) {
@@ -655,55 +648,55 @@ function ge() {
655
648
  return U;
656
649
  })();
657
650
  let y = { id: 357149030, data: [{ id: 2807729, data: 1e6 }, { id: 19840, data: "webm-writer-js" }, { id: 22337, data: "webm-writer-js" }, L] }, w = [{ id: 176, data: x }, { id: 186, data: h }];
658
- o.transparent && w.push({ id: 21440, data: 1 });
659
- let F = { id: 374648427, data: [{ id: 174, data: [{ id: 215, data: 1 }, { id: 29637, data: 1 }, { id: 156, data: 0 }, { id: 2274716, data: "und" }, { id: 134, data: "V_VP8" }, { id: 2459272, data: "VP8" }, { id: 131, data: 1 }, { id: 224, data: w }] }] };
660
- d = { id: 408125543, size: -2, data: [u, y, F] };
651
+ n.transparent && w.push({ id: 21440, data: 1 });
652
+ let S = { id: 374648427, data: [{ id: 174, data: [{ id: 215, data: 1 }, { id: 29637, data: 1 }, { id: 156, data: 0 }, { id: 2274716, data: "und" }, { id: 134, data: "V_VP8" }, { id: 2459272, data: "VP8" }, { id: 131, data: 1 }, { id: 224, data: w }] }] };
653
+ d = { id: 408125543, size: -2, data: [u, y, S] };
661
654
  let $ = new l(256);
662
- n($, B.pos, [{ id: 440786851, data: [{ id: 17030, data: 1 }, { id: 17143, data: 1 }, { id: 17138, data: 4 }, { id: 17139, data: 8 }, { id: 17026, data: "webm" }, { id: 17031, data: 2 }, { id: 17029, data: 2 }] }, d]), B.write($.getAsDataArray()), A.SegmentInfo.positionEBML.data = D(y.offset), A.Tracks.positionEBML.data = D(F.offset), m = !0;
655
+ s($, B.pos, [{ id: 440786851, data: [{ id: 17030, data: 1 }, { id: 17143, data: 1 }, { id: 17138, data: 4 }, { id: 17139, data: 8 }, { id: 17026, data: "webm" }, { id: 17031, data: 2 }, { id: 17029, data: 2 }] }, d]), B.write($.getAsDataArray()), A.SegmentInfo.positionEBML.data = D(y.offset), A.Tracks.positionEBML.data = D(S.offset), m = !0;
663
656
  }
664
657
  function k(y) {
665
658
  return y.alpha ? (function(w) {
666
- let F, $, M = new l(4);
659
+ let S, $, M = new l(4);
667
660
  if (!(w.trackNumber > 0 && w.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
668
- return M.writeEBMLVarInt(w.trackNumber), M.writeU16BE(w.timecode), M.writeByte(0), F = { id: 161, data: [M.getAsDataArray(), w.frame] }, $ = { id: 30113, data: [{ id: 166, data: [{ id: 238, data: 1 }, { id: 165, data: w.alpha }] }] }, { id: 160, data: [F, $] };
661
+ return M.writeEBMLVarInt(w.trackNumber), M.writeU16BE(w.timecode), M.writeByte(0), S = { id: 161, data: [M.getAsDataArray(), w.frame] }, $ = { id: 30113, data: [{ id: 166, data: [{ id: 238, data: 1 }, { id: 165, data: w.alpha }] }] }, { id: 160, data: [S, $] };
669
662
  })(y) : (function(w) {
670
- let F = new l(4);
663
+ let S = new l(4);
671
664
  if (!(w.trackNumber > 0 && w.trackNumber < 127)) throw new Error("TrackNumber must be > 0 and < 127");
672
- return F.writeEBMLVarInt(w.trackNumber), F.writeU16BE(w.timecode), F.writeByte(128), { id: 163, data: [F.getAsDataArray(), w.frame] };
665
+ return S.writeEBMLVarInt(w.trackNumber), S.writeU16BE(w.timecode), S.writeByte(128), { id: 163, data: [S.getAsDataArray(), w.frame] };
673
666
  })(y);
674
667
  }
675
668
  function R() {
676
- if (g.length === 0) return;
669
+ if (f.length === 0) return;
677
670
  let y = 0;
678
- for (let I = 0; I < g.length; I++) y += g[I].frame.length + (g[I].alpha ? g[I].alpha.length : 0);
679
- let w = new l(y + 64 * g.length), F = (function(I) {
671
+ for (let I = 0; I < f.length; I++) y += f[I].frame.length + (f[I].alpha ? f[I].alpha.length : 0);
672
+ let w = new l(y + 64 * f.length), S = (function(I) {
680
673
  return { id: 524531317, data: [{ id: 231, data: Math.round(I.timecode) }] };
681
674
  })({ timecode: Math.round(C) });
682
- for (let I = 0; I < g.length; I++) F.data.push(k(g[I]));
675
+ for (let I = 0; I < f.length; I++) S.data.push(k(f[I]));
683
676
  var $, M, U;
684
- n(w, B.pos, F), B.write(w.getAsDataArray()), $ = 1, M = Math.round(C), U = F.offset, V.push({ id: 187, data: [{ id: 179, data: M }, { id: 183, data: [{ id: 247, data: $ }, { id: 241, data: D(U) }] }] }), g = [], C += S, S = 0;
677
+ s(w, B.pos, S), B.write(w.getAsDataArray()), $ = 1, M = Math.round(C), U = S.offset, V.push({ id: 187, data: [{ id: 179, data: M }, { id: 183, data: [{ id: 247, data: $ }, { id: 241, data: D(U) }] }] }), f = [], C += F, F = 0;
685
678
  }
686
- this.addFrame = function(y, w, F) {
687
- m || (x = y.width || 0, h = y.height || 0, O());
688
- let $, M = r(t(y, o.quality)), U = null;
689
- $ = F || (typeof w == "number" ? w : o.frameDuration), o.transparent && (w instanceof HTMLCanvasElement || typeof w == "string" ? U = w : M.hasAlpha && (U = (function(I) {
690
- f !== null && f.width === I.width && f.height === I.height || (f = document.createElement("canvas"), f.width = I.width, f.height = I.height, _ = f.getContext("2d"), v = _.createImageData(f.width, f.height));
691
- let q = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, J = v.data, K = 0, zt = I.width * I.height * 4;
692
- for (let ot = 3; ot < zt; ot += 4) {
693
- let nt = q[ot];
694
- J[K++] = nt, J[K++] = nt, J[K++] = nt, J[K++] = 255;
679
+ this.addFrame = function(y, w, S) {
680
+ m || (x = y.width || 0, h = y.height || 0, T());
681
+ let $, M = r(e(y, n.quality)), U = null;
682
+ $ = S || (typeof w == "number" ? w : n.frameDuration), n.transparent && (w instanceof HTMLCanvasElement || typeof w == "string" ? U = w : M.hasAlpha && (U = (function(I) {
683
+ g !== null && g.width === I.width && g.height === I.height || (g = document.createElement("canvas"), g.width = I.width, g.height = I.height, _ = g.getContext("2d"), v = _.createImageData(g.width, g.height));
684
+ let q = I.getContext("2d").getImageData(0, 0, I.width, I.height).data, J = v.data, K = 0, We = I.width * I.height * 4;
685
+ for (let oe = 3; oe < We; oe += 4) {
686
+ let ne = q[oe];
687
+ J[K++] = ne, J[K++] = ne, J[K++] = ne, J[K++] = 255;
695
688
  }
696
- return _.putImageData(v, 0, 0), f;
689
+ return _.putImageData(v, 0, 0), g;
697
690
  })(y))), (function(I) {
698
- I.trackNumber = 1, I.timecode = Math.round(S), g.push(I), S += I.duration, S >= 5e3 && R();
699
- })({ frame: M.frame, duration: $, alpha: U ? r(t(U, o.alphaQuality)).frame : null });
691
+ I.trackNumber = 1, I.timecode = Math.round(F), f.push(I), F += I.duration, F >= 5e3 && R();
692
+ })({ frame: M.frame, duration: $, alpha: U ? r(e(U, n.alphaQuality)).frame : null });
700
693
  }, this.complete = function() {
701
- return m || O(), R(), (function() {
694
+ return m || T(), R(), (function() {
702
695
  let y = { id: 475249515, data: V }, w = new l(16 + 32 * V.length);
703
- n(w, B.pos, y), B.write(w.getAsDataArray()), A.Cues.positionEBML.data = D(y.offset);
696
+ s(w, B.pos, y), B.write(w.getAsDataArray()), A.Cues.positionEBML.data = D(y.offset);
704
697
  })(), (function() {
705
698
  let y = new l(u.size), w = B.pos;
706
- n(y, u.dataOffset, u.data), B.seek(u.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
699
+ s(y, u.dataOffset, u.data), B.seek(u.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
707
700
  })(), (function() {
708
701
  let y = new l(8), w = B.pos;
709
702
  y.writeDoubleBE(C), B.seek(L.dataOffset), B.write(y.getAsDataArray()), B.seek(w);
@@ -713,107 +706,107 @@ function ge() {
713
706
  })(), B.complete("video/webm");
714
707
  }, this.getWrittenSize = function() {
715
708
  return B.length;
716
- }, o = (function(y, w) {
717
- let F = {};
709
+ }, n = (function(y, w) {
710
+ let S = {};
718
711
  return [y, w].forEach(function($) {
719
- for (let M in $) Object.prototype.hasOwnProperty.call($, M) && (F[M] = $[M]);
720
- }), F;
721
- })(E, o || {}), (function() {
722
- if (!o.frameDuration) {
723
- if (!o.frameRate) throw new Error("Missing required frameDuration or frameRate setting");
724
- o.frameDuration = 1e3 / o.frameRate;
712
+ for (let M in $) Object.prototype.hasOwnProperty.call($, M) && (S[M] = $[M]);
713
+ }), S;
714
+ })(E, n || {}), (function() {
715
+ if (!n.frameDuration) {
716
+ if (!n.frameRate) throw new Error("Missing required frameDuration or frameRate setting");
717
+ n.frameDuration = 1e3 / n.frameRate;
725
718
  }
726
- o.quality = Math.max(Math.min(o.quality, 0.99999), 0), o.alphaQuality === void 0 ? o.alphaQuality = o.quality : o.alphaQuality = Math.max(Math.min(o.alphaQuality, 0.99999), 0);
719
+ n.quality = Math.max(Math.min(n.quality, 0.99999), 0), n.alphaQuality === void 0 ? n.alphaQuality = n.quality : n.alphaQuality = Math.max(Math.min(n.alphaQuality, 0.99999), 0);
727
720
  })();
728
721
  };
729
722
  };
730
- s.exports = c;
731
- })()), Ct.exports;
732
- var s;
733
- }
734
- var Et, kt = { exports: {} };
735
- function be() {
736
- return Et || (Et = 1, s = kt, (function() {
737
- let t = function(e) {
738
- this.data = new Uint8Array(e), this.pos = 0;
723
+ o.exports = c;
724
+ })()), Ce.exports;
725
+ var o;
726
+ }
727
+ var Ee, ke = { exports: {} };
728
+ function vt() {
729
+ return Ee || (Ee = 1, o = ke, (function() {
730
+ let e = function(t) {
731
+ this.data = new Uint8Array(t), this.pos = 0;
739
732
  };
740
- t.prototype.seek = function(e) {
741
- this.pos = e;
742
- }, t.prototype.writeBytes = function(e) {
743
- for (let r = 0; r < e.length; r++) this.data[this.pos++] = e[r];
744
- }, t.prototype.writeByte = function(e) {
745
- this.data[this.pos++] = e;
746
- }, t.prototype.writeU8 = t.prototype.writeByte, t.prototype.writeU16BE = function(e) {
747
- this.data[this.pos++] = e >> 8, this.data[this.pos++] = e;
748
- }, t.prototype.writeDoubleBE = function(e) {
749
- let r = new Uint8Array(new Float64Array([e]).buffer);
733
+ e.prototype.seek = function(t) {
734
+ this.pos = t;
735
+ }, e.prototype.writeBytes = function(t) {
736
+ for (let r = 0; r < t.length; r++) this.data[this.pos++] = t[r];
737
+ }, e.prototype.writeByte = function(t) {
738
+ this.data[this.pos++] = t;
739
+ }, e.prototype.writeU8 = e.prototype.writeByte, e.prototype.writeU16BE = function(t) {
740
+ this.data[this.pos++] = t >> 8, this.data[this.pos++] = t;
741
+ }, e.prototype.writeDoubleBE = function(t) {
742
+ let r = new Uint8Array(new Float64Array([t]).buffer);
750
743
  for (let a = r.length - 1; a >= 0; a--) this.writeByte(r[a]);
751
- }, t.prototype.writeFloatBE = function(e) {
752
- let r = new Uint8Array(new Float32Array([e]).buffer);
744
+ }, e.prototype.writeFloatBE = function(t) {
745
+ let r = new Uint8Array(new Float32Array([t]).buffer);
753
746
  for (let a = r.length - 1; a >= 0; a--) this.writeByte(r[a]);
754
- }, t.prototype.writeString = function(e) {
755
- for (let r = 0; r < e.length; r++) this.data[this.pos++] = e.charCodeAt(r);
756
- }, t.prototype.writeEBMLVarIntWidth = function(e, r) {
747
+ }, e.prototype.writeString = function(t) {
748
+ for (let r = 0; r < t.length; r++) this.data[this.pos++] = t.charCodeAt(r);
749
+ }, e.prototype.writeEBMLVarIntWidth = function(t, r) {
757
750
  switch (r) {
758
751
  case 1:
759
- this.writeU8(128 | e);
752
+ this.writeU8(128 | t);
760
753
  break;
761
754
  case 2:
762
- this.writeU8(64 | e >> 8), this.writeU8(e);
755
+ this.writeU8(64 | t >> 8), this.writeU8(t);
763
756
  break;
764
757
  case 3:
765
- this.writeU8(32 | e >> 16), this.writeU8(e >> 8), this.writeU8(e);
758
+ this.writeU8(32 | t >> 16), this.writeU8(t >> 8), this.writeU8(t);
766
759
  break;
767
760
  case 4:
768
- this.writeU8(16 | e >> 24), this.writeU8(e >> 16), this.writeU8(e >> 8), this.writeU8(e);
761
+ this.writeU8(16 | t >> 24), this.writeU8(t >> 16), this.writeU8(t >> 8), this.writeU8(t);
769
762
  break;
770
763
  case 5:
771
- this.writeU8(8 | e / 4294967296 & 7), this.writeU8(e >> 24), this.writeU8(e >> 16), this.writeU8(e >> 8), this.writeU8(e);
764
+ this.writeU8(8 | t / 4294967296 & 7), this.writeU8(t >> 24), this.writeU8(t >> 16), this.writeU8(t >> 8), this.writeU8(t);
772
765
  break;
773
766
  default:
774
767
  throw new Error("Bad EBML VINT size " + r);
775
768
  }
776
- }, t.prototype.measureEBMLVarInt = function(e) {
777
- if (e < 127) return 1;
778
- if (e < 16383) return 2;
779
- if (e < 2097151) return 3;
780
- if (e < 268435455) return 4;
781
- if (e < 34359738367) return 5;
782
- throw new Error("EBML VINT size not supported " + e);
783
- }, t.prototype.writeEBMLVarInt = function(e) {
784
- this.writeEBMLVarIntWidth(e, this.measureEBMLVarInt(e));
785
- }, t.prototype.writeUnsignedIntBE = function(e, r) {
786
- switch (r === void 0 && (r = this.measureUnsignedInt(e)), r) {
769
+ }, e.prototype.measureEBMLVarInt = function(t) {
770
+ if (t < 127) return 1;
771
+ if (t < 16383) return 2;
772
+ if (t < 2097151) return 3;
773
+ if (t < 268435455) return 4;
774
+ if (t < 34359738367) return 5;
775
+ throw new Error("EBML VINT size not supported " + t);
776
+ }, e.prototype.writeEBMLVarInt = function(t) {
777
+ this.writeEBMLVarIntWidth(t, this.measureEBMLVarInt(t));
778
+ }, e.prototype.writeUnsignedIntBE = function(t, r) {
779
+ switch (r === void 0 && (r = this.measureUnsignedInt(t)), r) {
787
780
  case 5:
788
- this.writeU8(Math.floor(e / 4294967296));
781
+ this.writeU8(Math.floor(t / 4294967296));
789
782
  case 4:
790
- this.writeU8(e >> 24);
783
+ this.writeU8(t >> 24);
791
784
  case 3:
792
- this.writeU8(e >> 16);
785
+ this.writeU8(t >> 16);
793
786
  case 2:
794
- this.writeU8(e >> 8);
787
+ this.writeU8(t >> 8);
795
788
  case 1:
796
- this.writeU8(e);
789
+ this.writeU8(t);
797
790
  break;
798
791
  default:
799
792
  throw new Error("Bad UINT size " + r);
800
793
  }
801
- }, t.prototype.measureUnsignedInt = function(e) {
802
- return e < 256 ? 1 : e < 65536 ? 2 : e < 1 << 24 ? 3 : e < 4294967296 ? 4 : 5;
803
- }, t.prototype.getAsDataArray = function() {
794
+ }, e.prototype.measureUnsignedInt = function(t) {
795
+ return t < 256 ? 1 : t < 65536 ? 2 : t < 1 << 24 ? 3 : t < 4294967296 ? 4 : 5;
796
+ }, e.prototype.getAsDataArray = function() {
804
797
  if (this.pos < this.data.byteLength) return this.data.subarray(0, this.pos);
805
798
  if (this.pos == this.data.byteLength) return this.data;
806
799
  throw new Error("ArrayBufferDataStream's pos lies beyond end of buffer");
807
- }, s.exports = t;
808
- })()), kt.exports;
809
- var s;
810
- }
811
- var Bt, It, St, Ft = { exports: {} };
812
- function ve() {
813
- return Bt || (Bt = 1, s = Ft, (function() {
814
- let t = function(e) {
800
+ }, o.exports = e;
801
+ })()), ke.exports;
802
+ var o;
803
+ }
804
+ var Be, Ie, Fe, Se = { exports: {} };
805
+ function xt() {
806
+ return Be || (Be = 1, o = Se, (function() {
807
+ let e = function(t) {
815
808
  return function(r) {
816
- let a = [], i = Promise.resolve(), n = null, c = null;
809
+ let a = [], i = Promise.resolve(), s = null, c = null;
817
810
  function l(d) {
818
811
  return new Promise(function(u, m) {
819
812
  let x = new FileReader();
@@ -831,45 +824,45 @@ function ve() {
831
824
  }));
832
825
  });
833
826
  }
834
- function o(d) {
827
+ function n(d) {
835
828
  let u = d.byteLength || d.length || d.size;
836
829
  if (!Number.isInteger(u)) throw new Error("Failed to determine size of element");
837
830
  return u;
838
831
  }
839
- r && r.constructor.name === "FileWriter" ? n = r : e && r && (c = r), this.pos = 0, this.length = 0, this.seek = function(d) {
832
+ r && r.constructor.name === "FileWriter" ? s = r : t && r && (c = r), this.pos = 0, this.length = 0, this.seek = function(d) {
840
833
  if (d < 0) throw new Error("Offset may not be negative");
841
834
  if (isNaN(d)) throw new Error("Offset may not be NaN");
842
835
  if (d > this.length) throw new Error("Seeking beyond the end of file is not allowed");
843
836
  this.pos = d;
844
837
  }, this.write = function(d) {
845
- let u = { offset: this.pos, data: d, length: o(d) }, m = u.offset >= this.length;
838
+ let u = { offset: this.pos, data: d, length: n(d) }, m = u.offset >= this.length;
846
839
  this.pos += u.length, this.length = Math.max(this.length, this.pos), i = i.then(function() {
847
840
  if (c) return new Promise(function(x, h) {
848
- p(u.data).then(function(f) {
849
- let _ = 0, v = Buffer.from(f.buffer), g = function(C, S, E) {
850
- _ += S, _ >= E.length ? x() : e.write(c, E, _, E.length - _, u.offset + _, g);
841
+ p(u.data).then(function(g) {
842
+ let _ = 0, v = Buffer.from(g.buffer), f = function(C, F, E) {
843
+ _ += F, _ >= E.length ? x() : t.write(c, E, _, E.length - _, u.offset + _, f);
851
844
  };
852
- e.write(c, v, 0, v.length, u.offset, g);
845
+ t.write(c, v, 0, v.length, u.offset, f);
853
846
  });
854
847
  });
855
- if (n) return new Promise(function(x, h) {
856
- n.onwriteend = x, n.seek(u.offset), n.write(new Blob([u.data]));
848
+ if (s) return new Promise(function(x, h) {
849
+ s.onwriteend = x, s.seek(u.offset), s.write(new Blob([u.data]));
857
850
  });
858
851
  if (!m) for (let x = 0; x < a.length; x++) {
859
852
  let h = a[x];
860
853
  if (!(u.offset + u.length <= h.offset || u.offset >= h.offset + h.length)) {
861
854
  if (u.offset < h.offset || u.offset + u.length > h.offset + h.length) throw new Error("Overwrite crosses blob boundaries");
862
- return u.offset == h.offset && u.length == h.length ? void (h.data = u.data) : p(h.data).then(function(f) {
863
- return h.data = f, p(u.data);
864
- }).then(function(f) {
865
- u.data = f, h.data.set(u.data, u.offset - h.offset);
855
+ return u.offset == h.offset && u.length == h.length ? void (h.data = u.data) : p(h.data).then(function(g) {
856
+ return h.data = g, p(u.data);
857
+ }).then(function(g) {
858
+ u.data = g, h.data.set(u.data, u.offset - h.offset);
866
859
  });
867
860
  }
868
861
  }
869
862
  a.push(u);
870
863
  });
871
864
  }, this.complete = function(d) {
872
- return i = c || n ? i.then(function() {
865
+ return i = c || s ? i.then(function() {
873
866
  return null;
874
867
  }) : i.then(function() {
875
868
  let u = [];
@@ -879,87 +872,87 @@ function ve() {
879
872
  };
880
873
  };
881
874
  };
882
- s.exports = t;
883
- })()), Ft.exports;
884
- var s;
885
- }
886
- function xe() {
887
- return St ? It : (St = 1, It = ge()(be(), ve()(null)));
888
- }
889
- var ye = xe();
890
- const _e = fe(ye);
891
- class we {
892
- async $record(t, e, r, a) {
893
- const i = Math.max(1, Math.round(e.frameRate)), n = Math.max(1, Math.round(e.frameCount)), c = new _e({ quality: e.quality, alphaQuality: e.transparent ? e.quality : void 0, transparent: e.transparent, frameRate: i }), l = this._createSnapshotSurface();
894
- return await new Promise((p, o) => {
875
+ o.exports = e;
876
+ })()), Se.exports;
877
+ var o;
878
+ }
879
+ function yt() {
880
+ return Fe ? Ie : (Fe = 1, Ie = bt()(vt(), xt()(null)));
881
+ }
882
+ var _t = yt();
883
+ const wt = gt(_t);
884
+ class Ct {
885
+ async $record(e, t, r, a) {
886
+ const i = Math.max(1, Math.round(t.frameRate)), s = Math.max(1, Math.round(t.frameCount)), c = new wt({ quality: t.quality, alphaQuality: t.transparent ? t.quality : void 0, transparent: t.transparent, frameRate: i }), l = this._createSnapshotSurface();
887
+ return await new Promise((p, n) => {
895
888
  let d, u = "capturing", m = !1, x = 0;
896
889
  const h = () => {
897
890
  d && (d(), d = void 0);
898
- }, f = () => {
899
- a?.({ state: "recording", frameIndex: x, totalFrames: n });
900
- }, _ = (g) => {
891
+ }, g = () => {
892
+ a?.({ state: "recording", frameIndex: x, totalFrames: s });
893
+ }, _ = (f) => {
901
894
  if (m) return;
902
895
  m = !0, h();
903
- const C = g instanceof Error ? g.message : "WEBM export failed";
904
- a?.({ state: "error", message: C }), o(g instanceof Error ? g : new Error(String(g)));
896
+ const C = f instanceof Error ? f.message : "WEBM export failed";
897
+ a?.({ state: "error", message: C }), n(f instanceof Error ? f : new Error(String(f)));
905
898
  }, v = () => {
906
- u !== "capturing" || m || (u = "encoding", h(), c.complete().then((g) => {
899
+ u !== "capturing" || m || (u = "encoding", h(), c.complete().then((f) => {
907
900
  ((C) => {
908
- m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(n, x), totalFrames: n }), p(C));
909
- })(g);
901
+ m || (m = !0, a?.({ state: "completed", frameIndex: Math.min(s, x), totalFrames: s }), p(C));
902
+ })(f);
910
903
  }).catch(_));
911
904
  };
912
905
  d = r(() => {
913
906
  (() => {
914
- if (u === "capturing") if (x >= n) v();
907
+ if (u === "capturing") if (x >= s) v();
915
908
  else try {
916
- const g = l(t);
917
- c.addFrame(g), x += 1, f(), x >= n && v();
918
- } catch (g) {
919
- _(g);
909
+ const f = l(e);
910
+ c.addFrame(f), x += 1, g(), x >= s && v();
911
+ } catch (f) {
912
+ _(f);
920
913
  }
921
914
  })();
922
- }), f();
915
+ }), g();
923
916
  });
924
917
  }
925
918
  _createSnapshotSurface() {
926
- let t = null, e = null;
919
+ let e = null, t = null;
927
920
  return (r) => {
928
- const a = Math.max(1, r.width), i = Math.max(1, r.height), n = ((c, l) => (t || (t = document.createElement("canvas")), t.width !== c || t.height !== l ? (t.width = c, t.height = l, e = t.getContext("2d"), e && (e.imageSmoothingEnabled = !1)) : e || (e = t.getContext("2d"), e && (e.imageSmoothingEnabled = !1)), e ? t : null))(a, i);
929
- return n && e ? (e.clearRect(0, 0, a, i), e.drawImage(r, 0, 0, a, i), n) : r;
921
+ const a = Math.max(1, r.width), i = Math.max(1, r.height), s = ((c, l) => (e || (e = document.createElement("canvas")), e.width !== c || e.height !== l ? (e.width = c, e.height = l, t = e.getContext("2d"), t && (t.imageSmoothingEnabled = !1)) : t || (t = e.getContext("2d"), t && (t.imageSmoothingEnabled = !1)), t ? e : null))(a, i);
922
+ return s && t ? (t.clearRect(0, 0, a, i), t.drawImage(r, 0, 0, a, i), s) : r;
930
923
  };
931
924
  }
932
925
  }
933
- class Ce {
926
+ class Et {
934
927
  _recorder;
935
928
  _textmodifier;
936
929
  _registerPostDrawHook;
937
- constructor(t, e) {
938
- this._recorder = new we(), this._textmodifier = t, this._registerPostDrawHook = e;
930
+ constructor(e, t) {
931
+ this._recorder = new Ct(), this._textmodifier = e, this._registerPostDrawHook = t;
939
932
  }
940
- async $saveWEBM(t = {}) {
941
- const e = this._textmodifier.canvas, r = this._applyDefaultOptions(t);
933
+ async $saveWEBM(e = {}) {
934
+ const t = this._textmodifier.canvas, r = this._applyDefaultOptions(e);
942
935
  try {
943
- const a = await this._recorder.$record(e, r, this._registerPostDrawHook, t.onProgress);
936
+ const a = await this._recorder.$record(t, r, this._registerPostDrawHook, e.onProgress);
944
937
  new Q().$downloadFile(a, r.filename);
945
938
  } catch (a) {
946
- throw t.onProgress?.({ state: "error", message: a instanceof Error ? a.message : "WEBM export failed" }), a;
939
+ throw e.onProgress?.({ state: "error", message: a instanceof Error ? a.message : "WEBM export failed" }), a;
947
940
  }
948
941
  }
949
- _applyDefaultOptions(t) {
950
- return { filename: t.filename, frameRate: Math.abs(Math.round(t.frameRate ?? 60)), frameCount: Math.abs(Math.round(t.frameCount ?? 300)), quality: Math.abs(Math.min(Math.max(t.quality ?? 1, 0), 1)), transparent: !!t.transparent, debugLogging: !!t.debugLogging };
942
+ _applyDefaultOptions(e) {
943
+ return { filename: e.filename, frameRate: Math.abs(Math.round(e.frameRate ?? 60)), frameCount: Math.abs(Math.round(e.frameCount ?? 300)), quality: Math.abs(Math.min(Math.max(e.quality ?? 1, 0), 1)), transparent: !!e.transparent, debugLogging: !!e.debugLogging };
951
944
  }
952
945
  }
953
946
  const b = { root: "textmode-export-overlay", stack: "textmode-export-overlay__stack", stackDense: "textmode-export-overlay__stack--dense", stackCompact: "textmode-export-overlay__stack--compact", section: "textmode-export-overlay__section", header: "textmode-export-overlay__header", headerTitleRow: "textmode-export-overlay__header-title-row", headerLinks: "textmode-export-overlay__header-links", row: "textmode-export-overlay__row", label: "textmode-export-overlay__label", field: "textmode-export-overlay__field", fieldCompact: "textmode-export-overlay__field--compact", fieldDense: "textmode-export-overlay__field--dense", fieldFull: "textmode-export-overlay__field--full", fieldChannel: "textmode-export-overlay__field--channel", input: "textmode-export-overlay__input", checkbox: "textmode-export-overlay__checkbox", muted: "textmode-export-overlay__muted", status: "textmode-export-overlay__status", statusGif: "textmode-export-overlay__status--gif", statusVideo: "textmode-export-overlay__status--video", statusTitle: "textmode-export-overlay__status-title", statusValue: "textmode-export-overlay__status-value", divider: "textmode-export-overlay__divider", title: "textmode-export-overlay__title", button: "textmode-export-overlay__button", buttonPrimary: "textmode-export-overlay__button--primary", buttonSecondary: "textmode-export-overlay__button--secondary", buttonFull: "textmode-export-overlay__button--full", supportLink: "textmode-export-overlay__support-link", supportIcon: "textmode-export-overlay__support-icon", linkIcon: "textmode-export-overlay__link-icon" };
954
- class T {
947
+ class O {
955
948
  element;
956
949
  mounted = !1;
957
950
  destroyed = !1;
958
- mount(t) {
951
+ mount(e) {
959
952
  if (this.destroyed) throw new Error("Cannot mount a destroyed component");
960
953
  if (this.mounted) return;
961
- const e = this.render();
962
- t.appendChild(e), this.element = e, this.onMount(), this.mounted = !0;
954
+ const t = this.render();
955
+ e.appendChild(t), this.element = t, this.onMount(), this.mounted = !0;
963
956
  }
964
957
  unmount() {
965
958
  this.mounted && this.element && (this._onUnmount(), this.element.remove(), this.element = void 0, this.mounted = !1);
@@ -967,8 +960,8 @@ class T {
967
960
  destroy() {
968
961
  this.destroyed || (this.unmount(), this._onDestroy(), this.destroyed = !0);
969
962
  }
970
- update(t) {
971
- this.mounted && this.onUpdate(t);
963
+ update(e) {
964
+ this.mounted && this.onUpdate(e);
972
965
  }
973
966
  onMount() {
974
967
  }
@@ -976,7 +969,7 @@ class T {
976
969
  }
977
970
  _onDestroy() {
978
971
  }
979
- onUpdate(t) {
972
+ onUpdate(e) {
980
973
  }
981
974
  get root() {
982
975
  if (!this.element) throw new Error("Component is not mounted yet");
@@ -986,92 +979,92 @@ class T {
986
979
  return this.mounted;
987
980
  }
988
981
  }
989
- class H extends T {
982
+ class H extends O {
990
983
  static _iconNamespace = "http://www.w3.org/2000/svg";
991
984
  render() {
992
- const t = document.createElement("div");
993
- t.classList.add(b.stack, b.stackDense, b.header);
994
985
  const e = document.createElement("div");
995
- e.classList.add(b.headerTitleRow);
986
+ e.classList.add(b.stack, b.stackDense, b.header);
987
+ const t = document.createElement("div");
988
+ t.classList.add(b.headerTitleRow);
996
989
  const r = document.createElement("strong");
997
990
  r.textContent = "textmode.export.js", r.classList.add(b.title);
998
991
  const a = document.createElement("div");
999
992
  a.classList.add(b.headerLinks);
1000
- const i = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]), n = this._createLink("https://code.textmode.art/support.html", "Support textmode.export.js", b.supportIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1" }, { d: "M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z" }, { d: "M16.746 16.726a3 3 0 1 0 .252 -5.555" }]);
1001
- a.appendChild(i), a.appendChild(n), e.appendChild(r), e.appendChild(a);
993
+ const i = this._createLink("https://github.com/humanbydefinition/textmode.export.js", "View repository on GitHub", b.linkIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M9 19c-4.3 1.4 -4.3 -2.5 -6 -3m12 5v-3.5c0 -1 .1 -1.4 -.5 -2c2.8 -.3 5.5 -1.4 5.5 -6a4.6 4.6 0 0 0 -1.3 -3.2a4.2 4.2 0 0 0 -.1 -3.2s-1.1 -.3 -3.5 1.3a12.3 12.3 0 0 0 -6.2 0c-2.4 -1.6 -3.5 -1.3 -3.5 -1.3a4.2 4.2 0 0 0 -.1 3.2a4.6 4.6 0 0 0 -1.3 3.2c0 4.6 2.7 5.7 5.5 6c-.6 .6 -.6 1.2 -.5 2v3.5" }]), s = this._createLink("https://code.textmode.art/support.html", "Support textmode.export.js", b.supportIcon, [{ d: "M0 0h24v24H0z", fill: "none", stroke: "none" }, { d: "M3 14c.83 .642 2.077 1.017 3.5 1c1.423 .017 2.67 -.358 3.5 -1c.83 -.642 2.077 -1.017 3.5 -1c1.423 -.017 2.67 .358 3.5 1" }, { d: "M8 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M12 3a2.4 2.4 0 0 0 -1 2a2.4 2.4 0 0 0 1 2" }, { d: "M3 10h14v5a6 6 0 0 1 -6 6h-2a6 6 0 0 1 -6 -6v-5z" }, { d: "M16.746 16.726a3 3 0 1 0 .252 -5.555" }]);
994
+ a.appendChild(i), a.appendChild(s), t.appendChild(r), t.appendChild(a);
1002
995
  const c = document.createElement("div");
1003
- return c.classList.add(b.divider), t.appendChild(e), t.appendChild(c), t;
996
+ return c.classList.add(b.divider), e.appendChild(t), e.appendChild(c), e;
1004
997
  }
1005
- _createLink(t, e, r, a) {
998
+ _createLink(e, t, r, a) {
1006
999
  const i = document.createElement("a");
1007
- return i.href = t, i.target = "_blank", i.rel = "noopener noreferrer", i.classList.add(b.supportLink), i.setAttribute("aria-label", e), i.appendChild(this._createIcon(r, a)), i;
1000
+ return i.href = e, i.target = "_blank", i.rel = "noopener noreferrer", i.classList.add(b.supportLink), i.setAttribute("aria-label", t), i.appendChild(this._createIcon(r, a)), i;
1008
1001
  }
1009
- _createIcon(t, e) {
1002
+ _createIcon(e, t) {
1010
1003
  const r = document.createElementNS(H._iconNamespace, "svg");
1011
- r.setAttribute("xmlns", H._iconNamespace), r.setAttribute("width", "18"), r.setAttribute("height", "18"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), r.classList.add(t);
1012
- for (const a of e) {
1004
+ r.setAttribute("xmlns", H._iconNamespace), r.setAttribute("width", "18"), r.setAttribute("height", "18"), r.setAttribute("viewBox", "0 0 24 24"), r.setAttribute("fill", "none"), r.setAttribute("stroke", "currentColor"), r.setAttribute("stroke-width", "2"), r.setAttribute("stroke-linecap", "round"), r.setAttribute("stroke-linejoin", "round"), r.classList.add(e);
1005
+ for (const a of t) {
1013
1006
  const i = document.createElementNS(H._iconNamespace, "path");
1014
- for (const [n, c] of Object.entries(a)) i.setAttribute(n, c);
1007
+ for (const [s, c] of Object.entries(a)) i.setAttribute(s, c);
1015
1008
  r.appendChild(i);
1016
1009
  }
1017
1010
  return r;
1018
1011
  }
1019
1012
  }
1020
- class P extends T {
1013
+ class P extends O {
1021
1014
  props;
1022
- constructor(t) {
1023
- super(), this.props = t;
1015
+ constructor(e) {
1016
+ super(), this.props = e;
1024
1017
  }
1025
1018
  render() {
1026
- const t = document.createElement("div");
1027
- t.classList.add(b.field), this.applyVariant(t, this.props.variant);
1028
- const e = document.createElement("label");
1029
- if (e.classList.add(b.label), e.textContent = this.props.label, this.props.labelFor && (e.htmlFor = this.props.labelFor), t.appendChild(e), this.props.description) {
1019
+ const e = document.createElement("div");
1020
+ e.classList.add(b.field), this.applyVariant(e, this.props.variant);
1021
+ const t = document.createElement("label");
1022
+ if (t.classList.add(b.label), t.textContent = this.props.label, this.props.labelFor && (t.htmlFor = this.props.labelFor), e.appendChild(t), this.props.description) {
1030
1023
  const r = document.createElement("span");
1031
- r.classList.add(b.muted), r.textContent = this.props.description, t.appendChild(r);
1024
+ r.classList.add(b.muted), r.textContent = this.props.description, e.appendChild(r);
1032
1025
  }
1033
- return t;
1026
+ return e;
1034
1027
  }
1035
- attachControl(t) {
1036
- this.root.appendChild(t);
1028
+ attachControl(e) {
1029
+ this.root.appendChild(e);
1037
1030
  }
1038
- update(t) {
1039
- this.props = t, super.update(t);
1031
+ update(e) {
1032
+ this.props = e, super.update(e);
1040
1033
  }
1041
- onUpdate(t) {
1042
- const e = this.root;
1043
- for (; e.firstChild; ) e.removeChild(e.firstChild);
1044
- this.props = t, e.classList.add(b.field), this.applyVariant(e, t.variant);
1034
+ onUpdate(e) {
1035
+ const t = this.root;
1036
+ for (; t.firstChild; ) t.removeChild(t.firstChild);
1037
+ this.props = e, t.classList.add(b.field), this.applyVariant(t, e.variant);
1045
1038
  const r = document.createElement("label");
1046
- if (r.classList.add(b.label), r.textContent = t.label, t.labelFor && (r.htmlFor = t.labelFor), e.appendChild(r), t.description) {
1039
+ if (r.classList.add(b.label), r.textContent = e.label, e.labelFor && (r.htmlFor = e.labelFor), t.appendChild(r), e.description) {
1047
1040
  const a = document.createElement("span");
1048
- a.classList.add(b.muted), a.textContent = t.description, e.appendChild(a);
1041
+ a.classList.add(b.muted), a.textContent = e.description, t.appendChild(a);
1049
1042
  }
1050
1043
  }
1051
- applyVariant(t, e) {
1052
- switch (t.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel), e) {
1044
+ applyVariant(e, t) {
1045
+ switch (e.classList.remove(b.fieldCompact, b.fieldDense, b.fieldFull, b.fieldChannel), t) {
1053
1046
  case "compact":
1054
- t.classList.add(b.fieldCompact);
1047
+ e.classList.add(b.fieldCompact);
1055
1048
  break;
1056
1049
  case "dense":
1057
- t.classList.add(b.fieldDense);
1050
+ e.classList.add(b.fieldDense);
1058
1051
  break;
1059
1052
  case "full":
1060
- t.classList.add(b.fieldFull);
1053
+ e.classList.add(b.fieldFull);
1061
1054
  break;
1062
1055
  case "channel":
1063
- t.classList.add(b.fieldChannel);
1056
+ e.classList.add(b.fieldChannel);
1064
1057
  }
1065
1058
  }
1066
1059
  }
1067
- class mt extends T {
1060
+ class me extends O {
1068
1061
  props;
1069
1062
  select;
1070
1063
  handleChange = () => {
1071
1064
  this.props.defaultValue = this.select.value;
1072
1065
  };
1073
- constructor(t) {
1074
- super(), this.props = t;
1066
+ constructor(e) {
1067
+ super(), this.props = e;
1075
1068
  }
1076
1069
  render() {
1077
1070
  return this.select = document.createElement("select"), this.select.classList.add(b.input), this.props.id && (this.select.id = this.props.id), this.populateOptions(), this.select.addEventListener("change", this.handleChange), this.select;
@@ -1082,34 +1075,34 @@ class mt extends T {
1082
1075
  get value() {
1083
1076
  return this.select.value;
1084
1077
  }
1085
- set value(t) {
1086
- this.select && (this.select.value = t), this.props.defaultValue = t;
1078
+ set value(e) {
1079
+ this.select && (this.select.value = e), this.props.defaultValue = e;
1087
1080
  }
1088
1081
  _onUnmount() {
1089
1082
  this.select.removeEventListener("change", this.handleChange);
1090
1083
  }
1091
- onUpdate(t) {
1092
- this.props = t, this.populateOptions(), t.defaultValue && (this.select.value = t.defaultValue);
1084
+ onUpdate(e) {
1085
+ this.props = e, this.populateOptions(), e.defaultValue && (this.select.value = e.defaultValue);
1093
1086
  }
1094
- update(t) {
1095
- this.props = { ...this.props, ...t }, this.select && (t.id && (this.select.id = t.id), t.options && this.populateOptions(), t.defaultValue !== void 0 && (this.select.value = t.defaultValue));
1087
+ update(e) {
1088
+ this.props = { ...this.props, ...e }, this.select && (e.id && (this.select.id = e.id), e.options && this.populateOptions(), e.defaultValue !== void 0 && (this.select.value = e.defaultValue));
1096
1089
  }
1097
1090
  populateOptions() {
1098
1091
  if (this.select) {
1099
1092
  this.select.innerHTML = "";
1100
- for (const t of this.props.options) {
1101
- const e = document.createElement("option");
1102
- e.value = t.value, e.textContent = t.label, this.select.appendChild(e);
1093
+ for (const e of this.props.options) {
1094
+ const t = document.createElement("option");
1095
+ t.value = e.value, t.textContent = e.label, this.select.appendChild(t);
1103
1096
  }
1104
1097
  this.props.defaultValue && (this.select.value = this.props.defaultValue);
1105
1098
  }
1106
1099
  }
1107
1100
  }
1108
- class Lt extends T {
1101
+ class Le extends O {
1109
1102
  props;
1110
1103
  button;
1111
- constructor(t) {
1112
- super(), this.props = t;
1104
+ constructor(e) {
1105
+ super(), this.props = e;
1113
1106
  }
1114
1107
  render() {
1115
1108
  return this.button = document.createElement("button"), this.button.type = "button", this.button.textContent = this.props.label, this.button.classList.add(b.button), this.props.variant === "secondary" ? this.button.classList.add(b.buttonSecondary) : this.button.classList.add(b.buttonPrimary), this.props.fullWidth && this.button.classList.add(b.buttonFull), this.button.disabled = !!this.props.disabled, this.button;
@@ -1117,87 +1110,87 @@ class Lt extends T {
1117
1110
  get buttonElement() {
1118
1111
  return this.button;
1119
1112
  }
1120
- setLabel(t) {
1121
- this.props.label = t, this.button.textContent = t;
1113
+ setLabel(e) {
1114
+ this.props.label = e, this.button.textContent = e;
1122
1115
  }
1123
- setDisabled(t) {
1124
- this.props.disabled = t, this.button.disabled = t;
1116
+ setDisabled(e) {
1117
+ this.props.disabled = e, this.button.disabled = e;
1125
1118
  }
1126
- onUpdate(t) {
1127
- this.props = t, this.button.textContent = t.label, this.button.disabled = !!t.disabled, t.variant === "secondary" ? (this.button.classList.add(b.buttonSecondary), this.button.classList.remove(b.buttonPrimary)) : (this.button.classList.add(b.buttonPrimary), this.button.classList.remove(b.buttonSecondary)), this.button.classList.toggle(b.buttonFull, !!t.fullWidth);
1119
+ onUpdate(e) {
1120
+ this.props = e, this.button.textContent = e.label, this.button.disabled = !!e.disabled, e.variant === "secondary" ? (this.button.classList.add(b.buttonSecondary), this.button.classList.remove(b.buttonPrimary)) : (this.button.classList.add(b.buttonPrimary), this.button.classList.remove(b.buttonSecondary)), this.button.classList.toggle(b.buttonFull, !!e.fullWidth);
1128
1121
  }
1129
1122
  }
1130
- class Ee {
1123
+ class kt {
1131
1124
  api;
1132
- constructor(t) {
1133
- this.api = t;
1125
+ constructor(e) {
1126
+ this.api = e;
1134
1127
  }
1135
- async $copy(t, e) {
1136
- switch (t) {
1128
+ async $copy(e, t) {
1129
+ switch (e) {
1137
1130
  case "txt": {
1138
- const r = this.api.toString(e);
1131
+ const r = this.api.toString(t);
1139
1132
  await navigator.clipboard.writeText(r);
1140
1133
  break;
1141
1134
  }
1142
1135
  case "svg": {
1143
- const r = this.api.toSVG(e);
1136
+ const r = this.api.toSVG(t);
1144
1137
  await navigator.clipboard.writeText(r);
1145
1138
  break;
1146
1139
  }
1147
1140
  case "image":
1148
- await this.api.copyCanvas(e);
1141
+ await this.api.copyCanvas(t);
1149
1142
  break;
1150
1143
  default:
1151
- throw new Error(`Clipboard not supported for ${t}`);
1144
+ throw new Error(`Clipboard not supported for ${e}`);
1152
1145
  }
1153
1146
  }
1154
1147
  }
1155
- class ke {
1148
+ class Bt {
1156
1149
  api;
1157
1150
  events;
1158
- constructor(t, e) {
1159
- this.api = t, this.events = e;
1151
+ constructor(e, t) {
1152
+ this.api = e, this.events = t;
1160
1153
  }
1161
- async $requestExport(t, e, r = {}) {
1162
- this.events.$emit("export:request", { format: t });
1154
+ async $requestExport(e, t, r = {}) {
1155
+ this.events.$emit("export:request", { format: e });
1163
1156
  try {
1164
1157
  const a = { onGIFProgress: r.onGIFProgress ? (i) => {
1165
- r.onGIFProgress?.(i), this.events.$emit("export:progress", { format: t, progress: i });
1166
- } : t === "gif" ? (i) => this.events.$emit("export:progress", { format: t, progress: i }) : void 0, onVideoProgress: r.onVideoProgress ? (i) => {
1167
- r.onVideoProgress?.(i), this.events.$emit("export:progress", { format: t, progress: i });
1168
- } : t === "video" ? (i) => this.events.$emit("export:progress", { format: t, progress: i }) : void 0 };
1169
- await this._execute(t, e, a), this.events.$emit("export:success", { format: t });
1158
+ r.onGIFProgress?.(i), this.events.$emit("export:progress", { format: e, progress: i });
1159
+ } : e === "gif" ? (i) => this.events.$emit("export:progress", { format: e, progress: i }) : void 0, onVideoProgress: r.onVideoProgress ? (i) => {
1160
+ r.onVideoProgress?.(i), this.events.$emit("export:progress", { format: e, progress: i });
1161
+ } : e === "video" ? (i) => this.events.$emit("export:progress", { format: e, progress: i }) : void 0 };
1162
+ await this._execute(e, t, a), this.events.$emit("export:success", { format: e });
1170
1163
  } catch (a) {
1171
- throw this.events.$emit("export:error", { format: t, error: a }), a;
1164
+ throw this.events.$emit("export:error", { format: e, error: a }), a;
1172
1165
  }
1173
1166
  }
1174
- _execute(t, e, r) {
1175
- switch (t) {
1167
+ _execute(e, t, r) {
1168
+ switch (e) {
1176
1169
  case "txt":
1177
- return Promise.resolve(this.api.saveStrings(e));
1170
+ return Promise.resolve(this.api.saveStrings(t));
1178
1171
  case "image":
1179
- return this.api.saveCanvas(e);
1172
+ return this.api.saveCanvas(t);
1180
1173
  case "svg":
1181
- return Promise.resolve(this.api.saveSVG(e));
1174
+ return Promise.resolve(this.api.saveSVG(t));
1182
1175
  case "gif": {
1183
- const a = { ...e, onProgress: r.onGIFProgress };
1176
+ const a = { ...t, onProgress: r.onGIFProgress };
1184
1177
  return this.api.saveGIF(a);
1185
1178
  }
1186
1179
  case "video": {
1187
- const a = { ...e, onProgress: r.onVideoProgress };
1180
+ const a = { ...t, onProgress: r.onVideoProgress };
1188
1181
  return this.api.saveWEBM(a);
1189
1182
  }
1190
1183
  }
1191
1184
  }
1192
1185
  }
1193
- class Be {
1186
+ class It {
1194
1187
  modifier;
1195
1188
  overlay;
1196
1189
  animationFrameId = null;
1197
1190
  handleUpdate;
1198
1191
  bound = !1;
1199
- constructor(t, e) {
1200
- this.modifier = t, this.overlay = e, this.handleUpdate = () => this.scheduleUpdate();
1192
+ constructor(e, t) {
1193
+ this.modifier = e, this.overlay = t, this.handleUpdate = () => this.scheduleUpdate();
1201
1194
  }
1202
1195
  scheduleUpdate() {
1203
1196
  this.animationFrameId !== null && cancelAnimationFrame(this.animationFrameId), this.animationFrameId = requestAnimationFrame(() => this.update());
@@ -1207,20 +1200,20 @@ class Be {
1207
1200
  }
1208
1201
  update() {
1209
1202
  this.animationFrameId = null;
1210
- const t = this.modifier.canvas.getBoundingClientRect();
1211
- this.overlay.style.top = `${t.top + window.scrollY + 8}px`, this.overlay.style.left = `${t.left + window.scrollX + 8}px`;
1203
+ const e = this.modifier.canvas.getBoundingClientRect();
1204
+ this.overlay.style.top = `${e.top + window.scrollY + 8}px`, this.overlay.style.left = `${e.left + window.scrollX + 8}px`;
1212
1205
  }
1213
1206
  dispose() {
1214
1207
  this.animationFrameId !== null && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = null), this.bound && (window.removeEventListener("resize", this.handleUpdate), window.removeEventListener("scroll", this.handleUpdate, !0), this.bound = !1);
1215
1208
  }
1216
1209
  }
1217
- const X = "textmode-export-number-input", Ie = `${X}__field`, Se = `${X}__controls`, Fe = `${X}__control`, Ut = `${X}__display`, et = `${Ut}--visible`, Le = (s) => {
1218
- s.dispatchEvent(new Event("input", { bubbles: !0 })), s.dispatchEvent(new Event("change", { bubbles: !0 }));
1219
- }, Mt = (s) => {
1220
- const t = document.createElement("button");
1221
- return t.type = "button", t.className = Fe, t.textContent = s > 0 ? "▲" : "▼", t;
1210
+ const X = "textmode-export-number-input", Ft = `${X}__field`, St = `${X}__controls`, Lt = `${X}__control`, Ue = `${X}__display`, te = `${Ue}--visible`, Mt = (o) => {
1211
+ o.dispatchEvent(new Event("input", { bubbles: !0 })), o.dispatchEvent(new Event("change", { bubbles: !0 }));
1212
+ }, Me = (o) => {
1213
+ const e = document.createElement("button");
1214
+ return e.type = "button", e.className = Lt, e.textContent = o > 0 ? "▲" : "▼", e;
1222
1215
  };
1223
- class G extends T {
1216
+ class G extends O {
1224
1217
  props;
1225
1218
  input;
1226
1219
  display;
@@ -1231,14 +1224,14 @@ class G extends T {
1231
1224
  holdIntervalId;
1232
1225
  activePointerId;
1233
1226
  disabledObserver;
1234
- constructor(t) {
1235
- super(), this.props = t;
1227
+ constructor(e) {
1228
+ super(), this.props = e;
1236
1229
  }
1237
1230
  render() {
1238
- const t = document.createElement("div");
1239
- t.className = X, this.input = document.createElement("input"), this.input.type = "number", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Ie, this.display = document.createElement("div"), this.display.className = Ut;
1240
1231
  const e = document.createElement("div");
1241
- return e.className = Se, this.incrementButton = Mt(1), this.decrementButton = Mt(-1), e.appendChild(this.incrementButton), e.appendChild(this.decrementButton), t.appendChild(this.input), t.appendChild(this.display), t.appendChild(e), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(t), this.updateDisplay(), t;
1232
+ e.className = X, this.input = document.createElement("input"), this.input.type = "number", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Ft, this.display = document.createElement("div"), this.display.className = Ue;
1233
+ const t = document.createElement("div");
1234
+ return t.className = St, this.incrementButton = Me(1), this.decrementButton = Me(-1), t.appendChild(this.incrementButton), t.appendChild(this.decrementButton), e.appendChild(this.input), e.appendChild(this.display), e.appendChild(t), this.bindStepControls(), this.bindHoldBehavior(), this.bindInputListeners(), this.observeDisabledState(e), this.updateDisplay(), e;
1242
1235
  }
1243
1236
  get inputElement() {
1244
1237
  return this.input;
@@ -1246,8 +1239,8 @@ class G extends T {
1246
1239
  get value() {
1247
1240
  return this.input.value;
1248
1241
  }
1249
- set value(t) {
1250
- this.input.value = t, this.updateDisplay();
1242
+ set value(e) {
1243
+ this.input.value = e, this.updateDisplay();
1251
1244
  }
1252
1245
  refresh() {
1253
1246
  this.updateDisplay();
@@ -1256,29 +1249,29 @@ class G extends T {
1256
1249
  this.clearHoldTimers(), this.disabledObserver?.disconnect();
1257
1250
  }
1258
1251
  bindStepControls() {
1259
- const t = (i) => () => {
1252
+ const e = (i) => () => {
1260
1253
  if (this.input.disabled) return;
1261
- const n = this.input.value, c = this.input.getAttribute("step");
1254
+ const s = this.input.value, c = this.input.getAttribute("step");
1262
1255
  if (c && c !== "any") i > 0 ? this.input.stepUp() : this.input.stepDown();
1263
1256
  else {
1264
- const l = i > 0 ? 1 : -1, p = Number.parseFloat(this.input.value || "0"), o = Number.isFinite(p) ? p + l : l;
1265
- this.input.value = String(o);
1257
+ const l = i > 0 ? 1 : -1, p = Number.parseFloat(this.input.value || "0"), n = Number.isFinite(p) ? p + l : l;
1258
+ this.input.value = String(n);
1266
1259
  }
1267
- this.input.value !== n && Le(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1268
- }, e = t(1), r = t(-1), a = (i, n) => (c) => {
1260
+ this.input.value !== s && Mt(this.input), this.updateDisplay(), this.input.focus({ preventScroll: !0 });
1261
+ }, t = e(1), r = e(-1), a = (i, s) => (c) => {
1269
1262
  if (this.suppressClickAfterPointer.get(i)) return this.suppressClickAfterPointer.set(i, !1), void c.preventDefault();
1270
- n();
1263
+ s();
1271
1264
  };
1272
- this.incrementButton.addEventListener("click", a(this.incrementButton, e)), this.decrementButton.addEventListener("click", a(this.decrementButton, r));
1265
+ this.incrementButton.addEventListener("click", a(this.incrementButton, t)), this.decrementButton.addEventListener("click", a(this.decrementButton, r));
1273
1266
  }
1274
1267
  bindHoldBehavior() {
1275
- const t = (e, r) => {
1268
+ const e = (t, r) => {
1276
1269
  const a = r > 0 ? () => this.incrementButton.click() : () => this.decrementButton.click();
1277
- e.addEventListener("pointerdown", (c) => {
1270
+ t.addEventListener("pointerdown", (c) => {
1278
1271
  if (c.button === 0) {
1279
- c.preventDefault(), this.suppressClickAfterPointer.set(e, !0), this.activePointerId = c.pointerId;
1272
+ c.preventDefault(), this.suppressClickAfterPointer.set(t, !0), this.activePointerId = c.pointerId;
1280
1273
  try {
1281
- e.setPointerCapture(c.pointerId);
1274
+ t.setPointerCapture(c.pointerId);
1282
1275
  } catch {
1283
1276
  }
1284
1277
  a(), this.holdTimeoutId = window.setTimeout(() => {
@@ -1289,175 +1282,185 @@ class G extends T {
1289
1282
  const i = () => {
1290
1283
  if (this.activePointerId !== void 0) {
1291
1284
  try {
1292
- e.releasePointerCapture(this.activePointerId);
1285
+ t.releasePointerCapture(this.activePointerId);
1293
1286
  } catch {
1294
1287
  }
1295
1288
  this.activePointerId = void 0;
1296
1289
  }
1297
- }, n = () => {
1290
+ }, s = () => {
1298
1291
  this.clearHoldTimers(), i();
1299
1292
  };
1300
- e.addEventListener("pointerup", n), e.addEventListener("pointerleave", n), e.addEventListener("pointercancel", n);
1293
+ t.addEventListener("pointerup", s), t.addEventListener("pointerleave", s), t.addEventListener("pointercancel", s);
1301
1294
  };
1302
- t(this.incrementButton, 1), t(this.decrementButton, -1);
1295
+ e(this.incrementButton, 1), e(this.decrementButton, -1);
1303
1296
  }
1304
1297
  bindInputListeners() {
1305
- const t = () => {
1298
+ const e = () => {
1306
1299
  this.props.defaultValue = this.input.value, this.updateDisplay();
1307
1300
  };
1308
- this.input.addEventListener("input", t), this.input.addEventListener("change", t);
1301
+ this.input.addEventListener("input", e), this.input.addEventListener("change", e);
1309
1302
  }
1310
- observeDisabledState(t) {
1311
- const e = () => {
1303
+ observeDisabledState(e) {
1304
+ const t = () => {
1312
1305
  const r = this.input.disabled;
1313
- this.incrementButton.disabled = r, this.decrementButton.disabled = r, t.classList.toggle("is-disabled", r), r ? (this.display.classList.remove(et), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor")) : this.updateDisplay();
1306
+ this.incrementButton.disabled = r, this.decrementButton.disabled = r, e.classList.toggle("is-disabled", r), r ? (this.display.classList.remove(te), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor")) : this.updateDisplay();
1314
1307
  };
1315
- typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(e), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), e();
1308
+ typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(t), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), t();
1316
1309
  }
1317
1310
  updateDisplay() {
1318
- const t = this.props.formatDisplay;
1319
- if (!t) return this.display.textContent = "", this.display.classList.remove(et), this.input.style.removeProperty("color"), void this.input.style.removeProperty("caretColor");
1320
- const e = this.input.value, r = Number.parseFloat(e), a = t(Number.isFinite(r) ? r : Number.NaN, e, this.input);
1321
- a ? (this.display.textContent = a, this.display.classList.add(et), this.input.style.color = "transparent", this.input.style.caretColor = "#f8fafc") : (this.display.textContent = "", this.display.classList.remove(et), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor"));
1311
+ const e = this.props.formatDisplay;
1312
+ if (!e) return this.display.textContent = "", this.display.classList.remove(te), this.input.style.removeProperty("color"), void this.input.style.removeProperty("caretColor");
1313
+ const t = this.input.value, r = Number.parseFloat(t), a = e(Number.isFinite(r) ? r : Number.NaN, t, this.input);
1314
+ a ? (this.display.textContent = a, this.display.classList.add(te), this.input.style.color = "transparent", this.input.style.caretColor = "#f8fafc") : (this.display.textContent = "", this.display.classList.remove(te), this.input.style.removeProperty("color"), this.input.style.removeProperty("caretColor"));
1322
1315
  }
1323
1316
  clearHoldTimers() {
1324
1317
  this.holdTimeoutId !== void 0 && (window.clearTimeout(this.holdTimeoutId), this.holdTimeoutId = void 0), this.holdIntervalId !== void 0 && (window.clearInterval(this.holdIntervalId), this.holdIntervalId = void 0);
1325
1318
  }
1326
1319
  }
1327
- class j extends T {
1320
+ class j extends O {
1328
1321
  variant;
1329
1322
  additionalClasses;
1330
- constructor(t = "stack", e = []) {
1331
- super(), this.variant = t, this.additionalClasses = e;
1323
+ constructor(e = "stack", t = []) {
1324
+ super(), this.variant = e, this.additionalClasses = t;
1332
1325
  }
1333
1326
  render() {
1334
- const t = document.createElement("div"), e = [this.variant === "stack" ? b.stack : void 0, this.variant === "stackDense" ? b.stackDense : void 0, this.variant === "stackCompact" ? b.stackCompact : void 0, this.variant === "row" ? b.row : void 0, this.variant === "section" ? b.section : void 0, ...this.additionalClasses].filter(Boolean);
1335
- return t.classList.add(...e), t;
1327
+ const e = document.createElement("div"), t = [this.variant === "stack" ? b.stack : void 0, this.variant === "stackDense" ? b.stackDense : void 0, this.variant === "stackCompact" ? b.stackCompact : void 0, this.variant === "row" ? b.row : void 0, this.variant === "section" ? b.section : void 0, ...this.additionalClasses].filter(Boolean);
1328
+ return e.classList.add(...t), e;
1336
1329
  }
1337
1330
  }
1338
- const $t = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1339
- class Nt extends T {
1331
+ const $e = { neutral: "textmode-export-overlay__status-value--neutral", active: "textmode-export-overlay__status-value--active", alert: "textmode-export-overlay__status-value--alert" };
1332
+ class Ne extends O {
1340
1333
  props;
1341
1334
  container;
1342
1335
  messageElement;
1343
- constructor(t) {
1344
- super(), this.props = t;
1336
+ constructor(e) {
1337
+ super(), this.props = e;
1345
1338
  }
1346
1339
  render() {
1347
1340
  this.container = document.createElement("div"), this.container.classList.add(b.status), this.props.context === "gif" ? this.container.classList.add(b.statusGif) : this.props.context === "video" && this.container.classList.add(b.statusVideo);
1348
- const t = document.createElement("span");
1349
- return t.classList.add(b.statusTitle), t.textContent = this.props.title, this.messageElement = document.createElement("span"), this.messageElement.classList.add(b.statusValue), this.messageElement.textContent = this.props.message, this.applyVariant(this.props.variant ?? "neutral"), this.container.appendChild(t), this.container.appendChild(this.messageElement), this.container;
1341
+ const e = document.createElement("span");
1342
+ return e.classList.add(b.statusTitle), e.textContent = this.props.title, this.messageElement = document.createElement("span"), this.messageElement.classList.add(b.statusValue), this.messageElement.textContent = this.props.message, this.applyVariant(this.props.variant ?? "neutral"), this.container.appendChild(e), this.container.appendChild(this.messageElement), this.container;
1350
1343
  }
1351
- setMessage(t, e = "neutral") {
1352
- this.messageElement.textContent = t, this.applyVariant(e);
1344
+ setMessage(e, t = "neutral") {
1345
+ this.messageElement.textContent = e, this.applyVariant(t);
1353
1346
  }
1354
- onUpdate(t) {
1355
- this.props = t, this.setMessage(t.message, t.variant ?? "neutral");
1347
+ onUpdate(e) {
1348
+ this.props = e, this.setMessage(e.message, e.variant ?? "neutral");
1356
1349
  }
1357
- applyVariant(t) {
1358
- this.messageElement.classList.remove(...Object.values($t)), this.messageElement.classList.add($t[t]);
1350
+ applyVariant(e) {
1351
+ this.messageElement.classList.remove(...Object.values($e)), this.messageElement.classList.add($e[e]);
1359
1352
  }
1360
1353
  }
1361
- class Y extends T {
1354
+ class Y extends O {
1362
1355
  _config;
1363
1356
  _managedComponents = /* @__PURE__ */ new Set();
1364
- constructor(t) {
1365
- super(), this._config = t;
1357
+ constructor(e) {
1358
+ super(), this._config = e;
1366
1359
  }
1367
- _manageComponent(t) {
1368
- return this._managedComponents.add(t), t;
1360
+ _manageComponent(e) {
1361
+ return this._managedComponents.add(e), e;
1369
1362
  }
1370
1363
  _onUnmount() {
1371
- for (const t of this._managedComponents) t.unmount();
1364
+ for (const e of this._managedComponents) e.unmount();
1372
1365
  }
1373
1366
  _onDestroy() {
1374
- for (const t of this._managedComponents) t.destroy();
1367
+ for (const e of this._managedComponents) e.destroy();
1375
1368
  this._managedComponents.clear();
1376
1369
  }
1377
1370
  }
1378
1371
  const z = { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 };
1379
- class ut extends Y {
1372
+ class ue extends Y {
1380
1373
  frameCountInput = this._manageComponent(new G({ defaultValue: String(z.frameCount), attributes: { min: "1", max: "600", step: "1" } }));
1381
1374
  frameRateInput = this._manageComponent(new G({ defaultValue: String(z.frameRate), attributes: { min: "1", max: "60", step: "1" } }));
1382
1375
  scaleInput = this._manageComponent(new G({ defaultValue: String(z.scale), attributes: { min: "0.1", max: "8", step: "0.1" } }));
1383
- repeatInput = this._manageComponent(new G({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (t, e) => Number.isFinite(t) ? t === 0 ? "∞" : null : e.trim() === "" ? null : e }));
1384
- status = this._manageComponent(new Nt({ title: "status", message: "ready to record", variant: "neutral", context: "gif" }));
1376
+ repeatInput = this._manageComponent(new G({ defaultValue: "0", attributes: { min: "0", max: "50", step: "1" }, formatDisplay: (e, t) => Number.isFinite(e) ? e === 0 ? "∞" : null : t.trim() === "" ? null : t }));
1377
+ status = this._manageComponent(new Ne({ title: "status", message: "ready to record", variant: "neutral", context: "gif" }));
1385
1378
  recordingState = "idle";
1386
- constructor(t) {
1387
- super(t);
1379
+ constructor(e) {
1380
+ super(e);
1388
1381
  }
1389
1382
  render() {
1390
- const t = document.createElement("div");
1391
- t.classList.add(b.stack);
1392
- const e = new j("row");
1393
- e.mount(t);
1383
+ const e = document.createElement("div");
1384
+ e.classList.add(b.stack);
1385
+ const t = new j("row");
1386
+ t.mount(e);
1394
1387
  const r = new P({ label: "number of frames", labelFor: "textmode-export-gif-frame-count", variant: "dense" });
1395
- r.mount(e.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-gif-frame-count";
1388
+ r.mount(t.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-gif-frame-count";
1396
1389
  const a = new P({ label: "frame rate (fps)", labelFor: "textmode-export-gif-frame-rate", variant: "dense" });
1397
- a.mount(e.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
1390
+ a.mount(t.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-gif-frame-rate";
1398
1391
  const i = new j("row");
1399
- i.mount(t);
1400
- const n = new P({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
1401
- n.mount(i.root), this.scaleInput.mount(n.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
1392
+ i.mount(e);
1393
+ const s = new P({ label: "scale", labelFor: "textmode-export-gif-scale", variant: "dense" });
1394
+ s.mount(i.root), this.scaleInput.mount(s.root), this.scaleInput.inputElement.id = "textmode-export-gif-scale";
1402
1395
  const c = new P({ label: "loop count", labelFor: "textmode-export-gif-repeat", variant: "dense" });
1403
- return c.mount(i.root), this.repeatInput.mount(c.root), this.repeatInput.inputElement.id = "textmode-export-gif-repeat", this.status.mount(t), t;
1396
+ return c.mount(i.root), this.repeatInput.mount(c.root), this.repeatInput.inputElement.id = "textmode-export-gif-repeat", this.status.mount(e), e;
1404
1397
  }
1405
1398
  getOptions() {
1406
- const t = this._config.defaultOptions ?? {};
1407
- return { frameCount: this.safeParseInt(this.frameCountInput.value, t.frameCount ?? 300), frameRate: this.safeParseInt(this.frameRateInput.value, t.frameRate ?? 60), scale: this.safeParseFloat(this.scaleInput.value, t.scale ?? 1), repeat: this.safeParseInt(this.repeatInput.value, t.repeat ?? 0) };
1399
+ const e = this._config.defaultOptions ?? {};
1400
+ return { frameCount: this.safeParseInt(this.frameCountInput.value, e.frameCount ?? 300), frameRate: this.safeParseInt(this.frameRateInput.value, e.frameRate ?? 60), scale: this.safeParseFloat(this.scaleInput.value, e.scale ?? 1), repeat: this.safeParseInt(this.repeatInput.value, e.repeat ?? 0) };
1408
1401
  }
1409
1402
  reset() {
1410
1403
  this.recordingState = "idle", this.applyDefaults(), this.setRecordingState("idle");
1411
1404
  }
1412
1405
  validate() {
1413
- const t = Number.parseInt(this.frameCountInput.value, 10), e = Number.parseInt(this.frameRateInput.value, 10), r = Number.parseFloat(this.scaleInput.value);
1414
- return Number.isFinite(t) && t > 0 && Number.isFinite(e) && e > 0 && Number.isFinite(r) && r > 0;
1406
+ const e = Number.parseInt(this.frameCountInput.value, 10), t = Number.parseInt(this.frameRateInput.value, 10), r = Number.parseFloat(this.scaleInput.value);
1407
+ return Number.isFinite(e) && e > 0 && Number.isFinite(t) && t > 0 && Number.isFinite(r) && r > 0;
1415
1408
  }
1416
1409
  isRecording() {
1417
- return this.recordingState === "recording";
1410
+ return this.recordingState === "recording" || this.recordingState === "encoding";
1418
1411
  }
1419
- setRecordingState(t, e) {
1420
- this.recordingState = t;
1421
- const r = t === "recording";
1422
- switch (this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.scaleInput.inputElement.disabled = r, this.repeatInput.inputElement.disabled = r, t) {
1412
+ setRecordingState(e, t) {
1413
+ this.recordingState = e;
1414
+ const r = e === "recording" || e === "encoding";
1415
+ switch (this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.scaleInput.inputElement.disabled = r, this.repeatInput.inputElement.disabled = r, e) {
1423
1416
  case "recording":
1424
- if (e?.totalFrames) {
1425
- const a = e.frameIndex ?? 0;
1426
- this.status.setMessage(`recording ${a}/${e.totalFrames}`, "active");
1417
+ if (t?.totalFrames) {
1418
+ const a = t.frameIndex ?? 0;
1419
+ this.status.setMessage(`recording ${a}/${t.totalFrames}`, "active");
1427
1420
  } else this.status.setMessage("recording…", "active");
1428
1421
  break;
1422
+ case "encoding":
1423
+ if (t?.totalFrames) {
1424
+ const a = t.frameIndex ?? 0;
1425
+ this.status.setMessage(`encoding ${a}/${t.totalFrames}`, "active");
1426
+ } else this.status.setMessage("encoding…", "active");
1427
+ break;
1429
1428
  case "completed":
1430
1429
  this.status.setMessage("GIF saved successfully", "active");
1431
1430
  break;
1432
1431
  case "error":
1433
- this.status.setMessage(e?.message ?? "failed to export GIF", "alert");
1432
+ this.status.setMessage(t?.message ?? "failed to export GIF", "alert");
1434
1433
  break;
1435
1434
  default:
1436
1435
  this.status.setMessage("ready to record", "neutral");
1437
1436
  }
1438
1437
  }
1439
- handleProgress(t) {
1440
- t.state === "recording" && t.totalFrames ? this.status.setMessage(`recording ${t.frameIndex ?? 0}/${t.totalFrames}`, "active") : t.state === "completed" ? this.status.setMessage("GIF saved successfully", "active") : t.state === "error" && this.status.setMessage(t.message ?? "failed to export GIF", "alert");
1438
+ handleProgress(e) {
1439
+ if (e.state !== "recording" && e.state !== "encoding" || !e.totalFrames) e.state === "completed" ? this.status.setMessage("GIF saved successfully", "active") : e.state === "error" && this.status.setMessage(e.message ?? "failed to export GIF", "alert");
1440
+ else {
1441
+ const t = e.state === "recording" ? "recording" : "encoding";
1442
+ this.status.setMessage(`${t} ${e.frameIndex ?? 0}/${e.totalFrames}`, "active");
1443
+ }
1441
1444
  }
1442
1445
  applyDefaults() {
1443
- const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? z.frameCount, r = t.frameRate ?? z.frameRate, a = t.scale ?? z.scale, i = t.repeat ?? z.repeat;
1444
- this.frameCountInput.value = String(e), this.frameRateInput.value = String(r), this.scaleInput.value = String(a), this.repeatInput.value = String(i), this.frameCountInput.refresh(), this.frameRateInput.refresh(), this.scaleInput.refresh(), this.repeatInput.refresh();
1446
+ const e = this._config.defaultOptions ?? {}, t = e.frameCount ?? z.frameCount, r = e.frameRate ?? z.frameRate, a = e.scale ?? z.scale, i = e.repeat ?? z.repeat;
1447
+ this.frameCountInput.value = String(t), this.frameRateInput.value = String(r), this.scaleInput.value = String(a), this.repeatInput.value = String(i), this.frameCountInput.refresh(), this.frameRateInput.refresh(), this.scaleInput.refresh(), this.repeatInput.refresh();
1445
1448
  }
1446
- safeParseInt(t, e) {
1447
- const r = Number.parseInt(t, 10);
1448
- return Number.isFinite(r) ? r : e;
1449
+ safeParseInt(e, t) {
1450
+ const r = Number.parseInt(e, 10);
1451
+ return Number.isFinite(r) ? r : t;
1449
1452
  }
1450
- safeParseFloat(t, e) {
1451
- const r = Number.parseFloat(t);
1452
- return Number.isFinite(r) ? r : e;
1453
+ safeParseFloat(e, t) {
1454
+ const r = Number.parseFloat(e);
1455
+ return Number.isFinite(r) ? r : t;
1453
1456
  }
1454
1457
  }
1455
- const it = "textmode-export-range-input", Me = `${it}__field`, $e = `${it}__tooltip`, ct = `${it}__tooltip--visible`, rt = (s, t) => {
1456
- if (typeof s != "string" || s.length === 0) return t;
1457
- const e = Number.parseFloat(s);
1458
- return Number.isFinite(e) ? e : t;
1459
- }, Ae = (s, t, e) => Math.min(e, Math.max(t, s));
1460
- class Pe extends T {
1458
+ const ie = "textmode-export-range-input", $t = `${ie}__field`, At = `${ie}__tooltip`, ce = `${ie}__tooltip--visible`, re = (o, e) => {
1459
+ if (typeof o != "string" || o.length === 0) return e;
1460
+ const t = Number.parseFloat(o);
1461
+ return Number.isFinite(t) ? t : e;
1462
+ }, Pt = (o, e, t) => Math.min(t, Math.max(e, o));
1463
+ class Dt extends O {
1461
1464
  props;
1462
1465
  input;
1463
1466
  tooltip;
@@ -1468,12 +1471,12 @@ class Pe extends T {
1468
1471
  activePointerId;
1469
1472
  disabledObserver;
1470
1473
  resizeObserver;
1471
- constructor(t) {
1472
- super(), this.props = t;
1474
+ constructor(e) {
1475
+ super(), this.props = e;
1473
1476
  }
1474
1477
  render() {
1475
- const t = document.createElement("div");
1476
- return t.className = it, this.input = document.createElement("input"), this.input.type = "range", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = Me, this.tooltip = document.createElement("div"), this.tooltip.className = $e, t.appendChild(this.input), t.appendChild(this.tooltip), this.bindEvents(t), this.updateTooltip(), this.syncDisabledState(t), t;
1478
+ const e = document.createElement("div");
1479
+ return e.className = ie, this.input = document.createElement("input"), this.input.type = "range", this.input.value = this.props.defaultValue, Object.assign(this.input, this.props.attributes), this.input.className = $t, this.tooltip = document.createElement("div"), this.tooltip.className = At, e.appendChild(this.input), e.appendChild(this.tooltip), this.bindEvents(e), this.updateTooltip(), this.syncDisabledState(e), e;
1477
1480
  }
1478
1481
  get inputElement() {
1479
1482
  return this.input;
@@ -1481,13 +1484,13 @@ class Pe extends T {
1481
1484
  get value() {
1482
1485
  return this.input.value;
1483
1486
  }
1484
- set value(t) {
1485
- this.input.value = t, this.updateTooltip();
1487
+ set value(e) {
1488
+ this.input.value = e, this.updateTooltip();
1486
1489
  }
1487
1490
  _onDestroy() {
1488
1491
  this.disabledObserver?.disconnect(), this.resizeObserver?.disconnect();
1489
1492
  }
1490
- bindEvents(t) {
1493
+ bindEvents(e) {
1491
1494
  this.input.addEventListener("pointerenter", () => {
1492
1495
  this.hoverActive = !0, this.refreshTooltipVisibility();
1493
1496
  }), this.input.addEventListener("pointerleave", () => {
@@ -1510,27 +1513,27 @@ class Pe extends T {
1510
1513
  this.activePointerId = void 0;
1511
1514
  }
1512
1515
  });
1513
- const e = () => {
1516
+ const t = () => {
1514
1517
  this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.hoverActive = this.input.matches(":hover"), this.releasePointerCapture(), this.refreshTooltipVisibility();
1515
1518
  };
1516
- this.input.addEventListener("pointerup", e), this.input.addEventListener("pointercancel", e), this.input.addEventListener("lostpointercapture", e), this.input.addEventListener("input", () => {
1519
+ this.input.addEventListener("pointerup", t), this.input.addEventListener("pointercancel", t), this.input.addEventListener("lostpointercapture", t), this.input.addEventListener("input", () => {
1517
1520
  (this.hoverActive || this.focusActive || this.pointerActive) && this.updateTooltip(), this.props.defaultValue = this.input.value;
1518
1521
  }), this.input.addEventListener("change", () => {
1519
1522
  this.pointerActive || this.updateTooltip(), this.props.defaultValue = this.input.value;
1520
1523
  }), typeof ResizeObserver < "u" && (this.resizeObserver = new ResizeObserver(() => {
1521
- this.tooltip.classList.contains(ct) && this.updateTooltipPosition();
1522
- }), this.resizeObserver.observe(t));
1524
+ this.tooltip.classList.contains(ce) && this.updateTooltipPosition();
1525
+ }), this.resizeObserver.observe(e));
1523
1526
  }
1524
1527
  refreshTooltipVisibility() {
1525
- const t = (this.hoverActive || this.focusActive || this.pointerActive) && !this.input.disabled;
1526
- t && this.updateTooltip(), this.tooltip.classList.toggle(ct, t);
1528
+ const e = (this.hoverActive || this.focusActive || this.pointerActive) && !this.input.disabled;
1529
+ e && this.updateTooltip(), this.tooltip.classList.toggle(ce, e);
1527
1530
  }
1528
- syncDisabledState(t) {
1529
- const e = () => {
1531
+ syncDisabledState(e) {
1532
+ const t = () => {
1530
1533
  const r = this.input.disabled;
1531
- t.classList.toggle("is-disabled", r), r && (this.hoverActive = !1, this.focusActive = !1, this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.releasePointerCapture(), this.tooltip.classList.remove(ct));
1534
+ e.classList.toggle("is-disabled", r), r && (this.hoverActive = !1, this.focusActive = !1, this.pointerActive = !1, this.suppressFocusFromPointer = !1, this.releasePointerCapture(), this.tooltip.classList.remove(ce));
1532
1535
  };
1533
- typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(e), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), e();
1536
+ typeof MutationObserver < "u" && (this.disabledObserver = new MutationObserver(t), this.disabledObserver.observe(this.input, { attributes: !0, attributeFilter: ["disabled"] })), t();
1534
1537
  }
1535
1538
  releasePointerCapture() {
1536
1539
  if (this.activePointerId !== void 0) {
@@ -1545,78 +1548,78 @@ class Pe extends T {
1545
1548
  this.updateTooltipContent(), this.updateTooltipPosition();
1546
1549
  }
1547
1550
  updateTooltipContent() {
1548
- const t = this.props.formatValue ?? ((r) => `${r}`), e = this.getCurrentValue();
1549
- this.tooltip.textContent = t(e, this.input);
1551
+ const e = this.props.formatValue ?? ((r) => `${r}`), t = this.getCurrentValue();
1552
+ this.tooltip.textContent = e(t, this.input);
1550
1553
  }
1551
1554
  updateTooltipPosition() {
1552
- const t = this.getMin(), e = this.getMax(), r = Ae(this.getCurrentValue(), t, e), a = e - t, i = a === 0 ? 0 : (r - t) / a;
1555
+ const e = this.getMin(), t = this.getMax(), r = Pt(this.getCurrentValue(), e, t), a = t - e, i = a === 0 ? 0 : (r - e) / a;
1553
1556
  this.tooltip.style.left = 100 * i + "%";
1554
1557
  }
1555
1558
  getMin() {
1556
- return rt(this.input.min, 0);
1559
+ return re(this.input.min, 0);
1557
1560
  }
1558
1561
  getMax() {
1559
- return rt(this.input.max, 100);
1562
+ return re(this.input.max, 100);
1560
1563
  }
1561
1564
  getCurrentValue() {
1562
- return rt(this.input.value, rt(this.props.defaultValue, 0));
1565
+ return re(this.input.value, re(this.props.defaultValue, 0));
1563
1566
  }
1564
1567
  }
1565
- function De(s) {
1566
- if (!Number.isFinite(s)) return "default quality";
1567
- const t = Math.max(0, Math.min(1, s));
1568
- return t >= 0.995 ? "near-lossless" : t >= 0.98 ? "maximum detail" : t >= 0.88 ? "ultra quality" : t >= 0.7 ? "high quality" : t >= 0.5 ? "balanced" : t >= 0.25 ? "compact" : t >= 0.1 ? "lightweight" : "draft";
1568
+ function Vt(o) {
1569
+ if (!Number.isFinite(o)) return "default quality";
1570
+ const e = Math.max(0, Math.min(1, o));
1571
+ return e >= 0.995 ? "near-lossless" : e >= 0.98 ? "maximum detail" : e >= 0.88 ? "ultra quality" : e >= 0.7 ? "high quality" : e >= 0.5 ? "balanced" : e >= 0.25 ? "compact" : e >= 0.1 ? "lightweight" : "draft";
1569
1572
  }
1570
- function Ve(s) {
1571
- return `${De(s)} (quality ≈ ${s.toFixed(3)})`;
1573
+ function Ot(o) {
1574
+ return `${Vt(o)} (quality ≈ ${o.toFixed(3)})`;
1572
1575
  }
1573
- class pt extends Y {
1574
- frameRateInput = this._manageComponent(new G({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (t) => Number.isFinite(t) ? `${t} fps` : null }));
1576
+ class pe extends Y {
1577
+ frameRateInput = this._manageComponent(new G({ defaultValue: String(60), attributes: { min: String(1), max: String(60), step: "1" }, formatDisplay: (e) => Number.isFinite(e) ? `${e} fps` : null }));
1575
1578
  frameCountInput = this._manageComponent(new G({ defaultValue: String(480), attributes: { min: String(1), max: String(3600), step: "1" } }));
1576
- qualityInput = this._manageComponent(new Pe({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (t) => Ve(t) }));
1577
- status = this._manageComponent(new Nt({ title: "status", message: "ready to record", variant: "neutral", context: "video" }));
1579
+ qualityInput = this._manageComponent(new Dt({ defaultValue: String(0.7), attributes: { min: String(0), max: String(1), step: "0.001" }, formatValue: (e) => Ot(e) }));
1580
+ status = this._manageComponent(new Ne({ title: "status", message: "ready to record", variant: "neutral", context: "video" }));
1578
1581
  recordingState = "idle";
1579
- constructor(t) {
1580
- super(t);
1582
+ constructor(e) {
1583
+ super(e);
1581
1584
  }
1582
1585
  render() {
1583
- const t = document.createElement("div");
1584
- t.classList.add(b.stack);
1585
- const e = new j("row");
1586
- e.mount(t);
1586
+ const e = document.createElement("div");
1587
+ e.classList.add(b.stack);
1588
+ const t = new j("row");
1589
+ t.mount(e);
1587
1590
  const r = new P({ label: "number of frames", labelFor: "textmode-export-video-frame-count", variant: "compact" });
1588
- r.mount(e.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-video-frame-count";
1591
+ r.mount(t.root), this.frameCountInput.mount(r.root), this.frameCountInput.inputElement.id = "textmode-export-video-frame-count";
1589
1592
  const a = new P({ label: "frame rate (fps)", labelFor: "textmode-export-video-frame-rate", variant: "compact" });
1590
- a.mount(e.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-video-frame-rate";
1593
+ a.mount(t.root), this.frameRateInput.mount(a.root), this.frameRateInput.inputElement.id = "textmode-export-video-frame-rate";
1591
1594
  const i = new P({ label: "quality", labelFor: "textmode-export-video-quality", variant: "full" });
1592
- return i.mount(t), this.qualityInput.mount(i.root), this.qualityInput.inputElement.id = "textmode-export-video-quality", this.status.mount(t), t;
1595
+ return i.mount(e), this.qualityInput.mount(i.root), this.qualityInput.inputElement.id = "textmode-export-video-quality", this.status.mount(e), e;
1593
1596
  }
1594
1597
  getOptions() {
1595
- const t = this._config.defaultOptions ?? {}, e = Number.parseInt(this.frameCountInput.value, 10), r = Number.parseFloat(this.frameRateInput.value), a = Number.parseFloat(this.qualityInput.value);
1596
- return { frameCount: Number.isFinite(e) ? e : t.frameCount ?? 480, frameRate: Number.isFinite(r) ? r : t.frameRate ?? 60, quality: Number.isFinite(a) ? a : t.quality ?? 0.7 };
1598
+ const e = this._config.defaultOptions ?? {}, t = Number.parseInt(this.frameCountInput.value, 10), r = Number.parseFloat(this.frameRateInput.value), a = Number.parseFloat(this.qualityInput.value);
1599
+ return { frameCount: Number.isFinite(t) ? t : e.frameCount ?? 480, frameRate: Number.isFinite(r) ? r : e.frameRate ?? 60, quality: Number.isFinite(a) ? a : e.quality ?? 0.7 };
1597
1600
  }
1598
1601
  reset() {
1599
1602
  this.recordingState = "idle", this.applyDefaults(), this.status.setMessage("ready to record", "neutral");
1600
1603
  }
1601
1604
  validate() {
1602
- const t = Number.parseInt(this.frameCountInput.value, 10), e = Number.parseFloat(this.frameRateInput.value);
1603
- return Number.isFinite(t) && t >= 1 && Number.isFinite(e) && e >= 1;
1605
+ const e = Number.parseInt(this.frameCountInput.value, 10), t = Number.parseFloat(this.frameRateInput.value);
1606
+ return Number.isFinite(e) && e >= 1 && Number.isFinite(t) && t >= 1;
1604
1607
  }
1605
1608
  isRecording() {
1606
1609
  return this.recordingState === "recording";
1607
1610
  }
1608
- setRecordingState(t, e) {
1609
- this.recordingState = t;
1610
- const r = t === "recording";
1611
- this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.qualityInput.inputElement.disabled = r, this.syncStatus(t, e);
1611
+ setRecordingState(e, t) {
1612
+ this.recordingState = e;
1613
+ const r = e === "recording";
1614
+ this.frameCountInput.inputElement.disabled = r, this.frameRateInput.inputElement.disabled = r, this.qualityInput.inputElement.disabled = r, this.syncStatus(e, t);
1612
1615
  }
1613
- handleProgress(t) {
1614
- this.syncStatus(t.state, t);
1616
+ handleProgress(e) {
1617
+ this.syncStatus(e.state, e);
1615
1618
  }
1616
- syncStatus(t, e) {
1617
- switch (t) {
1619
+ syncStatus(e, t) {
1620
+ switch (e) {
1618
1621
  case "recording": {
1619
- const r = e?.frameIndex ?? 0, a = e?.totalFrames ?? this.resolvePlannedFrameCount();
1622
+ const r = t?.frameIndex ?? 0, a = t?.totalFrames ?? this.resolvePlannedFrameCount();
1620
1623
  if (a) {
1621
1624
  const i = Math.min(Math.max(0, Math.round(r)), a);
1622
1625
  this.status.setMessage(`recording ${i}/${a} frames`, "active");
@@ -1627,23 +1630,23 @@ class pt extends Y {
1627
1630
  this.status.setMessage("saved to disk", "active");
1628
1631
  break;
1629
1632
  case "error":
1630
- this.status.setMessage(e?.message ? `error: ${e.message}` : "recording failed", "alert");
1633
+ this.status.setMessage(t?.message ? `error: ${t.message}` : "recording failed", "alert");
1631
1634
  break;
1632
1635
  default:
1633
1636
  this.status.setMessage("ready to record", "neutral");
1634
1637
  }
1635
1638
  }
1636
1639
  resolvePlannedFrameCount() {
1637
- const t = Number.parseInt(this.frameCountInput.value, 10);
1638
- return Number.isFinite(t) && t > 0 ? Math.round(t) : void 0;
1640
+ const e = Number.parseInt(this.frameCountInput.value, 10);
1641
+ return Number.isFinite(e) && e > 0 ? Math.round(e) : void 0;
1639
1642
  }
1640
1643
  applyDefaults() {
1641
- const t = this._config.defaultOptions ?? {}, e = t.frameCount ?? 480, r = t.frameRate ?? 60, a = t.quality ?? 0.7;
1642
- this.frameCountInput.value = String(e), this.frameRateInput.value = String(r), this.qualityInput.value = String(a), this.frameCountInput.refresh(), this.frameRateInput.refresh();
1644
+ const e = this._config.defaultOptions ?? {}, t = e.frameCount ?? 480, r = e.frameRate ?? 60, a = e.quality ?? 0.7;
1645
+ this.frameCountInput.value = String(t), this.frameRateInput.value = String(r), this.qualityInput.value = String(a), this.frameCountInput.refresh(), this.frameRateInput.refresh();
1643
1646
  }
1644
1647
  }
1645
- const Te = `@layer textmode-export-overlay{.textmode-export-overlay{--overlay-bg: rgba(20, 20, 20, .8);--overlay-surface: rgba(40, 40, 40, .9);--overlay-border: rgba(255, 255, 255, .14);--overlay-border-strong: rgba(255, 255, 255, .2);--overlay-border-focus: rgba(160, 160, 160, .6);--overlay-focus-shadow: 0 0 0 1px rgba(140, 140, 140, .28);--overlay-text: #ffffff;--overlay-muted: rgba(200, 200, 200, .74);--overlay-radius: .75rem;--overlay-stack-gap: .55rem;position:absolute;top:0;left:0;display:flex;flex-direction:column;gap:var(--overlay-stack-gap);min-width:236px;max-width:236px;padding:.65rem .8rem;background:var(--overlay-bg);color:var(--overlay-text);border-radius:var(--overlay-radius);border:1px solid var(--overlay-border);box-shadow:0 12px 28px #0000004d;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:.82rem;line-height:1.35;pointer-events:auto;z-index:2147483647}.textmode-export-overlay *{box-sizing:border-box}.textmode-export-overlay__header{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__header-title-row{display:flex;align-items:center;justify-content:space-between;gap:.4rem}.textmode-export-overlay__header-links{display:inline-flex;align-items:center;gap:.3rem}.textmode-export-overlay__support-link{display:inline-flex;align-items:center;justify-content:center;padding:.2rem;border-radius:.45rem;border:1px solid transparent;color:#d7d7d7d1;background:transparent;text-decoration:none;line-height:0;transition:background .18s ease,color .18s ease,transform .18s ease,border-color .18s ease}.textmode-export-overlay__support-link:hover{color:#fff;background:#5a5a5a4d;border-color:#c8c8c824}.textmode-export-overlay__support-link:focus-visible{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-overlay__support-icon,.textmode-export-overlay__link-icon{display:block;width:1rem;height:1rem}.textmode-export-overlay__stack{display:flex;flex-direction:column;gap:var(--overlay-stack-gap)}.textmode-export-overlay__stack--dense{gap:.3rem}.textmode-export-overlay__stack--compact{gap:.45rem}.textmode-export-overlay__section{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__title{font-size:.92rem;font-weight:600}.textmode-export-overlay__divider{width:100%;height:1px;background:#ffffff29;margin-top:.25rem}.textmode-export-overlay__label{font-weight:500;opacity:.9}.textmode-export-overlay__checkbox{display:flex;align-items:center;gap:.5rem}.textmode-export-overlay__checkbox input[type=checkbox]{width:1rem;height:1rem;accent-color:rgba(100,100,100,.9)}.textmode-export-overlay__row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:flex-start;width:100%}.textmode-export-overlay__field{display:flex;flex-direction:column;gap:.3rem;flex:1 1 120px;min-width:120px}.textmode-export-overlay__field--compact{flex:1 1 100px;min-width:100px}.textmode-export-overlay__field--dense{flex:1 1 90px;min-width:90px}.textmode-export-overlay__field--channel{flex:1 1 0;min-width:0}.textmode-export-overlay__field--full{width:100%;flex:1 1 100%}.textmode-export-overlay__input,.textmode-export-overlay select.textmode-export-overlay__input,.textmode-export-overlay input.textmode-export-overlay__input{width:100%;padding:.35rem .5rem;border-radius:.4rem;border:1px solid var(--overlay-border-strong);background:var(--overlay-surface);color:var(--overlay-text);font:inherit;line-height:1.35;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}.textmode-export-overlay select.textmode-export-overlay__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(200, 200, 200, 0.74)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .5rem center;background-size:1rem;padding-right:2rem}.textmode-export-overlay__input:focus{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow);background:#2d2f42eb}.textmode-export-overlay__input::placeholder{color:var(--overlay-muted);opacity:.7}.textmode-export-overlay__muted{font-size:.75rem;opacity:.7;display:block}.textmode-export-overlay__button{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;border-radius:.45rem;border:none;font-weight:600;padding:.45rem .7rem;cursor:pointer;transition:background .2s ease,transform .2s ease,box-shadow .2s ease}.textmode-export-overlay__button--primary{background:#505050;color:#fff}.textmode-export-overlay__button--secondary{background:#606060;color:#fff}.textmode-export-overlay__button--full{width:100%}.textmode-export-overlay__button:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 7px 18px #00000073}.textmode-export-overlay__button--primary:hover:not(:disabled){background:#404040}.textmode-export-overlay__button--secondary:hover:not(:disabled){background:#4a4a4a}.textmode-export-overlay__button:disabled{cursor:default;opacity:.55;transform:none;box-shadow:none}.textmode-export-overlay__status{display:flex;flex-direction:column;gap:.25rem;padding:.45rem .55rem;border-radius:.45rem;border:1px solid rgba(110,110,110,.22);background:#4646462e}.textmode-export-overlay__status--gif{background:#5050501f;border-color:#78787840}.textmode-export-overlay__status--video{background:#4646461f;border-color:#6e6e6e40}.textmode-export-overlay__status-title{font-weight:600;font-size:.75rem;opacity:.85;text-transform:uppercase;letter-spacing:.04em}.textmode-export-overlay__status-value{font-size:.82rem;color:#dedede;transition:color .18s ease}.textmode-export-overlay__status-value--neutral{color:#cfcfcf}.textmode-export-overlay__status-value--active{color:#f5f5f5}.textmode-export-overlay__status-value--alert{color:#b8b8b8}.textmode-export-number-input,.textmode-export-overlay .textmode-export-number-input{display:flex;align-items:stretch;width:100%;background:var(--overlay-surface);border:1px solid var(--overlay-border-strong);border-radius:.4rem;overflow:hidden;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;position:relative}.textmode-export-number-input:focus-within{border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-number-input.is-disabled{opacity:.55}.textmode-export-number-input__field{flex:1 1 auto;min-width:0;border:none;background:transparent;color:var(--overlay-text);font:inherit;padding:.35rem .5rem;appearance:textfield}.textmode-export-number-input__field::-webkit-outer-spin-button,.textmode-export-number-input__field::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.textmode-export-number-input__field:focus{outline:none}.textmode-export-number-input__controls{display:flex;flex-direction:column;border-left:1px solid rgba(255,255,255,.12);min-width:1.6rem}.textmode-export-number-input__control{display:flex;align-items:center;justify-content:center;width:100%;flex:1;border:none;background:#32323299;color:#d0d0d0;font-size:.68rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease;padding:0}.textmode-export-number-input__control:hover:not(:disabled){background:#5a5a5ad9;color:#fff}.textmode-export-number-input__control:disabled{cursor:default;opacity:.4;background:#28282880;color:#c8c8c866}.textmode-export-number-input:focus-within .textmode-export-number-input__control{background:#3c3c3cbf;color:#e8e8e8}.textmode-export-number-input__display{position:absolute;inset:0;display:flex;align-items:center;padding:.4rem .55rem;pointer-events:none;color:#f8fafc;opacity:0;transition:opacity .14s ease}.textmode-export-number-input__display--visible{opacity:1}.textmode-export-range-input{position:relative;width:100%}.textmode-export-range-input.is-disabled{opacity:.55}.textmode-export-range-input__field{width:100%;height:1.4rem;padding:0;margin:0;background:transparent;cursor:pointer;appearance:none;-webkit-appearance:none}.textmode-export-range-input__field::-webkit-slider-thumb{width:12px;height:12px;margin-top:-3.5px;-webkit-appearance:none;border-radius:50%;background:#a0a0a0;border:2px solid #303030;box-shadow:0 0 0 2px #00000059}.textmode-export-range-input__field::-webkit-slider-runnable-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__field::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:#a0a0a0;border:2px solid #303030;margin-top:-3.5px}.textmode-export-range-input__field::-moz-range-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__tooltip{position:absolute;top:-1.5rem;left:0;transform:translate(-50%);padding:.2rem .35rem;border-radius:.35rem;background:#1e1e1ee0;color:#f8fafc;font-size:.68rem;line-height:1;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease}.textmode-export-range-input__tooltip--visible{opacity:1}}`;
1646
- class Oe {
1648
+ const Tt = `@layer textmode-export-overlay{.textmode-export-overlay{--overlay-bg: rgba(20, 20, 20, .8);--overlay-surface: rgba(40, 40, 40, .9);--overlay-border: rgba(255, 255, 255, .14);--overlay-border-strong: rgba(255, 255, 255, .2);--overlay-border-focus: rgba(160, 160, 160, .6);--overlay-focus-shadow: 0 0 0 1px rgba(140, 140, 140, .28);--overlay-text: #ffffff;--overlay-muted: rgba(200, 200, 200, .74);--overlay-radius: .75rem;--overlay-stack-gap: .55rem;position:absolute;top:0;left:0;display:flex;flex-direction:column;gap:var(--overlay-stack-gap);min-width:236px;max-width:236px;padding:.65rem .8rem;background:var(--overlay-bg);color:var(--overlay-text);border-radius:var(--overlay-radius);border:1px solid var(--overlay-border);box-shadow:0 12px 28px #0000004d;-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;font-size:.82rem;line-height:1.35;pointer-events:auto;z-index:2147483647}.textmode-export-overlay *{box-sizing:border-box}.textmode-export-overlay__header{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__header-title-row{display:flex;align-items:center;justify-content:space-between;gap:.4rem}.textmode-export-overlay__header-links{display:inline-flex;align-items:center;gap:.3rem}.textmode-export-overlay__support-link{display:inline-flex;align-items:center;justify-content:center;padding:.2rem;border-radius:.45rem;border:1px solid transparent;color:#d7d7d7d1;background:transparent;text-decoration:none;line-height:0;transition:background .18s ease,color .18s ease,transform .18s ease,border-color .18s ease}.textmode-export-overlay__support-link:hover{color:#fff;background:#5a5a5a4d;border-color:#c8c8c824}.textmode-export-overlay__support-link:focus-visible{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-overlay__support-icon,.textmode-export-overlay__link-icon{display:block;width:1rem;height:1rem}.textmode-export-overlay__stack{display:flex;flex-direction:column;gap:var(--overlay-stack-gap)}.textmode-export-overlay__stack--dense{gap:.3rem}.textmode-export-overlay__stack--compact{gap:.45rem}.textmode-export-overlay__section{display:flex;flex-direction:column;gap:.4rem}.textmode-export-overlay__title{font-size:.92rem;font-weight:600}.textmode-export-overlay__divider{width:100%;height:1px;background:#ffffff29;margin-top:.25rem}.textmode-export-overlay__label{font-weight:500;opacity:.9}.textmode-export-overlay__checkbox{display:flex;align-items:center;gap:.5rem}.textmode-export-overlay__checkbox input[type=checkbox]{width:1rem;height:1rem;accent-color:rgba(100,100,100,.9)}.textmode-export-overlay__row{display:flex;gap:.6rem;flex-wrap:wrap;align-items:flex-start;width:100%}.textmode-export-overlay__field{display:flex;flex-direction:column;gap:.3rem;flex:1 1 120px;min-width:120px}.textmode-export-overlay__field--compact{flex:1 1 100px;min-width:100px}.textmode-export-overlay__field--dense{flex:1 1 90px;min-width:90px}.textmode-export-overlay__field--channel{flex:1 1 0;min-width:0}.textmode-export-overlay__field--full{width:100%;flex:1 1 100%}.textmode-export-overlay__input,.textmode-export-overlay select.textmode-export-overlay__input,.textmode-export-overlay input.textmode-export-overlay__input{width:100%;padding:.35rem .5rem;border-radius:.4rem;border:1px solid var(--overlay-border-strong);background:var(--overlay-surface);color:var(--overlay-text);font:inherit;line-height:1.35;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease}.textmode-export-overlay select.textmode-export-overlay__input{-webkit-appearance:none;-moz-appearance:none;appearance:none;background-image:url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='rgba(200, 200, 200, 0.74)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");background-repeat:no-repeat;background-position:right .5rem center;background-size:1rem;padding-right:2rem}.textmode-export-overlay__input:focus{outline:none;border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow);background:#2d2f42eb}.textmode-export-overlay__input::placeholder{color:var(--overlay-muted);opacity:.7}.textmode-export-overlay__muted{font-size:.75rem;opacity:.7;display:block}.textmode-export-overlay__button{display:inline-flex;align-items:center;justify-content:center;gap:.35rem;border-radius:.45rem;border:none;font-weight:600;padding:.45rem .7rem;cursor:pointer;transition:background .2s ease,transform .2s ease,box-shadow .2s ease}.textmode-export-overlay__button--primary{background:#505050;color:#fff}.textmode-export-overlay__button--secondary{background:#606060;color:#fff}.textmode-export-overlay__button--full{width:100%}.textmode-export-overlay__button:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 7px 18px #00000073}.textmode-export-overlay__button--primary:hover:not(:disabled){background:#404040}.textmode-export-overlay__button--secondary:hover:not(:disabled){background:#4a4a4a}.textmode-export-overlay__button:disabled{cursor:default;opacity:.55;transform:none;box-shadow:none}.textmode-export-overlay__status{display:flex;flex-direction:column;gap:.25rem;padding:.45rem .55rem;border-radius:.45rem;border:1px solid rgba(110,110,110,.22);background:#4646462e}.textmode-export-overlay__status--gif{background:#5050501f;border-color:#78787840}.textmode-export-overlay__status--video{background:#4646461f;border-color:#6e6e6e40}.textmode-export-overlay__status-title{font-weight:600;font-size:.75rem;opacity:.85;text-transform:uppercase;letter-spacing:.04em}.textmode-export-overlay__status-value{font-size:.82rem;color:#dedede;transition:color .18s ease}.textmode-export-overlay__status-value--neutral{color:#cfcfcf}.textmode-export-overlay__status-value--active{color:#f5f5f5}.textmode-export-overlay__status-value--alert{color:#b8b8b8}.textmode-export-number-input,.textmode-export-overlay .textmode-export-number-input{display:flex;align-items:stretch;width:100%;background:var(--overlay-surface);border:1px solid var(--overlay-border-strong);border-radius:.4rem;overflow:hidden;transition:border-color .18s ease,box-shadow .18s ease,background .18s ease;position:relative}.textmode-export-number-input:focus-within{border-color:var(--overlay-border-focus);box-shadow:var(--overlay-focus-shadow)}.textmode-export-number-input.is-disabled{opacity:.55}.textmode-export-number-input__field{flex:1 1 auto;min-width:0;border:none;background:transparent;color:var(--overlay-text);font:inherit;padding:.35rem .5rem;appearance:textfield}.textmode-export-number-input__field::-webkit-outer-spin-button,.textmode-export-number-input__field::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.textmode-export-number-input__field:focus{outline:none}.textmode-export-number-input__controls{display:flex;flex-direction:column;border-left:1px solid rgba(255,255,255,.12);min-width:1.6rem}.textmode-export-number-input__control{display:flex;align-items:center;justify-content:center;width:100%;flex:1;border:none;background:#32323299;color:#d0d0d0;font-size:.68rem;line-height:1;cursor:pointer;transition:background .15s ease,color .15s ease;padding:0}.textmode-export-number-input__control:hover:not(:disabled){background:#5a5a5ad9;color:#fff}.textmode-export-number-input__control:disabled{cursor:default;opacity:.4;background:#28282880;color:#c8c8c866}.textmode-export-number-input:focus-within .textmode-export-number-input__control{background:#3c3c3cbf;color:#e8e8e8}.textmode-export-number-input__display{position:absolute;inset:0;display:flex;align-items:center;padding:.4rem .55rem;pointer-events:none;color:#f8fafc;opacity:0;transition:opacity .14s ease}.textmode-export-number-input__display--visible{opacity:1}.textmode-export-range-input{position:relative;width:100%}.textmode-export-range-input.is-disabled{opacity:.55}.textmode-export-range-input__field{width:100%;height:1.4rem;padding:0;margin:0;background:transparent;cursor:pointer;appearance:none;-webkit-appearance:none}.textmode-export-range-input__field::-webkit-slider-thumb{width:12px;height:12px;margin-top:-3.5px;-webkit-appearance:none;border-radius:50%;background:#a0a0a0;border:2px solid #303030;box-shadow:0 0 0 2px #00000059}.textmode-export-range-input__field::-webkit-slider-runnable-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__field::-moz-range-thumb{width:12px;height:12px;border-radius:50%;background:#a0a0a0;border:2px solid #303030;margin-top:-3.5px}.textmode-export-range-input__field::-moz-range-track{height:5px;border-radius:999px;background:linear-gradient(90deg,#8c8c8cd9,#646464a6)}.textmode-export-range-input__tooltip{position:absolute;top:-1.5rem;left:0;transform:translate(-50%);padding:.2rem .35rem;border-radius:.35rem;background:#1e1e1ee0;color:#f8fafc;font-size:.68rem;line-height:1;white-space:nowrap;pointer-events:none;opacity:0;transition:opacity .15s ease}.textmode-export-range-input__tooltip--visible{opacity:1}}`;
1649
+ class Rt {
1647
1650
  _textmodifier;
1648
1651
  _state;
1649
1652
  _events;
@@ -1660,102 +1663,114 @@ class Oe {
1660
1663
  _positionService;
1661
1664
  _header = new H();
1662
1665
  _formatField = new P({ label: "export format", labelFor: "textmode-export-format", variant: "full" });
1663
- _formatSelect = new mt({ id: "textmode-export-format", options: [] });
1664
- _exportButton = new Lt({ label: "download file", fullWidth: !0, variant: "primary" });
1665
- _copyButton = new Lt({ label: "copy to clipboard", fullWidth: !0, variant: "primary" });
1666
+ _formatSelect = new me({ id: "textmode-export-format", options: [] });
1667
+ _exportButton = new Le({ label: "download file", fullWidth: !0, variant: "primary" });
1668
+ _copyButton = new Le({ label: "copy to clipboard", fullWidth: !0, variant: "primary" });
1666
1669
  _currentFormat;
1667
1670
  _currentBlade;
1668
1671
  _handleFormatSelectChange = () => {
1669
1672
  this._handleFormatChange(this._formatSelect.value);
1670
1673
  };
1671
1674
  _handleExportClickSafe = () => {
1672
- this._handleExportClick().catch((t) => {
1673
- console.error("[textmode-export] Export failed", t);
1675
+ this._handleExportClick().catch((e) => {
1676
+ console.error("[textmode-export] Export failed", e);
1674
1677
  });
1675
1678
  };
1676
1679
  _handleCopyClickSafe = () => {
1677
- this._handleCopyClick().catch((t) => {
1678
- console.error("[textmode-export] Copy failed", t);
1680
+ this._handleCopyClick().catch((e) => {
1681
+ console.error("[textmode-export] Copy failed", e);
1679
1682
  });
1680
1683
  };
1681
- constructor(t, e, r, a, i) {
1682
- this._textmodifier = t, this._state = r, this._events = a, this._exportService = new ke(e, a), this._clipboardService = new Ee(e), this._definitions = i, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
1684
+ constructor(e, t, r, a, i) {
1685
+ this._textmodifier = e, this._state = r, this._events = a, this._exportService = new Bt(t, a), this._clipboardService = new kt(t), this._definitions = i, this._currentFormat = r.snapshot.format, this._initializeFormatMap(), this._registerEventHandlers();
1683
1686
  }
1684
1687
  $mount() {
1685
- this._createOverlay(), this._renderStaticContent(), this._positionService = new Be(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1688
+ this._createOverlay(), this._renderStaticContent(), this._positionService = new It(this._textmodifier, this._shadowHost), this._positionService.bind(), this._switchFormat(this._currentFormat);
1689
+ }
1690
+ show() {
1691
+ this._shadowHost && (this._shadowHost.style.display = "");
1692
+ }
1693
+ hide() {
1694
+ this._shadowHost && (this._shadowHost.style.display = "none");
1695
+ }
1696
+ toggle() {
1697
+ this.isVisible() ? this.hide() : this.show();
1698
+ }
1699
+ isVisible() {
1700
+ return !!this._shadowHost && this._shadowHost.style.display !== "none";
1686
1701
  }
1687
1702
  $dispose() {
1688
1703
  this._formatSelect.isMounted() && this._formatSelect.selectElement.removeEventListener("change", this._handleFormatSelectChange), this._exportButton.isMounted() && this._exportButton.buttonElement.removeEventListener("click", this._handleExportClickSafe), this._copyButton.isMounted() && this._copyButton.buttonElement.removeEventListener("click", this._handleCopyClickSafe);
1689
- for (const t of this._eventUnsubscribers) t();
1704
+ for (const e of this._eventUnsubscribers) e();
1690
1705
  this._eventUnsubscribers.length = 0, this._events.$clear();
1691
- for (const t of this._formats.values()) t.blade.destroy();
1706
+ for (const e of this._formats.values()) e.blade.destroy();
1692
1707
  this._formats.clear(), this._currentBlade = void 0, this._shadowHost?.isConnected && this._shadowHost.remove(), this._positionService?.dispose();
1693
1708
  }
1694
1709
  _initializeFormatMap() {
1695
- for (const t of this._definitions) {
1696
- const e = t.createBlade();
1697
- this._formats.set(t.format, { definition: t, blade: e, initialized: !1 });
1710
+ for (const e of this._definitions) {
1711
+ const t = e.createBlade();
1712
+ this._formats.set(e.format, { definition: e, blade: t, initialized: !1 });
1698
1713
  }
1699
1714
  }
1700
1715
  _createOverlay() {
1701
1716
  this._shadowHost = document.createElement("div"), this._shadowHost.dataset.plugin = "textmode-export-overlay-host", this._shadowHost.style.cssText = "position: absolute; top: 0; left: 0; pointer-events: none; z-index: 2147483647;", this._shadowRoot = this._shadowHost.attachShadow({ mode: "open" });
1702
- const t = document.createElement("style");
1703
- t.textContent = Te, this._shadowRoot.appendChild(t), this._overlayElement = document.createElement("div"), this._overlayElement.dataset.plugin = "textmode-export-overlay", this._overlayElement.classList.add(b.root, b.stack), this._shadowRoot.appendChild(this._overlayElement), document.body.appendChild(this._shadowHost);
1717
+ const e = document.createElement("style");
1718
+ e.textContent = Tt, this._shadowRoot.appendChild(e), this._overlayElement = document.createElement("div"), this._overlayElement.dataset.plugin = "textmode-export-overlay", this._overlayElement.classList.add(b.root, b.stack), this._shadowRoot.appendChild(this._overlayElement), document.body.appendChild(this._shadowHost);
1704
1719
  }
1705
1720
  _renderStaticContent() {
1706
1721
  this._header.mount(this._overlayElement);
1707
- const t = document.createElement("div");
1708
- t.classList.add(b.section), this._overlayElement.appendChild(t), this._formatField.mount(t), this._prepareFormatOptions(), this._formatSelect.mount(this._formatField.root), this._formatSelect.selectElement.addEventListener("change", this._handleFormatSelectChange), this._optionsContainer = document.createElement("div"), this._optionsContainer.classList.add(b.stack, b.stackCompact), this._overlayElement.appendChild(this._optionsContainer), this._exportButton.mount(this._overlayElement), this._exportButton.buttonElement.addEventListener("click", this._handleExportClickSafe), this._copyButtonContainer = document.createElement("div"), this._copyButtonContainer.classList.add(b.stack, b.stackDense), this._overlayElement.appendChild(this._copyButtonContainer), this._copyButton.mount(this._copyButtonContainer), this._copyButton.buttonElement.dataset.defaultLabel = "copy to clipboard", this._copyButton.buttonElement.addEventListener("click", this._handleCopyClickSafe);
1722
+ const e = document.createElement("div");
1723
+ e.classList.add(b.section), this._overlayElement.appendChild(e), this._formatField.mount(e), this._prepareFormatOptions(), this._formatSelect.mount(this._formatField.root), this._formatSelect.selectElement.addEventListener("change", this._handleFormatSelectChange), this._optionsContainer = document.createElement("div"), this._optionsContainer.classList.add(b.stack, b.stackCompact), this._overlayElement.appendChild(this._optionsContainer), this._exportButton.mount(this._overlayElement), this._exportButton.buttonElement.addEventListener("click", this._handleExportClickSafe), this._copyButtonContainer = document.createElement("div"), this._copyButtonContainer.classList.add(b.stack, b.stackDense), this._overlayElement.appendChild(this._copyButtonContainer), this._copyButton.mount(this._copyButtonContainer), this._copyButton.buttonElement.dataset.defaultLabel = "copy to clipboard", this._copyButton.buttonElement.addEventListener("click", this._handleCopyClickSafe);
1709
1724
  }
1710
1725
  _prepareFormatOptions() {
1711
- const t = this._definitions.map((e) => ({ value: e.format, label: e.label }));
1712
- this._formatSelect.update({ options: t, defaultValue: this._currentFormat });
1726
+ const e = this._definitions.map((t) => ({ value: t.format, label: t.label }));
1727
+ this._formatSelect.update({ options: e, defaultValue: this._currentFormat });
1713
1728
  }
1714
1729
  _registerEventHandlers() {
1715
- this._eventUnsubscribers.push(this._events.$on("export:request", ({ format: t }) => {
1716
- t === this._currentFormat && (this._state.$set({ isBusy: !0, error: void 0 }), this._updateExportButton());
1717
- }), this._events.$on("export:success", ({ format: t }) => {
1718
- if (t === this._currentFormat) {
1719
- const e = { isBusy: !1 };
1720
- t === "gif" && (e.gifProgress = void 0), t === "video" && (e.videoProgress = void 0), this._state.$set(e), this._updateExportButton();
1730
+ this._eventUnsubscribers.push(this._events.$on("export:request", ({ format: e }) => {
1731
+ e === this._currentFormat && (this._state.$set({ isBusy: !0, error: void 0 }), this._updateExportButton());
1732
+ }), this._events.$on("export:success", ({ format: e }) => {
1733
+ if (e === this._currentFormat) {
1734
+ const t = { isBusy: !1 };
1735
+ e === "gif" && (t.gifProgress = void 0), e === "video" && (t.videoProgress = void 0), this._state.$set(t), this._updateExportButton();
1721
1736
  }
1722
- }), this._events.$on("export:error", ({ format: t, error: e }) => {
1723
- t === this._currentFormat && (this._state.$set({ isBusy: !1, error: e }), this._updateExportButton());
1724
- }), this._events.$on("export:progress", ({ format: t, progress: e }) => {
1725
- if (e) {
1726
- if (t === "gif" && this._currentBlade?.blade instanceof ut) {
1727
- const r = e;
1737
+ }), this._events.$on("export:error", ({ format: e, error: t }) => {
1738
+ e === this._currentFormat && (this._state.$set({ isBusy: !1, error: t }), this._updateExportButton());
1739
+ }), this._events.$on("export:progress", ({ format: e, progress: t }) => {
1740
+ if (t) {
1741
+ if (e === "gif" && this._currentBlade?.blade instanceof ue) {
1742
+ const r = t;
1728
1743
  this._state.$set({ gifProgress: r }), this._currentBlade.blade.handleProgress(r);
1729
- } else if (t === "video" && this._currentBlade?.blade instanceof pt) {
1730
- const r = e;
1744
+ } else if (e === "video" && this._currentBlade?.blade instanceof pe) {
1745
+ const r = t;
1731
1746
  this._state.$set({ videoProgress: r }), this._currentBlade.blade.handleProgress(r);
1732
1747
  }
1733
1748
  this._updateExportButton();
1734
1749
  }
1735
1750
  }));
1736
1751
  }
1737
- _handleFormatChange(t) {
1738
- this._currentFormat = t, this._state.$set({ format: t }), this._switchFormat(t), this._events.$emit("format:change", { format: t });
1752
+ _handleFormatChange(e) {
1753
+ this._currentFormat = e, this._state.$set({ format: e }), this._switchFormat(e), this._events.$emit("format:change", { format: e });
1739
1754
  }
1740
- _switchFormat(t) {
1741
- const e = this._formats.get(t);
1742
- if (!e) throw new Error(`Unknown export format: ${t}`);
1743
- this._currentBlade && this._currentBlade.blade.unmount(), this._optionsContainer.innerHTML = "", e.blade.mount(this._optionsContainer), e.initialized || (e.blade.reset(), e.initialized = !0), this._currentBlade = e, this._formatSelect.value = t, this._updateCopyButtonState(), this._updateExportButton(), this._positionService?.scheduleUpdate();
1755
+ _switchFormat(e) {
1756
+ const t = this._formats.get(e);
1757
+ if (!t) throw new Error(`Unknown export format: ${e}`);
1758
+ this._currentBlade && this._currentBlade.blade.unmount(), this._optionsContainer.innerHTML = "", t.blade.mount(this._optionsContainer), t.initialized || (t.blade.reset(), t.initialized = !0), this._currentBlade = t, this._formatSelect.value = e, this._updateCopyButtonState(), this._updateExportButton(), this._positionService?.scheduleUpdate();
1744
1759
  }
1745
1760
  _updateCopyButtonState() {
1746
- const t = this._currentBlade?.definition.supportsClipboard ?? !1;
1747
- this._copyButtonContainer.style.display = t ? "flex" : "none", this._copyButton.setDisabled(!t);
1761
+ const e = this._currentBlade?.definition.supportsClipboard ?? !1;
1762
+ this._copyButtonContainer.style.display = e ? "flex" : "none", this._copyButton.setDisabled(!e);
1748
1763
  }
1749
1764
  async _handleExportClick() {
1750
1765
  if (!this._currentBlade) return;
1751
- const t = this._currentBlade.definition.format, e = this._currentBlade.blade.getOptions();
1766
+ const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions();
1752
1767
  if (this._currentBlade.blade.validate()) {
1753
- if (t === "gif") {
1768
+ if (e === "gif") {
1754
1769
  const r = this._currentBlade.blade;
1755
1770
  if (r.isRecording()) return;
1756
1771
  r.setRecordingState("recording");
1757
1772
  try {
1758
- await this._exportService.$requestExport("gif", e, { onGIFProgress: (a) => {
1773
+ await this._exportService.$requestExport("gif", t, { onGIFProgress: (a) => {
1759
1774
  r.setRecordingState(a.state, a);
1760
1775
  } });
1761
1776
  } catch (a) {
@@ -1765,12 +1780,12 @@ class Oe {
1765
1780
  r.setRecordingState("idle"), this._updateExportButton();
1766
1781
  }, 1600);
1767
1782
  }
1768
- if (t === "video") {
1783
+ if (e === "video") {
1769
1784
  const r = this._currentBlade.blade;
1770
1785
  if (r.isRecording()) return;
1771
1786
  r.setRecordingState("recording");
1772
1787
  try {
1773
- await this._exportService.$requestExport("video", e, { onVideoProgress: (a) => {
1788
+ await this._exportService.$requestExport("video", t, { onVideoProgress: (a) => {
1774
1789
  r.setRecordingState(a.state, a);
1775
1790
  } });
1776
1791
  } catch (a) {
@@ -1782,7 +1797,7 @@ class Oe {
1782
1797
  }
1783
1798
  this._exportButton.setDisabled(!0), this._exportButton.setLabel("exporting…");
1784
1799
  try {
1785
- await this._exportService.$requestExport(t, e);
1800
+ await this._exportService.$requestExport(e, t);
1786
1801
  } finally {
1787
1802
  this._exportButton.setDisabled(!1), this._exportButton.setLabel("download file");
1788
1803
  }
@@ -1790,10 +1805,10 @@ class Oe {
1790
1805
  }
1791
1806
  async _handleCopyClick() {
1792
1807
  if (!this._currentBlade || !this._currentBlade.definition.supportsClipboard) return;
1793
- const t = this._currentBlade.definition.format, e = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
1808
+ const e = this._currentBlade.definition.format, t = this._currentBlade.blade.getOptions(), r = this._copyButton.buttonElement.dataset.defaultLabel ?? "copy to clipboard";
1794
1809
  this._copyButton.setDisabled(!0), this._copyButton.setLabel("copying…");
1795
1810
  try {
1796
- await this._clipboardService.$copy(t, e), this._copyButton.setLabel("copied!");
1811
+ await this._clipboardService.$copy(e, t), this._copyButton.setLabel("copied!");
1797
1812
  } catch (a) {
1798
1813
  console.error("[textmode-export] Failed to copy to clipboard", a), this._copyButton.setLabel("copy failed!");
1799
1814
  } finally {
@@ -1804,17 +1819,20 @@ class Oe {
1804
1819
  }
1805
1820
  _updateExportButton() {
1806
1821
  if (!this._currentBlade) return;
1807
- const t = this._currentBlade.definition.format;
1808
- if (t === "gif" && this._currentBlade.blade instanceof ut) {
1822
+ const e = this._currentBlade.definition.format;
1823
+ if (e === "gif" && this._currentBlade.blade instanceof ue) {
1809
1824
  const r = this._currentBlade.blade, a = this._state.snapshot.gifProgress;
1810
1825
  if (r.isRecording()) if (this._exportButton.setDisabled(!0), a?.totalFrames) {
1811
- const i = a.frameIndex ?? 0;
1812
- this._exportButton.setLabel(`recording ${i}/${a.totalFrames}`);
1813
- } else this._exportButton.setLabel("recording…");
1826
+ const i = a.frameIndex ?? 0, s = a.state === "encoding" ? "encoding" : "recording";
1827
+ this._exportButton.setLabel(`${s} ${i}/${a.totalFrames}`);
1828
+ } else {
1829
+ const i = a?.state === "encoding" ? "encoding" : "recording";
1830
+ this._exportButton.setLabel(`${i}…`);
1831
+ }
1814
1832
  else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
1815
1833
  return;
1816
1834
  }
1817
- if (t === "video" && this._currentBlade.blade instanceof pt) {
1835
+ if (e === "video" && this._currentBlade.blade instanceof pe) {
1818
1836
  const r = this._currentBlade.blade, a = this._state.snapshot.videoProgress;
1819
1837
  if (r.isRecording()) if (this._exportButton.setDisabled(!0), a?.totalFrames) {
1820
1838
  const i = a.frameIndex ?? 0;
@@ -1823,23 +1841,23 @@ class Oe {
1823
1841
  else this._exportButton.setDisabled(!1), this._exportButton.setLabel("start recording");
1824
1842
  return;
1825
1843
  }
1826
- const e = this._state.snapshot.isBusy;
1827
- this._exportButton.setDisabled(e), this._exportButton.setLabel(e ? "exporting…" : "download file");
1844
+ const t = this._state.snapshot.isBusy;
1845
+ this._exportButton.setDisabled(t), this._exportButton.setLabel(t ? "exporting…" : "download file");
1828
1846
  }
1829
1847
  }
1830
- class Re {
1848
+ class Ut {
1831
1849
  _listeners = /* @__PURE__ */ new Map();
1832
- $on(t, e) {
1833
- this._listeners.has(t) || this._listeners.set(t, /* @__PURE__ */ new Set());
1834
- const r = this._listeners.get(t);
1835
- return r.add(e), () => {
1836
- r.delete(e), r.size === 0 && this._listeners.delete(t);
1850
+ $on(e, t) {
1851
+ this._listeners.has(e) || this._listeners.set(e, /* @__PURE__ */ new Set());
1852
+ const r = this._listeners.get(e);
1853
+ return r.add(t), () => {
1854
+ r.delete(t), r.size === 0 && this._listeners.delete(e);
1837
1855
  };
1838
1856
  }
1839
- $emit(t, e) {
1840
- const r = this._listeners.get(t);
1857
+ $emit(e, t) {
1858
+ const r = this._listeners.get(e);
1841
1859
  if (r) for (const a of [...r]) try {
1842
- a(e);
1860
+ a(t);
1843
1861
  } catch (i) {
1844
1862
  console.error("[textmode-export] Event handler failed", i);
1845
1863
  }
@@ -1848,50 +1866,50 @@ class Re {
1848
1866
  this._listeners.clear();
1849
1867
  }
1850
1868
  }
1851
- class Ue {
1869
+ class Nt {
1852
1870
  _state;
1853
1871
  _listeners = /* @__PURE__ */ new Set();
1854
- constructor(t) {
1855
- this._state = t;
1872
+ constructor(e) {
1873
+ this._state = e;
1856
1874
  }
1857
1875
  get snapshot() {
1858
1876
  return Object.freeze({ ...this._state });
1859
1877
  }
1860
- $set(t) {
1861
- this._state = Object.assign({}, this._state, t);
1862
- const e = this.snapshot;
1878
+ $set(e) {
1879
+ this._state = Object.assign({}, this._state, e);
1880
+ const t = this.snapshot;
1863
1881
  for (const r of [...this._listeners]) try {
1864
- r(e);
1882
+ r(t);
1865
1883
  } catch (a) {
1866
1884
  console.error("[textmode-export] State listener failed", a);
1867
1885
  }
1868
1886
  }
1869
- $subscribe(t) {
1870
- return this._listeners.add(t), t(this.snapshot), () => {
1871
- this._listeners.delete(t);
1887
+ $subscribe(e) {
1888
+ return this._listeners.add(e), e(this.snapshot), () => {
1889
+ this._listeners.delete(e);
1872
1890
  };
1873
1891
  }
1874
- $reset(t) {
1875
- this._state = t;
1876
- const e = this.snapshot;
1877
- for (const r of [...this._listeners]) r(e);
1892
+ $reset(e) {
1893
+ this._state = e;
1894
+ const t = this.snapshot;
1895
+ for (const r of [...this._listeners]) r(t);
1878
1896
  }
1879
1897
  }
1880
- const Ne = (s) => ({ format: s, isBusy: !1 });
1881
- class Gt extends T {
1898
+ const Gt = (o) => ({ format: o, isBusy: !1 });
1899
+ class Ge extends O {
1882
1900
  props;
1883
1901
  checkbox;
1884
1902
  labelElement;
1885
1903
  handleChange = () => {
1886
1904
  this.props.defaultChecked = this.checkbox.checked;
1887
1905
  };
1888
- constructor(t) {
1889
- super(), this.props = t;
1906
+ constructor(e) {
1907
+ super(), this.props = e;
1890
1908
  }
1891
1909
  render() {
1892
1910
  this.labelElement = document.createElement("label"), this.labelElement.classList.add(b.checkbox), this.checkbox = document.createElement("input"), this.checkbox.type = "checkbox", this.props.id && (this.checkbox.id = this.props.id), this.checkbox.checked = !!this.props.defaultChecked, this.checkbox.addEventListener("change", this.handleChange);
1893
- const t = document.createElement("span");
1894
- return t.textContent = this.props.label, this.labelElement.htmlFor = this.props.id ?? "", this.labelElement.appendChild(this.checkbox), this.labelElement.appendChild(t), this.labelElement;
1911
+ const e = document.createElement("span");
1912
+ return e.textContent = this.props.label, this.labelElement.htmlFor = this.props.id ?? "", this.labelElement.appendChild(this.checkbox), this.labelElement.appendChild(e), this.labelElement;
1895
1913
  }
1896
1914
  get inputElement() {
1897
1915
  return this.checkbox;
@@ -1899,24 +1917,24 @@ class Gt extends T {
1899
1917
  get checked() {
1900
1918
  return this.checkbox.checked;
1901
1919
  }
1902
- set checked(t) {
1903
- this.checkbox.checked = t;
1920
+ set checked(e) {
1921
+ this.checkbox.checked = e;
1904
1922
  }
1905
1923
  _onUnmount() {
1906
1924
  this.checkbox.removeEventListener("change", this.handleChange);
1907
1925
  }
1908
- onUpdate(t) {
1909
- this.props = t, t.id && (this.checkbox.id = t.id, this.labelElement.htmlFor = t.id), this.checkbox.checked = !!t.defaultChecked, this.labelElement.lastElementChild && (this.labelElement.lastElementChild.textContent = t.label);
1926
+ onUpdate(e) {
1927
+ this.props = e, e.id && (this.checkbox.id = e.id, this.labelElement.htmlFor = e.id), this.checkbox.checked = !!e.defaultChecked, this.labelElement.lastElementChild && (this.labelElement.lastElementChild.textContent = e.label);
1910
1928
  }
1911
1929
  }
1912
- class Ge extends T {
1930
+ class zt extends O {
1913
1931
  props;
1914
1932
  input;
1915
1933
  handleInput = () => {
1916
1934
  this.props.defaultValue = this.input.value;
1917
1935
  };
1918
- constructor(t) {
1919
- super(), this.props = t;
1936
+ constructor(e) {
1937
+ super(), this.props = e;
1920
1938
  }
1921
1939
  render() {
1922
1940
  return this.input = document.createElement("input"), this.input.type = "text", this.input.classList.add(b.input), this.props.id && (this.input.id = this.props.id), this.props.maxLength !== void 0 && (this.input.maxLength = this.props.maxLength), this.props.defaultValue !== void 0 && (this.input.value = this.props.defaultValue), this.input.addEventListener("input", this.handleInput), this.input;
@@ -1927,31 +1945,31 @@ class Ge extends T {
1927
1945
  get value() {
1928
1946
  return this.input.value;
1929
1947
  }
1930
- set value(t) {
1931
- this.input.value = t;
1948
+ set value(e) {
1949
+ this.input.value = e;
1932
1950
  }
1933
1951
  _onUnmount() {
1934
1952
  this.input.removeEventListener("input", this.handleInput);
1935
1953
  }
1936
- onUpdate(t) {
1937
- this.props = t, t.id && (this.input.id = t.id), t.maxLength !== void 0 && (this.input.maxLength = t.maxLength), t.defaultValue !== void 0 && (this.input.value = t.defaultValue);
1954
+ onUpdate(e) {
1955
+ this.props = e, e.id && (this.input.id = e.id), e.maxLength !== void 0 && (this.input.maxLength = e.maxLength), e.defaultValue !== void 0 && (this.input.value = e.defaultValue);
1938
1956
  }
1939
1957
  }
1940
- class ze extends Y {
1941
- trailingSpaces = this._manageComponent(new Gt({ label: "preserve trailing spaces", defaultChecked: !1 }));
1942
- emptyCharacter = this._manageComponent(new Ge({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
1943
- constructor(t) {
1944
- super(t);
1958
+ class Wt extends Y {
1959
+ trailingSpaces = this._manageComponent(new Ge({ label: "preserve trailing spaces", defaultChecked: !1 }));
1960
+ emptyCharacter = this._manageComponent(new zt({ id: "textmode-export-empty-character", defaultValue: " ", maxLength: 1 }));
1961
+ constructor(e) {
1962
+ super(e);
1945
1963
  }
1946
1964
  render() {
1947
- const t = document.createElement("div");
1948
- t.classList.add(b.stack), this.trailingSpaces.mount(t);
1949
- const e = new P({ label: "empty character", labelFor: "textmode-export-empty-character", variant: "full" });
1950
- return e.mount(t), this.emptyCharacter.mount(e.root), t;
1965
+ const e = document.createElement("div");
1966
+ e.classList.add(b.stack), this.trailingSpaces.mount(e);
1967
+ const t = new P({ label: "empty character", labelFor: "textmode-export-empty-character", variant: "full" });
1968
+ return t.mount(e), this.emptyCharacter.mount(t.root), e;
1951
1969
  }
1952
1970
  getOptions() {
1953
- const t = this._config.defaultOptions ?? {}, e = this.emptyCharacter.value || t.emptyCharacter || " ";
1954
- return { preserveTrailingSpaces: this.trailingSpaces.checked, emptyCharacter: e };
1971
+ const e = this._config.defaultOptions ?? {}, t = this.emptyCharacter.value || e.emptyCharacter || " ";
1972
+ return { preserveTrailingSpaces: this.trailingSpaces.checked, emptyCharacter: t };
1955
1973
  }
1956
1974
  reset() {
1957
1975
  this.applyDefaults();
@@ -1960,60 +1978,60 @@ class ze extends Y {
1960
1978
  return this.emptyCharacter.value.length <= 1;
1961
1979
  }
1962
1980
  applyDefaults() {
1963
- const t = this._config.defaultOptions ?? {};
1964
- this.trailingSpaces.checked = t.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = t.emptyCharacter ?? " ";
1981
+ const e = this._config.defaultOptions ?? {};
1982
+ this.trailingSpaces.checked = e.preserveTrailingSpaces ?? !1, this.emptyCharacter.value = e.emptyCharacter ?? " ";
1965
1983
  }
1966
1984
  }
1967
- class We extends Y {
1968
- formatSelect = this._manageComponent(new mt({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${lt.png})` }, { value: "jpg", label: `JPG (${lt.jpg})` }, { value: "webp", label: `WEBP (${lt.webp})` }], defaultValue: "png" }));
1985
+ class qt extends Y {
1986
+ formatSelect = this._manageComponent(new me({ id: "textmode-export-image-format", options: [{ value: "png", label: `PNG (${le.png})` }, { value: "jpg", label: `JPG (${le.jpg})` }, { value: "webp", label: `WEBP (${le.webp})` }], defaultValue: "png" }));
1969
1987
  scaleInput = this._manageComponent(new G({ defaultValue: "1", attributes: { min: "0.1", step: "0.1" } }));
1970
- constructor(t) {
1971
- super(t);
1988
+ constructor(e) {
1989
+ super(e);
1972
1990
  }
1973
1991
  render() {
1974
- const t = document.createElement("div");
1975
- t.classList.add(b.stack);
1976
- const e = new j("row");
1977
- e.mount(t);
1992
+ const e = document.createElement("div");
1993
+ e.classList.add(b.stack);
1994
+ const t = new j("row");
1995
+ t.mount(e);
1978
1996
  const r = new P({ label: "image format", labelFor: "textmode-export-image-format", variant: "compact" });
1979
- r.mount(e.root), this.formatSelect.mount(r.root);
1997
+ r.mount(t.root), this.formatSelect.mount(r.root);
1980
1998
  const a = new P({ label: "scale", labelFor: "textmode-export-image-scale", variant: "dense" });
1981
- return a.mount(e.root), this.scaleInput.mount(a.root), this.scaleInput.inputElement.id = "textmode-export-image-scale", t;
1999
+ return a.mount(t.root), this.scaleInput.mount(a.root), this.scaleInput.inputElement.id = "textmode-export-image-scale", e;
1982
2000
  }
1983
2001
  getOptions() {
1984
- const t = Number.parseFloat(this.scaleInput.value);
1985
- return { format: this.formatSelect.value, scale: Number.isFinite(t) ? t : this._config.defaultOptions?.scale ?? 1 };
2002
+ const e = Number.parseFloat(this.scaleInput.value);
2003
+ return { format: this.formatSelect.value, scale: Number.isFinite(e) ? e : this._config.defaultOptions?.scale ?? 1 };
1986
2004
  }
1987
2005
  reset() {
1988
2006
  this.applyDefaults(), this.scaleInput.refresh();
1989
2007
  }
1990
2008
  validate() {
1991
- const t = Number.parseFloat(this.scaleInput.value);
1992
- return Number.isFinite(t) && t > 0;
2009
+ const e = Number.parseFloat(this.scaleInput.value);
2010
+ return Number.isFinite(e) && e > 0;
1993
2011
  }
1994
2012
  applyDefaults() {
1995
- const t = this._config.defaultOptions ?? {};
1996
- this.formatSelect.value = t.format ?? "png";
1997
- const e = t.scale ?? 1;
1998
- this.scaleInput.value = String(e);
2013
+ const e = this._config.defaultOptions ?? {};
2014
+ this.formatSelect.value = e.format ?? "png";
2015
+ const t = e.scale ?? 1;
2016
+ this.scaleInput.value = String(t);
1999
2017
  }
2000
2018
  }
2001
- class qe extends Y {
2002
- includeBackground = this._manageComponent(new Gt({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 }));
2003
- drawMode = this._manageComponent(new mt({ id: "textmode-export-svg-draw-mode", options: [{ value: "fill", label: "fill" }, { value: "stroke", label: "stroke" }], defaultValue: "fill" }));
2019
+ class Ht extends Y {
2020
+ includeBackground = this._manageComponent(new Ge({ id: "textmode-export-svg-include-backgrounds", label: "include cell backgrounds", defaultChecked: !0 }));
2021
+ drawMode = this._manageComponent(new me({ id: "textmode-export-svg-draw-mode", options: [{ value: "fill", label: "fill" }, { value: "stroke", label: "stroke" }], defaultValue: "fill" }));
2004
2022
  strokeWidth = this._manageComponent(new G({ defaultValue: "1", attributes: { min: "0", step: "0.1" } }));
2005
- constructor(t) {
2006
- super(t);
2023
+ constructor(e) {
2024
+ super(e);
2007
2025
  }
2008
2026
  render() {
2009
- const t = document.createElement("div");
2010
- t.classList.add(b.stack), this.includeBackground.mount(t);
2011
- const e = new j("row");
2012
- e.mount(t);
2027
+ const e = document.createElement("div");
2028
+ e.classList.add(b.stack), this.includeBackground.mount(e);
2029
+ const t = new j("row");
2030
+ t.mount(e);
2013
2031
  const r = new P({ label: "draw mode", labelFor: "textmode-export-svg-draw-mode", variant: "compact" });
2014
- r.mount(e.root), this.drawMode.mount(r.root);
2032
+ r.mount(t.root), this.drawMode.mount(r.root);
2015
2033
  const a = new P({ label: "stroke width", labelFor: "textmode-export-svg-stroke-width", variant: "compact" });
2016
- return a.mount(e.root), this.strokeWidth.mount(a.root), this.strokeWidth.inputElement.id = "textmode-export-svg-stroke-width", this.drawMode.selectElement.addEventListener("change", () => this.updateStrokeControls()), this.updateStrokeControls(), t;
2034
+ return a.mount(t.root), this.strokeWidth.mount(a.root), this.strokeWidth.inputElement.id = "textmode-export-svg-stroke-width", this.drawMode.selectElement.addEventListener("change", () => this.updateStrokeControls()), this.updateStrokeControls(), e;
2017
2035
  }
2018
2036
  getOptions() {
2019
2037
  return { includeBackgroundRectangles: this.includeBackground.checked, drawMode: this.drawMode.value, strokeWidth: Number.parseFloat(this.strokeWidth.value) };
@@ -2022,45 +2040,47 @@ class qe extends Y {
2022
2040
  this.applyDefaults(), this.updateStrokeControls();
2023
2041
  }
2024
2042
  validate() {
2025
- const t = Number.parseFloat(this.strokeWidth.value);
2026
- return this.drawMode.value !== "stroke" || Number.isFinite(t) && t >= 0;
2043
+ const e = Number.parseFloat(this.strokeWidth.value);
2044
+ return this.drawMode.value !== "stroke" || Number.isFinite(e) && e >= 0;
2027
2045
  }
2028
2046
  updateStrokeControls() {
2029
- const t = this.drawMode.value === "stroke";
2030
- this.strokeWidth.inputElement.disabled = !t, this.strokeWidth.refresh();
2047
+ const e = this.drawMode.value === "stroke";
2048
+ this.strokeWidth.inputElement.disabled = !e, this.strokeWidth.refresh();
2031
2049
  }
2032
2050
  applyDefaults() {
2033
- const t = this._config.defaultOptions ?? {};
2034
- this.includeBackground.checked = t.includeBackgroundRectangles ?? !0, this.drawMode.value = t.drawMode ?? "fill";
2035
- const e = t.strokeWidth ?? 1;
2036
- this.strokeWidth.value = String(e), this.strokeWidth.refresh();
2037
- }
2038
- }
2039
- const He = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new ze({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new We({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new qe({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new ut({ format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, defaultOptions: { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 } }) }, { format: "video", label: "video (.webm)", supportsClipboard: !1, createBlade: () => new pt({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
2040
- function je() {
2041
- return He;
2042
- }
2043
- function Qe(s, t) {
2044
- const e = je(), r = e[0]?.format, a = new Ue(Ne(r)), i = new Re(), n = new Oe(s, t, a, i, e);
2045
- return n.$mount(), n;
2046
- }
2047
- const Xe = (s = {}) => {
2048
- const t = s.overlay ?? !0;
2049
- let e;
2050
- return { name: "textmode-export", version: "1.0.0", async install(r, a) {
2051
- const i = { saveCanvas: async (n = {}) => new bt().$saveImage(r.canvas, n), copyCanvas: async (n = {}) => new bt().$copyImageToClipboard(r.canvas, n), saveSVG: (n = {}) => {
2052
- new gt().$saveSVG(r, n);
2053
- }, saveStrings: (n = {}) => {
2054
- new vt().$saveTXT(r, n);
2055
- }, toSVG: (n = {}) => new gt().$generateSVG(r, n), toString: (n = {}) => new vt().$generateTXT(r, n), saveGIF: async (n = {}) => new me(r, a.registerPostDrawHook).$saveGIF(n), saveWEBM: async (n = {}) => new Ce(r, a.registerPostDrawHook).$saveWEBM(n) };
2056
- Object.assign(r, i), t && (e = Qe(r, i));
2057
- }, async uninstall(r) {
2058
- e?.$dispose(), e = void 0;
2059
- const a = ["saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "saveGIF", "saveWEBM"];
2060
- for (const i of a) delete r[i];
2061
- } };
2051
+ const e = this._config.defaultOptions ?? {};
2052
+ this.includeBackground.checked = e.includeBackgroundRectangles ?? !0, this.drawMode.value = e.drawMode ?? "fill";
2053
+ const t = e.strokeWidth ?? 1;
2054
+ this.strokeWidth.value = String(t), this.strokeWidth.refresh();
2055
+ }
2056
+ }
2057
+ const jt = [{ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, createBlade: () => new Wt({ format: "txt", label: "plain text (.txt)", supportsClipboard: !0, defaultOptions: { preserveTrailingSpaces: !1, emptyCharacter: " " } }) }, { format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, createBlade: () => new qt({ format: "image", label: "image (.png / .jpg / .webp)", supportsClipboard: !0, defaultOptions: { format: "png", scale: 1 } }) }, { format: "svg", label: "vector (.svg)", supportsClipboard: !0, createBlade: () => new Ht({ format: "svg", label: "vector (.svg)", supportsClipboard: !0, defaultOptions: { includeBackgroundRectangles: !0, drawMode: "fill", strokeWidth: 1 } }) }, { format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, createBlade: () => new ue({ format: "gif", label: "animated GIF (.gif)", supportsClipboard: !1, defaultOptions: { frameCount: 300, frameRate: 60, scale: 1, repeat: 0 } }) }, { format: "video", label: "video (.webm)", supportsClipboard: !1, createBlade: () => new pe({ format: "video", label: "video (.webm)", supportsClipboard: !1, defaultOptions: { frameCount: 480, frameRate: 60, quality: 0.7 } }) }];
2058
+ function Qt() {
2059
+ return jt;
2060
+ }
2061
+ function Xt(o, e) {
2062
+ const t = Qt(), r = t[0]?.format, a = new Nt(Gt(r)), i = new Ut(), s = new Rt(o, e, a, i, t);
2063
+ return s.$mount(), s;
2064
+ }
2065
+ const ze = { name: "textmode.export", version: "1.2.1", async install(o, e) {
2066
+ const t = { saveCanvas: async (s = {}) => new be().$saveImage(o.canvas, s), copyCanvas: async (s = {}) => new be().$copyImageToClipboard(o.canvas, s), saveSVG: (s = {}) => {
2067
+ new ge().$saveSVG(o, s);
2068
+ }, saveStrings: (s = {}) => {
2069
+ new ve().$saveTXT(o, s);
2070
+ }, toSVG: (s = {}) => new ge().$generateSVG(o, s), toString: (s = {}) => new ve().$generateTXT(o, s), saveGIF: async (s = {}) => new ft(o, e.registerPostDrawHook).$saveGIF(s), saveWEBM: async (s = {}) => new Et(o, e.registerPostDrawHook).$saveWEBM(s) }, r = Xt(o, t), a = { show: () => r.show(), hide: () => r.hide(), toggle: () => r.toggle(), isVisible: () => r.isVisible() }, i = { ...t, exportOverlay: a };
2071
+ Object.assign(o, i), o._exportOverlayController = r;
2072
+ }, async uninstall(o) {
2073
+ o._exportOverlayController?.$dispose(), delete o._exportOverlayController;
2074
+ const t = ["exportOverlay", "saveCanvas", "copyCanvas", "saveSVG", "saveStrings", "toSVG", "toString", "saveGIF", "saveWEBM"];
2075
+ for (const r of t) delete o[r];
2076
+ } }, Yt = (o = {}) => {
2077
+ const e = o.overlay ?? !0, t = { ...ze }, r = t.install;
2078
+ return t.install = async (a, i) => {
2079
+ await r.call(t, a, i), !e && a.exportOverlay.hide();
2080
+ }, t;
2062
2081
  };
2063
- typeof window < "u" && (window.createTextmodeExportPlugin = Xe);
2082
+ typeof window < "u" && (window.ExportPlugin = ze, window.createTextmodeExportPlugin = Yt);
2064
2083
  export {
2065
- Xe as createTextmodeExportPlugin
2084
+ ze as ExportPlugin,
2085
+ Yt as createTextmodeExportPlugin
2066
2086
  };