@useinsider/guido 3.21.2-beta.45bb425 → 3.21.2-beta.4b0fed7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +1,84 @@
1
- import { useActionsApi as q } from "./useActionsApi.js";
2
- import { useConfig as O } from "./useConfig.js";
3
- import { useEditorLock as D } from "./useEditorLock.js";
4
- import { useSaveStart as F, useSaveComplete as j } from "./useGuidoActions.js";
5
- import { useSaveValidation as z } from "./useSaveValidation.js";
6
- import { useSaveValidationRollout as G } from "./useSaveValidationRollout.js";
7
- import { useSyncModuleExtractor as I } from "./useSyncModuleExtractor.js";
8
- import { ToasterTypeOptions as J } from "../enums/toaster.js";
9
- import { useStripoApi as K } from "../services/stripoApi.js";
10
- import { useConfigStore as N } from "../stores/config.js";
11
- import { useDynamicContentStore as Q } from "../stores/dynamic-content.js";
12
- import { useSaveValidationStore as X } from "../stores/save-validation.js";
13
- import { useTemplatePreparation as Y, getHtmlReferencedUnsubscribePages as Z } from "../utils/templatePreparation.js";
14
- import { useAllowlist as _ } from "./useAllowlist.js";
15
- import { useHtmlValidator as $ } from "./useHtmlValidator.js";
16
- import { useToaster as tt } from "./useToaster.js";
17
- import { useCouponBlockValidator as et } from "./validators/useCouponBlockValidator.js";
18
- import { useHtmlDocumentCountValidator as ot } from "./validators/useHtmlDocumentCountValidator.js";
19
- import { useLiquidValidator as it } from "./validators/useLiquidValidator.js";
20
- import { useSyncModuleBlockValidator as st } from "./validators/useSyncModuleBlockValidator.js";
21
- import { useUnsubscribeBlockValidator as at } from "./validators/useUnsubscribeBlockValidator.js";
22
- const Pt = () => {
23
- const n = F(), w = j(), { validateHtml: y } = $(), { validateLiquidSyntax: E } = it(), { validateCouponBlockTags: b } = et(), { validateUnsubscribeBlockUniqueness: g, validateUnsubscribeBlockHasTemplate: H } = at(), { validateSyncModuleBlocks: l } = st(), { validateSingleHtmlDocument: c } = ot(), { callbacks: r, isFeatureEnabled: v } = O(), { extractSyncModuleData: V } = I(), { setSyncModuleUnsubscriptionPages: x } = K(), { editorSave: C, getTemplateData: u } = q(), { showToaster: k } = tt(), { getBlockedDomains: h, resolveToast: B } = _(), { prepareTemplateDetails: p } = Y(), { collectSaveValidationErrors: T } = z(), { isEnabled: P } = G(), L = X(), U = Q(), S = N(), { runExclusive: m } = D(), d = async (t, e, i) => {
24
- if (!v("allowlistEnabled"))
1
+ import { useActionsApi as R } from "./useActionsApi.js";
2
+ import { useConfig as q } from "./useConfig.js";
3
+ import { useEditorLock as O } from "./useEditorLock.js";
4
+ import { useSaveStart as D, useSaveComplete as F } from "./useGuidoActions.js";
5
+ import { useSaveValidation as j } from "./useSaveValidation.js";
6
+ import { useSaveValidationRollout as z } from "./useSaveValidationRollout.js";
7
+ import { useSyncModuleExtractor as G } from "./useSyncModuleExtractor.js";
8
+ import { ToasterTypeOptions as I } from "../enums/toaster.js";
9
+ import { useStripoApi as J } from "../services/stripoApi.js";
10
+ import { useConfigStore as K } from "../stores/config.js";
11
+ import { useDynamicContentStore as N } from "../stores/dynamic-content.js";
12
+ import { useSaveValidationStore as Q } from "../stores/save-validation.js";
13
+ import { useTemplatePreparation as X, getHtmlReferencedUnsubscribePages as Y } from "../utils/templatePreparation.js";
14
+ import { useAllowlist as Z } from "./useAllowlist.js";
15
+ import { useHtmlValidator as _ } from "./useHtmlValidator.js";
16
+ import { useToaster as $ } from "./useToaster.js";
17
+ import { useCouponBlockValidator as tt } from "./validators/useCouponBlockValidator.js";
18
+ import { useLiquidValidator as et } from "./validators/useLiquidValidator.js";
19
+ import { useSyncModuleBlockValidator as ot } from "./validators/useSyncModuleBlockValidator.js";
20
+ import { useUnsubscribeBlockValidator as st } from "./validators/useUnsubscribeBlockValidator.js";
21
+ const Bt = () => {
22
+ const a = D(), p = F(), { validateHtml: v } = _(), { validateLiquidSyntax: S } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: w, validateUnsubscribeBlockHasTemplate: E } = st(), { validateSyncModuleBlocks: n } = ot(), { callbacks: r, isFeatureEnabled: d } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: H, getTemplateData: V } = R(), { showToaster: x } = $(), { getBlockedDomains: k, resolveToast: C } = Z(), { prepareTemplateDetails: m } = X(), { collectSaveValidationErrors: B } = j(), { isEnabled: h } = z(), T = Q(), P = N(), f = K(), { runExclusive: l } = O(), c = async (t, e, o) => {
23
+ if (!d("allowlistEnabled"))
25
24
  return !1;
26
- const o = await h(t, e);
27
- if (!o.length)
25
+ const i = await k(t, e);
26
+ if (!i.length)
28
27
  return !1;
29
- if (!i) {
30
- const s = await B(o);
31
- s != null && s.message && k({
32
- type: J.Warning,
28
+ if (!o) {
29
+ const s = await C(i);
30
+ s != null && s.message && x({
31
+ type: I.Warning,
33
32
  message: s.message,
34
33
  actionButton: s.actionButton
35
34
  });
36
35
  }
37
36
  return !0;
38
- }, A = async (t) => !b(t.compiledHtml) || !g(t.compiledHtml) || !H(t.compiledHtml) ? !1 : v("liquidSyntax") ? E(t.compiledHtml) : y(t.compiledHtml, t.dynamicContentList, !0), f = async (t, e) => {
39
- if (!await C())
37
+ }, L = async (t) => !y(t.compiledHtml) || !w(t.compiledHtml) || !E(t.compiledHtml) ? !1 : d("liquidSyntax") ? S(t.compiledHtml) : v(t.compiledHtml, t.dynamicContentList, !0), u = async (t, e) => {
38
+ if (!await H())
40
39
  return;
41
- const { unsubscribePayload: o, stripoModules: s } = V(t.rawHtml);
42
- if (await x(o), t.modules = s, !e.suppress) {
43
- const a = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
44
- w({ ...t, ...a, silent: e.silent });
40
+ const { unsubscribePayload: i, stripoModules: s } = b(t.rawHtml);
41
+ if (await g(i), t.modules = s, !e.suppress) {
42
+ const W = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
43
+ p({ ...t, ...W, silent: e.silent });
45
44
  }
46
45
  return t;
47
- }, M = async (t, e) => {
48
- var s;
49
- n();
50
- const i = await u();
51
- if (!c(i.html, e))
52
- return;
53
- const o = await p(i);
54
- if (l(o.rawHtml, e)) {
55
- if (P.value && !e) {
56
- const a = await T(
46
+ }, U = async (t, e) => {
47
+ var i;
48
+ a();
49
+ const o = await m();
50
+ if (n(o.rawHtml, e)) {
51
+ if (h.value && !e) {
52
+ const s = await B(
57
53
  o.compiledHtml,
58
54
  o.dynamicContentList
59
55
  );
60
- if (a.length) {
61
- L.open(a, "save");
56
+ if (s.length) {
57
+ T.open(s, "save");
62
58
  return;
63
59
  }
64
- } else if (!await A(o))
60
+ } else if (!await L(o))
65
61
  return;
66
- if (!((s = r.value) != null && s.externalValidation && !await r.value.externalValidation(o)) && !await d(o.compiledHtml, o.css, e))
67
- return f(o, { silent: e, suppress: t });
62
+ if (!((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(o)) && !await c(o.compiledHtml, o.css, e))
63
+ return u(o, { silent: e, suppress: t });
68
64
  }
69
- }, W = async () => {
70
- var i;
71
- if (!S.allowSaveWithErrors)
72
- return;
73
- n();
74
- const t = await u();
75
- if (!c(t.html, !1))
65
+ }, A = async () => {
66
+ var e;
67
+ if (!f.allowSaveWithErrors)
76
68
  return;
77
- const e = await p(t);
78
- if (l(e.rawHtml, !1) && !((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(e)) && !await d(e.compiledHtml, e.css, !1))
79
- return f(e, { silent: !1, blankCompiled: !0 });
80
- }, R = async () => {
81
- if (!S.allowSaveWithErrors)
69
+ a();
70
+ const t = await m();
71
+ if (n(t.rawHtml, !1) && !((e = r.value) != null && e.externalValidation && !await r.value.externalValidation(t)) && !await c(t.compiledHtml, t.css, !1))
72
+ return u(t, { silent: !1, blankCompiled: !0 });
73
+ }, M = async () => {
74
+ if (!f.allowSaveWithErrors)
82
75
  return;
83
- n();
84
- const { html: t, css: e } = await u();
85
- if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
76
+ a();
77
+ const { html: t, css: e } = await V();
78
+ if (!n(t, !0) || await c(t, e, !0))
86
79
  return;
87
- const i = Z(t), o = {
88
- dynamicContentList: U.getSelectedDynamicContentList,
80
+ const o = Y(t), i = {
81
+ dynamicContentList: P.getSelectedDynamicContentList,
89
82
  compiledHtml: "",
90
83
  rawHtml: t,
91
84
  css: e,
@@ -95,16 +88,16 @@ const Pt = () => {
95
88
  // No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
96
89
  recommendation: { configs: {} },
97
90
  unsubscribe: {
98
- status: i.length > 0,
99
- config: i
91
+ status: o.length > 0,
92
+ config: o
100
93
  }
101
94
  };
102
- return f(o, { silent: !0 });
95
+ return u(i, { silent: !0 });
103
96
  };
104
- return { save: (t = !1, e = !1) => m(
105
- () => M(t, e)
106
- ), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
97
+ return { save: (t = !1, e = !1) => l(
98
+ () => U(t, e)
99
+ ), saveWithErrors: () => l(A), saveRawOnly: () => l(M) };
107
100
  };
108
101
  export {
109
- Pt as useSave
102
+ Bt as useSave
110
103
  };
@@ -1,4 +1,4 @@
1
- import { useConfig as g } from "../../../composables/useConfig.js";
1
+ import { useConfig as C } from "../../../composables/useConfig.js";
2
2
  import { useRecommendation as O } from "../../../composables/useRecommendation.js";
3
3
  import { MOBILE_ROW_SELECTOR as q, MOBILE_CONTAINER_SELECTOR as M, CSS_CLASS_RECO_BUTTON as B } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
4
  import { useRecommendationExtensionStore as N } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
@@ -13,7 +13,7 @@ function A(t) {
13
13
  [r] = r.children;
14
14
  return r;
15
15
  }
16
- function y(t, r, e, o, c, i) {
16
+ function _(t, r, e, o, c, i) {
17
17
  switch (r) {
18
18
  case "productImage": {
19
19
  const n = t.querySelector("img");
@@ -78,7 +78,7 @@ function y(t, r, e, o, c, i) {
78
78
  }
79
79
  }
80
80
  const P = "name";
81
- function b(t, r, e, o) {
81
+ function y(t, r, e, o) {
82
82
  const c = `${o}${r}_${e}_${P}`;
83
83
  return {
84
84
  open: t.createComment(`{% if ${c} and ${c} != "" %}`),
@@ -86,19 +86,19 @@ function b(t, r, e, o) {
86
86
  };
87
87
  }
88
88
  function R(t, r, e) {
89
- return b(t, r, 0, e);
89
+ return y(t, r, 0, e);
90
90
  }
91
91
  function w(t, r, e, o) {
92
92
  if (!t.innerHTML.includes("{{"))
93
93
  return;
94
- const { open: c, close: i } = b(t.ownerDocument, r, e, o);
94
+ const { open: c, close: i } = y(t.ownerDocument, r, e, o);
95
95
  t.insertBefore(c, t.firstChild), t.appendChild(i);
96
96
  }
97
97
  function D(t, r, e, o) {
98
98
  var n, s;
99
99
  if (!t.innerHTML.includes("{{"))
100
100
  return;
101
- const { open: c, close: i } = b(t.ownerDocument, r, e, o);
101
+ const { open: c, close: i } = y(t.ownerDocument, r, e, o);
102
102
  (n = t.parentNode) == null || n.insertBefore(c, t), (s = t.parentNode) == null || s.insertBefore(i, t.nextSibling);
103
103
  }
104
104
  function v(t, r, e, o) {
@@ -106,8 +106,8 @@ function v(t, r, e, o) {
106
106
  i.querySelectorAll("[data-attribute-type]").forEach((d) => {
107
107
  const u = d.getAttribute("data-attribute-type") || "", a = d.querySelectorAll(".attribute-cell");
108
108
  a.length > 0 ? a.forEach((l) => {
109
- y(l, u, r, n, e, o);
110
- }) : y(d, u, r, n, e, o);
109
+ _(l, u, r, n, e, o);
110
+ }) : _(d, u, r, n, e, o);
111
111
  }), D(i, r, n, o);
112
112
  });
113
113
  }
@@ -119,9 +119,9 @@ function H(t, r, e, o) {
119
119
  c.forEach((d, u) => {
120
120
  d.querySelectorAll("[data-attribute-type]").forEach((l) => {
121
121
  const p = l.getAttribute("data-attribute-type") || "";
122
- l.querySelectorAll(".attribute-cell").forEach((f, h) => {
122
+ l.querySelectorAll(".attribute-cell").forEach((m, h) => {
123
123
  const S = u * s + h;
124
- y(f, p, r, S, e, o), w(f, r, S, o);
124
+ _(m, p, r, S, e, o), w(m, r, S, o);
125
125
  });
126
126
  });
127
127
  });
@@ -132,10 +132,10 @@ function W(t, r, e, o) {
132
132
  });
133
133
  }
134
134
  function F(t, r, e) {
135
- const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment") || "after";
136
- o === "list" ? v(t, r, c, e) : W(t, r, c, e);
135
+ const o = t.getAttribute("data-layout") || "grid", c = t.getAttribute("currency-alignment"), i = c === "0" || c === "before" ? "before" : "after";
136
+ o === "list" ? v(t, r, i, e) : W(t, r, i, e);
137
137
  }
138
- function _(t, r, e) {
138
+ function b(t, r, e) {
139
139
  const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), c = t.match(o);
140
140
  return c ? parseInt(c[1]) : e;
141
141
  }
@@ -143,7 +143,7 @@ function $(t) {
143
143
  const r = t.trim();
144
144
  return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
145
145
  }
146
- function C(t) {
146
+ function g(t) {
147
147
  const r = t.getAttribute("width");
148
148
  if (r && $(r))
149
149
  return r.trim();
@@ -153,28 +153,28 @@ function C(t) {
153
153
  function x(t, r) {
154
154
  let e = t.parentElement;
155
155
  for (; e && e !== r; ) {
156
- if (e.tagName === "TD" && C(e))
156
+ if (e.tagName === "TD" && g(e))
157
157
  return e;
158
158
  e = e.parentElement;
159
159
  }
160
160
  return null;
161
161
  }
162
162
  function G(t) {
163
- const r = t.getAttribute("style") || "", e = _(r, "width", 600), o = _(r, "padding", 0) * 2, c = Math.max(0, e - o);
163
+ const r = t.getAttribute("style") || "", e = b(r, "width", 600), o = b(r, "padding", 0) * 2, c = Math.max(0, e - o);
164
164
  c !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
165
165
  if (i.hasAttribute("width"))
166
166
  return;
167
167
  const n = x(i, t);
168
168
  if (!n)
169
169
  return;
170
- const s = C(n), d = _(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
170
+ const s = g(n), d = b(n.getAttribute("style") || "", "padding", 0) * 2, u = s.endsWith("%") ? Math.floor(c * parseFloat(s) / 100) : parseInt(s), a = Math.max(1, u - d), l = i.getAttribute("style") || "", p = /(?:^|[;\s])max-height\s*:\s*(\d+(?:\.\d+)?)px/i.exec(l);
171
171
  if (p) {
172
172
  i.setAttribute("width", String(Math.max(1, Math.min(a, Math.floor(parseFloat(p[1])))))), i.removeAttribute("height");
173
173
  return;
174
174
  }
175
175
  if (i.setAttribute("width", String(a)), !/\bwidth\s*:\s*\d/i.test(l)) {
176
- const m = l && !l.trim().endsWith(";") ? "; " : "";
177
- i.setAttribute("style", `${l}${m}width: ${a}px`);
176
+ const f = l && !l.trim().endsWith(";") ? "; " : "";
177
+ i.setAttribute("style", `${l}${f}width: ${a}px`);
178
178
  }
179
179
  });
180
180
  }
@@ -200,15 +200,15 @@ function Q(t) {
200
200
  return t;
201
201
  const { buildCampaignUrl: c } = O(), i = N();
202
202
  i.recommendationCampaignUrls = {};
203
- const { isFeatureEnabled: n } = g(), s = n("liquidSyntax") ? "reco_" : "";
203
+ const { isFeatureEnabled: n } = C(), s = n("liquidSyntax") ? "reco_" : "";
204
204
  return o.forEach((u) => {
205
- var l, p, m, f;
205
+ var l, p, f, m;
206
206
  const a = u.getAttribute("recommendation-id");
207
207
  if (a) {
208
208
  if ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), c(a), U(u, e), !T(u)) {
209
209
  F(u, a, s);
210
210
  const { open: h, close: S } = R(e, a, s);
211
- (m = u.parentNode) == null || m.insertBefore(h, u), (f = u.parentNode) == null || f.insertBefore(S, u.nextSibling);
211
+ (f = u.parentNode) == null || f.insertBefore(h, u), (m = u.parentNode) == null || m.insertBefore(S, u.nextSibling);
212
212
  }
213
213
  G(u);
214
214
  }
@@ -1,101 +1,108 @@
1
- import { DEFAULT_COMPOSITION as p, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
- import { ATTR_RECOMMENDATION_TITLE as l, ATTR_CUSTOM_PREFIX as k, ATTR_PRODUCT_BUTTON as A, ATTR_PRODUCT_OMNIBUS_DISCOUNT as R, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as h, ATTR_PRODUCT_NAME as E, ATTR_PRODUCT_IMAGE as O } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
- import { mapTextTheme as b, mapButtonTheme as y, mapImageTheme as N } from "./themeMapper.js";
4
- const C = "__title__", T = "product_attribute.";
5
- function P(r) {
6
- const t = r.variable ?? "";
7
- switch (t) {
1
+ import { DEFAULT_COMPOSITION as k, DEFAULT_VISIBILITY as f } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
+ import { ATTR_RECOMMENDATION_TITLE as R, ATTR_CUSTOM_PREFIX as x, ATTR_PRODUCT_BUTTON as E, ATTR_PRODUCT_OMNIBUS_DISCOUNT as h, ATTR_PRODUCT_OMNIBUS_PRICE as O, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as d, ATTR_PRODUCT_NAME as y, ATTR_PRODUCT_IMAGE as b } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
3
+ import { mapTextTheme as C, mapButtonTheme as N, mapImageTheme as P } from "./themeMapper.js";
4
+ const U = "__title__", _ = "product_attribute.";
5
+ function D(n) {
6
+ const s = n.variable ?? "";
7
+ switch (s) {
8
8
  case "p_recommendation_title":
9
- return { key: C, kind: "title" };
9
+ return { key: U, kind: "title" };
10
10
  case "p_image":
11
- return { key: O, kind: "image" };
11
+ return { key: b, kind: "image" };
12
12
  case "p_name":
13
- return { key: E, kind: "text" };
13
+ return { key: y, kind: "text" };
14
14
  case "p_price":
15
- return { key: h, kind: "text" };
15
+ return { key: d, kind: "text" };
16
16
  case "p_original_price":
17
- return { key: f, kind: "text" };
17
+ return { key: a, kind: "text" };
18
18
  case "p_omnibus_price":
19
- return { key: x, kind: "text" };
19
+ return { key: O, kind: "text" };
20
20
  case "p_omnibus_discount":
21
- return { key: R, kind: "text" };
21
+ return { key: h, kind: "text" };
22
22
  case "p_button":
23
- return { key: A, kind: "button" };
23
+ return { key: E, kind: "button" };
24
24
  default:
25
- if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
26
- const o = r.value ?? "", s = o.startsWith(T) ? o.slice(T.length) : o;
27
- if (!s)
25
+ if (n.variableType === "p_attribute" || s.startsWith("p_attribute_")) {
26
+ const t = n.value ?? "", o = t.startsWith(_) ? t.slice(_.length) : t;
27
+ if (!o)
28
28
  return null;
29
- const e = o || `${T}${s}`;
29
+ const u = t || `${_}${o}`;
30
30
  return {
31
- key: `${k}${e}`,
31
+ key: `${x}${u}`,
32
32
  kind: "custom",
33
- customAttrName: s,
34
- customAttrValue: e
33
+ customAttrName: o,
34
+ customAttrValue: u
35
35
  };
36
36
  }
37
37
  return null;
38
38
  }
39
39
  }
40
- function _(r) {
41
- const t = p.indexOf(r);
42
- return t === -1 ? Number.POSITIVE_INFINITY : t;
40
+ function I(n) {
41
+ const s = k.indexOf(n);
42
+ return s === -1 ? Number.POSITIVE_INFINITY : s;
43
+ }
44
+ const l = [d, a];
45
+ function S(n, s, t) {
46
+ return n === s || !l.includes(n) || !l.includes(s) ? 0 : n === (t ? a : d) ? -1 : 1;
43
47
  }
44
- function V(r) {
48
+ function F(n, { oldPriceFirst: s = !1 } = {}) {
45
49
  const t = {
46
50
  composition: [],
47
- visibility: { ...I },
51
+ visibility: { ...f },
48
52
  customAttributes: [],
49
53
  customAttrValues: {},
50
54
  perElementStyles: {},
51
55
  anyTextTrimming: !1
52
56
  };
53
- if (!r || r.length === 0)
54
- return t.composition = [...p], t;
57
+ if (!n || n.length === 0)
58
+ return t.composition = [...k], t;
55
59
  const o = [];
56
- r.forEach((e, i) => {
57
- const n = P(e);
58
- if (n) {
59
- if (n.kind === "title") {
60
- t.titleVariable = e, t.visibility[l] = e.hidden !== !0;
60
+ n.forEach((e, i) => {
61
+ const r = D(e);
62
+ if (r) {
63
+ if (r.kind === "title") {
64
+ t.titleVariable = e, t.visibility[R] = e.hidden !== !0;
61
65
  return;
62
66
  }
63
67
  o.push({
64
- key: n.key,
65
- kind: n.kind,
68
+ key: r.key,
69
+ kind: r.kind,
66
70
  hidden: e.hidden === !0,
67
71
  positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
68
72
  legacy: e,
69
- customAttrName: n.customAttrName,
70
- customAttrValue: n.customAttrValue,
73
+ customAttrName: r.customAttrName,
74
+ customAttrValue: r.customAttrValue,
71
75
  originalIndex: i
72
76
  });
73
77
  }
74
78
  }), o.sort((e, i) => {
75
79
  if (e.positionIdx !== i.positionIdx)
76
80
  return e.positionIdx - i.positionIdx;
77
- const n = _(e.key), u = _(i.key);
78
- return n !== u ? n - u : e.originalIndex - i.originalIndex;
81
+ const r = S(e.key, i.key, s);
82
+ if (r !== 0)
83
+ return r;
84
+ const m = I(e.key), c = I(i.key);
85
+ return m !== c ? m - c : e.originalIndex - i.originalIndex;
79
86
  });
80
- const s = {};
87
+ const u = {};
81
88
  return o.forEach((e) => {
82
- const { key: i, kind: n, hidden: u, legacy: c, customAttrName: d, customAttrValue: m } = e;
83
- switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && d && m && (t.customAttributes.includes(m) || t.customAttributes.push(m), t.customAttrValues[i] = m), n) {
89
+ const { key: i, kind: r, hidden: m, legacy: c, customAttrName: A, customAttrValue: T } = e;
90
+ switch (t.composition.push(i), t.visibility[i] = !m, r === "custom" && A && T && (t.customAttributes.includes(T) || t.customAttributes.push(T), t.customAttrValues[i] = T), r) {
84
91
  case "image":
85
- s[i] = N(c.theme);
92
+ u[i] = P(c.theme);
86
93
  break;
87
94
  case "button":
88
- s[i] = y(c.theme);
95
+ u[i] = N(c.theme);
89
96
  break;
90
97
  case "text":
91
98
  case "custom": {
92
- const a = b(c.theme);
93
- s[i] = a, a.textTrimming && (t.anyTextTrimming = !0);
99
+ const p = C(c.theme);
100
+ u[i] = p, p.textTrimming && (t.anyTextTrimming = !0);
94
101
  break;
95
102
  }
96
103
  }
97
- }), t.perElementStyles = s, t;
104
+ }), t.perElementStyles = u, t;
98
105
  }
99
106
  export {
100
- V as mapComposition
107
+ F as mapComposition
101
108
  };
@@ -1,54 +1,93 @@
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 A(t) {
4
- var i;
1
+ import { CURRENCY_ATTR as c, CSS_CLASS_SKIP_COMPILE as a } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
2
+ const m = "You May Also Like!";
3
+ function S(t) {
4
+ var o;
5
5
  const e = t.querySelector(".ext-recommendation-title");
6
6
  if (!e)
7
- return a;
8
- const r = (i = e.textContent) == null ? void 0 : i.trim();
9
- return r && r.length > 0 ? r : a;
7
+ return m;
8
+ const r = (o = e.textContent) == null ? void 0 : o.trim();
9
+ return r && r.length > 0 ? r : m;
10
10
  }
11
- function m(t) {
11
+ function T(t) {
12
12
  const e = t.querySelector(".ext-recommendation-title");
13
13
  return e ? !/display\s*:\s*none/i.test(e.getAttribute("style") ?? "") : !1;
14
14
  }
15
- function d(t) {
15
+ function f(t) {
16
+ var r;
17
+ const e = t.querySelector(".ext-recommendation-title");
18
+ return !!e && !((r = e == null ? void 0 : e.textContent) != null && r.trim());
19
+ }
20
+ function g(t) {
21
+ const e = t.querySelector(".ext-product-price"), r = t.querySelector(".ext-product-original-price");
22
+ return !e || !r ? !1 : e.compareDocumentPosition(r) === Node.DOCUMENT_POSITION_PRECEDING;
23
+ }
24
+ const d = /* @__PURE__ */ new Map([
25
+ ["p_name", ".ext-product-name p"],
26
+ ["p_price", ".ext-product-price p"],
27
+ ["p_original_price", ".ext-product-original-price p"]
28
+ ]);
29
+ function p(t) {
30
+ const e = ((t == null ? void 0 : t.getAttribute("style")) ?? "").match(/(?:^|;)\s*color\s*:\s*([^;]+)/i);
31
+ return (e == null ? void 0 : e[1].trim()) || void 0;
32
+ }
33
+ const A = "ins-trim-text";
34
+ function x(t, e) {
35
+ return t == null ? void 0 : t.map((r) => {
36
+ var s, l;
37
+ const o = d.get(r.variable ?? "");
38
+ if (!o)
39
+ return r;
40
+ const n = e.querySelector(o), u = (l = (s = r.theme) == null ? void 0 : s.textColor) != null && l.color ? void 0 : p(n), i = r.variable === "p_name" && (n == null ? void 0 : n.classList.contains(A));
41
+ return !u && !i ? r : {
42
+ ...r,
43
+ theme: {
44
+ ...r.theme,
45
+ ...u ? { textColor: { color: u } } : {},
46
+ ...i ? { textTrimming: !0 } : {}
47
+ }
48
+ };
49
+ });
50
+ }
51
+ function E(t) {
16
52
  const e = [
17
53
  t,
18
54
  ...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
19
55
  ];
20
56
  let r = "";
21
- return e.some((i) => {
22
- const o = i.getAttribute("bgcolor");
23
- if (o && o.trim())
24
- return r = o.trim(), !0;
25
- const u = (i.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
26
- return u && u[1] ? (r = u[1].trim(), !0) : !1;
57
+ return e.some((o) => {
58
+ const n = o.getAttribute("bgcolor");
59
+ if (n && n.trim())
60
+ return r = n.trim(), !0;
61
+ const i = (o.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
62
+ return i && i[1] ? (r = i[1].trim(), !0) : !1;
27
63
  }), r;
28
64
  }
29
- function C(t) {
30
- const e = t.getAttribute(n.CURRENCY);
65
+ function _(t) {
66
+ const e = t.getAttribute(c.CURRENCY);
31
67
  if (!e)
32
68
  return;
33
- const r = t.getAttribute(n.SYMBOL);
69
+ const r = t.getAttribute(c.SYMBOL);
34
70
  return {
35
71
  value: e,
36
72
  // An empty `currency-symbol` is omitted so `mapCurrency` falls back to
37
73
  // the currency code as the symbol.
38
74
  ...r ? { symbol: r } : {},
39
- alignment: t.getAttribute(n.ALIGNMENT) ?? "",
40
- decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
41
- decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
42
- thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
75
+ alignment: t.getAttribute(c.ALIGNMENT) ?? "",
76
+ decimalCount: t.getAttribute(c.DECIMAL_COUNT) ?? "",
77
+ decimalSeparator: t.getAttribute(c.DECIMAL_SEPARATOR) ?? "",
78
+ thousandSeparator: t.getAttribute(c.THOUSAND_SEPARATOR) ?? ""
43
79
  };
44
80
  }
45
- function g(t) {
46
- return t.classList.contains(c);
81
+ function y(t) {
82
+ return t.classList.contains(a);
47
83
  }
48
84
  export {
49
- d as extractCardBgColor,
50
- C as extractCurrencyFromBlock,
51
- A as extractTitleText,
52
- m as hasVisibleTitle,
53
- g as isPartnerManagedBlock
85
+ E as extractCardBgColor,
86
+ _ as extractCurrencyFromBlock,
87
+ S as extractTitleText,
88
+ f as hasEmptyTitle,
89
+ T as hasVisibleTitle,
90
+ g as isOldPriceFirst,
91
+ y as isPartnerManagedBlock,
92
+ x as withRenderedTextTheme
54
93
  };