@useinsider/guido 3.2.0-beta.da93bda → 3.2.0-beta.dc55d68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/dist/@types/config/schemas.js +150 -94
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +88 -87
  4. package/dist/composables/useRecommendation.js +16 -12
  5. package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
  6. package/dist/config/migrator/index.js +9 -9
  7. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  8. package/dist/config/migrator/recommendation/extractors.js +27 -0
  9. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  10. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  11. package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
  12. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  13. package/dist/config/migrator/recommendationMigrator.js +74 -290
  14. package/dist/enums/extensions/recommendationBlock.js +2 -1
  15. package/dist/enums/unsubscribe.js +34 -27
  16. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  17. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  18. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  19. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  20. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +21 -19
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  22. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  23. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  24. package/dist/guido.css +1 -1
  25. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
  26. package/dist/node_modules/valibot/dist/index.js +450 -235
  27. package/dist/package.json.js +1 -1
  28. package/dist/src/@types/config/defaults.d.ts +5 -1
  29. package/dist/src/@types/config/index.d.ts +3 -3
  30. package/dist/src/@types/config/schemas.d.ts +213 -0
  31. package/dist/src/@types/config/types.d.ts +9 -1
  32. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  33. package/dist/src/composables/useConfig.d.ts +56 -0
  34. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  35. package/dist/src/config/migrator/index.d.ts +2 -1
  36. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  37. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  38. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  39. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  40. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  41. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  42. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  43. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  44. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  45. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  46. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  47. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  48. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  49. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  50. package/dist/src/enums/unsubscribe.d.ts +5 -0
  51. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  52. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  53. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  54. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  55. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  56. package/dist/src/stores/config.d.ts +504 -0
  57. package/dist/src/utils/htmlEscape.d.ts +5 -0
  58. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  59. package/dist/utils/htmlEscape.js +13 -0
  60. package/package.json +7 -3
  61. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
