@useinsider/guido 3.30.0-beta.6054a97 → 3.30.0-beta.64ede62
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/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +11 -16
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +1 -1
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +44 -50
- package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
- package/dist/composables/useExport.js +8 -7
- package/dist/composables/useHtmlValidator.js +102 -100
- package/dist/composables/useToaster.js +11 -10
- package/dist/composables/useVersionHistoryApi.js +22 -21
- package/dist/composables/validators/useLiquidValidator.js +26 -24
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +64 -59
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +40 -39
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +33 -32
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +79 -78
- package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +50 -41
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +2 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/ampPreviewSanitizer.d.ts +5 -0
- package/dist/stores/preview.js +21 -15
- package/dist/utils/ampPreviewSanitizer.js +46 -0
- package/package.json +1 -1
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from "./DesktopPreview.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import
|
|
4
|
-
var
|
|
5
|
-
var s = this, e = s._self._c,
|
|
6
|
-
return e("div", { staticClass: "desktop-preview-wrapper" }, [e("p", { staticClass: "f-s-1 f-w-600 l-h-1 t-t-u t-c-53 mb-6 l-s-5" }, [s._v(" " + s._s(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
allow-forms
|
|
10
|
-
allow-scripts
|
|
11
|
-
allow-popups-to-escape-sandbox`, srcdoc: t.previewStore.previewHtml }, on: { load: t.onIframeLoad } }) : s._e()])])], 1)]);
|
|
12
|
-
}, i = [], n = /* @__PURE__ */ r(
|
|
13
|
-
o,
|
|
14
|
-
a,
|
|
3
|
+
import o from "../../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
+
var i = function() {
|
|
5
|
+
var s = this, e = s._self._c, r = s._self._setupProxy;
|
|
6
|
+
return e("div", { staticClass: "desktop-preview-wrapper" }, [e("p", { staticClass: "f-s-1 f-w-600 l-h-1 t-t-u t-c-53 mb-6 l-s-5" }, [s._v(" " + s._s(r.trans("email-editor.desktop-preview")) + " ")]), e("div", { ref: "containerRef", staticClass: "desktop-preview d-f f-d-c o-h s-1" }, [e(r.DesktopBrowserHeader), e("div", { staticClass: "desktop-preview__content d-f f-g-1 o-h b-c-5 min-h-0" }, [e("div", { staticClass: "f-g-1 h-1 o-h b-c-4 min-w-0" }, [r.isContainerReady ? e("iframe", { key: r.previewStore.previewSandbox, staticClass: "desktop-preview__iframe d-b w-1 h-1 b-c-4 bor-s-n", attrs: { sandbox: r.previewStore.previewSandbox, srcdoc: r.previewStore.previewHtml }, on: { load: r.onIframeLoad } }) : s._e()])])], 1)]);
|
|
7
|
+
}, a = [], n = /* @__PURE__ */ o(
|
|
8
|
+
t,
|
|
15
9
|
i,
|
|
10
|
+
a,
|
|
16
11
|
!1,
|
|
17
12
|
null,
|
|
18
|
-
"
|
|
13
|
+
"f5ff6219"
|
|
19
14
|
);
|
|
20
|
-
const
|
|
15
|
+
const _ = n.exports;
|
|
21
16
|
export {
|
|
22
|
-
|
|
17
|
+
_ as default
|
|
23
18
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import a from "./ContentView.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import
|
|
4
|
-
var
|
|
5
|
-
var t = this, s = t._self._c,
|
|
3
|
+
import r from "../../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
+
var n = function() {
|
|
5
|
+
var t = this, s = t._self._c, e = t._self._setupProxy;
|
|
6
6
|
return s("div", { staticClass: "w-1 h-1 b-c-4 d-f f-d-c" }, [s("div", { staticClass: "d-f j-c-s-b a-i-c p-2 h-6-s" }, [s("div", { staticClass: "d-f a-i-c cur-p", on: { click: function(l) {
|
|
7
7
|
return t.$emit("back-to-inbox");
|
|
8
|
-
} } }, [s(
|
|
9
|
-
}, i = [],
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
} } }, [s(e.InIcons, { staticClass: "f-s-3 i-c-7", attrs: { name: "line-chevron-left" } }), s("span", { staticClass: "ml-2 f-s-1 f-w-400 l-h-1 t-c-7" }, [t._v(t._s(e.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(e.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(e.InIcons, { staticClass: "ml-1 i-c-52", attrs: { name: "line-chevron-up" } })], 1)]), s("div", { staticClass: "iframe-wrapper f-g-1 o-h" }, [s("iframe", { key: e.previewStore.previewSandbox, ref: "iframeRef", staticClass: "iframe-scaled d-b b-c-4 bor-s-n", attrs: { sandbox: e.previewStore.previewSandbox, srcdoc: e.previewStore.previewHtml }, on: { load: e.onLoad } })])]);
|
|
9
|
+
}, i = [], c = /* @__PURE__ */ r(
|
|
10
|
+
a,
|
|
11
|
+
n,
|
|
12
12
|
i,
|
|
13
13
|
!1,
|
|
14
14
|
null,
|
|
15
|
-
"
|
|
15
|
+
"a7102458"
|
|
16
16
|
);
|
|
17
|
-
const
|
|
17
|
+
const p = c.exports;
|
|
18
18
|
export {
|
|
19
|
-
|
|
19
|
+
p as default
|
|
20
20
|
};
|
|
@@ -3,7 +3,7 @@ import r from "./AssignStrategyDrawer.vue2.js";
|
|
|
3
3
|
import o from "../../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
4
|
var a = function() {
|
|
5
5
|
var e = this, s = e._self._c, t = e._self._setupProxy;
|
|
6
|
-
return t.
|
|
6
|
+
return t.store.assignStrategyDrawerStatus ? s(t.OrgStrategyDetailModal, { staticClass: "assign-strategy-drawer", attrs: { "description-status": "", show: "", "description-text": t.drawerDescription, "footer-button-group-options": t.footerButtonGroupOptions, strategy: t.selectedStrategy ?? {}, "title-text": t.trans("gpt-app-builder.assign-recommendation-strategy") }, on: { close: t.closeDrawer, primaryClick: t.assignStrategy }, scopedSlots: e._u([{ key: "contentTop", fn: function() {
|
|
7
7
|
return [s("div", { staticClass: "assign-strategy-drawer-content px-5 py-5" }, [t.strategiesLoading ? s(t.InSkeleton, { staticClass: "assign-strategy-select-skeleton", attrs: { sizing: t.SELECT_SKELETON_SIZING } }) : s(t.OrgStrategyDropdown, { staticClass: "assign-strategy-select w-23-s", attrs: { id: "assign-strategy-select", "create-button-visible": "", "info-box-position": "bottom right", "placeholder-text": t.trans("smart-recommender.select-recommendation-strategy"), "selected-strategy-id": t.selectedStrategyId, state: t.showSelectionError ? "error" : "default", "state-message": t.showSelectionError ? t.trans("ds-steps.select-strategy-tooltip") : "", strategies: t.strategyOptions }, on: { create: function(c) {
|
|
8
8
|
return t.store.openStrategyCreation();
|
|
9
9
|
}, infoBoxButtonClick: t.onInfoBoxButtonClick, select: t.onSelect } })], 1)];
|
|
@@ -1,57 +1,51 @@
|
|
|
1
|
-
import { defineComponent as N, defineAsyncComponent as E, ref as
|
|
1
|
+
import { defineComponent as N, defineAsyncComponent as E, ref as D, computed as o, watch as R } from "vue";
|
|
2
2
|
import "@useinsider/design-system-organisms/style";
|
|
3
|
-
import { useToaster as
|
|
4
|
-
import { useTranslations as
|
|
5
|
-
import { DOTTED_DATE_LOCALE as
|
|
6
|
-
import { URLS as
|
|
7
|
-
import { ToasterTypeOptions as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
9
|
-
import { commitStrategyChange as
|
|
10
|
-
import
|
|
11
|
-
import { formatShortDate as
|
|
12
|
-
import { asText as
|
|
13
|
-
import { escapeHtml as
|
|
3
|
+
import { useToaster as P } from "../../../../composables/useToaster.js";
|
|
4
|
+
import { useTranslations as U } from "../../../../composables/useTranslations.js";
|
|
5
|
+
import { DOTTED_DATE_LOCALE as G } from "../../../../enums/date.js";
|
|
6
|
+
import { URLS as M } from "../../../../enums/extensions/recommendationBlock.js";
|
|
7
|
+
import { ToasterTypeOptions as p } from "../../../../enums/toaster.js";
|
|
8
|
+
import { useRecommendationExtensionStore as $ } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
|
+
import { commitStrategyChange as O } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
|
|
10
|
+
import z from "./StrategyInfoBoxContent.vue.js";
|
|
11
|
+
import { formatShortDate as H } from "../../../../utils/dateUtil.js";
|
|
12
|
+
import { asText as g } from "../../../../utils/genericUtil.js";
|
|
13
|
+
import { escapeHtml as f } from "../../../../utils/htmlEscape.js";
|
|
14
14
|
import { InSkeleton as I } from "@useinsider/design-system-vue";
|
|
15
|
-
const
|
|
15
|
+
const it = /* @__PURE__ */ N({
|
|
16
16
|
__name: "AssignStrategyDrawer",
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
17
|
+
setup(F) {
|
|
18
|
+
const d = () => import("@useinsider/design-system-organisms"), S = (t, r) => ({
|
|
19
19
|
render: (s) => s(I, { props: { sizing: { width: t, height: r } } })
|
|
20
20
|
}), h = E({
|
|
21
|
-
loader: async () => (await
|
|
21
|
+
loader: async () => (await d()).OrgStrategyDetailModal,
|
|
22
22
|
loadingComponent: S(480, 240),
|
|
23
23
|
delay: 0
|
|
24
24
|
}), x = E({
|
|
25
|
-
loader: async () => (await
|
|
26
|
-
}), i = "guido-edit-strategy-", A = { width: 480, height: 42 }, a =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
));
|
|
30
|
-
R(() => e.assignStrategyDrawerStatus, async (t) => {
|
|
31
|
-
if (!t) {
|
|
32
|
-
await P(), m.value = e.assignStrategyDrawerStatus;
|
|
25
|
+
loader: async () => (await d()).OrgStrategyDropdown
|
|
26
|
+
}), i = "guido-edit-strategy-", A = { width: 480, height: 42 }, a = U(), e = $(), { showToaster: c } = P(), n = D(null), m = "legacy", l = D(!1), C = o(() => e.strategiesLoading || e.legacyConversionLoading), L = o(() => e.assignStrategyDrawerStatus ? a("email-editor.assign-strategy-description", { url: M.RECOMMENDATION_STRATEGIES_PANEL_PATH }) : "");
|
|
27
|
+
R(() => e.assignStrategyDrawerStatus, (t) => {
|
|
28
|
+
if (!t)
|
|
33
29
|
return;
|
|
34
|
-
}
|
|
35
|
-
m.value = !0;
|
|
36
30
|
const { strategyId: r } = e.recommendationConfigs;
|
|
37
|
-
n.value = r || (e.isLegacyStrategyBlock ?
|
|
31
|
+
n.value = r || (e.isLegacyStrategyBlock ? m : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
|
|
38
32
|
c({
|
|
39
|
-
type:
|
|
33
|
+
type: p.Error,
|
|
40
34
|
message: a("discovery-strategy.error-description")
|
|
41
35
|
});
|
|
42
36
|
});
|
|
43
|
-
}
|
|
37
|
+
});
|
|
44
38
|
const v = (t) => {
|
|
45
|
-
const r =
|
|
39
|
+
const r = g(t.updated_at || t.created_at);
|
|
46
40
|
if (!r)
|
|
47
41
|
return "";
|
|
48
|
-
const s =
|
|
42
|
+
const s = H(r, G);
|
|
49
43
|
return a("recommendation-strategy.last-updated-on", { value: s });
|
|
50
|
-
},
|
|
44
|
+
}, _ = o(() => ({
|
|
51
45
|
text: a("ds-steps.legacy-strategy"),
|
|
52
|
-
value:
|
|
46
|
+
value: m,
|
|
53
47
|
hidden: !0
|
|
54
|
-
})),
|
|
48
|
+
})), y = o(() => e.strategies.map((t) => ({
|
|
55
49
|
text: t.name,
|
|
56
50
|
value: t.strategy_id,
|
|
57
51
|
infoBoxProps: {
|
|
@@ -60,10 +54,10 @@ const lt = /* @__PURE__ */ N({
|
|
|
60
54
|
variant: "information",
|
|
61
55
|
size: "small",
|
|
62
56
|
class: "assign-strategy-info-box",
|
|
63
|
-
titleText:
|
|
57
|
+
titleText: f(g(t.name)),
|
|
64
58
|
descriptionStatus: !0,
|
|
65
59
|
descriptionText: v(t),
|
|
66
|
-
slot:
|
|
60
|
+
slot: z,
|
|
67
61
|
slotProps: { strategy: t },
|
|
68
62
|
// The info box drops the option's value/text, so the id is the only channel
|
|
69
63
|
// that can carry the strategy back to the click handler.
|
|
@@ -76,14 +70,14 @@ const lt = /* @__PURE__ */ N({
|
|
|
76
70
|
icon: "line-open-website"
|
|
77
71
|
}]
|
|
78
72
|
}
|
|
79
|
-
}))),
|
|
73
|
+
}))), B = o(() => e.isLegacyStrategyBlock ? [_.value, ...y.value] : y.value), k = (t) => {
|
|
80
74
|
var w;
|
|
81
75
|
const r = (w = t == null ? void 0 : t.id) != null && w.startsWith(i) ? t.id.slice(i.length) : "";
|
|
82
76
|
if (!r)
|
|
83
77
|
return;
|
|
84
|
-
const s = e.currentRecommendationId,
|
|
85
|
-
e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null),
|
|
86
|
-
},
|
|
78
|
+
const s = e.currentRecommendationId, u = e.recommendationConfigs.strategyId === r;
|
|
79
|
+
e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), u && (e.removeStrategy(), s !== null && O(s, "Removed recommendation strategy")));
|
|
80
|
+
}, T = o(() => {
|
|
87
81
|
const t = e.strategies.find((r) => String(r.strategy_id) === String(n.value ?? ""));
|
|
88
82
|
return t ? { ...t, fallback_config: null } : null;
|
|
89
83
|
}), b = o(() => ({
|
|
@@ -98,10 +92,10 @@ const lt = /* @__PURE__ */ N({
|
|
|
98
92
|
labelText: a("products.cancel")
|
|
99
93
|
}
|
|
100
94
|
}));
|
|
101
|
-
return { __sfc: !0, loadOrganisms:
|
|
95
|
+
return { __sfc: !0, loadOrganisms: d, skeleton: S, OrgStrategyDetailModal: h, OrgStrategyDropdown: x, EDIT_BUTTON_ID_PREFIX: i, SELECT_SKELETON_SIZING: A, trans: a, store: e, showToaster: c, selectedStrategyId: n, LEGACY_OPTION_VALUE: m, showSelectionError: l, strategiesLoading: C, drawerDescription: L, lastUpdatedText: v, legacyStrategyOption: _, remoteStrategyOptions: y, strategyOptions: B, onInfoBoxButtonClick: k, selectedStrategy: T, footerButtonGroupOptions: b, closeDrawer: () => {
|
|
102
96
|
e.closeAssignStrategyDrawer();
|
|
103
97
|
}, assignStrategy: async () => {
|
|
104
|
-
const t =
|
|
98
|
+
const t = T.value;
|
|
105
99
|
if (!t) {
|
|
106
100
|
l.value = !0;
|
|
107
101
|
return;
|
|
@@ -109,26 +103,26 @@ const lt = /* @__PURE__ */ N({
|
|
|
109
103
|
let r = "";
|
|
110
104
|
try {
|
|
111
105
|
r = await e.resolveStrategyUrlTemplate(t, e.recommendationConfigs.currencySettings.value);
|
|
112
|
-
} catch (
|
|
113
|
-
console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed",
|
|
106
|
+
} catch (u) {
|
|
107
|
+
console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed", u);
|
|
114
108
|
}
|
|
115
109
|
if (!r) {
|
|
116
110
|
c({
|
|
117
|
-
type:
|
|
118
|
-
message: a("email-editor.strategy-assign-failed", { strategyName: t.name })
|
|
111
|
+
type: p.Error,
|
|
112
|
+
message: a("email-editor.strategy-assign-failed", { strategyName: f(g(t.name)) })
|
|
119
113
|
});
|
|
120
114
|
return;
|
|
121
115
|
}
|
|
122
116
|
const s = e.currentRecommendationId;
|
|
123
117
|
e.assignStrategy(t), c({
|
|
124
|
-
type:
|
|
125
|
-
message: a("email-editor.strategy-assigned-success", { strategyName: t.name })
|
|
126
|
-
}), e.closeAssignStrategyDrawer(), s !== null && await
|
|
118
|
+
type: p.Success,
|
|
119
|
+
message: a("email-editor.strategy-assigned-success", { strategyName: f(g(t.name)) })
|
|
120
|
+
}), e.closeAssignStrategyDrawer(), s !== null && await O(s, "Assigned recommendation strategy");
|
|
127
121
|
}, onSelect: (t) => {
|
|
128
122
|
n.value = t.value, l.value = !1;
|
|
129
123
|
}, InSkeleton: I };
|
|
130
124
|
}
|
|
131
125
|
});
|
|
132
126
|
export {
|
|
133
|
-
|
|
127
|
+
it as default
|
|
134
128
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ToasterTypeOptions as a } from "../enums/toaster.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { escapeHtml as m } from "../utils/htmlEscape.js";
|
|
3
|
+
import { useActionsApi as p } from "./useActionsApi.js";
|
|
4
|
+
import { useHtmlCompiler as d } from "./useHtmlCompiler.js";
|
|
5
|
+
import { useToaster as u } from "./useToaster.js";
|
|
6
|
+
const x = () => {
|
|
6
7
|
const c = (s, o, n) => {
|
|
7
8
|
const i = new Blob([s], { type: n }), t = URL.createObjectURL(i), e = document.createElement("a");
|
|
8
9
|
e.href = t, e.download = o, document.body.appendChild(e), e.click(), document.body.removeChild(e), URL.revokeObjectURL(t);
|
|
@@ -11,7 +12,7 @@ const H = () => {
|
|
|
11
12
|
return `${s}_${n}-${i}-${t}_${e}-${r}.html`;
|
|
12
13
|
};
|
|
13
14
|
return { exportHtml: async (s = !0) => {
|
|
14
|
-
const { getCompiledEmail: o } =
|
|
15
|
+
const { getCompiledEmail: o } = p(), { showToaster: n } = u(), { compileHtml: i } = d();
|
|
15
16
|
try {
|
|
16
17
|
const { html: t } = await o();
|
|
17
18
|
if (t) {
|
|
@@ -36,11 +37,11 @@ const H = () => {
|
|
|
36
37
|
const e = t instanceof Error ? t.message : String(t);
|
|
37
38
|
n({
|
|
38
39
|
type: a.Error,
|
|
39
|
-
message: `Error compiling email: ${e}`
|
|
40
|
+
message: `Error compiling email: ${m(e)}`
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
43
|
} };
|
|
43
44
|
};
|
|
44
45
|
export {
|
|
45
|
-
|
|
46
|
+
x as useExport
|
|
46
47
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useConfig as V } from "./useConfig.js";
|
|
2
2
|
import { getIgnoredRecommendationBlockIds as M } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
3
3
|
import { TemplateTypes as W } from "../enums/defaults.js";
|
|
4
|
-
import { CONDITION_TAG_REGEX as G, DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as K, CampaignCouldNotBeSavedKey as
|
|
4
|
+
import { CONDITION_TAG_REGEX as G, DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as K, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as X, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as j, VALID_DYNAMIC_VARIABLE_REGEX as U } from "../enums/html-validator.js";
|
|
5
5
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
6
6
|
import { BLOCK_ROOT_SELECTOR as q } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
7
7
|
import { itemsBlockDynamicVariables as z } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
@@ -10,57 +10,59 @@ import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as J } from "../extensions/B
|
|
|
10
10
|
import { useRecommendationExtensionStore as Q } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
11
11
|
import { filterToProductAttrValue as ee } from "../extensions/Blocks/Recommendation/utils/compositionKeys.js";
|
|
12
12
|
import { STRATEGY_FIELD_KEY as te, RecommendationAssignStrategyKey as ne, RecommendationRequiredFieldsKey as se } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
13
|
-
import { useRecommendationStore as
|
|
14
|
-
import { base64EncodeWithSpecialChars as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
import { useRecommendationStore as oe } from "../stores/recommendation.js";
|
|
14
|
+
import { base64EncodeWithSpecialChars as re } from "../utils/base64.js";
|
|
15
|
+
import { isPlainObject as ie, asText as ae } from "../utils/genericUtil.js";
|
|
16
|
+
import { escapeHtml as ce } from "../utils/htmlEscape.js";
|
|
17
|
+
import { computed as me } from "vue";
|
|
18
|
+
import { useHttp as le } from "./useHttp.js";
|
|
19
|
+
import { useToaster as ue } from "./useToaster.js";
|
|
20
|
+
import { useTranslations as de } from "./useTranslations.js";
|
|
21
|
+
const fe = /recommendation-id="(\d+)"/g;
|
|
22
|
+
function ge(s) {
|
|
23
|
+
return [...s.matchAll(fe)].map((l) => l[1]);
|
|
22
24
|
}
|
|
23
|
-
function
|
|
24
|
-
return
|
|
25
|
+
function pe(s, l) {
|
|
26
|
+
return l.some((f) => s.startsWith(`${f}_`));
|
|
25
27
|
}
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
const
|
|
29
|
-
return
|
|
28
|
+
const Ee = /^(\d+)_\d+_(.+)$/;
|
|
29
|
+
function Ce(s) {
|
|
30
|
+
const l = s.match(Ee);
|
|
31
|
+
return l ? { recoId: l[1], attribute: l[2] } : null;
|
|
30
32
|
}
|
|
31
|
-
function
|
|
32
|
-
const
|
|
33
|
+
function ye(s) {
|
|
34
|
+
const l = new Set(J);
|
|
33
35
|
return Object.values(s).forEach((f) => {
|
|
34
|
-
|
|
35
|
-
}),
|
|
36
|
+
l.add(ee(f).toLowerCase());
|
|
37
|
+
}), l;
|
|
36
38
|
}
|
|
37
|
-
function
|
|
39
|
+
function he(s, l, f, r, d) {
|
|
38
40
|
const u = s.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
|
|
39
41
|
if (!u)
|
|
40
42
|
return [];
|
|
41
|
-
const p = new Set(
|
|
43
|
+
const p = new Set(l.map((C) => C.toLowerCase())), E = [];
|
|
42
44
|
return u.forEach((C) => {
|
|
43
45
|
const g = C.slice(2, -2).trim().toLowerCase();
|
|
44
46
|
if (g !== "" && p.has(g))
|
|
45
47
|
return;
|
|
46
|
-
const y =
|
|
47
|
-
if (y &&
|
|
48
|
+
const y = Ce(g);
|
|
49
|
+
if (y && r.has(y.recoId)) {
|
|
48
50
|
if (!d || d.has(y.attribute))
|
|
49
51
|
return;
|
|
50
52
|
E.push(g);
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
pe(g, f) || g.includes(".") || E.push(g);
|
|
54
56
|
}), E;
|
|
55
57
|
}
|
|
56
|
-
function
|
|
57
|
-
return (s.replace(Y, "$1").match($) ?? []).filter((
|
|
58
|
-
const d =
|
|
59
|
-
return
|
|
58
|
+
function ve(s) {
|
|
59
|
+
return (s.replace(Y, "$1").match($) ?? []).filter((r) => {
|
|
60
|
+
const d = r.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
|
|
61
|
+
return j.includes(p) ? !1 : U.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
|
-
const
|
|
63
|
-
const { showToaster: s } =
|
|
64
|
+
const Ke = () => {
|
|
65
|
+
const { showToaster: s } = ue(), { post: l } = le(), { config: f } = V(), r = de(), d = oe(), u = Q(), p = me(
|
|
64
66
|
() => {
|
|
65
67
|
var e, t;
|
|
66
68
|
return ((t = (e = f.value) == null ? void 0 : e.partner) == null ? void 0 : t.messageType) === W.transactional;
|
|
@@ -73,161 +75,161 @@ const Ve = () => {
|
|
|
73
75
|
} catch {
|
|
74
76
|
return null;
|
|
75
77
|
}
|
|
76
|
-
return
|
|
78
|
+
return ye(u.filterList);
|
|
77
79
|
}, C = async (e) => {
|
|
78
|
-
const n = await
|
|
79
|
-
|
|
80
|
-
{ html:
|
|
81
|
-
), { status:
|
|
82
|
-
return
|
|
80
|
+
const t = "/newsletter/template-library/check-template-html-body", { data: n } = await l(
|
|
81
|
+
t,
|
|
82
|
+
{ html: re(e) }
|
|
83
|
+
), { status: o, message: a } = ie(n) ? n : { status: void 0, message: void 0 }, i = ae(a);
|
|
84
|
+
return o || s({
|
|
83
85
|
type: c.Error,
|
|
84
|
-
message:
|
|
85
|
-
}),
|
|
86
|
+
message: o === void 0 && i !== "" ? ce(i) : r("newsletter.invalid-url-link-for-toaster")
|
|
87
|
+
}), r(P), a === r(X) && s({
|
|
86
88
|
type: c.Error,
|
|
87
|
-
message:
|
|
88
|
-
}),
|
|
89
|
+
message: r("newsletter.already-in-progress")
|
|
90
|
+
}), !!o;
|
|
89
91
|
}, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), y = (e) => ["if", "endif"].includes(e.toLowerCase()), S = (e, t) => {
|
|
90
92
|
const n = e.match(/({%(.*?)%})/g);
|
|
91
|
-
let
|
|
93
|
+
let o = !0;
|
|
92
94
|
return n !== null && !p.value && n.forEach((a) => {
|
|
93
95
|
const i = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
94
96
|
if (i && i.length > 0) {
|
|
95
|
-
const [
|
|
96
|
-
g(
|
|
97
|
+
const [m] = i;
|
|
98
|
+
g(m) && !t.includes(m) && (s({
|
|
97
99
|
type: c.Warning,
|
|
98
|
-
message:
|
|
99
|
-
}),
|
|
100
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
101
|
+
}), o = !1);
|
|
100
102
|
}
|
|
101
|
-
}),
|
|
103
|
+
}), o;
|
|
102
104
|
}, R = async (e, t, n) => {
|
|
103
|
-
const
|
|
104
|
-
return S(e, t) &&
|
|
105
|
+
const o = n ? await C(e) : !0;
|
|
106
|
+
return S(e, t) && o;
|
|
105
107
|
}, _ = (e) => e.length > 0 ? !0 : (s({
|
|
106
108
|
type: c.Warning,
|
|
107
|
-
message:
|
|
109
|
+
message: r("newsletter.html-content-is-empty")
|
|
108
110
|
}), !1), A = (e) => {
|
|
109
111
|
const t = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
|
|
110
112
|
return t > n && s({
|
|
111
113
|
type: c.Warning,
|
|
112
|
-
message:
|
|
114
|
+
message: r("custom-fields.missing-closing-braces")
|
|
113
115
|
}), t < n && s({
|
|
114
116
|
type: c.Warning,
|
|
115
|
-
message:
|
|
117
|
+
message: r("custom-fields.missing-opening-braces")
|
|
116
118
|
}), t === n;
|
|
117
119
|
}, O = (e) => {
|
|
118
|
-
const t =
|
|
120
|
+
const t = ve(e).length === 0;
|
|
119
121
|
return t || s({
|
|
120
122
|
type: c.Warning,
|
|
121
|
-
message:
|
|
123
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
122
124
|
}), t;
|
|
123
|
-
}, b = (e, t, n,
|
|
125
|
+
}, b = (e, t, n, o) => {
|
|
124
126
|
if (p.value)
|
|
125
127
|
return !0;
|
|
126
|
-
const a =
|
|
128
|
+
const a = he(
|
|
127
129
|
e,
|
|
128
130
|
t,
|
|
129
|
-
|
|
131
|
+
ge(e),
|
|
130
132
|
n,
|
|
131
|
-
|
|
133
|
+
o
|
|
132
134
|
);
|
|
133
135
|
if (a.length > 0) {
|
|
134
136
|
const i = `
|
|
135
137
|
<ul>
|
|
136
|
-
${a.map((
|
|
138
|
+
${a.map((m) => `<li>${m}</li>`).join("")}
|
|
137
139
|
</ul>
|
|
138
140
|
`;
|
|
139
141
|
return s({
|
|
140
142
|
type: c.Error,
|
|
141
|
-
message:
|
|
143
|
+
message: r("custom-fields.invalid-custom-fields") + i
|
|
142
144
|
}), !1;
|
|
143
145
|
}
|
|
144
146
|
return !0;
|
|
145
147
|
}, w = (e) => {
|
|
146
148
|
const t = e.match(G), n = [];
|
|
147
|
-
let
|
|
149
|
+
let o = !0;
|
|
148
150
|
if (t && t.forEach((a) => {
|
|
149
|
-
const i = a.match(H),
|
|
150
|
-
(!i || a !== v) && !
|
|
151
|
+
const i = a.match(H), m = a.match(K), v = (i == null ? void 0 : i.join("")) || "";
|
|
152
|
+
(!i || a !== v) && !m && (s({
|
|
151
153
|
type: c.Error,
|
|
152
|
-
message:
|
|
153
|
-
}),
|
|
154
|
+
message: r("newsletter.display-conditions-invalid-syntax")
|
|
155
|
+
}), o = !1), i && i.forEach((h) => {
|
|
154
156
|
h.trim() === "=" && (s({
|
|
155
157
|
type: c.Error,
|
|
156
|
-
message:
|
|
157
|
-
}),
|
|
158
|
+
message: r("custom-conditions.wrong-equality-operators")
|
|
159
|
+
}), o = !1);
|
|
158
160
|
const T = h.match(/^[a-zA-Z]*$/g);
|
|
159
161
|
T && T.forEach((I) => {
|
|
160
162
|
y(I) && n.push(I);
|
|
161
163
|
});
|
|
162
164
|
});
|
|
163
165
|
}), n.length) {
|
|
164
|
-
const a = n.filter((
|
|
166
|
+
const a = n.filter((m) => m === "if"), i = n.filter((m) => m === "endif");
|
|
165
167
|
a.length !== i.length && (s({
|
|
166
168
|
type: c.Error,
|
|
167
|
-
message:
|
|
168
|
-
}),
|
|
169
|
+
message: r("custom-conditions.missing-if-endif-tag")
|
|
170
|
+
}), o = !1);
|
|
169
171
|
}
|
|
170
|
-
return
|
|
172
|
+
return o;
|
|
171
173
|
}, N = (e) => {
|
|
172
|
-
const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length,
|
|
173
|
-
return
|
|
174
|
+
const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, o = t === n;
|
|
175
|
+
return o || s({
|
|
174
176
|
type: c.Warning,
|
|
175
|
-
message:
|
|
176
|
-
}),
|
|
177
|
-
}, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n,
|
|
177
|
+
message: r("custom-conditions.no-space-after-braces")
|
|
178
|
+
}), o;
|
|
179
|
+
}, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, o) => n + o, 0) > 0 ? (s({
|
|
178
180
|
type: c.Warning,
|
|
179
|
-
message:
|
|
181
|
+
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
180
182
|
}), !1) : !0, B = () => {
|
|
181
183
|
if (!u.hasInvalidBlock())
|
|
182
184
|
return !0;
|
|
183
185
|
const e = u.invalidBlockFields(), t = e.length > 0 && e.every((n) => n === te);
|
|
184
186
|
return s({
|
|
185
187
|
type: t ? c.Warning : c.Error,
|
|
186
|
-
message:
|
|
188
|
+
message: r(t ? ne : se)
|
|
187
189
|
}), !1;
|
|
188
|
-
},
|
|
190
|
+
}, x = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
|
|
189
191
|
type: c.Error,
|
|
190
|
-
message:
|
|
191
|
-
}), !1) : !0,
|
|
192
|
+
message: r("newsletter.fill-all-necessary-fields")
|
|
193
|
+
}), !1) : !0, F = (e) => {
|
|
192
194
|
const t = /src="[^"]*\.(svg|pst)"/gm;
|
|
193
195
|
return e.match(t) === null ? !0 : (s({
|
|
194
196
|
type: c.Error,
|
|
195
|
-
message:
|
|
197
|
+
message: r("newsletter.invalid-image-type")
|
|
196
198
|
}), !1);
|
|
197
199
|
}, D = (e) => {
|
|
198
|
-
const
|
|
199
|
-
return Array.from(
|
|
200
|
-
var
|
|
201
|
-
return !((
|
|
200
|
+
const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(q);
|
|
201
|
+
return Array.from(o).find((i) => {
|
|
202
|
+
var m;
|
|
203
|
+
return !((m = i.id) != null && m.trim());
|
|
202
204
|
}) ? (s({
|
|
203
205
|
type: c.Error,
|
|
204
|
-
message:
|
|
206
|
+
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
205
207
|
}), !1) : !0;
|
|
206
208
|
}, k = (e) => {
|
|
207
|
-
const
|
|
208
|
-
return Array.from(
|
|
209
|
-
var
|
|
210
|
-
return !((
|
|
209
|
+
const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
|
|
210
|
+
return Array.from(o).find((i) => {
|
|
211
|
+
var m;
|
|
212
|
+
return !((m = i.id) != null && m.trim());
|
|
211
213
|
}) ? (s({
|
|
212
214
|
type: c.Error,
|
|
213
|
-
message:
|
|
215
|
+
message: r("unsubscribe-templates.select-radio-button-groups")
|
|
214
216
|
}), !1) : !0;
|
|
215
217
|
};
|
|
216
218
|
return { validateHtml: async (e, t, n = !1) => {
|
|
217
219
|
var v, h;
|
|
218
|
-
const
|
|
220
|
+
const o = [
|
|
219
221
|
...t.map((T) => T.value),
|
|
220
222
|
...z,
|
|
221
223
|
...((h = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : h.customFieldAttributes) ?? []
|
|
222
224
|
], a = M(e), i = await E(a);
|
|
223
|
-
return await R(e,
|
|
225
|
+
return await R(e, o, n) && _(e) && A(e) && O(e) && b(e, o, a, i) && w(e) && N(e) && L(e) && B() && x() && F(e) && D(e) && k(e);
|
|
224
226
|
} };
|
|
225
227
|
};
|
|
226
228
|
export {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
229
|
+
ye as buildPartnerAttributeNameSet,
|
|
230
|
+
he as findInvalidCustomFields,
|
|
231
|
+
ve as getInvalidDynamicContentTags,
|
|
232
|
+
ge as getRecommendationBlockIds,
|
|
233
|
+
Ce as parseRecommendationVariable,
|
|
234
|
+
Ke as useHtmlValidator
|
|
233
235
|
};
|