@useinsider/guido 3.19.0-beta.76f392b → 3.19.0-beta.7d287ab

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 (57) hide show
  1. package/dist/@types/config/schemas.js +104 -91
  2. package/dist/components/Guido.vue.js +8 -8
  3. package/dist/components/Guido.vue2.js +79 -74
  4. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  5. package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
  6. package/dist/components/wrappers/WpModal.vue.js +1 -1
  7. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  8. package/dist/composables/useAuthError.js +52 -0
  9. package/dist/composables/useAutoSave.js +11 -11
  10. package/dist/composables/useHttp.js +64 -54
  11. package/dist/composables/useLegacyStrategyConversion.js +23 -19
  12. package/dist/composables/useStripo.js +24 -20
  13. package/dist/composables/useToaster.js +17 -15
  14. package/dist/composables/validators/useLiquidValidator.js +15 -15
  15. package/dist/config/migrator/index.js +14 -13
  16. package/dist/config/migrator/itemsBlockMigrator.js +248 -236
  17. package/dist/config/migrator/recommendationMigrator.js +28 -21
  18. package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
  19. package/dist/enums/extensions/recommendationBlock.js +30 -29
  20. package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
  21. package/dist/extensions/Blocks/Items/controls/settingsControl.js +105 -114
  22. package/dist/extensions/Blocks/Items/enums/productEnums.js +9 -14
  23. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +9 -11
  24. package/dist/extensions/Blocks/Items/template.js +204 -219
  25. package/dist/extensions/Blocks/Recommendation/block.js +15 -14
  26. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +233 -189
  27. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
  28. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
  29. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
  30. package/dist/guido.css +1 -1
  31. package/dist/src/@types/config/schemas.d.ts +16 -0
  32. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  33. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  34. package/dist/src/composables/useAuthError.d.ts +12 -0
  35. package/dist/src/composables/useConfig.d.ts +2 -0
  36. package/dist/src/composables/useGuidoActions.d.ts +2 -0
  37. package/dist/src/composables/useHttp.d.ts +2 -0
  38. package/dist/src/config/migrator/index.d.ts +2 -1
  39. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
  40. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +0 -3
  42. package/dist/src/extensions/Blocks/Items/template.d.ts +0 -19
  43. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +8 -0
  44. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  45. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
  46. package/dist/src/mock/cortexChatStore.d.ts +12 -0
  47. package/dist/src/stores/config.d.ts +20 -0
  48. package/dist/src/stores/onboarding.d.ts +4 -0
  49. package/dist/src/stores/recommendation.d.ts +5 -0
  50. package/dist/src/utils/dateUtil.d.ts +10 -0
  51. package/dist/src/utils/genericUtil.d.ts +3 -0
  52. package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
  53. package/dist/stores/onboarding.js +4 -0
  54. package/dist/utils/pairProductVariables.js +71 -71
  55. package/package.json +1 -1
  56. package/dist/extensions/Blocks/Items/constants/cardLayout.js +0 -20
  57. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +0 -44