@@ -0,0 +1,496 @@
1
+ import { RecommendationBlockId as g } from "../../../extensions/Blocks/Recommendation/constants/blockIds.js";
2
+ import { CURRENCY_ATTR as R, ATTR_PRODUCT_IMAGE as I, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_NAME as G, ATTR_PRODUCT_PRICE as z, ATTR_PRODUCT_OLD_PRICE as H, ATTR_PRODUCT_OMNIBUS_PRICE as U, ATTR_PRODUCT_OMNIBUS_DISCOUNT as j, ATTR_CUSTOM_PREFIX as E } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
+ import { formatPrice as v } from "../../../extensions/Blocks/Recommendation/utils/priceFormatter.js";
4
+ import { escapeHtml as c } from "../../../utils/htmlEscape.js";
5
+ import { appendStyle as $ } from "./themeMapper.js";
6
+ const V = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png", Y = "attribute-cell", F = "Buy", J = "border-width: 1px; background: rgb(217, 234, 211); border-color: rgb(106, 168, 79)", X = "color: rgb(56, 118, 29); background: rgb(217, 234, 211)", et = "ins-recommendation-product-container ins-recommendation-desktop-container";
7
+ function ot(t) {
8
+ return t.replace(/>\s+</g, "><").trim();
9
+ }
10
+ function y(t) {
11
+ return t ? ` align="${c(t)}"` : ' align="center"';
12
+ }
13
+ function _() {
14
+ return {
15
+ tdStyle: "",
16
+ pStyle: "",
17
+ wrapBold: !1,
18
+ wrapItalic: !1,
19
+ textTrimming: !1
20
+ };
21
+ }
22
+ function K(t) {
23
+ return t ? { ...t, wrapBold: !0 } : { ..._(), wrapBold: !0 };
24
+ }
25
+ function N(t, o) {
26
+ let e = c(t);
27
+ return o.wrapBold && o.wrapItalic ? e = `<strong><em>${e}</em></strong>` : o.wrapBold ? e = `<strong>${e}</strong>` : o.wrapItalic && (e = `<em>${e}</em>`), e;
28
+ }
29
+ function b(t) {
30
+ return t ? ` style="${c(t)}"` : "";
31
+ }
32
+ function O(t, o) {
33
+ return `<td width="${t}%" class="${Y}" ${o}`;
34
+ }
35
+ function nt(t, o, e, l) {
36
+ const s = t.width ? ` width="${t.width}"` : "", n = t.height ? ` height="${t.height}"` : "", i = ["display: block", "max-width: 100%", "height: auto"];
37
+ t.width && i.push(`width: ${t.width}px`), t.height && i.push(`height: ${t.height}px`);
38
+ const r = i.join("; "), a = e ? ` style="background-color: ${c(e)}"` : "";
39
+ return `
40
+ ${O(l, 'valign="top" style="padding: 0 5px; height: 100%"')}>
41
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
42
+ class="product-card-segment"${a}>
43
+ <tbody>
44
+ <tr valign="top">
45
+ <td align="center"
46
+ class="esd-block-image product-image es-p5"
47
+ esd-extension-block-id="${g.IMAGE}">
48
+ <a target="_blank" href="https://example.com/product/${o + 1}">
49
+ <img src="${V}" alt="Product Name"
50
+ class="adapt-img"${s}${n}
51
+ style="${r}">
52
+ </a>
53
+ </td>
54
+ </tr>
55
+ </tbody>
56
+ </table>
57
+ </td>
58
+ `;
59
+ }
60
+ function D(t, o, e, l, s, n, i) {
61
+ const a = `table-layout: fixed${n ? `; background-color: ${c(n)}` : ""}`, d = b(s.tdStyle), p = y(s.align), u = `esd-block-text ${o}`.trim(), m = $(l, s.pStyle);
62
+ return `
63
+ ${O(i, 'valign="top" style="padding: 0 5px; height: 100%"')}>
64
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
65
+ class="product-card-segment" style="${a}">
66
+ <tbody>
67
+ <tr valign="top">
68
+ <td${p}
69
+ class="${u}"
70
+ esd-extension-block-id="${t}"${d}>
71
+ <p contenteditable="false"${b(m)}>${N(e, s)}</p>
72
+ </td>
73
+ </tr>
74
+ </tbody>
75
+ </table>
76
+ </td>
77
+ `;
78
+ }
79
+ function lt(t, o, e, l) {
80
+ const s = o ? ` style="background-color: ${c(o)}"` : "", n = b(t.tdStyle), i = y(t.align), a = $("font-size: 14px; color: #999999", t.pStyle);
81
+ return `
82
+ ${O(e, 'valign="top" style="padding: 0 5px; height: 100%"')}>
83
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
84
+ class="product-card-segment"${s}>
85
+ <tbody>
86
+ <tr valign="top">
87
+ <td${i}
88
+ class="esd-block-text product-old-price es-p15l es-p15r"
89
+ esd-extension-block-id="${g.OLD_PRICE}"${n}>
90
+ <p contenteditable="false"${b(a)}>
91
+ <s>${N(l, t)}</s>
92
+ </p>
93
+ </td>
94
+ </tr>
95
+ </tbody>
96
+ </table>
97
+ </td>
98
+ `;
99
+ }
100
+ function L(t, o, e, l, s, n, i) {
101
+ const r = s ? `; background-color: ${c(s)}` : "", a = b(l.tdStyle), d = y(l.align), u = $("font-size: 12px; color: #666666", l.pStyle);
102
+ return `
103
+ ${O(i, 'valign="top" style="padding: 0 5px; height: 100%"')}>
104
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
105
+ class="product-card-segment" style="table-layout: fixed${r}">
106
+ <tbody>
107
+ <tr valign="top">
108
+ <td${d}
109
+ data-text-before="" data-text-after=""
110
+ class="esd-block-text ${n} es-p15l es-p15r"
111
+ esd-extension-block-id="${t}"${a}>
112
+ <p contenteditable="false"${b(u)}>
113
+ <span class="omnibus-text-before"></span>
114
+ <span class="${o}">${c(e)}</span>
115
+ <span class="omnibus-text-after"></span>
116
+ </p>
117
+ </td>
118
+ </tr>
119
+ </tbody>
120
+ </table>
121
+ </td>
122
+ `;
123
+ }
124
+ function st(t, o, e, l) {
125
+ const s = e ? ` style="background-color: ${c(e)}"` : "", n = $("padding: 0 5px; height: 100%", o.tdStyle), i = y(o.align), r = o.text || F, a = $(J, o.spanStyle), d = $(X, o.aStyle);
126
+ return `
127
+ ${O(l, `valign="top" style="${c(n)}"`)}>
128
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
129
+ class="product-card-segment"${s}>
130
+ <tbody>
131
+ <tr valign="top">
132
+ <td${i}
133
+ class="esd-block-button product-button es-p10t es-p10b es-p5l es-p5r"
134
+ esd-extension-block-id="${g.BUTTON}">
135
+ <span class="es-button-border" style="${c(a)}">
136
+ <a href="https://example.com/product/${t + 1}" target="_blank"
137
+ class="es-button buy-button"
138
+ style="${c(d)}">${c(r)}</a>
139
+ </span>
140
+ </td>
141
+ </tr>
142
+ </tbody>
143
+ </table>
144
+ </td>
145
+ `;
146
+ }
147
+ function it(t, o, e, l, s) {
148
+ const n = l ? `; background-color: ${c(l)}` : "", i = b(e.tdStyle), r = y(e.align), d = $("font-size: 12px; color: #666666; margin: 0", e.pStyle), p = o.replace(/_/g, " ").replace(/\b\w/g, (u) => u.toUpperCase());
149
+ return `
150
+ ${O(s, 'valign="middle" style="padding: 0 5px; height: 100%"')}>
151
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
152
+ class="product-card-segment" style="table-layout: fixed${n}">
153
+ <tbody>
154
+ <tr valign="top">
155
+ <td product-attr="${c(t)}"${r}
156
+ class="esd-block-text product-custom-attribute es-p0t es-p0b es-p15l es-p15r"
157
+ esd-extension-block-id="${g.CUSTOM_ATTRIBUTE}"${i}>
158
+ <p contenteditable="false"${b(d)}>${c(p)}</p>
159
+ </td>
160
+ </tr>
161
+ </tbody>
162
+ </table>
163
+ </td>
164
+ `;
165
+ }
166
+ function ct(t, o, e, l, s, n, i) {
167
+ const r = o[t], a = r ?? _();
168
+ switch (t) {
169
+ case I:
170
+ return nt(
171
+ r ?? {},
172
+ s,
173
+ l,
174
+ n
175
+ );
176
+ case G:
177
+ return D(
178
+ g.NAME,
179
+ "product-name es-p10t es-p10b es-p15l es-p15r",
180
+ "Product Name",
181
+ "font-size: 16px; color: #333333",
182
+ a,
183
+ l,
184
+ n
185
+ );
186
+ case z:
187
+ return D(
188
+ g.PRICE,
189
+ "product-price es-p15l es-p15r",
190
+ i.pricePlaceholder,
191
+ "font-size: 16px; color: #333333",
192
+ K(r),
193
+ l,
194
+ n
195
+ );
196
+ case H:
197
+ return lt(a, l, n, i.oldPricePlaceholder);
198
+ case U:
199
+ return L(
200
+ g.OMNIBUS_PRICE,
201
+ "omnibus-price-value",
202
+ i.omnibusPricePlaceholder,
203
+ a,
204
+ l,
205
+ "product-omnibus-price",
206
+ n
207
+ );
208
+ case j:
209
+ return L(
210
+ g.OMNIBUS_DISCOUNT,
211
+ "omnibus-discount-value",
212
+ "-10%",
213
+ a,
214
+ l,
215
+ "product-omnibus-discount",
216
+ n
217
+ );
218
+ case k:
219
+ return st(
220
+ s,
221
+ r ?? {},
222
+ l,
223
+ n
224
+ );
225
+ default:
226
+ if (t.startsWith(E)) {
227
+ const d = e[t] ?? t.slice(E.length), p = t.slice(E.length);
228
+ return it(d, p, a, l, n);
229
+ }
230
+ return null;
231
+ }
232
+ }
233
+ const q = `
234
+ <tr>
235
+ <td class="spacer" style="height: 10px"></td>
236
+ </tr>
237
+ `;
238
+ function rt(t) {
239
+ return {
240
+ pricePlaceholder: v({ price: 18, currency: t }),
241
+ oldPricePlaceholder: v({ price: 20, currency: t }),
242
+ omnibusPricePlaceholder: v({ price: 20, currency: t })
243
+ };
244
+ }
245
+ function at(t, o, e, l) {
246
+ const { composition: s, visibility: n, perElement: i, customAttrValues: r, cardBg: a } = l, d = (100 / e).toFixed(2), p = e - o, u = `<td class="${Y}" style="padding: 0 5px;" width="${d}%"></td>`, m = p > 0 ? u.repeat(p) : "";
247
+ return `
248
+ <tr class="recommendation-product-row">
249
+ <td>
250
+ <table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
251
+ class="product-card-wrapper" style="table-layout: fixed">
252
+ <tbody>${s.map((T) => {
253
+ const w = n[T] !== !1, f = w ? "" : ' style="display: none"', C = w ? "1" : "0", S = [];
254
+ for (let x = 0; x < o; x += 1) {
255
+ const A = ct(
256
+ T,
257
+ i,
258
+ r,
259
+ a,
260
+ t + x,
261
+ d,
262
+ l
263
+ );
264
+ A && S.push(A);
265
+ }
266
+ return S.length === 0 ? "" : `
267
+ <tr class="recommendation-attribute-row"
268
+ data-attribute-type="${c(T)}"
269
+ data-visibility="${C}"${f}>
270
+ ${S.join("")}${m}
271
+ </tr>
272
+ `;
273
+ }).filter(Boolean).join("")}</tbody>
274
+ </table>
275
+ </td>
276
+ </tr>
277
+ `;
278
+ }
279
+ function dt(t, o, e) {
280
+ const l = [];
281
+ for (let s = 0; s < t; s += o) {
282
+ const n = Math.min(o, t - s);
283
+ s > 0 && l.push(q), l.push(at(s, n, o, e));
284
+ }
285
+ return l.join("");
286
+ }
287
+ function pt(t, o, e, l) {
288
+ const s = o[t];
289
+ if (t === G) {
290
+ const n = s ?? _(), i = $("font-size: 16px; color: #333333; margin: 0", n.pStyle), r = y(n.align ?? "left");
291
+ return `
292
+ <td class="esd-block-text product-name"
293
+ esd-extension-block-id="${g.NAME}"${r}${b(n.tdStyle)}>
294
+ <p contenteditable="false"${b(i)}>${N("Product Name", n)}</p>
295
+ </td>
296
+ `;
297
+ }
298
+ if (t === z) {
299
+ const n = K(s), i = $("font-size: 16px; color: #333333; margin: 0", n.pStyle), r = y(n.align ?? "left");
300
+ return `
301
+ <td class="esd-block-text product-price"
302
+ esd-extension-block-id="${g.PRICE}"${r}${b(n.tdStyle)}>
303
+ <p contenteditable="false"${b(i)}>${N(l.pricePlaceholder, n)}</p>
304
+ </td>
305
+ `;
306
+ }
307
+ if (t === H) {
308
+ const n = s ?? _(), r = $("font-size: 14px; color: #999999; text-decoration: line-through; margin: 0", n.pStyle), a = y(n.align ?? "left");
309
+ return `
310
+ <td class="esd-block-text product-old-price"
311
+ esd-extension-block-id="${g.OLD_PRICE}"${a}${b(n.tdStyle)}>
312
+ <p contenteditable="false"${b(r)}><s>${N(l.oldPricePlaceholder, n)}</s></p>
313
+ </td>
314
+ `;
315
+ }
316
+ if (t === U || t === j) {
317
+ const n = t === U, i = n ? g.OMNIBUS_PRICE : g.OMNIBUS_DISCOUNT, r = n ? "omnibus-price-value" : "omnibus-discount-value", a = n ? l.omnibusPricePlaceholder : "-10%", d = n ? "product-omnibus-price" : "product-omnibus-discount", p = s ?? _(), u = $("font-size: 12px; color: #666666; margin: 0", p.pStyle), m = y(p.align ?? "left");
318
+ return `
319
+ <td class="esd-block-text ${d}"
320
+ data-text-before="" data-text-after=""
321
+ esd-extension-block-id="${i}"${m}${b(p.tdStyle)}>
322
+ <p contenteditable="false"${b(u)}>
323
+ <span class="omnibus-text-before"></span>
324
+ <span class="${r}">${c(a)}</span>
325
+ <span class="omnibus-text-after"></span>
326
+ </p>
327
+ </td>
328
+ `;
329
+ }
330
+ if (t.startsWith(E)) {
331
+ const n = s ?? _(), i = e[t] ?? t.slice(E.length), a = t.slice(E.length).replace(/_/g, " ").replace(/\b\w/g, (m) => m.toUpperCase()), d = $("font-size: 12px; color: #666666; margin: 0", n.pStyle), p = y(n.align ?? "left"), u = g.CUSTOM_ATTRIBUTE;
332
+ return `
333
+ <td product-attr="${c(i)}"
334
+ class="esd-block-text product-custom-attribute"
335
+ esd-extension-block-id="${u}"${p}${b(n.tdStyle)}>
336
+ <p contenteditable="false"${b(d)}>${c(a)}</p>
337
+ </td>
338
+ `;
339
+ }
340
+ return null;
341
+ }
342
+ function ut(t, o) {
343
+ const { composition: e, visibility: l, perElement: s, customAttrValues: n, cardBg: i } = o, r = i ? `background-color: ${c(i)}` : "", a = r ? `style="table-layout: fixed; ${r}"` : 'style="table-layout: fixed"', d = s[I] ?? {}, p = l[I] !== !1, u = d.width ? ` width="${d.width}"` : "", m = p ? "" : ' style="display: none"', h = `
344
+ <td width="120"
345
+ class="esd-block-image product-image-cell recommendation-attribute-row es-p5"
346
+ esd-extension-block-id="${g.IMAGE}"
347
+ data-attribute-type="${I}"
348
+ data-visibility="${p ? "1" : "0"}"
349
+ align="center" valign="middle"${m}>
350
+ <a target="_blank" href="https://example.com/product/${t + 1}">
351
+ <img src="${V}" alt="Product Name"
352
+ class="adapt-img product-image"${u}
353
+ style="display: block; max-width: 100%; height: auto">
354
+ </a>
355
+ </td>
356
+ `, w = `
357
+ <td class="product-info-cell" valign="middle" style="padding: 15px">
358
+ <table cellpadding="0" cellspacing="0" role="presentation" width="100%"
359
+ style="table-layout: fixed">
360
+ <tbody>${e.filter((P) => P !== I && P !== k).map((P) => {
361
+ const B = l[P] !== !1, W = B ? "" : ' style="display: none"', tt = B ? "1" : "0", M = pt(P, s, n, o);
362
+ return M ? `<tr class="recommendation-attribute-row"
363
+ data-attribute-type="${c(P)}"
364
+ data-visibility="${tt}"${W}>${M}</tr>` : "";
365
+ }).filter(Boolean).join(`
366
+ `)}</tbody>
367
+ </table>
368
+ </td>
369
+ `, f = s[k] ?? {}, C = l[k] !== !1, S = f.text || F, x = $(J, f.spanStyle ?? ""), A = $(X, f.aStyle ?? ""), Q = C ? "" : ' style="display: none"', Z = `
370
+ <td width="100"
371
+ class="esd-block-button button-cell recommendation-attribute-row product-button es-p5l es-p5r"
372
+ esd-extension-block-id="${g.BUTTON}"
373
+ data-attribute-type="${k}"
374
+ data-visibility="${C ? "1" : "0"}"
375
+ align="${c(f.align ?? "center")}" valign="middle"${Q}>
376
+ <span class="es-button-border" style="${c(x)}">
377
+ <a href="https://example.com/product/${t + 1}" target="_blank"
378
+ class="es-button buy-button"
379
+ style="${c(A)}">${c(S)}</a>
380
+ </span>
381
+ </td>
382
+ `;
383
+ return `
384
+ <tr class="recommendation-product-row">
385
+ <td style="padding: 0 5px">
386
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"
387
+ class="product-card-wrapper" ${a}>
388
+ <tbody>
389
+ <tr>${h}${w}${Z}</tr>
390
+ </tbody>
391
+ </table>
392
+ </td>
393
+ </tr>
394
+ `;
395
+ }
396
+ function bt(t, o) {
397
+ const e = [];
398
+ for (let l = 0; l < t; l += 1)
399
+ l > 0 && e.push(q), e.push(ut(l, o));
400
+ return e.join("");
401
+ }
402
+ function gt(t, o) {
403
+ var a, d, p, u, m, h;
404
+ const e = t == null ? void 0 : t.theme, l = [];
405
+ (a = e == null ? void 0 : e.textStyle) != null && a["font-family"] && l.push(`font-family: ${e.textStyle["font-family"]}`), l.push(`font-size: ${((d = e == null ? void 0 : e.textStyle) == null ? void 0 : d["font-size"]) ?? "28px"}`), l.push(`color: ${((p = e == null ? void 0 : e.textColor) == null ? void 0 : p.color) ?? "#333333"}`), (u = e == null ? void 0 : e.textStyle) != null && u["font-weight"] && l.push(`font-weight: ${e.textStyle["font-weight"]}`), (m = e == null ? void 0 : e.textStyle) != null && m["font-style"] && l.push(`font-style: ${e.textStyle["font-style"]}`);
406
+ const s = l.join("; "), n = ((h = e == null ? void 0 : e.textStyle) == null ? void 0 : h["font-weight"]) !== "normal", i = c(o), r = n ? `<strong>${i}</strong>` : i;
407
+ return `
408
+ <td class="esd-block-text es-p10t es-p10b es-p20l es-p20r" align="center">
409
+ <p${b(s)}>${r}</p>
410
+ </td>
411
+ `;
412
+ }
413
+ function mt(t) {
414
+ const o = t.alignment === "before" ? "0" : "1";
415
+ return ` ${R.CURRENCY}="${c(t.code)}" ${R.SYMBOL}="${c(t.symbol)}" ${R.ALIGNMENT}="${o}" ${R.THOUSAND_SEPARATOR}="${c(t.thousandSeparator)}" ${R.DECIMAL_SEPARATOR}="${c(t.decimalSeparator)}" ${R.DECIMAL_COUNT}="${t.decimalCount}"`;
416
+ }
417
+ function xt(t) {
418
+ const {
419
+ nodeConfig: o,
420
+ composition: e,
421
+ cardBg: l,
422
+ titleText: s,
423
+ extraClasses: n = "",
424
+ legacyId: i,
425
+ legacyBgColor: r
426
+ } = t, a = parseInt(o.size) || 6, d = o.layout === "list" ? ' data-layout="list"' : "", p = o.layout === "list" ? " es-m-p0 ins-recommendation-list-layout" : "", u = {
427
+ composition: e.composition,
428
+ visibility: e.visibility,
429
+ perElement: e.perElementStyles,
430
+ customAttrValues: e.customAttrValues,
431
+ cardBg: l,
432
+ ...rt(o.currency)
433
+ }, m = o.layout === "list" ? bt(a, u) : dt(a, o.cardsInRow, u), h = gt(e.titleVariable, s), T = e.composition.join(","), w = JSON.stringify(e.customAttributes), f = [
434
+ "recommendation-block-v2",
435
+ "esd-block-recommendation-v3-block",
436
+ `es-p20${p}`,
437
+ `ins-recommendation-v3-block-${o.recommendationId}`,
438
+ // Marker class Stripo's block infrastructure uses to identify recommendation
439
+ // blocks. Without it, certain Styles-panel controls (e.g. button "Fit to
440
+ // Container") are suppressed even though every other selector matches.
441
+ "esd-recommendation-block",
442
+ "esd-extension-block",
443
+ "esd-container-frame",
444
+ "ins-recommendation-no-mobile-layout",
445
+ n
446
+ ].filter(Boolean).join(" "), C = mt(o.currency), S = ` esd-ext-config="${c(JSON.stringify(o))}"`, x = i ? ` id="${c(i)}"` : "", A = r ? ` bgcolor="${c(r)}"` : "";
447
+ return ot(`
448
+ <td align="left"
449
+ esd-extension-block-id="recommendation-block"
450
+ width="520"
451
+ class="${f}"${x}${A}
452
+ recommendation-id="${o.recommendationId}"${C}
453
+ data-card-composition="${c(T)}"
454
+ data-custom-attributes="${c(w)}"
455
+ data-column-spacing="${o.columnSpacing}"
456
+ data-row-spacing="${o.rowSpacing}"
457
+ data-mobile-column-spacing="${o.mobileColumnSpacing}"
458
+ data-mobile-row-spacing="${o.mobileRowSpacing}"${d}${S}>
459
+ <table width="100%" cellpadding="0" cellspacing="0" border="0">
460
+ <tbody>
461
+ <tr>
462
+ <td align="center">
463
+ <table class="container" width="100%" cellpadding="0" cellspacing="0" border="0">
464
+ <tbody>
465
+ <tr>
466
+ <td>
467
+ <table width="100%" cellpadding="0" cellspacing="0" border="0">
468
+ <tbody>
469
+ <tr>${h}</tr>
470
+ </tbody>
471
+ </table>
472
+ </td>
473
+ </tr>
474
+ <tr>
475
+ <td class="spacer" style="height: ${o.rowSpacing}px"></td>
476
+ </tr>
477
+ <tr>
478
+ <td>
479
+ <table width="100%" cellpadding="0" cellspacing="0" border="0"
480
+ class="${et}">${m}
481
+ </table>
482
+ </td>
483
+ </tr>
484
+ <tr class="ins-recommendation-mobile-row"></tr>
485
+ </tbody>
486
+ </table>
487
+ </td>
488
+ </tr>
489
+ </tbody>
490
+ </table>
491
+ </td>
492
+ `);
493
+ }
494
+ export {
495
+ xt as buildBlockHtml
496
+ };
@@ -0,0 +1,33 @@
1
+ function c(e) {
2
+ return e.replace(/&#x27;/g, "'").replace(/&#x2F;/g, "/").replace(/&apos;/g, "'").replace(/&quot;/g, '"').replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&amp;/g, "&");
3
+ }
4
+ function s(e) {
5
+ const t = e.getAttribute("esd-dev-product-config");
6
+ if (!t)
7
+ return null;
8
+ try {
9
+ const n = c(c(t));
10
+ return JSON.parse(n);
11
+ } catch {
12
+ return null;
13
+ }
14
+ }
15
+ function i(e) {
16
+ const t = e.getAttribute("ins-recommendation-v3-campaign-id");
17
+ if (t) {
18
+ const r = parseInt(t);
19
+ if (!Number.isNaN(r))
20
+ return r;
21
+ }
22
+ const a = (e.getAttribute("class") ?? "").match(/ins-recommendation-v3-block-(\d+)/);
23
+ if (a) {
24
+ const r = parseInt(a[1]);
25
+ if (!Number.isNaN(r))
26
+ return r;
27
+ }
28
+ return null;
29
+ }
30
+ export {
31
+ s as parseLegacyConfig,
32
+ i as parseRecommendationId
33
+ };
@@ -0,0 +1,78 @@
1
+ import { CURRENT_CONFIG_VERSION as s, DEFAULT_CURRENCY as i } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
+ import { DEFAULT_CARDS_IN_ROW as m, DEFAULT_MOBILE_ROW_SPACING as p, DEFAULT_MOBILE_COLUMN_SPACING as f, DEFAULT_ROW_SPACING as d, DEFAULT_COLUMN_SPACING as S, DEFAULT_MOBILE_CARDS_IN_ROW as u } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
3
+ function c(t) {
4
+ return t === "0" || t === 0 ? "before" : "after";
5
+ }
6
+ function l(t) {
7
+ if (typeof t == "number" && Number.isFinite(t))
8
+ return t;
9
+ if (typeof t == "string") {
10
+ const n = parseInt(t);
11
+ if (!Number.isNaN(n))
12
+ return n;
13
+ }
14
+ return i.decimalCount;
15
+ }
16
+ function _(t) {
17
+ return t === "." || t === "," || t === " " || t === "" ? t : ",";
18
+ }
19
+ function I(t) {
20
+ return t === "." || t === "," || t === " " ? t : ".";
21
+ }
22
+ function A(t) {
23
+ if (!t || typeof t != "object")
24
+ return { ...i };
25
+ const n = t, r = n.value ?? n.name ?? i.code, o = n.symbol ?? r;
26
+ return {
27
+ code: r,
28
+ symbol: o,
29
+ alignment: c(n.alignment),
30
+ decimalCount: l(n.decimalCount),
31
+ decimalSeparator: I(n.decimalSeparator),
32
+ thousandSeparator: _(n.thousandSeparator)
33
+ };
34
+ }
35
+ function N(t) {
36
+ return t === "horizontal" || t === "list" ? "list" : "grid";
37
+ }
38
+ function R(t) {
39
+ if (!t)
40
+ return "mostPopular";
41
+ switch (t) {
42
+ case "viewedTogether":
43
+ return "similarViewed";
44
+ case "purchasedTogether":
45
+ return "similarBought";
46
+ default:
47
+ return t;
48
+ }
49
+ }
50
+ function L(t, n, r) {
51
+ const o = n.rowCount ?? t.cardsInRow ?? m, a = n.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
52
+ return {
53
+ recommendationId: r,
54
+ strategy: R(t.strategy),
55
+ productIds: (t.productIds ?? []).map((e) => String(e)),
56
+ size: String(a),
57
+ shuffleProducts: !!t.shuffleProducts,
58
+ language: t.language ?? "en_US",
59
+ currency: A(t.currencySettings),
60
+ filters: (t.filters ?? []).map((e) => ({ ...e })),
61
+ layout: N(t.orientation ?? n.orientation),
62
+ cardsInRow: o,
63
+ mobileCardsInRow: u,
64
+ mobileLayoutEnabled: !1,
65
+ previousMobileCardsInRow: u,
66
+ columnSpacing: S,
67
+ rowSpacing: d,
68
+ mobileColumnSpacing: f,
69
+ mobileRowSpacing: p,
70
+ omnibusPrice: { textBefore: "", textAfter: "" },
71
+ omnibusDiscount: { textBefore: "", textAfter: "" },
72
+ configVersion: s
73
+ };
74
+ }
75
+ export {
76
+ A as mapCurrency,
77
+ L as mapSettings
78
+ };