@useinsider/guido 3.6.0-beta.3eeb930 → 3.6.0-beta.46ce04f

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 (32) hide show
  1. package/dist/composables/useHtmlValidator.js +131 -102
  2. package/dist/config/compiler/utils/recommendationCompilerUtils.js +28 -27
  3. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
  4. package/dist/config/migrator/recommendation/extractors.js +44 -22
  5. package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
  6. package/dist/config/migrator/recommendationMigrator.js +30 -31
  7. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +21 -15
  8. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +38 -24
  9. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +57 -52
  10. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +45 -34
  11. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
  12. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +62 -52
  13. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -67
  14. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
  15. package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
  16. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
  17. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
  18. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -2
  19. package/dist/extensions/Blocks/Recommendation/templates/index.js +5 -4
  20. package/dist/src/composables/useHtmlValidator.d.ts +9 -0
  21. package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
  22. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
  23. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
  24. package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
  25. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
  26. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  27. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
  28. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
  29. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
  30. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
  31. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
  32. package/package.json +1 -1
@@ -1,166 +1,195 @@
1
- import { useConfig as _ } from "./useConfig.js";
2
- import { TemplateTypes as H } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
1
+ import { useConfig as H } from "./useConfig.js";
2
+ import { getIgnoredRecommendationBlockIds as G } from "../config/compiler/utils/recommendationIgnoreUtils.js";
3
+ import { TemplateTypes as P } from "../enums/defaults.js";
4
+ import { DISPLAY_CONDITIONS_REGEX as $, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as j, CanNotMakeAnyChangesForRunningKey as q } from "../enums/html-validator.js";
4
5
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
- import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
- import { useRecommendationStore as K } from "../stores/recommendation.js";
9
- import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
10
- import { useHttp as U } from "./useHttp.js";
11
- import { useToaster as Y } from "./useToaster.js";
12
- import { useTranslations as Z } from "./useTranslations.js";
13
- const J = /recommendation-id="(\d+)"/g;
14
- function Q(a) {
15
- return [...a.matchAll(J)].map((u) => u[1]);
6
+ import { itemsBlockDynamicVariables as U } from "../extensions/Blocks/Items/enums/productEnums.js";
7
+ import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
8
+ import { useRecommendationExtensionStore as K } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
+ import { RecommendationRequiredFieldsKey as Y } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
10
+ import { useRecommendationStore as Z } from "../stores/recommendation.js";
11
+ import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
12
+ import { useHttp as Q } from "./useHttp.js";
13
+ import { useToaster as ee } from "./useToaster.js";
14
+ import { useTranslations as te } from "./useTranslations.js";
15
+ const se = /recommendation-id="(\d+)"/g;
16
+ function ne(o) {
17
+ return [...o.matchAll(se)].map((d) => d[1]);
16
18
  }
17
- function ee(a, u) {
18
- return u.some((d) => a.startsWith(`${d}_`));
19
+ function oe(o, d) {
20
+ return d.some((g) => o.startsWith(`${g}_`));
19
21
  }
20
- const ge = () => {
21
- var y, h;
22
- const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
23
- const t = await u(
22
+ const ie = /^(\d+)_\d+_(.+)$/;
23
+ function ae(o) {
24
+ const d = o.match(ie);
25
+ return d ? { recoId: d[1], attribute: d[2] } : null;
26
+ }
27
+ const we = () => {
28
+ var E, b;
29
+ const { showToaster: o } = ee(), { post: d } = Q(), { config: g } = H(), i = te(), v = Z(), p = K(), C = ((b = (E = g.value) == null ? void 0 : E.partner) == null ? void 0 : b.messageType) === P.transactional, w = async (e) => {
30
+ if (e.size === 0)
31
+ return /* @__PURE__ */ new Set();
32
+ try {
33
+ await p.fetchRecommendationFilters();
34
+ } catch {
35
+ return null;
36
+ }
37
+ const s = new Set(z);
38
+ return Object.values(p.filterList).forEach((t) => {
39
+ s.add(t.attributeName.toLowerCase());
40
+ }), s;
41
+ }, I = async (e) => {
42
+ const t = await d(
24
43
  "/newsletter/template-library/check-template-html-body",
25
- { html: z(e) }
26
- ), { status: n, message: l } = t.data;
27
- return n || a({
44
+ { html: J(e) }
45
+ ), { status: n, message: r } = t.data;
46
+ return n || o({
28
47
  type: c.Alert,
29
- message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
30
- }), r(M), l === r($) && a({
48
+ message: n === void 0 ? r : i("newsletter.invalid-url-link-for-toaster")
49
+ }), i(j), r === i(q) && o({
31
50
  type: c.Alert,
32
- message: r("newsletter.already-in-progress")
51
+ message: i("newsletter.already-in-progress")
33
52
  }), n;
34
- }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
53
+ }, A = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), R = (e, s) => {
35
54
  const t = e.match(/({%(.*?)%})/g);
36
55
  let n = !0;
37
- return t !== null && !p && t.forEach((l) => {
38
- const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
39
- if (o && o.length > 0) {
40
- const [i] = o;
41
- w(i) && !s.includes(i) && (a({
56
+ return t !== null && !C && t.forEach((r) => {
57
+ const a = r.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
58
+ if (a && a.length > 0) {
59
+ const [l] = a;
60
+ A(l) && !s.includes(l) && (o({
42
61
  type: c.Warning,
43
- message: r("custom-fields.invalid-custom-fields")
62
+ message: i("custom-fields.invalid-custom-fields")
44
63
  }), n = !1);
45
64
  }
46
65
  }), n;
47
- }, k = async (e, s, t) => {
48
- const n = t ? await b(e) : !0;
49
- return A(e, s) && n;
50
- }, x = (e) => e.length > 0 ? !0 : (a({
66
+ }, T = async (e, s, t) => {
67
+ const n = t ? await I(e) : !0;
68
+ return R(e, s) && n;
69
+ }, k = (e) => e.length > 0 ? !0 : (o({
51
70
  type: c.Warning,
52
- message: r("newsletter.html-content-is-empty")
53
- }), !1), I = (e) => {
71
+ message: i("newsletter.html-content-is-empty")
72
+ }), !1), x = (e) => {
54
73
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
55
- return s > t && a({
74
+ return s > t && o({
56
75
  type: c.Warning,
57
- message: r("custom-fields.missing-closing-braces")
58
- }), s < t && a({
76
+ message: i("custom-fields.missing-closing-braces")
77
+ }), s < t && o({
59
78
  type: c.Warning,
60
- message: r("custom-fields.missing-opening-braces")
79
+ message: i("custom-fields.missing-opening-braces")
61
80
  }), s === t;
62
- }, F = (e) => {
81
+ }, N = (e) => {
63
82
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
64
- return s || a({
83
+ return s || o({
65
84
  type: c.Warning,
66
- message: r("custom-fields.invalid-custom-fields")
85
+ message: i("custom-fields.invalid-custom-fields")
67
86
  }), s;
68
- }, T = (e, s) => {
69
- const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
70
- if (t && !p) {
71
- const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
72
- if (t.forEach((i) => {
73
- const m = i.slice(2, -2).trim().toLowerCase();
74
- (!n.has(m) || m === "") && !ee(m, l) && o.push(m);
75
- }), o.length > 0) {
76
- const i = `
87
+ }, B = (e, s, t, n) => {
88
+ const r = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
89
+ if (r && !C) {
90
+ const a = new Set(s.map((u) => u.toLowerCase())), l = ne(e), f = [];
91
+ if (r.forEach((u) => {
92
+ const m = u.slice(2, -2).trim().toLowerCase();
93
+ if (!(!a.has(m) || m === ""))
94
+ return;
95
+ const y = ae(m);
96
+ if (y && t.has(y.recoId)) {
97
+ if (!n || n.has(y.attribute))
98
+ return;
99
+ f.push(m);
100
+ return;
101
+ }
102
+ oe(m, l) || f.push(m);
103
+ }), f.length > 0) {
104
+ const u = `
77
105
  <ul>
78
- ${o.map((m) => `<li>${m}</li>`).join("")}
106
+ ${f.map((m) => `<li>${m}</li>`).join("")}
79
107
  </ul>
80
108
  `;
81
- return a({
109
+ return o({
82
110
  type: c.Alert,
83
- message: r("custom-fields.invalid-custom-fields") + i
111
+ message: i("custom-fields.invalid-custom-fields") + u
84
112
  }), !1;
85
113
  }
86
114
  }
87
115
  return !0;
88
- }, R = (e) => {
116
+ }, F = (e) => {
89
117
  const s = e.match(/{%(.*?)%}/g), t = [];
90
118
  let n = !0;
91
- if (s && s.forEach((l) => {
92
- const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
93
- (!o || l !== m) && !i && (a({
119
+ if (s && s.forEach((r) => {
120
+ const a = r.match($), l = r.match(X), f = (a == null ? void 0 : a.join("")) || "";
121
+ (!a || r !== f) && !l && (o({
94
122
  type: c.Alert,
95
- message: r("newsletter.display-conditions-invalid-syntax")
96
- }), n = !1), o && o.forEach((f) => {
97
- f.trim() === "=" && (a({
123
+ message: i("newsletter.display-conditions-invalid-syntax")
124
+ }), n = !1), a && a.forEach((u) => {
125
+ u.trim() === "=" && (o({
98
126
  type: c.Alert,
99
- message: r("custom-conditions.wrong-equality-operators")
127
+ message: i("custom-conditions.wrong-equality-operators")
100
128
  }), n = !1);
101
- const v = f.match(/^[a-zA-Z]*$/g);
102
- v && v.forEach((C) => {
103
- E(C) && t.push(C);
129
+ const m = u.match(/^[a-zA-Z]*$/g);
130
+ m && m.forEach((h) => {
131
+ S(h) && t.push(h);
104
132
  });
105
133
  });
106
134
  }), t.length) {
107
- const l = t.filter((i) => i === "if"), o = t.filter((i) => i === "endif");
108
- l.length !== o.length && (a({
135
+ const r = t.filter((l) => l === "if"), a = t.filter((l) => l === "endif");
136
+ r.length !== a.length && (o({
109
137
  type: c.Alert,
110
- message: r("custom-conditions.missing-if-endif-tag")
138
+ message: i("custom-conditions.missing-if-endif-tag")
111
139
  }), n = !1);
112
140
  }
113
141
  return n;
114
- }, B = (e) => {
142
+ }, O = (e) => {
115
143
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
116
- return n || a({
144
+ return n || o({
117
145
  type: c.Warning,
118
- message: r("custom-conditions.no-space-after-braces")
146
+ message: i("custom-conditions.no-space-after-braces")
119
147
  }), n;
120
- }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
148
+ }, _ = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (o({
121
149
  type: c.Warning,
122
- message: r("custom-conditions.no-braces-inside-if-tag")
123
- }), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
150
+ message: i("custom-conditions.no-braces-inside-if-tag")
151
+ }), !1) : !0, L = () => p.hasInvalidBlock() ? (o({
124
152
  type: c.Alert,
125
- message: r(j)
126
- }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
153
+ message: i(Y)
154
+ }), !1) : !0, V = () => v.recommendationConfigs && Object.values(v.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (o({
127
155
  type: c.Alert,
128
- message: r("newsletter.fill-all-necessary-fields")
129
- }), !1) : !0, D = (e) => {
156
+ message: i("newsletter.fill-all-necessary-fields")
157
+ }), !1) : !0, W = (e) => {
130
158
  const s = /src="[^"]*\.(svg|pst)"/gm;
131
- return e.match(s) === null ? !0 : (a({
159
+ return e.match(s) === null ? !0 : (o({
132
160
  type: c.Alert,
133
- message: r("newsletter.invalid-image-type")
161
+ message: i("newsletter.invalid-image-type")
134
162
  }), !1);
135
- }, L = (e) => {
163
+ }, D = (e) => {
136
164
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
137
- return Array.from(n).find((o) => {
138
- var i;
139
- return !((i = o.id) != null && i.trim());
140
- }) ? (a({
165
+ return Array.from(n).find((a) => {
166
+ var l;
167
+ return !((l = a.id) != null && l.trim());
168
+ }) ? (o({
141
169
  type: c.Alert,
142
- message: r("unsubscribe-templates.select-checkbox-groups")
170
+ message: i("unsubscribe-templates.select-checkbox-groups")
143
171
  }), !1) : !0;
144
- }, V = (e) => {
172
+ }, M = (e) => {
145
173
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
146
- return Array.from(n).find((o) => {
147
- var i;
148
- return !((i = o.id) != null && i.trim());
149
- }) ? (a({
174
+ return Array.from(n).find((a) => {
175
+ var l;
176
+ return !((l = a.id) != null && l.trim());
177
+ }) ? (o({
150
178
  type: c.Alert,
151
- message: r("unsubscribe-templates.select-radio-button-groups")
179
+ message: i("unsubscribe-templates.select-radio-button-groups")
152
180
  }), !1) : !0;
153
181
  };
154
182
  return { validateHtml: async (e, s, t = !1) => {
155
- var o, i;
183
+ var f, u;
156
184
  const n = [
157
185
  ...s.map((m) => m.value),
158
- ...q,
159
- ...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
160
- ];
161
- return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
186
+ ...U,
187
+ ...((u = (f = g.value) == null ? void 0 : f.template) == null ? void 0 : u.customFieldAttributes) ?? []
188
+ ], r = G(e), a = await w(r);
189
+ return await T(e, n, t) && k(e) && x(e) && N(e) && B(e, n, r, a) && F(e) && O(e) && _(e) && L() && V() && W(e) && D(e) && M(e);
162
190
  } };
163
191
  };
164
192
  export {
165
- ge as useHtmlValidator
193
+ ae as parseRecommendationVariable,
194
+ we as useHtmlValidator
166
195
  };
@@ -2,6 +2,7 @@ import { useConfig as g } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
3
3
  import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
5
6
  function y(r, n, e, o, i = "") {
6
7
  const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
7
8
  return o === "before" ? `${t} ${c}` : `${c} ${t}`;
@@ -12,7 +13,7 @@ function A(r) {
12
13
  [n] = n.children;
13
14
  return n;
14
15
  }
15
- function f(r, n, e, o, i, c) {
16
+ function b(r, n, e, o, i, c) {
16
17
  switch (n) {
17
18
  case "productImage": {
18
19
  const t = r.querySelector("img");
@@ -87,45 +88,45 @@ function f(r, n, e, o, i, c) {
87
88
  }
88
89
  }
89
90
  }
90
- function w(r, n, e, o) {
91
+ function E(r, n, e, o) {
91
92
  r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
92
93
  c.querySelectorAll("[data-attribute-type]").forEach((a) => {
93
94
  const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
94
95
  p.length > 0 ? p.forEach((l) => {
95
- f(l, u, n, t, e, o);
96
- }) : f(a, u, n, t, e, o);
96
+ b(l, u, n, t, e, o);
97
+ }) : b(a, u, n, t, e, o);
97
98
  });
98
99
  });
99
100
  }
100
- function E(r, n, e, o) {
101
+ function R(r, n, e, o) {
101
102
  const i = r.querySelectorAll(".recommendation-product-row");
102
103
  if (!i.length)
103
104
  return;
104
105
  const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
105
106
  i.forEach((a, u) => {
106
107
  a.querySelectorAll("[data-attribute-type]").forEach((l) => {
107
- const d = l.getAttribute("data-attribute-type") || "";
108
+ const m = l.getAttribute("data-attribute-type") || "";
108
109
  l.querySelectorAll(".attribute-cell").forEach((h, $) => {
109
110
  const S = u * s + $;
110
- f(h, d, n, S, e, o);
111
+ b(h, m, n, S, e, o);
111
112
  });
112
113
  });
113
114
  });
114
115
  }
115
- function R(r, n, e, o) {
116
+ function P(r, n, e, o) {
116
117
  r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
117
- E(c, n, e, o);
118
+ R(c, n, e, o);
118
119
  });
119
120
  }
120
- function P(r, n, e) {
121
+ function T(r, n, e) {
121
122
  const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
122
- o === "list" ? w(r, n, i, e) : R(r, n, i, e);
123
+ o === "list" ? E(r, n, i, e) : P(r, n, i, e);
123
124
  }
124
- function b(r, n, e) {
125
+ function f(r, n, e) {
125
126
  const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
126
127
  return i ? parseInt(i[1]) : e;
127
128
  }
128
- function T(r, n) {
129
+ function v(r, n) {
129
130
  let e = r.parentElement;
130
131
  for (; e && e !== n; ) {
131
132
  if (e.tagName === "TD") {
@@ -137,29 +138,29 @@ function T(r, n) {
137
138
  }
138
139
  return null;
139
140
  }
140
- function v(r) {
141
- const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
141
+ function O(r) {
142
+ const n = r.getAttribute("style") || "", e = f(n, "width", 600), o = f(n, "padding", 0) * 2, i = Math.max(0, e - o);
142
143
  i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
143
144
  if (c.hasAttribute("width"))
144
145
  return;
145
- const t = T(c, r);
146
+ const t = v(c, r);
146
147
  if (!t)
147
148
  return;
148
- const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
149
+ const s = t.getAttribute("width"), a = parseFloat(s), u = f(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
149
150
  c.setAttribute("width", String(l));
150
- const d = c.getAttribute("style") || "";
151
- if (!/\bwidth\s*:\s*\d/i.test(d)) {
152
- const m = d && !d.trim().endsWith(";") ? "; " : "";
153
- c.setAttribute("style", `${d}${m}width: ${l}px`);
151
+ const m = c.getAttribute("style") || "";
152
+ if (!/\bwidth\s*:\s*\d/i.test(m)) {
153
+ const d = m && !m.trim().endsWith(";") ? "; " : "";
154
+ c.setAttribute("style", `${m}${d}width: ${l}px`);
154
155
  }
155
156
  });
156
157
  }
157
- function O(r, n) {
158
+ function W(r, n) {
158
159
  const e = r.match(/<!DOCTYPE[^>]*>/i);
159
160
  return (e ? `${e[0]}
160
161
  ` : "") + n.documentElement.outerHTML;
161
162
  }
162
- function N(r) {
163
+ function F(r) {
163
164
  const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
164
165
  if (!o.length)
165
166
  return r;
@@ -167,12 +168,12 @@ function N(r) {
167
168
  c.recommendationCampaignUrls = {};
168
169
  const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
169
170
  return o.forEach((u) => {
170
- var l, d;
171
+ var l, m;
171
172
  const p = u.getAttribute("recommendation-id");
172
- p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
173
- }), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
173
+ p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (m = u.parentNode) == null || m.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((d) => d.remove()), i(p), w(u) || T(u, p, s), O(u));
174
+ }), W(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
174
175
  }
175
176
  export {
176
177
  y as formatPriceVariable,
177
- N as prepareRecommendationBlocks
178
+ F as prepareRecommendationBlocks
178
179
  };
@@ -0,0 +1,15 @@
1
+ import { CSS_CLASS_SKIP_COMPILE as n, BLOCK_ROOT_SELECTOR as i } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
2
+ function m(o) {
3
+ return o.classList.contains(n);
4
+ }
5
+ function a(o) {
6
+ const r = new DOMParser().parseFromString(o, "text/html").querySelectorAll(`${i}.${n}`), t = /* @__PURE__ */ new Set();
7
+ return r.forEach((c) => {
8
+ const e = c.getAttribute("recommendation-id");
9
+ e && t.add(e);
10
+ }), t;
11
+ }
12
+ export {
13
+ a as getIgnoredRecommendationBlockIds,
14
+ m as isIgnoredRecommendationBlock
15
+ };
@@ -1,27 +1,49 @@
1
- const i = "You May Also Like!";
2
- function s(r) {
3
- var e;
4
- const o = r.querySelector(".ext-recommendation-title");
5
- if (!o)
6
- return i;
7
- const t = (e = o.textContent) == null ? void 0 : e.trim();
8
- return t && t.length > 0 ? t : i;
1
+ import { CURRENCY_ATTR as n, CSS_CLASS_SKIP_COMPILE as c } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
2
+ const a = "You May Also Like!";
3
+ function l(t) {
4
+ var o;
5
+ const r = t.querySelector(".ext-recommendation-title");
6
+ if (!r)
7
+ return a;
8
+ const e = (o = r.textContent) == null ? void 0 : o.trim();
9
+ return e && e.length > 0 ? e : a;
9
10
  }
10
- function u(r) {
11
- const o = [
12
- r,
13
- ...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
11
+ function m(t) {
12
+ const r = [
13
+ t,
14
+ ...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
14
15
  ];
15
- let t = "";
16
- return o.some((e) => {
17
- const n = e.getAttribute("bgcolor");
18
- if (n && n.trim())
19
- return t = n.trim(), !0;
20
- const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
21
- return c && c[1] ? (t = c[1].trim(), !0) : !1;
22
- }), t;
16
+ let e = "";
17
+ return r.some((o) => {
18
+ const i = o.getAttribute("bgcolor");
19
+ if (i && i.trim())
20
+ return e = i.trim(), !0;
21
+ const u = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
22
+ return u && u[1] ? (e = u[1].trim(), !0) : !1;
23
+ }), e;
24
+ }
25
+ function C(t) {
26
+ const r = t.getAttribute(n.CURRENCY);
27
+ if (!r)
28
+ return;
29
+ const e = t.getAttribute(n.SYMBOL);
30
+ return {
31
+ value: r,
32
+ // An empty `currency-symbol` is omitted so `mapCurrency` falls back to
33
+ // the currency code as the symbol.
34
+ ...e ? { symbol: e } : {},
35
+ alignment: t.getAttribute(n.ALIGNMENT) ?? "",
36
+ decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
37
+ decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
38
+ thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
39
+ };
40
+ }
41
+ function d(t) {
42
+ return t.classList.contains(c);
23
43
  }
24
44
  export {
25
- u as extractCardBgColor,
26
- s as extractTitleText
45
+ m as extractCardBgColor,
46
+ C as extractCurrencyFromBlock,
47
+ l as extractTitleText,
48
+ d as isPartnerManagedBlock
27
49
  };