@@ -1,84 +1,154 @@
1
- var q = Object.defineProperty;
2
- var v = (c, t, e) => t in c ? q(c, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[t] = e;
3
- var M = (c, t, e) => v(c, typeof t != "symbol" ? t + "" : t, e);
4
- import { BLOCK_ID as R } from "../../extensions/Blocks/Items/block.js";
5
- import { ItemInCartOptions as h, DefaultConfigValues as b, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
6
- import { getDefaultTemplate as L } from "../../extensions/Blocks/Items/template.js";
7
- import { useTemplateStore as x } from "../../stores/template.js";
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 w } from "../../extensions/Blocks/Items/block.js";
5
+ import { productPairs as K } 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
+ img: {
11
+ pairsKey: "imageSrc",
12
+ defaultKey: "DEFAULT",
13
+ isArray: !0
14
+ },
15
+ name: {
16
+ pairsKey: "name",
17
+ defaultKey: "DEFAULT",
18
+ isArray: !0
19
+ },
20
+ url: {
21
+ pairsKey: "button",
22
+ defaultKey: "DEFAULT_HREF",
23
+ isArray: !1
24
+ },
25
+ formattedprice: {
26
+ pairsKey: "price",
27
+ defaultKey: "DEFAULT_PRICE_FORMATTED",
28
+ isArray: !1
29
+ },
30
+ productcurrency: {
31
+ pairsKey: "price",
32
+ defaultKey: "DEFAULT_CURRENCY",
33
+ isArray: !1
34
+ },
35
+ quantity: {
36
+ pairsKey: "quantity",
37
+ defaultKey: "DEFAULT",
38
+ isArray: !1
39
+ },
40
+ price: {
41
+ pairsKey: "price",
42
+ defaultKey: "DEFAULT_PRICE",
43
+ isArray: !1
44
+ },
45
+ originalprice: {
46
+ pairsKey: "originalPrice",
47
+ defaultKey: "DEFAULT_PRICE",
48
+ isArray: !1
49
+ },
50
+ originalformattedprice: {
51
+ pairsKey: "originalPrice",
52
+ defaultKey: "DEFAULT_PRICE_FORMATTED",
53
+ isArray: !1
54
+ },
55
+ single_price: {
56
+ pairsKey: "price",
57
+ defaultKey: "DEFAULT_SINGLE_PRICE",
58
+ isArray: !1
59
+ },
60
+ single_formattedprice: {
61
+ pairsKey: "price",
62
+ defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
63
+ isArray: !1
64
+ },
65
+ single_originalprice: {
66
+ pairsKey: "originalPrice",
67
+ defaultKey: "DEFAULT_SINGLE_PRICE",
68
+ isArray: !1
69
+ },
70
+ single_originalformattedprice: {
71
+ pairsKey: "originalPrice",
72
+ defaultKey: "DEFAULT_SINGLE_PRICE_FORMATTED",
73
+ isArray: !1
74
+ }
75
+ };
8
76
  function O() {
9
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
10
78
  }
