@useinsider/guido 3.8.3-beta.96b5eeb → 3.9.0-beta.ba394b1

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 (67) hide show
  1. package/dist/@types/config/schemas.js +70 -66
  2. package/dist/composables/useCustomInterfaceAppearance.js +16 -18
  3. package/dist/composables/usePreviewMode.js +15 -14
  4. package/dist/composables/useRecommendationPreview.js +111 -0
  5. package/dist/composables/useStripo.js +39 -37
  6. package/dist/composables/useStripoNotifications.js +26 -0
  7. package/dist/config/compiler/recommendationCompilerRules.js +1 -1
  8. package/dist/config/compiler/utils/recommendationCompilerUtils.js +88 -80
  9. package/dist/config/migrator/recommendation/htmlBuilder.js +53 -52
  10. package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
  11. package/dist/enums/toaster.js +2 -2
  12. package/dist/extensions/Blocks/Items/block.js +48 -29
  13. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
  14. package/dist/extensions/Blocks/Recommendation/block.js +64 -42
  15. package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
  16. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
  17. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +461 -363
  18. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +99 -87
  19. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +162 -160
  21. package/dist/extensions/Blocks/Recommendation/extension.js +30 -29
  22. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
  23. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
  24. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -1
  25. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +130 -96
  26. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +43 -54
  27. package/dist/extensions/Blocks/Recommendation/templates/index.js +17 -14
  28. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +86 -80
  29. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -40
  30. package/dist/extensions/Blocks/Recommendation/templates/utils.js +155 -102
  31. package/dist/extensions/Blocks/Recommendation/useRecommendationBlockWarning.js +7 -7
  32. package/dist/extensions/Blocks/controlFactories.js +76 -57
  33. package/dist/services/templateLibraryApi.js +9 -8
  34. package/dist/src/@types/config/schemas.d.ts +16 -0
  35. package/dist/src/composables/useConfig.d.ts +4 -0
  36. package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
  37. package/dist/src/composables/useStripoNotifications.d.ts +10 -0
  38. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  39. package/dist/src/enums/toaster.d.ts +2 -2
  40. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
  42. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +3 -3
  43. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
  44. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  45. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
  46. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
  49. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +1 -1
  50. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +1 -1
  51. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +1 -1
  52. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +1 -1
  53. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +1 -1
  54. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  55. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +13 -1
  56. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  57. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  58. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +10 -1
  59. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  60. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +51 -1
  61. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
  62. package/dist/src/extensions/Blocks/controlFactories.d.ts +10 -1
  63. package/dist/src/stores/config.d.ts +36 -0
  64. package/dist/src/stores/toaster.d.ts +2 -3
  65. package/dist/stores/toaster.js +10 -10
  66. package/package.json +2 -2
  67. package/dist/static/styles/components/notification.css.js +0 -74
@@ -1,204 +1,206 @@
1
1
  import { ModificationDescription as g } 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 y, CSS_CLASS_SKIP_COMPILE as F, MOBILE_CONTAINER_SELECTOR as O, DESKTOP_CONTAINER_SELECTOR as w, CONTAINER_SELECTOR as G, MOBILE_ROW_SELECTOR as N, ATTR_PRODUCT_ATTR as K, PRODUCT_ATTRIBUTE_PREFIX as R } from "../../constants/selectors.js";
3
+ import { CURRENCY_ATTR as y, CSS_CLASS_SKIP_COMPILE as F, MOBILE_CONTAINER_SELECTOR as O, DESKTOP_CONTAINER_SELECTOR as N, CONTAINER_SELECTOR as G, MOBILE_ROW_SELECTOR as w, ATTR_PRODUCT_ATTR as K, PRODUCT_ATTRIBUTE_PREFIX as T } from "../../constants/selectors.js";
4
4
  import { RecommendationConfigService as S } from "../../services/configService.js";
5
5
  import { useRecommendationExtensionStore as P } from "../../store/recommendation.js";
6
- import { prepareProductRows as _ } from "../../templates/index.js";
7
- import { captureStyles as k } from "../../utils/captureStyleTemplates.js";
6
+ import { prepareProductRows as L } from "../../templates/index.js";
7
+ import { captureStyles as _ } from "../../utils/captureStyleTemplates.js";
8
8
  import { formatPrice as V } from "../../utils/priceFormatter.js";
