@useinsider/guido 2.1.0-beta.038f431 → 2.1.0-beta.09c0a14

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 (48) hide show
  1. package/dist/composables/useActionsApi.js +15 -13
  2. package/dist/composables/useHtmlValidator.js +106 -84
  3. package/dist/composables/useRecommendation.js +54 -21
  4. package/dist/config/compiler/recommendationCompilerRules.js +45 -39
  5. package/dist/config/compiler/utils/recommendationCompilerUtils.js +147 -0
  6. package/dist/config/migrator/itemsBlockMigrator.js +140 -123
  7. package/dist/enums/recommendation.js +16 -15
  8. package/dist/extensions/Blocks/Items/block.js +19 -28
  9. package/dist/extensions/Blocks/Items/controls/button/link.js +19 -31
  10. package/dist/extensions/Blocks/Items/controls/cardComposition.js +124 -85
  11. package/dist/extensions/Blocks/Items/controls/image/link.js +19 -31
  12. package/dist/extensions/Blocks/Items/controls/name/trimming.js +28 -40
  13. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +35 -47
  14. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +49 -54
  15. package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +42 -51
  16. package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +23 -36
  17. package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +45 -57
  18. package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +42 -60
  19. package/dist/extensions/Blocks/Items/controls/settingsControl.js +189 -196
  20. package/dist/extensions/Blocks/Items/enums/settingsEnums.js +0 -2
  21. package/dist/extensions/Blocks/Items/extension.js +8 -9
  22. package/dist/extensions/Blocks/Items/settingsPanel.js +10 -15
  23. package/dist/extensions/Blocks/Items/template.js +181 -175
  24. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +65 -65
  25. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +10 -10
  26. package/dist/extensions/Blocks/common-control.js +91 -92
  27. package/dist/services/templateLibraryApi.js +16 -13
  28. package/dist/src/composables/useRecommendation.d.ts +1 -0
  29. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +17 -0
  30. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -1
  31. package/dist/src/extensions/Blocks/Items/controls/button/link.d.ts +0 -1
  32. package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +5 -5
  33. package/dist/src/extensions/Blocks/Items/controls/image/link.d.ts +0 -1
  34. package/dist/src/extensions/Blocks/Items/controls/name/trimming.d.ts +0 -1
  35. package/dist/src/extensions/Blocks/Items/controls/price/currencyLocation.d.ts +0 -1
  36. package/dist/src/extensions/Blocks/Items/controls/price/currencySymbol.d.ts +0 -1
  37. package/dist/src/extensions/Blocks/Items/controls/price/formattedPrice.d.ts +0 -1
  38. package/dist/src/extensions/Blocks/Items/controls/price/hideDiscount.d.ts +0 -1
  39. package/dist/src/extensions/Blocks/Items/controls/price/priceOrientation.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Items/controls/price/singlePrice.d.ts +0 -5
  41. package/dist/src/extensions/Blocks/Items/controls/settingsControl.d.ts +10 -12
  42. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +2 -1
  43. package/dist/src/extensions/Blocks/common-control.d.ts +4 -5
  44. package/dist/utils/pairProductVariables.js +57 -56
  45. package/dist/utils/templatePreparation.js +15 -14
  46. package/package.json +1 -1
  47. package/dist/extensions/Blocks/Items/store/items-block.js +0 -79
  48. package/dist/src/extensions/Blocks/Items/store/items-block.d.ts +0 -45
