@useinsider/guido 3.8.0 → 3.8.1-beta.0fbf78a

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 (54) hide show
  1. package/dist/composables/useHtmlValidator.js +180 -133
  2. package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -69
  3. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
  4. package/dist/config/migrator/itemsBlockMigrator.js +154 -115
  5. package/dist/config/migrator/recommendation/extractors.js +44 -22
  6. package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
  7. package/dist/config/migrator/recommendationMigrator.js +30 -31
  8. package/dist/extensions/Blocks/Items/template.js +26 -27
  9. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +22 -15
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +55 -41
  11. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -43
  12. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -45
  13. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
  14. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +64 -60
  15. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +294 -335
  16. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
  17. package/dist/extensions/Blocks/Recommendation/extension.js +7 -5
  18. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
  19. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
  20. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
  21. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -29
  22. package/dist/extensions/Blocks/Recommendation/templates/index.js +30 -8
  23. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
  24. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
  25. package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
  26. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
  27. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
  28. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
  29. package/dist/extensions/Blocks/Unsubscribe/block.js +1 -1
  30. package/dist/extensions/Blocks/controlFactories.js +159 -133
  31. package/dist/src/composables/useHtmlValidator.d.ts +27 -0
  32. package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
  33. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
  34. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
  35. package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
  36. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
  37. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  38. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  39. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +23 -0
  40. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +7 -1
  43. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
  44. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +29 -47
  45. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  46. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  47. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
  48. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
  49. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
  50. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
  51. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
  52. package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
  53. package/package.json +1 -1
  54. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
