@useinsider/guido 2.0.0-beta.e73ba15 → 2.0.0-beta.fb0f99d

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 (35) hide show
  1. package/dist/@types/config/schemas.js +53 -39
  2. package/dist/components/organisms/email-preview/amp/AmpToggle.vue.js +2 -2
  3. package/dist/components/organisms/header/RightSlot.vue2.js +10 -10
  4. package/dist/composables/useConfig.js +29 -27
  5. package/dist/composables/useSave.js +13 -11
  6. package/dist/extensions/Blocks/Recommendation/constants/layout.js +9 -4
  7. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +21 -41
  8. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +37 -48
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +78 -50
  10. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +72 -70
  11. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +1 -1
  12. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +3 -3
  13. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +60 -80
  14. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +16 -14
  15. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +27 -16
  16. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +46 -0
  17. package/dist/extensions/Blocks/Unsubscribe/extension.js +9 -9
  18. package/dist/extensions/Blocks/common-control.js +6 -7
  19. package/dist/guido.css +1 -1
  20. package/dist/src/@types/config/index.d.ts +2 -2
  21. package/dist/src/@types/config/schemas.d.ts +26 -0
  22. package/dist/src/@types/config/types.d.ts +7 -1
  23. package/dist/src/composables/useConfig.d.ts +6 -0
  24. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  25. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +10 -0
  26. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -10
  27. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +6 -17
  28. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -5
  29. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  30. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +77 -0
  31. package/dist/src/extensions/Blocks/common-control.d.ts +1 -1
  32. package/dist/src/stores/config.d.ts +147 -1
  33. package/dist/static/styles/components/button.css.js +1 -1
  34. package/dist/stores/config.js +7 -0
  35. package/package.json +1 -1