11
- function P(c) {
12
- return c ? {
13
- CartItems: _.ITEMS_TYPE.CART_ITEMS,
14
- BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
15
- PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
16
- CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
17
- BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
18
- PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
19
- }[c] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
79
+ function k(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;
20
88
  }
21
- function V(c) {
22
- return c.classList.contains("esd-browsed-items-block") ? _.ITEMS_TYPE.BROWSED_ITEMS : c.classList.contains("esd-purchased-items-block") ? _.ITEMS_TYPE.PURCHASED_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
23
- }
24
- function D(c) {
25
- var o;
26
- const t = (i, u) => i == null ? u : i === "1" || i === "true", e = (i, u) => i || u, a = c["data-type"] || c["data-source"], r = P(a), d = h[r];
27
- let n = c["data-cart_items_select_control_value"] || ((o = d == null ? void 0 : d[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
89
+ function h(o) {
90
+ var e;
91
+ const t = (l, u) => l == null ? u : l === "1" || l === "true", r = (l, u) => l || u, c = o["data-type"] || o["data-source"], a = k(c), 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;
28
93
  if (n && !n.includes("{{") && /^\d+$/.test(n)) {
29
- const i = parseInt(n) - 1, u = h[r];
30
- u && u[i] && (n = u[i].value);
94
+ const l = parseInt(n) - 1, u = I[a];
95
+ u && u[l] && (n = u[l].value);
31
96
  }
32
97
  return {
33
98
  initialized: !0,
34
- blockInstanceId: e(c["data-block-instance-id"], O()),
35
- source: r,
36
- type: r,
99
+ blockInstanceId: r(o["data-block-instance-id"], O()),
100
+ source: a,
101
+ type: a,
37
102
  itemsSelectValue: n,
38
- orientation: c["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
39
- nameTrimming: t(c["data-product_name_control_trim"], !0),
40
- priceHideDiscount: t(c["data-product_price_control_nodup"], !0),
41
- priceFormatted: t(c["data-product_price_control_formated"], !0),
42
- priceSinglePrice: t(c["data-product_price_control_single_price"], !1),
43
- priceCurrencySymbol: e(
44
- c["data-product_price_control_currency_symbol"],
45
- b.productPriceCurrencySymbolControlValue
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
+ g.productPriceCurrencySymbolControlValue
46
111
  ),
47
- priceCurrencyLocation: e(
48
- c["data-product_price_currency_location"],
49
- b.productPriceCurrencyLocationControlValue
112
+ priceCurrencyLocation: r(
113
+ o["data-product_price_currency_location"],
114
+ g.productPriceCurrencyLocationControlValue
50
115
  ),
51
- priceOrientation: c["data-product_original_price_control_orientation"] || "horizontal",
52
- quantityControlEnabled: t(c["data-product_quantity_control_enabled"], !0),
53
- buttonLink: e(c["data-product_button_link"], b.productButtonLinkControlValue),
54
- imageLink: e(c["data-product_image_link"], b.productImageLinkControlValue),
55
- buttonLabel: e(c["data-product_button_control_label"], "Buy"),
56
- buttonFullWidth: t(c["data-product_button_control_atw"], !0),
57
- imageVisible: t(c["data-product_image_control_enabled"], !0),
58
- nameVisible: t(c["data-product_name_control_enabled"], !0),
59
- quantityVisible: t(c["data-product_quantity_control_enabled"], !0),
60
- priceVisible: t(c["data-product_price_control_enabled"], !0),
61
- originalPriceVisible: t(c["data-product_original_price_control_enabled"], !0),
62
- buttonVisible: t(c["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)
63
128
  };
64
129
  }
65
- function H(c, t) {
66
- const e = {
130
+ const V = {
131
+ ins_apr: "CART_ITEMS",
132
+ browsed_item: "BROWSED_ITEMS",
133
+ purchased_item: "PURCHASED_ITEMS"
134
+ };
135
+ function $(o, t) {
136
+ const r = {
67
137
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
68
138
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
69
139
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
70
140
  };
71
- return e[c] || e.CART_ITEMS;
141
+ return r[o] || r.CART_ITEMS;
72
142
  }
73
- function $(c, t) {
74
- const e = {
143
+ function N(o, t) {
144
+ const r = {
75
145
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
76
146
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
77
147
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
78
148
  };
79
- return e[c] || e.CART_ITEMS;
149
+ return r[o] || r.CART_ITEMS;
80
150
  }
81
- class F {
151
+ class H {
82
152
  constructor() {
83
153
  M(this, "parser");
84
154
  this.parser = new DOMParser();
@@ -87,40 +157,42 @@ class F {
87
157
  try {
88
158
  if (!this.containsItemsBlock(t))
89
159
  return this.backfillV2ProductTdAttributes(t);
90
- const e = this.removeJinjaConditionals(t), a = this.parser.parseFromString(e, "text/html"), r = a.querySelectorAll(
160
+ let r = this.removeJinjaConditionals(t);
161
+ r = this.replaceTemplateVariables(r);
162
+ const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
91
163
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
92
164
  );
93
- return x().$patch((n) => {
94
- n.migrations = { ...n.migrations, [R]: r.length };
95
- }), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (r.forEach((n) => {
96
- const o = this.extractConfiguration(n), i = L({
97
- orientation: o.orientation,
98
- itemsType: o.itemsType,
99
- itemId: o.itemId,
100
- currencySymbol: o.currencySymbol,
101
- currencyLocation: o.currencyLocation,
102
- formattedPrice: o.formattedPrice,
103
- configBlockAttributes: o.configBlockAttributes,
165
+ return q().$patch((n) => {
166
+ n.migrations = { ...n.migrations, [w]: 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), l = F({
169
+ orientation: e.orientation,
170
+ itemsType: e.itemsType,
171
+ itemId: e.itemId,
172
+ currencySymbol: e.currencySymbol,
173
+ currencyLocation: e.currencyLocation,
174
+ formattedPrice: e.formattedPrice,
175
+ configBlockAttributes: e.configBlockAttributes,
104
176
  migrate: !0,
105
- nameStyles: o.nameStyles,
106
- buttonStyles: o.buttonStyles,
107
- priceStyles: o.priceStyles,
108
- originalPriceStyles: o.originalPriceStyles,
109
- quantityStyles: o.quantityStyles,
110
- nodeConfig: D(o.configBlockAttributes)
111
- }), l = this.parser.parseFromString(
112
- `<table><tbody><tr>${i}</tr></tbody></table>`,
177
+ nameStyles: e.nameStyles,
178
+ buttonStyles: e.buttonStyles,
179
+ priceStyles: e.priceStyles,
180
+ originalPriceStyles: e.originalPriceStyles,
181
+ quantityStyles: e.quantityStyles,
182
+ nodeConfig: h(e.configBlockAttributes)
183
+ }), s = this.parser.parseFromString(
184
+ `<table><tbody><tr>${l}</tr></tbody></table>`,
113
185
  "text/html"
114
186
  ).querySelector("td");
115
- if (l && n.parentNode) {
116
- const s = D(o.configBlockAttributes);
117
- l.setAttribute("esd-ext-config", JSON.stringify(s)), l.setAttribute("data-type", s.type);
118
- const p = l.querySelector("esd-config-block");
119
- p && p.remove(), n.parentNode.replaceChild(l, n);
187
+ if (s && n.parentNode) {
188
+ const _ = h(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);
120
192
  }
121
- }), a.documentElement.outerHTML);
122
- } catch (e) {
123
- return console.error("ItemsBlockMigrator failed:", e), t;
193
+ }), c.documentElement.outerHTML);
194
+ } catch (r) {
195
+ return console.error("ItemsBlockMigrator failed:", r), t;
124
196
  }
125
197
  }
126
198
  /**
@@ -130,118 +202,28 @@ class F {
130
202
  * - UI styles from product elements (name, price, button, quantity, etc.)
131
203
  */
132
204
  extractConfiguration(t) {
133
- var C;
134
- const e = P(
135
- this.readSelfOrDescendantAttribute(t, "data-type") || V(t)
136
- ), a = this.readSelfOrDescendantAttribute(t, "data-number") || "1", r = parseInt(a) - 1, d = h[e], n = ((C = d == null ? void 0 : d[r]) == null ? void 0 : C.value) || d[0].value, o = this.extractConfigBlockAttributes(t, e, a);
137
- this.applyDomFallbacks(t, o);
138
- const i = t.querySelector('[product-attr="price"]'), u = o["data-product_price_control_currency_symbol"], l = o["data-product_price_currency_location"] || "0", s = o["data-product_price_control_formated"], p = s !== "false" && s !== "0", S = o["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", y = t.querySelector('a[product-attr="name"]'), f = (y == null ? void 0 : y.getAttribute("style")) || void 0, g = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (g == null ? void 0 : g.getAttribute("style")) || void 0, w = (i == null ? void 0 : i.getAttribute("style")) || void 0, m = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), A = m != null && m.getAttribute("style") ? m : (m == null ? void 0 : m.closest("p")) ?? m, k = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), B = (E == null ? void 0 : E.getAttribute("style")) || void 0;
205
+ var C, D, P;
206
+ const r = k(
207
+ ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) ?? null
208
+ ), c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 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"]'), l = (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, c), 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, R = (e == null ? void 0 : e.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), L = (E == null ? void 0 : E.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
139
212
  return {
140
213
  orientation: S,
141
- itemsType: e,
214
+ itemsType: r,
142
215
  itemId: n,
143
- currencySymbol: u,
144
- currencyLocation: l,
145
- formattedPrice: p,
146
- configBlockAttributes: o,
147
- nameStyles: f,
148
- buttonStyles: I,
149
- priceStyles: w,
150
- originalPriceStyles: k,
216
+ currencySymbol: l,
217
+ currencyLocation: s,
218
+ formattedPrice: _,
219
+ configBlockAttributes: d,
220
+ nameStyles: A,
221
+ buttonStyles: m,
222
+ priceStyles: R,
223
+ originalPriceStyles: L,
151
224
  quantityStyles: B
152
225
  };
153
226
  }
154
- /**
155
- * DOM fallback for hand-edited templates. The esd-config-block is authoritative only for
156
- * the keys it ACTUALLY carries — every other key follows the live markup, whether the block
157
- * was deleted outright or (far more common) survives carrying only a couple of `_opened`
158
- * attributes. Without the per-key split, one such stub block shadows the whole DOM and the
159
- * card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
160
- */
161
- applyDomFallbacks(t, e) {
162
- var S, y;
163
- const a = t.querySelector("esd-config-block"), r = (...f) => !a || f.every((g) => !(a.getAttribute(g) ?? "").trim());
164
- Object.entries({
165
- image: '[product-attr="imageSrc"]',
166
- name: '[product-attr="name"]',
167
- price: '[product-attr="price"]',
168
- original_price: '[product-attr="originalPrice"], p.original-price',
169
- quantity: '[product-attr="quantity"]',
170
- button: '[product-attr="button"]'
171
- }).forEach(([f, g]) => {
172
- const I = `data-product_${f}_control_enabled`;
173
- r(I) && (e[I] = t.querySelector(g) ? "true" : "false");
174
- }), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
175
- const n = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (S = n == null ? void 0 : n.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
176
- o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o);
177
- const i = (n == null ? void 0 : n.getAttribute("style")) || "";
178
- r("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
179
- const u = t.querySelector('[product-attr="imageSrc"]'), l = u ? this.readImageSize(u) : null, s = (l == null ? void 0 : l.height) ?? (l == null ? void 0 : l.width), p = (l == null ? void 0 : l.width) ?? (l == null ? void 0 : l.height);
180
- s && r("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), p && r("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, r);
181
- const T = ((y = t.querySelector('[product-attr="name"]')) == null ? void 0 : y.getAttribute("style")) || "";
182
- r("data-product_name_control_trim") && /white-space:\s*normal/.test(T) && (e["data-product_name_control_trim"] = "0");
183
- }
184
- /**
185
- * Carries the price cell's own currency/format attributes into the config attributes when
186
- * the config block omits them. extractConfiguration used to read the cell separately for the
187
- * rendered markup while nodeConfig kept the defaults — so a ₺/after card migrated rendering
188
- * ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
189
- * the default back over the real value.
190
- */
191
- applyPriceDomFallbacks(t, e, a) {
192
- var u;
193
- const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
194
- if (!r)
195
- return;
196
- const d = (u = r.getAttribute("data-currency_symbol")) == null ? void 0 : u.trim();
197
- d && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = d);
198
- const n = r.getAttribute("data-curency");
199
- if (n && a("data-product_price_currency_location", "data-product_price_control_curency")) {
200
- const l = n === "after" ? "1" : "0";
201
- e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
202
- }
203
- const o = r.getAttribute("data-formated");
204
- o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
205
- const i = r.getAttribute("data-single_price");
206
- i && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
207
- }
208
- /**
209
- * Reads an attribute from the block element itself before falling back to a descendant.
210
- * Real legacy markup carries data-type/data-number on the `.ins-product-td` AND on the
211
- * esd-config-block; when an author deletes the config block only the td's copy survives.
212
- */
213
- readSelfOrDescendantAttribute(t, e) {
214
- var a;
215
- return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
216
- }
217
- /**
218
- * Reads the product image's pixel size — `width`/`height` attributes first, then px values
219
- * in the inline style. An explicit `width`/`height` wins over `max-*`, which is only an
220
- * upper bound; `max-*` still covers the common `width: 100%` case, where no pixel size can
221
- * be read from the property itself. Each side is null when it carries no pixel size.
222
- */
223
- readImageSize(t) {
224
- return {
225
- width: this.readImageDimension(t, "width"),
226
- height: this.readImageDimension(t, "height")
227
- };
228
- }
229
- /**
230
- * One side of readImageSize. `width="0"` is not a size — authors who override the real
231
- * dimensions in CSS zero out the attributes, and taking the 0 collapses the migrated image
232
- * to nothing, so only a positive integer counts as an answer.
233
- */
234
- readImageDimension(t, e) {
235
- var u;
236
- const a = (l) => {
237
- const s = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = s ? Math.floor(parseFloat(s[1])) : 0;
238
- return p > 0 ? String(p) : null;
239
- }, r = a((u = t.getAttribute(e)) == null ? void 0 : u.trim());
240
- if (r)
241
- return r;
242
- const d = t.getAttribute("style") || "", n = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = d.match(n) || d.match(o);
243
- return a(i == null ? void 0 : i[1]);
244
- }
245
227
  /**
246
228
  * Extracts all data-* attributes from the esd-config-block element
247
229
  * Returns a key-value mapping of all configuration attributes
@@ -249,27 +231,27 @@ class F {
249
231
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
250
232
  * @param itemNumber - The item number (1-based index)
251
233
  */
252
- extractConfigBlockAttributes(t, e, a) {
253
- const r = t.querySelector("esd-config-block"), d = {};
254
- if (r) {
255
- if (Array.from(r.attributes).forEach((o) => {
256
- o.name.startsWith("data-") && (d[o.name] = o.value);
257
- }), d["data-cart_items_select_control_value"]) {
258
- const o = d["data-cart_items_select_control_value"];
259
- if (/^\d+$/.test(o)) {
260
- const i = parseInt(o) - 1, u = h[e];
261
- u && u[i] && (d["data-cart_items_select_control_value"] = u[i].value);
262
- }
263
- }
264
- if (d["data-product_price_control_curency"]) {
265
- const o = d["data-product_price_control_curency"];
266
- let i = o;
267
- o === "before" ? i = "0" : o === "after" && (i = "1"), d["data-product_price_control_curency"] = i, d["data-product_price_currency_location"] = i;
234
+ extractConfigBlockAttributes(t, r, c) {
235
+ const a = t.querySelector("esd-config-block"), i = {};
236
+ if (!a)
237
+ return this.getDefaultConfigBlockAttributes();
238
+ if (Array.from(a.attributes).forEach((e) => {
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"];
242
+ if (/^\d+$/.test(e)) {
243
+ const l = parseInt(e) - 1, u = I[r];
244
+ u && u[l] && (i["data-cart_items_select_control_value"] = u[l].value);
268
245
  }
269
- (!d["data-product_price_control_currency_symbol"] || d["data-product_price_control_currency_symbol"].trim() === "") && (d["data-product_price_control_currency_symbol"] = "USD");
270
246
  }
271
- const n = { ...this.getDefaultConfigBlockAttributes(), ...d };
272
- return n["data-type"] = e, n["data-source"] = e, n["data-product_image_link"] = H(e, a), n["data-product_button_link"] = $(e, a), n;
247
+ if (i["data-product_price_control_curency"]) {
248
+ const e = i["data-product_price_control_curency"];
249
+ let l = e;
250
+ e === "before" ? l = "0" : e === "after" && (l = "1"), i["data-product_price_control_curency"] = l, i["data-product_price_currency_location"] = l;
251
+ }
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, c), n["data-product_button_link"] = N(r, c), n;
273
255
  }
274
256
  /**
275
257
  * Returns default esd-config-block attributes based on the old template structure
@@ -343,27 +325,25 @@ class F {
343
325
  backfillV2ProductTdAttributes(t) {
344
326
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
345
327
  return t;
346
- const e = this.parser.parseFromString(t, "text/html");
347
- let a = !1;
348
- return e.querySelectorAll(".ins-product-td").forEach((r) => {
349
- r.hasAttribute("width") && (r.removeAttribute("width"), a = !0), r.classList.contains("esd-container-frame") && (r.classList.remove("esd-container-frame"), a = !0);
350
- const d = r.querySelector("table.ins-product-wrapper");
351
- d != null && d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), a = !0);
352
- const n = r.getAttribute("esd-ext-config");
353
- let o = null;
328
+ const r = this.parser.parseFromString(t, "text/html");
329
+ let c = !1;
330
+ return r.querySelectorAll(".ins-product-td").forEach((a) => {
331
+ a.hasAttribute("width") && (a.removeAttribute("width"), c = !0);
332
+ const i = a.getAttribute("esd-ext-config");
333
+ let n = null;
354
334
  try {
355
- o = n ? JSON.parse(n) : null;
335
+ n = i ? JSON.parse(i) : null;
356
336
  } catch {
357
337
  }
358
- if (!o || (!r.getAttribute("data-nodup") && typeof o.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(o.priceHideDiscount)), a = !0), r.getAttribute("data-type")))
338
+ if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
359
339
  return;
360
- const i = o.type || o.source;
361
- if (!i)
340
+ const e = n.type || n.source;
341
+ if (!e)
362
342
  return;
363
- r.setAttribute("data-type", i), a = !0;
364
- const u = typeof o.itemsSelectValue == "string" ? o.itemsSelectValue.match(/\((\d+)\)/) : null;
365
- u && r.getAttribute("data-number") !== u[1] && r.setAttribute("data-number", u[1]);
366
- }), a ? e.documentElement.outerHTML : t;
343
+ a.setAttribute("data-type", e), c = !0;
344
+ const l = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
345
+ l && a.getAttribute("data-number") !== l[1] && a.setAttribute("data-number", l[1]);
346
+ }), c ? r.documentElement.outerHTML : t;
367
347
  }
368
348
  /**
369
349
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -384,22 +364,54 @@ class F {
384
364
  * contains display condition Jinja scripts that should NOT be removed.
385
365
  */
386
366
  removeJinjaConditionals(t) {
387
- const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", a = t.match(/esd-custom-display-conditions="[^"]*"/);
388
- let r = a ? t.replace(a[0], e) : t;
389
- return r = r.replace(
367
+ const r = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
368
+ let a = c ? t.replace(c[0], r) : t;
369
+ return a = a.replace(
390
370
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
391
371
  ""
392
- ), r = r.replace(
372
+ ), a = a.replace(
393
373
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
394
374
  ""
395
- ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), a && (r = r.replace(e, a[0])), r = r.replace(/\n\s*\n\s*\n/g, `
375
+ ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
396
376
 
397
- `), r;
377
+ `), a;
378
+ }
379
+ /**
380
+ * Replaces template variables with default values from productPairs
381
+ * Supports all block types by detecting prefix and using appropriate type:
382
+ *
383
+ * Examples:
384
+ * - {{ins_apr_img_1}} → https://web-image.useinsider.com/.../img_1.jpeg (CART_ITEMS)
385
+ * - {{browsed_item_name_2}} → 'Set of Sprite Yoga Straps' (BROWSED_ITEMS)
386
+ * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
387
+ */
388
+ replaceTemplateVariables(t) {
389
+ const { PAIRS_FOR_EXTENSION: r } = K;
390
+ return t.replace(/{{([^}]+)}}/g, (c, a) => {
391
+ const i = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
392
+ if (!i)
393
+ return c;
394
+ const [, n, e, l] = i, u = V[n];
395
+ if (!u)
396
+ return console.warn(`Unknown variable prefix: ${n}`), c;
397
+ const s = x[e];
398
+ if (!s)
399
+ return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
400
+ const { pairsKey: _, defaultKey: d, isArray: b } = s, y = r[_][u];
401
+ if (!y)
402
+ return console.warn(`No data found for: ${_}.${u}`), c;
403
+ if (b) {
404
+ const f = parseInt(l) - 1, m = y[d];
405
+ return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
406
+ }
407
+ const A = y[d];
408
+ return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
409
+ });
398
410
  }
399
411
  }
400
- function J(c) {
401
- return new F().migrate(c);
412
+ function Q(o) {
413
+ return new H().migrate(o);
402
414
  }
403
415
  export {
404
- J as migrateItemsBlock
416
+ Q as migrateItemsBlock
405
417
  };