@@ -1,12 +1,12 @@
1
- var B = Object.defineProperty;
2
- var v = (r, t, o) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
3
- var M = (r, t, o) => v(r, typeof t != "symbol" ? t + "" : t, o);
4
- import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
5
- import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
- import { ItemInCartOptions as T, DefaultConfigValues as g, SETTINGS_ENUMS as s } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
- import { getDefaultTemplate as w } from "../../extensions/Blocks/Items/template.js";
8
- import { useTemplateStore as F } from "../../stores/template.js";
9
- const q = {
1
+ var v = Object.defineProperty;
2
+ var U = (o, t, r) => t in o ? v(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
3
+ var M = (o, t, r) => U(o, typeof t != "symbol" ? t + "" : t, r);
4
+ import { BLOCK_ID as K } from "../../extensions/Blocks/Items/block.js";
5
+ import { productPairs as w } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { ItemInCartOptions as I, DefaultConfigValues as g, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as F } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as q } from "../../stores/template.js";
9
+ const x = {
10
10
  img: {
11
11
  pairsKey: "imageSrc",
12
12
  defaultKey: "DEFAULT",
@@ -76,77 +76,77 @@ const q = {
76
76
  function O() {
77
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
78
  }
79
- function $(r) {
80
- return r ? {
81
- CartItems: s.ITEMS_TYPE.CART_ITEMS,
82
- BrowsedItems: s.ITEMS_TYPE.BROWSED_ITEMS,
83
- PurchasedItems: s.ITEMS_TYPE.PURCHASED_ITEMS,
84
- CART_ITEMS: s.ITEMS_TYPE.CART_ITEMS,
85
- BROWSED_ITEMS: s.ITEMS_TYPE.BROWSED_ITEMS,
86
- PURCHASED_ITEMS: s.ITEMS_TYPE.PURCHASED_ITEMS
87
- }[r] || s.ITEMS_TYPE.CART_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
79
+ function R(o) {
80
+ return o ? {
81
+ CartItems: p.ITEMS_TYPE.CART_ITEMS,
82
+ BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
83
+ PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
84
+ CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
85
+ BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
86
+ PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
87
+ }[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
88
88
  }
89
- function R(r) {
89
+ function k(o) {
90
90
  var e;
91
- const t = (c, _) => c == null ? _ : c === "1" || c === "true", o = (c, _) => c || _, l = r["data-type"] || r["data-source"], a = $(l), n = T[a];
92
- let i = r["data-cart_items_select_control_value"] || ((e = n == null ? void 0 : n[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
- if (i && !i.includes("{{") && /^\d+$/.test(i)) {
94
- const c = parseInt(i) - 1, _ = T[a];
95
- _ && _[c] && (i = _[c].value);
91
+ const t = (c, u) => c == null ? u : c === "1" || c === "true", r = (c, u) => c || u, l = o["data-type"] || o["data-source"], a = R(l), i = I[a];
92
+ let n = o["data-cart_items_select_control_value"] || ((e = i == null ? void 0 : i[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
93
+ if (n && !n.includes("{{") && /^\d+$/.test(n)) {
94
+ const c = parseInt(n) - 1, u = I[a];
95
+ u && u[c] && (n = u[c].value);
96
96
  }
97
97
  return {
98
98
  initialized: !0,
99
- blockInstanceId: o(r["data-block-instance-id"], O()),
99
+ blockInstanceId: r(o["data-block-instance-id"], O()),
100
100
  source: a,
101
101
  type: a,
102
- itemsSelectValue: i,
103
- orientation: r["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
104
- nameTrimming: t(r["data-product_name_control_trim"], !0),
105
- priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
106
- priceFormatted: t(r["data-product_price_control_formated"], !0),
107
- priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
108
- priceCurrencySymbol: o(
109
- r["data-product_price_control_currency_symbol"],
102
+ itemsSelectValue: n,
103
+ orientation: o["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
104
+ nameTrimming: t(o["data-product_name_control_trim"], !0),
105
+ priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
106
+ priceFormatted: t(o["data-product_price_control_formated"], !0),
107
+ priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
108
+ priceCurrencySymbol: r(
109
+ o["data-product_price_control_currency_symbol"],
110
110
  g.productPriceCurrencySymbolControlValue
111
111
  ),
112
- priceCurrencyLocation: o(
113
- r["data-product_price_currency_location"],
112
+ priceCurrencyLocation: r(
113
+ o["data-product_price_currency_location"],
114
114
  g.productPriceCurrencyLocationControlValue
115
115
  ),
116
- priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
117
- quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
118
- buttonLink: o(r["data-product_button_link"], g.productButtonLinkControlValue),
119
- imageLink: o(r["data-product_image_link"], g.productImageLinkControlValue),
120
- buttonLabel: o(r["data-product_button_control_label"], "Buy"),
121
- buttonFullWidth: t(r["data-product_button_control_atw"], !0),
122
- imageVisible: t(r["data-product_image_control_enabled"], !0),
123
- nameVisible: t(r["data-product_name_control_enabled"], !0),
124
- quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
125
- priceVisible: t(r["data-product_price_control_enabled"], !0),
126
- originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
127
- buttonVisible: t(r["data-product_button_control_enabled"], !0)
116
+ priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
117
+ quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
118
+ buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
119
+ imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
120
+ buttonLabel: r(o["data-product_button_control_label"], "Buy"),
121
+ buttonFullWidth: t(o["data-product_button_control_atw"], !0),
122
+ imageVisible: t(o["data-product_image_control_enabled"], !0),
123
+ nameVisible: t(o["data-product_name_control_enabled"], !0),
124
+ quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
125
+ priceVisible: t(o["data-product_price_control_enabled"], !0),
126
+ originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
127
+ buttonVisible: t(o["data-product_button_control_enabled"], !0)
128
128
  };
129
129
  }
130
- const x = {
130
+ const V = {
131
131
  ins_apr: "CART_ITEMS",
132
132
  browsed_item: "BROWSED_ITEMS",
133
133
  purchased_item: "PURCHASED_ITEMS"
134
134
  };
135
- function V(r, t) {
136
- const o = {
135
+ function $(o, t) {
136
+ const r = {
137
137
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
138
138
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
139
139
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
140
140
  };
141
- return o[r] || o.CART_ITEMS;
141
+ return r[o] || r.CART_ITEMS;
142
142
  }
143
- function N(r, t) {
144
- const o = {
143
+ function N(o, t) {
144
+ const r = {
145
145
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
146
146
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
147
147
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
148
148
  };
149
- return o[r] || o.CART_ITEMS;
149
+ return r[o] || r.CART_ITEMS;
150
150
  }
151
151
  class z {
152
152
  constructor() {
@@ -156,16 +156,16 @@ class z {
156
156
  migrate(t) {
157
157
  try {
158
158
  if (!this.containsItemsBlock(t))
159
- return t;
160
- let o = this.removeJinjaConditionals(t);
161
- o = this.replaceTemplateVariables(o);
162
- const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
159
+ return this.backfillV2ProductTdAttributes(t);
160
+ let r = this.removeJinjaConditionals(t);
161
+ r = this.replaceTemplateVariables(r);
162
+ const l = this.parser.parseFromString(r, "text/html"), a = l.querySelectorAll(
163
163
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
164
164
  );
165
- return F().$patch((i) => {
166
- i.migrations = { ...i.migrations, [U]: a.length };
167
- }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), o) : (a.forEach((i) => {
168
- const e = this.extractConfiguration(i), c = w({
165
+ return q().$patch((n) => {
166
+ n.migrations = { ...n.migrations, [K]: a.length };
167
+ }), a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (a.forEach((n) => {
168
+ const e = this.extractConfiguration(n), c = F({
169
169
  orientation: e.orientation,
170
170
  itemsType: e.itemsType,
171
171
  itemId: e.itemId,
@@ -179,20 +179,20 @@ class z {
179
179
  priceStyles: e.priceStyles,
180
180
  originalPriceStyles: e.originalPriceStyles,
181
181
  quantityStyles: e.quantityStyles,
182
- nodeConfig: R(e.configBlockAttributes)
183
- }), u = this.parser.parseFromString(
182
+ nodeConfig: k(e.configBlockAttributes)
183
+ }), s = this.parser.parseFromString(
184
184
  `<table><tbody><tr>${c}</tr></tbody></table>`,
185
185
  "text/html"
186
186
  ).querySelector("td");
187
- if (u && i.parentNode) {
188
- const p = R(e.configBlockAttributes);
189
- u.setAttribute("esd-ext-config", JSON.stringify(p));
190
- const d = u.querySelector("esd-config-block");
191
- d && d.remove(), i.parentNode.replaceChild(u, i);
187
+ if (s && n.parentNode) {
188
+ const _ = k(e.configBlockAttributes);
189
+ s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
190
+ const d = s.querySelector("esd-config-block");
191
+ d && d.remove(), n.parentNode.replaceChild(s, n);
192
192
  }
193
193
  }), l.documentElement.outerHTML);
194
- } catch (o) {
195
- return console.error("ItemsBlockMigrator failed:", o), t;
194
+ } catch (r) {
195
+ return console.error("ItemsBlockMigrator failed:", r), t;
196
196
  }
197
197
  }
198
198
  /**
@@ -203,23 +203,25 @@ class z {
203
203
  */
204
204
  extractConfiguration(t) {
205
205
  var C, D, P;
206
- const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
207
- let b;
208
- S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
209
- const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
206
+ const r = R(
207
+ ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
208
+ ), l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, i = I[r], n = ((P = i == null ? void 0 : i[a]) == null ? void 0 : P.value) || i[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", s = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", _ = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, r, l), b = d["data-card_orientation_control_value"];
209
+ let S;
210
+ b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
211
+ const y = t.querySelector('a[product-attr="name"]'), A = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, h = (e == null ? void 0 : e.getAttribute("style")) || void 0, T = t.querySelector("p.original-price"), L = (T == null ? void 0 : T.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), B = (E == null ? void 0 : E.getAttribute("style")) || void 0;
210
212
  return {
211
- orientation: b,
212
- itemsType: o,
213
- itemId: i,
213
+ orientation: S,
214
+ itemsType: r,
215
+ itemId: n,
214
216
  currencySymbol: c,
215
- currencyLocation: u,
216
- formattedPrice: p,
217
+ currencyLocation: s,
218
+ formattedPrice: _,
217
219
  configBlockAttributes: d,
218
- nameStyles: I,
220
+ nameStyles: A,
219
221
  buttonStyles: m,
220
- priceStyles: k,
221
- originalPriceStyles: h,
222
- quantityStyles: L
222
+ priceStyles: h,
223
+ originalPriceStyles: L,
224
+ quantityStyles: B
223
225
  };
224
226
  }
225
227
  /**
@@ -229,27 +231,27 @@ class z {
229
231
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
230
232
  * @param itemNumber - The item number (1-based index)
231
233
  */
232
- extractConfigBlockAttributes(t, o, l) {
233
- const a = t.querySelector("esd-config-block"), n = {};
234
+ extractConfigBlockAttributes(t, r, l) {
235
+ const a = t.querySelector("esd-config-block"), i = {};
234
236
  if (!a)
235
237
  return this.getDefaultConfigBlockAttributes();
236
238
  if (Array.from(a.attributes).forEach((e) => {
237
- e.name.startsWith("data-") && (n[e.name] = e.value);
238
- }), n["data-cart_items_select_control_value"]) {
239
- const e = n["data-cart_items_select_control_value"];
239
+ e.name.startsWith("data-") && (i[e.name] = e.value);
240
+ }), i["data-cart_items_select_control_value"]) {
241
+ const e = i["data-cart_items_select_control_value"];
240
242
  if (/^\d+$/.test(e)) {
241
- const c = parseInt(e) - 1, _ = T[o];
242
- _ && _[c] && (n["data-cart_items_select_control_value"] = _[c].value);
243
+ const c = parseInt(e) - 1, u = I[r];
244
+ u && u[c] && (i["data-cart_items_select_control_value"] = u[c].value);
243
245
  }
244
246
  }
245
- if (n["data-product_price_control_curency"]) {
246
- const e = n["data-product_price_control_curency"];
247
+ if (i["data-product_price_control_curency"]) {
248
+ const e = i["data-product_price_control_curency"];
247
249
  let c = e;
248
- e === "before" ? c = "0" : e === "after" && (c = "1"), n["data-product_price_control_curency"] = c, n["data-product_price_currency_location"] = c;
250
+ e === "before" ? c = "0" : e === "after" && (c = "1"), i["data-product_price_control_curency"] = c, i["data-product_price_currency_location"] = c;
249
251
  }
250
- (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
251
- const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
252
- return i["data-type"] = o, i["data-source"] = o, i["data-product_image_link"] = V(o, l), i["data-product_button_link"] = N(o, l), i;
252
+ (!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
253
+ const n = { ...this.getDefaultConfigBlockAttributes(), ...i };
254
+ return n["data-type"] = r, n["data-source"] = r, n["data-product_image_link"] = $(r, l), n["data-product_button_link"] = N(r, l), n;
253
255
  }
254
256
  /**
255
257
  * Returns default esd-config-block attributes based on the old template structure
@@ -298,6 +300,43 @@ class z {
298
300
  "data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
299
301
  };
300
302
  }
303
+ /**
304
+ * Backfills data-type (and data-number) onto v2 `.ins-product-td` elements
305
+ * from their persisted `esd-ext-config` nodeConfig.
306
+ *
307
+ * Why: templates migrated and saved by an older build can carry the correct
308
+ * product type in `esd-ext-config` while the `.ins-product-td` is missing the
309
+ * `data-type` DOM attribute. Stripo strips `esd-*` attributes during compile,
310
+ * so by save time only `data-type` survives for `pairProductVariables` to read
311
+ * when choosing the merge-tag namespace. Restoring it here (at load, before the
312
+ * editor compiles) makes the namespace resolve to the real source
313
+ * (browsed_item_ / purchased_item_) instead of defaulting to ins_apr_ (Cart).
314
+ *
315
+ * Only re-serializes when something actually changed, so healthy templates
316
+ * (every product-td already has data-type) pass through byte-for-byte.
317
+ */
318
+ backfillV2ProductTdAttributes(t) {
319
+ if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
320
+ return t;
321
+ const r = this.parser.parseFromString(t, "text/html");
322
+ let l = !1;
323
+ return r.querySelectorAll(".ins-product-td").forEach((a) => {
324
+ if (a.getAttribute("data-type"))
325
+ return;
326
+ const i = a.getAttribute("esd-ext-config");
327
+ if (i)
328
+ try {
329
+ const n = JSON.parse(i), e = n.type || n.source;
330
+ if (!e)
331
+ return;
332
+ if (a.setAttribute("data-type", e), l = !0, !a.getAttribute("data-number")) {
333
+ const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
334
+ c && a.setAttribute("data-number", c[1]);
335
+ }
336
+ } catch {
337
+ }
338
+ }), l ? r.documentElement.outerHTML : t;
339
+ }
301
340
  /**
302
341
  * Fast check for the presence of any items block (cart / browsed / purchased)
303
342
  * in the raw HTML. Used to gate the migration pipeline so non-items templates
@@ -317,15 +356,15 @@ class z {
317
356
  * contains display condition Jinja scripts that should NOT be removed.
318
357
  */
319
358
  removeJinjaConditionals(t) {
320
- const o = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
321
- let a = l ? t.replace(l[0], o) : t;
359
+ const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
360
+ let a = l ? t.replace(l[0], r) : t;
322
361
  return a = a.replace(
323
362
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
324
363
  ""
325
364
  ), a = a.replace(
326
365
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
327
366
  ""
328
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(o, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
367
+ ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), l && (a = a.replace(r, l[0])), a = a.replace(/\n\s*\n\s*\n/g, `
329
368
 
330
369
  `), a;
331
370
  }
@@ -339,31 +378,31 @@ class z {
339
378
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
340
379
  */
341
380
  replaceTemplateVariables(t) {
342
- const { PAIRS_FOR_EXTENSION: o } = K;
381
+ const { PAIRS_FOR_EXTENSION: r } = w;
343
382
  return t.replace(/{{([^}]+)}}/g, (l, a) => {
344
- const n = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
345
- if (!n)
383
+ const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
384
+ if (!i)
346
385
  return l;
347
- const [, i, e, c] = n, _ = x[i];
348
- if (!_)
349
- return console.warn(`Unknown variable prefix: ${i}`), l;
350
- const u = q[e];
386
+ const [, n, e, c] = i, u = V[n];
351
387
  if (!u)
388
+ return console.warn(`Unknown variable prefix: ${n}`), l;
389
+ const s = x[e];
390
+ if (!s)
352
391
  return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
353
- const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
392
+ const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
354
393
  if (!y)
355
- return console.warn(`No data found for: ${p}.${_}`), l;
356
- if (S) {
394
+ return console.warn(`No data found for: ${_}.${u}`), l;
395
+ if (b) {
357
396
  const f = parseInt(c) - 1, m = y[d];
358
- return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
397
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), l);
359
398
  }
360
- const I = y[d];
361
- return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
399
+ const A = y[d];
400
+ return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), l);
362
401
  });
363
402
  }
364
403
  }
365
- function Q(r) {
366
- return new z().migrate(r);
404
+ function Q(o) {
405
+ return new z().migrate(o);
367
406
  }
368
407
  export {
369
408
  Q as migrateItemsBlock
@@ -1,27 +1,49 @@
1
- const i = "You May Also Like!";
2
- function s(r) {
3
- var e;
4
- const o = r.querySelector(".ext-recommendation-title");
5
- if (!o)
6
- return i;
7
- const t = (e = o.textContent) == null ? void 0 : e.trim();
8
- return t && t.length > 0 ? t : i;
1
+ import { CURRENCY_ATTR as n, CSS_CLASS_SKIP_COMPILE as c } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
2
+ const a = "You May Also Like!";
3
+ function l(t) {
4
+ var o;
5
+ const r = t.querySelector(".ext-recommendation-title");
6
+ if (!r)
7
+ return a;
8
+ const e = (o = r.textContent) == null ? void 0 : o.trim();
9
+ return e && e.length > 0 ? e : a;
9
10
  }
10
- function u(r) {
11
- const o = [
12
- r,
13
- ...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
11
+ function m(t) {
12
+ const r = [
13
+ t,
14
+ ...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
14
15
  ];
15
- let t = "";
16
- return o.some((e) => {
17
- const n = e.getAttribute("bgcolor");
18
- if (n && n.trim())
19
- return t = n.trim(), !0;
20
- const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
21
- return c && c[1] ? (t = c[1].trim(), !0) : !1;
22
- }), t;
16
+ let e = "";
17
+ return r.some((o) => {
18
+ const i = o.getAttribute("bgcolor");
19
+ if (i && i.trim())
20
+ return e = i.trim(), !0;
21
+ const u = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
22
+ return u && u[1] ? (e = u[1].trim(), !0) : !1;
23
+ }), e;
24
+ }
25
+ function C(t) {
26
+ const r = t.getAttribute(n.CURRENCY);
27
+ if (!r)
28
+ return;
29
+ const e = t.getAttribute(n.SYMBOL);
30
+ return {
31
+ value: r,
32
+ // An empty `currency-symbol` is omitted so `mapCurrency` falls back to
33
+ // the currency code as the symbol.
34
+ ...e ? { symbol: e } : {},
35
+ alignment: t.getAttribute(n.ALIGNMENT) ?? "",
36
+ decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
37
+ decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
38
+ thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
39
+ };
40
+ }
41
+ function d(t) {
42
+ return t.classList.contains(c);
23
43
  }
24
44
  export {
25
- u as extractCardBgColor,
26
- s as extractTitleText
45
+ m as extractCardBgColor,
46
+ C as extractCurrencyFromBlock,
47
+ l as extractTitleText,
48
+ d as isPartnerManagedBlock
27
49
  };