@useinsider/guido 3.12.0-beta.b73c720 → 3.12.0-beta.b94f28c
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/README.md +16 -1
- package/dist/@types/config/schemas.js +24 -27
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +111 -103
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +1 -1
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +8 -8
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +10 -10
- package/dist/composables/useAllowlist.js +50 -0
- package/dist/composables/usePreviewInteractionGuard.js +36 -11
- package/dist/composables/useRecommendation.js +51 -82
- package/dist/composables/useRecommendationPreview.js +61 -60
- package/dist/composables/useSave.js +42 -23
- package/dist/composables/useStripo.js +72 -69
- package/dist/composables/useUserRole.js +12 -0
- package/dist/config/migrator/recommendationMigrator.js +4 -7
- package/dist/enums/date.js +3 -4
- package/dist/enums/extensions/recommendationBlock.js +22 -28
- package/dist/enums/roles.js +4 -0
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +11 -12
- package/dist/extensions/Blocks/Recommendation/controls/blockBackground/index.js +10 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +109 -123
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +12 -12
- package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +12 -12
- package/dist/extensions/Blocks/Recommendation/extension.js +23 -21
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +1 -1
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +41 -40
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +102 -256
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +7 -7
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -24
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +3 -2
- package/dist/extensions/Blocks/controlFactories.js +125 -75
- package/dist/guido.css +1 -1
- package/dist/services/allowlistApi.js +15 -0
- package/dist/services/recommendationApi.js +27 -65
- package/dist/services/stripoApi.js +18 -18
- package/dist/src/@types/config/schemas.d.ts +10 -10
- package/dist/src/components/Guido.vue.d.ts +18 -2
- package/dist/src/composables/useAllowlist.d.ts +6 -0
- package/dist/src/composables/useConfig.d.ts +2 -2
- package/dist/src/composables/usePreviewInteractionGuard.d.ts +1 -1
- package/dist/src/composables/useRecommendation.d.ts +0 -2
- package/dist/src/composables/useStripo.d.ts +3 -2
- package/dist/src/composables/useUserRole.d.ts +3 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -10
- package/dist/src/enums/roles.d.ts +9 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +14 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +1 -3
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -606
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +1 -3
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +1 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +36 -0
- package/dist/src/services/allowlistApi.d.ts +4 -0
- package/dist/src/services/recommendationApi.d.ts +1 -7
- package/dist/src/stores/config.d.ts +21 -19
- package/dist/src/utils/genericUtil.d.ts +0 -9
- package/dist/src/utils/urlSchemes.d.ts +6 -0
- package/dist/static/styles/base.css.js +0 -15
- package/dist/static/styles/components/base-input.css.js +6 -7
- package/dist/stores/config.js +21 -19
- package/dist/utils/dateUtil.js +10 -23
- package/dist/utils/genericUtil.js +1 -10
- package/dist/utils/pairProductVariables.js +44 -43
- package/dist/{extensions/Blocks/Recommendation/utils → utils}/preserveTextStyles.js +1 -1
- package/dist/utils/templatePreparation.js +58 -62
- package/dist/utils/urlSchemes.js +4 -0
- package/package.json +1 -1
- package/dist/components/organisms/extensions/recommendation/StrategyDetailDrawer.vue.js +0 -36
- package/dist/components/organisms/extensions/recommendation/StrategyDetailDrawer.vue2.js +0 -244
- package/dist/components/organisms/extensions/recommendation/strategy-detail/CampaignTable.vue.js +0 -18
- package/dist/components/organisms/extensions/recommendation/strategy-detail/CampaignTable.vue2.js +0 -42
- package/dist/components/organisms/extensions/recommendation/strategy-detail/FilterHumanizer.vue.js +0 -20
- package/dist/components/organisms/extensions/recommendation/strategy-detail/FilterHumanizer.vue2.js +0 -18
- package/dist/components/organisms/extensions/recommendation/strategy-detail/HumanizerCondition.vue.js +0 -20
- package/dist/components/organisms/extensions/recommendation/strategy-detail/HumanizerCondition.vue2.js +0 -60
- package/dist/components/organisms/extensions/recommendation/strategy-detail/HumanizerGroup.vue.js +0 -19
- package/dist/components/organisms/extensions/recommendation/strategy-detail/HumanizerGroup.vue2.js +0 -19
- package/dist/components/organisms/extensions/recommendation/strategy-detail/InfoDisplayValue.vue.js +0 -22
- package/dist/components/organisms/extensions/recommendation/strategy-detail/InfoDisplayValue.vue2.js +0 -29
- package/dist/composables/useStrategyFilters.js +0 -16
- package/dist/enums/extensions/filteringV2.js +0 -8
- package/dist/enums/extensions/strategyDetail.js +0 -148
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +0 -146
- package/dist/extensions/Blocks/Recommendation/utils/strategyHumanizer.js +0 -97
- package/dist/extensions/Blocks/Recommendation/utils/strategySummary.js +0 -10
- package/dist/src/components/organisms/extensions/recommendation/StrategyDetailDrawer.vue.d.ts +0 -2
- package/dist/src/components/organisms/extensions/recommendation/strategy-detail/CampaignTable.vue.d.ts +0 -43
- package/dist/src/components/organisms/extensions/recommendation/strategy-detail/FilterHumanizer.vue.d.ts +0 -29
- package/dist/src/components/organisms/extensions/recommendation/strategy-detail/HumanizerCondition.vue.d.ts +0 -40
- package/dist/src/components/organisms/extensions/recommendation/strategy-detail/HumanizerGroup.vue.d.ts +0 -38
- package/dist/src/components/organisms/extensions/recommendation/strategy-detail/InfoDisplayValue.vue.d.ts +0 -51
- package/dist/src/composables/useStrategyFilters.d.ts +0 -24
- package/dist/src/enums/extensions/filteringV2.d.ts +0 -72
- package/dist/src/enums/extensions/strategyDetail.d.ts +0 -90
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -61
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyHumanizer.d.ts +0 -50
- package/dist/src/extensions/Blocks/Recommendation/utils/strategySummary.d.ts +0 -34
- /package/dist/src/{extensions/Blocks/Recommendation/utils → utils}/preserveTextStyles.d.ts +0 -0
|
@@ -1,17 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { URLS as o, MERGE_TAGS as a } from "../enums/unsubscribe.js";
|
|
2
|
+
import { UNSUBSCRIBE_LINK_SELECTOR as i } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
3
|
+
import { BASE_SAFE_URL_SCHEMES as u } from "../utils/urlSchemes.js";
|
|
4
|
+
const E = ["click", "auxclick"], d = [
|
|
5
|
+
...Object.values(a),
|
|
6
|
+
o.UNSUBSCRIBE_URL,
|
|
7
|
+
o.PREFERENCES_URL
|
|
8
|
+
], l = (e) => {
|
|
9
|
+
if (e.matches(i))
|
|
10
|
+
return !0;
|
|
11
|
+
const r = e.getAttribute("href") ?? "";
|
|
12
|
+
return d.some((t) => r.includes(t));
|
|
13
|
+
}, S = [...u, "tel:", "sms:"], f = (e) => {
|
|
14
|
+
const r = (e.getAttribute("href") ?? "").trim();
|
|
15
|
+
return r === "" || r.startsWith("#") || r.startsWith("{{") ? !1 : S.includes(e.protocol);
|
|
16
|
+
}, m = (e) => {
|
|
17
|
+
var t, n;
|
|
18
|
+
const r = (n = (t = e.target) == null ? void 0 : t.closest) == null ? void 0 : n.call(t, "a");
|
|
19
|
+
if (r) {
|
|
20
|
+
if (l(r) || !f(r)) {
|
|
21
|
+
e.preventDefault(), e.stopPropagation();
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
r.setAttribute("target", "_blank"), r.setAttribute("rel", "noopener noreferrer");
|
|
25
|
+
}
|
|
26
|
+
}, R = (e) => {
|
|
27
|
+
e.preventDefault(), e.stopPropagation();
|
|
28
|
+
}, s = /* @__PURE__ */ new WeakSet(), c = "guidoPreviewGuarded", g = () => ({ guardPreviewInteractions: (r) => {
|
|
4
29
|
try {
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
30
|
+
const t = r.contentDocument;
|
|
31
|
+
if (!t || s.has(t))
|
|
7
32
|
return;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
} catch (
|
|
12
|
-
console.warn("[usePreviewInteractionGuard] Could not guard preview iframe:",
|
|
33
|
+
delete t.documentElement.dataset[c], E.forEach((n) => {
|
|
34
|
+
t.addEventListener(n, m, !0);
|
|
35
|
+
}), t.addEventListener("submit", R, !0), s.add(t), t.documentElement.dataset[c] = "true";
|
|
36
|
+
} catch (t) {
|
|
37
|
+
console.warn("[usePreviewInteractionGuard] Could not guard preview iframe:", t);
|
|
13
38
|
}
|
|
14
39
|
} });
|
|
15
40
|
export {
|
|
16
|
-
|
|
41
|
+
g as usePreviewInteractionGuard
|
|
17
42
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { getRecommendationFeedSourceMaps as
|
|
2
|
-
import { MinDeviceViewport as
|
|
3
|
-
import { useRecommendationExtensionStore as
|
|
4
|
-
import { generateCompleteFilterQuery as
|
|
5
|
-
import { getPartnerRecommendationParams as
|
|
6
|
-
import { useConfigStore as
|
|
7
|
-
const
|
|
8
|
-
|
|
1
|
+
import { getRecommendationFeedSourceMaps as I, URLS as R } from "../enums/extensions/recommendationBlock.js";
|
|
2
|
+
import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
5
|
+
import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
|
|
6
|
+
import { useConfigStore as x } from "../stores/config.js";
|
|
7
|
+
const k = () => ({
|
|
8
|
+
calculateCardWidth: ({
|
|
9
9
|
mobileLeftPadding: a,
|
|
10
|
-
mobileRightPadding:
|
|
11
|
-
cardsInRow:
|
|
12
|
-
unresponsive:
|
|
10
|
+
mobileRightPadding: s,
|
|
11
|
+
cardsInRow: c,
|
|
12
|
+
unresponsive: o
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
return (
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
const r = o ? c : 1, e = a + s + (r - 1) * b;
|
|
15
|
+
return (C - e) / r;
|
|
16
|
+
},
|
|
17
|
+
getRecommendationCampaignData: (a) => {
|
|
18
|
+
const s = l(), c = Number(a), o = s.blockStates[c];
|
|
19
|
+
if (!o)
|
|
19
20
|
return {
|
|
20
21
|
textTrimming: !1,
|
|
21
22
|
orientation: "vertical",
|
|
@@ -28,81 +29,49 @@ const M = () => {
|
|
|
28
29
|
discountBeforeTextValue: "",
|
|
29
30
|
discountAfterTextValue: ""
|
|
30
31
|
};
|
|
31
|
-
const { recommendationConfigs:
|
|
32
|
+
const { recommendationConfigs: r } = o, e = r.orientation === "grid" ? "vertical" : "horizontal";
|
|
32
33
|
return {
|
|
33
|
-
textTrimming:
|
|
34
|
+
textTrimming: r.textTrimming,
|
|
34
35
|
orientation: e,
|
|
35
36
|
mobileLeftPadding: 0,
|
|
36
37
|
mobileRightPadding: 0,
|
|
37
|
-
cardsInRow:
|
|
38
|
-
unresponsive:
|
|
38
|
+
cardsInRow: r.cardsInRow,
|
|
39
|
+
unresponsive: r.unresponsive,
|
|
39
40
|
priceBeforeTextValue: "",
|
|
40
41
|
priceAfterTextValue: "",
|
|
41
42
|
discountBeforeTextValue: "",
|
|
42
43
|
discountAfterTextValue: ""
|
|
43
44
|
};
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
let e;
|
|
66
|
-
if (c)
|
|
67
|
-
e = c;
|
|
68
|
-
else {
|
|
69
|
-
const o = s.blockStates[n];
|
|
70
|
-
if (!o)
|
|
71
|
-
return "";
|
|
72
|
-
const { recommendationConfigs: i } = o;
|
|
73
|
-
e = {
|
|
74
|
-
strategy: i.strategy,
|
|
75
|
-
strategyId: i.strategyId,
|
|
76
|
-
language: i.language,
|
|
77
|
-
currencyCode: i.currencySettings.value,
|
|
78
|
-
size: i.size,
|
|
79
|
-
productIds: i.productIds,
|
|
80
|
-
filters: i.filters,
|
|
81
|
-
shuffleProducts: i.shuffleProducts
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
const d = e.strategyId ? s.strategyUrlTemplates[e.strategyId] : "";
|
|
85
|
-
if (d) {
|
|
86
|
-
const o = y(d, {
|
|
87
|
-
LOCALE: e.language,
|
|
88
|
-
CURRENCY: e.currencyCode,
|
|
89
|
-
CAMPAIGN_ID: r.variationId,
|
|
90
|
-
STRATEGY_ID: e.strategyId,
|
|
91
|
-
CLIENT_ID: "6KcLM9TwheVB1mgK",
|
|
92
|
-
USER_ID: "{user_id}",
|
|
93
|
-
ITEM_ID: "{itemId}"
|
|
94
|
-
});
|
|
95
|
-
return s.recommendationCampaignUrls[a] = o, o;
|
|
96
|
-
}
|
|
97
|
-
const C = ((m = E().find((o) => o.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
98
|
-
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", r.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", r.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
99
|
-
const R = e.filters.filter((o) => o.isValid), l = _(R);
|
|
100
|
-
l && t.set("filter", l), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(b(r.partnerName, e.strategy)).forEach(([o, i]) => t.set(o, i));
|
|
101
|
-
const T = decodeURIComponent(t.toString()), u = `${S.RECOMMENDATION_API_URL}/v2/${C}?${T}`;
|
|
102
|
-
return s.recommendationCampaignUrls[a] = u, u;
|
|
45
|
+
},
|
|
46
|
+
buildCampaignUrl: (a, s) => {
|
|
47
|
+
var m;
|
|
48
|
+
const c = l(), o = x(), r = Number(a);
|
|
49
|
+
let e;
|
|
50
|
+
if (s)
|
|
51
|
+
e = s;
|
|
52
|
+
else {
|
|
53
|
+
const i = c.blockStates[r];
|
|
54
|
+
if (!i)
|
|
55
|
+
return "";
|
|
56
|
+
const { recommendationConfigs: n } = i;
|
|
57
|
+
e = {
|
|
58
|
+
strategy: n.strategy,
|
|
59
|
+
language: n.language,
|
|
60
|
+
currencyCode: n.currencySettings.value,
|
|
61
|
+
size: n.size,
|
|
62
|
+
productIds: n.productIds,
|
|
63
|
+
filters: n.filters,
|
|
64
|
+
shuffleProducts: n.shuffleProducts
|
|
65
|
+
};
|
|
103
66
|
}
|
|
104
|
-
|
|
105
|
-
};
|
|
67
|
+
const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
|
|
68
|
+
t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", o.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", o.variationId), e.strategy === "manualMerchandising" ? t.set("productId", e.productIds.join(",")) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
|
|
69
|
+
const g = e.filters.filter((i) => i.isValid), d = h(g);
|
|
70
|
+
d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(o.partnerName, e.strategy)).forEach(([i, n]) => t.set(i, n));
|
|
71
|
+
const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
|
|
72
|
+
return c.recommendationCampaignUrls[a] = u, u;
|
|
73
|
+
}
|
|
74
|
+
});
|
|
106
75
|
export {
|
|
107
|
-
|
|
76
|
+
k as useRecommendation
|
|
108
77
|
};
|
|
@@ -1,111 +1,112 @@
|
|
|
1
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
2
|
-
import { useRecommendationExtensionStore as
|
|
3
|
-
import { formatPrice as
|
|
4
|
-
|
|
1
|
+
import { BLOCK_ROOT_SELECTOR as f, CURRENCY_ATTR as A, CONTAINER_SELECTOR as O } from "../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
2
|
+
import { useRecommendationExtensionStore as C } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
3
|
+
import { formatPrice as _ } from "../extensions/Blocks/Recommendation/utils/priceFormatter.js";
|
|
4
|
+
import { BASE_SAFE_URL_SCHEMES as R } from "../utils/urlSchemes.js";
|
|
5
|
+
const S = `${f}[recommendation-id]`, h = ".product-old-price", T = /\{\{(?:reco_)?(\d+_\d+_[a-zA-Z0-9_.]+)\}\}/g, b = new RegExp(
|
|
5
6
|
"\\{%\\s*if\\s+([\\s\\S]+?)\\s*%\\}([\\s\\S]*?)(?:\\{%\\s*else\\s*%\\}([\\s\\S]*?))?\\{%\\s*endif\\s*%\\}",
|
|
6
7
|
"g"
|
|
7
8
|
);
|
|
8
|
-
function
|
|
9
|
+
function L(e) {
|
|
9
10
|
return e.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
-
var
|
|
13
|
-
const
|
|
14
|
-
return
|
|
12
|
+
function g(e) {
|
|
13
|
+
var c;
|
|
14
|
+
const i = (c = e.replace(/[\u0000-\u0020]+/g, "").toLowerCase().match(/^([a-z][a-z0-9+.-]*):/)) == null ? void 0 : c[1];
|
|
15
|
+
return i && !R.includes(`${i}:`) ? "" : e;
|
|
15
16
|
}
|
|
16
17
|
function N(e) {
|
|
17
|
-
const t = e.getAttribute(
|
|
18
|
+
const t = e.getAttribute(A.CURRENCY) || "USD", i = e.getAttribute(A.DECIMAL_SEPARATOR) || ".", c = e.getAttribute(A.THOUSAND_SEPARATOR) || ",";
|
|
18
19
|
return {
|
|
19
20
|
code: t,
|
|
20
|
-
symbol: e.getAttribute(
|
|
21
|
-
alignment: e.getAttribute(
|
|
22
|
-
decimalCount: parseInt(e.getAttribute(
|
|
23
|
-
decimalSeparator:
|
|
24
|
-
thousandSeparator:
|
|
21
|
+
symbol: e.getAttribute(A.SYMBOL) || t,
|
|
22
|
+
alignment: e.getAttribute(A.ALIGNMENT) === "0" ? "before" : "after",
|
|
23
|
+
decimalCount: parseInt(e.getAttribute(A.DECIMAL_COUNT) || "2") || 2,
|
|
24
|
+
decimalSeparator: i,
|
|
25
|
+
thousandSeparator: c
|
|
25
26
|
};
|
|
26
27
|
}
|
|
27
|
-
function
|
|
28
|
+
function E(e, t) {
|
|
28
29
|
return (e == null ? void 0 : e[t]) ?? Object.values(e ?? {})[0] ?? 0;
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
const
|
|
32
|
-
return
|
|
31
|
+
function $(e, t) {
|
|
32
|
+
const i = E(e.original_price, t), c = E(e.price, t), n = i > 0 ? Math.round((i - c) / i * 100) : 0;
|
|
33
|
+
return n > 0 ? `${n}%` : "0%";
|
|
33
34
|
}
|
|
34
|
-
function P(e, t,
|
|
35
|
-
|
|
36
|
-
const r = (m) => `${
|
|
37
|
-
e.set(r("name"),
|
|
38
|
-
e.set(r(`product_attribute.${m}`), String(
|
|
35
|
+
function P(e, t, i, c, n, a) {
|
|
36
|
+
c.forEach((o, s) => {
|
|
37
|
+
const r = (m) => `${i}_${s}_${m}`, u = _({ price: E(o.price, n.code), currency: n }), l = _({ price: E(o.original_price, n.code), currency: n }), d = $(o, n.code);
|
|
38
|
+
e.set(r("name"), o.name ?? ""), e.set(r("image_url"), g(o.image_url ?? "")), e.set(r("url"), g(o.url ?? "")), e.set(r("item_id"), o.item_id ?? ""), e.set(r("currency"), ""), e.set(r("price"), u), e.set(r("original_price"), l), e.set(r("discount"), d), e.set(r("omnibus_price"), l), e.set(r("omnibus_discount"), d), a && u === l && t.add(`${i}_${s}`), Object.entries(o.product_attributes ?? {}).forEach(([m, p]) => {
|
|
39
|
+
e.set(r(`product_attribute.${m}`), String(p)), e.set(r(m), String(p));
|
|
39
40
|
});
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
const
|
|
44
|
-
if (!
|
|
43
|
+
function z(e, t) {
|
|
44
|
+
const i = e.match(/^(.+?)\s*(!=|==)\s*"([^"]*)"$/);
|
|
45
|
+
if (!i)
|
|
45
46
|
return !0;
|
|
46
|
-
const [,
|
|
47
|
-
return
|
|
47
|
+
const [, c, n, a] = i, o = t.get(c.trim()) ?? "";
|
|
48
|
+
return n === "!=" ? o !== a : o === a;
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
+
function w(e, t) {
|
|
50
51
|
return e.replace(
|
|
51
|
-
|
|
52
|
-
(
|
|
52
|
+
b,
|
|
53
|
+
(i, c, n, a) => c.split(/\s+and\s+/).every((s) => z(s.trim(), t)) ? n : a ?? ""
|
|
53
54
|
);
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
+
function D(e) {
|
|
56
57
|
let t = e;
|
|
57
58
|
for (; t.children.length === 1; )
|
|
58
59
|
[t] = t.children;
|
|
59
60
|
return t;
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
-
var
|
|
62
|
+
function I(e, t) {
|
|
63
|
+
var o;
|
|
63
64
|
if (!t.size)
|
|
64
65
|
return e;
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
const r = Number(
|
|
66
|
+
const i = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), c = new DOMParser().parseFromString(i, "text/html");
|
|
67
|
+
c.querySelectorAll(S).forEach((s) => {
|
|
68
|
+
const r = Number(s.getAttribute("recommendation-id"));
|
|
68
69
|
if (!Number.isFinite(r))
|
|
69
70
|
return;
|
|
70
|
-
const u =
|
|
71
|
-
(u.length ? Array.from(u) : [
|
|
72
|
-
d.querySelectorAll(
|
|
73
|
-
t.has(`${r}_${
|
|
71
|
+
const u = s.querySelectorAll(O);
|
|
72
|
+
(u.length ? Array.from(u) : [s]).forEach((d) => {
|
|
73
|
+
d.querySelectorAll(h).forEach((m, p) => {
|
|
74
|
+
t.has(`${r}_${p}`) && (D(m).textContent = "");
|
|
74
75
|
});
|
|
75
76
|
});
|
|
76
77
|
});
|
|
77
|
-
const
|
|
78
|
-
return ((
|
|
79
|
-
` : "") +
|
|
78
|
+
const n = (o = e.match(/<!DOCTYPE[^>]*>/i)) == null ? void 0 : o[0];
|
|
79
|
+
return ((n ? `${n}
|
|
80
|
+
` : "") + c.documentElement.outerHTML).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
+
function y(e) {
|
|
82
83
|
if (!e || !e.includes("recommendation-block-v2"))
|
|
83
84
|
return e;
|
|
84
|
-
const t =
|
|
85
|
-
if (
|
|
85
|
+
const t = C(), i = new DOMParser().parseFromString(e, "text/html"), c = Array.from(i.querySelectorAll(S)), n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set();
|
|
86
|
+
if (c.forEach((s) => {
|
|
86
87
|
var l;
|
|
87
|
-
const r = Number(
|
|
88
|
+
const r = Number(s.getAttribute("recommendation-id"));
|
|
88
89
|
if (!Number.isFinite(r))
|
|
89
90
|
return;
|
|
90
91
|
const u = ((l = t.blockStates[r]) == null ? void 0 : l.recommendationProducts) ?? [];
|
|
91
92
|
u.length && P(
|
|
92
|
-
|
|
93
|
+
n,
|
|
93
94
|
a,
|
|
94
95
|
r,
|
|
95
96
|
u,
|
|
96
|
-
N(
|
|
97
|
-
|
|
97
|
+
N(s),
|
|
98
|
+
s.getAttribute("hide-price") === "true"
|
|
98
99
|
);
|
|
99
|
-
}), !
|
|
100
|
+
}), !n.size)
|
|
100
101
|
return e;
|
|
101
|
-
let
|
|
102
|
-
return
|
|
103
|
-
|
|
104
|
-
(
|
|
105
|
-
),
|
|
102
|
+
let o = I(e, a);
|
|
103
|
+
return o = o.replace(
|
|
104
|
+
T,
|
|
105
|
+
(s, r) => n.has(r) ? L(n.get(r)) : s
|
|
106
|
+
), o = w(o, n), o;
|
|
106
107
|
}
|
|
107
|
-
const q = () => ({ substituteRecommendationPreview:
|
|
108
|
+
const q = () => ({ substituteRecommendationPreview: y });
|
|
108
109
|
export {
|
|
109
|
-
|
|
110
|
+
y as substituteRecommendationPreview,
|
|
110
111
|
q as useRecommendationPreview
|
|
111
112
|
};
|
|
@@ -1,32 +1,51 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import { useSaveStart as
|
|
1
|
+
import { useActionsApi as T } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as k } from "./useConfig.js";
|
|
3
|
+
import { useSaveStart as B, useSaveComplete as E } from "./useGuidoActions.js";
|
|
4
4
|
import { useSyncModuleExtractor as q } from "./useSyncModuleExtractor.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
import { ToasterTypeOptions as C } from "../enums/toaster.js";
|
|
6
|
+
import { useStripoApi as D } from "../services/stripoApi.js";
|
|
7
|
+
import { useTemplatePreparation as L } from "../utils/templatePreparation.js";
|
|
8
|
+
import { useAllowlist as P } from "./useAllowlist.js";
|
|
9
|
+
import { useHtmlValidator as U } from "./useHtmlValidator.js";
|
|
10
|
+
import { useToaster as A } from "./useToaster.js";
|
|
11
|
+
import { useCouponBlockValidator as M } from "./validators/useCouponBlockValidator.js";
|
|
12
|
+
import { useLiquidValidator as h } from "./validators/useLiquidValidator.js";
|
|
13
|
+
import { useUnsubscribeBlockValidator as F } from "./validators/useUnsubscribeBlockValidator.js";
|
|
14
|
+
const $ = () => {
|
|
15
|
+
const n = B(), l = E(), { validateHtml: c } = U(), { validateLiquidSyntax: d } = h(), { validateCouponBlockTags: m } = M(), { validateUnsubscribeBlockUniqueness: u, validateUnsubscribeBlockHasTemplate: p } = F(), { callbacks: e, isFeatureEnabled: a } = k(), { extractSyncModuleData: f } = q(), { setSyncModuleUnsubscriptionPages: v } = D(), { editorSave: S } = T(), { showToaster: b } = A(), { getBlockedDomains: w, resolveToast: V } = P();
|
|
16
|
+
return { save: async (y = !1, s = !1) => {
|
|
17
|
+
var r;
|
|
18
|
+
n();
|
|
19
|
+
const { prepareTemplateDetails: H } = L(), t = await H();
|
|
20
|
+
if (!m(t.compiledHtml) || !u(t.compiledHtml) || !p(t.compiledHtml))
|
|
18
21
|
return;
|
|
19
|
-
if (
|
|
20
|
-
if (!await
|
|
22
|
+
if (a("liquidSyntax")) {
|
|
23
|
+
if (!await d(t.compiledHtml))
|
|
21
24
|
return;
|
|
22
|
-
} else if (!await
|
|
25
|
+
} else if (!await c(t.compiledHtml, t.dynamicContentList, !0))
|
|
23
26
|
return;
|
|
24
|
-
if ((
|
|
27
|
+
if ((r = e.value) != null && r.externalValidation && !await e.value.externalValidation(t))
|
|
25
28
|
return;
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
if (a("allowlistEnabled")) {
|
|
30
|
+
const i = await w(t.compiledHtml, t.css);
|
|
31
|
+
if (i.length) {
|
|
32
|
+
if (!s) {
|
|
33
|
+
const o = await V(i);
|
|
34
|
+
o != null && o.message && b({
|
|
35
|
+
type: C.Warning,
|
|
36
|
+
message: o.message,
|
|
37
|
+
actionButton: o.actionButton
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (!await S())
|
|
44
|
+
return;
|
|
45
|
+
const { unsubscribePayload: g, stripoModules: x } = f(t.rawHtml);
|
|
46
|
+
return await v(g), t.modules = x, y || l({ ...t, silent: s }), t;
|
|
28
47
|
} };
|
|
29
48
|
};
|
|
30
49
|
export {
|
|
31
|
-
|
|
50
|
+
$ as useSave
|
|
32
51
|
};
|