@useinsider/guido 3.6.0-beta.596b70e → 3.6.0-beta.5cbaa8f

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +12 -10
  2. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +32 -24
  3. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +40 -34
  4. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +338 -310
  5. package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
  6. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
  7. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +146 -117
  8. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -49
  9. package/dist/extensions/Blocks/Recommendation/templates/index.js +8 -9
  10. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +83 -110
  11. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -31
  12. package/dist/extensions/Blocks/Recommendation/templates/utils.js +54 -90
  13. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +19 -24
  14. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +16 -20
  15. package/dist/extensions/Blocks/Unsubscribe/block.js +122 -72
  16. package/dist/extensions/Blocks/controlFactories.js +133 -159
  17. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
  18. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
  19. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +47 -20
  20. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  21. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  22. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +2 -3
  23. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +11 -127
  24. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -15
  25. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +113 -0
  26. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +9 -20
  27. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +9 -0
  28. package/dist/src/extensions/Blocks/controlFactories.d.ts +1 -11
  29. package/package.json +1 -1
  30. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +0 -139
  31. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.test.d.ts +0 -1
  32. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.test.d.ts +0 -1
  33. package/dist/src/extensions/Blocks/Recommendation/templates/utils.test.d.ts +0 -1
  34. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +0 -44
  35. package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.test.d.ts +0 -1
  36. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.test.d.ts +0 -1