@@ -0,0 +1,147 @@
1
+ import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
2
+ function m(o, n, c, e) {
3
+ const s = `{{${o}_${n}_${c}}}`, t = `{{${o}_${n}_currency}}`;
4
+ return e === "before" ? `${t} ${s}` : `${s} ${t}`;
5
+ }
6
+ function b(o, n, c, e, s) {
7
+ switch (n) {
8
+ case "productImage": {
9
+ const t = o.querySelector("img");
10
+ t && t.setAttribute("src", `{{${c}_${e}_img}}`);
11
+ const r = o.querySelector("a");
12
+ r && r.setAttribute("href", `{{${c}_${e}_url}}`);
13
+ break;
14
+ }
15
+ case "productName": {
16
+ const t = o.querySelector("p");
17
+ if (t) {
18
+ const r = t.querySelector("strong") || t;
19
+ r.textContent = `{{${c}_${e}_name}}`;
20
+ }
21
+ break;
22
+ }
23
+ case "productPrice": {
24
+ const t = o.querySelector("p");
25
+ if (t) {
26
+ const r = t.querySelector("strong") || t;
27
+ r.textContent = m(c, e, "price", s);
28
+ }
29
+ break;
30
+ }
31
+ case "productOldPrice": {
32
+ const t = o.querySelector("p");
33
+ if (t) {
34
+ const r = t.querySelector("strong") || t;
35
+ r.textContent = m(
36
+ c,
37
+ e,
38
+ "original_price",
39
+ s
40
+ ), t.setAttribute("product-attr", "discount");
41
+ }
42
+ break;
43
+ }
44
+ case "productButton": {
45
+ const t = o.querySelector("a");
46
+ t && t.setAttribute("href", `{{${c}_${e}_url}}`);
47
+ break;
48
+ }
49
+ case "productOmnibusPrice": {
50
+ const t = o.querySelector(".omnibus-price-value");
51
+ if (t) {
52
+ t.textContent = `{{${c}_${e}_omnibus_price}}`;
53
+ const r = t.closest("p");
54
+ r && (r.setAttribute("product-attr", "omnibus_price"), r.setAttribute("composition", "true"));
55
+ }
56
+ break;
57
+ }
58
+ case "productOmnibusDiscount": {
59
+ const t = o.querySelector(".omnibus-discount-value");
60
+ if (t) {
61
+ t.textContent = `{{${c}_${e}_omnibus_discount}}`;
62
+ const r = t.closest("p");
63
+ r && (r.setAttribute("product-attr", "omnibus_discount"), r.setAttribute("composition", "true"));
64
+ }
65
+ break;
66
+ }
67
+ }
68
+ }
69
+ function $(o, n, c) {
70
+ o.querySelectorAll(".recommendation-product-row").forEach((s, t) => {
71
+ s.querySelectorAll("[data-attribute-type]").forEach((u) => {
72
+ const l = u.getAttribute("data-attribute-type") || "", a = u.querySelectorAll(".attribute-cell");
73
+ a.length > 0 ? a.forEach((i) => {
74
+ b(i, l, n, t, c);
75
+ }) : b(u, l, n, t, c);
76
+ });
77
+ });
78
+ }
79
+ function h(o, n, c) {
80
+ const e = o.querySelectorAll(".recommendation-product-row");
81
+ if (!e.length)
82
+ return;
83
+ const [s] = e, t = s.querySelector("[data-attribute-type]"), r = t ? t.querySelectorAll(".attribute-cell").length : 1;
84
+ e.forEach((u, l) => {
85
+ u.querySelectorAll("[data-attribute-type]").forEach((i) => {
86
+ const f = i.getAttribute("data-attribute-type") || "";
87
+ i.querySelectorAll(".attribute-cell").forEach((y, d) => {
88
+ const A = l * r + d;
89
+ b(y, f, n, A, c);
90
+ });
91
+ });
92
+ });
93
+ }
94
+ function S(o, n) {
95
+ const c = o.getAttribute("data-layout") || "grid", e = o.getAttribute("currency-alignment") || "after";
96
+ c === "list" ? $(o, n, e) : h(o, n, e);
97
+ }
98
+ function q(o, n, c) {
99
+ let e = o;
100
+ if ((n.getAttribute("data-layout") || "grid") === "list") {
101
+ const t = n.querySelectorAll(".recommendation-product-row");
102
+ Array.from(t).reverse().forEach((u, l) => {
103
+ const a = t.length - 1 - l, i = u.outerHTML, p = `${`{% if ins_reco_total_product_kind_${c} > ${a} %}`}${i}{% endif %}`;
104
+ e = e.replace(i, p);
105
+ });
106
+ } else {
107
+ const t = n.querySelectorAll(".recommendation-product-row");
108
+ if (!t.length)
109
+ return e;
110
+ const [r] = t, u = r.querySelector("[data-attribute-type]"), l = u ? u.querySelectorAll(".attribute-cell").length : 1, a = [];
111
+ t.forEach((i, f) => {
112
+ const p = i.querySelector(".product-card-wrapper") || i;
113
+ a.push({
114
+ element: p,
115
+ productThreshold: f * l
116
+ });
117
+ }), a.reverse().forEach(({ element: i, productThreshold: f }) => {
118
+ const p = i.outerHTML, d = `${`{% if ins_reco_total_product_kind_${c} > ${f} %}`}${p}{% endif %}`;
119
+ e = e.replace(p, d);
120
+ });
121
+ }
122
+ return e;
123
+ }
124
+ function g(o, n) {
125
+ const c = o.match(/<!DOCTYPE[^>]*>/i);
126
+ return (c ? `${c[0]}
127
+ ` : "") + n.documentElement.outerHTML;
128
+ }
129
+ function E(o) {
130
+ const n = o.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), c = new DOMParser().parseFromString(n, "text/html"), e = c.querySelectorAll(".ins-recommendation-v3-block-v2");
131
+ if (!e.length)
132
+ return o;
133
+ const { buildCampaignUrl: s } = _();
134
+ e.forEach((r) => {
135
+ const u = r.getAttribute("recommendation-id");
136
+ u && (s(u), S(r, u));
137
+ });
138
+ let t = g(n, c);
139
+ return e.forEach((r) => {
140
+ const u = r.getAttribute("recommendation-id");
141
+ u && (t = q(t, r, u));
142
+ }), t.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
143
+ }
144
+ export {
145
+ m as formatPriceVariable,
146
+ E as prepareRecommendationBlocks
147
+ };
@@ -1,9 +1,9 @@
1
- var L = Object.defineProperty;
2
- var K = (o, t, r) => t in o ? L(o, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[t] = r;
3
- var R = (o, t, r) => K(o, typeof t != "symbol" ? t + "" : t, r);
4
- import { productPairs as B } from "../../extensions/Blocks/Items/enums/productEnums.js";
5
- import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
- import { getDefaultTemplate as U } from "../../extensions/Blocks/Items/template.js";
1
+ var B = Object.defineProperty;
2
+ var U = (r, t, e) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var M = (r, t, e) => U(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { productPairs as v } from "../../extensions/Blocks/Items/enums/productEnums.js";
5
+ import { ItemInCartOptions as E, DefaultConfigValues as g, SETTINGS_ENUMS as d } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
+ import { getDefaultTemplate as K } from "../../extensions/Blocks/Items/template.js";
7
7
  const w = {
8
8
  img: {
9
9
  pairsKey: "imageSrc",
@@ -74,102 +74,118 @@ const w = {
74
74
  function F() {
75
75
  return String(Date.now() + Math.floor(Math.random() * 1e3));
76
76
  }
77
- function q(o) {
78
- return o ? {
79
- CartItems: _.ITEMS_TYPE.CART_ITEMS,
80
- BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
81
- PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
82
- CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
83
- BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
84
- PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
85
- }[o] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
77
+ function q(r) {
78
+ return r ? {
79
+ CartItems: d.ITEMS_TYPE.CART_ITEMS,
80
+ BrowsedItems: d.ITEMS_TYPE.BROWSED_ITEMS,
81
+ PurchasedItems: d.ITEMS_TYPE.PURCHASED_ITEMS,
82
+ CART_ITEMS: d.ITEMS_TYPE.CART_ITEMS,
83
+ BROWSED_ITEMS: d.ITEMS_TYPE.BROWSED_ITEMS,
84
+ PURCHASED_ITEMS: d.ITEMS_TYPE.PURCHASED_ITEMS
85
+ }[r] || d.ITEMS_TYPE.CART_ITEMS : d.ITEMS_TYPE.CART_ITEMS;
86
86
  }
87
- function M(o) {
88
- const t = (e, a) => e == null ? a : e === "1" || e === "true", r = (e, a) => e || a, c = o["data-type"] || o["data-source"], n = q(c);
89
- let i = o["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
90
- if (i && !i.includes("{{") && /^\d+$/.test(i)) {
91
- const e = parseInt(i) - 1, a = E[n];
92
- a && a[e] && (i = a[e].value);
87
+ function R(r) {
88
+ const t = (a, o) => a == null ? o : a === "1" || a === "true", e = (a, o) => a || o, i = r["data-type"] || r["data-source"], l = q(i);
89
+ let n = r["data-cart_items_select_control_value"] || g.cartItemsSelectControlValue;
90
+ if (n && !n.includes("{{") && /^\d+$/.test(n)) {
91
+ const a = parseInt(n) - 1, o = E[l];
92
+ o && o[a] && (n = o[a].value);
93
93
  }
94
94
  return {
95
95
  initialized: !0,
96
- blockInstanceId: r(o["data-block-instance-id"], F()),
97
- source: n,
98
- type: n,
99
- itemsSelectValue: i,
100
- orientation: o["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
101
- nameTrimming: t(o["data-product_name_control_trim"], !0),
102
- priceHideDiscount: t(o["data-product_price_control_nodup"], !0),
103
- priceFormatted: t(o["data-product_price_control_formated"], !0),
104
- priceSinglePrice: t(o["data-product_price_control_single_price"], !1),
105
- priceCurrencySymbol: r(
106
- o["data-product_price_currency_symbol"],
96
+ blockInstanceId: e(r["data-block-instance-id"], F()),
97
+ source: l,
98
+ type: l,
99
+ itemsSelectValue: n,
100
+ orientation: r["data-card_orientation_control_value"] || d.ORIENTATION.VERTICAL,
101
+ nameTrimming: t(r["data-product_name_control_trim"], !0),
102
+ priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
103
+ priceFormatted: t(r["data-product_price_control_formated"], !0),
104
+ priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
105
+ priceCurrencySymbol: e(
106
+ r["data-product_price_control_currency_symbol"],
107
107
  g.productPriceCurrencySymbolControlValue
108
108
  ),
109
- priceCurrencyLocation: r(
110
- o["data-product_price_currency_location"],
109
+ priceCurrencyLocation: e(
110
+ r["data-product_price_currency_location"],
111
111
  g.productPriceCurrencyLocationControlValue
112
112
  ),
113
- priceOrientation: o["data-product_original_price_control_orientation"] || "horizontal",
114
- quantityControlEnabled: t(o["data-product_quantity_control_enabled"], !0),
115
- buttonLink: r(o["data-product_button_link"], g.productButtonLinkControlValue),
116
- imageLink: r(o["data-product_image_link"], g.productImageLinkControlValue),
117
- buttonLabel: r(o["data-product_button_control_label"], "Buy"),
118
- buttonFullWidth: t(o["data-product_button_control_atw"], !0),
119
- imageVisible: t(o["data-product_image_control_enabled"], !0),
120
- nameVisible: t(o["data-product_name_control_enabled"], !0),
121
- quantityVisible: t(o["data-product_quantity_control_enabled"], !0),
122
- priceVisible: t(o["data-product_price_control_enabled"], !0),
123
- originalPriceVisible: t(o["data-product_original_price_control_enabled"], !0),
124
- buttonVisible: t(o["data-product_button_control_enabled"], !0)
113
+ priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
114
+ quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
115
+ buttonLink: e(r["data-product_button_link"], g.productButtonLinkControlValue),
116
+ imageLink: e(r["data-product_image_link"], g.productImageLinkControlValue),
117
+ buttonLabel: e(r["data-product_button_control_label"], "Buy"),
118
+ buttonFullWidth: t(r["data-product_button_control_atw"], !0),
119
+ imageVisible: t(r["data-product_image_control_enabled"], !0),
120
+ nameVisible: t(r["data-product_name_control_enabled"], !0),
121
+ quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
122
+ priceVisible: t(r["data-product_price_control_enabled"], !0),
123
+ originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
124
+ buttonVisible: t(r["data-product_button_control_enabled"], !0)
125
125
  };
126
126
  }
127
- const x = {
127
+ const $ = {
128
128
  ins_apr: "CART_ITEMS",
129
129
  browsed_item: "BROWSED_ITEMS",
130
130
  purchased_item: "PURCHASED_ITEMS"
131
131
  };
132
- class N {
132
+ function x(r, t) {
133
+ const e = {
134
+ CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
135
+ BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
136
+ PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
137
+ };
138
+ return e[r] || e.CART_ITEMS;
139
+ }
140
+ function O(r, t) {
141
+ const e = {
142
+ CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
143
+ BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
144
+ PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
145
+ };
146
+ return e[r] || e.CART_ITEMS;
147
+ }
148
+ class V {
133
149
  constructor() {
134
- R(this, "parser");
150
+ M(this, "parser");
135
151
  this.parser = new DOMParser();
136
152
  }
137
153
  migrate(t) {
138
154
  try {
139
- let r = this.removeJinjaConditionals(t);
140
- r = this.replaceTemplateVariables(r);
141
- const c = this.parser.parseFromString(r, "text/html"), n = c.querySelectorAll(
155
+ let e = this.removeJinjaConditionals(t);
156
+ e = this.replaceTemplateVariables(e);
157
+ const i = this.parser.parseFromString(e, "text/html"), l = i.querySelectorAll(
142
158
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
143
159
  );
144
- return n.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), r) : (n.forEach((i) => {
145
- const e = this.extractConfiguration(i), a = U({
146
- orientation: e.orientation,
147
- itemsType: e.itemsType,
148
- itemId: e.itemId,
149
- currencySymbol: e.currencySymbol,
150
- currencyLocation: e.currencyLocation,
151
- formattedPrice: e.formattedPrice,
152
- configBlockAttributes: e.configBlockAttributes,
160
+ return l.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (l.forEach((n) => {
161
+ const a = this.extractConfiguration(n), o = K({
162
+ orientation: a.orientation,
163
+ itemsType: a.itemsType,
164
+ itemId: a.itemId,
165
+ currencySymbol: a.currencySymbol,
166
+ currencyLocation: a.currencyLocation,
167
+ formattedPrice: a.formattedPrice,
168
+ configBlockAttributes: a.configBlockAttributes,
153
169
  migrate: !0,
154
- nameStyles: e.nameStyles,
155
- buttonStyles: e.buttonStyles,
156
- priceStyles: e.priceStyles,
157
- originalPriceStyles: e.originalPriceStyles,
158
- quantityStyles: e.quantityStyles,
159
- nodeConfig: M(e.configBlockAttributes)
160
- }), l = this.parser.parseFromString(
161
- `<table><tbody><tr>${a}</tr></tbody></table>`,
170
+ nameStyles: a.nameStyles,
171
+ buttonStyles: a.buttonStyles,
172
+ priceStyles: a.priceStyles,
173
+ originalPriceStyles: a.originalPriceStyles,
174
+ quantityStyles: a.quantityStyles,
175
+ nodeConfig: R(a.configBlockAttributes)
176
+ }), c = this.parser.parseFromString(
177
+ `<table><tbody><tr>${o}</tr></tbody></table>`,
162
178
  "text/html"
163
179
  ).querySelector("td");
164
- if (l && i.parentNode) {
165
- const f = M(e.configBlockAttributes);
166
- l.setAttribute("esd-ext-config", JSON.stringify(f));
167
- const u = l.querySelector("esd-config-block");
168
- u && u.remove(), i.parentNode.replaceChild(l, i);
180
+ if (c && n.parentNode) {
181
+ const f = R(a.configBlockAttributes);
182
+ c.setAttribute("esd-ext-config", JSON.stringify(f));
183
+ const u = c.querySelector("esd-config-block");
184
+ u && u.remove(), n.parentNode.replaceChild(c, n);
169
185
  }
170
- }), c.documentElement.outerHTML);
171
- } catch (r) {
172
- return console.error("ItemsBlockMigrator failed:", r), t;
186
+ }), i.documentElement.outerHTML);
187
+ } catch (e) {
188
+ return console.error("ItemsBlockMigrator failed:", e), t;
173
189
  }
174
190
  }
175
191
  /**
@@ -180,23 +196,23 @@ class N {
180
196
  */
181
197
  extractConfiguration(t) {
182
198
  var C, D, P;
183
- const r = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", n = parseInt(c) - 1, i = E[r], e = ((P = i == null ? void 0 : i[n]) == null ? void 0 : P.value) || i[0].value, a = t.querySelector('[product-attr="price"]'), d = (a == null ? void 0 : a.getAttribute("data-currency_symbol")) || "USD", f = ((a == null ? void 0 : a.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (a == null ? void 0 : a.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, r), b = s["data-card_orientation_control_value"];
199
+ const e = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", i = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", l = parseInt(i) - 1, n = E[e], a = ((P = n == null ? void 0 : n[l]) == null ? void 0 : P.value) || n[0].value, o = t.querySelector('[product-attr="price"]'), _ = (o == null ? void 0 : o.getAttribute("data-currency_symbol")) || "USD", f = ((o == null ? void 0 : o.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", u = (o == null ? void 0 : o.getAttribute("data-formated")) !== "false", s = this.extractConfigBlockAttributes(t, e, i), b = s["data-card_orientation_control_value"];
184
200
  let S;
185
201
  b ? S = b === "horizontal" ? "horizontal" : "vertical" : S = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
186
- const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, h = (a == null ? void 0 : a.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), k = (A == null ? void 0 : A.getAttribute("style")) || void 0, I = t.querySelector('[product-attr="quantity"]'), v = (I == null ? void 0 : I.getAttribute("style")) || void 0;
202
+ const p = t.querySelector('a[product-attr="name"]'), T = (p == null ? void 0 : p.getAttribute("style")) || void 0, y = t.querySelector('a[product-attr="button"]'), m = (y == null ? void 0 : y.getAttribute("style")) || void 0, k = (o == null ? void 0 : o.getAttribute("style")) || void 0, I = t.querySelector("p.original-price"), h = (I == null ? void 0 : I.getAttribute("style")) || void 0, A = t.querySelector('[product-attr="quantity"]'), L = (A == null ? void 0 : A.getAttribute("style")) || void 0;
187
203
  return {
188
204
  orientation: S,
189
- itemsType: r,
190
- itemId: e,
191
- currencySymbol: d,
205
+ itemsType: e,
206
+ itemId: a,
207
+ currencySymbol: _,
192
208
  currencyLocation: f,
193
209
  formattedPrice: u,
194
210
  configBlockAttributes: s,
195
211
  nameStyles: T,
196
212
  buttonStyles: m,
197
- priceStyles: h,
198
- originalPriceStyles: k,
199
- quantityStyles: v
213
+ priceStyles: k,
214
+ originalPriceStyles: h,
215
+ quantityStyles: L
200
216
  };
201
217
  }
202
218
  /**
@@ -204,28 +220,29 @@ class N {
204
220
  * Returns a key-value mapping of all configuration attributes
205
221
  * @param block - The block element containing the esd-config-block
206
222
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
223
+ * @param itemNumber - The item number (1-based index)
207
224
  */
208
- extractConfigBlockAttributes(t, r) {
209
- const c = t.querySelector("esd-config-block"), n = {};
210
- if (!c)
225
+ extractConfigBlockAttributes(t, e, i) {
226
+ const l = t.querySelector("esd-config-block"), n = {};
227
+ if (!l)
211
228
  return this.getDefaultConfigBlockAttributes();
212
- if (Array.from(c.attributes).forEach((e) => {
213
- e.name.startsWith("data-") && (n[e.name] = e.value);
229
+ if (Array.from(l.attributes).forEach((o) => {
230
+ o.name.startsWith("data-") && (n[o.name] = o.value);
214
231
  }), n["data-cart_items_select_control_value"]) {
215
- const e = n["data-cart_items_select_control_value"];
216
- if (/^\d+$/.test(e)) {
217
- const a = parseInt(e) - 1, d = E[r];
218
- d && d[a] && (n["data-cart_items_select_control_value"] = d[a].value);
232
+ const o = n["data-cart_items_select_control_value"];
233
+ if (/^\d+$/.test(o)) {
234
+ const _ = parseInt(o) - 1, c = E[e];
235
+ c && c[_] && (n["data-cart_items_select_control_value"] = c[_].value);
219
236
  }
220
237
  }
221
238
  if (n["data-product_price_control_curency"]) {
222
- const e = n["data-product_price_control_curency"];
223
- let a = e;
224
- e === "before" ? a = "0" : e === "after" && (a = "1"), n["data-product_price_control_curency"] = a, n["data-product_price_currency_location"] = a;
239
+ const o = n["data-product_price_control_curency"];
240
+ let _ = o;
241
+ o === "before" ? _ = "0" : o === "after" && (_ = "1"), n["data-product_price_control_curency"] = _, n["data-product_price_currency_location"] = _;
225
242
  }
226
- (!n["data-product_price_currency_symbol"] || n["data-product_price_currency_symbol"].trim() === "") && (n["data-product_price_currency_symbol"] = "USD");
227
- const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
228
- return i["data-type"] = r, i["data-source"] = r, i;
243
+ (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
244
+ const a = { ...this.getDefaultConfigBlockAttributes(), ...n };
245
+ return a["data-type"] = e, a["data-source"] = e, a["data-product_image_link"] = x(e, i), a["data-product_button_link"] = O(e, i), a;
229
246
  }
230
247
  /**
231
248
  * Returns default esd-config-block attributes based on the old template structure
@@ -254,7 +271,7 @@ class N {
254
271
  "data-product_price_control_color": "#060606",
255
272
  "data-product_price_control_curency": "0",
256
273
  "data-product_price_currency_location": "0",
257
- "data-product_price_currency_symbol": "USD",
274
+ "data-product_price_control_currency_symbol": "USD",
258
275
  "data-product_price_control_formated": "1",
259
276
  "data-product_price_control_nodup": "1",
260
277
  "data-product_price_control_single_price": "false",
@@ -282,16 +299,16 @@ class N {
282
299
  * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
283
300
  */
284
301
  removeJinjaConditionals(t) {
285
- let r = t.replace(
302
+ let e = t.replace(
286
303
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
287
304
  ""
288
305
  );
289
- return r = r.replace(
306
+ return e = e.replace(
290
307
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
291
308
  ""
292
- ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), r = r.replace(/\n\s*\n\s*\n/g, `
309
+ ), e = e.replace(/\{%\s*endif\s*%\}/g, ""), e = e.replace(/\n\s*\n\s*\n/g, `
293
310
 
294
- `), r;
311
+ `), e;
295
312
  }
296
313
  /**
297
314
  * Replaces template variables with default values from productPairs
@@ -303,32 +320,32 @@ class N {
303
320
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
304
321
  */
305
322
  replaceTemplateVariables(t) {
306
- const { PAIRS_FOR_EXTENSION: r } = B;
307
- return t.replace(/{{([^}]+)}}/g, (c, n) => {
308
- const i = n.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
309
- if (!i)
310
- return c;
311
- const [, e, a, d] = i, l = x[e];
312
- if (!l)
313
- return console.warn(`Unknown variable prefix: ${e}`), c;
314
- const f = w[a];
323
+ const { PAIRS_FOR_EXTENSION: e } = v;
324
+ return t.replace(/{{([^}]+)}}/g, (i, l) => {
325
+ const n = l.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
326
+ if (!n)
327
+ return i;
328
+ const [, a, o, _] = n, c = $[a];
329
+ if (!c)
330
+ return console.warn(`Unknown variable prefix: ${a}`), i;
331
+ const f = w[o];
315
332
  if (!f)
316
- return console.warn(`Unknown variable suffix mapping for: ${a}`), c;
317
- const { pairsKey: u, defaultKey: s, isArray: b } = f, p = r[u][l];
333
+ return console.warn(`Unknown variable suffix mapping for: ${o}`), i;
334
+ const { pairsKey: u, defaultKey: s, isArray: b } = f, p = e[u][c];
318
335
  if (!p)
319
- return console.warn(`No data found for: ${u}.${l}`), c;
336
+ return console.warn(`No data found for: ${u}.${c}`), i;
320
337
  if (b) {
321
- const y = parseInt(d) - 1, m = p[s];
322
- return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${l}.${s}[${y}]`), c);
338
+ const y = parseInt(_) - 1, m = p[s];
339
+ return Array.isArray(m) && m[y] ? m[y] : (console.warn(`Array value not found: ${u}.${c}.${s}[${y}]`), i);
323
340
  }
324
341
  const T = p[s];
325
- return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${l}.${s}`), c);
342
+ return T !== void 0 ? String(T) : (console.warn(`Default value not found: ${u}.${c}.${s}`), i);
326
343
  });
327
344
  }
328
345
  }
329
- function Y(o) {
330
- return new N().migrate(o);
346
+ function G(r) {
347
+ return new V().migrate(r);
331
348
  }
332
349
  export {
333
- Y as migrateItemsBlock
350
+ G as migrateItemsBlock
334
351
  };
@@ -1,4 +1,4 @@
1
- const s = 20, e = 320, t = {
1
+ const e = 20, s = 320, t = "vertical", m = {
2
2
  CART_ABANDONMENT: {
3
3
  ins_apr_img_1: "https://s3-eu-west-1.amazonaws.com/web-image.useinsider.com/email-assets/dummyImages/ins_apr_img_1.png",
4
4
  ins_apr_img_2: "https://s3-eu-west-1.amazonaws.com/web-image.useinsider.com/email-assets/dummyImages/ins_apr_img_2.png",
@@ -15,7 +15,7 @@ const s = 20, e = 320, t = {
15
15
  DISCOUNT: "discount",
16
16
  OMNIBUS_DISCOUNT: "omnibus_discount",
17
17
  OMNIBUS_PRICE: "omnibus_price"
18
- }, m = {
18
+ }, _ = {
19
19
  IF: {
20
20
  discount: `{% if {${i.DISCOUNT}} != "0%" and {${i.DISCOUNT}} != "" %}`,
21
21
  omnibus_discount: `{% if {${i.DISCOUNT}} != "0%" and {${i.DISCOUNT}} != "" and {${i.OMNIBUS_DISCOUNT}} != "0%" and {${i.OMNIBUS_DISCOUNT}} != "" %}`,
@@ -23,17 +23,17 @@ const s = 20, e = 320, t = {
23
23
  },
24
24
  ELSE: "{% else %}",
25
25
  END_IF: "{% endif %}"
26
- }, _ = {
27
- ID: /ins-recommendation-v3-campaign-id="(.*?)"/gi,
28
- ATTRIBUTE_PARAGRAPH: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)">[\S\s]*?<\/p>/gm,
29
- ATTRIBUTE_PARAGRAPH_START_TAG: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)">/gm,
26
+ }, a = {
27
+ ID: /recommendation-id="(.*?)"/gi,
28
+ ATTRIBUTE_PARAGRAPH: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>[\S\s]*?<\/p>/gm,
29
+ ATTRIBUTE_PARAGRAPH_START_TAG: /<p[^>]*?product-attr="(discount|omnibus_discount|omnibus_price)"[^>]*>/gm,
30
30
  COMPOSITION: /composition="true"/gm,
31
31
  CUSTOM_FIELD: /{{[0-9]+_[0-8]_(discount|omnibus_discount|omnibus_price)}}/gm,
32
32
  CUSTOM_FIELD_INDEXES_PART: /{{[0-9]+_[0-8]_/gm,
33
33
  CUSTOM_FIELD_NAME_PART: /_(discount|omnibus_discount|omnibus_price)}}/gm
34
- }, a = {
35
- PARAGRAPH_END_TAG: "</p>"
36
34
  }, n = {
35
+ PARAGRAPH_END_TAG: "</p>"
36
+ }, o = {
37
37
  REGULAR_NAME_HEIGHT: ".ext-product-name.ins-vertical p { height:90px!important;",
38
38
  TRIMMED_NAME_HEIGHT: ".ext-product-name.ins-vertical p { height:18px!important;",
39
39
  ELLIPSIS: "text-overflow:ellipsis!important; white-space:nowrap!important;",
@@ -46,11 +46,12 @@ const s = 20, e = 320, t = {
46
46
  };
47
47
  export {
48
48
  i as ATTRIBUTES,
49
- m as CONDITIONS,
50
- n as CSS,
51
- t as DUMMY_IMAGE_MAPPINGS,
52
- s as DefaultPadding,
53
- a as HTML,
54
- e as MinDeviceViewport,
55
- _ as REGEX
49
+ _ as CONDITIONS,
50
+ o as CSS,
51
+ m as DUMMY_IMAGE_MAPPINGS,
52
+ e as DefaultPadding,
53
+ n as HTML,
54
+ s as MinDeviceViewport,
55
+ a as REGEX,
56
+ t as VerticalOrientation
56
57
  };