@useinsider/guido 3.27.0-beta.8bef749 → 3.27.0-beta.8f596fb

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,59 +1,63 @@
1
- var B = Object.defineProperty;
2
- var v = (n, t, e) => t in n ? B(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var M = (n, t, e) => v(n, typeof t != "symbol" ? t + "" : t, e);
4
- import { BLOCK_ID as R } from "../../extensions/Blocks/Items/block.js";
5
- import { hasZeroWidthDeclaration as L, withoutZeroWidth as x } from "../../extensions/Blocks/Items/constants/cardWidth.js";
6
- import { ItemInCartOptions as h, DefaultConfigValues as b, SETTINGS_ENUMS as _ } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
- import { getDefaultTemplate as V } from "../../extensions/Blocks/Items/template.js";
8
- import { useTemplateStore as O } from "../../stores/template.js";
9
- import { protectLiquid as H, restoreLiquid as $ } from "../../utils/liquidProtection.js";
10
- function F() {
1
+ var v = Object.defineProperty;
2
+ var L = (n, t, e) => t in n ? v(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var M = (n, t, e) => L(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { BLOCK_ID as x } from "../../extensions/Blocks/Items/block.js";
5
+ import { hasZeroWidthDeclaration as V, withoutZeroWidth as O } from "../../extensions/Blocks/Items/constants/cardWidth.js";
6
+ import { ItemInCartOptions as h, DefaultConfigValues as y, SETTINGS_ENUMS as s } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as H } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as U } from "../../stores/template.js";
9
+ import { protectLiquid as P, restoreLiquid as D } from "../../utils/liquidProtection.js";
10
+ const $ = /\{%-?\s*(\w+)(?:(?!\{%)[\s\S])*?%\}/g, F = [
11
+ /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/,
12
+ /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/
13
+ ], N = /esd-custom-display-conditions?="[^"]*"/g;
14
+ function Y() {
11
15
  return String(Date.now() + Math.floor(Math.random() * 1e3));
12
16
  }
13
- function D(n) {
17
+ function w(n) {
14
18
  return n ? {
15
- CartItems: _.ITEMS_TYPE.CART_ITEMS,
16
- BrowsedItems: _.ITEMS_TYPE.BROWSED_ITEMS,
17
- PurchasedItems: _.ITEMS_TYPE.PURCHASED_ITEMS,
18
- CART_ITEMS: _.ITEMS_TYPE.CART_ITEMS,
19
- BROWSED_ITEMS: _.ITEMS_TYPE.BROWSED_ITEMS,
20
- PURCHASED_ITEMS: _.ITEMS_TYPE.PURCHASED_ITEMS
21
- }[n] || _.ITEMS_TYPE.CART_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
19
+ CartItems: s.ITEMS_TYPE.CART_ITEMS,
20
+ BrowsedItems: s.ITEMS_TYPE.BROWSED_ITEMS,
21
+ PurchasedItems: s.ITEMS_TYPE.PURCHASED_ITEMS,
22
+ CART_ITEMS: s.ITEMS_TYPE.CART_ITEMS,
23
+ BROWSED_ITEMS: s.ITEMS_TYPE.BROWSED_ITEMS,
24
+ PURCHASED_ITEMS: s.ITEMS_TYPE.PURCHASED_ITEMS
25
+ }[n] || s.ITEMS_TYPE.CART_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
22
26
  }
23
- function U(n) {
24
- return n.classList.contains("esd-browsed-items-block") ? _.ITEMS_TYPE.BROWSED_ITEMS : n.classList.contains("esd-purchased-items-block") ? _.ITEMS_TYPE.PURCHASED_ITEMS : _.ITEMS_TYPE.CART_ITEMS;
27
+ function W(n) {
28
+ return n.classList.contains("esd-browsed-items-block") ? s.ITEMS_TYPE.BROWSED_ITEMS : n.classList.contains("esd-purchased-items-block") ? s.ITEMS_TYPE.PURCHASED_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
25
29
  }
26
- function P(n) {
27
- var o;
28
- const t = (i, d) => i == null ? d : i === "1" || i === "true", e = (i, d) => i || d, a = n["data-type"] || n["data-source"], r = D(a), u = h[r];
29
- let c = n["data-cart_items_select_control_value"] || ((o = u == null ? void 0 : u[0]) == null ? void 0 : o.value) || b.cartItemsSelectControlValue;
30
+ function k(n) {
31
+ var r;
32
+ const t = (i, d) => i == null ? d : i === "1" || i === "true", e = (i, d) => i || d, u = n["data-type"] || n["data-source"], o = w(u), a = h[o];
33
+ let c = n["data-cart_items_select_control_value"] || ((r = a == null ? void 0 : a[0]) == null ? void 0 : r.value) || y.cartItemsSelectControlValue;
30
34
  if (c && !c.includes("{{") && /^\d+$/.test(c)) {
31
- const i = parseInt(c) - 1, d = h[r];
35
+ const i = parseInt(c) - 1, d = h[o];
32
36
  d && d[i] && (c = d[i].value);
33
37
  }
34
38
  return {
35
39
  initialized: !0,
36
- blockInstanceId: e(n["data-block-instance-id"], F()),
37
- source: r,
38
- type: r,
40
+ blockInstanceId: e(n["data-block-instance-id"], Y()),
41
+ source: o,
42
+ type: o,
39
43
  itemsSelectValue: c,
40
- orientation: n["data-card_orientation_control_value"] || _.ORIENTATION.VERTICAL,
44
+ orientation: n["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
41
45
  nameTrimming: t(n["data-product_name_control_trim"], !0),
42
46
  priceHideDiscount: t(n["data-product_price_control_nodup"], !0),
43
47
  priceFormatted: t(n["data-product_price_control_formated"], !0),
44
48
  priceSinglePrice: t(n["data-product_price_control_single_price"], !1),
45
49
  priceCurrencySymbol: e(
46
50
  n["data-product_price_control_currency_symbol"],
47
- b.productPriceCurrencySymbolControlValue
51
+ y.productPriceCurrencySymbolControlValue
48
52
  ),
49
53
  priceCurrencyLocation: e(
50
54
  n["data-product_price_currency_location"],
51
- b.productPriceCurrencyLocationControlValue
55
+ y.productPriceCurrencyLocationControlValue
52
56
  ),
53
57
  priceOrientation: n["data-product_original_price_control_orientation"] || "horizontal",
54
58
  quantityControlEnabled: t(n["data-product_quantity_control_enabled"], !0),
55
- buttonLink: e(n["data-product_button_link"], b.productButtonLinkControlValue),
56
- imageLink: e(n["data-product_image_link"], b.productImageLinkControlValue),
59
+ buttonLink: e(n["data-product_button_link"], y.productButtonLinkControlValue),
60
+ imageLink: e(n["data-product_image_link"], y.productImageLinkControlValue),
57
61
  buttonLabel: e(n["data-product_button_control_label"], "Buy"),
58
62
  buttonFullWidth: t(n["data-product_button_control_atw"], !0),
59
63
  imageVisible: t(n["data-product_image_control_enabled"], !0),
@@ -64,7 +68,7 @@ function P(n) {
64
68
  buttonVisible: t(n["data-product_button_control_enabled"], !0)
65
69
  };
66
70
  }
67
- function Y(n, t) {
71
+ function z(n, t) {
68
72
  const e = {
69
73
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
70
74
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
@@ -72,7 +76,7 @@ function Y(n, t) {
72
76
  };
73
77
  return e[n] || e.CART_ITEMS;
74
78
  }
75
- function W(n, t) {
79
+ function G(n, t) {
76
80
  const e = {
77
81
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
78
82
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
@@ -80,7 +84,7 @@ function W(n, t) {
80
84
  };
81
85
  return e[n] || e.CART_ITEMS;
82
86
  }
83
- class z {
87
+ class J {
84
88
  constructor() {
85
89
  M(this, "parser");
86
90
  this.parser = new DOMParser();
@@ -89,38 +93,38 @@ class z {
89
93
  try {
90
94
  if (!this.containsItemsBlock(t))
91
95
  return this.backfillV2ProductTdAttributes(t);
92
- const e = this.removeJinjaConditionals(t), a = this.parser.parseFromString(e, "text/html"), r = a.querySelectorAll(
96
+ const e = this.removeJinjaConditionals(t), u = this.parser.parseFromString(P(e), "text/html"), o = u.querySelectorAll(
93
97
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
94
98
  );
95
- return O().$patch((c) => {
96
- c.migrations = { ...c.migrations, [R]: r.length };
97
- }), r.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e)) : (r.forEach((c) => {
98
- const o = this.extractConfiguration(c), i = V({
99
- orientation: o.orientation,
100
- itemsType: o.itemsType,
101
- itemId: o.itemId,
102
- currencySymbol: o.currencySymbol,
103
- currencyLocation: o.currencyLocation,
104
- formattedPrice: o.formattedPrice,
105
- configBlockAttributes: o.configBlockAttributes,
99
+ return U().$patch((c) => {
100
+ c.migrations = { ...c.migrations, [x]: o.length };
101
+ }), o.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e)) : (o.forEach((c) => {
102
+ const r = this.extractConfiguration(c), i = H({
103
+ orientation: r.orientation,
104
+ itemsType: r.itemsType,
105
+ itemId: r.itemId,
106
+ currencySymbol: r.currencySymbol,
107
+ currencyLocation: r.currencyLocation,
108
+ formattedPrice: r.formattedPrice,
109
+ configBlockAttributes: r.configBlockAttributes,
106
110
  migrate: !0,
107
- nameStyles: o.nameStyles,
108
- buttonStyles: o.buttonStyles,
109
- priceStyles: o.priceStyles,
110
- originalPriceStyles: o.originalPriceStyles,
111
- quantityStyles: o.quantityStyles,
112
- nodeConfig: P(o.configBlockAttributes)
111
+ nameStyles: r.nameStyles,
112
+ buttonStyles: r.buttonStyles,
113
+ priceStyles: r.priceStyles,
114
+ originalPriceStyles: r.originalPriceStyles,
115
+ quantityStyles: r.quantityStyles,
116
+ nodeConfig: k(r.configBlockAttributes)
113
117
  }), l = this.parser.parseFromString(
114
118
  `<table><tbody><tr>${i}</tr></tbody></table>`,
115
119
  "text/html"
116
120
  ).querySelector("td");
117
121
  if (l && c.parentNode) {
118
- const s = P(o.configBlockAttributes);
119
- l.setAttribute("esd-ext-config", JSON.stringify(s)), l.setAttribute("data-type", s.type);
122
+ const _ = k(r.configBlockAttributes);
123
+ l.setAttribute("esd-ext-config", JSON.stringify(_)), l.setAttribute("data-type", _.type);
120
124
  const p = l.querySelector("esd-config-block");
121
125
  p && p.remove(), c.parentNode.replaceChild(l, c);
122
126
  }
123
- }), this.backfillV2ProductTdAttributes(a.documentElement.outerHTML));
127
+ }), this.backfillV2ProductTdAttributes(D(u.documentElement.outerHTML)));
124
128
  } catch (e) {
125
129
  return console.error("ItemsBlockMigrator failed:", e), t;
126
130
  }
@@ -133,11 +137,11 @@ class z {
133
137
  */
134
138
  extractConfiguration(t) {
135
139
  var C;
136
- const e = D(
137
- this.readSelfOrDescendantAttribute(t, "data-type") || U(t)
138
- ), a = this.readSelfOrDescendantAttribute(t, "data-number") || "1", r = parseInt(a) - 1, u = h[e], c = ((C = u == null ? void 0 : u[r]) == null ? void 0 : C.value) || u[0].value, o = this.extractConfigBlockAttributes(t, e, a);
139
- this.applyDomFallbacks(t, o);
140
- const i = t.querySelector('[product-attr="price"]'), d = 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", f = t.querySelector('a[product-attr="name"]'), y = (f == null ? void 0 : f.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, k = (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, q = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), w = (E == null ? void 0 : E.getAttribute("style")) || void 0;
140
+ const e = w(
141
+ this.readSelfOrDescendantAttribute(t, "data-type") || W(t)
142
+ ), u = this.readSelfOrDescendantAttribute(t, "data-number") || "1", o = parseInt(u) - 1, a = h[e], c = ((C = a == null ? void 0 : a[o]) == null ? void 0 : C.value) || a[0].value, r = this.extractConfigBlockAttributes(t, e, u);
143
+ this.applyDomFallbacks(t, r);
144
+ const i = t.querySelector('[product-attr="price"]'), d = r["data-product_price_control_currency_symbol"], l = r["data-product_price_currency_location"] || "0", _ = r["data-product_price_control_formated"], p = _ !== "false" && _ !== "0", S = r["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", g = t.querySelector('a[product-attr="name"]'), b = (g == null ? void 0 : g.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (f == null ? void 0 : f.getAttribute("style")) || void 0, q = (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, R = (A == null ? void 0 : A.getAttribute("style")) || void 0, T = t.querySelector('[product-attr="quantity"]'), B = (T == null ? void 0 : T.getAttribute("style")) || void 0;
141
145
  return {
142
146
  orientation: S,
143
147
  itemsType: e,
@@ -145,12 +149,12 @@ class z {
145
149
  currencySymbol: d,
146
150
  currencyLocation: l,
147
151
  formattedPrice: p,
148
- configBlockAttributes: o,
149
- nameStyles: y,
152
+ configBlockAttributes: r,
153
+ nameStyles: b,
150
154
  buttonStyles: I,
151
- priceStyles: k,
152
- originalPriceStyles: q,
153
- quantityStyles: w
155
+ priceStyles: q,
156
+ originalPriceStyles: R,
157
+ quantityStyles: B
154
158
  };
155
159
  }
156
160
  /**
@@ -161,8 +165,8 @@ class z {
161
165
  * card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
162
166
  */
163
167
  applyDomFallbacks(t, e) {
164
- var S, f;
165
- const a = t.querySelector("esd-config-block"), r = (...y) => !a || y.every((g) => !(a.getAttribute(g) ?? "").trim());
168
+ var S, g;
169
+ const u = t.querySelector("esd-config-block"), o = (...b) => !u || b.every((f) => !(u.getAttribute(f) ?? "").trim());
166
170
  Object.entries({
167
171
  image: '[product-attr="imageSrc"]',
168
172
  name: '[product-attr="name"]',
@@ -170,18 +174,18 @@ class z {
170
174
  original_price: '[product-attr="originalPrice"], p.original-price',
171
175
  quantity: '[product-attr="quantity"]',
172
176
  button: '[product-attr="button"]'
173
- }).forEach(([y, g]) => {
174
- const I = `data-product_${y}_control_enabled`;
175
- r(I) && (e[I] = t.querySelector(g) ? "true" : "false");
176
- }), r("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
177
- const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), o = (S = c == null ? void 0 : c.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
178
- o && r("data-product_button_control_label") && (e["data-product_button_control_label"] = o);
177
+ }).forEach(([b, f]) => {
178
+ const I = `data-product_${b}_control_enabled`;
179
+ o(I) && (e[I] = t.querySelector(f) ? "true" : "false");
180
+ }), o("data-card_orientation_control_value") && (e["data-card_orientation_control_value"] = t.querySelector('[colspan="2"]') ? "vertical" : "horizontal");
181
+ const c = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), r = (S = c == null ? void 0 : c.textContent) == null ? void 0 : S.replace(/\s+/g, " ").trim();
182
+ r && o("data-product_button_control_label") && (e["data-product_button_control_label"] = r);
179
183
  const i = (c == null ? void 0 : c.getAttribute("style")) || "";
180
- 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");
181
- const d = t.querySelector('[product-attr="imageSrc"]'), l = d ? this.readImageSize(d) : 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);
182
- 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);
183
- const T = ((f = t.querySelector('[product-attr="name"]')) == null ? void 0 : f.getAttribute("style")) || "";
184
- r("data-product_name_control_trim") && /white-space:\s*normal/.test(T) && (e["data-product_name_control_trim"] = "0");
184
+ o("data-product_button_control_atw") && /display:\s*inline/.test(i) && !/(?:^|;)\s*width\s*:\s*100%/.test(i) && (e["data-product_button_control_atw"] = "false");
185
+ const d = t.querySelector('[product-attr="imageSrc"]'), l = d ? this.readImageSize(d) : null, _ = (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);
186
+ _ && o("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = _), p && o("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = p), this.applyPriceDomFallbacks(t, e, o);
187
+ const E = ((g = t.querySelector('[product-attr="name"]')) == null ? void 0 : g.getAttribute("style")) || "";
188
+ o("data-product_name_control_trim") && /white-space:\s*normal/.test(E) && (e["data-product_name_control_trim"] = "0");
185
189
  }
186
190
  /**
187
191
  * Carries the price cell's own currency/format attributes into the config attributes when
@@ -190,22 +194,22 @@ class z {
190
194
  * ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
191
195
  * the default back over the real value.
192
196
  */
193
- applyPriceDomFallbacks(t, e, a) {
197
+ applyPriceDomFallbacks(t, e, u) {
194
198
  var d;
195
- const r = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
196
- if (!r)
199
+ const o = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
200
+ if (!o)
197
201
  return;
198
- const u = (d = r.getAttribute("data-currency_symbol")) == null ? void 0 : d.trim();
199
- u && a("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = u);
200
- const c = r.getAttribute("data-curency");
201
- if (c && a("data-product_price_currency_location", "data-product_price_control_curency")) {
202
+ const a = (d = o.getAttribute("data-currency_symbol")) == null ? void 0 : d.trim();
203
+ a && u("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = a);
204
+ const c = o.getAttribute("data-curency");
205
+ if (c && u("data-product_price_currency_location", "data-product_price_control_curency")) {
202
206
  const l = c === "after" ? "1" : "0";
203
207
  e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
204
208
  }
205
- const o = r.getAttribute("data-formated");
206
- o && a("data-product_price_control_formated") && (e["data-product_price_control_formated"] = o);
207
- const i = r.getAttribute("data-single_price");
208
- i && a("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
209
+ const r = o.getAttribute("data-formated");
210
+ r && u("data-product_price_control_formated") && (e["data-product_price_control_formated"] = r);
211
+ const i = o.getAttribute("data-single_price");
212
+ i && u("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = i);
209
213
  }
210
214
  /**
211
215
  * Reads an attribute from the block element itself before falling back to a descendant.
@@ -213,8 +217,8 @@ class z {
213
217
  * esd-config-block; when an author deletes the config block only the td's copy survives.
214
218
  */
215
219
  readSelfOrDescendantAttribute(t, e) {
216
- var a;
217
- return t.getAttribute(e) || ((a = t.querySelector(`[${e}]`)) == null ? void 0 : a.getAttribute(e)) || null;
220
+ var u;
221
+ return t.getAttribute(e) || ((u = t.querySelector(`[${e}]`)) == null ? void 0 : u.getAttribute(e)) || null;
218
222
  }
219
223
  /**
220
224
  * Reads the product image's pixel size — `width`/`height` attributes first, then px values
@@ -235,14 +239,14 @@ class z {
235
239
  */
236
240
  readImageDimension(t, e) {
237
241
  var d;
238
- const a = (l) => {
239
- const s = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = s ? Math.floor(parseFloat(s[1])) : 0;
242
+ const u = (l) => {
243
+ const _ = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = _ ? Math.floor(parseFloat(_[1])) : 0;
240
244
  return p > 0 ? String(p) : null;
241
- }, r = a((d = t.getAttribute(e)) == null ? void 0 : d.trim());
242
- if (r)
243
- return r;
244
- const u = t.getAttribute("style") || "", c = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), o = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = u.match(c) || u.match(o);
245
- return a(i == null ? void 0 : i[1]);
245
+ }, o = u((d = t.getAttribute(e)) == null ? void 0 : d.trim());
246
+ if (o)
247
+ return o;
248
+ const a = t.getAttribute("style") || "", c = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), r = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), i = a.match(c) || a.match(r);
249
+ return u(i == null ? void 0 : i[1]);
246
250
  }
247
251
  /**
248
252
  * Extracts all data-* attributes from the esd-config-block element
@@ -251,27 +255,27 @@ class z {
251
255
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
252
256
  * @param itemNumber - The item number (1-based index)
253
257
  */
254
- extractConfigBlockAttributes(t, e, a) {
255
- const r = t.querySelector("esd-config-block"), u = {};
256
- if (r) {
257
- if (Array.from(r.attributes).forEach((o) => {
258
- o.name.startsWith("data-") && (u[o.name] = o.value);
259
- }), u["data-cart_items_select_control_value"]) {
260
- const o = u["data-cart_items_select_control_value"];
261
- if (/^\d+$/.test(o)) {
262
- const i = parseInt(o) - 1, d = h[e];
263
- d && d[i] && (u["data-cart_items_select_control_value"] = d[i].value);
258
+ extractConfigBlockAttributes(t, e, u) {
259
+ const o = t.querySelector("esd-config-block"), a = {};
260
+ if (o) {
261
+ if (Array.from(o.attributes).forEach((r) => {
262
+ r.name.startsWith("data-") && (a[r.name] = r.value);
263
+ }), a["data-cart_items_select_control_value"]) {
264
+ const r = a["data-cart_items_select_control_value"];
265
+ if (/^\d+$/.test(r)) {
266
+ const i = parseInt(r) - 1, d = h[e];
267
+ d && d[i] && (a["data-cart_items_select_control_value"] = d[i].value);
264
268
  }
265
269
  }
266
- if (u["data-product_price_control_curency"]) {
267
- const o = u["data-product_price_control_curency"];
268
- let i = o;
269
- o === "before" ? i = "0" : o === "after" && (i = "1"), u["data-product_price_control_curency"] = i, u["data-product_price_currency_location"] = i;
270
+ if (a["data-product_price_control_curency"]) {
271
+ const r = a["data-product_price_control_curency"];
272
+ let i = r;
273
+ r === "before" ? i = "0" : r === "after" && (i = "1"), a["data-product_price_control_curency"] = i, a["data-product_price_currency_location"] = i;
270
274
  }
271
- (!u["data-product_price_control_currency_symbol"] || u["data-product_price_control_currency_symbol"].trim() === "") && (u["data-product_price_control_currency_symbol"] = "USD");
275
+ (!a["data-product_price_control_currency_symbol"] || a["data-product_price_control_currency_symbol"].trim() === "") && (a["data-product_price_control_currency_symbol"] = "USD");
272
276
  }
273
- const c = { ...this.getDefaultConfigBlockAttributes(), ...u };
274
- return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = Y(e, a), c["data-product_button_link"] = W(e, a), c;
277
+ const c = { ...this.getDefaultConfigBlockAttributes(), ...a };
278
+ return c["data-type"] = e, c["data-source"] = e, c["data-product_image_link"] = z(e, u), c["data-product_button_link"] = G(e, u), c;
275
279
  }
276
280
  /**
277
281
  * Returns default esd-config-block attributes based on the old template structure
@@ -345,29 +349,29 @@ class z {
345
349
  backfillV2ProductTdAttributes(t) {
346
350
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
347
351
  return t;
348
- const e = this.parser.parseFromString(H(t), "text/html");
349
- let a = !1;
350
- return e.querySelectorAll(".ins-product-td").forEach((r) => {
351
- r.hasAttribute("width") && (r.removeAttribute("width"), a = !0), r.classList.contains("esd-container-frame") && (r.classList.remove("esd-container-frame"), a = !0), r.querySelectorAll("table.ins-product-wrapper").forEach((d) => {
352
- d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), a = !0);
352
+ const e = this.parser.parseFromString(P(t), "text/html");
353
+ let u = !1;
354
+ return e.querySelectorAll(".ins-product-td").forEach((o) => {
355
+ o.hasAttribute("width") && (o.removeAttribute("width"), u = !0), o.classList.contains("esd-container-frame") && (o.classList.remove("esd-container-frame"), u = !0), o.querySelectorAll("table.ins-product-wrapper").forEach((d) => {
356
+ d.hasAttribute("width") && d.getAttribute("width") !== "100%" && (d.setAttribute("width", "100%"), u = !0);
353
357
  const l = d.getAttribute("style");
354
- l && L(l) && (d.setAttribute("style", x(l)), d.setAttribute("width", "100%"), a = !0);
358
+ l && V(l) && (d.setAttribute("style", O(l)), d.setAttribute("width", "100%"), u = !0);
355
359
  });
356
- const u = r.getAttribute("esd-ext-config");
360
+ const a = o.getAttribute("esd-ext-config");
357
361
  let c = null;
358
362
  try {
359
- c = u ? JSON.parse(u) : null;
363
+ c = a ? JSON.parse(a) : null;
360
364
  } catch {
361
365
  }
362
- if (!c || (!r.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (r.setAttribute("data-nodup", String(c.priceHideDiscount)), a = !0), r.getAttribute("data-type")))
366
+ if (!c || (!o.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (o.setAttribute("data-nodup", String(c.priceHideDiscount)), u = !0), o.getAttribute("data-type")))
363
367
  return;
364
- const o = c.type || c.source;
365
- if (!o)
368
+ const r = c.type || c.source;
369
+ if (!r)
366
370
  return;
367
- r.setAttribute("data-type", o), a = !0;
371
+ o.setAttribute("data-type", r), u = !0;
368
372
  const i = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
369
- i && r.getAttribute("data-number") !== i[1] && r.setAttribute("data-number", i[1]);
370
- }), a ? $(e.documentElement.outerHTML) : t;
373
+ i && o.getAttribute("data-number") !== i[1] && o.setAttribute("data-number", i[1]);
374
+ }), u ? D(e.documentElement.outerHTML) : t;
371
375
  }
372
376
  /**
373
377
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -378,32 +382,28 @@ class z {
378
382
  return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
379
383
  }
380
384
  /**
381
- * Removes Jinja2 conditional statements from HTML
382
- * Handles all items block types:
383
- * - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
384
- * - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
385
- * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
386
- *
387
- * IMPORTANT: Preserves the esd-custom-display-conditions attribute on <body> which
388
- * contains display condition Jinja scripts that should NOT be removed.
385
+ * Removes each Items guard opener together with the endif that closes it, and no other tag.
386
+ * Liquid inside esd-custom-display-condition(s) attribute values is skipped.
389
387
  */
390
388
  removeJinjaConditionals(t) {
391
- const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", a = t.match(/esd-custom-display-conditions="[^"]*"/);
392
- let r = a ? t.replace(a[0], e) : t;
393
- return r = r.replace(
394
- /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
395
- ""
396
- ), r = r.replace(
397
- /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
398
- ""
399
- ), r = r.replace(/\{%\s*endif\s*%\}/g, ""), a && (r = r.replace(e, a[0])), r = r.replace(/\n\s*\n\s*\n/g, `
389
+ const e = [...t.matchAll(N)].map((a) => ({ start: a.index, end: a.index + a[0].length })), u = [];
390
+ let o = t.replace($, (a, c, r) => {
391
+ if (e.some(({ start: i, end: d }) => r >= i && r < d))
392
+ return a;
393
+ if (c === "if") {
394
+ const i = F.some((d) => d.test(a));
395
+ return u.push(i), i ? "" : a;
396
+ }
397
+ return c === "endif" && u.pop() ? "" : a;
398
+ });
399
+ return o = o.replace(/\n\s*\n\s*\n/g, `
400
400
 
401
- `), r;
401
+ `), o;
402
402
  }
403
403
  }
404
- function X(n) {
405
- return new z().migrate(n);
404
+ function rt(n) {
405
+ return new J().migrate(n);
406
406
  }
407
407
  export {
408
- X as migrateItemsBlock
408
+ rt as migrateItemsBlock
409
409
  };
@@ -1,9 +1,9 @@
1
- const o = "3.27.0-beta.8bef749", s = { stripo: { version: "2.83.1" } }, e = {
1
+ const o = "3.27.0-beta.8f596fb", s = { stripo: { version: "2.83.1" } }, t = {
2
2
  version: o,
3
3
  guido: s
4
4
  };
5
5
  export {
6
- e as default,
6
+ t as default,
7
7
  s as guido,
8
8
  o as version
9
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.27.0-beta.8bef749",
3
+ "version": "3.27.0-beta.8f596fb",
4
4
  "description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
5
5
  "main": "./dist/guido.umd.cjs",
6
6
  "module": "./dist/library.js",