9
- import { getDefaultProducts as L, DEFAULT_CARD_COMPOSITION as T, sanitizeImageUrl as W, toDisplayableAttributeValue as Y } from "../../templates/utils.js";
9
+ import { getDefaultProducts as k, DEFAULT_CARD_COMPOSITION as R, sanitizeImageUrl as W, isSamePrice as Y, toDisplayableAttributeValue as X } from "../../templates/utils.js";
10
10
  const M = "recommendation-block-v2";
11
- function A(e) {
12
- if (!e)
11
+ function A(t) {
12
+ if (!t)
13
13
  return null;
14
- if ("getAttribute" in e) {
15
- const t = e.getAttribute("class");
16
- if (t && t.includes(M))
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(`.${M}`) ?? null : null;
19
+ return "querySelector" in t ? t.querySelector(`.${M}`) ?? null : null;
20
20
  }
21
- function X(e) {
22
- const t = A(e);
23
- return !t || !("getAttribute" in t) ? !1 : (t.getAttribute("class") ?? "").split(/\s+/).includes(F);
21
+ function z(t) {
22
+ const e = A(t);
23
+ return !e || !("getAttribute" in e) ? !1 : (e.getAttribute("class") ?? "").split(/\s+/).includes(F);
24
24
  }
25
- function C(e) {
26
- const t = A(e);
27
- if (!t || !("getAttribute" in t))
25
+ function C(t) {
26
+ const e = A(t);
27
+ if (!e || !("getAttribute" in e))
28
28
  return "grid";
29
- const n = t.getAttribute("data-layout");
29
+ const n = e.getAttribute("data-layout");
30
30
  return n === "list" || n === "horizontal" ? "list" : "grid";
31
31
  }
32
- function x(e) {
33
- const t = A(e);
34
- if (!t || !("getAttribute" in t))
35
- return T;
36
- const n = t.getAttribute("data-card-composition");
37
- return n ? n.split(",").filter(Boolean) : T;
32
+ function x(t) {
33
+ const e = A(t);
34
+ if (!e || !("getAttribute" in e))
35
+ return R;
36
+ const n = e.getAttribute("data-card-composition");
37
+ return n ? n.split(",").filter(Boolean) : R;
38
38
  }
39
- function D(e) {
40
- if (!e || !("childNodes" in e))
39
+ function D(t) {
40
+ if (!t || !("childNodes" in t))
41
41
  return null;
42
- const t = e.childNodes(), n = t.find(
42
+ const e = t.childNodes(), n = e.find(
43
43
  (o) => "getType" in o && o.getType() === "text"
44
44
  );
45
- return n || t.reduce((o, r) => o || !("getType" in r) || r.getType() === "text" ? o : D(r), null);
45
+ return n || e.reduce((o, r) => o || !("getType" in r) || r.getType() === "text" ? o : D(r), null);
46
46
  }
47
- function b(e, t, n) {
48
- const o = D(t);
49
- return o ? (e.modifyHtml(o).setText(n), !0) : !1;
47
+ function b(t, e, n) {
48
+ const o = D(e);
49
+ return o ? (t.modifyHtml(o).setText(n), !0) : !1;
50
50
  }
51
- function H(e, t) {
52
- return e && e.length > 0 ? e : t.length > 0 ? t : L();
51
+ function H(t, e) {
52
+ return t && t.length > 0 ? t : e.length > 0 ? e : k();
53
53
  }
54
- function U(e) {
55
- if (typeof e == "number")
56
- return `0 ${e / 2}px`;
54
+ function U(t) {
55
+ if (typeof t == "number")
56
+ return `0 ${t / 2}px`;
57
57
  }
58
- function z(e) {
59
- const { currentNode: t, documentModifier: n } = e;
60
- if (!t || !("querySelector" in t))
58
+ function J(t) {
59
+ const { currentNode: e, documentModifier: n } = t;
60
+ if (!e || !("querySelector" in e))
61
61
  return !1;
62
- const o = t.querySelector(N);
62
+ const o = e.querySelector(w);
63
63
  return o ? (n.modifyHtml(o).setInnerHtml(""), !0) : !1;
64
64
  }
65
- function J(e) {
66
- return "getOuterHTML" in e && typeof e.getOuterHTML == "function" ? e.getOuterHTML() : "";
65
+ function Q(t) {
66
+ return "getOuterHTML" in t && typeof t.getOuterHTML == "function" ? t.getOuterHTML() : "";
67
67
  }
68
- function Q(e) {
69
- const t = e.querySelector(".container");
70
- return !t || !("childNodes" in t) ? null : t.childNodes().find((o) => "getTagName" in o && o.getTagName() === "tbody") ?? t.querySelector("tbody") ?? null;
68
+ function Z(t) {
69
+ const e = t.querySelector(".container");
70
+ return !e || !("childNodes" in e) ? null : e.childNodes().find((o) => "getTagName" in o && o.getTagName() === "tbody") ?? e.querySelector("tbody") ?? null;
71
71
  }
72
- function Z(e, t, n) {
73
- const o = Q(e);
72
+ function ee(t, e, n) {
73
+ const o = Z(t);
74
74
  if (!o || !("childNodes" in o))
75
75
  return;
76
- const r = o.childNodes().map(J).join(""), s = `<tr class="ins-recommendation-mobile-row">${n}</tr>`;
77
- t.modifyHtml(o).setInnerHtml(r + s), t.apply(new g("Added mobile product row"));
76
+ const r = o.childNodes().map(Q).join(""), s = `<tr class="ins-recommendation-mobile-row">${n}</tr>`;
77
+ e.modifyHtml(o).setInnerHtml(r + s), e.apply(new g("Added mobile product row"));
78
78
  }
79
- function $(e, t = {}) {
79
+ function $(t, e = {}) {
80
80
  const {
81
81
  currentNode: n,
82
82
  documentModifier: o,
83
83
  products: r,
84
84
  layout: s,
85
85
  composition: i
86
- } = e;
86
+ } = t;
87
87
  if (!n || !("querySelector" in n))
88
88
  return !1;
89
89
  const u = s ?? C(n), c = S.getConfig(n);
90
90
  if (u === "list" || !c.mobileLayoutEnabled)
91
- return z({ currentNode: n, documentModifier: o });
92
- const l = P(), a = H(r, l.recommendationProducts), d = i ?? x(n), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${_(a, u, {
91
+ return J({ currentNode: n, documentModifier: o });
92
+ const l = P(), a = H(r, l.recommendationProducts), d = i ?? x(n), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${L(a, u, {
93
93
  productsPerRow: c.mobileCardsInRow,
94
94
  composition: d,
95
95
  filterList: l.filterList,
96
- // Match the initial render's gutter so a regeneration never changes block height (SD-143023).
96
+ priceInline: !c.priceMovedToNextLine,
97
+ // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
97
98
  cellPadding: U(c.mobileColumnSpacing),
98
99
  rowSpacingPx: c.mobileRowSpacing,
99
- ...t
100
- })}</table></td>`, E = n.querySelector(N);
101
- return E ? (o.modifyHtml(E).setInnerHtml(p), !0) : (Z(n, o, p), !1);
100
+ ...e
101
+ })}</table></td>`, E = n.querySelector(w);
102
+ return E ? (o.modifyHtml(E).setInnerHtml(p), !0) : (ee(n, o, p), !1);
102
103
  }
103
- function pe(e) {
104
- $(e, k(e.currentNode)) && e.documentModifier.apply(new g("Updated mobile product rows"));
104
+ function ye(t) {
105
+ $(t, _(t.currentNode)) && t.documentModifier.apply(new g("Updated mobile product rows"));
105
106
  }
106
- function ee(e, t = {}) {
107
+ function te(t, e = {}) {
107
108
  const {
108
109
  currentNode: n,
109
110
  documentModifier: o,
110
111
  products: r,
111
112
  layout: s,
112
113
  composition: i
113
- } = e;
114
+ } = t;
114
115
  if (!n || !("querySelector" in n))
115
116
  return !1;
116
- const u = n.querySelector(w) ?? n.querySelector(G);
117
+ const u = n.querySelector(N) ?? n.querySelector(G);
117
118
  if (!u)
118
119
  return !1;
119
- const c = P(), l = H(r, c.recommendationProducts), { cardsInRow: a } = S.getConfig(n), d = i ?? x(n), f = s ?? C(n), p = S.getConfig(n), E = _(l, f, {
120
+ const c = P(), l = H(r, c.recommendationProducts), { cardsInRow: a } = S.getConfig(n), d = i ?? x(n), f = s ?? C(n), p = S.getConfig(n), E = L(l, f, {
120
121
  productsPerRow: a,
121
122
  composition: d,
122
123
  filterList: c.filterList,
123
- // Match the initial render's gutter so a regeneration never changes block height (SD-143023).
124
+ priceInline: !p.priceMovedToNextLine,
125
+ // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
124
126
  cellPadding: U(p.columnSpacing),
125
127
  rowSpacingPx: p.rowSpacing,
126
- ...t
128
+ ...e
127
129
  });
128
130
  return o.modifyHtml(u).setInnerHtml(E), !0;
129
131
  }
130
- function ye(e) {
132
+ function be(t) {
131
133
  const {
132
- currentNode: t,
134
+ currentNode: e,
133
135
  documentModifier: n,
134
136
  afterRegenerate: o,
135
137
  products: r,
136
138
  layout: s,
137
139
  composition: i,
138
140
  skipStylePreservation: u
139
- } = e;
140
- if (!t)
141
+ } = t;
142
+ if (!e)
141
143
  return;
142
- const c = u ? {} : k(t), l = {
143
- currentNode: t,
144
+ const c = u ? {} : _(e), l = {
145
+ currentNode: e,
144
146
  documentModifier: n,
145
147
  products: r,
146
148
  layout: s,
147
149
  composition: i
148
150
  };
149
- let a = ee(l, c);
151
+ let a = te(l, c);
150
152
  a = $(l, c) || a, a && n.apply(new g("Regenerate products with styles")), o == null || o();
151
153
  }
152
- function be(e, t) {
153
- return e.length === t ? e : e.length > t ? e.slice(0, t) : [...e, ...L(t - e.length)];
154
+ function ge(t, e) {
155
+ return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...k(e - t.length)];
154
156
  }
155
157
  function B() {
156
- const e = P(), { currencySettings: t } = e.recommendationConfigs, n = parseInt(t.decimalCount);
158
+ const t = P(), { currencySettings: e } = t.recommendationConfigs, n = parseInt(e.decimalCount);
157
159
  return {
158
- code: t.value,
159
- symbol: t.symbol,
160
- alignment: t.alignment === "0" ? "before" : "after",
160
+ code: e.value,
161
+ symbol: e.symbol,
162
+ alignment: e.alignment === "0" ? "before" : "after",
161
163
  decimalCount: Number.isNaN(n) ? 2 : n,
162
- decimalSeparator: t.decimalSeparator,
163
- thousandSeparator: t.thousandSeparator
164
+ decimalSeparator: e.decimalSeparator,
165
+ thousandSeparator: e.thousandSeparator
164
166
  };
165
167
  }
166
- function q(e, t = "price") {
167
- const n = B(), o = e[t], r = (o == null ? void 0 : o[n.code]) ?? Object.values(o ?? {})[0] ?? 0;
168
+ function q(t, e = "price") {
169
+ const n = B(), o = t[e], r = (o == null ? void 0 : o[n.code]) ?? Object.values(o ?? {})[0] ?? 0;
168
170
  return V({
169
171
  price: r,
170
172
  currency: n
171
173
  });
172
174
  }
173
- function te(e) {
175
+ function ne(t) {
174
176
  var s, i;
175
- const t = B(), 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;
177
+ const e = B(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((i = t.price) == null ? void 0 : i[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
176
178
  return r > 0 ? `-${r}%` : "0%";
177
179
  }
178
- function v(e) {
179
- const { documentModifier: t, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: i } = e;
180
+ function v(t) {
181
+ const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: i } = t;
180
182
  let u = !1;
181
183
  if (o && "querySelector" in o) {
182
184
  const c = o.querySelector("strong") ?? o.querySelector("p"), l = q(n, "price");
183
- b(t, c ?? null, l) && (u = !0);
185
+ b(e, c ?? null, l) && (u = !0);
184
186
  }
185
187
  if (r && "querySelector" in r) {
186
188
  const c = r.querySelector("strong") ?? r.querySelector("p"), l = q(n, "original_price");
187
- b(t, c ?? null, l) && (u = !0);
189
+ b(e, c ?? null, l) && (u = !0), e.modifyHtml(r).setAttribute("data-same-price", String(Y(n))), u = !0;
188
190
  }
189
191
  if (s && "querySelector" in s) {
190
192
  const c = s.querySelector(".omnibus-price-value") ?? null, l = q(n, "original_price");
191
- b(t, c, l) && (u = !0);
193
+ b(e, c, l) && (u = !0);
192
194
  }
193
195
  if (i && "querySelector" in i) {
194
- const c = i.querySelector(".omnibus-discount-value") ?? null, l = te(n);
195
- b(t, c, l) && (u = !0);
196
+ const c = i.querySelector(".omnibus-discount-value") ?? null, l = ne(n);
197
+ b(e, c, l) && (u = !0);
196
198
  }
197
199
  return u;
198
200
  }
199
- function ne(e) {
201
+ function oe(t) {
200
202
  const {
201
- documentModifier: t,
203
+ documentModifier: e,
202
204
  product: n,
203
205
  imageEl: o,
204
206
  nameEl: r,
@@ -207,20 +209,20 @@ function ne(e) {
207
209
  omnibusPriceEl: u,
208
210
  omnibusDiscountEl: c,
209
211
  buttonEl: l
210
- } = e;
212
+ } = t;
211
213
  let a = !1;
212
214
  if (o && "querySelector" in o) {
213
215
  const d = o.querySelector("img");
214
- d && (t.modifyHtml(d).setAttribute("src", W(n.image_url)).setAttribute("alt", n.name), a = !0);
216
+ d && (e.modifyHtml(d).setAttribute("src", W(n.image_url)).setAttribute("alt", n.name), a = !0);
215
217
  const f = o.querySelector("a");
216
- f && (t.modifyHtml(f).setAttribute("href", n.url), a = !0);
218
+ f && (e.modifyHtml(f).setAttribute("href", n.url), a = !0);
217
219
  }
218
220
  if (r && "querySelector" in r) {
219
221
  const d = r.querySelector("strong") ?? r.querySelector("p");
220
- b(t, d ?? null, n.name) && (a = !0);
222
+ b(e, d ?? null, n.name) && (a = !0);
221
223
  }
222
224
  if (v({
223
- documentModifier: t,
225
+ documentModifier: e,
224
226
  product: n,
225
227
  priceEl: s,
226
228
  oldPriceEl: i,
@@ -228,27 +230,27 @@ function ne(e) {
228
230
  omnibusDiscountEl: c
229
231
  }) && (a = !0), l && "querySelector" in l) {
230
232
  const d = l.querySelector("a.es-button") || l.querySelector("a");
231
- d && (t.modifyHtml(d).setAttribute("href", n.url), a = !0);
233
+ d && (e.modifyHtml(d).setAttribute("href", n.url), a = !0);
232
234
  }
233
235
  return a;
234
236
  }
235
- function j(e) {
236
- return "querySelector" in e ? e.querySelector(w) ?? e : e;
237
+ function j(t) {
238
+ return "querySelector" in t ? t.querySelector(N) ?? t : t;
237
239
  }
238
- function oe(e, t) {
240
+ function re(t, e) {
239
241
  var o;
240
242
  let n;
241
- if (e.startsWith(R)) {
242
- const r = e.slice(R.length);
243
- n = (o = t.product_attributes) == null ? void 0 : o[r];
243
+ if (t.startsWith(T)) {
244
+ const r = t.slice(T.length);
245
+ n = (o = e.product_attributes) == null ? void 0 : o[r];
244
246
  } else
245
- n = t[e];
246
- return Y(n) || null;
247
+ n = e[t];
248
+ return X(n) || null;
247
249
  }
248
- function re(e, t, n) {
249
- if (!("querySelectorAll" in e))
250
+ function ie(t, e, n) {
251
+ if (!("querySelectorAll" in t))
250
252
  return !1;
251
- const o = e.querySelectorAll(
253
+ const o = t.querySelectorAll(
252
254
  `[esd-extension-block-id="${m.CUSTOM_ATTRIBUTE}"]`
253
255
  );
254
256
  if (o.length === 0)
@@ -269,36 +271,36 @@ function re(e, t, n) {
269
271
  i.slice(0, c).forEach((l, a) => {
270
272
  if (!("querySelector" in l))
271
273
  return;
272
- const d = oe(u, n[a]);
274
+ const d = re(u, n[a]);
273
275
  if (d === null)
274
276
  return;
275
277
  const f = l.querySelector("p") ?? null;
276
- b(t, f, d) && (s = !0);
278
+ b(e, f, d) && (s = !0);
277
279
  });
278
280
  }), s;
279
281
  }
280
- function h(e, t, n) {
281
- if (!("querySelectorAll" in e))
282
+ function I(t, e, n) {
283
+ if (!("querySelectorAll" in t))
282
284
  return !1;
283
- const o = e.querySelectorAll(
285
+ const o = t.querySelectorAll(
284
286
  `[esd-extension-block-id="${m.IMAGE}"]`
285
- ), r = e.querySelectorAll(
287
+ ), r = t.querySelectorAll(
286
288
  `[esd-extension-block-id="${m.NAME}"]`
287
- ), s = e.querySelectorAll(
289
+ ), s = t.querySelectorAll(
288
290
  `[esd-extension-block-id="${m.PRICE}"]`
289
- ), i = e.querySelectorAll(
291
+ ), i = t.querySelectorAll(
290
292
  `[esd-extension-block-id="${m.OLD_PRICE}"]`
291
- ), u = e.querySelectorAll(
293
+ ), u = t.querySelectorAll(
292
294
  `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
293
- ), c = e.querySelectorAll(
295
+ ), c = t.querySelectorAll(
294
296
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
295
- ), l = e.querySelectorAll(
297
+ ), l = t.querySelectorAll(
296
298
  `[esd-extension-block-id="${m.BUTTON}"]`
297
299
  ), a = Math.min(o.length, n.length);
298
300
  let d = !1;
299
301
  for (let f = 0; f < a; f++) {
300
- const p = ne({
301
- documentModifier: t,
302
+ const p = oe({
303
+ documentModifier: e,
302
304
  product: n[f],
303
305
  imageEl: o[f] ?? null,
304
306
  nameEl: r[f] ?? null,
@@ -310,23 +312,23 @@ function h(e, t, n) {
310
312
  });
311
313
  d = d || p;
312
314
  }
313
- return re(e, t, n) && (d = !0), d;
315
+ return ie(t, e, n) && (d = !0), d;
314
316
  }
315
- function ge(e) {
316
- const { currentNode: t, documentModifier: n, products: o } = e;
317
- if (!t || !("querySelectorAll" in t))
317
+ function Se(t) {
318
+ const { currentNode: e, documentModifier: n, products: o } = t;
319
+ if (!e || !("querySelectorAll" in e))
318
320
  return !1;
319
- const r = j(t);
321
+ const r = j(e);
320
322
  if (!("querySelectorAll" in r) || r.querySelectorAll(
321
323
  `[esd-extension-block-id="${m.IMAGE}"]`
322
324
  ).length !== o.length)
323
325
  return !1;
324
- let i = h(r, n, o);
325
- const u = C(t), c = S.getConfig(t);
326
- if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
327
- const l = t.querySelector(O);
326
+ let i = I(r, n, o);
327
+ const u = C(e), c = S.getConfig(e);
328
+ if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in e) {
329
+ const l = e.querySelector(O);
328
330
  if (l) {
329
- const a = h(
331
+ const a = I(
330
332
  l,
331
333
  n,
332
334
  o
@@ -336,22 +338,22 @@ function ge(e) {
336
338
  }
337
339
  return i && n.apply(new g("Updated product content in-place")), !0;
338
340
  }
339
- function I(e, t, n) {
340
- if (!("querySelectorAll" in e))
341
+ function h(t, e, n) {
342
+ if (!("querySelectorAll" in t))
341
343
  return !1;
342
- const o = e.querySelectorAll(
344
+ const o = t.querySelectorAll(
343
345
  `[esd-extension-block-id="${m.PRICE}"]`
344
- ), r = e.querySelectorAll(
346
+ ), r = t.querySelectorAll(
345
347
  `[esd-extension-block-id="${m.OLD_PRICE}"]`
346
- ), s = e.querySelectorAll(
348
+ ), s = t.querySelectorAll(
347
349
  `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
348
- ), i = e.querySelectorAll(
350
+ ), i = t.querySelectorAll(
349
351
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
350
352
  ), u = Math.min(o.length, n.length);
351
353
  let c = !1;
352
354
  for (let l = 0; l < u; l++)
353
355
  v({
354
- documentModifier: t,
356
+ documentModifier: e,
355
357
  product: n[l],
356
358
  priceEl: o[l] ?? null,
357
359
  oldPriceEl: r[l] ?? null,
@@ -360,29 +362,29 @@ function I(e, t, n) {
360
362
  }) && (c = !0);
361
363
  return c;
362
364
  }
363
- function Se(e) {
364
- const { currentNode: t, documentModifier: n } = e;
365
- if (!t || !("querySelectorAll" in t))
365
+ function Ee(t) {
366
+ const { currentNode: e, documentModifier: n } = t;
367
+ if (!e || !("querySelectorAll" in e))
366
368
  return !1;
367
- if (X(t))
369
+ if (z(e))
368
370
  return !0;
369
371
  const r = P().recommendationProducts;
370
372
  if (r.length === 0)
371
373
  return !1;
372
- const s = j(t);
373
- let i = I(s, n, r);
374
- const u = C(t), c = S.getConfig(t);
375
- if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in t) {
376
- const l = t.querySelector(O);
374
+ const s = j(e);
375
+ let i = h(s, n, r);
376
+ const u = C(e), c = S.getConfig(e);
377
+ if (u !== "list" && c.mobileLayoutEnabled && "querySelector" in e) {
378
+ const l = e.querySelector(O);
377
379
  if (l) {
378
- const a = I(l, n, r);
380
+ const a = h(l, n, r);
379
381
  i = i || a;
380
382
  }
381
383
  }
382
384
  return i && n.apply(new g("Updated price formatting in-place")), i;
383
385
  }
384
- function Ee(e) {
385
- const { currentNode: t, documentModifier: n, currency: o } = e, r = A(t);
386
+ function Pe(t) {
387
+ const { currentNode: e, documentModifier: n, currency: o } = t, r = A(e);
386
388
  if (!r)
387
389
  return;
388
390
  const s = o.alignment === "before" ? "0" : "1", i = (u, c) => {
@@ -391,16 +393,16 @@ function Ee(e) {
391
393
  i(y.CURRENCY, o.code), i(y.SYMBOL, o.symbol), i(y.ALIGNMENT, s), i(y.THOUSAND_SEPARATOR, o.thousandSeparator), i(y.DECIMAL_SEPARATOR, o.decimalSeparator), i(y.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new g("Update currency attributes"));
392
394
  }
393
395
  export {
394
- be as adjustProductsToSize,
396
+ ge as adjustProductsToSize,
395
397
  q as formatProductPrice,
396
398
  A as getBlockElement,
397
399
  x as getCardComposition,
398
400
  C as getCurrentLayout,
399
- X as isPartnerManagedBlock,
400
- pe as regenerateMobileProductRows,
401
- ye as regenerateProductRowsWithStyles,
402
- Ee as setCurrencyAttributes,
403
- Se as updatePricesInPlace,
404
- ge as updateProductContentInPlace,
405
- ne as updateSingleProductContent
401
+ z as isPartnerManagedBlock,
402
+ ye as regenerateMobileProductRows,
403
+ be as regenerateProductRowsWithStyles,
404
+ Pe as setCurrencyAttributes,
405
+ Ee as updatePricesInPlace,
406
+ Se as updateProductContentInPlace,
407
+ oe as updateSingleProductContent
406
408
  };
@@ -1,46 +1,47 @@
1
1
  import { ExtensionBuilder as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { RecommendationBlock as m } from "./block.js";
3
- import { RecommendationBlockControl as n } from "./controls/main/index.js";
3
+ import n from "./canvasPreview.css.js";
4
+ import { RecommendationBlockControl as i } from "./controls/main/index.js";
4
5
  import "./constants/selectors.js";
5
6
  import "./store/recommendation.js";
6
7
  import "./utils/captureStyleTemplates.js";
7
- import { NameControls as i } from "./controls/name/index.js";
8
- import { PriceControls as e } from "./controls/price/index.js";
9
- import { OldPriceControls as s } from "./controls/oldPrice/index.js";
10
- import { OmnibusPriceControls as l } from "./controls/omnibusPrice/index.js";
11
- import { OmnibusDiscountControls as p } from "./controls/omnibusDiscount/index.js";
12
- import { ButtonControls as a } from "./controls/button/index.js";
13
- import { ImageControls as c } from "./controls/image/index.js";
8
+ import { NameControls as e } from "./controls/name/index.js";
9
+ import { PriceControls as s } from "./controls/price/index.js";
10
+ import { OldPriceControls as l } from "./controls/oldPrice/index.js";
11
+ import { OmnibusPriceControls as p } from "./controls/omnibusPrice/index.js";
12
+ import { OmnibusDiscountControls as a } from "./controls/omnibusDiscount/index.js";
13
+ import { ButtonControls as c } from "./controls/button/index.js";
14
+ import { ImageControls as f } from "./controls/image/index.js";
14
15
  import { CustomAttributeControls as C } from "./controls/customAttribute/index.js";
15
- import { SpacingControl as f } from "./controls/spacing/index.js";
16
- import { CardBackgroundColorControl as d } from "./controls/cardBackground/index.js";
17
- import { RecommendationCardCompositionControl as u } from "./controls/cardComposition/index.js";
18
- import { SyncInfoMessageControl as g } from "./controls/syncInfoMessage.js";
19
- import { RecommendationIconsRegistry as R } from "./iconsRegistry.js";
20
- import y from "./recommendation.css.js";
21
- import { SettingsPanel as B } from "./settingsPanel.js";
22
- const b = [
23
- i,
16
+ import { SpacingControl as d } from "./controls/spacing/index.js";
17
+ import { CardBackgroundColorControl as u } from "./controls/cardBackground/index.js";
18
+ import { RecommendationCardCompositionControl as g } from "./controls/cardComposition/index.js";
19
+ import { SyncInfoMessageControl as y } from "./controls/syncInfoMessage.js";
20
+ import { RecommendationIconsRegistry as P } from "./iconsRegistry.js";
21
+ import R from "./recommendation.css.js";
22
+ import { SettingsPanel as S } from "./settingsPanel.js";
23
+ const w = [
24
24
  e,
25
25
  s,
26
26
  l,
27
27
  p,
28
28
  a,
29
29
  c,
30
- C
31
- ], P = [
32
- n,
33
- d,
34
30
  f,
31
+ C
32
+ ], B = [
33
+ i,
35
34
  u,
36
- g
37
- ], S = [
38
- ...P,
39
- ...b.flatMap((o) => Object.values(o))
40
- ], Q = S.reduce(
35
+ d,
36
+ g,
37
+ y
38
+ ], b = [
39
+ ...B,
40
+ ...w.flatMap((o) => Object.values(o))
41
+ ], U = b.reduce(
41
42
  (o, t) => o.addControl(t),
42
- new r().addBlock(m).withSettingsPanelRegistry(B)
43
- ).addStyles(y).withIconsRegistry(R).build();
43
+ new r().addBlock(m).withSettingsPanelRegistry(S)
44
+ ).addStyles(R).withPreviewStyles(n).withIconsRegistry(P).build();
44
45
  export {
45
- Q as default
46
+ U as default
46
47
  };