@useinsider/guido 3.21.2-beta.4b0fed7 → 3.21.2-beta.4c14c74
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.
- package/dist/composables/useSave.js +75 -68
- package/dist/composables/validators/useHtmlDocumentCountValidator.js +22 -0
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +22 -22
- package/dist/config/migrator/recommendation/compositionMapper.js +49 -56
- package/dist/config/migrator/recommendation/extractors.js +29 -68
- package/dist/config/migrator/recommendation/htmlBuilder.js +200 -283
- package/dist/config/migrator/recommendation/settingsMapper.js +32 -35
- package/dist/config/migrator/recommendationMigrator.js +29 -32
- package/dist/extensions/Blocks/Items/controls/button/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/cardComposition.js +14 -17
- package/dist/extensions/Blocks/Items/controls/image/link.js +14 -17
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +9 -10
- package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +12 -13
- package/dist/extensions/Blocks/Items/controls/price/formattedPrice.js +29 -30
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +15 -16
- package/dist/extensions/Blocks/Items/controls/price/priceOrientation.js +25 -26
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +27 -28
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +75 -80
- package/dist/extensions/Blocks/Recommendation/block.js +24 -33
- package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +3 -3
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +13 -13
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +229 -208
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +8 -8
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +15 -15
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +10 -10
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +2 -1
- package/dist/extensions/Blocks/common-control.js +62 -55
- package/dist/services/templateLibraryApi.js +36 -31
- package/dist/src/composables/validators/useHtmlDocumentCountValidator.d.ts +3 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +1 -3
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -20
- package/dist/src/extensions/Blocks/Items/controls/cardComposition.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +11 -4
- package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +2 -3
- package/dist/src/extensions/Blocks/common-control.d.ts +2 -0
- package/dist/src/utils/templatePreparation.d.ts +2 -1
- package/dist/utils/pairProductVariables.js +98 -90
- package/dist/utils/templatePreparation.js +30 -30
- package/package.json +1 -1
|
@@ -1,84 +1,91 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useEditorLock as
|
|
4
|
-
import { useSaveStart as
|
|
5
|
-
import { useSaveValidation as
|
|
6
|
-
import { useSaveValidationRollout as
|
|
7
|
-
import { useSyncModuleExtractor as
|
|
8
|
-
import { ToasterTypeOptions as
|
|
9
|
-
import { useStripoApi as
|
|
10
|
-
import { useConfigStore as
|
|
11
|
-
import { useDynamicContentStore as
|
|
12
|
-
import { useSaveValidationStore as
|
|
13
|
-
import { useTemplatePreparation as
|
|
14
|
-
import { useAllowlist as
|
|
15
|
-
import { useHtmlValidator as
|
|
16
|
-
import { useToaster as
|
|
17
|
-
import { useCouponBlockValidator as
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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"))
|
|
24
25
|
return !1;
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
26
|
+
const o = await h(t, e);
|
|
27
|
+
if (!o.length)
|
|
27
28
|
return !1;
|
|
28
|
-
if (!
|
|
29
|
-
const s = await
|
|
30
|
-
s != null && s.message &&
|
|
31
|
-
type:
|
|
29
|
+
if (!i) {
|
|
30
|
+
const s = await B(o);
|
|
31
|
+
s != null && s.message && k({
|
|
32
|
+
type: J.Warning,
|
|
32
33
|
message: s.message,
|
|
33
34
|
actionButton: s.actionButton
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
37
|
return !0;
|
|
37
|
-
},
|
|
38
|
-
if (!await
|
|
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())
|
|
39
40
|
return;
|
|
40
|
-
const { unsubscribePayload:
|
|
41
|
-
if (await
|
|
42
|
-
const
|
|
43
|
-
|
|
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 });
|
|
44
45
|
}
|
|
45
46
|
return t;
|
|
46
|
-
},
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
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(
|
|
53
57
|
o.compiledHtml,
|
|
54
58
|
o.dynamicContentList
|
|
55
59
|
);
|
|
56
|
-
if (
|
|
57
|
-
|
|
60
|
+
if (a.length) {
|
|
61
|
+
L.open(a, "save");
|
|
58
62
|
return;
|
|
59
63
|
}
|
|
60
|
-
} else if (!await
|
|
64
|
+
} else if (!await A(o))
|
|
61
65
|
return;
|
|
62
|
-
if (!((
|
|
63
|
-
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 });
|
|
64
68
|
}
|
|
65
|
-
},
|
|
66
|
-
var
|
|
67
|
-
if (!
|
|
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))
|
|
68
76
|
return;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
if (!f.allowSaveWithErrors)
|
|
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)
|
|
75
82
|
return;
|
|
76
|
-
|
|
77
|
-
const { html: t, css: e } = await
|
|
78
|
-
if (!
|
|
83
|
+
n();
|
|
84
|
+
const { html: t, css: e } = await u();
|
|
85
|
+
if (!c(t, !0) || !l(t, !0) || await d(t, e, !0))
|
|
79
86
|
return;
|
|
80
|
-
const
|
|
81
|
-
dynamicContentList:
|
|
87
|
+
const i = Z(t), o = {
|
|
88
|
+
dynamicContentList: U.getSelectedDynamicContentList,
|
|
82
89
|
compiledHtml: "",
|
|
83
90
|
rawHtml: t,
|
|
84
91
|
css: e,
|
|
@@ -88,16 +95,16 @@ const Bt = () => {
|
|
|
88
95
|
// No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
|
|
89
96
|
recommendation: { configs: {} },
|
|
90
97
|
unsubscribe: {
|
|
91
|
-
status:
|
|
92
|
-
config:
|
|
98
|
+
status: i.length > 0,
|
|
99
|
+
config: i
|
|
93
100
|
}
|
|
94
101
|
};
|
|
95
|
-
return
|
|
102
|
+
return f(o, { silent: !0 });
|
|
96
103
|
};
|
|
97
|
-
return { save: (t = !1, e = !1) =>
|
|
98
|
-
() =>
|
|
99
|
-
), saveWithErrors: () =>
|
|
104
|
+
return { save: (t = !1, e = !1) => m(
|
|
105
|
+
() => M(t, e)
|
|
106
|
+
), saveWithErrors: () => m(W), saveRawOnly: () => m(R) };
|
|
100
107
|
};
|
|
101
108
|
export {
|
|
102
|
-
|
|
109
|
+
Pt as useSave
|
|
103
110
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useToaster as i } from "../useToaster.js";
|
|
2
|
+
import { useTranslations as m } from "../useTranslations.js";
|
|
3
|
+
import { ToasterTypeOptions as c } from "../../enums/toaster.js";
|
|
4
|
+
const u = "newsletter.multiple-html-designs-detected", r = `(?:[^>"']|"[^"]*"|'[^']*')*`, a = "style|script|noscript|xmp|iframe|noembed|noframes|textarea|title", T = /<html(?=[\s>/])/gi, A = new RegExp(
|
|
5
|
+
`<!--[\\s\\S]*?-->|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>|<(${a})(?=[\\s/>])${r}>[\\s\\S]*?</\\1\\s*>|<([a-zA-Z][\\w:-]*)${r}>`,
|
|
6
|
+
"gi"
|
|
7
|
+
), p = (e) => Array.from(e.matchAll(A)).filter(([, , t]) => (t == null ? void 0 : t.toLowerCase()) === "html").length, g = () => {
|
|
8
|
+
const { showToaster: e } = i(), t = m();
|
|
9
|
+
return { validateSingleHtmlDocument: (o, l = !1) => {
|
|
10
|
+
var n;
|
|
11
|
+
if ((((n = o.match(T)) == null ? void 0 : n.length) ?? 0) < 2)
|
|
12
|
+
return !0;
|
|
13
|
+
const s = p(o);
|
|
14
|
+
return s <= 1 ? !0 : (console.debug("guido:save:blocked", { reason: "multiple-html-documents", htmlRootCount: s }), l || e({
|
|
15
|
+
type: c.Warning,
|
|
16
|
+
message: t(u)
|
|
17
|
+
}), !1);
|
|
18
|
+
} };
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
g as useHtmlDocumentCountValidator
|
|
22
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useConfig as
|
|
1
|
+
import { useConfig as g } 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
|
|
16
|
+
function y(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 _(t, r, e, o, c, i) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
const P = "name";
|
|
81
|
-
function
|
|
81
|
+
function b(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 y(t, r, e, o) {
|
|
|
86
86
|
};
|
|
87
87
|
}
|
|
88
88
|
function R(t, r, e) {
|
|
89
|
-
return
|
|
89
|
+
return b(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 } =
|
|
94
|
+
const { open: c, close: i } = b(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 } =
|
|
101
|
+
const { open: c, close: i } = b(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
|
-
|
|
110
|
-
}) :
|
|
109
|
+
y(l, u, r, n, e, o);
|
|
110
|
+
}) : y(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((
|
|
122
|
+
l.querySelectorAll(".attribute-cell").forEach((f, h) => {
|
|
123
123
|
const S = u * s + h;
|
|
124
|
-
|
|
124
|
+
y(f, p, r, S, e, o), w(f, 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")
|
|
136
|
-
o === "list" ? v(t, r,
|
|
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);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
138
|
+
function _(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
|
|
146
|
+
function C(t) {
|
|
147
147
|
const r = t.getAttribute("width");
|
|
148
148
|
if (r && $(r))
|
|
149
149
|
return r.trim();
|
|
@@ -153,28 +153,28 @@ function g(t) {
|
|
|
153
153
|
function x(t, r) {
|
|
154
154
|
let e = t.parentElement;
|
|
155
155
|
for (; e && e !== r; ) {
|
|
156
|
-
if (e.tagName === "TD" &&
|
|
156
|
+
if (e.tagName === "TD" && C(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 =
|
|
163
|
+
const r = t.getAttribute("style") || "", e = _(r, "width", 600), o = _(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 =
|
|
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);
|
|
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
|
|
177
|
-
i.setAttribute("style", `${l}${
|
|
176
|
+
const m = l && !l.trim().endsWith(";") ? "; " : "";
|
|
177
|
+
i.setAttribute("style", `${l}${m}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 } =
|
|
203
|
+
const { isFeatureEnabled: n } = g(), s = n("liquidSyntax") ? "reco_" : "";
|
|
204
204
|
return o.forEach((u) => {
|
|
205
|
-
var l, p,
|
|
205
|
+
var l, p, m, f;
|
|
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
|
-
(
|
|
211
|
+
(m = u.parentNode) == null || m.insertBefore(h, u), (f = u.parentNode) == null || f.insertBefore(S, u.nextSibling);
|
|
212
212
|
}
|
|
213
213
|
G(u);
|
|
214
214
|
}
|
|
@@ -1,108 +1,101 @@
|
|
|
1
|
-
import { DEFAULT_COMPOSITION as
|
|
2
|
-
import { ATTR_RECOMMENDATION_TITLE as
|
|
3
|
-
import { mapTextTheme as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
switch (
|
|
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) {
|
|
8
8
|
case "p_recommendation_title":
|
|
9
|
-
return { key:
|
|
9
|
+
return { key: C, kind: "title" };
|
|
10
10
|
case "p_image":
|
|
11
|
-
return { key:
|
|
11
|
+
return { key: O, kind: "image" };
|
|
12
12
|
case "p_name":
|
|
13
|
-
return { key:
|
|
13
|
+
return { key: E, kind: "text" };
|
|
14
14
|
case "p_price":
|
|
15
|
-
return { key:
|
|
15
|
+
return { key: h, kind: "text" };
|
|
16
16
|
case "p_original_price":
|
|
17
|
-
return { key:
|
|
17
|
+
return { key: f, kind: "text" };
|
|
18
18
|
case "p_omnibus_price":
|
|
19
|
-
return { key:
|
|
19
|
+
return { key: x, kind: "text" };
|
|
20
20
|
case "p_omnibus_discount":
|
|
21
|
-
return { key:
|
|
21
|
+
return { key: R, kind: "text" };
|
|
22
22
|
case "p_button":
|
|
23
|
-
return { key:
|
|
23
|
+
return { key: A, kind: "button" };
|
|
24
24
|
default:
|
|
25
|
-
if (
|
|
26
|
-
const
|
|
27
|
-
if (!
|
|
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)
|
|
28
28
|
return null;
|
|
29
|
-
const
|
|
29
|
+
const e = o || `${T}${s}`;
|
|
30
30
|
return {
|
|
31
|
-
key: `${
|
|
31
|
+
key: `${k}${e}`,
|
|
32
32
|
kind: "custom",
|
|
33
|
-
customAttrName:
|
|
34
|
-
customAttrValue:
|
|
33
|
+
customAttrName: s,
|
|
34
|
+
customAttrValue: e
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
return
|
|
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;
|
|
40
|
+
function _(r) {
|
|
41
|
+
const t = p.indexOf(r);
|
|
42
|
+
return t === -1 ? Number.POSITIVE_INFINITY : t;
|
|
47
43
|
}
|
|
48
|
-
function
|
|
44
|
+
function V(r) {
|
|
49
45
|
const t = {
|
|
50
46
|
composition: [],
|
|
51
|
-
visibility: { ...
|
|
47
|
+
visibility: { ...I },
|
|
52
48
|
customAttributes: [],
|
|
53
49
|
customAttrValues: {},
|
|
54
50
|
perElementStyles: {},
|
|
55
51
|
anyTextTrimming: !1
|
|
56
52
|
};
|
|
57
|
-
if (!
|
|
58
|
-
return t.composition = [...
|
|
53
|
+
if (!r || r.length === 0)
|
|
54
|
+
return t.composition = [...p], t;
|
|
59
55
|
const o = [];
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
63
|
-
if (
|
|
64
|
-
t.titleVariable = e, t.visibility[
|
|
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;
|
|
65
61
|
return;
|
|
66
62
|
}
|
|
67
63
|
o.push({
|
|
68
|
-
key:
|
|
69
|
-
kind:
|
|
64
|
+
key: n.key,
|
|
65
|
+
kind: n.kind,
|
|
70
66
|
hidden: e.hidden === !0,
|
|
71
67
|
positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
|
|
72
68
|
legacy: e,
|
|
73
|
-
customAttrName:
|
|
74
|
-
customAttrValue:
|
|
69
|
+
customAttrName: n.customAttrName,
|
|
70
|
+
customAttrValue: n.customAttrValue,
|
|
75
71
|
originalIndex: i
|
|
76
72
|
});
|
|
77
73
|
}
|
|
78
74
|
}), o.sort((e, i) => {
|
|
79
75
|
if (e.positionIdx !== i.positionIdx)
|
|
80
76
|
return e.positionIdx - i.positionIdx;
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
return r;
|
|
84
|
-
const m = I(e.key), c = I(i.key);
|
|
85
|
-
return m !== c ? m - c : e.originalIndex - i.originalIndex;
|
|
77
|
+
const n = _(e.key), u = _(i.key);
|
|
78
|
+
return n !== u ? n - u : e.originalIndex - i.originalIndex;
|
|
86
79
|
});
|
|
87
|
-
const
|
|
80
|
+
const s = {};
|
|
88
81
|
return o.forEach((e) => {
|
|
89
|
-
const { key: i, kind:
|
|
90
|
-
switch (t.composition.push(i), t.visibility[i] = !
|
|
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) {
|
|
91
84
|
case "image":
|
|
92
|
-
|
|
85
|
+
s[i] = N(c.theme);
|
|
93
86
|
break;
|
|
94
87
|
case "button":
|
|
95
|
-
|
|
88
|
+
s[i] = y(c.theme);
|
|
96
89
|
break;
|
|
97
90
|
case "text":
|
|
98
91
|
case "custom": {
|
|
99
|
-
const
|
|
100
|
-
|
|
92
|
+
const a = b(c.theme);
|
|
93
|
+
s[i] = a, a.textTrimming && (t.anyTextTrimming = !0);
|
|
101
94
|
break;
|
|
102
95
|
}
|
|
103
96
|
}
|
|
104
|
-
}), t.perElementStyles =
|
|
97
|
+
}), t.perElementStyles = s, t;
|
|
105
98
|
}
|
|
106
99
|
export {
|
|
107
|
-
|
|
100
|
+
V as mapComposition
|
|
108
101
|
};
|
|
@@ -1,93 +1,54 @@
|
|
|
1
|
-
import { CURRENCY_ATTR as
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
var
|
|
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;
|
|
5
5
|
const e = t.querySelector(".ext-recommendation-title");
|
|
6
6
|
if (!e)
|
|
7
|
-
return
|
|
8
|
-
const r = (
|
|
9
|
-
return r && r.length > 0 ? r :
|
|
7
|
+
return a;
|
|
8
|
+
const r = (i = e.textContent) == null ? void 0 : i.trim();
|
|
9
|
+
return r && r.length > 0 ? r : a;
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function m(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
|
|
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) {
|
|
15
|
+
function d(t) {
|
|
52
16
|
const e = [
|
|
53
17
|
t,
|
|
54
18
|
...Array.from(t.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
55
19
|
];
|
|
56
20
|
let r = "";
|
|
57
|
-
return e.some((
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
return r =
|
|
61
|
-
const
|
|
62
|
-
return
|
|
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;
|
|
63
27
|
}), r;
|
|
64
28
|
}
|
|
65
|
-
function
|
|
66
|
-
const e = t.getAttribute(
|
|
29
|
+
function C(t) {
|
|
30
|
+
const e = t.getAttribute(n.CURRENCY);
|
|
67
31
|
if (!e)
|
|
68
32
|
return;
|
|
69
|
-
const r = t.getAttribute(
|
|
33
|
+
const r = t.getAttribute(n.SYMBOL);
|
|
70
34
|
return {
|
|
71
35
|
value: e,
|
|
72
36
|
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
73
37
|
// the currency code as the symbol.
|
|
74
38
|
...r ? { symbol: r } : {},
|
|
75
|
-
alignment: t.getAttribute(
|
|
76
|
-
decimalCount: t.getAttribute(
|
|
77
|
-
decimalSeparator: t.getAttribute(
|
|
78
|
-
thousandSeparator: t.getAttribute(
|
|
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) ?? ""
|
|
79
43
|
};
|
|
80
44
|
}
|
|
81
|
-
function
|
|
82
|
-
return t.classList.contains(
|
|
45
|
+
function g(t) {
|
|
46
|
+
return t.classList.contains(c);
|
|
83
47
|
}
|
|
84
48
|
export {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
g as isOldPriceFirst,
|
|
91
|
-
y as isPartnerManagedBlock,
|
|
92
|
-
x as withRenderedTextTheme
|
|
49
|
+
d as extractCardBgColor,
|
|
50
|
+
C as extractCurrencyFromBlock,
|
|
51
|
+
A as extractTitleText,
|
|
52
|
+
m as hasVisibleTitle,
|
|
53
|
+
g as isPartnerManagedBlock
|
|
93
54
|
};
|