@emabuild/email-renderer 0.8.0 → 0.9.0

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.
package/dist/index.js CHANGED
@@ -1,55 +1,84 @@
1
- function I(e) {
1
+ function T(e) {
2
+ return typeof e == "object" && e !== null && !Array.isArray(e);
3
+ }
4
+ function ue(e) {
5
+ return T(e) ? e : {};
6
+ }
7
+ function j(e) {
2
8
  return typeof e != "string" && typeof e != "number" ? null : String(e).replace(/[;{}<>"]/g, "").replace(/!important/gi, "").trim() || null;
3
9
  }
4
- function K(e) {
5
- return typeof e == "string" && e.trim() !== "" && I(e) === e.trim();
10
+ function Z(e) {
11
+ return typeof e == "string" && e.trim() !== "" && j(e) === e.trim();
6
12
  }
7
- function ne(e) {
13
+ function se(e) {
8
14
  const t = e?.body;
9
15
  return t ? [...t.headers ?? [], ...t.rows ?? [], ...t.footers ?? []] : [];
10
16
  }
11
- const Y = (e) => typeof e == "string" ? e.trim() : "", Me = (e) => typeof e == "string" && /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(e);
12
- function he(e, t) {
17
+ const Y = (e) => typeof e == "string" ? e.trim() : "", Fe = (e) => typeof e == "string" && /^[a-z]{2,3}(-[A-Za-z0-9]{2,8})*$/.test(e);
18
+ function we(e, t) {
13
19
  return Y(t) || Y(e?.title) || Y(e?.subject);
14
20
  }
15
- function ye(e) {
16
- return Me(e?.language) ? e.language : "";
21
+ function ke(e) {
22
+ const t = e?.language;
23
+ return Fe(t) ? t : "";
17
24
  }
18
- function be(e) {
25
+ function xe(e) {
19
26
  const t = String(e?.fontWeight ?? "");
20
27
  return /^\d{3}$|^(normal|bold)$/.test(t) ? t : "";
21
28
  }
22
- function ie(e) {
29
+ function ee(e) {
23
30
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
24
31
  }
25
- function De(e) {
32
+ const He = /[\u00AD\u034F\u200B-\u200F\u2060\uFEFF]/g;
33
+ function de(e) {
34
+ return e.replace(He, "");
35
+ }
36
+ function S(e) {
37
+ return e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;");
38
+ }
39
+ function Ue(e) {
26
40
  return e.trim().replace(/['"()\\\s<>]/g, (t) => `%${t.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`);
27
41
  }
28
- function Be(e, t) {
29
- const o = e.backgroundImage;
30
- if (!o || typeof o != "object" || typeof o.url != "string" || !o.url.trim()) return { attr: "", css: "", vml: "" };
31
- const n = De(o.url), s = o.repeat === !0 || o.repeat === "repeat" ? "repeat" : "no-repeat", i = o.cover === !0 ? "cover" : o.fullWidth === !0 ? "100% auto" : "auto", r = o.center !== !1 ? "center top" : "left top", a = s === "repeat" ? "tile" : "frame";
42
+ function ie(e) {
43
+ if (!T(e) || typeof e.url != "string" || !e.url.trim()) return null;
44
+ const t = Ue(e.url), n = e.repeat === !0 || e.repeat === "repeat" ? "repeat" : "no-repeat", o = e.cover === !0 ? "cover" : e.fullWidth === !0 ? "100% auto" : "auto", s = e.center !== !1 ? "center top" : "left top";
32
45
  return {
33
- attr: ` background="${P(n)}"`,
34
- css: `background-image:url('${n}');background-repeat:${s};background-position:${r};background-size:${i};`,
35
- vml: `<!--[if gte mso 9]><v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t"><v:fill type="${a}" src="${P(n)}" color="${P(t)}"/></v:background><![endif]-->
36
- `
46
+ url: t,
47
+ repeat: n,
48
+ css: `background-image:url('${t}');background-repeat:${n};background-position:${s};background-size:${o};`,
49
+ fillType: n === "repeat" ? "tile" : "frame"
37
50
  };
38
51
  }
39
- function P(e) {
40
- return e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;");
52
+ function Ce(e) {
53
+ return ie(e)?.css ?? "";
54
+ }
55
+ function Ge(e, t, n) {
56
+ const o = `<v:fill type="${e.fillType}" src="${S(e.url)}"${n ? ` color="${S(n)}"` : ""}/>`;
57
+ return {
58
+ open: `<!--[if gte mso 9]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:${t}px;">${o}<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0"><![endif]-->`,
59
+ close: "<!--[if gte mso 9]></v:textbox></v:rect><![endif]-->"
60
+ };
61
+ }
62
+ function Ke(e, t) {
63
+ const n = ie(e.backgroundImage);
64
+ return n ? {
65
+ attr: ` background="${S(n.url)}"`,
66
+ css: n.css,
67
+ vml: `<!--[if gte mso 9]><v:background xmlns:v="urn:schemas-microsoft-com:vml" fill="t"><v:fill type="${n.fillType}" src="${S(n.url)}" color="${S(t)}"/></v:background><![endif]-->
68
+ `
69
+ } : { attr: "", css: "", vml: "" };
41
70
  }
42
- function We(e, t, o, n = {}) {
43
- const s = o.backgroundColor || "transparent", i = o.contentWidth || "600px", r = o.fontFamily?.value || "arial,helvetica,sans-serif", a = o.textColor || "#000000", l = o.preheaderText || "", u = he(o, n.title), c = ye(o), d = c ? ` lang="${c}" xml:lang="${c}"` : "", h = ie(u || l.trim()), m = n.darkMode ? "light dark" : "light", p = be(o), f = p ? `font-weight:${p};` : "", g = Be(o, s), y = (n.fontUrls ?? []).length ? `
71
+ function Ze(e, t, n, o = {}) {
72
+ const s = n.backgroundColor || "transparent", i = n.contentWidth || "600px", r = n.fontFamily?.value || "arial,helvetica,sans-serif", c = n.textColor || "#000000", l = n.preheaderText || "", d = we(n, o.title), u = ke(n), a = u ? ` lang="${u}" xml:lang="${u}"` : "", h = ee(d || l.trim()), m = o.darkMode ? "light dark" : "light", y = xe(n), b = y ? `font-weight:${y};` : "", f = Ke(n, s), p = (o.fontUrls ?? []).length ? `
44
73
  <!--[if !mso]><!-->
45
- ${n.fontUrls.map(($) => ` <link href="${P($)}" rel="stylesheet" type="text/css">`).join(`
74
+ ${o.fontUrls.map((v) => ` <link href="${S(v)}" rel="stylesheet" type="text/css">`).join(`
46
75
  `)}
47
- <!--<![endif]-->` : "", b = (n.styles ?? []).map(($) => `
76
+ <!--<![endif]-->` : "", g = (o.styles ?? []).map((v) => `
48
77
  <style type="text/css">
49
- ${$}
50
- </style>`).join(""), v = l ? ie(l) : "&zwnj;", w = `<div style="display:none;mso-hide:all;font-size:1px;color:${s};line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;">${v}${"&zwnj;&nbsp;".repeat(80)}</div>`;
78
+ ${v}
79
+ </style>`).join(""), $ = l ? ee(l) : "&zwnj;", w = `<div style="display:none;mso-hide:all;font-size:1px;color:${s};line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;">${$}${"&zwnj;&nbsp;".repeat(80)}</div>`;
51
80
  return `<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
52
- <html${d} xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
81
+ <html${a} xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
53
82
  <head>
54
83
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
55
84
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -58,7 +87,7 @@ ${$}
58
87
  <meta name="format-detection" content="telephone=no,address=no,email=no,date=no,url=no">
59
88
  <meta name="color-scheme" content="${m}">
60
89
  <meta name="supported-color-schemes" content="${m}">
61
- <title>${h}</title>${y}
90
+ <title>${h}</title>${p}
62
91
  <!--[if mso]>
63
92
  <noscript><xml>
64
93
  <o:OfficeDocumentSettings>
@@ -79,11 +108,11 @@ ${$}
79
108
  table, tr, td { vertical-align: top; border-collapse: collapse; }
80
109
  p { margin: 0; }
81
110
  a[x-apple-data-detectors='true'] { color: inherit !important; text-decoration: none !important; }
82
- </style>${b}
111
+ </style>${g}
83
112
  </head>
84
- <body class="clean-body u_body" style="margin:0;padding:0;-webkit-text-size-adjust:100%;background-color:${s};color:${a};${f}">
85
- ${g.vml}${w}
86
- <table id="u_body" role="presentation"${g.attr} style="border-collapse:collapse;border-spacing:0;margin:0 auto;background-color:${s};${g.css}width:100%;" cellpadding="0" cellspacing="0" border="0">
113
+ <body class="clean-body u_body" style="margin:0;padding:0;-webkit-text-size-adjust:100%;background-color:${s};color:${c};${b}">
114
+ ${f.vml}${w}
115
+ <table id="u_body" role="presentation"${f.attr} style="border-collapse:collapse;border-spacing:0;margin:0 auto;background-color:${s};${f.css}width:100%;" cellpadding="0" cellspacing="0" border="0">
87
116
  <tbody>
88
117
  <tr>
89
118
  <td style="vertical-align:top;">
@@ -97,21 +126,21 @@ ${$}
97
126
  </body>
98
127
  </html>`;
99
128
  }
100
- function oe(e, t) {
129
+ function re(e, t) {
101
130
  if (!t || typeof t != "object") return e;
102
- const o = typeof t.before == "string" ? t.before : "", n = typeof t.after == "string" ? t.after : "";
103
- return !o && !n ? e : `${o}${e}${n}`;
131
+ const n = typeof t.before == "string" ? t.before : "", o = typeof t.after == "string" ? t.after : "";
132
+ return !n && !o ? e : `${n}${e}${o}`;
104
133
  }
105
- function q(e) {
134
+ function N(e) {
106
135
  return `only screen and (max-width: ${e + 20}px)`;
107
136
  }
108
- function Pe(e) {
137
+ function Ye(e) {
109
138
  return `
110
139
  @media only screen and (min-width: ${e + 20}px) {
111
140
  .u_row .u_column { display: inline-block !important; }
112
141
  }
113
142
 
114
- @media ${q(e)} {
143
+ @media ${N(e)} {
115
144
  .u_row .u_column {
116
145
  display: block !important;
117
146
  width: 100% !important;
@@ -126,7 +155,7 @@ function Pe(e) {
126
155
  }
127
156
  }
128
157
 
129
- @media ${q(e)} {
158
+ @media ${N(e)} {
130
159
  .u_row-container {
131
160
  max-width: 100% !important;
132
161
  padding-left: 0 !important;
@@ -150,30 +179,35 @@ function Pe(e) {
150
179
  function L(e) {
151
180
  return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
152
181
  }
153
- function Le(e) {
182
+ function Xe(e) {
154
183
  return `v-${L(e)}`;
155
184
  }
156
- const R = (e) => !!e && typeof e == "object" && !Array.isArray(e), M = (e) => typeof e == "string" ? e.trim().replace(/[^A-Za-z0-9_:.-]/g, "-") : "";
157
- function U(e) {
158
- return e.replace(/[:.]/g, "\\$&").replace(/^(-?)(\d)/, (t, o, n) => `${o}\\3${n} `);
185
+ const te = (e) => typeof e == "string" ? e.trim().replace(/[^A-Za-z0-9_:.-]/g, "-") : "";
186
+ function F(e) {
187
+ return e.replace(/[:.]/g, "\\$&").replace(/^(-?)(\d)/, (t, n, o) => `${n}\\3${o} `);
159
188
  }
160
- function $e(e, t) {
161
- return M(`${e}${typeof t == "string" || typeof t == "number" ? t : ""}`);
189
+ function Je(e, t) {
190
+ return te(`${e}${typeof t == "string" || typeof t == "number" ? t : ""}`);
162
191
  }
163
- function se(e) {
164
- const t = e.values ?? {};
165
- return M(t.anchor) || M(R(t._meta) ? t._meta.htmlID : "") || $e("u_content_", e.id);
192
+ function le(e) {
193
+ return _e(e, "u_content_");
166
194
  }
167
195
  function H(e) {
168
- const t = e.values ?? {};
169
- return M(t.anchor) || M(R(t._meta) ? t._meta.htmlID : "") || $e("u_row_", e.id);
196
+ return _e(e, "u_row_");
197
+ }
198
+ function _e(e, t) {
199
+ const n = ue(e.values);
200
+ return te(n.anchor) || te(ue(n._meta).htmlID) || Je(t, e.id);
201
+ }
202
+ function Se(e, t) {
203
+ if (!T(e) || !T(e._override)) return null;
204
+ const n = e._override[t];
205
+ return T(n) && Object.keys(n).length > 0 ? n : null;
170
206
  }
171
207
  function B(e) {
172
- if (!R(e) || !R(e._override)) return null;
173
- const t = e._override.mobile;
174
- return !R(t) || Object.keys(t).length === 0 ? null : t;
208
+ return Se(e, "mobile");
175
209
  }
176
- const Ne = /* @__PURE__ */ new Set([
210
+ const Qe = /* @__PURE__ */ new Set([
177
211
  "_meta",
178
212
  "_override",
179
213
  "text",
@@ -190,175 +224,184 @@ const Ne = /* @__PURE__ */ new Set([
190
224
  "name",
191
225
  "calculatedWidth",
192
226
  "calculatedHeight"
193
- ]), qe = /* @__PURE__ */ new Set(["fontSize", "letterSpacing", "width", "height", "maxWidth", "borderRadius", "iconSize", "spacing"]), Fe = {
227
+ ]), Ve = /* @__PURE__ */ new Set(["fontSize", "letterSpacing", "width", "height", "maxWidth", "borderRadius", "iconSize", "spacing"]), et = {
194
228
  containerPadding: "padding",
195
229
  columnsBackgroundColor: "background-color"
196
230
  };
197
231
  function X(e, t) {
198
- return typeof t == "number" ? isFinite(t) ? qe.has(e) ? `${t}px` : String(t) : null : typeof t == "string" ? I(t) : null;
232
+ return typeof t == "number" ? isFinite(t) ? Ve.has(e) ? `${t}px` : String(t) : null : typeof t == "string" ? j(t) : null;
199
233
  }
200
- function Z(e) {
234
+ function U(e) {
201
235
  const t = [];
202
- for (const [o, n] of Object.entries(e)) {
203
- if (Ne.has(o)) continue;
204
- if (R(n)) {
205
- if (o === "border")
206
- for (const [i, r] of Object.entries(n)) {
236
+ for (const [n, o] of Object.entries(e)) {
237
+ if (Qe.has(n)) continue;
238
+ if (T(o)) {
239
+ if (n === "border")
240
+ for (const [i, r] of Object.entries(o)) {
207
241
  if (!/^border(Top|Right|Bottom|Left)?(Width|Style|Color)$/.test(i)) continue;
208
- const a = X(i, r);
209
- a && t.push({ className: "v-border", property: L(i), value: a });
242
+ const c = X(i, r);
243
+ c && t.push({ className: "v-border", property: L(i), value: c });
210
244
  }
211
- else if (o === "buttonColors")
245
+ else if (n === "buttonColors")
212
246
  for (const i of ["backgroundColor", "color"]) {
213
- const r = X(i, n[i]);
247
+ const r = X(i, o[i]);
214
248
  r && t.push({ className: "v-button-colors", property: L(i), value: r });
215
249
  }
216
250
  continue;
217
251
  }
218
- const s = X(o, n);
219
- s && t.push({ className: Le(o), property: Fe[o] ?? L(o), value: s });
252
+ const s = X(n, o);
253
+ s && t.push({ className: Xe(n), property: et[n] ?? L(n), value: s });
220
254
  }
221
255
  return t;
222
256
  }
223
- function ve(e, t) {
224
- const o = /* @__PURE__ */ new Map();
225
- for (const n of e) {
226
- const s = o.get(n.className) ?? [];
227
- s.push(`${n.property}: ${n.value} !important;`), o.set(n.className, s);
257
+ function Ae(e, t) {
258
+ const n = /* @__PURE__ */ new Map();
259
+ for (const o of e) {
260
+ const s = n.get(o.className) ?? [];
261
+ s.push(`${o.property}: ${o.value} !important;`), n.set(o.className, s);
228
262
  }
229
- return [...o].map(([n, s]) => ` ${t(n)} { ${s.join(" ")} }`);
263
+ return [...n].map(([o, s]) => ` ${t(o)} { ${s.join(" ")} }`);
230
264
  }
231
- function Ue(e) {
265
+ function tt(e) {
232
266
  const t = B(e.values);
233
267
  if (!t) return [];
234
- const o = U(se(e));
235
- return o ? ve(Z(t), (n) => `#${o} .${n}, #${o}.${n}`) : [];
268
+ const n = F(le(e));
269
+ return n ? Ae(U(t), (o) => `#${n} .${o}, #${n}.${o}`) : [];
236
270
  }
237
- function He(e) {
271
+ function nt(e) {
238
272
  const t = B(e.values);
239
273
  if (!t) return [];
240
- const o = U(H(e));
241
- return o ? ve(
242
- Z(t),
243
- (n) => n === "v-columns-background-color" ? `#${o} .${n}` : `#${o}.${n}`
274
+ const n = F(H(e));
275
+ return n ? Ae(
276
+ U(t),
277
+ (o) => o === "v-columns-background-color" ? `#${n} .${o}` : `#${n}.${o}`
244
278
  ) : [];
245
279
  }
246
- function we(e) {
247
- const t = He(e);
248
- for (const o of e.columns ?? [])
249
- for (const n of o.contents ?? []) t.push(...Ue(n));
280
+ function Te(e) {
281
+ const t = nt(e);
282
+ for (const n of e.columns ?? [])
283
+ for (const o of n.contents ?? []) t.push(...tt(o));
250
284
  return t;
251
285
  }
252
- function ke(e, t) {
253
- return e.length ? `@media ${q(t)} {
286
+ function Ee(e, t) {
287
+ return e.length ? `@media ${N(t)} {
254
288
  ${e.join(`
255
289
  `)}
256
290
  }` : "";
257
291
  }
258
- function rn(e) {
292
+ function gn(e) {
259
293
  const t = e?.body;
260
294
  if (!t) return "";
261
- const o = parseInt(String(t.values?.contentWidth || "600")) || 600, n = [];
262
- for (const s of ne(e))
263
- n.push(...we(s));
264
- return ke(n, o);
265
- }
266
- function xe(e) {
267
- if (!e || typeof e != "object") return "";
268
- const t = e;
269
- let o = "";
295
+ const n = parseInt(String(t.values?.contentWidth || "600")) || 600, o = [];
296
+ for (const s of se(e))
297
+ o.push(...Te(s));
298
+ return Ee(o, n);
299
+ }
300
+ const J = (e) => typeof e == "string" || typeof e == "number" ? String(e) : "";
301
+ function Ie(e) {
302
+ if (!T(e)) return "";
303
+ let t = "";
270
304
  for (const n of ["Top", "Right", "Bottom", "Left"]) {
271
- const s = String(t[`border${n}Width`] ?? "").trim();
272
- if (!K(s) || parseFloat(s) <= 0) continue;
273
- const i = String(t[`border${n}Style`] || "solid"), r = String(t[`border${n}Color`] || "#CCCCCC");
274
- !K(i) || !K(r) || (o += `border-${n.toLowerCase()}:${s} ${i} ${r};`);
275
- }
276
- return o;
277
- }
278
- const Ce = (e) => e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;");
279
- function Ze(e, t, o, n = "email") {
280
- const s = parseInt(t.contentWidth || "600"), i = e.values.backgroundColor || "", r = e.values.columnsBackgroundColor || "", a = e.values.padding || "0px", l = e.cells.reduce((C, A) => C + A, 0), u = i ? `background-color:${i};` : "", c = e.values.backgroundImage;
281
- let d = "";
282
- if (c?.url) {
283
- const C = c.repeat === !0 || c.repeat === "repeat" ? "repeat" : "no-repeat", A = c.cover === !0 ? "cover" : c.fullWidth === !0 ? "100% auto" : "auto", E = c.center !== !1 ? "center top" : "left top";
284
- d = `background-image:url('${c.url}');background-repeat:${C};background-position:${E};background-size:${A};`;
305
+ const o = J(e[`border${n}Width`]).trim();
306
+ if (!Z(o) || parseFloat(o) <= 0) continue;
307
+ const s = J(e[`border${n}Style`]) || "solid", i = J(e[`border${n}Color`]) || "#CCCCCC";
308
+ !Z(s) || !Z(i) || (t += `border-${n.toLowerCase()}:${o} ${s} ${i};`);
285
309
  }
286
- const h = e.columns.length > 1, m = B(e.values), p = !!e.values.noStackMobile && e.columns.length > 1, f = !!m && "columnsBackgroundColor" in m, g = e.columns.map((C, A) => {
287
- const E = Math.round(e.cells[A] / l * s), ze = p ? +(e.cells[A] / l * 100).toFixed(4) : 0;
288
- return { colHtml: Ge(C, E, r, t, o, { pct: ze, colsBgHook: f, displayMode: n }), colWidthPx: E };
310
+ return t;
311
+ }
312
+ function Re(e) {
313
+ const t = (e ?? "").trim().split(/\s+/).filter(Boolean);
314
+ if (!t.length) return ["0px", "0px", "0px", "0px"];
315
+ const [n = "0px", o = n, s = n, i = o] = t;
316
+ return [n, o, s, i];
317
+ }
318
+ function ot(e) {
319
+ return Re(e).every((t) => /^0(\.0+)?([a-z%]+)?$/i.test(t));
320
+ }
321
+ function je(e, t = "") {
322
+ if (ot(e) && !t) return { open: "", close: "" };
323
+ const n = t ? `background-color:${t};` : "";
324
+ return {
325
+ open: `<!--[if mso]><table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td${t && /^#[0-9a-f]{3,8}$/i.test(t) ? ` bgcolor="${t}"` : ""} style="padding:${e};${n}"><![endif]-->`,
326
+ close: "<!--[if mso]></td></tr></table><![endif]-->"
327
+ };
328
+ }
329
+ function Oe(e) {
330
+ return `<!--[if !mso]><!-->${e}<!--<![endif]-->`;
331
+ }
332
+ function st(e, t, n, o = "email") {
333
+ const s = parseInt(t.contentWidth || "600"), i = e.values.backgroundColor || "", r = e.values.columnsBackgroundColor || "", c = e.values.padding || "0px", l = e.cells.reduce((_, M) => _ + M, 0), d = i ? `background-color:${i};` : "", u = ie(e.values.backgroundImage), a = u?.css ?? "", h = e.columns.length > 1, m = B(e.values), y = !!e.values.noStackMobile && e.columns.length > 1, b = !!m && "columnsBackgroundColor" in m, f = e.columns.map((_, M) => {
334
+ const z = (e.cells[M] ?? 0) / l, ae = Math.round(z * s), qe = y ? +(z * 100).toFixed(4) : 0;
335
+ return { colHtml: it(_, ae, r, t, n, { pct: qe, colsBgHook: b, displayMode: o }), colWidthPx: ae };
289
336
  });
290
- let y;
337
+ let p;
291
338
  if (h) {
292
- const C = g.map(
293
- ({ colHtml: A, colWidthPx: E }) => `<!--[if (mso)|(IE)]><td align="center" width="${E}" style="width:${E}px;padding:0px;" valign="top"><![endif]-->${A}<!--[if (mso)|(IE)]></td><![endif]-->`
339
+ const _ = f.map(
340
+ ({ colHtml: M, colWidthPx: z }) => `<!--[if (mso)|(IE)]><td align="center" width="${z}" style="width:${z}px;padding:0px;" valign="top"><![endif]-->${M}<!--[if (mso)|(IE)]></td><![endif]-->`
294
341
  );
295
- y = `<!--[if (mso)|(IE)]><table role="presentation" width="${s}" cellpadding="0" cellspacing="0" border="0"><tr><![endif]-->${C.join("")}<!--[if (mso)|(IE)]></tr></table><![endif]-->`;
342
+ p = `<!--[if (mso)|(IE)]><table role="presentation" width="${s}" cellpadding="0" cellspacing="0" border="0"><tr><![endif]-->${_.join("")}<!--[if (mso)|(IE)]></tr></table><![endif]-->`;
296
343
  } else
297
- y = g.map(({ colHtml: C }) => C).join("");
298
- const b = e.values.hideDesktop ? " u_hide_desktop" : "", v = e.values.hideMobile ? " u_hide_mobile" : "", w = h ? "font-size:0;" : "", $ = p ? " no-stack" : "", j = m ? ["padding", "backgroundColor"].filter((C) => C in m).map((C) => C === "padding" ? " v-padding" : " v-background-color").join("") : "", z = e.values._meta, _ = e.values.anchor || z?.htmlID || m ? H(e) : "", k = _ ? ` id="${Ce(_)}"` : "", x = `<div class="u_row${$}${b}${v}${j}"${k} style="padding:${a};${u}${d}">
299
- <div style="margin:0 auto;max-width:${s}px;${w}text-align:center;">${y}</div>
344
+ p = f.map(({ colHtml: _ }) => _).join("");
345
+ const g = e.values.hideDesktop ? " u_hide_desktop" : "", $ = e.values.hideMobile ? " u_hide_mobile" : "", w = h ? "font-size:0;" : "", v = y ? " no-stack" : "", x = m ? ["padding", "backgroundColor"].filter((_) => _ in m).map((_) => _ === "padding" ? " v-padding" : " v-background-color").join("") : "", E = e.values.anchor || e.values._meta?.htmlID || m ? H(e) : "", W = E ? ` id="${S(E)}"` : "", [A, , C] = Re(c), k = je(`${A} 0px ${C} 0px`), ce = u ? Ge(u, s, i) : { open: "", close: "" };
346
+ let K = `<div class="u_row${v}${g}${$}${x}"${W} style="padding:${c};${d}${a}">
347
+ ${ce.open}${k.open}<div style="margin:0 auto;max-width:${s}px;${w}text-align:center;">${p}</div>${k.close}${ce.close}
300
348
  </div>`;
301
- return oe(x, e.values.displayCondition);
349
+ return e.values.hideDesktop && (K = Oe(K)), re(K, e.values.displayCondition);
302
350
  }
303
- function Ge(e, t, o, n, s, i) {
304
- const r = e.values?.backgroundColor || "", a = r || o || "", l = i.colsBgHook && !r ? ' class="v-columns-background-color"' : "", u = e.values.padding || "0px", c = e.values.borderRadius || "0px", d = a ? `background-color:${a};` : "", h = _e(e, t, n, s, i.displayMode), m = `<div${l} style="width:100%;box-sizing:border-box;${d}${xe(e.values.border)}${c !== "0px" ? `border-radius:${c};` : ""}">
305
- <div style="padding:${u};">
351
+ function it(e, t, n, o, s, i) {
352
+ const r = e.values?.backgroundColor || "", c = r || n || "", l = i.colsBgHook && !r ? ' class="v-columns-background-color"' : "", d = e.values.padding || "0px", u = e.values.borderRadius || "0px", a = c ? `background-color:${c};` : "", h = Me(e, t, o, s, i.displayMode), m = je(d), y = `<div${l} style="width:100%;box-sizing:border-box;${a}${Ie(e.values.border)}${u !== "0px" ? `border-radius:${u};` : ""}">
353
+ ${m.open}<div style="padding:${d};">
306
354
  ${h || "&nbsp;"}
307
- </div>
355
+ </div>${m.close}
308
356
  </div>`;
309
357
  return i.pct ? `<div class="u_column_ns" style="display:inline-block;vertical-align:top;width:${i.pct}%;max-width:${t}px;">
310
358
  <div class="u_column" style="display:inline-block;vertical-align:top;width:100%;font-size:14px;text-align:left;">
311
- ${m}
359
+ ${y}
312
360
  </div>
313
361
  </div>` : `<div class="u_column" style="display:inline-block;vertical-align:top;width:100%;max-width:${t}px;font-size:14px;text-align:left;">
314
- ${m}
362
+ ${y}
315
363
  </div>`;
316
364
  }
317
- function _e(e, t, o, n, s) {
318
- const i = parseInt(o.contentWidth || "600");
365
+ function Me(e, t, n, o, s) {
366
+ const i = parseInt(n.contentWidth || "600");
319
367
  return e.contents.map((r) => {
320
- const a = n.get(r.type);
321
- if (!a) return `<!-- unknown tool: ${r.type} -->`;
322
- const l = { columnWidth: t, displayMode: s, contentWidth: i, bodyValues: o };
323
- let u = a(r.values, l);
324
- const c = !!r.values.hideDesktop, d = !!r.values.hideMobile;
325
- if ((c || d) && (u = `<div class="${[c && "u_hide_desktop", d && "u_hide_mobile"].filter(Boolean).join(" ")}">${u}</div>`), B(r.values)) {
326
- const h = se(r);
327
- h && !u.includes(`id="${h}"`) && (u = `<div id="${Ce(h)}">${u}</div>`);
368
+ const c = o.get(r.type);
369
+ if (!c) return `<!-- unknown tool: ${r.type} -->`;
370
+ const l = { columnWidth: t, displayMode: s, contentWidth: i, bodyValues: n };
371
+ let d = c(r.values, l);
372
+ const u = !!r.values.hideDesktop, a = !!r.values.hideMobile;
373
+ if ((u || a) && (d = `<div class="${[u && "u_hide_desktop", a && "u_hide_mobile"].filter(Boolean).join(" ")}">${d}</div>`, u && s === "email" && (d = Oe(d))), B(r.values)) {
374
+ const h = le(r);
375
+ h && !d.includes(`id="${h}"`) && (d = `<div id="${S(h)}">${d}</div>`);
328
376
  }
329
- return oe(u, r.values.displayCondition);
377
+ return re(d, r.values.displayCondition);
330
378
  }).join(`
331
379
  `);
332
380
  }
333
- const V = (e) => e.replace(/&(?![a-zA-Z0-9#]+;)/g, "&amp;").replace(/"/g, "&quot;"), Ke = (e) => e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), Ye = (e) => e.trim().replace(/['"()\\\s<>]/g, (t) => `%${t.charCodeAt(0).toString(16).toUpperCase().padStart(2, "0")}`), S = (e) => I(e) ?? "";
334
- function Se(e) {
335
- if (!e || typeof e != "object" || typeof e.url != "string" || !e.url.trim()) return "";
336
- const t = e.repeat === !0 || e.repeat === "repeat" ? "repeat" : "no-repeat", o = e.cover === !0 ? "cover" : e.fullWidth === !0 ? "100% auto" : "auto", n = e.center !== !1 ? "center top" : "left top";
337
- return `background-image:url('${Ye(e.url)}');background-repeat:${t};background-position:${n};background-size:${o};`;
338
- }
339
- function Xe(e, t, o) {
340
- const n = parseInt(t.contentWidth || "600") || 600, s = e.cells.reduce((b, v) => b + v, 0) || 1, i = e.values.backgroundColor ? `background-color:${S(e.values.backgroundColor)};` : "", r = Se(e.values.backgroundImage), a = S(e.values.padding || "0px"), l = B(e.values), u = !!e.values.noStackMobile && e.columns.length > 1, c = !!l && "columnsBackgroundColor" in l, d = e.values.columnsBackgroundColor || "", h = e.columns.map((b, v) => Je(b, e.cells[v] ?? 1, Math.round((e.cells[v] ?? 1) / s * n), d, c, t, o)).join(`
381
+ const I = (e) => j(e) ?? "";
382
+ function rt(e, t, n) {
383
+ const o = parseInt(t.contentWidth || "600") || 600, s = e.cells.reduce((p, g) => p + g, 0) || 1, i = e.values.backgroundColor ? `background-color:${I(e.values.backgroundColor)};` : "", r = Ce(e.values.backgroundImage), c = I(e.values.padding || "0px"), l = B(e.values), d = !!e.values.noStackMobile && e.columns.length > 1, u = !!l && "columnsBackgroundColor" in l, a = e.values.columnsBackgroundColor || "", h = e.columns.map((p, g) => lt(p, e.cells[g] ?? 1, Math.round((e.cells[g] ?? 1) / s * o), a, u, t, n)).join(`
341
384
  `), m = ["u_row"];
342
- u && m.push("no-stack"), e.values.hideDesktop && m.push("u_hide_desktop"), e.values.hideMobile && m.push("u_hide_mobile"), l && ("padding" in l && m.push("v-padding"), "backgroundColor" in l && m.push("v-background-color"));
343
- const p = e.values._meta, f = e.values.anchor || p?.htmlID || l ? H(e) : "", g = f ? ` id="${V(f)}"` : "", y = `<div class="${m.join(" ")}"${g} style="padding:${a};${i}${r}">
385
+ d && m.push("no-stack"), e.values.hideDesktop && m.push("u_hide_desktop"), e.values.hideMobile && m.push("u_hide_mobile"), l && ("padding" in l && m.push("v-padding"), "backgroundColor" in l && m.push("v-background-color"));
386
+ const y = e.values.anchor || e.values._meta?.htmlID || l ? H(e) : "", b = y ? ` id="${S(y)}"` : "", f = `<div class="${m.join(" ")}"${b} style="padding:${c};${i}${r}">
344
387
  <div class="u_row_inner">
345
388
  ${h}
346
389
  </div>
347
390
  </div>`;
348
- return oe(Qe(y), e.values.displayCondition);
391
+ return re(ct(f), e.values.displayCondition);
349
392
  }
350
- function Je(e, t, o, n, s, i, r) {
351
- const a = e.values?.backgroundColor || "", l = a || n, u = s && !a ? " v-columns-background-color" : "", c = e.values?.borderRadius && e.values.borderRadius !== "0px" ? `border-radius:${S(e.values.borderRadius)};` : "", d = S(e.values?.padding || "0px"), h = _e(e, o, i, r, "web");
393
+ function lt(e, t, n, o, s, i, r) {
394
+ const c = e.values?.backgroundColor || "", l = c || o, d = s && !c ? " v-columns-background-color" : "", u = e.values?.borderRadius && e.values.borderRadius !== "0px" ? `border-radius:${I(e.values.borderRadius)};` : "", a = I(e.values?.padding || "0px"), h = Me(e, n, i, r, "web");
352
395
  return ` <div class="u_column" style="flex:${+t || 1} 1 0%;">
353
- <div class="u_column_inner${u}" style="${l ? `background-color:${S(l)};` : ""}${xe(e.values?.border)}${c}padding:${d};">
396
+ <div class="u_column_inner${d}" style="${l ? `background-color:${I(l)};` : ""}${Ie(e.values?.border)}${u}padding:${a};">
354
397
  ${h}
355
398
  </div>
356
399
  </div>`;
357
400
  }
358
- function Qe(e) {
401
+ function ct(e) {
359
402
  return !e.includes("<!--[if") && !e.includes("<![endif]") ? e : e.replace(/<!--\[if [^\]]*\]>(?!<!-->)[\s\S]*?<!\[endif\]-->/gi, "").replace(/<!--\[if [^\]]*\]><!-->/gi, "").replace(/<!--<!\[endif\]-->/gi, "");
360
403
  }
361
- function Ve(e) {
404
+ function at(e) {
362
405
  return `*, *::before, *::after { box-sizing: border-box; }
363
406
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
364
407
  body { margin: 0; padding: 0; }
@@ -370,7 +413,7 @@ table { border-collapse: collapse; }
370
413
  .u_row_inner { display: flex; flex-wrap: nowrap; align-items: stretch; max-width: ${e}px; margin: 0 auto; }
371
414
  .u_column { min-width: 0; }
372
415
  .u_column_inner { height: 100%; }
373
- @media ${q(e)} {
416
+ @media ${N(e)} {
374
417
  .u_row:not(.no-stack) > .u_row_inner { flex-direction: column; }
375
418
  .u_row:not(.no-stack) > .u_row_inner > .u_column { flex: 0 0 auto !important; width: 100% !important; }
376
419
  .u_hide_mobile { display: none !important; }
@@ -379,29 +422,29 @@ table { border-collapse: collapse; }
379
422
  .u_hide_desktop { display: none !important; }
380
423
  }`;
381
424
  }
382
- function et(e) {
425
+ function ut(e) {
383
426
  if (!e || typeof e != "object") return "";
384
- const t = (s, i) => [s ? `color: ${S(s)};` : "", typeof i == "boolean" ? `text-decoration: ${i ? "underline" : "none"};` : ""].filter(Boolean).join(" "), o = t(e.linkColor, e.linkUnderline), n = t(e.linkHoverColor, e.linkHoverUnderline);
385
- return (o ? `
386
- .u_body a { ${o} }` : "") + (n ? `
387
- .u_body a:hover { ${n} }` : "");
388
- }
389
- function tt(e, t, o = {}) {
390
- const n = parseInt(t.contentWidth || "600") || 600, s = S(t.backgroundColor || "#ffffff"), i = S(t.textColor || "#000000"), r = S(t.fontFamily?.value || "arial,helvetica,sans-serif"), a = be(t), l = a ? ` font-weight: ${a};` : "", u = he(t, o.title), c = Se(t.backgroundImage), d = et(t.linkStyle), h = (o.fontUrls ?? []).map((f) => `
391
- <link href="${V(f)}" rel="stylesheet">`).join(""), m = (o.styles ?? []).map((f) => `
427
+ const t = (s, i) => [s ? `color: ${I(s)};` : "", typeof i == "boolean" ? `text-decoration: ${i ? "underline" : "none"};` : ""].filter(Boolean).join(" "), n = t(e.linkColor, e.linkUnderline), o = t(e.linkHoverColor, e.linkHoverUnderline);
428
+ return (n ? `
429
+ .u_body a { ${n} }` : "") + (o ? `
430
+ .u_body a:hover { ${o} }` : "");
431
+ }
432
+ function dt(e, t, n = {}) {
433
+ const o = parseInt(t.contentWidth || "600") || 600, s = I(t.backgroundColor || "#ffffff"), i = I(t.textColor || "#000000"), r = I(t.fontFamily?.value || "arial,helvetica,sans-serif"), c = xe(t), l = c ? ` font-weight: ${c};` : "", d = we(t, n.title), u = Ce(t.backgroundImage), a = ut(t.linkStyle), h = (n.fontUrls ?? []).map((b) => `
434
+ <link href="${S(b)}" rel="stylesheet">`).join(""), m = (n.styles ?? []).map((b) => `
392
435
  <style>
393
- ${f}
436
+ ${b}
394
437
  </style>`).join("");
395
438
  return `<!DOCTYPE html>
396
- <html lang="${V(o.lang || ye(t) || "en")}">
439
+ <html lang="${S(n.lang || ke(t) || "en")}">
397
440
  <head>
398
441
  <meta charset="utf-8">
399
442
  <meta name="viewport" content="width=device-width, initial-scale=1">
400
- <title>${u ? Ke(u) : ""}</title>${h}
443
+ <title>${d ? ee(d) : ""}</title>${h}
401
444
  <style>
402
- ${Ve(n)}
445
+ ${at(o)}
403
446
  body { background-color: ${s}; color: ${i}; font-family: ${r};${l} }
404
- .u_body { background-color: ${s};${c ? ` ${c.replace(/;(?=.)/g, "; ")}` : ""} }${d}
447
+ .u_body { background-color: ${s};${u ? ` ${u.replace(/;(?=.)/g, "; ")}` : ""} }${a}
405
448
  </style>${m}
406
449
  </head>
407
450
  <body>
@@ -411,60 +454,57 @@ ${e}
411
454
  </body>
412
455
  </html>`;
413
456
  }
414
- const N = (e) => !!e && typeof e == "object" && !Array.isArray(e);
415
- function Te(e) {
416
- if (!N(e) || !N(e._override)) return null;
417
- const t = e._override.dark;
418
- return N(t) && Object.keys(t).length ? t : null;
457
+ function ze(e) {
458
+ return Se(e, "dark");
419
459
  }
420
- const nt = (e) => /color$/.test(e.property);
421
- function Ae(e, t) {
422
- const o = /* @__PURE__ */ new Map();
423
- for (const n of e.filter(nt)) o.set(n.className, [...o.get(n.className) ?? [], n]);
424
- return [...o].map(([n, s]) => ({ selector: t(n), decls: s }));
460
+ const ft = (e) => /color$/.test(e.property);
461
+ function De(e, t) {
462
+ const n = /* @__PURE__ */ new Map();
463
+ for (const o of e.filter(ft)) n.set(o.className, [...n.get(o.className) ?? [], o]);
464
+ return [...n].map(([o, s]) => ({ selector: t(o), decls: s }));
425
465
  }
426
- function ot(e) {
427
- const t = Te(e.values);
466
+ function pt(e) {
467
+ const t = ze(e.values);
428
468
  if (!t) return [];
429
- const o = U(se(e));
430
- return o ? Ae(Z(t), (n) => `#${o} .${n}, #${o}.${n}`) : [];
469
+ const n = F(le(e));
470
+ return n ? De(U(t), (o) => `#${n} .${o}, #${n}.${o}`) : [];
431
471
  }
432
- function st(e) {
433
- const t = Te(e.values);
472
+ function mt(e) {
473
+ const t = ze(e.values);
434
474
  if (!t) return [];
435
- const o = U(H(e));
436
- return o ? Ae(Z(t), (n) => n === "v-columns-background-color" ? `#${o} .${n}` : `#${o}.${n}`) : [];
475
+ const n = F(H(e));
476
+ return n ? De(U(t), (o) => o === "v-columns-background-color" ? `#${n} .${o}` : `#${n}.${o}`) : [];
437
477
  }
438
- function it(e) {
478
+ function ht(e) {
439
479
  const t = e.body?.values?.darkMode;
440
- if (!N(t)) return [];
441
- const o = [], n = I(t.backgroundColor), s = I(t.textColor), i = I(t.linkColor);
442
- return n && o.push({ selector: "body, .u_body, #u_body", decls: [{ className: "", property: "background-color", value: n }] }), s && o.push({ selector: "body, .u_body, #u_body, .u_body .v-color", decls: [{ className: "", property: "color", value: s }] }), i && o.push({ selector: ".u_body a, #u_body a", decls: [{ className: "", property: "color", value: i }] }), o;
443
- }
444
- function ln(e) {
445
- return Ee(e) !== "";
446
- }
447
- function Ee(e) {
448
- const t = [...it(e)];
449
- for (const r of ne(e)) {
450
- t.push(...st(r));
451
- for (const a of r.columns ?? []) for (const l of a.contents ?? []) t.push(...ot(l));
480
+ if (!T(t)) return [];
481
+ const n = [], o = j(t.backgroundColor), s = j(t.textColor), i = j(t.linkColor);
482
+ return o && n.push({ selector: "body, .u_body, #u_body", decls: [{ className: "", property: "background-color", value: o }] }), s && n.push({ selector: "body, .u_body, #u_body, .u_body .v-color", decls: [{ className: "", property: "color", value: s }] }), i && n.push({ selector: ".u_body a, #u_body a", decls: [{ className: "", property: "color", value: i }] }), n;
483
+ }
484
+ function yn(e) {
485
+ return Be(e) !== "";
486
+ }
487
+ function Be(e) {
488
+ const t = [...ht(e)];
489
+ for (const r of se(e)) {
490
+ t.push(...mt(r));
491
+ for (const c of r.columns ?? []) for (const l of c.contents ?? []) t.push(...pt(l));
452
492
  }
453
493
  if (!t.length) return "";
454
- const o = (r) => `${r.property}: ${r.value} !important;`, n = t.map((r) => ` ${r.selector} { ${r.decls.map(o).join(" ")} }`).join(`
455
- `), s = (r, a) => t.map((l) => ({ sel: l.selector.split(",").map((u) => `[${r}] ${u.trim()}`).join(", "), decls: l.decls.filter(a) })).filter((l) => l.decls.length).map((l) => `${l.sel} { ${l.decls.map(o).join(" ")} }`).join(`
494
+ const n = (r) => `${r.property}: ${r.value} !important;`, o = t.map((r) => ` ${r.selector} { ${r.decls.map(n).join(" ")} }`).join(`
495
+ `), s = (r, c) => t.map((l) => ({ sel: l.selector.split(",").map((d) => `[${r}] ${d.trim()}`).join(", "), decls: l.decls.filter(c) })).filter((l) => l.decls.length).map((l) => `${l.sel} { ${l.decls.map(n).join(" ")} }`).join(`
456
496
  `), i = (r) => r.property === "background-color";
457
497
  return [
458
498
  ":root { color-scheme: light dark; supported-color-schemes: light dark; }",
459
499
  `@media (prefers-color-scheme: dark) {
460
- ${n}
500
+ ${o}
461
501
  }`,
462
502
  s("data-ogsc", (r) => !i(r)),
463
503
  s("data-ogsb", i)
464
504
  ].filter(Boolean).join(`
465
505
  `);
466
506
  }
467
- const rt = [
507
+ const gt = [
468
508
  "box-sizing",
469
509
  "overflow-wrap",
470
510
  "word-break",
@@ -478,17 +518,17 @@ const rt = [
478
518
  "display:\\s*flex",
479
519
  "display:\\s*grid",
480
520
  "gap"
481
- ], lt = new RegExp(
482
- `(?:;\\s*|^\\s*)(${rt.join("|")})\\s*:[^;]*`,
521
+ ], yt = new RegExp(
522
+ `(?:;\\s*|^\\s*)(${gt.join("|")})\\s*:[^;]*`,
483
523
  "gi"
484
- ), at = /var\(--[^)]*\)/gi;
485
- function ct(e) {
486
- return e.replace(/style="([^"]*)"/gi, (t, o) => {
487
- let n = o;
488
- return n = n.replace(lt, ";"), n = n.replace(at, "inherit"), n = n.replace(/;(\s*;)+/g, ";").replace(/^\s*;\s*/, "").replace(/;\s*$/, "").trim(), n ? `style="${n}"` : "";
524
+ ), bt = /var\(--[^)]*\)/gi;
525
+ function $t(e) {
526
+ return e.replace(/style="([^"]*)"/gi, (t, n) => {
527
+ let o = n;
528
+ return o = o.replace(yt, ";"), o = o.replace(bt, "inherit"), o = o.replace(/;(\s*;)+/g, ";").replace(/^\s*;\s*/, "").replace(/;\s*$/, "").trim(), o ? `style="${o}"` : "";
489
529
  });
490
530
  }
491
- const ut = /* @__PURE__ */ new Set(["style", "script", "textarea", "title"]), ee = /* @__PURE__ */ new Set([
531
+ const vt = /* @__PURE__ */ new Set(["style", "script", "textarea", "title"]), ne = /* @__PURE__ */ new Set([
492
532
  "area",
493
533
  "base",
494
534
  "br",
@@ -505,429 +545,431 @@ const ut = /* @__PURE__ */ new Set(["style", "script", "textarea", "title"]), ee
505
545
  "wbr"
506
546
  ]);
507
547
  function O(e) {
508
- const t = [], o = e.length;
509
- let n = 0, s = 0;
548
+ const t = [], n = e.length;
549
+ let o = 0, s = 0;
510
550
  const i = (r) => {
511
551
  r > s && t.push({ type: "text", raw: e.slice(s, r) });
512
552
  };
513
- for (; n < o; ) {
514
- const r = e.indexOf("<", n);
553
+ for (; o < n; ) {
554
+ const r = e.indexOf("<", o);
515
555
  if (r === -1) break;
516
- const a = e.charAt(r + 1);
556
+ const c = e.charAt(r + 1);
517
557
  if (e.startsWith("<!--", r)) {
518
- const l = e.indexOf("-->", r + 4), u = l === -1 ? o : l + 3;
519
- i(r), t.push({ type: "comment", raw: e.slice(r, u) }), n = s = u;
558
+ const l = e.indexOf("-->", r + 4), d = l === -1 ? n : l + 3;
559
+ i(r), t.push({ type: "comment", raw: e.slice(r, d) }), o = s = d;
520
560
  continue;
521
561
  }
522
- if (a === "!" || a === "?") {
523
- const l = e.indexOf(">", r + 2), u = l === -1 ? o : l + 1;
524
- i(r), t.push({ type: "doctype", raw: e.slice(r, u) }), n = s = u;
562
+ if (c === "!" || c === "?") {
563
+ const l = e.indexOf(">", r + 2), d = l === -1 ? n : l + 1;
564
+ i(r), t.push({ type: "doctype", raw: e.slice(r, d) }), o = s = d;
525
565
  continue;
526
566
  }
527
- if (a === "/" && /[a-zA-Z]/.test(e.charAt(r + 2))) {
528
- const l = e.indexOf(">", r + 2), u = l === -1 ? o : l + 1, c = e.slice(r + 2, l === -1 ? o : l).trim().split(/\s/)[0].toLowerCase();
529
- i(r), t.push({ type: "close", name: c, raw: e.slice(r, u) }), n = s = u;
567
+ if (c === "/" && /[a-zA-Z]/.test(e.charAt(r + 2))) {
568
+ const l = e.indexOf(">", r + 2), d = l === -1 ? n : l + 1, u = e.slice(r + 2, l === -1 ? n : l).trim().split(/\s/, 1)[0]?.toLowerCase() ?? "";
569
+ i(r), t.push({ type: "close", name: u, raw: e.slice(r, d) }), o = s = d;
530
570
  continue;
531
571
  }
532
- if (/[a-zA-Z]/.test(a)) {
533
- const l = dt(e, r);
572
+ if (/[a-zA-Z]/.test(c)) {
573
+ const l = wt(e, r);
534
574
  if (!l) {
535
- n = r + 1;
575
+ o = r + 1;
536
576
  continue;
537
577
  }
538
- if (i(r), t.push(l.token), n = s = l.end, ut.has(l.token.name) && !l.token.selfClosing) {
539
- const u = new RegExp(`</${l.token.name}\\s*>`, "ig");
540
- u.lastIndex = n;
541
- const c = u.exec(e), d = c ? c.index : o;
542
- d > n && t.push({ type: "rawtext", parent: l.token.name, raw: e.slice(n, d) }), c ? (t.push({ type: "close", name: l.token.name, raw: c[0] }), n = s = d + c[0].length) : n = s = o;
578
+ if (i(r), t.push(l.token), o = s = l.end, vt.has(l.token.name) && !l.token.selfClosing) {
579
+ const d = new RegExp(`</${l.token.name}\\s*>`, "ig");
580
+ d.lastIndex = o;
581
+ const u = d.exec(e), a = u ? u.index : n;
582
+ a > o && t.push({ type: "rawtext", parent: l.token.name, raw: e.slice(o, a) }), u ? (t.push({ type: "close", name: l.token.name, raw: u[0] }), o = s = a + u[0].length) : o = s = n;
543
583
  }
544
584
  continue;
545
585
  }
546
- n = r + 1;
586
+ o = r + 1;
547
587
  }
548
- return i(o), t;
588
+ return i(n), t;
549
589
  }
550
- function dt(e, t) {
551
- const o = e.length;
552
- let n = t + 1;
553
- const s = /^[a-zA-Z][^\s/>]*/.exec(e.slice(n, n + 128));
590
+ function wt(e, t) {
591
+ const n = e.length;
592
+ let o = t + 1;
593
+ const s = /^[a-zA-Z][^\s/>]*/.exec(e.slice(o, o + 128));
554
594
  if (!s) return null;
555
595
  const i = s[0].toLowerCase();
556
- n += s[0].length;
596
+ o += s[0].length;
557
597
  const r = [];
558
- let a = !1;
559
- for (; n < o; ) {
560
- for (; n < o && /\s/.test(e.charAt(n)); ) n++;
561
- const l = e.charAt(n);
598
+ let c = !1;
599
+ for (; o < n; ) {
600
+ for (; o < n && /\s/.test(e.charAt(o)); ) o++;
601
+ const l = e.charAt(o);
562
602
  if (l === ">")
563
- return n++, { token: { type: "open", name: i, attrs: r, selfClosing: a, raw: e.slice(t, n) }, end: n };
603
+ return o++, { token: { type: "open", name: i, attrs: r, selfClosing: c, raw: e.slice(t, o) }, end: o };
564
604
  if (l === "/") {
565
- if (n++, e.charAt(n) === ">")
566
- return a = !0, n++, { token: { type: "open", name: i, attrs: r, selfClosing: a, raw: e.slice(t, n) }, end: n };
605
+ if (o++, e.charAt(o) === ">")
606
+ return c = !0, o++, { token: { type: "open", name: i, attrs: r, selfClosing: c, raw: e.slice(t, o) }, end: o };
567
607
  continue;
568
608
  }
569
- if (n >= o) break;
570
- const u = n;
571
- for (; n < o && !/[\s=/>]/.test(e.charAt(n)); ) n++;
572
- if (n === u) {
573
- n++;
609
+ if (o >= n) break;
610
+ const d = o;
611
+ for (; o < n && !/[\s=/>]/.test(e.charAt(o)); ) o++;
612
+ if (o === d) {
613
+ o++;
574
614
  continue;
575
615
  }
576
- const c = e.slice(u, n).toLowerCase();
577
- let d = n;
578
- for (; d < o && /\s/.test(e.charAt(d)); ) d++;
579
- if (e.charAt(d) === "=") {
580
- for (d++; d < o && /\s/.test(e.charAt(d)); ) d++;
581
- const h = e.charAt(d);
616
+ const u = e.slice(d, o).toLowerCase();
617
+ let a = o;
618
+ for (; a < n && /\s/.test(e.charAt(a)); ) a++;
619
+ if (e.charAt(a) === "=") {
620
+ for (a++; a < n && /\s/.test(e.charAt(a)); ) a++;
621
+ const h = e.charAt(a);
582
622
  if (h === '"' || h === "'") {
583
- const m = e.indexOf(h, d + 1), p = m === -1 ? o : m;
584
- r.push({ name: c, value: e.slice(d + 1, p), quote: h }), n = m === -1 ? o : m + 1;
623
+ const m = e.indexOf(h, a + 1), y = m === -1 ? n : m;
624
+ r.push({ name: u, value: e.slice(a + 1, y), quote: h }), o = m === -1 ? n : m + 1;
585
625
  } else {
586
- const m = d;
587
- for (; d < o && !/[\s>]/.test(e.charAt(d)); ) d++;
588
- r.push({ name: c, value: e.slice(m, d), quote: "" }), n = d;
626
+ const m = a;
627
+ for (; a < n && !/[\s>]/.test(e.charAt(a)); ) a++;
628
+ r.push({ name: u, value: e.slice(m, a), quote: "" }), o = a;
589
629
  }
590
630
  } else
591
- r.push({ name: c, value: null, quote: "" });
631
+ r.push({ name: u, value: null, quote: "" });
592
632
  }
593
633
  return null;
594
634
  }
595
- function ft(e) {
635
+ function kt(e) {
596
636
  let t = `<${e.name}`;
597
- for (const o of e.attrs) {
598
- if (o.value === null) {
599
- t += ` ${o.name}`;
637
+ for (const n of e.attrs) {
638
+ if (n.value === null) {
639
+ t += ` ${n.name}`;
600
640
  continue;
601
641
  }
602
- let n = o.quote || '"';
603
- n === "'" && o.value.includes("'") && (n = '"');
604
- const s = n === '"' ? o.value.replace(/"/g, "&quot;") : o.value;
605
- t += ` ${o.name}=${n}${s}${n}`;
642
+ let o = n.quote || '"';
643
+ o === "'" && n.value.includes("'") && (o = '"');
644
+ const s = o === '"' ? n.value.replace(/"/g, "&quot;") : n.value;
645
+ t += ` ${n.name}=${o}${s}${o}`;
606
646
  }
607
647
  return t += e.selfClosing ? " />" : ">", t;
608
648
  }
609
- function W(e) {
649
+ function P(e) {
610
650
  let t = "";
611
- for (const o of e)
612
- t += o.type === "open" && o.dirty ? ft(o) : o.raw;
651
+ for (const n of e)
652
+ t += n.type === "open" && n.dirty ? kt(n) : n.raw;
613
653
  return t;
614
654
  }
615
- function T(e, t) {
616
- const o = e.attrs.find((n) => n.name === t);
617
- return o ? o.value : void 0;
655
+ function R(e, t) {
656
+ const n = e.attrs.find((o) => o.name === t);
657
+ return n ? n.value : void 0;
618
658
  }
619
- function pt(e, t, o) {
620
- const n = e.attrs.find((s) => s.name === t);
621
- n ? (n.value = o, n.quote || (n.quote = '"')) : e.attrs.push({ name: t, value: o, quote: '"' }), e.dirty = !0;
659
+ function xt(e, t, n) {
660
+ const o = e.attrs.find((s) => s.name === t);
661
+ o ? (o.value = n, o.quote || (o.quote = '"')) : e.attrs.push({ name: t, value: n, quote: '"' }), e.dirty = !0;
622
662
  }
623
- function mt(e) {
663
+ function Ct(e) {
624
664
  const t = e.slice(4, e.endsWith("-->") ? -3 : void 0).trim();
625
665
  return /^\[if\b/i.test(t) || /^<!\[endif\]/i.test(t) || /<!\[endif\]$/i.test(t);
626
666
  }
627
- function je(e) {
628
- let t = "", o = 0;
629
- for (; o < e.length; ) {
630
- const n = e[o];
631
- if (n === '"' || n === "'") {
632
- const s = G(e, o);
633
- t += e.slice(o, s), o = s;
634
- } else if (n === "/" && e[o + 1] === "*") {
635
- const s = e.indexOf("*/", o + 2);
636
- o = s === -1 ? e.length : s + 2;
667
+ function Pe(e) {
668
+ let t = "", n = 0;
669
+ for (; n < e.length; ) {
670
+ const o = e.charAt(n);
671
+ if (o === '"' || o === "'") {
672
+ const s = G(e, n);
673
+ t += e.slice(n, s), n = s;
674
+ } else if (o === "/" && e[n + 1] === "*") {
675
+ const s = e.indexOf("*/", n + 2);
676
+ n = s === -1 ? e.length : s + 2;
637
677
  } else
638
- t += n, o++;
678
+ t += o, n++;
639
679
  }
640
680
  return t;
641
681
  }
642
682
  function G(e, t) {
643
- const o = e[t];
644
- let n = t + 1;
645
- for (; n < e.length; ) {
646
- if (e[n] === "\\") {
647
- n += 2;
683
+ const n = e.charAt(t);
684
+ let o = t + 1;
685
+ for (; o < e.length; ) {
686
+ if (e[o] === "\\") {
687
+ o += 2;
648
688
  continue;
649
689
  }
650
- if (e[n] === o || e[n] === `
651
- `) return n + 1;
652
- n++;
690
+ if (e[o] === n || e[o] === `
691
+ `) return o + 1;
692
+ o++;
653
693
  }
654
694
  return e.length;
655
695
  }
656
- function F(e, t, o) {
657
- let n = 0, s = t;
696
+ function q(e, t, n) {
697
+ let o = 0, s = t;
658
698
  for (; s < e.length; ) {
659
- const i = e[s];
699
+ const i = e.charAt(s);
660
700
  if (i === '"' || i === "'") {
661
701
  s = G(e, s);
662
702
  continue;
663
703
  }
664
- if (i === "(" || i === "[") n++;
665
- else if (i === ")" || i === "]") n = Math.max(0, n - 1);
666
- else if (n === 0 && o.includes(i)) return s;
704
+ if (i === "(" || i === "[") o++;
705
+ else if (i === ")" || i === "]") o = Math.max(0, o - 1);
706
+ else if (o === 0 && n.includes(i)) return s;
667
707
  s++;
668
708
  }
669
709
  return -1;
670
710
  }
671
- function re(e, t) {
672
- let o = 0, n = t;
673
- for (; n < e.length; ) {
674
- const s = e[n];
711
+ function fe(e, t) {
712
+ let n = 0, o = t;
713
+ for (; o < e.length; ) {
714
+ const s = e.charAt(o);
675
715
  if (s === '"' || s === "'") {
676
- n = G(e, n);
716
+ o = G(e, o);
677
717
  continue;
678
718
  }
679
- if (s === "{") o++;
680
- else if (s === "}" && (o--, o === 0))
681
- return n;
682
- n++;
719
+ if (s === "{") n++;
720
+ else if (s === "}" && (n--, n === 0))
721
+ return o;
722
+ o++;
683
723
  }
684
724
  return e.length - 1;
685
725
  }
686
- function Ie(e, t) {
687
- const o = [];
688
- let n = 0, s = F(e, 0, t);
726
+ function We(e, t) {
727
+ const n = [];
728
+ let o = 0, s = q(e, 0, t);
689
729
  for (; s !== -1; )
690
- o.push(e.slice(n, s)), n = s + 1, s = F(e, n, t);
691
- return o.push(e.slice(n)), o;
730
+ n.push(e.slice(o, s)), o = s + 1, s = q(e, o, t);
731
+ return n.push(e.slice(o)), n;
692
732
  }
693
- function Re(e) {
733
+ function Le(e) {
694
734
  const t = [];
695
- for (const o of Ie(e, ";")) {
696
- const n = o.indexOf(":");
697
- if (n === -1) continue;
698
- const s = o.slice(0, n).trim().toLowerCase();
699
- let i = o.slice(n + 1).trim();
735
+ for (const n of We(e, ";")) {
736
+ const o = n.indexOf(":");
737
+ if (o === -1) continue;
738
+ const s = n.slice(0, o).trim().toLowerCase();
739
+ let i = n.slice(o + 1).trim();
700
740
  if (!s || !i) continue;
701
741
  let r = !1;
702
- const a = /\s*!\s*important\s*$/i.exec(i);
703
- a && (r = !0, i = i.slice(0, a.index).trim()), t.push({ property: s, value: i, important: r });
742
+ const c = /\s*!\s*important\s*$/i.exec(i);
743
+ c && (r = !0, i = i.slice(0, c.index).trim()), t.push({ property: s, value: i, important: r });
704
744
  }
705
745
  return t;
706
746
  }
707
- function le(e) {
747
+ function pe(e) {
708
748
  return e.map((t) => `${t.property}:${t.value}${t.important ? " !important" : ""}`).join(";");
709
749
  }
710
- function gt(e) {
711
- const t = je(e), o = [];
712
- let n = 0;
713
- for (; n < t.length; ) {
714
- for (; n < t.length && /[\s;]/.test(t[n]); ) n++;
715
- if (t.startsWith("<!--", n)) {
716
- n += 4;
750
+ function _t(e) {
751
+ const t = Pe(e), n = [];
752
+ let o = 0;
753
+ for (; o < t.length; ) {
754
+ for (; o < t.length && /[\s;]/.test(t.charAt(o)); ) o++;
755
+ if (t.startsWith("<!--", o)) {
756
+ o += 4;
717
757
  continue;
718
758
  }
719
- if (t.startsWith("-->", n)) {
720
- n += 3;
759
+ if (t.startsWith("-->", o)) {
760
+ o += 3;
721
761
  continue;
722
762
  }
723
- if (n >= t.length) break;
724
- if (t[n] === "@") {
725
- const u = (/^@([\w-]+)/.exec(t.slice(n))?.[1] ?? "").toLowerCase(), c = F(t, n, ";{");
726
- if (c === -1) {
727
- o.push({ type: "at-rule", name: u, raw: t.slice(n).trim() });
763
+ if (o >= t.length) break;
764
+ if (t[o] === "@") {
765
+ const d = (/^@([\w-]+)/.exec(t.slice(o))?.[1] ?? "").toLowerCase(), u = q(t, o, ";{");
766
+ if (u === -1) {
767
+ n.push({ type: "at-rule", name: d, raw: t.slice(o).trim() });
728
768
  break;
729
769
  }
730
- if (t[c] === ";")
731
- o.push({ type: "at-rule", name: u, raw: t.slice(n, c + 1).trim() }), n = c + 1;
770
+ if (t[u] === ";")
771
+ n.push({ type: "at-rule", name: d, raw: t.slice(o, u + 1).trim() }), o = u + 1;
732
772
  else {
733
- const d = re(t, c);
734
- o.push({ type: "at-rule", name: u, raw: t.slice(n, d + 1).trim() }), n = d + 1;
773
+ const a = fe(t, u);
774
+ n.push({ type: "at-rule", name: d, raw: t.slice(o, a + 1).trim() }), o = a + 1;
735
775
  }
736
776
  continue;
737
777
  }
738
- const s = F(t, n, "{");
778
+ const s = q(t, o, "{");
739
779
  if (s === -1) break;
740
- const i = re(t, s), r = t.slice(n, s).trim(), a = t.slice(s + 1, i);
741
- o.push({
780
+ const i = fe(t, s), r = t.slice(o, s).trim(), c = t.slice(s + 1, i);
781
+ n.push({
742
782
  type: "rule",
743
- selectors: Ie(r, ",").map((l) => l.trim()).filter(Boolean),
744
- declarations: Re(a),
745
- raw: t.slice(n, i + 1).trim()
746
- }), n = i + 1;
783
+ selectors: We(r, ",").map((l) => l.trim()).filter(Boolean),
784
+ declarations: Le(c),
785
+ raw: t.slice(o, i + 1).trim()
786
+ }), o = i + 1;
747
787
  }
748
- return o;
788
+ return n;
749
789
  }
750
- const ht = /^@(?:-[a-z]+-)?(?:media|supports|document|container|layer|keyframes)\b/i;
751
- function yt(e) {
752
- const t = je(e);
753
- let o = "", n = 0;
790
+ const St = /^@(?:-[a-z]+-)?(?:media|supports|document|container|layer|keyframes)\b/i;
791
+ function At(e) {
792
+ const t = Pe(e);
793
+ let n = "", o = 0;
754
794
  const s = [];
755
795
  let i = 0;
756
796
  const r = () => s.length > 0 && s[s.length - 1];
757
- for (; n < t.length; ) {
758
- const a = t[n];
759
- if (a === '"' || a === "'") {
760
- const l = G(t, n);
761
- o += t.slice(n, l), n = l;
797
+ for (; o < t.length; ) {
798
+ const c = t.charAt(o);
799
+ if (c === '"' || c === "'") {
800
+ const l = G(t, o);
801
+ n += t.slice(o, l), o = l;
762
802
  continue;
763
803
  }
764
- if (/\s/.test(a)) {
765
- for (; n < t.length && /\s/.test(t[n]); ) n++;
766
- const l = o[o.length - 1], u = t[n];
767
- if (l === void 0 || u === void 0 || "{};,>".includes(l) || "{};,>".includes(u) || l === ":" || u === ":" && r()) continue;
768
- o += " ";
804
+ if (/\s/.test(c)) {
805
+ for (; o < t.length && /\s/.test(t.charAt(o)); ) o++;
806
+ const l = n.at(-1);
807
+ if (l === void 0 || o >= t.length) continue;
808
+ const d = t.charAt(o);
809
+ if ("{};,>".includes(l) || "{};,>".includes(d) || l === ":" || d === ":" && r()) continue;
810
+ n += " ";
769
811
  continue;
770
812
  }
771
- if (a === "{") {
772
- const l = o.slice(i).trim();
773
- s.push(!ht.test(l)), o += a, i = o.length, n++;
813
+ if (c === "{") {
814
+ const l = n.slice(i).trim();
815
+ s.push(!St.test(l)), n += c, i = n.length, o++;
774
816
  continue;
775
817
  }
776
- a === "}" && (o[o.length - 1] === ";" && (o = o.slice(0, -1)), s.pop()), o += a, (a === "}" || a === ";") && (i = o.length), n++;
818
+ c === "}" && (n[n.length - 1] === ";" && (n = n.slice(0, -1)), s.pop()), n += c, (c === "}" || c === ";") && (i = n.length), o++;
777
819
  }
778
- return o.trim();
820
+ return n.trim();
779
821
  }
780
- const bt = /^[a-zA-Z0-9_\-#.*\s>]+$/, $t = /^(\*|[a-zA-Z][a-zA-Z0-9-]*)?((?:[#.][a-zA-Z_-][a-zA-Z0-9_-]*)*)$/;
781
- function vt(e) {
822
+ const Tt = /^[a-zA-Z0-9_\-#.*\s>]+$/, Et = /^(\*|[a-zA-Z][a-zA-Z0-9-]*)?((?:[#.][a-zA-Z_-][a-zA-Z0-9_-]*)*)$/;
823
+ function It(e) {
782
824
  const t = e.trim();
783
- if (!t || !bt.test(t)) return null;
784
- const o = t.replace(/\s*>\s*/g, " > ").trim().split(/\s+/), n = [], s = [], i = [0, 0, 0];
825
+ if (!t || !Tt.test(t)) return null;
826
+ const n = t.replace(/\s*>\s*/g, " > ").trim().split(/\s+/), o = [], s = [], i = [0, 0, 0];
785
827
  let r = null;
786
- for (const a of o) {
787
- if (a === ">") {
788
- if (n.length === 0 || r === ">") return null;
828
+ for (const c of n) {
829
+ if (c === ">") {
830
+ if (o.length === 0 || r === ">") return null;
789
831
  r = ">";
790
832
  continue;
791
833
  }
792
- const l = $t.exec(a);
834
+ const l = Et.exec(c);
793
835
  if (!l || !l[1] && !l[2]) return null;
794
- const u = { tag: null, id: null, classes: [] };
795
- l[1] && l[1] !== "*" && (u.tag = l[1].toLowerCase(), i[2]++);
796
- for (const c of l[2].match(/[#.][^#.]+/g) ?? [])
797
- if (c[0] === "#") {
798
- if (u.id !== null && u.id !== c.slice(1)) return null;
799
- u.id = c.slice(1), i[0]++;
836
+ const d = { tag: null, id: null, classes: [] };
837
+ l[1] && l[1] !== "*" && (d.tag = l[1].toLowerCase(), i[2]++);
838
+ for (const u of l[2]?.match(/[#.][^#.]+/g) ?? [])
839
+ if (u[0] === "#") {
840
+ if (d.id !== null && d.id !== u.slice(1)) return null;
841
+ d.id = u.slice(1), i[0]++;
800
842
  } else
801
- u.classes.push(c.slice(1)), i[1]++;
802
- n.length > 0 && s.push(r ?? " "), r = null, n.push(u);
843
+ d.classes.push(u.slice(1)), i[1]++;
844
+ o.length > 0 && s.push(r ?? " "), r = null, o.push(d);
803
845
  }
804
- return r !== null || n.length === 0 ? null : (n.reverse(), s.reverse(), { compounds: n, combinators: s, specificity: i });
846
+ return r !== null || o.length === 0 ? null : (o.reverse(), s.reverse(), { compounds: o, combinators: s, specificity: i });
805
847
  }
806
- function wt(e, t) {
848
+ function Rt(e, t) {
807
849
  if (t.tag !== null && e.token.name !== t.tag || t.id !== null && e.id !== t.id) return !1;
808
- for (const o of t.classes)
809
- if (!e.classes.includes(o)) return !1;
850
+ for (const n of t.classes)
851
+ if (!e.classes.includes(n)) return !1;
810
852
  return !0;
811
853
  }
812
- function te(e, t, o) {
813
- if (!wt(e, t.compounds[o])) return !1;
814
- if (o === t.compounds.length - 1) return !0;
815
- if (t.combinators[o] === ">")
816
- return e.parent !== null && te(e.parent, t, o + 1);
817
- for (let s = e.parent; s; s = s.parent)
818
- if (te(s, t, o + 1)) return !0;
854
+ function oe(e, t, n) {
855
+ const o = t.compounds[n];
856
+ if (!o || !Rt(e, o)) return !1;
857
+ if (n === t.compounds.length - 1) return !0;
858
+ if (t.combinators[n] === ">")
859
+ return e.parent !== null && oe(e.parent, t, n + 1);
860
+ for (let i = e.parent; i; i = i.parent)
861
+ if (oe(i, t, n + 1)) return !0;
819
862
  return !1;
820
863
  }
821
- function kt(e, t) {
822
- return te(e, t, 0);
864
+ function jt(e, t) {
865
+ return oe(e, t, 0);
823
866
  }
824
- function xt(e, t) {
867
+ function Ot(e, t) {
825
868
  return e[0] - t[0] || e[1] - t[1] || e[2] - t[2];
826
869
  }
827
- function Ct(e) {
828
- const t = [], o = [];
829
- for (const n of e)
830
- if (n.type === "open") {
831
- const s = T(n, "id"), i = T(n, "class"), r = {
832
- token: n,
833
- parent: o[o.length - 1] ?? null,
870
+ function Mt(e) {
871
+ const t = [], n = [];
872
+ for (const o of e)
873
+ if (o.type === "open") {
874
+ const s = R(o, "id"), i = R(o, "class"), r = {
875
+ token: o,
876
+ parent: n[n.length - 1] ?? null,
834
877
  id: s ? s.trim() : null,
835
878
  classes: i ? i.trim().split(/\s+/).filter(Boolean) : []
836
879
  };
837
- t.push(r), !n.selfClosing && !ee.has(n.name) && o.push(r);
838
- } else if (n.type === "close") {
839
- for (let s = o.length - 1; s >= 0; s--)
840
- if (o[s].token.name === n.name) {
841
- o.length = s;
880
+ t.push(r), !o.selfClosing && !ne.has(o.name) && n.push(r);
881
+ } else if (o.type === "close") {
882
+ for (let s = n.length - 1; s >= 0; s--)
883
+ if (n[s]?.token.name === o.name) {
884
+ n.length = s;
842
885
  break;
843
886
  }
844
887
  }
845
888
  return t;
846
889
  }
847
- function _t(e) {
890
+ function zt(e) {
848
891
  for (let t = e; t; t = t.parent)
849
892
  if (t.token.name === "body") return !0;
850
893
  return !1;
851
894
  }
852
- function St(e, t = {}) {
853
- const o = t.removeInlinedRules !== !1, n = O(e), s = [];
895
+ function Dt(e, t = {}) {
896
+ const n = t.removeInlinedRules !== !1, o = O(e), s = [];
854
897
  let i = 0;
855
898
  const r = /* @__PURE__ */ new Map();
856
- for (let c = 0; c < n.length; c++) {
857
- const d = n[c];
858
- if (d.type !== "open" || d.name !== "style" || T(d, "media") !== void 0) continue;
859
- const h = n[c + 1];
899
+ for (const [u, a] of o.entries()) {
900
+ if (a.type !== "open" || a.name !== "style" || R(a, "media") !== void 0) continue;
901
+ const h = o[u + 1];
860
902
  if (!h || h.type !== "rawtext") continue;
861
903
  const m = [];
862
- let p = !1;
863
- for (const f of gt(h.raw)) {
864
- if (f.type === "at-rule") {
865
- m.push(f.raw);
904
+ let y = !1;
905
+ for (const b of _t(h.raw)) {
906
+ if (b.type === "at-rule") {
907
+ m.push(b.raw);
866
908
  continue;
867
909
  }
868
- const g = [], y = [];
869
- for (const v of f.selectors) {
870
- const w = vt(v);
910
+ const f = [], p = [];
911
+ for (const $ of b.selectors) {
912
+ const w = It($);
871
913
  if (w) {
872
- g.push(v);
873
- const $ = f.declarations.filter((j) => !j.important);
874
- $.length > 0 && s.push({ selector: w, declarations: $, order: i++ });
914
+ f.push($);
915
+ const v = b.declarations.filter((x) => !x.important);
916
+ v.length > 0 && s.push({ selector: w, declarations: v, order: i++ });
875
917
  } else
876
- y.push(v);
918
+ p.push($);
877
919
  }
878
- if (g.length === 0 || !o) {
879
- m.push(f.raw);
920
+ if (f.length === 0 || !n) {
921
+ m.push(b.raw);
880
922
  continue;
881
923
  }
882
- p = !0, y.length > 0 && m.push(`${y.join(", ")} { ${le(f.declarations)} }`);
883
- const b = f.declarations.filter((v) => v.important);
884
- b.length > 0 && m.push(`${g.join(", ")} { ${le(b)} }`);
924
+ y = !0, p.length > 0 && m.push(`${p.join(", ")} { ${pe(b.declarations)} }`);
925
+ const g = b.declarations.filter(($) => $.important);
926
+ g.length > 0 && m.push(`${f.join(", ")} { ${pe(g)} }`);
885
927
  }
886
- p && r.set(c + 1, m.join(`
928
+ y && r.set(u + 1, m.join(`
887
929
  `));
888
930
  }
889
931
  if (s.length === 0) return e;
890
- s.sort((c, d) => xt(c.selector.specificity, d.selector.specificity) || c.order - d.order);
891
- const a = Ct(n), l = a.some((c) => c.token.name === "body");
892
- for (const c of a) {
893
- if (l && !_t(c)) continue;
894
- const d = /* @__PURE__ */ new Map();
895
- for (const y of s)
896
- if (kt(c, y.selector))
897
- for (const b of y.declarations)
898
- d.delete(b.property), d.set(b.property, b.value);
899
- if (d.size === 0) continue;
900
- const h = (T(c.token, "style") ?? "").trim(), m = new Set(Re(h).map((y) => y.property)), p = [];
901
- for (const [y, b] of d)
902
- m.has(y) || p.push(`${y}:${b}`);
903
- if (p.length === 0) continue;
904
- const f = h.replace(/^;+/, ""), g = f ? `${p.join(";")};${f}` : `${p.join(";")};`;
905
- pt(c.token, "style", g);
932
+ s.sort((u, a) => Ot(u.selector.specificity, a.selector.specificity) || u.order - a.order);
933
+ const c = Mt(o), l = c.some((u) => u.token.name === "body");
934
+ for (const u of c) {
935
+ if (l && !zt(u)) continue;
936
+ const a = /* @__PURE__ */ new Map();
937
+ for (const p of s)
938
+ if (jt(u, p.selector))
939
+ for (const g of p.declarations)
940
+ a.delete(g.property), a.set(g.property, g.value);
941
+ if (a.size === 0) continue;
942
+ const h = (R(u.token, "style") ?? "").trim(), m = new Set(Le(h).map((p) => p.property)), y = [];
943
+ for (const [p, g] of a)
944
+ m.has(p) || y.push(`${p}:${g}`);
945
+ if (y.length === 0) continue;
946
+ const b = h.replace(/^;+/, ""), f = b ? `${y.join(";")};${b}` : `${y.join(";")};`;
947
+ xt(u.token, "style", f);
906
948
  }
907
- const u = /* @__PURE__ */ new Set();
908
- for (const [c, d] of r)
909
- d.trim() ? n[c] = { type: "rawtext", parent: "style", raw: `
910
- ${d}
911
- ` } : (u.add(c - 1), u.add(c), n[c + 1]?.type === "close" && u.add(c + 1));
912
- return W(n.filter((c, d) => !u.has(d)));
913
- }
914
- const Tt = /* @__PURE__ */ new Set(["class", "style", "id"]), At = /* @__PURE__ */ new Set([
949
+ const d = /* @__PURE__ */ new Set();
950
+ for (const [u, a] of r)
951
+ a.trim() ? o[u] = { type: "rawtext", parent: "style", raw: `
952
+ ${a}
953
+ ` } : (d.add(u - 1), d.add(u), o[u + 1]?.type === "close" && d.add(u + 1));
954
+ return P(o.filter((u, a) => !d.has(a)));
955
+ }
956
+ const Bt = /* @__PURE__ */ new Set(["class", "style", "id"]), Pt = /* @__PURE__ */ new Set([
915
957
  "contenteditable",
916
958
  "spellcheck",
917
959
  "data-content-id",
918
960
  "data-column-id",
919
961
  "data-row-id"
920
962
  ]);
921
- function Et(e) {
963
+ function Wt(e) {
922
964
  const t = O(e);
923
- for (const o of t) {
924
- if (o.type !== "open" || o.attrs.length === 0) continue;
925
- const n = o.attrs.filter((s) => !(At.has(s.name) || Tt.has(s.name) && (s.value === null || !s.value.trim())));
926
- n.length !== o.attrs.length && (o.attrs = n, o.dirty = !0);
965
+ for (const n of t) {
966
+ if (n.type !== "open" || n.attrs.length === 0) continue;
967
+ const o = n.attrs.filter((s) => !(Pt.has(s.name) || Bt.has(s.name) && (s.value === null || !s.value.trim())));
968
+ o.length !== n.attrs.length && (n.attrs = o, n.dirty = !0);
927
969
  }
928
- return W(t);
970
+ return P(t);
929
971
  }
930
- const jt = /* @__PURE__ */ new Set([
972
+ const Lt = /* @__PURE__ */ new Set([
931
973
  "html",
932
974
  "head",
933
975
  "body",
@@ -979,14 +1021,14 @@ const jt = /* @__PURE__ */ new Set([
979
1021
  "noscript",
980
1022
  "xml",
981
1023
  "pre"
982
- ]), It = /[ \t\n\r\f]+/g, Rt = /^[ \t\n\r\f]*$/;
983
- function ae(e) {
984
- return !e || e.type === "comment" || e.type === "doctype" ? !0 : e.type === "open" || e.type === "close" ? jt.has(e.name) || e.name.includes(":") : !1;
1024
+ ]), Nt = /[ \t\n\r\f]+/g, qt = /^[ \t\n\r\f]*$/;
1025
+ function me(e) {
1026
+ return !e || e.type === "comment" || e.type === "doctype" ? !0 : e.type === "open" || e.type === "close" ? Lt.has(e.name) || e.name.includes(":") : !1;
985
1027
  }
986
- function Ot(e) {
1028
+ function Ft(e) {
987
1029
  const t = [];
988
1030
  for (const s of O(e)) {
989
- if (s.type === "comment" && !mt(s.raw)) continue;
1031
+ if (s.type === "comment" && !Ct(s.raw)) continue;
990
1032
  const i = t[t.length - 1];
991
1033
  if (s.type === "text" && i?.type === "text") {
992
1034
  t[t.length - 1] = { type: "text", raw: i.raw + s.raw };
@@ -994,30 +1036,29 @@ function Ot(e) {
994
1036
  }
995
1037
  t.push(s);
996
1038
  }
997
- const o = [];
998
- let n = 0;
999
- for (let s = 0; s < t.length; s++) {
1000
- const i = t[s];
1001
- if (i.type === "open" && i.name === "pre" && !i.selfClosing && n++, i.type === "close" && i.name === "pre" && (n = Math.max(0, n - 1)), i.type === "rawtext") {
1002
- i.parent === "style" ? o.push({ ...i, raw: yt(i.raw) }) : o.push(i);
1039
+ const n = [];
1040
+ let o = 0;
1041
+ for (const [s, i] of t.entries()) {
1042
+ if (i.type === "open" && i.name === "pre" && !i.selfClosing && o++, i.type === "close" && i.name === "pre" && (o = Math.max(0, o - 1)), i.type === "rawtext") {
1043
+ i.parent === "style" ? n.push({ ...i, raw: At(i.raw) }) : n.push(i);
1003
1044
  continue;
1004
1045
  }
1005
- if (i.type !== "text" || n > 0) {
1006
- o.push(i);
1046
+ if (i.type !== "text" || o > 0) {
1047
+ n.push(i);
1007
1048
  continue;
1008
1049
  }
1009
- const r = ae(t[s - 1]), a = ae(t[s + 1]);
1010
- if (Rt.test(i.raw)) {
1011
- if (r || a) continue;
1012
- o.push({ type: "text", raw: " " });
1050
+ const r = me(t[s - 1]), c = me(t[s + 1]);
1051
+ if (qt.test(i.raw)) {
1052
+ if (r || c) continue;
1053
+ n.push({ type: "text", raw: " " });
1013
1054
  continue;
1014
1055
  }
1015
- let l = i.raw.replace(It, " ");
1016
- r && (l = l.replace(/^ /, "")), a && (l = l.replace(/ $/, "")), o.push({ type: "text", raw: l });
1056
+ let l = i.raw.replace(Nt, " ");
1057
+ r && (l = l.replace(/^ /, "")), c && (l = l.replace(/ $/, "")), n.push({ type: "text", raw: l });
1017
1058
  }
1018
- return W(o).trim();
1059
+ return P(n).trim();
1019
1060
  }
1020
- const zt = /* @__PURE__ */ new Set([
1061
+ const Ht = /* @__PURE__ */ new Set([
1021
1062
  "iframe",
1022
1063
  "frame",
1023
1064
  "frameset",
@@ -1033,7 +1074,7 @@ const zt = /* @__PURE__ */ new Set([
1033
1074
  "discard",
1034
1075
  "handler",
1035
1076
  "listener"
1036
- ]), Mt = /* @__PURE__ */ new Set([
1077
+ ]), Ut = /* @__PURE__ */ new Set([
1037
1078
  "href",
1038
1079
  "src",
1039
1080
  "action",
@@ -1049,56 +1090,56 @@ const zt = /* @__PURE__ */ new Set([
1049
1090
  "ping",
1050
1091
  "xlink:href",
1051
1092
  "srcset"
1052
- ]), Dt = /^(?:javascript|vbscript|livescript):|^data:(?:text\/html|application\/(?:x?html|javascript))/i, Bt = /^data:image\/svg/i, Wt = /(?:javascript|vbscript|livescript):/i, Pt = /expression\s*\(|javascript:|vbscript:|-moz-binding|behavior\s*:/i, Lt = /<(?:script|i?frame|object|embed|applet|base|meta[^>]*refresh|animate|set|discard|handler|listener)\b|\son[a-z]+\s*=|srcdoc|formaction|script\s*:|data\s*:|expression|behavior|binding|&#|&colon|&tab|&newline/i;
1053
- function J(e) {
1054
- return e.replace(/&#x0*([0-9a-f]+);?/gi, (t, o) => String.fromCodePoint(parseInt(o, 16) % 1114112)).replace(/&#0*(\d+);?/g, (t, o) => String.fromCodePoint(Number(o) % 1114112)).replace(/&colon;?/gi, ":").replace(/&tab;?/gi, "").replace(/&newline;?/gi, "").replace(/[\u0000- \u007f-\u009f]/g, "");
1093
+ ]), Gt = /^(?:javascript|vbscript|livescript):|^data:(?:text\/html|application\/(?:x?html|javascript))/i, Kt = /^data:image\/svg/i, Zt = /(?:javascript|vbscript|livescript):/i, Yt = /expression\s*\(|javascript:|vbscript:|-moz-binding|behavior\s*:/i, Xt = /<(?:script|i?frame|object|embed|applet|base|meta[^>]*refresh|animate|set|discard|handler|listener)\b|\son[a-z]+\s*=|srcdoc|formaction|script\s*:|data\s*:|expression|behavior|binding|&#|&colon|&tab|&newline/i;
1094
+ function Q(e) {
1095
+ return e.replace(/&#x0*([0-9a-f]+);?/gi, (t, n) => String.fromCodePoint(parseInt(n, 16) % 1114112)).replace(/&#0*(\d+);?/g, (t, n) => String.fromCodePoint(Number(n) % 1114112)).replace(/&colon;?/gi, ":").replace(/&tab;?/gi, "").replace(/&newline;?/gi, "").replace(/[\u0000- \u007f-\u009f]/g, "");
1055
1096
  }
1056
- function Nt(e, t) {
1097
+ function Jt(e, t) {
1057
1098
  if (e.startsWith("on") || e === "srcdoc" || e === "formaction") return !0;
1058
1099
  if (t === null) return !1;
1059
- if (e === "srcset") return Wt.test(J(t));
1060
- if (Mt.has(e) || e.endsWith(":href")) {
1061
- const o = J(t);
1062
- return Dt.test(o) || (e === "href" || e.endsWith(":href")) && Bt.test(o);
1100
+ if (e === "srcset") return Zt.test(Q(t));
1101
+ if (Ut.has(e) || e.endsWith(":href")) {
1102
+ const n = Q(t);
1103
+ return Gt.test(n) || (e === "href" || e.endsWith(":href")) && Kt.test(n);
1063
1104
  }
1064
- return e === "style" ? Pt.test(J(t)) : !1;
1105
+ return e === "style" ? Yt.test(Q(t)) : !1;
1065
1106
  }
1066
- function qt(e) {
1067
- if (!Lt.test(e)) return e;
1068
- const t = O(e), o = [];
1069
- let n = !1, s = !1;
1107
+ function Qt(e) {
1108
+ if (!Xt.test(e)) return e;
1109
+ const t = O(e), n = [];
1110
+ let o = !1, s = !1;
1070
1111
  for (const i of t) {
1071
1112
  if (s) {
1072
- n = !0, i.type === "close" && i.name === "script" && (s = !1);
1113
+ o = !0, i.type === "close" && i.name === "script" && (s = !1);
1073
1114
  continue;
1074
1115
  }
1075
1116
  if (i.type === "open" || i.type === "close") {
1076
1117
  if (i.name === "script") {
1077
- n = !0, i.type === "open" && !i.selfClosing && (s = !0);
1118
+ o = !0, i.type === "open" && !i.selfClosing && (s = !0);
1078
1119
  continue;
1079
1120
  }
1080
- if (zt.has(i.name)) {
1081
- n = !0;
1121
+ if (Ht.has(i.name)) {
1122
+ o = !0;
1082
1123
  continue;
1083
1124
  }
1084
1125
  }
1085
1126
  if (i.type === "rawtext" && i.parent === "script") {
1086
- n = !0;
1127
+ o = !0;
1087
1128
  continue;
1088
1129
  }
1089
1130
  if (i.type === "open") {
1090
- if (i.name === "meta" && i.attrs.some((a) => a.name === "http-equiv" && /refresh/i.test(a.value ?? ""))) {
1091
- n = !0;
1131
+ if (i.name === "meta" && i.attrs.some((c) => c.name === "http-equiv" && /refresh/i.test(c.value ?? ""))) {
1132
+ o = !0;
1092
1133
  continue;
1093
1134
  }
1094
- const r = i.attrs.filter((a) => !Nt(a.name, a.value));
1095
- r.length !== i.attrs.length && (i.attrs = r, i.dirty = !0, n = !0);
1135
+ const r = i.attrs.filter((c) => !Jt(c.name, c.value));
1136
+ r.length !== i.attrs.length && (i.attrs = r, i.dirty = !0, o = !0);
1096
1137
  }
1097
- o.push(i);
1138
+ n.push(i);
1098
1139
  }
1099
- return n ? W(o) : e;
1140
+ return o ? P(n) : e;
1100
1141
  }
1101
- const ce = {
1142
+ const he = {
1102
1143
  amp: "&",
1103
1144
  lt: "<",
1104
1145
  gt: ">",
@@ -1175,17 +1216,17 @@ const ce = {
1175
1216
  hearts: "♥",
1176
1217
  star: "☆",
1177
1218
  check: "✓"
1178
- }, ue = /[\u00AD\u034F\u200B-\u200F\u2060\uFEFF]/g;
1179
- function Q(e) {
1180
- return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);/gi, (t, o) => {
1181
- if (o[0] === "#") {
1182
- const n = o[1] === "x" || o[1] === "X" ? parseInt(o.slice(2), 16) : parseInt(o.slice(1), 10);
1183
- return !isFinite(n) || n <= 0 || n > 1114111 ? "" : n === 160 ? " " : String.fromCodePoint(n);
1219
+ };
1220
+ function V(e) {
1221
+ return e.replace(/&(#x[0-9a-f]+|#[0-9]+|[a-z][a-z0-9]*);/gi, (t, n) => {
1222
+ if (n[0] === "#") {
1223
+ const o = n[1] === "x" || n[1] === "X" ? parseInt(n.slice(2), 16) : parseInt(n.slice(1), 10);
1224
+ return !isFinite(o) || o <= 0 || o > 1114111 ? "" : o === 160 ? " " : String.fromCodePoint(o);
1184
1225
  }
1185
- return o in ce ? ce[o] : t;
1226
+ return (Object.hasOwn(he, n) ? he[n] : void 0) ?? t;
1186
1227
  });
1187
1228
  }
1188
- const de = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]), fe = /* @__PURE__ */ new Set([
1229
+ const ge = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]), ye = /* @__PURE__ */ new Set([
1189
1230
  "div",
1190
1231
  "table",
1191
1232
  "tbody",
@@ -1210,119 +1251,119 @@ const de = /* @__PURE__ */ new Set(["h1", "h2", "h3", "h4", "h5", "h6"]), fe = /
1210
1251
  "figcaption",
1211
1252
  "pre",
1212
1253
  "address"
1213
- ]), pe = /* @__PURE__ */ new Set(["p", "blockquote"]), Ft = /* @__PURE__ */ new Set(["head", "style", "script", "title", "noscript", "template", "svg", "select", "textarea", "object", "video", "audio", "map"]);
1214
- function Ut(e) {
1215
- if (T(e, "hidden") !== void 0 || T(e, "aria-hidden") === "true" && e.name !== "img") return !0;
1216
- const t = (T(e, "style") ?? "").toLowerCase().replace(/\s+/g, "");
1254
+ ]), be = /* @__PURE__ */ new Set(["p", "blockquote"]), Vt = /* @__PURE__ */ new Set(["head", "style", "script", "title", "noscript", "template", "svg", "select", "textarea", "object", "video", "audio", "map"]);
1255
+ function en(e) {
1256
+ if (R(e, "hidden") !== void 0 || R(e, "aria-hidden") === "true" && e.name !== "img") return !0;
1257
+ const t = (R(e, "style") ?? "").toLowerCase().replace(/\s+/g, "");
1217
1258
  return /(^|;)display:none/.test(t) || /mso-hide:all/.test(t) || /(^|;)max-height:0(px|em|%)?(;|$|!)/.test(t);
1218
1259
  }
1219
- function Ht(e, t) {
1220
- const o = (n) => n.trim().toLowerCase().replace(/^(mailto:|tel:|sms:)/, "").replace(/^https?:\/\//, "").replace(/^www\./, "").replace(/\/+$/, "");
1221
- return o(e) === o(t);
1222
- }
1223
- function Zt(e, t = {}) {
1224
- const o = t.linkStyle ?? "inline", n = [], s = [{ kind: "root", buf: "" }], i = [], r = () => s[s.length - 1], a = () => {
1225
- const p = r();
1226
- p.buf = p.buf.replace(/[ \t]+$/, "");
1227
- }, l = (p) => {
1228
- let f = Q(p.replace(/\s+/g, " ")).replace(ue, "").replace(/[ \t\u00A0]+/g, " ");
1229
- if (!f) return;
1230
- const g = r();
1231
- (!g.buf || /[\s]$/.test(g.buf)) && (f = f.replace(/^ /, "")), g.buf += f;
1232
- }, u = (p) => {
1233
- a();
1234
- const f = r();
1235
- if (!f.buf) return;
1236
- const g = /\n*$/.exec(f.buf)[0].length;
1237
- g < p && (f.buf += `
1238
- `.repeat(p - g));
1239
- }, c = () => {
1240
- const p = r();
1241
- p.buf && !/\s$/.test(p.buf) && (p.buf += " ");
1260
+ function tn(e, t) {
1261
+ const n = (o) => o.trim().toLowerCase().replace(/^(mailto:|tel:|sms:)/, "").replace(/^https?:\/\//, "").replace(/^www\./, "").replace(/\/+$/, "");
1262
+ return n(e) === n(t);
1263
+ }
1264
+ function nn(e, t = {}) {
1265
+ const n = t.linkStyle ?? "inline", o = [], s = { kind: "root", buf: "" }, i = [s], r = [], c = () => i.at(-1) ?? s, l = () => (i.length > 1 ? i.pop() : void 0) ?? s, d = () => {
1266
+ const f = c();
1267
+ f.buf = f.buf.replace(/[ \t]+$/, "");
1268
+ }, u = (f) => {
1269
+ let p = de(V(f.replace(/\s+/g, " "))).replace(/[ \t\u00A0]+/g, " ");
1270
+ if (!p) return;
1271
+ const g = c();
1272
+ (!g.buf || /[\s]$/.test(g.buf)) && (p = p.replace(/^ /, "")), g.buf += p;
1273
+ }, a = (f) => {
1274
+ d();
1275
+ const p = c();
1276
+ if (!p.buf) return;
1277
+ const g = p.buf.length - p.buf.replace(/\n+$/, "").length;
1278
+ g < f && (p.buf += `
1279
+ `.repeat(f - g));
1280
+ }, h = () => {
1281
+ const f = c();
1282
+ f.buf && !/\s$/.test(f.buf) && (f.buf += " ");
1242
1283
  };
1243
- let d = "", h = 0;
1244
- for (const p of O(e)) {
1245
- if (h) {
1246
- p.type === "open" && p.name === d && !p.selfClosing && !ee.has(p.name) ? h++ : p.type === "close" && p.name === d && h--;
1284
+ let m = "", y = 0;
1285
+ for (const f of O(e)) {
1286
+ if (y) {
1287
+ f.type === "open" && f.name === m && !f.selfClosing && !ne.has(f.name) ? y++ : f.type === "close" && f.name === m && y--;
1247
1288
  continue;
1248
1289
  }
1249
- if (p.type === "text") {
1250
- l(p.raw);
1290
+ if (f.type === "text") {
1291
+ u(f.raw);
1251
1292
  continue;
1252
1293
  }
1253
- if (p.type !== "open" && p.type !== "close") continue;
1254
- const f = p.name;
1255
- if (p.type === "open") {
1256
- const g = ee.has(f) || p.selfClosing;
1257
- if (Ft.has(f) || Ut(p) && f !== "br") {
1258
- g || (d = f, h = 1);
1294
+ if (f.type !== "open" && f.type !== "close") continue;
1295
+ const p = f.name;
1296
+ if (f.type === "open") {
1297
+ const g = ne.has(p) || f.selfClosing;
1298
+ if (Vt.has(p) || en(f) && p !== "br") {
1299
+ g || (m = p, y = 1);
1259
1300
  continue;
1260
1301
  }
1261
- if (f === "br")
1262
- a(), r().buf += `
1302
+ if (p === "br")
1303
+ d(), c().buf += `
1263
1304
  `;
1264
- else if (f === "img") {
1265
- const y = Q(T(p, "alt") ?? "").replace(ue, "").trim();
1266
- y && (c(), r().buf += `[${y}]`);
1267
- } else if (f === "hr")
1268
- u(1), r().buf += "---", u(1);
1269
- else if (de.has(f))
1270
- u(2), s.push({ kind: "heading", buf: "" });
1271
- else if (f === "a")
1272
- s.push({ kind: "link", buf: "", href: Q(T(p, "href") ?? "").trim() });
1273
- else if (f === "ul" || f === "ol")
1274
- u(1), i.push({ ordered: f === "ol", n: 0 });
1275
- else if (f === "li") {
1276
- u(1);
1277
- const y = i[i.length - 1], b = " ".repeat(Math.max(0, i.length - 1));
1278
- r().buf += y?.ordered ? `${b}${++y.n}. ` : `${b}- `;
1279
- } else pe.has(f) ? u(2) : fe.has(f) ? u(1) : (f === "td" || f === "th") && c();
1305
+ else if (p === "img") {
1306
+ const $ = de(V(R(f, "alt") ?? "")).trim();
1307
+ $ && (h(), c().buf += `[${$}]`);
1308
+ } else if (p === "hr")
1309
+ a(1), c().buf += "---", a(1);
1310
+ else if (ge.has(p))
1311
+ a(2), i.push({ kind: "heading", buf: "" });
1312
+ else if (p === "a")
1313
+ i.push({ kind: "link", buf: "", href: V(R(f, "href") ?? "").trim() });
1314
+ else if (p === "ul" || p === "ol")
1315
+ a(1), r.push({ ordered: p === "ol", n: 0 });
1316
+ else if (p === "li") {
1317
+ a(1);
1318
+ const $ = r[r.length - 1], w = " ".repeat(Math.max(0, r.length - 1));
1319
+ c().buf += $?.ordered ? `${w}${++$.n}. ` : `${w}- `;
1320
+ } else be.has(p) ? a(2) : ye.has(p) ? a(1) : (p === "td" || p === "th") && h();
1280
1321
  continue;
1281
1322
  }
1282
- if (de.has(f) && r().kind === "heading") {
1283
- const g = s.pop().buf.trim().toUpperCase();
1284
- u(2), g && (r().buf += g), u(2);
1285
- } else if (f === "a" && r().kind === "link") {
1286
- const g = s.pop(), y = g.buf.replace(/\s+/g, " ").trim(), b = g.href ?? "", v = b && !b.startsWith("#") && !/^javascript:/i.test(b);
1287
- let w = y;
1288
- if (v && !Ht(b, y))
1289
- if (!y) w = b;
1290
- else if (o === "footnote") {
1291
- let $ = n.indexOf(b);
1292
- $ === -1 && ($ = n.push(b) - 1), w = `${y} [${$ + 1}]`;
1293
- } else w = `${y} (${b})`;
1294
- w && (c(), r().buf += w);
1295
- } else f === "ul" || f === "ol" ? (i.pop(), u(1)) : f === "table" ? u(2) : f === "li" || fe.has(f) ? u(1) : pe.has(f) ? u(2) : (f === "td" || f === "th") && c();
1323
+ if (ge.has(p) && c().kind === "heading") {
1324
+ const g = l().buf.trim().toUpperCase();
1325
+ a(2), g && (c().buf += g), a(2);
1326
+ } else if (p === "a" && c().kind === "link") {
1327
+ const g = l(), $ = g.buf.replace(/\s+/g, " ").trim(), w = g.href ?? "", v = w && !w.startsWith("#") && !/^javascript:/i.test(w);
1328
+ let x = $;
1329
+ if (v && !tn(w, $))
1330
+ if (!$) x = w;
1331
+ else if (n === "footnote") {
1332
+ let E = o.indexOf(w);
1333
+ E === -1 && (E = o.push(w) - 1), x = `${$} [${E + 1}]`;
1334
+ } else x = `${$} (${w})`;
1335
+ x && (h(), c().buf += x);
1336
+ } else p === "ul" || p === "ol" ? (r.pop(), a(1)) : p === "table" ? a(2) : p === "li" || ye.has(p) ? a(1) : be.has(p) ? a(2) : (p === "td" || p === "th") && h();
1296
1337
  }
1297
- for (; s.length > 1; ) {
1298
- const p = s.pop();
1299
- r().buf += p.kind === "heading" ? p.buf.toUpperCase() : p.buf;
1338
+ for (; i.length > 1; ) {
1339
+ const f = l();
1340
+ c().buf += f.kind === "heading" ? f.buf.toUpperCase() : f.buf;
1300
1341
  }
1301
- let m = r().buf.split(`
1302
- `).map((p) => p.replace(/[ \t]+/g, " ").trim()).join(`
1342
+ let b = c().buf.split(`
1343
+ `).map((f) => f.replace(/[ \t]+/g, " ").trim()).join(`
1303
1344
  `).replace(/\n{4,}/g, `
1304
1345
 
1305
1346
 
1306
1347
  `).trim();
1307
- return t.wordwrap && (m = Gt(m, t.wordwrap)), n.length && (m += `
1348
+ return t.wordwrap && (b = on(b, t.wordwrap)), o.length && (b += `
1308
1349
 
1309
- ${n.map((p, f) => `[${f + 1}] ${p}`).join(`
1310
- `)}`), m;
1350
+ ${o.map((f, p) => `[${p + 1}] ${f}`).join(`
1351
+ `)}`), b;
1311
1352
  }
1312
- function Gt(e, t) {
1353
+ function on(e, t) {
1313
1354
  return t > 0 ? e.split(`
1314
- `).map((o) => {
1315
- if (o.length <= t) return o;
1316
- const n = /^(\s*(?:- |\d+\. ))?/.exec(o)[0].replace(/./g, " "), s = [];
1355
+ `).map((n) => {
1356
+ if (n.length <= t) return n;
1357
+ const o = /^(\s*(?:- |\d+\. ))?/.exec(n)[0].replace(/./g, " "), s = [];
1317
1358
  let i = "";
1318
- for (const r of o.split(" "))
1319
- i ? i.length + 1 + r.length <= t ? i += ` ${r}` : (s.push(i), i = n + r) : i = r;
1359
+ for (const r of n.split(" "))
1360
+ i ? i.length + 1 + r.length <= t ? i += ` ${r}` : (s.push(i), i = o + r) : i = r;
1320
1361
  return i && s.push(i), s.join(`
1321
1362
  `);
1322
1363
  }).join(`
1323
1364
  `) : e;
1324
1365
  }
1325
- class Oe {
1366
+ class Ne {
1326
1367
  constructor() {
1327
1368
  this.rows = /* @__PURE__ */ new WeakMap(), this.stats = { hits: 0, misses: 0 };
1328
1369
  }
@@ -1330,231 +1371,231 @@ class Oe {
1330
1371
  this.rows = /* @__PURE__ */ new WeakMap(), this.stats = { hits: 0, misses: 0 };
1331
1372
  }
1332
1373
  }
1333
- function an() {
1334
- return new Oe();
1374
+ function bn() {
1375
+ return new Ne();
1335
1376
  }
1336
- const me = /* @__PURE__ */ new WeakMap();
1337
- let Kt = 1;
1338
- function Yt(e) {
1339
- let t = me.get(e);
1340
- return t === void 0 && (t = Kt++, me.set(e, t)), t;
1341
- }
1342
- const Xt = /* @__PURE__ */ new Set(["preheaderText"]);
1343
- function Jt(e, t, o) {
1344
- const n = {};
1345
- for (const s of Object.keys(e ?? {})) Xt.has(s) || (n[s] = e[s]);
1346
- return `${t}|${Yt(o)}|${JSON.stringify(n)}`;
1347
- }
1348
- function ge(e, t, o, n) {
1349
- const s = n ? Xe(e, t, o) : Ze(e, t, o, "email"), i = tn(s), r = /* @__PURE__ */ new Set();
1350
- for (const a of e.columns ?? []) for (const l of a.contents ?? []) D(l.values, r);
1377
+ const $e = /* @__PURE__ */ new WeakMap();
1378
+ let sn = 1;
1379
+ function rn(e) {
1380
+ let t = $e.get(e);
1381
+ return t === void 0 && (t = sn++, $e.set(e, t)), t;
1382
+ }
1383
+ const ln = /* @__PURE__ */ new Set(["preheaderText"]);
1384
+ function cn(e, t, n) {
1385
+ const o = {};
1386
+ for (const s of Object.keys(e ?? {})) ln.has(s) || (o[s] = e[s]);
1387
+ return `${t}|${rn(n)}|${JSON.stringify(o)}`;
1388
+ }
1389
+ function ve(e, t, n, o) {
1390
+ const s = o ? rt(e, t, n) : st(e, t, n, "email"), i = fn(s), r = /* @__PURE__ */ new Set();
1391
+ for (const c of e.columns ?? []) for (const l of c.contents ?? []) D(l.values, r);
1351
1392
  return {
1352
1393
  // Web pages keep modern CSS (flex, grid, …); email strips what clients don't support
1353
- html: n ? i.html : ct(i.html),
1394
+ html: o ? i.html : $t(i.html),
1354
1395
  styles: i.styles,
1355
1396
  fonts: [...r],
1356
- overrides: we(e)
1397
+ overrides: Te(e)
1357
1398
  };
1358
1399
  }
1359
- function Qt(e, t, o, n) {
1360
- const s = e.body.values, i = parseInt(s.contentWidth || "600") || 600, r = o?.displayMode === "web", a = n?.cache ?? o?.cache, l = a instanceof Oe, u = l ? Jt(s, r ? "web" : "email", t) : "", c = [
1400
+ function an(e, t, n, o) {
1401
+ const s = e.body.values, i = parseInt(s.contentWidth || "600") || 600, r = n?.displayMode === "web", c = o?.cache ?? n?.cache, l = c instanceof Ne, d = l ? cn(s, r ? "web" : "email", t) : "", u = [
1361
1402
  ...e.body.headers ?? [],
1362
1403
  ...e.body.rows ?? [],
1363
1404
  ...e.body.footers ?? []
1364
- ], d = [], h = [], m = /* @__PURE__ */ new Set(), p = /* @__PURE__ */ new Set();
1365
- D({ fontFamily: s?.fontFamily }, p);
1366
- const f = [];
1367
- for (const _ of c) {
1368
- let k;
1405
+ ], a = [], h = [], m = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set();
1406
+ D({ fontFamily: s?.fontFamily }, y);
1407
+ const b = [];
1408
+ for (const A of u) {
1409
+ let C;
1369
1410
  if (l) {
1370
- const x = a.rows.get(_);
1371
- x && x.key === u ? (k = x.parts, a.stats.hits++) : (k = ge(_, s, t, r), a.rows.set(_, { key: u, parts: k }), a.stats.misses++);
1411
+ const k = c.rows.get(A);
1412
+ k && k.key === d ? (C = k.parts, c.stats.hits++) : (C = ve(A, s, t, r), c.rows.set(A, { key: d, parts: C }), c.stats.misses++);
1372
1413
  } else
1373
- k = ge(_, s, t, r);
1374
- d.push(k.html);
1375
- for (const x of k.styles)
1376
- m.has(x) || (m.add(x), h.push(x));
1377
- for (const x of k.fonts) p.add(x);
1378
- for (const x of k.overrides) f.push(x);
1414
+ C = ve(A, s, t, r);
1415
+ a.push(C.html);
1416
+ for (const k of C.styles)
1417
+ m.has(k) || (m.add(k), h.push(k));
1418
+ for (const k of C.fonts) y.add(k);
1419
+ for (const k of C.overrides) b.push(k);
1379
1420
  }
1380
- const g = d.join(`
1381
- `), y = [...p], b = ke(f, i), v = Ee(e), w = [...h, ...b ? [b] : [], ...v ? [v] : []];
1382
- let $ = r ? tt(g, s, { fontUrls: y, styles: w, title: o?.title }) : We(g, Pe(i), s, {
1383
- fontUrls: y,
1421
+ const f = a.join(`
1422
+ `), p = [...y], g = Ee(b, i), $ = Be(e), w = [...h, ...g ? [g] : [], ...$ ? [$] : []];
1423
+ let v = r ? dt(f, s, { fontUrls: p, styles: w, title: n?.title }) : Ze(f, Ye(i), s, {
1424
+ fontUrls: p,
1384
1425
  styles: w,
1385
- title: o?.title,
1386
- darkMode: !!v
1426
+ title: n?.title,
1427
+ darkMode: !!$
1387
1428
  });
1388
- if (o?.mergeTags)
1389
- for (const [_, k] of Object.entries(o.mergeTags))
1390
- $ = $.replaceAll(`{{${_}}}`, k);
1391
- o?.designTags && ($ = Vt($, o.designTags, o.designTagsDelimiter)), !r && o?.displayMode !== "popup" && ($ = qt($)), o?.inlineStyles && ($ = St($)), o?.cleanup && ($ = Et($)), o?.minify && ($ = Ot($));
1392
- const j = nn($), z = {
1393
- html: $,
1429
+ if (n?.mergeTags)
1430
+ for (const [A, C] of Object.entries(n.mergeTags))
1431
+ v = v.replaceAll(`{{${A}}}`, C);
1432
+ n?.designTags && (v = un(v, n.designTags, n.designTagsDelimiter)), !r && n?.displayMode !== "popup" && (v = Qt(v)), n?.inlineStyles && (v = Dt(v)), n?.cleanup && (v = Wt(v)), (n?.minify ?? !r) && (v = Ft(v));
1433
+ const x = pn(v), E = {
1434
+ html: v,
1394
1435
  chunks: {
1395
- body: j.body,
1396
- css: j.css,
1397
- fonts: y,
1436
+ body: x.body,
1437
+ css: x.css,
1438
+ fonts: p,
1398
1439
  js: ""
1399
1440
  }
1400
1441
  };
1401
- if (l) {
1402
- let _;
1403
- Object.defineProperty(z, "design", {
1404
- enumerable: !0,
1405
- configurable: !0,
1406
- get: () => _ ??= structuredClone(e),
1407
- set: (k) => {
1408
- _ = k;
1409
- }
1410
- });
1411
- } else
1412
- z.design = structuredClone(e);
1413
- return z;
1442
+ if (!l) return { ...E, design: structuredClone(e) };
1443
+ let W;
1444
+ return {
1445
+ ...E,
1446
+ get design() {
1447
+ return W ??= structuredClone(e);
1448
+ },
1449
+ set design(A) {
1450
+ W = A;
1451
+ }
1452
+ };
1414
1453
  }
1415
- function cn(e, t, o, n) {
1416
- const { html: s } = Qt(
1454
+ function $n(e, t, n, o) {
1455
+ const { html: s } = an(
1417
1456
  e,
1418
1457
  t,
1419
- { ...o, inlineStyles: !1, minify: !1, cleanup: !1 },
1420
- n
1458
+ { ...n, inlineStyles: !1, minify: !1, cleanup: !1 },
1459
+ o
1421
1460
  );
1422
- return Zt(s, { wordwrap: o?.wordwrap, linkStyle: o?.linkStyle });
1461
+ return nn(s, { wordwrap: n?.wordwrap, linkStyle: n?.linkStyle });
1423
1462
  }
1424
- function Vt(e, t, o = ["{{", "}}"]) {
1425
- const [n, s] = o;
1463
+ function un(e, t, n = ["{{", "}}"]) {
1464
+ const [o, s] = n;
1426
1465
  let i = e;
1427
- for (const [r, a] of Object.entries(t))
1428
- i = i.replaceAll(`${n}${r}${s}`, String(a));
1466
+ for (const [r, c] of Object.entries(t))
1467
+ i = i.replaceAll(`${o}${r}${s}`, String(c));
1429
1468
  return i;
1430
1469
  }
1431
- function en(e) {
1470
+ function dn(e) {
1432
1471
  return e === "fontFamily" || e.endsWith("FontFamily");
1433
1472
  }
1434
- function D(e, t, o = 0) {
1435
- if (!(!e || typeof e != "object" || o > 4)) {
1436
- for (const [n, s] of Object.entries(e))
1473
+ function D(e, t, n = 0) {
1474
+ if (!(!T(e) || n > 4)) {
1475
+ for (const [o, s] of Object.entries(e))
1437
1476
  if (!(!s || typeof s != "object"))
1438
- if (en(n)) {
1439
- const i = s.url;
1477
+ if (dn(o)) {
1478
+ const i = T(s) ? s.url : void 0;
1440
1479
  typeof i == "string" && i.trim() && t.add(i.trim());
1441
1480
  } else
1442
- D(s, t, o + 1);
1481
+ D(s, t, n + 1);
1443
1482
  }
1444
1483
  }
1445
- function un(e) {
1484
+ function vn(e) {
1446
1485
  const t = /* @__PURE__ */ new Set();
1447
1486
  D({ fontFamily: e.body.values?.fontFamily }, t);
1448
- const o = ne(e);
1449
- for (const n of o)
1450
- for (const s of n.columns ?? [])
1487
+ const n = se(e);
1488
+ for (const o of n)
1489
+ for (const s of o.columns ?? [])
1451
1490
  for (const i of s.contents ?? [])
1452
1491
  D(i.values, t);
1453
1492
  return [...t];
1454
1493
  }
1455
- function tn(e) {
1456
- const t = O(e), o = [], n = /* @__PURE__ */ new Set(), s = [];
1494
+ function fn(e) {
1495
+ const t = O(e), n = [], o = /* @__PURE__ */ new Set(), s = [];
1457
1496
  for (let i = 0; i < t.length; i++) {
1458
1497
  const r = t[i];
1459
1498
  if (r.type === "open" && r.name === "style" && !r.selfClosing) {
1460
- let a = i + 1, l = "";
1461
- t[a]?.type === "rawtext" && (l = t[a].raw.trim(), a++);
1462
- const u = r.attrs.find((c) => c.name === "media")?.value?.trim();
1463
- if (l && u && u !== "all" && (l = `@media ${u} {
1499
+ let c = i + 1, l = "";
1500
+ const d = t[c];
1501
+ d?.type === "rawtext" && (l = d.raw.trim(), c++);
1502
+ const u = r.attrs.find((h) => h.name === "media")?.value?.trim();
1503
+ l && u && u !== "all" && (l = `@media ${u} {
1464
1504
  ${l}
1465
- }`), t[a]?.type === "close" && t[a].name === "style") {
1466
- l && !n.has(l) && (n.add(l), o.push(l)), i = a;
1505
+ }`);
1506
+ const a = t[c];
1507
+ if (a?.type === "close" && a.name === "style") {
1508
+ l && !o.has(l) && (o.add(l), n.push(l)), i = c;
1467
1509
  continue;
1468
1510
  }
1469
1511
  }
1470
1512
  s.push(r);
1471
1513
  }
1472
- return { html: o.length || s.length !== t.length ? W(s) : e, styles: o };
1514
+ return { html: n.length || s.length !== t.length ? P(s) : e, styles: n };
1473
1515
  }
1474
- function nn(e) {
1475
- const t = e.match(/<body[^>]*>([\s\S]*)<\/body>/i);
1516
+ function pn(e) {
1476
1517
  return {
1477
- body: t ? t[1].trim() : e,
1478
- css: on(e)
1518
+ body: e.match(/<body[^>]*>([\s\S]*)<\/body>/i)?.[1]?.trim() ?? e,
1519
+ css: mn(e)
1479
1520
  };
1480
1521
  }
1481
- function on(e) {
1482
- const t = /<!--[\s\S]*?-->|<(script|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi, o = [];
1483
- let n;
1484
- for (; n = t.exec(e); ) {
1485
- if (n[2] === void 0) continue;
1486
- const s = n[2].trim();
1487
- s && o.push(s);
1522
+ function mn(e) {
1523
+ const t = /<!--[\s\S]*?-->|<(script|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<style\b[^>]*>([\s\S]*?)<\/style\s*>/gi, n = [];
1524
+ let o;
1525
+ for (; o = t.exec(e); ) {
1526
+ if (o[2] === void 0) continue;
1527
+ const s = o[2].trim();
1528
+ s && n.push(s);
1488
1529
  }
1489
- return o.join(`
1530
+ return n.join(`
1490
1531
  `);
1491
1532
  }
1492
- function dn(e) {
1493
- const t = [], o = [];
1494
- e.includes("<!DOCTYPE") || t.push({ rule: "doctype", message: "Missing <!DOCTYPE> declaration. Required for consistent rendering.", severity: "error" }), (!e.includes("<meta") || !e.includes("charset")) && t.push({ rule: "charset", message: 'Missing charset meta tag. Add <meta charset="UTF-8">.', severity: "error" }), e.includes("viewport") || o.push({ rule: "viewport", message: "Missing viewport meta tag. Needed for responsive rendering on mobile.", severity: "warning" });
1495
- const n = (e.match(/<table/gi) || []).length, s = (e.match(/role="presentation"/gi) || []).length;
1496
- n > 0 && s < n * 0.5 && o.push({ rule: "table-role", message: `Only ${s}/${n} tables have role="presentation". Screen readers may interpret layout tables as data tables.`, severity: "warning" });
1533
+ function wn(e) {
1534
+ const t = [], n = [];
1535
+ e.includes("<!DOCTYPE") || t.push({ rule: "doctype", message: "Missing <!DOCTYPE> declaration. Required for consistent rendering.", severity: "error" }), (!e.includes("<meta") || !e.includes("charset")) && t.push({ rule: "charset", message: 'Missing charset meta tag. Add <meta charset="UTF-8">.', severity: "error" }), e.includes("viewport") || n.push({ rule: "viewport", message: "Missing viewport meta tag. Needed for responsive rendering on mobile.", severity: "warning" });
1536
+ const o = (e.match(/<table/gi) || []).length, s = (e.match(/role="presentation"/gi) || []).length;
1537
+ o > 0 && s < o * 0.5 && n.push({ rule: "table-role", message: `Only ${s}/${o} tables have role="presentation". Screen readers may interpret layout tables as data tables.`, severity: "warning" });
1497
1538
  const i = e.match(/<img[^>]*>/gi) || [];
1498
- for (const g of i)
1499
- g.includes("alt=") || t.push({ rule: "img-alt", message: "Image missing alt attribute. Required for accessibility and when images are blocked.", severity: "error" }), (!g.includes("style=") || !g.includes("display")) && o.push({ rule: "img-display", message: "Image without display:block may have a bottom gap in some email clients.", severity: "warning" }), (g.includes('width="100%"') || !g.includes("width=") && !g.includes("width:")) && o.push({ rule: "img-width", message: "Image without explicit pixel width. Some email clients ignore percentage widths.", severity: "warning" });
1500
- const r = e.match(/<style[^>]*>[\s\S]*?<\/style>/gi) || [], a = e.includes('style="');
1501
- r.length > 0 && !e.includes("@media") && o.push({ rule: "no-media-queries", message: "Style block found but no @media queries. Consider adding responsive breakpoints.", severity: "warning" }), !a && n > 0 && t.push({ rule: "inline-styles", message: "No inline styles detected. Gmail and many clients strip <style> tags — inline styles are essential.", severity: "error" });
1539
+ for (const f of i)
1540
+ f.includes("alt=") || t.push({ rule: "img-alt", message: "Image missing alt attribute. Required for accessibility and when images are blocked.", severity: "error" }), (!f.includes("style=") || !f.includes("display")) && n.push({ rule: "img-display", message: "Image without display:block may have a bottom gap in some email clients.", severity: "warning" }), (f.includes('width="100%"') || !f.includes("width=") && !f.includes("width:")) && n.push({ rule: "img-width", message: "Image without explicit pixel width. Some email clients ignore percentage widths.", severity: "warning" });
1541
+ const r = e.match(/<style[^>]*>[\s\S]*?<\/style>/gi) || [], c = e.includes('style="');
1542
+ r.length > 0 && !e.includes("@media") && n.push({ rule: "no-media-queries", message: "Style block found but no @media queries. Consider adding responsive breakpoints.", severity: "warning" }), !c && o > 0 && t.push({ rule: "inline-styles", message: "No inline styles detected. Gmail and many clients strip <style> tags — inline styles are essential.", severity: "error" });
1502
1543
  const l = ["position:fixed", "position:absolute", "display:flex", "display:grid", "gap:", "transform:", "animation:"];
1503
- for (const g of l)
1504
- e.includes('style="') && e.match(new RegExp(`style="[^"]*${g.replace(":", ":\\s*")}`, "i")) && o.push({ rule: "unsupported-css", message: `CSS property "${g.replace(":", "")}" not supported in most email clients.`, severity: "warning" });
1505
- e.includes("<!--[if") || o.push({ rule: "mso-conditionals", message: "No MSO conditional comments found. Outlook may not render multi-column layouts correctly.", severity: "warning" }), !e.includes("xmlns:v") && !e.includes("xmlns:o") && o.push({ rule: "mso-namespace", message: "Missing Microsoft Office XML namespaces. May affect Outlook rendering.", severity: "warning" });
1506
- const c = (e.match(/<a[^>]*>/gi) || []).filter((g) => !g.includes("style="));
1507
- c.length > 0 && o.push({ rule: "link-color", message: `${c.length} link(s) without inline styles. Email clients override unstyled link colors.`, severity: "warning" }), !e.includes("color-scheme") && !e.includes("prefers-color-scheme") && o.push({ rule: "dark-mode", message: "No dark mode support detected. Consider adding color-scheme meta and prefers-color-scheme media query.", severity: "warning" });
1508
- const d = Math.round(e.length / 1024);
1509
- d > 102 ? t.push({ rule: "size-limit", message: `Email HTML is ${d}KB. Gmail clips emails larger than 102KB.`, severity: "error" }) : d > 80 && o.push({ rule: "size-warning", message: `Email HTML is ${d}KB. Getting close to Gmail's 102KB clip limit.`, severity: "warning" }), !e.includes("display:none") && !e.includes("max-height:0") && o.push({ rule: "preheader", message: "No preheader text detected. Preheader text improves open rates in inbox previews.", severity: "warning" });
1510
- const h = 100, m = t.length * 15, p = o.length * 5, f = Math.max(0, h - m - p);
1544
+ for (const f of l)
1545
+ e.includes('style="') && e.match(new RegExp(`style="[^"]*${f.replace(":", ":\\s*")}`, "i")) && n.push({ rule: "unsupported-css", message: `CSS property "${f.replace(":", "")}" not supported in most email clients.`, severity: "warning" });
1546
+ e.includes("<!--[if") || n.push({ rule: "mso-conditionals", message: "No MSO conditional comments found. Outlook may not render multi-column layouts correctly.", severity: "warning" }), !e.includes("xmlns:v") && !e.includes("xmlns:o") && n.push({ rule: "mso-namespace", message: "Missing Microsoft Office XML namespaces. May affect Outlook rendering.", severity: "warning" });
1547
+ const u = (e.match(/<a[^>]*>/gi) || []).filter((f) => !f.includes("style="));
1548
+ u.length > 0 && n.push({ rule: "link-color", message: `${u.length} link(s) without inline styles. Email clients override unstyled link colors.`, severity: "warning" }), !e.includes("color-scheme") && !e.includes("prefers-color-scheme") && n.push({ rule: "dark-mode", message: "No dark mode support detected. Consider adding color-scheme meta and prefers-color-scheme media query.", severity: "warning" });
1549
+ const a = Math.round(e.length / 1024);
1550
+ a > 102 ? t.push({ rule: "size-limit", message: `Email HTML is ${a}KB. Gmail clips emails larger than 102KB.`, severity: "error" }) : a > 80 && n.push({ rule: "size-warning", message: `Email HTML is ${a}KB. Getting close to Gmail's 102KB clip limit.`, severity: "warning" }), !e.includes("display:none") && !e.includes("max-height:0") && n.push({ rule: "preheader", message: "No preheader text detected. Preheader text improves open rates in inbox previews.", severity: "warning" });
1551
+ const h = 100, m = t.length * 15, y = n.length * 5, b = Math.max(0, h - m - y);
1511
1552
  return {
1512
1553
  valid: t.length === 0,
1513
1554
  errors: t,
1514
- warnings: o,
1515
- score: f
1555
+ warnings: n,
1556
+ score: b
1516
1557
  };
1517
1558
  }
1518
1559
  export {
1519
- ne as allRows,
1520
- be as bodyFontWeight,
1521
- Ee as buildDarkModeCss,
1522
- rn as buildResponsiveOverridesCss,
1523
- I as cleanCssValue,
1524
- Et as cleanupHtml,
1525
- un as collectFontUrls,
1526
- se as contentElementId,
1527
- an as createRenderCache,
1528
- Q as decodeEntities,
1529
- ye as documentLanguage,
1530
- he as documentTitle,
1531
- Te as getDarkOverrides,
1560
+ se as allRows,
1561
+ xe as bodyFontWeight,
1562
+ Be as buildDarkModeCss,
1563
+ gn as buildResponsiveOverridesCss,
1564
+ j as cleanCssValue,
1565
+ Wt as cleanupHtml,
1566
+ vn as collectFontUrls,
1567
+ le as contentElementId,
1568
+ bn as createRenderCache,
1569
+ V as decodeEntities,
1570
+ ke as documentLanguage,
1571
+ we as documentTitle,
1572
+ ze as getDarkOverrides,
1532
1573
  B as getMobileOverrides,
1533
- Pe as getResponsiveCss,
1534
- Ve as getWebCss,
1535
- ln as hasDarkMode,
1536
- St as inlineCss,
1537
- Me as isLanguageCode,
1538
- K as isSafeCssValue,
1574
+ Ye as getResponsiveCss,
1575
+ at as getWebCss,
1576
+ yn as hasDarkMode,
1577
+ Dt as inlineCss,
1578
+ Fe as isLanguageCode,
1579
+ Z as isSafeCssValue,
1539
1580
  L as kebabKey,
1540
- yt as minifyCss,
1541
- Ot as minifyHtml,
1542
- q as mobileMediaQuery,
1543
- Le as overrideClass,
1544
- Z as overrideDeclarations,
1545
- Qt as renderDesignToHtml,
1546
- cn as renderDesignToPlainText,
1547
- Zt as renderPlainText,
1548
- Ze as renderRow,
1549
- Xe as renderWebRow,
1550
- Vt as replaceDesignTags,
1581
+ At as minifyCss,
1582
+ Ft as minifyHtml,
1583
+ N as mobileMediaQuery,
1584
+ Xe as overrideClass,
1585
+ U as overrideDeclarations,
1586
+ an as renderDesignToHtml,
1587
+ $n as renderDesignToPlainText,
1588
+ nn as renderPlainText,
1589
+ st as renderRow,
1590
+ rt as renderWebRow,
1591
+ un as replaceDesignTags,
1551
1592
  H as rowElementId,
1552
- qt as stripActiveContent,
1553
- Qe as stripMsoConditionals,
1554
- dn as validateEmailHtml,
1555
- We as wrapInDocumentShell,
1556
- tt as wrapInWebShell,
1557
- Gt as wrapText,
1558
- oe as wrapWithDisplayCondition
1593
+ Qt as stripActiveContent,
1594
+ ct as stripMsoConditionals,
1595
+ wn as validateEmailHtml,
1596
+ Ze as wrapInDocumentShell,
1597
+ dt as wrapInWebShell,
1598
+ on as wrapText,
1599
+ re as wrapWithDisplayCondition
1559
1600
  };
1560
1601
  //# sourceMappingURL=index.js.map