@useinsider/guido 3.17.0-beta.ab974c6 → 3.17.0-beta.bc6e089

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.
@@ -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 K = Object.defineProperty;
2
+ var U = (a, t, e) => t in a ? K(a, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[t] = e;
3
+ var R = (a, t, e) => U(a, typeof t != "symbol" ? t + "" : t, e);
4
+ import { BLOCK_ID as F } from "../../extensions/Blocks/Items/block.js";
5
+ import { productPairs as x } from "../../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { ItemInCartOptions as I, DefaultConfigValues as S, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as O } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as $ } from "../../stores/template.js";
9
+ const V = {
10
10
  img: {
11
11
  pairsKey: "imageSrc",
12
12
  defaultKey: "DEFAULT",
@@ -73,126 +73,126 @@ const x = {
73
73
  isArray: !1
74
74
  }
75
75
  };
76
- function O() {
76
+ function N() {
77
77
  return String(Date.now() + Math.floor(Math.random() * 1e3));
78
78
  }
79
- function k(o) {
80
- return o ? {
79
+ function L(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;
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);
89
+ function k(a) {
90
+ var r;
91
+ const t = (l, u) => l == null ? u : l === "1" || l === "true", e = (l, u) => l || u, c = a["data-type"] || a["data-source"], o = L(c), n = I[o];
92
+ let i = a["data-cart_items_select_control_value"] || ((r = n == null ? void 0 : n[0]) == null ? void 0 : r.value) || S.cartItemsSelectControlValue;
93
+ if (i && !i.includes("{{") && /^\d+$/.test(i)) {
94
+ const l = parseInt(i) - 1, u = I[o];
95
+ u && u[l] && (i = u[l].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,
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
99
+ blockInstanceId: e(a["data-block-instance-id"], N()),
100
+ source: o,
101
+ type: o,
102
+ itemsSelectValue: i,
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
+ S.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
+ S.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"], S.productButtonLinkControlValue),
119
+ imageLink: e(a["data-product_image_link"], S.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 z = {
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 H(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 Y(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 W {
152
152
  constructor() {
153
- M(this, "parser");
153
+ R(this, "parser");
154
154
  this.parser = new DOMParser();
155
155
  }
156
156
  migrate(t) {
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 c = this.parser.parseFromString(e, "text/html"), o = c.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((i) => {
166
+ i.migrations = { ...i.migrations, [F]: o.length };
167
+ }), o.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), e) : (o.forEach((i) => {
168
+ const r = this.extractConfiguration(i), l = O({
169
+ orientation: r.orientation,
170
+ itemsType: r.itemsType,
171
+ itemId: r.itemId,
172
+ currencySymbol: r.currencySymbol,
173
+ currencyLocation: r.currencyLocation,
174
+ formattedPrice: r.formattedPrice,
175
+ configBlockAttributes: r.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)
177
+ nameStyles: r.nameStyles,
178
+ buttonStyles: r.buttonStyles,
179
+ priceStyles: r.priceStyles,
180
+ originalPriceStyles: r.originalPriceStyles,
181
+ quantityStyles: r.quantityStyles,
182
+ nodeConfig: k(r.configBlockAttributes)
183
183
  }), s = this.parser.parseFromString(
184
184
  `<table><tbody><tr>${l}</tr></tbody></table>`,
185
185
  "text/html"
186
186
  ).querySelector("td");
187
- if (s && n.parentNode) {
188
- const _ = h(e.configBlockAttributes);
187
+ if (s && i.parentNode) {
188
+ const _ = k(r.configBlockAttributes);
189
189
  s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
190
190
  const d = s.querySelector("esd-config-block");
191
- d && d.remove(), n.parentNode.replaceChild(s, n);
191
+ d && d.remove(), i.parentNode.replaceChild(s, i);
192
192
  }
193
193
  }), c.documentElement.outerHTML);
194
- } catch (r) {
195
- return console.error("ItemsBlockMigrator failed:", r), t;
194
+ } catch (e) {
195
+ return console.error("ItemsBlockMigrator failed:", e), t;
196
196
  }
197
197
  }
198
198
  /**
@@ -202,28 +202,76 @@ 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 D, P, M;
206
+ const e = L(
207
+ ((D = t.querySelector("[data-type]")) == null ? void 0 : D.getAttribute("data-type")) ?? null
208
+ ), c = ((P = t.querySelector("[data-number]")) == null ? void 0 : P.getAttribute("data-number")) || "1", o = parseInt(c) - 1, n = I[e], i = ((M = n == null ? void 0 : n[o]) == null ? void 0 : M.value) || n[0].value, r = this.extractConfigBlockAttributes(t, e, c);
209
+ this.applyDomFallbacks(t, r);
210
+ const l = t.querySelector('[product-attr="price"]'), u = l ?? t.querySelector('[product-attr="originalPrice"]'), s = (u == null ? void 0 : u.getAttribute("data-currency_symbol")) || r["data-product_price_control_currency_symbol"], _ = u == null ? void 0 : u.getAttribute("data-curency");
211
+ let d = r["data-product_price_currency_location"] || "0";
212
+ _ && (d = _ === "after" ? "1" : "0");
213
+ const A = (u == null ? void 0 : u.getAttribute("data-formated")) ?? r["data-product_price_control_formated"], h = A !== "false" && A !== "0", m = r["data-card_orientation_control_value"];
214
+ let g;
215
+ m ? g = m === "horizontal" ? "horizontal" : "vertical" : g = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
216
+ const f = t.querySelector('a[product-attr="name"]'), b = (f == null ? void 0 : f.getAttribute("style")) || void 0, E = t.querySelector('a[product-attr="button"]'), w = (E == null ? void 0 : E.getAttribute("style")) || void 0, v = (l == null ? void 0 : l.getAttribute("style")) || void 0, y = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = y != null && y.getAttribute("style") ? y : (y == null ? void 0 : y.closest("p")) ?? y, B = (T == null ? void 0 : T.getAttribute("style")) || void 0, C = t.querySelector('[product-attr="quantity"]'), q = (C == null ? void 0 : C.getAttribute("style")) || void 0;
212
217
  return {
213
- orientation: S,
214
- itemsType: r,
215
- 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,
224
- quantityStyles: B
218
+ orientation: g,
219
+ itemsType: e,
220
+ itemId: i,
221
+ currencySymbol: s,
222
+ currencyLocation: d,
223
+ formattedPrice: h,
224
+ configBlockAttributes: r,
225
+ nameStyles: b,
226
+ buttonStyles: w,
227
+ priceStyles: v,
228
+ originalPriceStyles: B,
229
+ quantityStyles: q
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 u;
241
+ const c = t.querySelector("esd-config-block");
242
+ if (Object.entries({
243
+ image: '[product-attr="imageSrc"]',
244
+ name: '[product-attr="name"]',
245
+ price: '[product-attr="price"]',
246
+ original_price: '[product-attr="originalPrice"], p.original-price',
247
+ quantity: '[product-attr="quantity"]',
248
+ button: '[product-attr="button"]'
249
+ }).forEach(([s, _]) => {
250
+ const d = `data-product_${s}_control_enabled`;
251
+ (!c || !c.hasAttribute(d)) && (e[d] = t.querySelector(_) ? "true" : "false");
252
+ }), c)
253
+ return;
254
+ e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal";
255
+ const n = t.querySelector('a[product-attr="button"]'), i = (u = n == null ? void 0 : n.textContent) == null ? void 0 : u.replace(/\s+/g, " ").trim();
256
+ i && (e["data-product_button_control_label"] = i), /display:\s*inline/.test((n == null ? void 0 : n.getAttribute("style")) || "") && (e["data-product_button_control_atw"] = "false");
257
+ const r = t.querySelector('[product-attr="imageSrc"]'), l = r ? this.readImageDimension(r) : null;
258
+ l && (e["data-product_image_control_image-height"] = l, e["data-product_image_control_image-width"] = l);
259
+ }
260
+ /**
261
+ * Reads a pixel dimension for the product image from its DOM element — the legacy
262
+ * `width` attribute first, then a px value in the inline style. An explicit `width` wins
263
+ * over `max-width`, which is only an upper bound; `max-width` still covers the common
264
+ * `width: 100%` case, where no pixel size can be read from `width` itself.
265
+ * Returns null when no pixel size is present.
266
+ */
267
+ readImageDimension(t) {
268
+ var n;
269
+ const e = (n = t.getAttribute("width")) == null ? void 0 : n.trim();
270
+ if (e && /^\d+$/.test(e))
271
+ return e;
272
+ const c = t.getAttribute("style") || "", o = c.match(/(?:^|;)\s*width:\s*(\d+)px/) || c.match(/max-width:\s*(\d+)px/);
273
+ return o ? o[1] : null;
274
+ }
227
275
  /**
228
276
  * Extracts all data-* attributes from the esd-config-block element
229
277
  * Returns a key-value mapping of all configuration attributes
@@ -231,27 +279,27 @@ class H {
231
279
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
232
280
  * @param itemNumber - The item number (1-based index)
233
281
  */
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);
282
+ extractConfigBlockAttributes(t, e, c) {
283
+ const o = t.querySelector("esd-config-block"), n = {};
284
+ if (o) {
285
+ if (Array.from(o.attributes).forEach((r) => {
286
+ r.name.startsWith("data-") && (n[r.name] = r.value);
287
+ }), n["data-cart_items_select_control_value"]) {
288
+ const r = n["data-cart_items_select_control_value"];
289
+ if (/^\d+$/.test(r)) {
290
+ const l = parseInt(r) - 1, u = I[e];
291
+ u && u[l] && (n["data-cart_items_select_control_value"] = u[l].value);
292
+ }
245
293
  }
294
+ if (n["data-product_price_control_curency"]) {
295
+ const r = n["data-product_price_control_curency"];
296
+ let l = r;
297
+ r === "before" ? l = "0" : r === "after" && (l = "1"), n["data-product_price_control_curency"] = l, n["data-product_price_currency_location"] = l;
298
+ }
299
+ (!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
246
300
  }
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;
301
+ const i = { ...this.getDefaultConfigBlockAttributes(), ...n };
302
+ return i["data-type"] = e, i["data-source"] = e, i["data-product_image_link"] = H(e, c), i["data-product_button_link"] = Y(e, c), i;
255
303
  }
256
304
  /**
257
305
  * Returns default esd-config-block attributes based on the old template structure
@@ -325,25 +373,25 @@ class H {
325
373
  backfillV2ProductTdAttributes(t) {
326
374
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
327
375
  return t;
328
- const r = this.parser.parseFromString(t, "text/html");
376
+ const e = this.parser.parseFromString(t, "text/html");
329
377
  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;
378
+ return e.querySelectorAll(".ins-product-td").forEach((o) => {
379
+ o.hasAttribute("width") && (o.removeAttribute("width"), c = !0);
380
+ const n = o.getAttribute("esd-ext-config");
381
+ let i = null;
334
382
  try {
335
- n = i ? JSON.parse(i) : null;
383
+ i = n ? JSON.parse(n) : null;
336
384
  } catch {
337
385
  }
338
- if (!n || (!a.getAttribute("data-nodup") && typeof n.priceHideDiscount == "boolean" && (a.setAttribute("data-nodup", String(n.priceHideDiscount)), c = !0), a.getAttribute("data-type")))
386
+ if (!i || (!o.getAttribute("data-nodup") && typeof i.priceHideDiscount == "boolean" && (o.setAttribute("data-nodup", String(i.priceHideDiscount)), c = !0), o.getAttribute("data-type")))
339
387
  return;
340
- const e = n.type || n.source;
341
- if (!e)
388
+ const r = i.type || i.source;
389
+ if (!r)
342
390
  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;
391
+ o.setAttribute("data-type", r), c = !0;
392
+ const l = typeof i.itemsSelectValue == "string" ? i.itemsSelectValue.match(/\((\d+)\)/) : null;
393
+ l && o.getAttribute("data-number") !== l[1] && o.setAttribute("data-number", l[1]);
394
+ }), c ? e.documentElement.outerHTML : t;
347
395
  }
348
396
  /**
349
397
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -364,17 +412,17 @@ class H {
364
412
  * contains display condition Jinja scripts that should NOT be removed.
365
413
  */
366
414
  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(
415
+ const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
416
+ let o = c ? t.replace(c[0], e) : t;
417
+ return o = o.replace(
370
418
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
371
419
  ""
372
- ), a = a.replace(
420
+ ), o = o.replace(
373
421
  /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
374
422
  ""
375
- ), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(r, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
423
+ ), o = o.replace(/\{%\s*endif\s*%\}/g, ""), c && (o = o.replace(e, c[0])), o = o.replace(/\n\s*\n\s*\n/g, `
376
424
 
377
- `), a;
425
+ `), o;
378
426
  }
379
427
  /**
380
428
  * Replaces template variables with default values from productPairs
@@ -386,32 +434,32 @@ class H {
386
434
  * - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
387
435
  */
388
436
  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)
437
+ const { PAIRS_FOR_EXTENSION: e } = x;
438
+ return t.replace(/{{([^}]+)}}/g, (c, o) => {
439
+ const n = o.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
440
+ if (!n)
393
441
  return c;
394
- const [, n, e, l] = i, u = V[n];
442
+ const [, i, r, l] = n, u = z[i];
395
443
  if (!u)
396
- return console.warn(`Unknown variable prefix: ${n}`), c;
397
- const s = x[e];
444
+ return console.warn(`Unknown variable prefix: ${i}`), c;
445
+ const s = V[r];
398
446
  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)
447
+ return console.warn(`Unknown variable suffix mapping for: ${r}`), c;
448
+ const { pairsKey: _, defaultKey: d, isArray: A } = s, m = e[_][u];
449
+ if (!m)
402
450
  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);
451
+ if (A) {
452
+ const f = parseInt(l) - 1, b = m[d];
453
+ return Array.isArray(b) && b[f] ? b[f] : (console.warn(`Array value not found: ${_}.${u}.${d}[${f}]`), c);
406
454
  }
407
- const A = y[d];
408
- return A !== void 0 ? String(A) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
455
+ const g = m[d];
456
+ return g !== void 0 ? String(g) : (console.warn(`Default value not found: ${_}.${u}.${d}`), c);
409
457
  });
410
458
  }
411
459
  }
412
- function Q(o) {
413
- return new H().migrate(o);
460
+ function et(a) {
461
+ return new W().migrate(a);
414
462
  }
415
463
  export {
416
- Q as migrateItemsBlock
464
+ et as migrateItemsBlock
417
465
  };