@useinsider/guido 3.17.0-beta.77567eb → 3.17.0-beta.a51375c

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.
package/README.md CHANGED
@@ -633,16 +633,16 @@ toaster fires (useful before the host has wired the catalog).
633
633
 
634
634
  ```bash
635
635
  # Install
636
- npm install
636
+ bun install
637
637
 
638
638
  # Start dev server
639
- npm start
639
+ bun start
640
640
 
641
641
  # Build
642
- npm run build
642
+ bun run build
643
643
 
644
644
  # Lint & type-check
645
- npm run lint
645
+ bun run lint
646
646
  ```
647
647
 
648
648
  ### Environment Variables
@@ -660,7 +660,7 @@ VITE_STRIPO_USER=your_user
660
660
 
661
661
  ```bash
662
662
  # Build the package
663
- npm run build
663
+ bun run build
664
664
 
665
665
  # Create tarball
666
666
  npm pack
@@ -1,12 +1,12 @@
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 = {
1
+ var q = Object.defineProperty;
2
+ var U = (a, t, e) => t in a ? q(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var M = (a, t, e) => U(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import { BLOCK_ID as K } from "../../extensions/Blocks/Items/block.js";
5
+ import { productPairs as F } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { ItemInCartOptions as A, DefaultConfigValues as b, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as x } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as $ } from "../../stores/template.js";
9
+ const O = {
10
10
  img: {
11
11
  pairsKey: "imageSrc",
12
12
  defaultKey: "DEFAULT",
@@ -73,82 +73,82 @@ const x = {
73
73
  isArray: !1
74
74
  }
75
75
  };
76
- function O() {
76
+ function V() {
77
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
78
  }
79
- function k(o) {
80
- return o ? {
79
+ function k(a) {
80
+ return a ? {
81
81
  CartItems: p.ITEMS_TYPE.CART_ITEMS,
82
82
  BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
83
83
  PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
84
84
  CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
85
85
  BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
86
86
  PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
87
- }[o] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
87
+ }[a] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
88
88
  }
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;
89
+ function R(a) {
90
+ var o;
91
+ const t = (c, u) => c == null ? u : c === "1" || c === "true", e = (c, u) => c || u, l = a["data-type"] || a["data-source"], r = k(l), i = A[r];
92
+ let n = a["data-cart_items_select_control_value"] || ((o = i == null ? void 0 : i[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
93
93
  if (n && !n.includes("{{") && /^\d+$/.test(n)) {
94
- const l = parseInt(n) - 1, u = I[a];
95
- u && u[l] && (n = u[l].value);
94
+ const c = parseInt(n) - 1, u = A[r];
95
+ u && u[c] && (n = u[c].value);
96
96
  }
97
97
  return {
98
98
  initialized: !0,
99
- blockInstanceId: r(o["data-block-instance-id"], O()),
100
- source: a,
101
- type: a,
99
+ blockInstanceId: e(a["data-block-instance-id"], V()),
100
+ source: r,
101
+ type: r,
102
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
- g.productPriceCurrencySymbolControlValue
103
+ orientation: a["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
104
+ nameTrimming: t(a["data-product_name_control_trim"], !0),
105
+ priceHideDiscount: t(a["data-product_price_control_nodup"], !0),
106
+ priceFormatted: t(a["data-product_price_control_formated"], !0),
107
+ priceSinglePrice: t(a["data-product_price_control_single_price"], !1),
108
+ priceCurrencySymbol: e(
109
+ a["data-product_price_control_currency_symbol"],
110
+ b.productPriceCurrencySymbolControlValue
111
111
  ),
112
- priceCurrencyLocation: r(
113
- o["data-product_price_currency_location"],
114
- g.productPriceCurrencyLocationControlValue
112
+ priceCurrencyLocation: e(
113
+ a["data-product_price_currency_location"],
114
+ b.productPriceCurrencyLocationControlValue
115
115
  ),
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)
116
+ priceOrientation: a["data-product_original_price_control_orientation"] || "horizontal",
117
+ quantityControlEnabled: t(a["data-product_quantity_control_enabled"], !0),
118
+ buttonLink: e(a["data-product_button_link"], b.productButtonLinkControlValue),
119
+ imageLink: e(a["data-product_image_link"], b.productImageLinkControlValue),
120
+ buttonLabel: e(a["data-product_button_control_label"], "Buy"),
121
+ buttonFullWidth: t(a["data-product_button_control_atw"], !0),
122
+ imageVisible: t(a["data-product_image_control_enabled"], !0),
123
+ nameVisible: t(a["data-product_name_control_enabled"], !0),
124
+ quantityVisible: t(a["data-product_quantity_control_enabled"], !0),
125
+ priceVisible: t(a["data-product_price_control_enabled"], !0),
126
+ originalPriceVisible: t(a["data-product_original_price_control_enabled"], !0),
127
+ buttonVisible: t(a["data-product_button_control_enabled"], !0)
128
128
  };
129
129
  }
130
- const V = {
130
+ const N = {
131
131
  ins_apr: "CART_ITEMS",
132
132
  browsed_item: "BROWSED_ITEMS",
133
133
  purchased_item: "PURCHASED_ITEMS"
134
134
  };
135
- function $(o, t) {
136
- const r = {
135
+ function z(a, t) {
136
+ const e = {
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 r[o] || r.CART_ITEMS;
141
+ return e[a] || e.CART_ITEMS;
142
142
  }
143
- function N(o, t) {
144
- const r = {
143
+ function H(a, t) {
144
+ const e = {
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 r[o] || r.CART_ITEMS;
149
+ return e[a] || e.CART_ITEMS;
150
150
  }
151
- class H {
151
+ class Y {
152
152
  constructor() {
153
153
  M(this, "parser");
154
154
  this.parser = new DOMParser();
@@ -157,42 +157,42 @@ class H {
157
157
  try {
158
158
  if (!this.containsItemsBlock(t))
159
159
  return this.backfillV2ProductTdAttributes(t);
160
- let r = this.removeJinjaConditionals(t);
161
- r = this.replaceTemplateVariables(r);
162
- const c = this.parser.parseFromString(r, "text/html"), a = c.querySelectorAll(
160
+ let e = this.removeJinjaConditionals(t);
161
+ e = this.replaceTemplateVariables(e);
162
+ const l = this.parser.parseFromString(e, "text/html"), r = l.querySelectorAll(
163
163
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
164
164
  );
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,
165
+ return $().$patch((n) => {
166
+ n.migrations = { ...n.migrations, [K]: r.length };
167
+ }), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (r.forEach((n) => {
168
+ const o = this.extractConfiguration(n), c = x({
169
+ orientation: o.orientation,
170
+ itemsType: o.itemsType,
171
+ itemId: o.itemId,
172
+ currencySymbol: o.currencySymbol,
173
+ currencyLocation: o.currencyLocation,
174
+ formattedPrice: o.formattedPrice,
175
+ configBlockAttributes: o.configBlockAttributes,
176
176
  migrate: !0,
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>`,
177
+ nameStyles: o.nameStyles,
178
+ buttonStyles: o.buttonStyles,
179
+ priceStyles: o.priceStyles,
180
+ originalPriceStyles: o.originalPriceStyles,
181
+ quantityStyles: o.quantityStyles,
182
+ nodeConfig: R(o.configBlockAttributes)
183
+ }), d = this.parser.parseFromString(
184
+ `<table><tbody><tr>${c}</tr></tbody></table>`,
185
185
  "text/html"
186
186
  ).querySelector("td");
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);
187
+ if (d && n.parentNode) {
188
+ const s = R(o.configBlockAttributes);
189
+ d.setAttribute("esd-ext-config", JSON.stringify(s)), d.setAttribute("data-type", s.type);
190
+ const _ = d.querySelector("esd-config-block");
191
+ _ && _.remove(), n.parentNode.replaceChild(d, n);
192
192
  }