@@ -1,29 +1,31 @@
1
- var f = Object.defineProperty;
2
- var C = (a, n, t) => n in a ? f(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
- var c = (a, n, t) => C(a, typeof n != "symbol" ? n + "" : n, t);
4
- import { ModificationDescription as d } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as g } from "../../../common-control.js";
6
- import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as A, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as N, ATTR_PRODUCT_OMNIBUS_PRICE as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as D, ATTR_PRODUCT_BUTTON as v } from "../../constants/selectors.js";
7
- import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
8
- const V = "ui-elements-recommendation-card-composition", S = {
1
+ var T = Object.defineProperty;
2
+ var C = (a, n, t) => n in a ? T(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
3
+ var l = (a, n, t) => C(a, typeof n != "symbol" ? n + "" : n, t);
4
+ import { ModificationDescription as u } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as f } from "../../../common-control.js";
6
+ import { ATTR_PRODUCT_IMAGE as O, ATTR_PRODUCT_NAME as g, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_OLD_PRICE as A, ATTR_PRODUCT_OMNIBUS_PRICE as D, ATTR_PRODUCT_OMNIBUS_DISCOUNT as N, ATTR_PRODUCT_BUTTON as V } from "../../constants/selectors.js";
7
+ import { useRecommendationExtensionStore as E } from "../../store/recommendation.js";
8
+ import { getTableDisplayValue as I } from "../../utils/tagName.js";
9
+ import { getCurrentLayout as P } from "../main/utils.js";
10
+ const S = "ui-elements-recommendation-card-composition", k = {
9
11
  ORDERABLE: "cardComposition"
10
- }, b = ".recommendation-attribute-row", P = ".product-card-wrapper > tbody", y = "data-card-composition", p = "data-attribute-type", h = "data-visibility", s = [
12
+ }, c = ".recommendation-attribute-row", v = ".product-card-wrapper > tbody", _ = "data-card-composition", d = "data-attribute-type", m = "data-visibility", s = [
11
13
  { key: O, label: "Product Image", visible: !0 },
12
- { key: A, label: "Product Name", visible: !0 },
14
+ { key: g, label: "Product Name", visible: !0 },
13
15
  { key: R, label: "Product Price", visible: !0 },
14
- { key: N, label: "Product Original Price", visible: !0 },
15
- { key: E, label: "Omnibus Price", visible: !1 },
16
- { key: D, label: "Omnibus Discount", visible: !1 },
17
- { key: v, label: "Product Button", visible: !0 }
16
+ { key: A, label: "Product Original Price", visible: !0 },
17
+ { key: D, label: "Omnibus Price", visible: !1 },
18
+ { key: N, label: "Omnibus Discount", visible: !1 },
19
+ { key: V, label: "Product Button", visible: !0 }
18
20
  ];
19
- class x extends g {
21
+ class H extends f {
20
22
  constructor() {
21
23
  super(...arguments);
22
- c(this, "store", I());
23
- c(this, "unsubscribeOrientation", null);
24
+ l(this, "store", E());
25
+ l(this, "unsubscribeOrientation", null);
24
26
  }
25
27
  getId() {
26
- return V;
28
+ return S;
27
29
  }
28
30
  getTemplate() {
29
31
  const t = s.map((e) => ({
@@ -34,7 +36,7 @@ class x extends g {
34
36
  return `
35
37
  <div class="container" data-card-composition-control>
36
38
  ${this._GuLabel({ text: "Card Element Order & Visibility" })}
37
- ${this._GuOrderable(S.ORDERABLE, t)}
39
+ ${this._GuOrderable(k.ORDERABLE, t)}
38
40
  </div>
39
41
  `;
40
42
  }
@@ -85,7 +87,7 @@ class x extends g {
85
87
  _readCompositionFromNode() {
86
88
  if (!this.currentNode || !("getAttribute" in this.currentNode))
87
89
  return s.map((e) => e.key);
88
- const t = this.currentNode.getAttribute(y);
90
+ const t = this.currentNode.getAttribute(_);
89
91
  return t ? t.split(",").filter(Boolean) : s.map((e) => e.key);
90
92
  }
91
93
  /**
@@ -101,7 +103,7 @@ class x extends g {
101
103
  _readVisibilityFromRows() {
102
104
  if (!this.currentNode)
103
105
  return this._getDefaultVisibilities();
104
- const t = Array.from(this.currentNode.querySelectorAll(b)), e = this._extractVisibilityFromRows(t);
106
+ const t = Array.from(this.currentNode.querySelectorAll(c)), e = this._extractVisibilityFromRows(t);
105
107
  return this._mergeWithDefaults(e);
106
108
  }
107
109
  /**
@@ -118,7 +120,7 @@ class x extends g {
118
120
  return t.forEach((i) => {
119
121
  if (!("getAttribute" in i))
120
122
  return;
121
- const o = i.getAttribute(p), r = i.getAttribute(h);
123
+ const o = i.getAttribute(d), r = i.getAttribute(m);
122
124
  o && r !== null && (e[o] = this._parseVisibilityValue(r));
123
125
  }), e;
124
126
  }
@@ -146,7 +148,7 @@ class x extends g {
146
148
  if (!this.currentNode)
147
149
  return;
148
150
  const e = this._getCurrentLayout();
149
- this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(y, t.join(",")).apply(new d("Update card composition")), e === "vertical" && this._reorderProductAttributes(t);
151
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(_, t.join(",")).apply(new u("Update card composition")), e === "vertical" && this._reorderProductAttributes(t);
150
152
  }
151
153
  /**
152
154
  * Reorders attribute rows within each product card based on composition order
@@ -155,21 +157,21 @@ class x extends g {
155
157
  _reorderProductAttributes(t) {
156
158
  if (!this.currentNode)
157
159
  return;
158
- const e = this.currentNode.querySelectorAll(P);
160
+ const e = this.currentNode.querySelectorAll(v);
159
161
  if (!(e != null && e.length))
160
162
  return;
161
163
  const i = this.api.getDocumentModifier();
162
164
  e.forEach((o) => {
163
165
  const r = this._buildCompositionHtml(o, t);
164
166
  i.modifyHtml(o).setInnerHtml(r);
165
- }), i.apply(new d("Reorder product attributes"));
167
+ }), i.apply(new u("Reorder product attributes"));
166
168
  }
167
169
  /**
168
170
  * Builds HTML string with attributes ordered according to composition
169
171
  */
170
172
  _buildCompositionHtml(t, e) {
171
173
  return e.reduce((i, o) => {
172
- const r = t.querySelector(`${b}[${p}="${o}"]`);
174
+ const r = t.querySelector(`${c}[${d}="${o}"]`);
173
175
  return r && "getOuterHTML" in r ? i + r.getOuterHTML() : i;
174
176
  }, "");
175
177
  }
@@ -182,33 +184,20 @@ class x extends g {
182
184
  _applyVisibilityToBlock(t, e) {
183
185
  if (!this.currentNode)
184
186
  return;
185
- const i = this.currentNode.querySelectorAll(`${b}[${p}="${t}"]`);
187
+ const i = this.currentNode.querySelectorAll(`${c}[${d}="${t}"]`);
186
188
  if (!(i != null && i.length))
187
189
  return;
188
- const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, m = this.api.getDocumentModifier();
189
- i.forEach((l) => {
190
- let u = "TR";
191
- if ("tagName" in l && l.tagName)
192
- u = l.tagName.toUpperCase();
193
- else if ("getTagName" in l) {
194
- const _ = l;
195
- typeof _.getTagName == "function" && (u = _.getTagName().toUpperCase());
196
- }
197
- const T = e ? u === "TD" || u === "BLOCK_IMAGE" || u === "BLOCK_BUTTON" ? "table-cell" : "table-row" : "none";
198
- m.modifyHtml(l).setStyle("display", T).setAttribute(h, o);
199
- }), m.apply(new d(r));
190
+ const o = e ? "1" : "0", r = `Set ${t} visibility to ${e ? "visible" : "hidden"}`, b = this.api.getDocumentModifier();
191
+ i.forEach((p) => {
192
+ const y = I(p), h = e ? y : "none";
193
+ b.modifyHtml(p).setStyle("display", h).setAttribute(m, o);
194
+ }), b.apply(new u(r));
200
195
  }
201
196
  /**
202
197
  * Gets the current layout orientation from store or DOM
203
198
  */
204
199
  _getCurrentLayout() {
205
- const t = this.store.recommendationConfigs.orientation;
206
- if (t)
207
- return t;
208
- if (!this.currentNode || !("querySelector" in this.currentNode))
209
- return "vertical";
210
- const e = this.currentNode.querySelector(".ins-recommendation-v3-block-v2");
211
- return !e || !("getAttribute" in e) ? "vertical" : e.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
200
+ return this.store.recommendationConfigs.orientation || P(this.currentNode);
212
201
  }
213
202
  /**
214
203
  * Updates orderable state based on layout orientation
@@ -238,6 +227,6 @@ class x extends g {
238
227
  }
239
228
  }
240
229
  export {
241
- V as COMPOSITION_CONTROL_BLOCK_ID,
242
- x as RecommendationCardCompositionControl
230
+ S as COMPOSITION_CONTROL_BLOCK_ID,
231
+ H as RecommendationCardCompositionControl
243
232
  };
@@ -1,40 +1,54 @@
1
- var l = Object.defineProperty;
2
- var a = (s, n, t) => n in s ? l(s, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[n] = t;
3
- var r = (s, n, t) => a(s, typeof n != "symbol" ? n + "" : n, t);
1
+ var a = Object.defineProperty;
2
+ var c = (n, r, o) => r in n ? a(n, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[r] = o;
3
+ var e = (n, r, o) => c(n, typeof r != "symbol" ? r + "" : r, o);
4
4
  import { CommonControl as m } from "../../../common-control.js";
5
- import { useRecommendationExtensionStore as c } from "../../store/recommendation.js";
6
- import { AlgorithmControl as C } from "./algorithm.js";
7
- import { ALGORITHM_CONTROL_ID as U } from "./algorithm.js";
8
- import { CurrencyControl as h } from "./currency.js";
9
- import { CURRENCY_CONTROL_ID as $ } from "./currency.js";
10
- import { FiltersControl as u } from "./filters.js";
11
- import { FILTERS_CONTROL_ID as F } from "./filters.js";
12
- import { LocaleControl as f } from "./locale.js";
13
- import { LOCALE_CONTROL_ID as A } from "./locale.js";
14
- import { ProductLayoutControl as d } from "./productLayout.js";
15
- import { PRODUCT_LAYOUT_CONTROL_ID as v } from "./productLayout.js";
16
- import { ShuffleControl as p } from "./shuffle.js";
5
+ import { useRecommendationExtensionStore as h } from "../../store/recommendation.js";
6
+ import { AlgorithmControl as u } from "./algorithm.js";
7
+ import { ALGORITHM_CONTROL_ID as x } from "./algorithm.js";
8
+ import { CurrencyControl as C } from "./currency.js";
9
+ import { CURRENCY_CONTROL_ID as k } from "./currency.js";
10
+ import { FiltersControl as f } from "./filters.js";
11
+ import { FILTERS_CONTROL_ID as A } from "./filters.js";
12
+ import { LocaleControl as d } from "./locale.js";
13
+ import { LOCALE_CONTROL_ID as z } from "./locale.js";
14
+ import { ProductLayoutControl as p } from "./productLayout.js";
15
+ import { PRODUCT_LAYOUT_CONTROL_ID as Y } from "./productLayout.js";
16
+ import { ShuffleControl as R } from "./shuffle.js";
17
17
  import { SHUFFLE_CONTROL_ID as B } from "./shuffle.js";
18
- const R = "ui-elements-recommendation-block";
19
- class I extends m {
18
+ import { useDebounceFn as _ } from "../../../../../node_modules/@vueuse/shared/index.js";
19
+ const y = /* @__PURE__ */ new Set([
20
+ "size",
21
+ "strategy",
22
+ "filters",
23
+ "productIds",
24
+ "language",
25
+ "shuffleProducts"
26
+ ]), L = "ui-elements-recommendation-block";
27
+ class P extends m {
20
28
  constructor() {
21
29
  super(...arguments);
22
- r(this, "store", c());
23
- r(this, "storeUnsubscription", () => {
30
+ e(this, "store", h());
31
+ e(this, "storeUnsubscription", () => {
24
32
  });
25
33
  // Sub-control instances for lifecycle management
26
- r(this, "algorithmControl", null);
27
- r(this, "localeControl", null);
28
- r(this, "currencyControl", null);
29
- r(this, "productLayoutControl", null);
30
- r(this, "filtersControl", null);
31
- r(this, "shuffleControl", null);
34
+ e(this, "algorithmControl", null);
35
+ e(this, "localeControl", null);
36
+ e(this, "currencyControl", null);
37
+ e(this, "productLayoutControl", null);
38
+ e(this, "filtersControl", null);
39
+ e(this, "shuffleControl", null);
40
+ /**
41
+ * Debounced product fetch to prevent rapid API calls during config changes
42
+ */
43
+ e(this, "_debouncedFetchProducts", _(() => {
44
+ this.store.fetchRecommendationProducts();
45
+ }, 500));
32
46
  }
33
47
  getId() {
34
- return R;
48
+ return L;
35
49
  }
36
50
  getTemplate() {
37
- return this.algorithmControl = new C(), this.localeControl = new f(), this.currencyControl = new h(), this.productLayoutControl = new d(), this.filtersControl = new u(), this.shuffleControl = new p(), `
51
+ return this.algorithmControl = new u(), this.localeControl = new d(), this.currencyControl = new C(), this.productLayoutControl = new p(), this.filtersControl = new f(), this.shuffleControl = new R(), `
38
52
  <div class="recommendation-controls-container">
39
53
  ${this.algorithmControl.getTemplate()}
40
54
  ${this.localeControl.getTemplate()}
@@ -50,17 +64,26 @@ class I extends m {
50
64
  this.store.fetchRecommendationFilters(),
51
65
  this.store.fetchRecommendationCreateData(),
52
66
  this.store.fetchRecommendationProducts()
53
- ])).forEach((o, e) => {
54
- o.status === "rejected" && console.warn(`Recommendation block: ${[
67
+ ])).forEach((t, s) => {
68
+ t.status === "rejected" && console.warn(`Recommendation block: ${[
55
69
  "fetchRecommendationFilters",
56
70
  "fetchRecommendationCreateData",
57
71
  "fetchRecommendationProducts"
58
- ][e]} failed`, o.reason);
72
+ ][s]} failed`, t.reason);
59
73
  }), this._initializeSubControls(), this._listenStateUpdates();
60
74
  }
61
75
  onDestroy() {
62
- var t, o, e, i;
63
- this.storeUnsubscription(), (o = (t = this.filtersControl) == null ? void 0 : t.onDestroy) == null || o.call(t), (i = (e = this.productLayoutControl) == null ? void 0 : e.onDestroy) == null || i.call(e);
76
+ this.storeUnsubscription(), [
77
+ this.algorithmControl,
78
+ this.localeControl,
79
+ this.currencyControl,
80
+ this.productLayoutControl,
81
+ this.filtersControl,
82
+ this.shuffleControl
83
+ ].forEach((t) => {
84
+ var s;
85
+ return (s = t == null ? void 0 : t.onDestroy) == null ? void 0 : s.call(t);
86
+ });
64
87
  }
65
88
  /**
66
89
  * Initialize all sub-controls with the shared API context
@@ -74,33 +97,38 @@ class I extends m {
74
97
  this.productLayoutControl,
75
98
  this.filtersControl,
76
99
  this.shuffleControl
77
- ].forEach((o) => {
78
- var e;
79
- o && (o.api = this.api, o.currentNode = this.currentNode, (e = o.onRender) == null || e.call(o));
100
+ ].forEach((t) => {
101
+ var s;
102
+ t && (t.api = this.api, t.currentNode = this.currentNode, (s = t.onRender) == null || s.call(t));
80
103
  });
81
104
  }
82
105
  /**
83
106
  * Listen to store changes that require product refresh
107
+ * Only triggers for meaningful config changes (size, strategy, filters, etc.)
108
+ * Uses debounce to prevent rapid API calls
84
109
  */
85
110
  _listenStateUpdates() {
86
- this.storeUnsubscription = this.store.$subscribe((t) => {
87
- "payload" in t && t.payload.recommendationConfigs && this.store.fetchRecommendationProducts();
111
+ this.storeUnsubscription = this.store.$subscribe((o) => {
112
+ if ("payload" in o) {
113
+ const t = o.payload.recommendationConfigs;
114
+ t && Object.keys(t).some((l) => y.has(l)) && this._debouncedFetchProducts();
115
+ }
88
116
  });
89
117
  }
90
118
  }
91
119
  export {
92
- U as ALGORITHM_CONTROL_ID,
93
- C as AlgorithmControl,
94
- R as CONTROL_BLOCK_ID,
95
- $ as CURRENCY_CONTROL_ID,
96
- h as CurrencyControl,
97
- F as FILTERS_CONTROL_ID,
98
- u as FiltersControl,
99
- A as LOCALE_CONTROL_ID,
100
- f as LocaleControl,
101
- v as PRODUCT_LAYOUT_CONTROL_ID,
102
- d as ProductLayoutControl,
103
- I as RecommendationBlockControl,
120
+ x as ALGORITHM_CONTROL_ID,
121
+ u as AlgorithmControl,
122
+ L as CONTROL_BLOCK_ID,
123
+ k as CURRENCY_CONTROL_ID,
124
+ C as CurrencyControl,
125
+ A as FILTERS_CONTROL_ID,
126
+ f as FiltersControl,
127
+ z as LOCALE_CONTROL_ID,
128
+ d as LocaleControl,
129
+ Y as PRODUCT_LAYOUT_CONTROL_ID,
130
+ p as ProductLayoutControl,
131
+ P as RecommendationBlockControl,
104
132
  B as SHUFFLE_CONTROL_ID,
105
- p as ShuffleControl
133
+ R as ShuffleControl
106
134
  };
@@ -1,112 +1,114 @@
1
1
  import { ModificationDescription as s } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CONTAINER_SELECTOR as y } from "../../constants/selectors.js";
3
- import { useRecommendationExtensionStore as S } from "../../store/recommendation.js";
4
- import { prepareProductRows as A } from "../../templates/index.js";
5
- import { DEFAULT_CARD_COMPOSITION as d, getDefaultProducts as b } from "../../templates/utils.js";
6
- const f = "ins-recommendation-v3-block-v2";
7
- function p(e) {
8
- if (!e)
2
+ import { CONTAINER_SELECTOR as S } from "../../constants/selectors.js";
3
+ import { useRecommendationExtensionStore as A } from "../../store/recommendation.js";
4
+ import { prepareProductRows as b } from "../../templates/index.js";
5
+ import { hasGetStyle as d, isTdNode as C } from "../../utils/tagName.js";
6
+ import { DEFAULT_CARD_COMPOSITION as f, getDefaultProducts as h } from "../../templates/utils.js";
7
+ const m = "ins-recommendation-v3-block-v2";
8
+ function p(r) {
9
+ if (!r)
9
10
  return null;
10
- if ("getAttribute" in e) {
11
- const t = e.getAttribute("class");
12
- if (t && t.includes(f))
13
- return e;
11
+ if ("getAttribute" in r) {
12
+ const t = r.getAttribute("class");
13
+ if (t && t.includes(m))
14
+ return r;
14
15
  }
15
- return "querySelector" in e ? e.querySelector(`.${f}`) : null;
16
+ return "querySelector" in r ? r.querySelector(`.${m}`) : null;
16
17
  }
17
- function m(e) {
18
- const t = p(e);
18
+ function g(r) {
19
+ const t = p(r);
19
20
  return !t || !("getAttribute" in t) ? "vertical" : t.getAttribute("data-layout") === "horizontal" ? "horizontal" : "vertical";
20
21
  }
21
- function C(e) {
22
- const t = p(e);
22
+ function w(r) {
23
+ const t = p(r);
23
24
  if (!t || !("getAttribute" in t))
24
- return d;
25
- const r = t.getAttribute("data-card-composition");
26
- return r ? r.split(",").filter(Boolean) : d;
25
+ return f;
26
+ const e = t.getAttribute("data-card-composition");
27
+ return e ? e.split(",").filter(Boolean) : f;
27
28
  }
28
- function R(e) {
29
- const { currentNode: t, documentModifier: r, afterRegenerate: o } = e;
29
+ function I(r) {
30
+ const { currentNode: t, documentModifier: e, afterRegenerate: o } = r;
30
31
  if (!t || !("querySelector" in t))
31
32
  return;
32
- const a = t.querySelector(y);
33
+ const a = t.querySelector(S);
33
34
  if (!a)
34
35
  return;
35
- const c = S(), i = c.recommendationProducts.length > 0 ? c.recommendationProducts : b(), { cardsInRow: l } = c.recommendationConfigs, n = C(t), u = m(t), g = A(i, u, {
36
+ const n = A(), c = n.recommendationProducts.length > 0 ? n.recommendationProducts : h(), { cardsInRow: l } = n.recommendationConfigs, i = w(t), u = g(t), y = b(c, u, {
36
37
  productsPerRow: l,
37
- composition: n
38
+ composition: i
38
39
  });
39
- r.modifyHtml(a).setInnerHtml(g).apply(new s("Updated product")), o == null || o();
40
+ e.modifyHtml(a).setInnerHtml(y).apply(new s("Updated product")), o == null || o();
40
41
  }
41
- function h(e, t, r, o) {
42
- const c = `0 ${Math.floor(r / 2)}px`;
43
- let i = !1;
42
+ function E(r, t, e, o) {
43
+ const n = `0 ${Math.floor(e / 2)}px`;
44
+ let c = !1;
44
45
  return o === "vertical" ? Array.from(
45
- e.querySelectorAll(".attribute-cell")
46
- ).forEach((n) => {
47
- t.modifyHtml(n).setStyle("padding", c), i = !0;
46
+ r.querySelectorAll(".attribute-cell")
47
+ ).forEach((i) => {
48
+ t.modifyHtml(i).setStyle("padding", n), c = !0;
48
49
  }) : Array.from(
49
- e.querySelectorAll(".product-card-wrapper")
50
- ).forEach((n) => {
51
- "parentNode" in n && n.parentNode && typeof n.parentNode == "object" && "tagName" in n.parentNode && n.parentNode.tagName === "TD" && (t.modifyHtml(n.parentNode).setStyle("padding", c), i = !0);
52
- }), i;
53
- }
54
- function E(e, t, r) {
55
- const o = `${r}px`, a = Array.from(e.querySelectorAll(".spacer"));
56
- let c = !1;
57
- return a.forEach((i) => {
58
- t.modifyHtml(i).setStyle("height", o), c = !0;
50
+ r.querySelectorAll(".product-card-wrapper")
51
+ ).forEach((i) => {
52
+ const u = "parentNode" in i ? i.parentNode : null;
53
+ u && C(u) && (t.modifyHtml(u).setStyle("padding", n), c = !0);
59
54
  }), c;
60
55
  }
61
- function P(e) {
62
- const { currentNode: t, documentModifier: r } = e;
56
+ function k(r, t, e) {
57
+ const o = `${e}px`, a = Array.from(r.querySelectorAll(".spacer"));
58
+ let n = !1;
59
+ return a.forEach((c) => {
60
+ t.modifyHtml(c).setStyle("height", o), n = !0;
61
+ }), n;
62
+ }
63
+ function v(r) {
64
+ const { currentNode: t, documentModifier: e } = r;
63
65
  if (!t)
64
66
  return;
65
67
  const o = p(t);
66
68
  if (!o || !("getAttribute" in o))
67
69
  return;
68
- const a = o.getAttribute("data-column-spacing"), c = o.getAttribute("data-row-spacing"), i = m(t);
70
+ const a = o.getAttribute("data-column-spacing"), n = o.getAttribute("data-row-spacing"), c = g(t);
69
71
  let l = !1;
70
72
  if (a) {
71
- const n = parseInt(a);
72
- Number.isNaN(n) || (l = h(
73
+ const i = parseInt(a);
74
+ Number.isNaN(i) || (l = E(
73
75
  t,
74
- r,
75
- n,
76
- i
76
+ e,
77
+ i,
78
+ c
77
79
  ));
78
80
  }
79
- if (c) {
80
- const n = parseInt(c);
81
- if (!Number.isNaN(n)) {
82
- const u = E(t, r, n);
81
+ if (n) {
82
+ const i = parseInt(n);
83
+ if (!Number.isNaN(i)) {
84
+ const u = k(t, e, i);
83
85
  l = l || u;
84
86
  }
85
87
  }
86
- l && r.apply(new s("Reapply spacing after regeneration"));
88
+ l && e.apply(new s("Reapply spacing after regeneration"));
87
89
  }
88
- function H(e) {
89
- if (!e)
90
+ function x(r) {
91
+ if (!r)
90
92
  return null;
91
- const t = e.querySelector(".product-card-segment"), r = e.querySelector(".product-card-wrapper");
93
+ const t = r.querySelector(".product-card-segment"), e = r.querySelector(".product-card-wrapper");
92
94
  let o = null;
93
- return t && "getStyle" in t && (o = t.getStyle("background-color")), (!o || o === "transparent") && r && "getStyle" in r && (o = r.getStyle("background-color")), o;
95
+ return t && d(t) && (o = t.getStyle("background-color") ?? null), (!o || o === "transparent") && e && d(e) && (o = e.getStyle("background-color") ?? null), o;
94
96
  }
95
- function I(e) {
96
- const { currentNode: t, documentModifier: r, bgColor: o, layout: a } = e;
97
+ function O(r) {
98
+ const { currentNode: t, documentModifier: e, bgColor: o, layout: a } = r;
97
99
  if (!o || o === "transparent" || !t)
98
100
  return;
99
- const c = a === "vertical" ? ".product-card-segment" : ".product-card-wrapper", i = Array.from(t.querySelectorAll(c));
100
- i.length !== 0 && (i.forEach((l) => {
101
- r.modifyHtml(l).setStyle("background-color", o);
102
- }), r.apply(new s("Apply card background color")));
101
+ const n = a === "vertical" ? ".product-card-segment" : ".product-card-wrapper", c = Array.from(t.querySelectorAll(n));
102
+ c.length !== 0 && (c.forEach((l) => {
103
+ e.modifyHtml(l).setStyle("background-color", o);
104
+ }), e.apply(new s("Apply card background color")));
103
105
  }
104
106
  export {
105
- I as applyCardBackgroundColor,
107
+ O as applyCardBackgroundColor,
106
108
  p as getBlockElement,
107
- C as getCardComposition,
108
- H as getCurrentCardBackgroundColor,
109
- m as getCurrentLayout,
110
- P as reapplySpacing,
111
- R as regenerateProductRows
109
+ w as getCardComposition,
110
+ x as getCurrentCardBackgroundColor,
111
+ g as getCurrentLayout,
112
+ v as reapplySpacing,
113
+ I as regenerateProductRows
112
114
  };
@@ -64,7 +64,7 @@ class b extends a {
64
64
  }
65
65
  _listenToFormUpdates() {
66
66
  this.api.onValueChanged("omnibusDiscountTextAfter", (t) => {
67
- this._onTextChange(t);
67
+ typeof t == "string" && this._onTextChange(t);
68
68
  });
69
69
  }
70
70
  }
@@ -5,7 +5,7 @@ import { RecommendationControlId as d } from "../../constants/controlIds.js";
5
5
  import { CONTAINER_SELECTOR as T } from "../../constants/selectors.js";
6
6
  import { preserveTextStyles as f } from "../../utils/preserveTextStyles.js";
7
7
  const i = "data-text-before", u = "", p = ".omnibus-text-before";
8
- class B extends l {
8
+ class g extends l {
9
9
  getId() {
10
10
  return d.OMNIBUS_DISCOUNT_TEXT_BEFORE;
11
11
  }
@@ -64,10 +64,10 @@ class B extends l {
64
64
  }
65
65
  _listenToFormUpdates() {
66
66
  this.api.onValueChanged("omnibusDiscountTextBefore", (e) => {
67
- this._onTextChange(e);
67
+ typeof e == "string" && this._onTextChange(e);
68
68
  });
69
69
  }
70
70
  }
71
71
  export {
72
- B as OmnibusDiscountTextBeforeControl
72
+ g as OmnibusDiscountTextBeforeControl
73
73
  };