@useinsider/guido 3.27.1-beta.07db3f3 → 3.27.1-beta.08606af

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,130 +1,165 @@
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() {
1
+ var O = Object.defineProperty;
2
+ var x = (r, t, e) => t in r ? O(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var w = (r, t, e) => x(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { BLOCK_ID as V } from "../../extensions/Blocks/Items/block.js";
5
+ import { hasZeroWidthDeclaration as H, withoutZeroWidth as N } from "../../extensions/Blocks/Items/constants/cardWidth.js";
6
+ import { ItemInCartOptions as E, DefaultConfigValues as S, SETTINGS_ENUMS as p } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
7
+ import { getDefaultTemplate as W } from "../../extensions/Blocks/Items/template.js";
8
+ import { useTemplateStore as $ } from "../../stores/template.js";
9
+ import { protectLiquid as F, restoreLiquid as U } from "../../utils/liquidProtection.js";
10
+ const D = "table.es-left, table.es-right", Y = [
11
+ ".es-hidden",
12
+ ".ins-product-td",
13
+ "td.esd-cart-items-block",
14
+ "td.esd-browsed-items-block",
15
+ "td.esd-purchased-items-block"
16
+ ].join(", ");
17
+ function h(r) {
18
+ const t = Number(r.getAttribute("width"));
19
+ return Number.isFinite(t) && t > 0 ? t : 0;
20
+ }
21
+ function P(r) {
22
+ return Array.from(r.children).filter((t) => t.tagName === "TBODY").flatMap((t) => Array.from(t.children)).flatMap((t) => Array.from(t.children).filter((e) => e.tagName === "TD"));
23
+ }
24
+ function z(r) {
25
+ var e, i;
26
+ let t = (e = r.parentElement) == null ? void 0 : e.closest("table");
27
+ for (; t; ) {
28
+ const o = h(t);
29
+ if (o)
30
+ return o;
31
+ t = (i = t.parentElement) == null ? void 0 : i.closest("table");
32
+ }
33
+ return 0;
34
+ }
35
+ function k(r) {
36
+ var a, c;
37
+ const t = (c = (a = r.parentElement) == null ? void 0 : a.parentElement) == null ? void 0 : c.parentElement, e = t == null ? void 0 : t.parentElement;
38
+ if (!t || !e || !t.matches(D) || !h(r))
39
+ return !1;
40
+ const i = P(t), o = i.some((l) => !l.matches(Y) && h(l));
41
+ if (!i.includes(r) || o)
42
+ return !1;
43
+ const u = Array.from(e.children).filter((l) => l.matches(D)).reduce((l, d) => l + Math.max(0, ...P(d).map(h)), 0), n = z(e);
44
+ return n > 0 && u <= n;
45
+ }
46
+ function j() {
15
47
  return String(Date.now() + Math.floor(Math.random() * 1e3));
16
48
  }
17
- function w(n) {
18
- return n ? {
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;
49
+ function R(r) {
50
+ return r ? {
51
+ CartItems: p.ITEMS_TYPE.CART_ITEMS,
52
+ BrowsedItems: p.ITEMS_TYPE.BROWSED_ITEMS,
53
+ PurchasedItems: p.ITEMS_TYPE.PURCHASED_ITEMS,
54
+ CART_ITEMS: p.ITEMS_TYPE.CART_ITEMS,
55
+ BROWSED_ITEMS: p.ITEMS_TYPE.BROWSED_ITEMS,
56
+ PURCHASED_ITEMS: p.ITEMS_TYPE.PURCHASED_ITEMS
57
+ }[r] || p.ITEMS_TYPE.CART_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
26
58
  }
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;
59
+ function J(r) {
60
+ return r.classList.contains("esd-browsed-items-block") ? p.ITEMS_TYPE.BROWSED_ITEMS : r.classList.contains("esd-purchased-items-block") ? p.ITEMS_TYPE.PURCHASED_ITEMS : p.ITEMS_TYPE.CART_ITEMS;
29
61
  }
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;
34
- if (c && !c.includes("{{") && /^\d+$/.test(c)) {
35
- const i = parseInt(c) - 1, d = h[o];
36
- d && d[i] && (c = d[i].value);
62
+ function q(r) {
63
+ var a;
64
+ const t = (c, l) => c == null ? l : c === "1" || c === "true", e = (c, l) => c || l, i = r["data-type"] || r["data-source"], o = R(i), u = E[o];
65
+ let n = r["data-cart_items_select_control_value"] || ((a = u == null ? void 0 : u[0]) == null ? void 0 : a.value) || S.cartItemsSelectControlValue;
66
+ if (n && !n.includes("{{") && /^\d+$/.test(n)) {
67
+ const c = parseInt(n) - 1, l = E[o];
68
+ l && l[c] && (n = l[c].value);
37
69
  }
38
70
  return {
39
71
  initialized: !0,
40
- blockInstanceId: e(n["data-block-instance-id"], Y()),
72
+ blockInstanceId: e(r["data-block-instance-id"], j()),
41
73
  source: o,
42
74
  type: o,
43
- itemsSelectValue: c,
44
- orientation: n["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
45
- nameTrimming: t(n["data-product_name_control_trim"], !0),
46
- priceHideDiscount: t(n["data-product_price_control_nodup"], !0),
47
- priceFormatted: t(n["data-product_price_control_formated"], !0),
48
- priceSinglePrice: t(n["data-product_price_control_single_price"], !1),
75
+ itemsSelectValue: n,
76
+ orientation: r["data-card_orientation_control_value"] || p.ORIENTATION.VERTICAL,
77
+ nameTrimming: t(r["data-product_name_control_trim"], !0),
78
+ priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
79
+ priceFormatted: t(r["data-product_price_control_formated"], !0),
80
+ priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
49
81
  priceCurrencySymbol: e(
50
- n["data-product_price_control_currency_symbol"],
51
- y.productPriceCurrencySymbolControlValue
82
+ r["data-product_price_control_currency_symbol"],
83
+ S.productPriceCurrencySymbolControlValue
52
84
  ),
53
85
  priceCurrencyLocation: e(
54
- n["data-product_price_currency_location"],
55
- y.productPriceCurrencyLocationControlValue
86
+ r["data-product_price_currency_location"],
87
+ S.productPriceCurrencyLocationControlValue
56
88
  ),
57
- priceOrientation: n["data-product_original_price_control_orientation"] || "horizontal",
58
- quantityControlEnabled: t(n["data-product_quantity_control_enabled"], !0),
59
- buttonLink: e(n["data-product_button_link"], y.productButtonLinkControlValue),
60
- imageLink: e(n["data-product_image_link"], y.productImageLinkControlValue),
61
- buttonLabel: e(n["data-product_button_control_label"], "Buy"),
62
- buttonFullWidth: t(n["data-product_button_control_atw"], !0),
63
- imageVisible: t(n["data-product_image_control_enabled"], !0),
64
- nameVisible: t(n["data-product_name_control_enabled"], !0),
65
- quantityVisible: t(n["data-product_quantity_control_enabled"], !0),
66
- priceVisible: t(n["data-product_price_control_enabled"], !0),
67
- originalPriceVisible: t(n["data-product_original_price_control_enabled"], !0),
68
- buttonVisible: t(n["data-product_button_control_enabled"], !0)
89
+ priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
90
+ quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
91
+ buttonLink: e(r["data-product_button_link"], S.productButtonLinkControlValue),
92
+ imageLink: e(r["data-product_image_link"], S.productImageLinkControlValue),
93
+ buttonLabel: e(r["data-product_button_control_label"], "Buy"),
94
+ buttonFullWidth: t(r["data-product_button_control_atw"], !0),
95
+ imageVisible: t(r["data-product_image_control_enabled"], !0),
96
+ nameVisible: t(r["data-product_name_control_enabled"], !0),
97
+ quantityVisible: t(r["data-product_quantity_control_enabled"], !0),
98
+ priceVisible: t(r["data-product_price_control_enabled"], !0),
99
+ originalPriceVisible: t(r["data-product_original_price_control_enabled"], !0),
100
+ buttonVisible: t(r["data-product_button_control_enabled"], !0)
69
101
  };
70
102
  }
71
- function z(n, t) {
103
+ function Z(r, t) {
72
104
  const e = {
73
105
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
74
106
  BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
75
107
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
76
108
  };
77
- return e[n] || e.CART_ITEMS;
109
+ return e[r] || e.CART_ITEMS;
78
110
  }
79
- function G(n, t) {
111
+ function G(r, t) {
80
112
  const e = {
81
113
  CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
82
114
  BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
83
115
  PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
84
116
  };
85
- return e[n] || e.CART_ITEMS;
117
+ return e[r] || e.CART_ITEMS;
86
118
  }
87
- class J {
119
+ class K {
88
120
  constructor() {
89
- M(this, "parser");
121
+ w(this, "parser");
90
122
  this.parser = new DOMParser();
91
123
  }
92
124
  migrate(t) {
93
125
  try {
94
126
  if (!this.containsItemsBlock(t))
95
127
  return this.backfillV2ProductTdAttributes(t);
96
- const e = this.removeJinjaConditionals(t), u = this.parser.parseFromString(P(e), "text/html"), o = u.querySelectorAll(
128
+ const e = this.removeJinjaConditionals(t), i = this.parser.parseFromString(e, "text/html"), o = i.querySelectorAll(
97
129
  "td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
98
130
  );
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,
131
+ if ($().$patch((a) => {
132
+ a.migrations = { ...a.migrations, [V]: o.length };
133
+ }), o.length === 0)
134
+ return console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), this.backfillV2ProductTdAttributes(e);
135
+ const n = new Set(Array.from(o).filter(k));
136
+ return o.forEach((a) => {
137
+ const c = this.extractConfiguration(a), l = W({
138
+ orientation: c.orientation,
139
+ itemsType: c.itemsType,
140
+ itemId: c.itemId,
141
+ currencySymbol: c.currencySymbol,
142
+ currencyLocation: c.currencyLocation,
143
+ formattedPrice: c.formattedPrice,
144
+ configBlockAttributes: c.configBlockAttributes,
110
145
  migrate: !0,
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)
117
- }), l = this.parser.parseFromString(
118
- `<table><tbody><tr>${i}</tr></tbody></table>`,
146
+ nameStyles: c.nameStyles,
147
+ buttonStyles: c.buttonStyles,
148
+ priceStyles: c.priceStyles,
149
+ originalPriceStyles: c.originalPriceStyles,
150
+ quantityStyles: c.quantityStyles,
151
+ nodeConfig: q(c.configBlockAttributes)
152
+ }), s = this.parser.parseFromString(
153
+ `<table><tbody><tr>${l}</tr></tbody></table>`,
119
154
  "text/html"
120
155
  ).querySelector("td");
121
- if (l && c.parentNode) {
122
- const _ = k(r.configBlockAttributes);
123
- l.setAttribute("esd-ext-config", JSON.stringify(_)), l.setAttribute("data-type", _.type);
124
- const p = l.querySelector("esd-config-block");
125
- p && p.remove(), c.parentNode.replaceChild(l, c);
156
+ if (s && a.parentNode) {
157
+ const _ = q(c.configBlockAttributes);
158
+ s.setAttribute("esd-ext-config", JSON.stringify(_)), s.setAttribute("data-type", _.type);
159
+ const m = s.querySelector("esd-config-block");
160
+ m && m.remove(), n.has(a) && (s.setAttribute("width", String(h(a))), s.classList.add("esd-container-frame")), a.parentNode.replaceChild(s, a);
126
161
  }
127
- }), this.backfillV2ProductTdAttributes(D(u.documentElement.outerHTML)));
162
+ }), this.backfillV2ProductTdAttributes(i.documentElement.outerHTML);
128
163
  } catch (e) {
129
164
  return console.error("ItemsBlockMigrator failed:", e), t;
130
165
  }
@@ -136,25 +171,25 @@ class J {
136
171
  * - UI styles from product elements (name, price, button, quantity, etc.)
137
172
  */
138
173
  extractConfiguration(t) {
139
- var C;
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;
174
+ var M;
175
+ const e = R(
176
+ this.readSelfOrDescendantAttribute(t, "data-type") || J(t)
177
+ ), i = this.readSelfOrDescendantAttribute(t, "data-number") || "1", o = parseInt(i) - 1, u = E[e], n = ((M = u == null ? void 0 : u[o]) == null ? void 0 : M.value) || u[0].value, a = this.extractConfigBlockAttributes(t, e, i);
178
+ this.applyDomFallbacks(t, a);
179
+ const c = t.querySelector('[product-attr="price"]'), l = a["data-product_price_control_currency_symbol"], d = a["data-product_price_currency_location"] || "0", s = a["data-product_price_control_formated"], _ = s !== "false" && s !== "0", A = a["data-card_orientation_control_value"] === "horizontal" ? "horizontal" : "vertical", g = t.querySelector('a[product-attr="name"]'), y = (g == null ? void 0 : g.getAttribute("style")) || void 0, b = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), I = (b == null ? void 0 : b.getAttribute("style")) || void 0, B = (c == null ? void 0 : c.getAttribute("style")) || void 0, f = t.querySelector("p.original-price") ?? t.querySelector('[product-attr="originalPrice"]'), T = f != null && f.getAttribute("style") ? f : (f == null ? void 0 : f.closest("p")) ?? f, L = (T == null ? void 0 : T.getAttribute("style")) || void 0, C = t.querySelector('[product-attr="quantity"]'), v = (C == null ? void 0 : C.getAttribute("style")) || void 0;
145
180
  return {
146
- orientation: S,
181
+ orientation: A,
147
182
  itemsType: e,
148
- itemId: c,
149
- currencySymbol: d,
150
- currencyLocation: l,
151
- formattedPrice: p,
152
- configBlockAttributes: r,
153
- nameStyles: b,
183
+ itemId: n,
184
+ currencySymbol: l,
185
+ currencyLocation: d,
186
+ formattedPrice: _,
187
+ configBlockAttributes: a,
188
+ nameStyles: y,
154
189
  buttonStyles: I,
155
- priceStyles: q,
156
- originalPriceStyles: R,
157
- quantityStyles: B
190
+ priceStyles: B,
191
+ originalPriceStyles: L,
192
+ quantityStyles: v
158
193
  };
159
194
  }
160
195
  /**
@@ -165,8 +200,8 @@ class J {
165
200
  * card migrates with the boilerplate defaults: caption "Buy", USD, full-width button.
166
201
  */
167
202
  applyDomFallbacks(t, e) {
168
- var S, g;
169
- const u = t.querySelector("esd-config-block"), o = (...b) => !u || b.every((f) => !(u.getAttribute(f) ?? "").trim());
203
+ var A, g;
204
+ const i = t.querySelector("esd-config-block"), o = (...y) => !i || y.every((b) => !(i.getAttribute(b) ?? "").trim());
170
205
  Object.entries({
171
206
  image: '[product-attr="imageSrc"]',
172
207
  name: '[product-attr="name"]',
@@ -174,18 +209,18 @@ class J {
174
209
  original_price: '[product-attr="originalPrice"], p.original-price',
175
210
  quantity: '[product-attr="quantity"]',
176
211
  button: '[product-attr="button"]'
177
- }).forEach(([b, f]) => {
178
- const I = `data-product_${b}_control_enabled`;
179
- o(I) && (e[I] = t.querySelector(f) ? "true" : "false");
212
+ }).forEach(([y, b]) => {
213
+ const I = `data-product_${y}_control_enabled`;
214
+ o(I) && (e[I] = t.querySelector(b) ? "true" : "false");
180
215
  }), 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);
183
- const i = (c == null ? void 0 : c.getAttribute("style")) || "";
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");
216
+ const n = t.querySelector('a[product-attr="button"]') ?? t.querySelector('[product-attr="button"]'), a = (A = n == null ? void 0 : n.textContent) == null ? void 0 : A.replace(/\s+/g, " ").trim();
217
+ a && o("data-product_button_control_label") && (e["data-product_button_control_label"] = a);
218
+ const c = (n == null ? void 0 : n.getAttribute("style")) || "";
219
+ o("data-product_button_control_atw") && /display:\s*inline/.test(c) && !/(?:^|;)\s*width\s*:\s*100%/.test(c) && (e["data-product_button_control_atw"] = "false");
220
+ const l = t.querySelector('[product-attr="imageSrc"]'), d = l ? this.readImageSize(l) : null, s = (d == null ? void 0 : d.height) ?? (d == null ? void 0 : d.width), _ = (d == null ? void 0 : d.width) ?? (d == null ? void 0 : d.height);
221
+ s && o("data-product_image_control_image-height") && (e["data-product_image_control_image-height"] = s), _ && o("data-product_image_control_image-width") && (e["data-product_image_control_image-width"] = _), this.applyPriceDomFallbacks(t, e, o);
222
+ const m = ((g = t.querySelector('[product-attr="name"]')) == null ? void 0 : g.getAttribute("style")) || "";
223
+ o("data-product_name_control_trim") && /white-space:\s*normal/.test(m) && (e["data-product_name_control_trim"] = "0");
189
224
  }
190
225
  /**
191
226
  * Carries the price cell's own currency/format attributes into the config attributes when
@@ -194,22 +229,22 @@ class J {
194
229
  * ₺ but reporting USD/before to the settings panel, and the first unrelated price edit wrote
195
230
  * the default back over the real value.
196
231
  */
197
- applyPriceDomFallbacks(t, e, u) {
198
- var d;
232
+ applyPriceDomFallbacks(t, e, i) {
233
+ var l;
199
234
  const o = t.querySelector('[product-attr="price"]') ?? t.querySelector('[product-attr="originalPrice"]');
200
235
  if (!o)
201
236
  return;
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")) {
206
- const l = c === "after" ? "1" : "0";
207
- e["data-product_price_currency_location"] = l, e["data-product_price_control_curency"] = l;
237
+ const u = (l = o.getAttribute("data-currency_symbol")) == null ? void 0 : l.trim();
238
+ u && i("data-product_price_control_currency_symbol") && (e["data-product_price_control_currency_symbol"] = u);
239
+ const n = o.getAttribute("data-curency");
240
+ if (n && i("data-product_price_currency_location", "data-product_price_control_curency")) {
241
+ const d = n === "after" ? "1" : "0";
242
+ e["data-product_price_currency_location"] = d, e["data-product_price_control_curency"] = d;
208
243
  }
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);
244
+ const a = o.getAttribute("data-formated");
245
+ a && i("data-product_price_control_formated") && (e["data-product_price_control_formated"] = a);
246
+ const c = o.getAttribute("data-single_price");
247
+ c && i("data-product_price_control_single_price") && (e["data-product_price_control_single_price"] = c);
213
248
  }
214
249
  /**
215
250
  * Reads an attribute from the block element itself before falling back to a descendant.
@@ -217,8 +252,8 @@ class J {
217
252
  * esd-config-block; when an author deletes the config block only the td's copy survives.
218
253
  */
219
254
  readSelfOrDescendantAttribute(t, e) {
220
- var u;
221
- return t.getAttribute(e) || ((u = t.querySelector(`[${e}]`)) == null ? void 0 : u.getAttribute(e)) || null;
255
+ var i;
256
+ return t.getAttribute(e) || ((i = t.querySelector(`[${e}]`)) == null ? void 0 : i.getAttribute(e)) || null;
222
257
  }
223
258
  /**
224
259
  * Reads the product image's pixel size — `width`/`height` attributes first, then px values
@@ -238,15 +273,15 @@ class J {
238
273
  * to nothing, so only a positive integer counts as an answer.
239
274
  */
240
275
  readImageDimension(t, e) {
241
- var d;
242
- const u = (l) => {
243
- const _ = (l ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), p = _ ? Math.floor(parseFloat(_[1])) : 0;
244
- return p > 0 ? String(p) : null;
245
- }, o = u((d = t.getAttribute(e)) == null ? void 0 : d.trim());
276
+ var l;
277
+ const i = (d) => {
278
+ const s = (d ?? "").trim().match(/^(\d+(?:\.\d+)?)(?:px)?$/i), _ = s ? Math.floor(parseFloat(s[1])) : 0;
279
+ return _ > 0 ? String(_) : null;
280
+ }, o = i((l = t.getAttribute(e)) == null ? void 0 : l.trim());
246
281
  if (o)
247
282
  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]);
283
+ const u = t.getAttribute("style") || "", n = new RegExp(`(?:^|;)\\s*${e}:\\s*(\\d+(?:\\.\\d+)?)px`), a = new RegExp(`max-${e}:\\s*(\\d+(?:\\.\\d+)?)px`), c = u.match(n) || u.match(a);
284
+ return i(c == null ? void 0 : c[1]);
250
285
  }
251
286
  /**
252
287
  * Extracts all data-* attributes from the esd-config-block element
@@ -255,27 +290,27 @@ class J {
255
290
  * @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
256
291
  * @param itemNumber - The item number (1-based index)
257
292
  */
258
- extractConfigBlockAttributes(t, e, u) {
259
- const o = t.querySelector("esd-config-block"), a = {};
293
+ extractConfigBlockAttributes(t, e, i) {
294
+ const o = t.querySelector("esd-config-block"), u = {};
260
295
  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);
296
+ if (Array.from(o.attributes).forEach((a) => {
297
+ a.name.startsWith("data-") && (u[a.name] = a.value);
298
+ }), u["data-cart_items_select_control_value"]) {
299
+ const a = u["data-cart_items_select_control_value"];
300
+ if (/^\d+$/.test(a)) {
301
+ const c = parseInt(a) - 1, l = E[e];
302
+ l && l[c] && (u["data-cart_items_select_control_value"] = l[c].value);
268
303
  }
269
304
  }
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;
305
+ if (u["data-product_price_control_curency"]) {
306
+ const a = u["data-product_price_control_curency"];
307
+ let c = a;
308
+ a === "before" ? c = "0" : a === "after" && (c = "1"), u["data-product_price_control_curency"] = c, u["data-product_price_currency_location"] = c;
274
309
  }
275
- (!a["data-product_price_control_currency_symbol"] || a["data-product_price_control_currency_symbol"].trim() === "") && (a["data-product_price_control_currency_symbol"] = "USD");
310
+ (!u["data-product_price_control_currency_symbol"] || u["data-product_price_control_currency_symbol"].trim() === "") && (u["data-product_price_control_currency_symbol"] = "USD");
276
311
  }
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;
312
+ const n = { ...this.getDefaultConfigBlockAttributes(), ...u };
313
+ return n["data-type"] = e, n["data-source"] = e, n["data-product_image_link"] = Z(e, i), n["data-product_button_link"] = G(e, i), n;
279
314
  }
280
315
  /**
281
316
  * Returns default esd-config-block attributes based on the old template structure
@@ -342,6 +377,7 @@ class J {
342
377
  * no longer emits it; here we heal already-saved templates by removing it so the
343
378
  * cell inherits its column width. width="560" was only ever written alongside
344
379
  * esd-ext-config, so the guard below still catches every affected template.
380
+ * A cell that is its column's only width carrier keeps its width and frame.
345
381
  *
346
382
  * Only re-serializes when something actually changed, so healthy templates
347
383
  * (data-type present, no static width) pass through byte-for-byte.
@@ -349,29 +385,31 @@ class J {
349
385
  backfillV2ProductTdAttributes(t) {
350
386
  if (!t.includes("ins-product-td") || !t.includes("esd-ext-config"))
351
387
  return t;
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);
357
- const l = d.getAttribute("style");
358
- l && V(l) && (d.setAttribute("style", O(l)), d.setAttribute("width", "100%"), u = !0);
388
+ const e = this.parser.parseFromString(F(t), "text/html");
389
+ let i = !1;
390
+ const o = Array.from(e.querySelectorAll(".ins-product-td")), u = new Set(o.filter(k));
391
+ return o.forEach((n) => {
392
+ const a = u.has(n);
393
+ !a && n.hasAttribute("width") && (n.removeAttribute("width"), i = !0), !a && n.classList.contains("esd-container-frame") && (n.classList.remove("esd-container-frame"), i = !0), n.querySelectorAll("table.ins-product-wrapper").forEach((_) => {
394
+ !a && _.hasAttribute("width") && _.getAttribute("width") !== "100%" && (_.setAttribute("width", "100%"), i = !0);
395
+ const m = _.getAttribute("style");
396
+ m && H(m) && (_.setAttribute("style", N(m)), _.setAttribute("width", "100%"), i = !0);
359
397
  });
360
- const a = o.getAttribute("esd-ext-config");
361
- let c = null;
398
+ const c = n.getAttribute("esd-ext-config");
399
+ let l = null;
362
400
  try {
363
- c = a ? JSON.parse(a) : null;
401
+ l = c ? JSON.parse(c) : null;
364
402
  } catch {
365
403
  }
366
- if (!c || (!o.getAttribute("data-nodup") && typeof c.priceHideDiscount == "boolean" && (o.setAttribute("data-nodup", String(c.priceHideDiscount)), u = !0), o.getAttribute("data-type")))
404
+ if (!l || (!n.getAttribute("data-nodup") && typeof l.priceHideDiscount == "boolean" && (n.setAttribute("data-nodup", String(l.priceHideDiscount)), i = !0), n.getAttribute("data-type")))
367
405
  return;
368
- const r = c.type || c.source;
369
- if (!r)
406
+ const d = l.type || l.source;
407
+ if (!d)
370
408
  return;
371
- o.setAttribute("data-type", r), u = !0;
372
- const i = typeof c.itemsSelectValue == "string" ? c.itemsSelectValue.match(/\((\d+)\)/) : null;
373
- i && o.getAttribute("data-number") !== i[1] && o.setAttribute("data-number", i[1]);
374
- }), u ? D(e.documentElement.outerHTML) : t;
409
+ n.setAttribute("data-type", d), i = !0;
410
+ const s = typeof l.itemsSelectValue == "string" ? l.itemsSelectValue.match(/\((\d+)\)/) : null;
411
+ s && n.getAttribute("data-number") !== s[1] && n.setAttribute("data-number", s[1]);
412
+ }), i ? U(e.documentElement.outerHTML) : t;
375
413
  }
376
414
  /**
377
415
  * Fast check for the presence of any items block (cart / browsed / purchased)
@@ -382,28 +420,32 @@ class J {
382
420
  return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
383
421
  }
384
422
  /**
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.
423
+ * Removes Jinja2 conditional statements from HTML
424
+ * Handles all items block types:
425
+ * - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
426
+ * - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
427
+ * - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
428
+ *
429
+ * IMPORTANT: Preserves the esd-custom-display-conditions attribute on <body> which
430
+ * contains display condition Jinja scripts that should NOT be removed.
387
431
  */
388
432
  removeJinjaConditionals(t) {
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, `
433
+ const e = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", i = t.match(/esd-custom-display-conditions="[^"]*"/);
434
+ let o = i ? t.replace(i[0], e) : t;
435
+ return o = o.replace(
436
+ /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(&gt;|>)\s*\d+\s*%\}/g,
437
+ ""
438
+ ), o = o.replace(
439
+ /\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!&#61;|!=)\s*\1_originalprice_\d+\s*%\}/g,
440
+ ""
441
+ ), o = o.replace(/\{%\s*endif\s*%\}/g, ""), i && (o = o.replace(e, i[0])), o = o.replace(/\n\s*\n\s*\n/g, `
400
442
 
401
443
  `), o;
402
444
  }
403
445
  }
404
- function rt(n) {
405
- return new J().migrate(n);
446
+ function nt(r) {
447
+ return new K().migrate(r);
406
448
  }
407
449
  export {
408
- rt as migrateItemsBlock
450
+ nt as migrateItemsBlock
409
451
  };
@@ -1,4 +1,4 @@
1
- const o = "3.27.1-beta.07db3f3", s = { stripo: { version: "2.86.1" } }, t = {
1
+ const o = "3.27.1-beta.08606af", s = { stripo: { version: "2.86.1" } }, t = {
2
2
  version: o,
3
3
  guido: s
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.27.1-beta.07db3f3",
3
+ "version": "3.27.1-beta.08606af",
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",
@@ -61,7 +61,7 @@
61
61
  "dependencies": {
62
62
  "@stripoinc/ui-editor-extensions": "3.11.0",
63
63
  "@useinsider/design-system-organisms": "0.0.3-beta.d816f06",
64
- "@useinsider/design-system-vue": "2.5.0",
64
+ "@useinsider/design-system-vue": "2.7.0",
65
65
  "@vueuse/core": "11.3.0",
66
66
  "lodash-es": "4.17.21",
67
67
  "pinia": "2.3.1",