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