@@ -1,404 +1,432 @@
1
- import { ModificationDescription as S } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
1
+ import { ModificationDescription as p } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { RecommendationBlockId as m } from "../../constants/blockIds.js";
3
- import { CURRENCY_ATTR as p, MOBILE_CONTAINER_SELECTOR as w, DESKTOP_CONTAINER_SELECTOR as N, CONTAINER_SELECTOR as K, MOBILE_ROW_SELECTOR as _, ATTR_PRODUCT_ATTR as V } from "../../constants/selectors.js";
4
- import { RecommendationConfigService as b } from "../../services/configService.js";
5
- import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
6
- import { prepareProductRows as L } from "../../templates/index.js";
7
- import { captureAttributeStyleTemplates as x, captureCardBackgroundColor as D, captureCellBackgroundColors as U } from "../../utils/captureStyleTemplates.js";
8
- import { formatPrice as X } from "../../utils/priceFormatter.js";
9
- import { getDefaultProducts as B, sanitizeImageUrl as z, DEFAULT_CARD_COMPOSITION as M } from "../../templates/utils.js";
10
- const h = "recommendation-block-v2";
11
- function T(e) {
12
- if (!e)
3
+ import { CURRENCY_ATTR as y, MOBILE_CONTAINER_SELECTOR as q, MOBILE_ROW_SELECTOR as k, DESKTOP_CONTAINER_SELECTOR as P, CONTAINER_SELECTOR as v, ATTR_PRODUCT_ATTR as W } from "../../constants/selectors.js";
4
+ import { RecommendationConfigService as E } from "../../services/configService.js";
5
+ import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
6
+ import { prepareProductRows as _ } from "../../templates/index.js";
7
+ import { formatPrice as j } from "../../utils/priceFormatter.js";
8
+ import { isTdNode as F } from "../../utils/tagName.js";
9
+ import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as R, sanitizeImageUrl as V } from "../../templates/utils.js";
10
+ const M = "recommendation-block-v2";
11
+ function h(t) {
12
+ if (!t)
13
13
  return null;
14
- if ("getAttribute" in e) {
15
- const t = e.getAttribute("class");
16
- if (t && t.includes(h))
17
- return e;
14
+ if ("getAttribute" in t) {
15
+ const e = t.getAttribute("class");
16
+ if (e && e.includes(M))
17
+ return t;
18
18
  }
19
- return "querySelector" in e ? e.querySelector(`.${h}`) ?? null : null;
19
+ return "querySelector" in t ? t.querySelector(`.${M}`) ?? null : null;
20
20
  }
21
- function C(e) {
22
- const t = T(e);
23
- if (!t || !("getAttribute" in t))
21
+ function b(t) {
22
+ const e = h(t);
23
+ if (!e || !("getAttribute" in e))
24
24
  return "grid";
25
- const n = t.getAttribute("data-layout");
26
- return n === "list" || n === "horizontal" ? "list" : "grid";
25
+ const o = e.getAttribute("data-layout");
26
+ return o === "list" || o === "horizontal" ? "list" : "grid";
27
27
  }
28
- function $(e) {
29
- const t = T(e);
30
- if (!t || !("getAttribute" in t))
31
- return M;
32
- const n = t.getAttribute("data-card-composition");
33
- return n ? n.split(",").filter(Boolean) : M;
28
+ function x(t) {
29
+ const e = h(t);
30
+ if (!e || !("getAttribute" in e))
31
+ return R;
32
+ const o = e.getAttribute("data-card-composition");
33
+ return o ? o.split(",").filter(Boolean) : R;
34
34
  }
35
- function H(e) {
36
- if (!e || !("childNodes" in e))
35
+ function D(t) {
36
+ if (!t || !("childNodes" in t))
37
37
  return null;
38
- const t = e.childNodes(), n = t.find(
39
- (o) => "getType" in o && o.getType() === "text"
38
+ const e = t.childNodes(), o = e.find(
39
+ (n) => "getType" in n && n.getType() === "text"
40
40
  );
41
- return n || t.reduce((o, r) => o || !("getType" in r) || r.getType() === "text" ? o : H(r), null);
41
+ return o || e.reduce((n, i) => n || !("getType" in i) || i.getType() === "text" ? n : D(i), null);
42
42
  }
43
- function y(e, t, n) {
44
- const o = H(t);
45
- return o ? (e.modifyHtml(o).setText(n), !0) : !1;
43
+ function S(t, e, o) {
44
+ const n = D(e);
45
+ return n ? (t.modifyHtml(n).setText(o), !0) : !1;
46
46
  }
47
- function v(e, t) {
48
- return e && e.length > 0 ? e : t.length > 0 ? t : B();
47
+ function U(t, e) {
48
+ return t && t.length > 0 ? t : e.length > 0 ? e : L();
49
49
  }
50
- function j(e) {
51
- if (typeof e == "number")
52
- return `0 ${e / 2}px`;
53
- }
54
- function J(e) {
55
- const { currentNode: t, documentModifier: n } = e;
56
- if (!t || !("querySelector" in t))
57
- return !1;
58
- const o = t.querySelector(_);
59
- return o ? (n.modifyHtml(o).setInnerHtml(""), !0) : !1;
50
+ function G(t) {
51
+ const { currentNode: e, documentModifier: o } = t;
52
+ if (!e || !("querySelector" in e))
53
+ return;
54
+ const n = e.querySelector(k);
55
+ n && (o.modifyHtml(n).setInnerHtml(""), o.apply(new p("Cleared mobile row content")));
60
56
  }
61
- function F(e, t, n, o) {
57
+ function Y(t) {
62
58
  const {
63
- currentNode: r,
64
- documentModifier: s,
65
- products: i,
66
- layout: u,
59
+ currentNode: e,
60
+ documentModifier: o,
61
+ products: n,
62
+ layout: i,
67
63
  composition: c
68
- } = e;
69
- if (!r || !("querySelector" in r))
70
- return !1;
71
- const l = u ?? C(r), a = b.getConfig(r);
72
- if (l === "list" || !a.mobileLayoutEnabled)
73
- return J({ currentNode: r, documentModifier: s });
74
- const f = r.querySelector(_);
75
- if (!f)
76
- return !1;
77
- const d = E(), g = v(i, d.recommendationProducts), P = c ?? $(r), q = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${L(g, l, {
78
- productsPerRow: a.mobileCardsInRow,
79
- composition: P,
80
- filterList: d.filterList,
81
- // One product per row has no gutter — suppress padding without clobbering the stored value.
82
- cellPadding: a.mobileCardsInRow === 1 ? "0" : j(a.mobileColumnSpacing),
83
- rowSpacingPx: a.mobileRowSpacing,
84
- styleTemplates: t,
85
- cardBackgroundColor: n,
86
- cellBackgroundColors: o
64
+ } = t;
65
+ if (!e || !("querySelector" in e))
66
+ return;
67
+ const r = i ?? b(e), s = E.getConfig(e);
68
+ if (r === "list" || !s.mobileLayoutEnabled) {
69
+ G({ currentNode: e, documentModifier: o });
70
+ return;
71
+ }
72
+ const u = e.querySelector(k);
73
+ if (!u)
74
+ return;
75
+ const l = C(), d = U(n, l.recommendationProducts), a = c ?? x(e), g = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${_(d, r, {
76
+ productsPerRow: s.mobileCardsInRow,
77
+ composition: a,
78
+ filterList: l.filterList
87
79
  })}</table></td>`;
88
- return s.modifyHtml(f).setInnerHtml(q), !0;
89
- }
90
- function fe(e) {
91
- const t = x(e.currentNode), n = D(e.currentNode), o = U(e.currentNode);
92
- F(e, t, n, o) && e.documentModifier.apply(new S("Updated mobile product rows"));
80
+ o.modifyHtml(u).setInnerHtml(g), o.apply(new p("Updated mobile product rows"));
93
81
  }
94
- function Q(e, t, n, o) {
82
+ function K(t) {
95
83
  const {
96
- currentNode: r,
97
- documentModifier: s,
84
+ currentNode: e,
85
+ documentModifier: o,
86
+ afterRegenerate: n,
98
87
  products: i,
99
- layout: u,
100
- composition: c
101
- } = e;
102
- if (!r || !("querySelector" in r))
103
- return !1;
104
- const l = r.querySelector(N) ?? r.querySelector(K);
105
- if (!l)
106
- return !1;
107
- const a = E(), f = v(i, a.recommendationProducts), { cardsInRow: d } = a.recommendationConfigs, g = c ?? $(r), P = u ?? C(r), A = b.getConfig(r), q = L(f, P, {
88
+ layout: c,
89
+ composition: r
90
+ } = t;
91
+ if (!e || !("querySelector" in e))
92
+ return;
93
+ const s = e.querySelector(P) ?? e.querySelector(v);
94
+ if (!s)
95
+ return;
96
+ const u = C(), l = U(i, u.recommendationProducts), { cardsInRow: d } = u.recommendationConfigs, a = r ?? x(e), f = c ?? b(e), g = _(l, f, {
108
97
  productsPerRow: d,
109
- composition: g,
110
- filterList: a.filterList,
111
- // One product per row has no gutter — suppress padding without clobbering the stored value.
112
- cellPadding: d === 1 ? "0" : j(A.columnSpacing),
113
- rowSpacingPx: A.rowSpacing,
114
- styleTemplates: t,
115
- cardBackgroundColor: n,
116
- cellBackgroundColors: o
98
+ composition: a,
99
+ filterList: u.filterList
117
100
  });
118
- return s.modifyHtml(l).setInnerHtml(q), !0;
101
+ o.modifyHtml(s).setInnerHtml(g).apply(new p("Updated product")), Y(t), n == null || n();
119
102
  }
120
- function me(e) {
121
- const {
122
- currentNode: t,
123
- documentModifier: n,
124
- afterRegenerate: o,
125
- products: r,
126
- layout: s,
127
- composition: i,
128
- skipStylePreservation: u
129
- } = e;
130
- if (!t)
103
+ function T(t, e, o, n) {
104
+ const c = `0 ${Math.floor(o / 2)}px`;
105
+ let r = !1;
106
+ return n === "grid" ? Array.from(
107
+ t.querySelectorAll(".attribute-cell")
108
+ ).forEach((u) => {
109
+ e.modifyHtml(u).setStyle("padding", c), r = !0;
110
+ }) : Array.from(
111
+ t.querySelectorAll(".product-card-wrapper")
112
+ ).forEach((u) => {
113
+ const l = "parentNode" in u ? u.parentNode : null;
114
+ l && F(l) && (e.modifyHtml(l).setStyle("padding", c), r = !0);
115
+ }), r;
116
+ }
117
+ function I(t, e, o) {
118
+ const n = `${o}px`, i = Array.from(t.querySelectorAll(".spacer"));
119
+ let c = !1;
120
+ return i.forEach((r) => {
121
+ e.modifyHtml(r).setStyle("height", n), c = !0;
122
+ }), c;
123
+ }
124
+ function X(t) {
125
+ const { currentNode: e, documentModifier: o } = t;
126
+ if (!e)
131
127
  return;
132
- const c = u ? void 0 : x(t), l = u ? void 0 : D(t), a = u ? void 0 : U(t), f = {
133
- currentNode: t,
134
- documentModifier: n,
135
- products: r,
136
- layout: s,
137
- composition: i
138
- };
139
- let d = Q(
140
- f,
141
- c,
142
- l,
143
- a
144
- );
145
- d = F(
146
- f,
147
- c,
148
- l,
149
- a
150
- ) || d, d && n.apply(new S("Regenerate products with styles")), o == null || o();
128
+ const n = E.getConfig(e), i = b(e);
129
+ let c = !1;
130
+ const r = e.querySelector(P);
131
+ if (r) {
132
+ c = T(
133
+ r,
134
+ o,
135
+ n.columnSpacing,
136
+ i
137
+ );
138
+ const l = I(
139
+ r,
140
+ o,
141
+ n.rowSpacing
142
+ );
143
+ c = c || l;
144
+ }
145
+ const s = e.querySelector(q);
146
+ if (s) {
147
+ const u = T(
148
+ s,
149
+ o,
150
+ n.mobileColumnSpacing,
151
+ i
152
+ );
153
+ c = c || u;
154
+ const l = I(
155
+ s,
156
+ o,
157
+ n.mobileRowSpacing
158
+ );
159
+ c = c || l;
160
+ }
161
+ c && o.apply(new p("Reapply spacing after regeneration"));
162
+ }
163
+ function se(t) {
164
+ const { currentNode: e, documentModifier: o, afterRegenerate: n, products: i, layout: c, composition: r } = t;
165
+ e && K({
166
+ currentNode: e,
167
+ documentModifier: o,
168
+ products: i,
169
+ layout: c,
170
+ composition: r,
171
+ afterRegenerate: () => {
172
+ setTimeout(() => {
173
+ X({ currentNode: e, documentModifier: o });
174
+ }, 0), n == null || n();
175
+ }
176
+ });
151
177
  }
152
- function pe(e, t) {
153
- return e.length === t ? e : e.length > t ? e.slice(0, t) : [...e, ...B(t - e.length)];
178
+ function ae(t, e) {
179
+ return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...L(e - t.length)];
154
180
  }
155
- function G() {
156
- const e = E(), { currencySettings: t } = e.recommendationConfigs, n = parseInt(t.decimalCount);
181
+ function H() {
182
+ const t = C(), { currencySettings: e } = t.recommendationConfigs, o = parseInt(e.decimalCount);
157
183
  return {
158
- code: t.value,
159
- symbol: t.symbol,
160
- alignment: t.alignment === "0" ? "before" : "after",
161
- decimalCount: Number.isNaN(n) ? 2 : n,
162
- decimalSeparator: t.decimalSeparator,
163
- thousandSeparator: t.thousandSeparator
184
+ code: e.value,
185
+ symbol: e.symbol,
186
+ alignment: e.alignment === "0" ? "before" : "after",
187
+ decimalCount: Number.isNaN(o) ? 2 : o,
188
+ decimalSeparator: e.decimalSeparator,
189
+ thousandSeparator: e.thousandSeparator
164
190
  };
165
191
  }
166
- function R(e, t = "price") {
167
- const n = G(), o = e[t], r = (o == null ? void 0 : o[n.code]) ?? Object.values(o ?? {})[0] ?? 0;
168
- return X({
169
- price: r,
170
- currency: n
192
+ function A(t, e = "price") {
193
+ const o = H(), n = t[e], i = (n == null ? void 0 : n[o.code]) ?? Object.values(n ?? {})[0] ?? 0;
194
+ return j({
195
+ price: i,
196
+ currency: o
171
197
  });
172
198
  }
173
- function Z(e) {
174
- var s, i;
175
- const t = G(), n = ((s = e.original_price) == null ? void 0 : s[t.code]) ?? Object.values(e.original_price ?? {})[0] ?? 0, o = ((i = e.price) == null ? void 0 : i[t.code]) ?? Object.values(e.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
176
- return r > 0 ? `-${r}%` : "0%";
199
+ function z(t) {
200
+ var c, r;
201
+ const e = H(), o = ((c = t.original_price) == null ? void 0 : c[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, n = ((r = t.price) == null ? void 0 : r[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, i = o > 0 ? Math.round((o - n) / o * 100) : 0;
202
+ return i > 0 ? `-${i}%` : "0%";
177
203
  }
178
- function W(e) {
179
- const { documentModifier: t, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: i } = e;
180
- let u = !1;
181
- if (o && "querySelector" in o) {
182
- const c = o.querySelector("strong") ?? o.querySelector("p"), l = R(n, "price");
183
- y(t, c ?? null, l) && (u = !0);
204
+ function $(t) {
205
+ const { documentModifier: e, product: o, priceEl: n, oldPriceEl: i, omnibusPriceEl: c, omnibusDiscountEl: r } = t;
206
+ let s = !1;
207
+ if (n && "querySelector" in n) {
208
+ const u = n.querySelector("strong") ?? n.querySelector("p"), l = A(o, "price");
209
+ S(e, u ?? null, l) && (s = !0);
184
210
  }
185
- if (r && "querySelector" in r) {
186
- const c = r.querySelector("strong") ?? r.querySelector("p"), l = R(n, "original_price");
187
- y(t, c ?? null, l) && (u = !0);
211
+ if (i && "querySelector" in i) {
212
+ const u = i.querySelector("strong") ?? i.querySelector("p"), l = A(o, "original_price");
213
+ S(e, u ?? null, l) && (s = !0);
188
214
  }
189
- if (s && "querySelector" in s) {
190
- const c = s.querySelector(".omnibus-price-value") ?? null, l = R(n, "original_price");
191
- y(t, c, l) && (u = !0);
215
+ if (c && "querySelector" in c) {
216
+ const u = c.querySelector(".omnibus-price-value") ?? null, l = A(o, "original_price");
217
+ S(e, u, l) && (s = !0);
192
218
  }
193
- if (i && "querySelector" in i) {
194
- const c = i.querySelector(".omnibus-discount-value") ?? null, l = Z(n);
195
- y(t, c, l) && (u = !0);
219
+ if (r && "querySelector" in r) {
220
+ const u = r.querySelector(".omnibus-discount-value") ?? null, l = z(o);
221
+ S(e, u, l) && (s = !0);
196
222
  }
197
- return u;
223
+ return s;
198
224
  }
199
- function ee(e) {
225
+ function J(t) {
200
226
  const {
201
- documentModifier: t,
202
- product: n,
203
- imageEl: o,
204
- nameEl: r,
205
- priceEl: s,
206
- oldPriceEl: i,
207
- omnibusPriceEl: u,
208
- omnibusDiscountEl: c,
227
+ documentModifier: e,
228
+ product: o,
229
+ imageEl: n,
230
+ nameEl: i,
231
+ priceEl: c,
232
+ oldPriceEl: r,
233
+ omnibusPriceEl: s,
234
+ omnibusDiscountEl: u,
209
235
  buttonEl: l
210
- } = e;
211
- let a = !1;
212
- if (o && "querySelector" in o) {
213
- const f = o.querySelector("img");
214
- f && (t.modifyHtml(f).setAttribute("src", z(n.image_url)).setAttribute("alt", n.name), a = !0);
215
- const d = o.querySelector("a");
216
- d && (t.modifyHtml(d).setAttribute("href", n.url), a = !0);
236
+ } = t;
237
+ let d = !1;
238
+ if (n && "querySelector" in n) {
239
+ const a = n.querySelector("img");
240
+ a && (e.modifyHtml(a).setAttribute("src", V(o.image_url)).setAttribute("alt", o.name), d = !0);
241
+ const f = n.querySelector("a");
242
+ f && (e.modifyHtml(f).setAttribute("href", o.url), d = !0);
217
243
  }
218
- if (r && "querySelector" in r) {
219
- const f = r.querySelector("strong") ?? r.querySelector("p");
220
- y(t, f ?? null, n.name) && (a = !0);
244
+ if (i && "querySelector" in i) {
245
+ const a = i.querySelector("strong") ?? i.querySelector("p");
246
+ S(e, a ?? null, o.name) && (d = !0);
221
247
  }
222
- if (W({
223
- documentModifier: t,
224
- product: n,
225
- priceEl: s,
226
- oldPriceEl: i,
227
- omnibusPriceEl: u,
228
- omnibusDiscountEl: c
229
- }) && (a = !0), l && "querySelector" in l) {
230
- const f = l.querySelector("a.es-button") || l.querySelector("a");
231
- f && (t.modifyHtml(f).setAttribute("href", n.url), a = !0);
248
+ if ($({
249
+ documentModifier: e,
250
+ product: o,
251
+ priceEl: c,
252
+ oldPriceEl: r,
253
+ omnibusPriceEl: s,
254
+ omnibusDiscountEl: u
255
+ }) && (d = !0), l && "querySelector" in l) {
256
+ const a = l.querySelector("a.es-button") || l.querySelector("a");
257
+ a && (e.modifyHtml(a).setAttribute("href", o.url), d = !0);
232
258
  }
233
- return a;
259
+ return d;
234
260
  }
235
- function Y(e) {
236
- return "querySelector" in e ? e.querySelector(N) ?? e : e;
261
+ function B(t) {
262
+ return "querySelector" in t ? t.querySelector(P) ?? t : t;
237
263
  }
238
- const I = "product_attribute.";
239
- function te(e, t) {
240
- var o;
241
- let n;
242
- if (e.startsWith(I)) {
243
- const r = e.slice(I.length);
244
- n = (o = t.product_attributes) == null ? void 0 : o[r];
264
+ const O = "product_attribute.";
265
+ function Q(t, e) {
266
+ var n;
267
+ let o;
268
+ if (t.startsWith(O)) {
269
+ const i = t.slice(O.length);
270
+ o = (n = e.product_attributes) == null ? void 0 : n[i];
245
271
  } else
246
- n = t[e];
247
- return typeof n == "string" && n.length > 0 ? n : typeof n == "number" ? String(n) : null;
272
+ o = e[t];
273
+ return typeof o == "string" && o.length > 0 ? o : typeof o == "number" ? String(o) : null;
248
274
  }
249
- function ne(e, t, n) {
250
- if (!("querySelectorAll" in e))
275
+ function Z(t, e, o) {
276
+ if (!("querySelectorAll" in t))
251
277
  return !1;
252
- const o = e.querySelectorAll(
278
+ const n = t.querySelectorAll(
253
279
  `[esd-extension-block-id="${m.CUSTOM_ATTRIBUTE}"]`
254
280
  );
255
- if (o.length === 0)
281
+ if (n.length === 0)
256
282
  return !1;
257
- const r = /* @__PURE__ */ new Map();
258
- o.forEach((i) => {
259
- if (!("getAttribute" in i))
283
+ const i = /* @__PURE__ */ new Map();
284
+ n.forEach((r) => {
285
+ if (!("getAttribute" in r))
260
286
  return;
261
- const u = i.getAttribute(V);
262
- if (!u)
287
+ const s = r.getAttribute(W);
288
+ if (!s)
263
289
  return;
264
- const c = r.get(u) ?? [];
265
- c.push(i), r.set(u, c);
290
+ const u = i.get(s) ?? [];
291
+ u.push(r), i.set(s, u);
266
292
  });
267
- let s = !1;
268
- return r.forEach((i, u) => {
269
- const c = Math.min(i.length, n.length);
270
- i.slice(0, c).forEach((l, a) => {
293
+ let c = !1;
294
+ return i.forEach((r, s) => {
295
+ const u = Math.min(r.length, o.length);
296
+ r.slice(0, u).forEach((l, d) => {
271
297
  if (!("querySelector" in l))
272
298
  return;
273
- const f = te(u, n[a]);
274
- if (f === null)
299
+ const a = Q(s, o[d]);
300
+ if (a === null)
275
301
  return;
276
- const d = l.querySelector("p") ?? null;
277
- y(t, d, f) && (s = !0);
302
+ const f = l.querySelector("p") ?? null;
303
+ S(e, f, a) && (c = !0);
278
304
  });
279
- }), s;
305
+ }), c;
280
306
  }
281
- function O(e, t, n) {
282
- if (!("querySelectorAll" in e))
307
+ function w(t, e, o) {
308
+ if (!("querySelectorAll" in t))
283
309
  return !1;
284
- const o = e.querySelectorAll(
310
+ const n = t.querySelectorAll(
285
311
  `[esd-extension-block-id="${m.IMAGE}"]`
286
- ), r = e.querySelectorAll(
312
+ ), i = t.querySelectorAll(
287
313
  `[esd-extension-block-id="${m.NAME}"]`
288
- ), s = e.querySelectorAll(
314
+ ), c = t.querySelectorAll(
289
315
  `[esd-extension-block-id="${m.PRICE}"]`
290
- ), i = e.querySelectorAll(
316
+ ), r = t.querySelectorAll(
291
317
  `[esd-extension-block-id="${m.OLD_PRICE}"]`
292
- ), u = e.querySelectorAll(
318
+ ), s = t.querySelectorAll(
293
319
  `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
294
- ), c = e.querySelectorAll(
320
+ ), u = t.querySelectorAll(
295
321
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
296
- ), l = e.querySelectorAll(
322
+ ), l = t.querySelectorAll(
297
323
  `[esd-extension-block-id="${m.BUTTON}"]`
298
- ), a = Math.min(o.length, n.length);
299
- let f = !1;
300
- for (let d = 0; d < a; d++) {
301
- const g = ee({
302
- documentModifier: t,
303
- product: n[d],
304
- imageEl: o[d] ?? null,
305
- nameEl: r[d] ?? null,
306
- priceEl: s[d] ?? null,
307
- oldPriceEl: i[d] ?? null,
308
- omnibusPriceEl: u[d] ?? null,
309
- omnibusDiscountEl: c[d] ?? null,
310
- buttonEl: l[d] ?? null
324
+ ), d = Math.min(n.length, o.length);
325
+ let a = !1;
326
+ for (let f = 0; f < d; f++) {
327
+ const g = J({
328
+ documentModifier: e,
329
+ product: o[f],
330
+ imageEl: n[f] ?? null,
331
+ nameEl: i[f] ?? null,
332
+ priceEl: c[f] ?? null,
333
+ oldPriceEl: r[f] ?? null,
334
+ omnibusPriceEl: s[f] ?? null,
335
+ omnibusDiscountEl: u[f] ?? null,
336
+ buttonEl: l[f] ?? null
311
337
  });
312
- f = f || g;
338
+ a = a || g;
313
339
  }
314
- return ne(e, t, n) && (f = !0), f;
340
+ return Z(t, e, o) && (a = !0), a;
315
341
  }
316
- function ye(e) {
317
- const { currentNode: t, documentModifier: n, products: o } = e;
318
- if (!t || !("querySelectorAll" in t))
342
+ function de(t) {
343
+ const { currentNode: e, documentModifier: o, products: n } = t;
344
+ if (!e || !("querySelectorAll" in e))
319
345
  return !1;
320
- const r = Y(t);
321
- if (!("querySelectorAll" in r) || r.querySelectorAll(
346
+ const i = B(e);
347
+ if (!("querySelectorAll" in i) || i.querySelectorAll(
322
348
  `[esd-extension-block-id="${m.IMAGE}"]`
323
- ).length !== o.length)
349
+ ).length !== n.length)
324
350
  return !1;
325
- let i = O(r, n, o);
326
- const u = C(t), c = b.getConfig(t);
327
- if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
328
- const l = t.querySelector(w);
351
+ let r = w(i, o, n);
352
+ const s = b(e), u = E.getConfig(e);
353
+ if (s !== "list" && u.mobileLayoutEnabled && "querySelector" in e) {
354
+ const l = e.querySelector(q);
329
355
  if (l) {
330
- const a = O(
356
+ const d = w(
331
357
  l,
332
- n,
333
- o
358
+ o,
359
+ n
334
360
  );
335
- i = i || a;
361
+ r = r || d;
336
362
  }
337
363
  }
338
- return i && n.apply(new S("Updated product content in-place")), !0;
364
+ return r && o.apply(new p("Updated product content in-place")), !0;
339
365
  }
340
- function k(e, t, n) {
341
- if (!("querySelectorAll" in e))
366
+ function N(t, e, o) {
367
+ if (!("querySelectorAll" in t))
342
368
  return !1;
343
- const o = e.querySelectorAll(
369
+ const n = t.querySelectorAll(
344
370
  `[esd-extension-block-id="${m.PRICE}"]`
345
- ), r = e.querySelectorAll(
371
+ ), i = t.querySelectorAll(
346
372
  `[esd-extension-block-id="${m.OLD_PRICE}"]`
347
- ), s = e.querySelectorAll(
373
+ ), c = t.querySelectorAll(
348
374
  `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
349
- ), i = e.querySelectorAll(
375
+ ), r = t.querySelectorAll(
350
376
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
351
- ), u = Math.min(o.length, n.length);
352
- let c = !1;
353
- for (let l = 0; l < u; l++)
354
- W({
355
- documentModifier: t,
356
- product: n[l],
357
- priceEl: o[l] ?? null,
358
- oldPriceEl: r[l] ?? null,
359
- omnibusPriceEl: s[l] ?? null,
360
- omnibusDiscountEl: i[l] ?? null
361
- }) && (c = !0);
362
- return c;
377
+ ), s = Math.min(n.length, o.length);
378
+ let u = !1;
379
+ for (let l = 0; l < s; l++)
380
+ $({
381
+ documentModifier: e,
382
+ product: o[l],
383
+ priceEl: n[l] ?? null,
384
+ oldPriceEl: i[l] ?? null,
385
+ omnibusPriceEl: c[l] ?? null,
386
+ omnibusDiscountEl: r[l] ?? null
387
+ }) && (u = !0);
388
+ return u;
363
389
  }
364
- function ge(e) {
365
- const { currentNode: t, documentModifier: n } = e;
366
- if (!t || !("querySelectorAll" in t))
390
+ function fe(t) {
391
+ const { currentNode: e, documentModifier: o } = t;
392
+ if (!e || !("querySelectorAll" in e))
367
393
  return !1;
368
- const r = E().recommendationProducts;
369
- if (r.length === 0)
394
+ const i = C().recommendationProducts;
395
+ if (i.length === 0)
370
396
  return !1;
371
- const s = Y(t);
372
- let i = k(s, n, r);
373
- const u = C(t), c = b.getConfig(t);
374
- if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
375
- const l = t.querySelector(w);
397
+ const c = B(e);
398
+ let r = N(c, o, i);
399
+ const s = b(e), u = E.getConfig(e);
400
+ if (s !== "list" && u.mobileLayoutEnabled && "querySelector" in e) {
401
+ const l = e.querySelector(q);
376
402
  if (l) {
377
- const a = k(l, n, r);
378
- i = i || a;
403
+ const d = N(l, o, i);
404
+ r = r || d;
379
405
  }
380
406
  }
381
- return i && n.apply(new S("Updated price formatting in-place")), i;
407
+ return r && o.apply(new p("Updated price formatting in-place")), r;
382
408
  }
383
- function Se(e) {
384
- const { currentNode: t, documentModifier: n, currency: o } = e, r = T(t);
385
- if (!r)
409
+ function me(t) {
410
+ const { currentNode: e, documentModifier: o, currency: n } = t, i = h(e);
411
+ if (!i)
386
412
  return;
387
- const s = o.alignment === "before" ? "0" : "1", i = (u, c) => {
388
- n.modifyHtml(r).setAttribute(u, c);
413
+ const c = n.alignment === "before" ? "0" : "1", r = (s, u) => {
414
+ o.modifyHtml(i).setAttribute(s, u);
389
415
  };
390
- i(p.CURRENCY, o.code), i(p.SYMBOL, o.symbol), i(p.ALIGNMENT, s), i(p.THOUSAND_SEPARATOR, o.thousandSeparator), i(p.DECIMAL_SEPARATOR, o.decimalSeparator), i(p.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new S("Update currency attributes"));
416
+ r(y.CURRENCY, n.code), r(y.SYMBOL, n.symbol), r(y.ALIGNMENT, c), r(y.THOUSAND_SEPARATOR, n.thousandSeparator), r(y.DECIMAL_SEPARATOR, n.decimalSeparator), r(y.DECIMAL_COUNT, n.decimalCount.toString()), o.apply(new p("Update currency attributes"));
391
417
  }
392
418
  export {
393
- pe as adjustProductsToSize,
394
- R as formatProductPrice,
395
- T as getBlockElement,
396
- $ as getCardComposition,
397
- C as getCurrentLayout,
398
- fe as regenerateMobileProductRows,
399
- me as regenerateProductRowsWithStyles,
400
- Se as setCurrencyAttributes,
401
- ge as updatePricesInPlace,
402
- ye as updateProductContentInPlace,
403
- ee as updateSingleProductContent
419
+ ae as adjustProductsToSize,
420
+ A as formatProductPrice,
421
+ h as getBlockElement,
422
+ x as getCardComposition,
423
+ b as getCurrentLayout,
424
+ X as reapplySpacing,
425
+ Y as regenerateMobileProductRows,
426
+ K as regenerateProductRows,
427
+ se as regenerateProductRowsWithStyles,
428
+ me as setCurrencyAttributes,
429
+ fe as updatePricesInPlace,
430
+ de as updateProductContentInPlace,
431
+ J as updateSingleProductContent
404
432
  };