@useinsider/guido 3.2.0 → 3.3.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.
Files changed (144) hide show
  1. package/README.md +117 -1
  2. package/dist/@types/config/schemas.js +153 -95
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +90 -88
  5. package/dist/components/organisms/AutoSaveController.vue.js +17 -0
  6. package/dist/components/organisms/AutoSaveController.vue2.js +13 -0
  7. package/dist/components/organisms/header/AutoSaveToggle.vue.js +22 -0
  8. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +19 -0
  9. package/dist/components/organisms/header/RightSlot.vue.js +8 -8
  10. package/dist/components/organisms/header/RightSlot.vue2.js +9 -8
  11. package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
  12. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  13. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
  14. package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
  15. package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
  16. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
  17. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
  18. package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
  19. package/dist/composables/useActionsApi.js +4 -4
  20. package/dist/composables/useAutoSave.js +71 -0
  21. package/dist/composables/useFullStoryBridge.js +14 -0
  22. package/dist/composables/useRecommendation.js +46 -26
  23. package/dist/composables/useRibbonOffset.js +21 -0
  24. package/dist/composables/useSave.js +19 -16
  25. package/dist/composables/useStripo.js +40 -40
  26. package/dist/composables/validators/useCouponBlockValidator.js +24 -0
  27. package/dist/config/compiler/recommendationCompilerRules.js +79 -74
  28. package/dist/config/compiler/unsubscribeCompilerRules.js +40 -37
  29. package/dist/config/compiler/utils/recommendationCompilerUtils.js +107 -71
  30. package/dist/config/migrator/index.js +9 -9
  31. package/dist/config/migrator/radioButtonMigrator.js +64 -44
  32. package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
  33. package/dist/config/migrator/recommendation/extractors.js +27 -0
  34. package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
  35. package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
  36. package/dist/config/migrator/recommendation/settingsMapper.js +70 -0
  37. package/dist/config/migrator/recommendation/themeMapper.js +93 -0
  38. package/dist/config/migrator/recommendationMigrator.js +74 -290
  39. package/dist/enums/extensions/recommendationBlock.js +2 -1
  40. package/dist/enums/onboarding.js +7 -2
  41. package/dist/enums/unsubscribe.js +34 -27
  42. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
  43. package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
  44. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  45. package/dist/extensions/Blocks/Recommendation/block.js +35 -32
  46. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  47. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  48. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
  49. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
  50. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +27 -26
  51. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
  52. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +228 -181
  53. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
  54. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
  55. package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
  56. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
  57. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +123 -79
  58. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +19 -10
  59. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  60. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +25 -15
  61. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
  62. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  63. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
  64. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +21 -0
  65. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
  66. package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
  67. package/dist/guido.css +1 -1
  68. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
  69. package/dist/node_modules/valibot/dist/index.js +450 -235
  70. package/dist/package.json.js +1 -1
  71. package/dist/services/templateLibraryApi.js +5 -4
  72. package/dist/src/@types/config/defaults.d.ts +5 -1
  73. package/dist/src/@types/config/index.d.ts +3 -3
  74. package/dist/src/@types/config/schemas.d.ts +217 -0
  75. package/dist/src/@types/config/types.d.ts +9 -1
  76. package/dist/src/components/Guido.vue.d.ts +1 -1
  77. package/dist/src/components/organisms/AutoSaveController.vue.d.ts +2 -0
  78. package/dist/src/components/organisms/header/AutoSaveToggle.vue.d.ts +2 -0
  79. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  80. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  81. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  82. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  83. package/dist/src/composables/useActionsApi.d.ts +1 -1
  84. package/dist/src/composables/useAutoSave.d.ts +3 -0
  85. package/dist/src/composables/useConfig.d.ts +58 -0
  86. package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
  87. package/dist/src/composables/useRecommendation.d.ts +10 -1
  88. package/dist/src/composables/useRecommendation.test.d.ts +1 -0
  89. package/dist/src/composables/useRibbonOffset.d.ts +4 -0
  90. package/dist/src/composables/useSave.d.ts +1 -1
  91. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +3 -0
  92. package/dist/src/config/migrator/index.d.ts +2 -1
  93. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
  94. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
  95. package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
  96. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
  97. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
  98. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
  99. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
  100. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
  101. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
  102. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
  103. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
  104. package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
  105. package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
  106. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
  107. package/dist/src/enums/onboarding.d.ts +6 -0
  108. package/dist/src/enums/unsubscribe.d.ts +5 -0
  109. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  110. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
  111. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
  112. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
  113. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
  114. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
  115. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
  116. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
  117. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
  118. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +34 -0
  119. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  120. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +21 -0
  121. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +1 -0
  122. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
  123. package/dist/src/library.d.ts +1 -1
  124. package/dist/src/stores/autosave.d.ts +12 -0
  125. package/dist/src/stores/config.d.ts +522 -0
  126. package/dist/src/stores/editor.d.ts +23 -0
  127. package/dist/src/stores/onboarding.d.ts +4 -0
  128. package/dist/src/utils/htmlEscape.d.ts +5 -0
  129. package/dist/src/utils/htmlEscape.test.d.ts +1 -0
  130. package/dist/src/utils/timeUtil.d.ts +8 -0
  131. package/dist/static/styles/components/button.css.js +16 -9
  132. package/dist/static/styles/components/loader.css.js +4 -0
  133. package/dist/static/styles/components/narrow-panel.css.js +52 -0
  134. package/dist/stores/autosave.js +17 -0
  135. package/dist/stores/editor.js +3 -1
  136. package/dist/stores/onboarding.js +4 -0
  137. package/dist/utils/htmlEscape.js +13 -0
  138. package/dist/utils/pairProductVariables.js +89 -88
  139. package/dist/utils/templatePreparation.js +72 -32
  140. package/dist/utils/timeUtil.js +19 -0
  141. package/package.json +7 -3
  142. package/dist/enums/displayConditions.js +0 -80
  143. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  144. package/dist/src/enums/displayConditions.d.ts +0 -2
