@bloklabs/cli 1.16.0 → 1.16.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.
@@ -0,0 +1,831 @@
1
+ //#region src/components/shared/color-presets.ts
2
+ var e = [
3
+ {
4
+ name: "gray",
5
+ text: "#787774",
6
+ bg: "#f1f1ef"
7
+ },
8
+ {
9
+ name: "brown",
10
+ text: "#9f6b53",
11
+ bg: "#f4eeee"
12
+ },
13
+ {
14
+ name: "orange",
15
+ text: "#d9730d",
16
+ bg: "#fbecdd"
17
+ },
18
+ {
19
+ name: "yellow",
20
+ text: "#cb9b00",
21
+ bg: "#fbf3db"
22
+ },
23
+ {
24
+ name: "green",
25
+ text: "#448361",
26
+ bg: "#edf3ec"
27
+ },
28
+ {
29
+ name: "blue",
30
+ text: "#337ea9",
31
+ bg: "#e7f3f8"
32
+ },
33
+ {
34
+ name: "purple",
35
+ text: "#9065b0",
36
+ bg: "#f6f3f9"
37
+ },
38
+ {
39
+ name: "pink",
40
+ text: "#c14c8a",
41
+ bg: "#f9f0f5"
42
+ },
43
+ {
44
+ name: "red",
45
+ text: "#d44c47",
46
+ bg: "#fdebec"
47
+ }
48
+ ], t = [
49
+ {
50
+ name: "gray",
51
+ text: "#9b9b9b",
52
+ bg: "#2f2f2f"
53
+ },
54
+ {
55
+ name: "brown",
56
+ text: "#c59177",
57
+ bg: "#452a1c"
58
+ },
59
+ {
60
+ name: "orange",
61
+ text: "#dc8c47",
62
+ bg: "#4d2f14"
63
+ },
64
+ {
65
+ name: "yellow",
66
+ text: "#d4ab49",
67
+ bg: "#544012"
68
+ },
69
+ {
70
+ name: "green",
71
+ text: "#5db184",
72
+ bg: "#1e432f"
73
+ },
74
+ {
75
+ name: "blue",
76
+ text: "#5c9fcc",
77
+ bg: "#123a54"
78
+ },
79
+ {
80
+ name: "purple",
81
+ text: "#a67dca",
82
+ bg: "#341d49"
83
+ },
84
+ {
85
+ name: "pink",
86
+ text: "#d45e99",
87
+ bg: "#4b1b33"
88
+ },
89
+ {
90
+ name: "red",
91
+ text: "#dd5e5a",
92
+ bg: "#4e1a18"
93
+ }
94
+ ];
95
+ //#endregion
96
+ //#region src/components/utils/default-page-colors.ts
97
+ function n(e) {
98
+ let t = e.replace(/\s/g, "").toLowerCase();
99
+ return t === "rgb(255,255,255)" || t === "#ffffff" || t === "#fff" || t === "white";
100
+ }
101
+ function r(e) {
102
+ let t = e.replace(/\s/g, "").toLowerCase(), n = /^rgba?\((\d+),(\d+),(\d+)(?:,[\d.]+)?\)$/.exec(t);
103
+ if (n) {
104
+ let e = parseInt(n[1], 10) / 255, t = parseInt(n[2], 10) / 255, r = parseInt(n[3], 10) / 255;
105
+ return .2126 * e + .7152 * t + .0722 * r;
106
+ }
107
+ let r = /^hsla?\(([\d.]+),([\d.]+)%,([\d.]+)%(?:,[\d.]+)?\)$/.exec(t);
108
+ if (r) {
109
+ let e = parseFloat(r[1]) / 360, t = parseFloat(r[2]) / 100, n = parseFloat(r[3]) / 100;
110
+ if (t === 0) return .2126 * n + .7152 * n + .0722 * n;
111
+ let i = n < .5 ? n * (1 + t) : n + t - n * t, a = 2 * n - i, o = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, s = (e) => {
112
+ let t = o(e);
113
+ return t < 1 / 6 ? a + (i - a) * 6 * t : t < 1 / 2 ? i : t < 2 / 3 ? a + (i - a) * (2 / 3 - t) * 6 : a;
114
+ }, c = s(e + 1 / 3), l = s(e), u = s(e - 1 / 3);
115
+ return .2126 * c + .7152 * l + .0722 * u;
116
+ }
117
+ let i = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
118
+ if (i) {
119
+ let e = i[1], t = e.length === 3 ? [
120
+ e[0] + e[0],
121
+ e[1] + e[1],
122
+ e[2] + e[2]
123
+ ] : [
124
+ e.substring(0, 2),
125
+ e.substring(2, 4),
126
+ e.substring(4, 6)
127
+ ], n = parseInt(t[0], 16) / 255, r = parseInt(t[1], 16) / 255, a = parseInt(t[2], 16) / 255;
128
+ return .2126 * n + .7152 * r + .0722 * a;
129
+ }
130
+ return -1;
131
+ }
132
+ function i(e) {
133
+ let t = r(e);
134
+ return t >= 0 && t < .12;
135
+ }
136
+ var a = 250;
137
+ function o(e) {
138
+ let t = e.replace(/\s/g, "").toLowerCase();
139
+ if (t === "transparent") return {
140
+ r: 0,
141
+ g: 0,
142
+ b: 0,
143
+ a: 0
144
+ };
145
+ if (t === "white") return {
146
+ r: 255,
147
+ g: 255,
148
+ b: 255,
149
+ a: 1
150
+ };
151
+ let n = /^rgba?\((\d+),(\d+),(\d+)(?:,([\d.]+))?\)$/.exec(t);
152
+ if (n) return {
153
+ r: parseInt(n[1], 10),
154
+ g: parseInt(n[2], 10),
155
+ b: parseInt(n[3], 10),
156
+ a: n[4] === void 0 ? 1 : parseFloat(n[4])
157
+ };
158
+ let r = /^#([0-9a-f]{6}|[0-9a-f]{3})$/.exec(t);
159
+ if (r) {
160
+ let e = r[1], t = e.length === 3 ? [
161
+ e[0] + e[0],
162
+ e[1] + e[1],
163
+ e[2] + e[2]
164
+ ] : [
165
+ e.substring(0, 2),
166
+ e.substring(2, 4),
167
+ e.substring(4, 6)
168
+ ];
169
+ return {
170
+ r: parseInt(t[0], 16),
171
+ g: parseInt(t[1], 16),
172
+ b: parseInt(t[2], 16),
173
+ a: 1
174
+ };
175
+ }
176
+ return null;
177
+ }
178
+ function s(e) {
179
+ let t = o(e);
180
+ return t !== null && (t.a === 0 || t.r >= a && t.g >= a && t.b >= a) || i(e);
181
+ }
182
+ //#endregion
183
+ //#region src/components/utils/color-mapping.ts
184
+ function c(e, t, n) {
185
+ let r = t / 100, i = n / 100;
186
+ if (r === 0) {
187
+ let e = Math.round(i * 255);
188
+ return [
189
+ e,
190
+ e,
191
+ e
192
+ ];
193
+ }
194
+ let a = (e) => e < 0 ? e + 1 : e > 1 ? e - 1 : e, o = (e, t, n) => {
195
+ let r = a(n);
196
+ return r < 1 / 6 ? e + (t - e) * 6 * r : r < 1 / 2 ? t : r < 2 / 3 ? e + (t - e) * (2 / 3 - r) * 6 : e;
197
+ }, s = i < .5 ? i * (1 + r) : i + r - i * r, c = 2 * i - s, l = e / 360;
198
+ return [
199
+ Math.round(o(c, s, l + 1 / 3) * 255),
200
+ Math.round(o(c, s, l) * 255),
201
+ Math.round(o(c, s, l - 1 / 3) * 255)
202
+ ];
203
+ }
204
+ function l(e) {
205
+ let t = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i.exec(e);
206
+ if (t) return [
207
+ parseInt(t[1], 16),
208
+ parseInt(t[2], 16),
209
+ parseInt(t[3], 16)
210
+ ];
211
+ let n = /^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})[0-9a-f]{2}$/i.exec(e);
212
+ if (n) return [
213
+ parseInt(n[1], 16),
214
+ parseInt(n[2], 16),
215
+ parseInt(n[3], 16)
216
+ ];
217
+ let r = /^#([0-9a-f])([0-9a-f])([0-9a-f])$/i.exec(e);
218
+ if (r) return [
219
+ parseInt(r[1] + r[1], 16),
220
+ parseInt(r[2] + r[2], 16),
221
+ parseInt(r[3] + r[3], 16)
222
+ ];
223
+ let i = /^#([0-9a-f])([0-9a-f])([0-9a-f])[0-9a-f]$/i.exec(e);
224
+ if (i) return [
225
+ parseInt(i[1] + i[1], 16),
226
+ parseInt(i[2] + i[2], 16),
227
+ parseInt(i[3] + i[3], 16)
228
+ ];
229
+ let a = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
230
+ if (a) return [
231
+ Number(a[1]),
232
+ Number(a[2]),
233
+ Number(a[3])
234
+ ];
235
+ let o = /^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%\s*(?:,\s*[\d.]+\s*)?\)$/i.exec(e);
236
+ return o ? c(Number(o[1]), Number(o[2]), Number(o[3])) : null;
237
+ }
238
+ var u = .1;
239
+ function d(e) {
240
+ let t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.max(t, n, r), a = Math.min(t, n, r), o = (i + a) / 2;
241
+ if (i === a) return [
242
+ 0,
243
+ 0,
244
+ o
245
+ ];
246
+ let s = i - a, c = o > .5 ? s / (2 - i - a) : s / (i + a);
247
+ return [
248
+ ((e) => e === t ? ((n - r) / s + (n < r ? 6 : 0)) / 6 : e === n ? ((r - t) / s + 2) / 6 : ((t - n) / s + 4) / 6)(i) * 360,
249
+ c,
250
+ o
251
+ ];
252
+ }
253
+ function f(e, t) {
254
+ let n = e[1] < u, r = t[1] < u;
255
+ if (n && r) {
256
+ let n = Math.abs(e[2] - t[2]);
257
+ return n * n;
258
+ }
259
+ if (n !== r) return 1e3;
260
+ let i = Math.abs(e[0] - t[0]), a = Math.min(i, 360 - i) / 180, o = Math.abs(e[1] - t[1]), s = Math.abs(e[2] - t[2]);
261
+ return 8 * a * a + 1 * o * o + 1 * s * s;
262
+ }
263
+ function p(t, r) {
264
+ if (r === "bg" && (n(t) || i(t))) return t;
265
+ let a = l(t);
266
+ if (a === null) return t;
267
+ let o = d(a);
268
+ return e.reduce((e, t) => {
269
+ let n = l(t[r]);
270
+ if (n === null) return e;
271
+ let i = f(o, d(n));
272
+ return i < e.distance ? {
273
+ color: t[r],
274
+ distance: i
275
+ } : e;
276
+ }, {
277
+ color: t,
278
+ distance: Infinity
279
+ }).color;
280
+ }
281
+ function m(r, a) {
282
+ if (a === "bg" && (n(r) || i(r))) return null;
283
+ let o = l(r);
284
+ if (o === null) return null;
285
+ let s = d(o);
286
+ return [...e, ...t].reduce((e, t) => {
287
+ let n = l(t[a]);
288
+ if (n === null) return e;
289
+ let r = f(s, d(n));
290
+ return e === null || r < e.distance ? {
291
+ name: t.name,
292
+ distance: r
293
+ } : e;
294
+ }, null)?.name ?? null;
295
+ }
296
+ //#endregion
297
+ //#region src/shared/inline-normalization-policy.ts
298
+ var h = /* @__PURE__ */ new Set([
299
+ "A",
300
+ "B",
301
+ "STRONG",
302
+ "I",
303
+ "EM",
304
+ "U",
305
+ "S",
306
+ "DEL",
307
+ "INS",
308
+ "MARK",
309
+ "CODE",
310
+ "SUB",
311
+ "SUP",
312
+ "SMALL",
313
+ "SPAN",
314
+ "FONT"
315
+ ]), ee = new Set([...h].filter((e) => e !== "A")), g = /* @__PURE__ */ new Set([
316
+ "IMG",
317
+ "IFRAME",
318
+ "VIDEO",
319
+ "AUDIO",
320
+ "INPUT",
321
+ "SVG",
322
+ "CANVAS",
323
+ "OBJECT",
324
+ "EMBED"
325
+ ]), _ = /* @__PURE__ */ new Set([
326
+ "U",
327
+ "S",
328
+ "DEL",
329
+ "INS"
330
+ ]), te = /* @__PURE__ */ new Set([
331
+ "background-color",
332
+ "background",
333
+ "text-decoration",
334
+ "text-decoration-line",
335
+ "border",
336
+ "border-bottom",
337
+ "box-shadow",
338
+ "outline"
339
+ ]), v = /* @__PURE__ */ new Set([
340
+ "",
341
+ "none",
342
+ "transparent",
343
+ "initial",
344
+ "unset"
345
+ ]), y = (e) => {
346
+ let t = e.attributes.filter((e) => e.name.toLowerCase() !== "style").map((e) => `${e.name.toLowerCase()}=${e.value}`).sort(), n = e.styleDeclarations.map((e) => `${e.property.toLowerCase()}:${e.value.trim()}`).sort();
347
+ return `${e.tagName}|${t.join("|")}|${n.join(";")}`;
348
+ }, b = (e) => e.attributes.some((e) => e.name.toLowerCase() === "id"), x = (e) => _.has(e.tagName) ? !0 : e.styleDeclarations.some((e) => te.has(e.property.toLowerCase()) && !v.has(e.value.trim().toLowerCase())), S = (e) => {
349
+ if (!ee.has(e.tagName)) return !1;
350
+ let t = e.text();
351
+ return t.trim().length > 0 || e.hasVoidContentDescendant() ? !1 : t.length === 0 || !x(e);
352
+ }, C = (e, t) => !h.has(e.tagName) || b(e) || b(t) ? !1 : y(e) === y(t), ne = (e, t) => {
353
+ if (!h.has(e.tagName) || b(e)) return !1;
354
+ let n = y(e);
355
+ return t.some((e) => y(e) === n);
356
+ }, w = (e) => {
357
+ let t = e.style, n = Array.from({ length: t.length }, (e, n) => {
358
+ let r = t.item(n);
359
+ return {
360
+ property: r,
361
+ value: t.getPropertyValue(r)
362
+ };
363
+ });
364
+ return {
365
+ tagName: e.tagName.toUpperCase(),
366
+ attributes: Array.from(e.attributes).map((e) => ({
367
+ name: e.name,
368
+ value: e.value
369
+ })),
370
+ styleDeclarations: n,
371
+ text: () => e.textContent ?? "",
372
+ hasVoidContentDescendant: () => Array.from(e.querySelectorAll("*")).some((e) => g.has(e.tagName.toUpperCase()))
373
+ };
374
+ }, T = (e, t) => {
375
+ let n = e.parentElement;
376
+ return n === null || n === t ? [] : [w(n), ...T(n, t)];
377
+ }, E = (e) => {
378
+ let t = e.parentNode;
379
+ if (t !== null) {
380
+ for (; e.firstChild !== null;) t.insertBefore(e.firstChild, e);
381
+ t.removeChild(e);
382
+ }
383
+ }, D = (e) => {
384
+ let t = (t) => e.contains(t), n = (e) => t(e) && h.has(e.tagName.toUpperCase()), r = Array.from(e.querySelectorAll("*")).filter((t) => {
385
+ if (!n(t)) return !1;
386
+ let r = w(t);
387
+ return S(r) || ne(r, T(t, e));
388
+ });
389
+ r.forEach(E);
390
+ let i = (e, t) => {
391
+ let n = e.nextSibling;
392
+ if (n === null || n.nodeType !== Node.ELEMENT_NODE || !C(t, w(n))) return !1;
393
+ let r = n;
394
+ for (; r.firstChild !== null;) e.appendChild(r.firstChild);
395
+ return r.remove(), i(e, t), !0;
396
+ }, a = Array.from(e.querySelectorAll("*")).filter(n).map((e) => t(e) && i(e, w(e))).some(Boolean);
397
+ return r.length > 0 || a;
398
+ }, O = (e) => {
399
+ let t = (n) => n === 0 || !D(e) ? !1 : (t(n - 1), !0), n = t(10);
400
+ return n && e.normalize?.(), n;
401
+ };
402
+ //#endregion
403
+ //#region src/components/utils/spacer-paragraph.ts
404
+ function k(e, t = {}) {
405
+ let { lineBreaksAreContent: n = !0 } = t, r = Array.from(e.children);
406
+ return !(n ? r.length > 0 : r.some((e) => e.tagName !== "BR")) && (e.textContent ?? "").replace(/\s/g, "") === "";
407
+ }
408
+ //#endregion
409
+ //#region src/preprocess/legacy-cms-html.ts
410
+ function A(e) {
411
+ j(e), F(e), z(e), V(e), H(e), W(e);
412
+ }
413
+ function j(e) {
414
+ let t = e.ownerDocument;
415
+ for (let n of Array.from(e.querySelectorAll("div[style]"))) {
416
+ if (n.closest("table")) continue;
417
+ let e = R(n);
418
+ if (!e || I(e)) continue;
419
+ let r = t.createElement("aside");
420
+ r.style.backgroundColor = e, r.append(...Array.from(n.childNodes)), M(r), N(r), n.replaceWith(r);
421
+ }
422
+ }
423
+ function M(e) {
424
+ for (;;) {
425
+ let t = Array.from(e.querySelectorAll(":scope > div")).filter((e) => !e.getAttribute("style") && !e.getAttribute("class"));
426
+ if (t.length === 0) break;
427
+ for (let e of t) e.replaceWith(...Array.from(e.childNodes));
428
+ }
429
+ }
430
+ function N(e) {
431
+ for (let t of Array.from(e.querySelectorAll("p"))) {
432
+ let e = t.lastElementChild;
433
+ e?.tagName === "BR" && e.remove();
434
+ }
435
+ }
436
+ var P = 250;
437
+ function F(e) {
438
+ let t = e.querySelectorAll("[style*=\"background-color\"]");
439
+ for (let e of Array.from(t)) I(e.style.backgroundColor) && (e.style.removeProperty("background-color"), e.getAttribute("style")?.trim() === "" && e.removeAttribute("style"), L(e) && e.replaceWith(...Array.from(e.childNodes)));
440
+ }
441
+ function I(e) {
442
+ if (!e) return !1;
443
+ let t = e.replace(/\s/g, "").toLowerCase();
444
+ if (t === "transparent") return !0;
445
+ let n = t.match(/^rgba?\((\d+),(\d+),(\d+)(?:,([^)]+))?\)$/);
446
+ if (!n) return !1;
447
+ if ((n[4] === void 0 ? 1 : parseFloat(n[4])) === 0) return !0;
448
+ let r = parseInt(n[1], 10), i = parseInt(n[2], 10), a = parseInt(n[3], 10);
449
+ return r >= P && i >= P && a >= P;
450
+ }
451
+ function L(e) {
452
+ return e.attributes.length > 0 ? !1 : (e.textContent ?? "").replace(/[\s\u00A0]/g, "").length === 0;
453
+ }
454
+ function R(e) {
455
+ if (e.style.backgroundColor) return e.style.backgroundColor;
456
+ let t = (e.getAttribute("style") ?? "").match(/background:\s*([^;]+)/i);
457
+ if (t) {
458
+ let e = t[1].trim().match(/^(rgb[a]?\([^)]+\)|#[0-9a-fA-F]{3,8}|[a-z]+)$/i);
459
+ if (e) return e[1];
460
+ }
461
+ return "";
462
+ }
463
+ function z(e) {
464
+ for (let t of Array.from(e.querySelectorAll("td, th"))) {
465
+ let e = t.querySelectorAll("p");
466
+ if (e.length !== 0) {
467
+ for (let t of Array.from(e)) B(t);
468
+ q(t);
469
+ }
470
+ }
471
+ }
472
+ function B(e) {
473
+ if (e.innerHTML.trim() === "" || e.innerHTML.trim() === "&nbsp;") {
474
+ e.remove();
475
+ return;
476
+ }
477
+ let t = e.ownerDocument, n = t.createDocumentFragment();
478
+ n.append(...Array.from(e.childNodes)), n.append(t.createElement("br")), e.replaceWith(n);
479
+ }
480
+ function V(e) {
481
+ for (let t of Array.from(e.querySelectorAll("p"))) t.closest("td") || t.closest("th") || k(t, { lineBreaksAreContent: !1 }) && t.remove();
482
+ }
483
+ function H(e) {
484
+ let t = e.ownerDocument;
485
+ for (let n of Array.from(e.querySelectorAll("del, strike"))) {
486
+ let e = t.createElement("s");
487
+ e.append(...Array.from(n.childNodes)), n.replaceWith(e);
488
+ }
489
+ }
490
+ var U = /^[\u2022\u00B7][\s\u00A0]*|^-\s/;
491
+ function W(e) {
492
+ let t = e.ownerDocument, n = G(e);
493
+ for (let e of n) {
494
+ let n = t.createElement("ul");
495
+ e[0].before(n);
496
+ for (let t of e) re(t, n);
497
+ }
498
+ }
499
+ function re(e, t) {
500
+ let n = e.ownerDocument.createElement("li"), r = J(e);
501
+ r && (r.textContent = (r.textContent ?? "").replace(U, "")), n.append(...Array.from(e.childNodes)), t.appendChild(n), e.remove();
502
+ }
503
+ function G(e) {
504
+ let t = [], n = Array.from(e.childNodes);
505
+ for (let e of n) {
506
+ if (e.nodeType !== Node.ELEMENT_NODE) continue;
507
+ let n = e;
508
+ if (!(n.tagName === "P" && U.test(n.textContent ?? ""))) continue;
509
+ let r = t[t.length - 1], i = K(n);
510
+ r && i !== null && r[r.length - 1] === i ? r.push(n) : t.push([n]);
511
+ }
512
+ return t;
513
+ }
514
+ function K(e) {
515
+ let t = e.previousSibling;
516
+ return t && t.nodeType === Node.ELEMENT_NODE ? t : null;
517
+ }
518
+ function q(e) {
519
+ for (;;) {
520
+ let t = e.lastChild;
521
+ if (!t) break;
522
+ let n = t.nodeType === Node.ELEMENT_NODE && t.tagName === "BR", r = t.nodeType === Node.TEXT_NODE && t.textContent?.trim() === "";
523
+ if (!n && !r) break;
524
+ t.remove();
525
+ }
526
+ }
527
+ function J(e) {
528
+ if (e.nodeType === Node.TEXT_NODE) return e;
529
+ for (let t of Array.from(e.childNodes)) {
530
+ let e = J(t);
531
+ if (e) return e;
532
+ }
533
+ return null;
534
+ }
535
+ //#endregion
536
+ //#region src/cli/commands/convert-html/sanitizer.ts
537
+ var Y = {
538
+ B: !0,
539
+ STRONG: !0,
540
+ I: !0,
541
+ EM: !0,
542
+ A: /* @__PURE__ */ new Set(["href"]),
543
+ S: !0,
544
+ U: !0,
545
+ CODE: !0,
546
+ MARK: /* @__PURE__ */ new Set(["style"]),
547
+ BR: !0,
548
+ P: !0,
549
+ H1: !0,
550
+ H2: !0,
551
+ H3: !0,
552
+ H4: !0,
553
+ H5: !0,
554
+ H6: !0,
555
+ UL: !0,
556
+ OL: !0,
557
+ LI: /* @__PURE__ */ new Set(["aria-level"]),
558
+ TABLE: !0,
559
+ THEAD: !0,
560
+ TBODY: !0,
561
+ TR: !0,
562
+ TD: /* @__PURE__ */ new Set(["style"]),
563
+ TH: /* @__PURE__ */ new Set(["style"]),
564
+ BLOCKQUOTE: !0,
565
+ PRE: !0,
566
+ HR: !0,
567
+ ASIDE: /* @__PURE__ */ new Set(["style"]),
568
+ DETAILS: !0,
569
+ SUMMARY: !0,
570
+ IMG: /* @__PURE__ */ new Set(["src", "style"])
571
+ };
572
+ function X(e) {
573
+ Z(e);
574
+ }
575
+ function ie(e) {
576
+ let t = Array.from(e.childNodes);
577
+ for (let n of t) e.before(n);
578
+ return e.remove(), t.filter((e) => e.nodeType === e.ELEMENT_NODE);
579
+ }
580
+ function ae(e, t) {
581
+ for (let n of Array.from(e.attributes)) (t === !0 || !t.has(n.name)) && e.removeAttribute(n.name);
582
+ }
583
+ function Z(e) {
584
+ let t = Array.from(e.childNodes);
585
+ for (let e of t) {
586
+ if (e.nodeType !== e.ELEMENT_NODE) continue;
587
+ let n = e, r = Y[n.tagName];
588
+ if (r === void 0) {
589
+ t.push(...ie(n));
590
+ continue;
591
+ }
592
+ ae(n, r), Z(n);
593
+ }
594
+ }
595
+ //#endregion
596
+ //#region src/cli/commands/convert-html/id-generator.ts
597
+ function oe() {
598
+ let e = /* @__PURE__ */ new Map();
599
+ return (t) => {
600
+ let n = (e.get(t) ?? 0) + 1;
601
+ return e.set(t, n), `${t}-${n}`;
602
+ };
603
+ }
604
+ //#endregion
605
+ //#region src/cli/commands/convert-html/block-builder.ts
606
+ function se(e) {
607
+ let t = oe(), n = [];
608
+ for (let r of Array.from(e.childNodes)) ce(r, n, t);
609
+ return n;
610
+ }
611
+ function ce(e, t, n) {
612
+ if (e.nodeType === Node.TEXT_NODE) {
613
+ let r = e.textContent?.trim() ?? "";
614
+ r && t.push({
615
+ id: n("paragraph"),
616
+ type: "paragraph",
617
+ data: { text: r }
618
+ });
619
+ return;
620
+ }
621
+ if (e.nodeType !== Node.ELEMENT_NODE) return;
622
+ let r = e, i = r.tagName;
623
+ if (i === "P") {
624
+ t.push({
625
+ id: n("paragraph"),
626
+ type: "paragraph",
627
+ data: { text: r.innerHTML }
628
+ });
629
+ return;
630
+ }
631
+ if (/^H[1-6]$/.test(i)) {
632
+ let e = Number(i[1]);
633
+ t.push({
634
+ id: n("header"),
635
+ type: "header",
636
+ data: {
637
+ text: r.innerHTML,
638
+ level: e
639
+ }
640
+ });
641
+ return;
642
+ }
643
+ if (i === "BLOCKQUOTE") {
644
+ t.push({
645
+ id: n("quote"),
646
+ type: "quote",
647
+ data: {
648
+ text: r.innerHTML,
649
+ size: "default"
650
+ }
651
+ });
652
+ return;
653
+ }
654
+ if (i === "PRE") {
655
+ t.push({
656
+ id: n("code"),
657
+ type: "code",
658
+ data: {
659
+ code: r.textContent ?? "",
660
+ language: "plain-text"
661
+ }
662
+ });
663
+ return;
664
+ }
665
+ if (i === "HR") {
666
+ t.push({
667
+ id: n("divider"),
668
+ type: "divider",
669
+ data: {}
670
+ });
671
+ return;
672
+ }
673
+ if (i === "IMG") {
674
+ let e = r.getAttribute("src") ?? "", i = pe(r, "width");
675
+ t.push({
676
+ id: n("image"),
677
+ type: "image",
678
+ data: { url: e },
679
+ stretched: null,
680
+ key: null,
681
+ width: i
682
+ });
683
+ return;
684
+ }
685
+ if (i === "DETAILS") {
686
+ let e = r.querySelector("summary"), i = e ? e.innerHTML : r.innerHTML;
687
+ t.push({
688
+ id: n("toggle"),
689
+ type: "toggle",
690
+ data: { text: i }
691
+ });
692
+ return;
693
+ }
694
+ if (i === "UL" || i === "OL") {
695
+ Q(r, i === "OL" ? "ordered" : "unordered", 0, t, n);
696
+ return;
697
+ }
698
+ if (i === "TABLE") {
699
+ le(r, t, n);
700
+ return;
701
+ }
702
+ if (i === "ASIDE") {
703
+ ue(r, t, n);
704
+ return;
705
+ }
706
+ t.push({
707
+ id: n("paragraph"),
708
+ type: "paragraph",
709
+ data: { text: r.innerHTML }
710
+ });
711
+ }
712
+ function Q(e, t, n, r, i) {
713
+ let a = e.getAttribute("start"), o = a ? Number(a) : null, s = Array.from(e.children).filter((e) => e.tagName === "LI");
714
+ for (let [e, a] of s.entries()) {
715
+ let s = a.cloneNode(!0), c = [];
716
+ for (let e of Array.from(s.querySelectorAll("ul, ol"))) c.push(e.cloneNode(!0)), e.remove();
717
+ let l = s.innerHTML.trim(), u = a.getAttribute("aria-level"), d = u ? Math.max(0, parseInt(u, 10) - 1) : n;
718
+ r.push({
719
+ id: i("list"),
720
+ type: "list",
721
+ data: {
722
+ text: l,
723
+ style: t,
724
+ depth: d === 0 ? null : d,
725
+ checked: null,
726
+ start: e === 0 && o !== null ? o : null
727
+ }
728
+ });
729
+ for (let e of c) Q(e, e.tagName === "OL" ? "ordered" : "unordered", n + 1, r, i);
730
+ }
731
+ }
732
+ function le(e, t, n) {
733
+ let r = n("table"), i = Array.from(e.querySelectorAll("tr")), a = [];
734
+ for (let e of i) {
735
+ let i = Array.from(e.querySelectorAll("td, th")).map((e) => de(e, r, t, n));
736
+ a.push(i);
737
+ }
738
+ let o = i[0] ? Array.from(i[0].querySelectorAll("td, th")) : [], s = o.some((e) => e.tagName === "TH"), c = o.map((e) => {
739
+ let t = $(e, "width");
740
+ if (t) {
741
+ let e = parseInt(t, 10);
742
+ return isNaN(e) ? null : e;
743
+ }
744
+ return null;
745
+ }), l = {
746
+ id: r,
747
+ type: "table",
748
+ data: {
749
+ withHeadings: s,
750
+ withHeadingColumn: !1,
751
+ content: a,
752
+ ...c.some((e) => e !== null) ? { colWidths: c } : {}
753
+ }
754
+ }, u = t.findIndex((e) => e.parent === r);
755
+ u >= 0 ? t.splice(u, 0, l) : t.push(l);
756
+ }
757
+ function ue(e, t, r) {
758
+ let a = r("callout"), o = $(e, "background-color"), s = o && !n(o) && !i(o) ? m(o, "bg") : null, c = [];
759
+ for (let n of Array.from(e.childNodes)) {
760
+ let e = fe(n, a, t, r);
761
+ e && c.push(e);
762
+ }
763
+ let l = t.findIndex((e) => e.parent === a), u = {
764
+ id: a,
765
+ type: "callout",
766
+ data: {
767
+ emoji: "💡",
768
+ backgroundColor: s
769
+ },
770
+ content: c
771
+ };
772
+ l >= 0 ? t.splice(l, 0, u) : t.push(u);
773
+ }
774
+ function de(e, t, r, a) {
775
+ let o = e.innerHTML.trim();
776
+ if (!o) return {
777
+ blocks: [],
778
+ color: null,
779
+ textColor: null
780
+ };
781
+ let s = a("paragraph");
782
+ r.push({
783
+ id: s,
784
+ type: "paragraph",
785
+ parent: t,
786
+ data: { text: o }
787
+ });
788
+ let c = $(e, "background-color"), l = $(e, "color"), u = c && !n(c) && !i(c) ? m(c, "bg") : null;
789
+ return {
790
+ blocks: [s],
791
+ color: u,
792
+ textColor: l ? m(l, "text") : null
793
+ };
794
+ }
795
+ function fe(e, t, n, r) {
796
+ if (e.nodeType === Node.ELEMENT_NODE) {
797
+ let i = e, a = r("paragraph");
798
+ return n.push({
799
+ id: a,
800
+ type: "paragraph",
801
+ parent: t,
802
+ data: { text: i.innerHTML }
803
+ }), a;
804
+ }
805
+ if (e.nodeType === Node.TEXT_NODE) {
806
+ let i = e.textContent?.trim() ?? "";
807
+ if (!i) return null;
808
+ let a = r("paragraph");
809
+ return n.push({
810
+ id: a,
811
+ type: "paragraph",
812
+ parent: t,
813
+ data: { text: i }
814
+ }), a;
815
+ }
816
+ return null;
817
+ }
818
+ function pe(e, t) {
819
+ let n = $(e, t);
820
+ if (!n) return null;
821
+ let r = parseInt(n, 10);
822
+ return isNaN(r) ? null : r;
823
+ }
824
+ function $(e, t) {
825
+ let n = e.getAttribute("style");
826
+ if (!n) return null;
827
+ let r = RegExp(`(?<![\\-a-z])${t}\\s*:\\s*([^;]+)`).exec(n);
828
+ return r ? r[1].trim() : null;
829
+ }
830
+ //#endregion
831
+ export { O as a, k as i, X as n, p as o, A as r, s, se as t };