193
- }), c.documentElement.outerHTML);
194
- } catch (r) {
195
- return console.error("ItemsBlockMigrator failed:", r), t;
193
+ }), l.documentElement.outerHTML);
194
+ } catch (e) {
195
+ return console.error("ItemsBlockMigrator failed:", e), t;
196
196
  }
197
197
  }
198
198
  /**
@@ -202,28 +202,72 @@ class H {
202
202
  * - UI styles from product elements (name, price, button, quantity, etc.)
203
203
  */
204
204
  extractConfiguration(t) {
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;
205
+ var h, D, P;
206
+ const e = k(
207
+ ((h = t.querySelector("[data-type]")) == null ? void 0 : h.getAttribute("data-type")) ?? null
208
+ ), l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", r = parseInt(l) - 1, i = A[e], n = ((P = i == null ? void 0 : i[r]) == null ? void 0 : P.value) || i[0].value, o = this.extractConfigBlockAttributes(t, e, l);
209
+ this.applyDomFallbacks(t, o);
210
+ const c = t.querySelector('[product-attr="price"]'), u = c ?? t.querySelector('[product-attr="originalPrice"]'), d = (u == null ? void 0 : u.getAttribute("data-currency_symbol")) || o["data-product_price_control_currency_symbol"] || "USD", s = u == null ? void 0 : u.getAttribute("data-curency");
211
+ let _ = o["data-product_price_currency_location"] || "0";
212
+ s && (_ = s === "after" ? "1" : "0");
213
+ const S = (u == null ? void 0 : u.getAttribute("data-formated")) ?? o["data-product_price_control_formated"], C = S !== "false" && S !== "0", y = o["data-card_orientation_control_value"];
214
+ let f;
215
+ y ? f = y === "horizontal" ? "horizontal" : "vertical" : f = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
216
+ const m = t.querySelector('a[product-attr="name"]'), g = (m == null ? void 0 : m.getAttribute("style")) || void 0, I = t.querySelector('a[product-attr="button"]'), L = (I == null ? void 0 : I.getAttribute("style")) || void 0, w = (c == null ? void 0 : c.getAttribute("style")) || void 0, E = t.querySelector("p.original-price"), v = (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;
212
217
  return {
213
- orientation: S,
214
- itemsType: r,
218
+ orientation: f,
219
+ itemsType: e,
215
220
  itemId: n,
216
- currencySymbol: l,
217
- currencyLocation: s,
218
- formattedPrice: _,
219
- configBlockAttributes: d,
220
- nameStyles: A,
221
- buttonStyles: m,
222
- priceStyles: R,
223
- originalPriceStyles: L,
221
+ currencySymbol: d,
222
+ currencyLocation: _,
223
+ formattedPrice: C,
224
+ configBlockAttributes: o,
225
+ nameStyles: g,
226
+ buttonStyles: L,
227
+ priceStyles: w,
228
+ originalPriceStyles: v,
224
229
  quantityStyles: B
225
230
  };
226
231
  }
232
+ /**
233
+ * DOM fallback for hand-edited templates whose esd-config-block was deleted. With no
234
+ * toggle record left, derive each field's enabled state from whether its product-attr
235
+ * element still exists and read the button label from the live caption — a deleted
236
+ * element means the field is off, not an all-ON default. A present config block stays
237
+ * authoritative (a missing flag there still means "default on"), so we no-op for it.
238
+ */
239
+ applyDomFallbacks(t, e) {
240
+ var c;
241
+ if (t.querySelector("esd-config-block"))
242
+ return;
243
+ e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal", Object.entries({
244
+ image: "imageSrc",
245
+ name: "name",
246
+ price: "price",
247
+ original_price: "originalPrice",
248
+ quantity: "quantity",
249
+ button: "button"
250
+ }).forEach(([u, d]) => {
251
+ e[`data-product_${u}_control_enabled`] = t.querySelector(`[product-attr="${d}"]`) ? "true" : "false";
252
+ });
253
+ const r = t.querySelector('a[product-attr="button"]'), i = (c = r == null ? void 0 : r.textContent) == null ? void 0 : c.replace(/\s+/g, " ").trim();
254
+ i && (e["data-product_button_control_label"] = i), /display:\s*inline/.test((r == null ? void 0 : r.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
255
+ const n = t.querySelector('[product-attr="imageSrc"]'), o = n ? this.readImageDimension(n) : null;
256
+ o && (e["data-product_image_control_image-height"] = o, e["data-product_image_control_image-width"] = o);
257
+ }
258
+ /**
259
+ * Reads a pixel dimension for the product image from its DOM element — the legacy
260
+ * `width` attribute first, then a px value in the inline style (max-width wins over a
261
+ * percentage width). Returns null when no pixel size is present.
262
+ */
263
+ readImageDimension(t) {
264
+ var i;
265
+ const e = (i = t.getAttribute("width")) == null ? void 0 : i.trim();
266
+ if (e && /^\d+$/.test(e))
267
+ return e;
268
+ const l = t.getAttribute("style") || "", r = l.match(/max-width:\s*(\d+)px/) || l.match(/(?:^|;)\s*width:\s*(\d+)px/);
269
+ return r ? r[1] : null;
270
+ }
227
271
  /**
228
272
  * Extracts all data-* attributes from the esd-config-block element
229
273
  * Returns a key-value mapping of all configuration attributes
@@ -231,27 +275,27 @@ class H {
231
275
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
232
276
  * @param itemNumber - The item number (1-based index)
233
277
  */
234
- extractConfigBlockAttributes(t, r, c) {
235
- const a = t.querySelector("esd-config-block"), i = {};
236
- if (!a)
278
+ extractConfigBlockAttributes(t, e, l) {
279
+ const r = t.querySelector("esd-config-block"), i = {};
280
+ if (!r)
237
281
  return this.getDefaultConfigBlockAttributes();
238
- if (Array.from(a.attributes).forEach((e) => {
239
- e.name.startsWith("data-") && (i[e.name] = e.value);
282
+ if (Array.from(r.attributes).forEach((o) => {
283
+ o.name.startsWith("data-") && (i[o.name] = o.value);
240
284
  }), 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);
285
+ const o = i["data-cart_items_select_control_value"];
286
+ if (/^\d+$/.test(o)) {
287
+ const c = parseInt(o) - 1, u = A[e];
288
+ u && u[c] && (i["data-cart_items_select_control_value"] = u[c].value);
245
289
  }
246
290
  }
247
291
  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;
292
+ const o = i["data-product_price_control_curency"];
293
+ let c = o;
294
+ o === "before" ? c = "0" : o === "after" && (c = "1"), i["data-product_price_control_curency"] = c, i["data-product_price_currency_location"] = c;
251
295
  }
252
296
  (!i["data-product_price_control_currency_symbol"] || i["data-product_price_control_currency_symbol"].trim() === "") && (i["data-product_price_control_currency_symbol"] = "USD");
253
297
  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;
298
+ return n["data-type"] = e, n["data-source"] = e, n["data-product_image_link"] = z(e, l), n["data-product_button_link"] = H(e, l), n;
255
299
  }
256
300
  /**
257
301
  * Returns default esd-config-block attributes based on the old template structure
@@ -325,25 +369,25 @@ class H {
325
369
  backfillV2ProductTdAttributes(t) {
326
370
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
327
371
  return t;
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");
372
+ const e = this.parser.parseFromString(t, "text/html");
373
+ let l = !1;
374
+ return e.querySelectorAll(".ins-product-td").forEach((r) => {
375
+ r.hasAttribute("width") && (r.removeAttribute("width"), l = !0);
376
+ const i = r.getAttribute("esd-ext-config");
333
377
  let n = null;
334
378
  try {
335
379
  n = i ? JSON.parse(i) : null;
336
380
  } catch {
337
381
  }
338
- if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
382
+ if (!n || (!r.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(n.priceHideDiscount)), l = !0), r.getAttribute("data-type")))
339
383
  return;
340
- const e = n.type || n.source;
341
- if (!e)
384
+ const o = n.type || n.source;
385
+ if (!o)
342
386
  return;
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;
387
+ r.setAttribute("data-type", o), l = !0;
388
+ const c = typeof n.itemsSelectValue == "string" ? n.itemsSelectValue.match(/\((\d+)\)/) : null;
389
+ c && r.getAttribute("data-number") !== c[1] && r.setAttribute("data-number", c[1]);
390
+ }), l ? e.documentElement.outerHTML : t;
347
391
  }
348
392
  /**
349
393
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -364,17 +408,17 @@ class H {
364
408
  * contains display condition Jinja scripts that should NOT be removed.
365
409
  */
366
410
  removeJinjaConditionals(t) {
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(
411
+ const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", l = t.match(/esd-custom-display-conditions="[^"]*"/);
412
+ let r = l ? t.replace(l[0], e) : t;
413
+ return r = r.replace(
370
414
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
371
415
  ""
372
- ), a = a.replace(
416
+ ), r = r.replace(
373
417
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
374
418
  ""
375
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
419
+ ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), l && (r = r.replace(e, l[0])), r = r.replace(/\n\s*\n\s*\n/g, `
376
420
 
377
- `), a;
421
+ `), r;
378
422
  }
379
423
  /**
380
424
  * Replaces template variables with default values from productPairs
@@ -386,32 +430,32 @@ class H {
386
430
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
387
431
  */
388
432
  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+)$/);
433
+ const { PAIRS_FOR_EXTENSION: e } = F;
434
+ return t.replace(/{{([^}]+)}}/g, (l, r) => {
435
+ const i = r.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
392
436
  if (!i)
393
- return c;
394
- const [, n, e, l] = i, u = V[n];
437
+ return l;
438
+ const [, n, o, c] = i, u = N[n];
395
439
  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];
440
+ return console.warn(`Unknown variable prefix: ${n}`), l;
441
+ const d = O[o];
442
+ if (!d)
443
+ return console.warn(`Unknown variable suffix mapping for: ${o}`), l;
444
+ const { pairsKey: s, defaultKey: _, isArray: S } = d, y = e[s][u];
401
445
  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);
446
+ return console.warn(`No data found for: ${s}.${u}`), l;
447
+ if (S) {
448
+ const m = parseInt(c) - 1, g = y[_];
449
+ return Array.isArray(g) && g[m] ? g[m] : (console.warn(`Array value not found: ${s}.${u}.${_}[${m}]`), l);
406
450
  }
407
- const A = y[d];
408
- return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
451
+ const f = y[_];
452
+ return f !== void 0 ? String(f) : (console.warn(`Default value not found: ${s}.${u}.${_}`), l);
409
453
  });
410
454
  }
411
455
  }
412
- function Q(o) {
413
- return new H().migrate(o);
456
+ function tt(a) {
457
+ return new Y().migrate(a);
414
458
  }
415
459
  export {
416
- Q as migrateItemsBlock
460
+ tt as migrateItemsBlock
417
461
  };