@@ -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 z, ATTR_PRODUCT_PRICE as G, 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 N } 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); font-family: arial, 'helvetica neue', helvetica, sans-serif; font-size: 16px; font-weight: normal; line-height: 120%; mso-border-alt: 10px solid rgb(217, 234, 211); mso-padding-alt: 0", 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 v(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 a = i.join("; "), r = 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"${r}>
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="${a}">
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 r = `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="${r}">
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)}>${v(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), r = $("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(r)}>
91
+ <s>${v(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 a = s ? `; background-color: ${c(s)}` : "", r = 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${a}">
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}"${r}>
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), a = o.text || F, r = $(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(r)}">
136
+ <a href="https://example.com/product/${t + 1}" target="_blank"
137
+ class="es-button buy-button"
138
+ style="${c(d)}">${c(a)}</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), a = 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)}"${a}
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 a = o[t], r = a ?? _();
168
+ switch (t) {
169
+ case I:
170
+ return nt(
171
+ a ?? {},
172
+ s,
173
+ l,
174
+ n
175
+ );
176
+ case z:
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
+ r,
183
+ l,
184
+ n
185
+ );
186
+ case G:
187
+ return D(
188
+ g.PRICE,
189
+ "product-price es-p15l es-p15r",
190
+ i.pricePlaceholder,
191
+ "font-size: 16px; color: #333333",
192
+ K(a),
193
+ l,
194
+ n
195
+ );
196
+ case H:
197
+ return lt(r, l, n, i.oldPricePlaceholder);
198
+ case U:
199
+ return L(
200
+ g.OMNIBUS_PRICE,
201
+ "omnibus-price-value",
202
+ i.omnibusPricePlaceholder,
203
+ r,
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
+ r,
214
+ l,
215
+ "product-omnibus-discount",
216
+ n
217
+ );
218
+ case k:
219
+ return st(
220
+ s,
221
+ a ?? {},
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, r, 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 at(t) {
239
+ return {
240
+ pricePlaceholder: N({ price: 18, currency: t }),
241
+ oldPricePlaceholder: N({ price: 20, currency: t }),
242
+ omnibusPricePlaceholder: N({ price: 20, currency: t })
243
+ };
244
+ }
245
+ function rt(t, o, e, l) {
246
+ const { composition: s, visibility: n, perElement: i, customAttrValues: a, cardBg: r } = 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
+ a,
259
+ r,
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(rt(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 === z) {
290
+ const n = s ?? _(), i = $("font-size: 16px; color: #333333; margin: 0", n.pStyle), a = y(n.align ?? "left");
291
+ return `
292
+ <td class="esd-block-text product-name"
293
+ esd-extension-block-id="${g.NAME}"${a}${b(n.tdStyle)}>
294
+ <p contenteditable="false"${b(i)}>${v("Product Name", n)}</p>
295
+ </td>
296
+ `;
297
+ }
298
+ if (t === G) {
299
+ const n = K(s), i = $("font-size: 16px; color: #333333; margin: 0", n.pStyle), a = y(n.align ?? "left");
300
+ return `
301
+ <td class="esd-block-text product-price"
302
+ esd-extension-block-id="${g.PRICE}"${a}${b(n.tdStyle)}>
303
+ <p contenteditable="false"${b(i)}>${v(l.pricePlaceholder, n)}</p>
304
+ </td>
305
+ `;
306
+ }
307
+ if (t === H) {
308
+ const n = s ?? _(), a = $("font-size: 14px; color: #999999; text-decoration: line-through; margin: 0", n.pStyle), r = y(n.align ?? "left");
309
+ return `
310
+ <td class="esd-block-text product-old-price"
311
+ esd-extension-block-id="${g.OLD_PRICE}"${r}${b(n.tdStyle)}>
312
+ <p contenteditable="false"${b(a)}><s>${v(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, a = n ? "omnibus-price-value" : "omnibus-discount-value", r = 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="${a}">${c(r)}</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), r = 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(r)}</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, a = i ? `background-color: ${c(i)}` : "", r = a ? `style="table-layout: fixed; ${a}"` : '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" ${r}>
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 r, d, p, u, m, h;
404
+ const e = t == null ? void 0 : t.theme, l = [];
405
+ (r = e == null ? void 0 : e.textStyle) != null && r["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), a = 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)}>${a}</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: a
426
+ } = t, r = 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
+ ...at(o.currency)
433
+ }, m = o.layout === "list" ? bt(r, u) : dt(r, 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 = a ? ` bgcolor="${c(a)}"` : "";
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,70 @@
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 S, DEFAULT_COLUMN_SPACING as d, DEFAULT_MOBILE_CARDS_IN_ROW as u } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
3
+ import { mapLegacyStrategy as c } from "../../../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
4
+ function l(t) {
5
+ return t === "0" || t === 0 ? "before" : "after";
6
+ }
7
+ function _(t) {
8
+ if (typeof t == "number" && Number.isFinite(t))
9
+ return t;
10
+ if (typeof t == "string") {
11
+ const n = parseInt(t);
12
+ if (!Number.isNaN(n))
13
+ return n;
14
+ }
15
+ return i.decimalCount;
16
+ }
17
+ function I(t) {
18
+ return t === "." || t === "," || t === " " || t === "" ? t : ",";
19
+ }
20
+ function A(t) {
21
+ return t === "." || t === "," || t === " " ? t : ".";
22
+ }
23
+ function N(t) {
24
+ if (!t || typeof t != "object")
25
+ return { ...i };
26
+ const n = t, o = n.value ?? n.name ?? i.code, r = n.symbol ?? o;
27
+ return {
28
+ code: o,
29
+ symbol: r,
30
+ alignment: l(n.alignment),
31
+ decimalCount: _(n.decimalCount),
32
+ decimalSeparator: A(n.decimalSeparator),
33
+ thousandSeparator: I(n.thousandSeparator)
34
+ };
35
+ }
36
+ function R(t) {
37
+ return t === "horizontal" || t === "list" ? "list" : "grid";
38
+ }
39
+ function b(t) {
40
+ return c(t) || "mostPopular";
41
+ }
42
+ function D(t, n, o) {
43
+ const r = n.rowCount ?? t.cardsInRow ?? m, a = n.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
44
+ return {
45
+ recommendationId: o,
46
+ strategy: b(t.strategy),
47
+ productIds: (t.productIds ?? []).map((e) => String(e)),
48
+ size: String(a),
49
+ shuffleProducts: !!t.shuffleProducts,
50
+ language: t.language ?? "en_US",
51
+ currency: N(t.currencySettings),
52
+ filters: (t.filters ?? []).map((e) => ({ ...e })),
53
+ layout: R(t.orientation ?? n.orientation),
54
+ cardsInRow: r,
55
+ mobileCardsInRow: u,
56
+ mobileLayoutEnabled: !1,
57
+ previousMobileCardsInRow: u,
58
+ columnSpacing: d,
59
+ rowSpacing: S,
60
+ mobileColumnSpacing: f,
61
+ mobileRowSpacing: p,
62
+ omnibusPrice: { textBefore: "", textAfter: "" },
63
+ omnibusDiscount: { textBefore: "", textAfter: "" },
64
+ configVersion: s
65
+ };
66
+ }
67
+ export {
68
+ N as mapCurrency,
69
+ D as mapSettings
70
+ };