@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.
Files changed (23) hide show
  1. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +11 -16
  2. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +11 -11
  3. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +1 -1
  4. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +44 -50
  5. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
  6. package/dist/composables/useExport.js +8 -7
  7. package/dist/composables/useHtmlValidator.js +102 -100
  8. package/dist/composables/useToaster.js +11 -10
  9. package/dist/composables/useVersionHistoryApi.js +22 -21
  10. package/dist/composables/validators/useLiquidValidator.js +26 -24
  11. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +64 -59
  12. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +40 -39
  13. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +33 -32
  14. package/dist/extensions/Blocks/Recommendation/templates/utils.js +79 -78
  15. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +50 -41
  16. package/dist/guido.css +1 -1
  17. package/dist/package.json.js +4 -4
  18. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +2 -0
  19. package/dist/src/stores/preview.d.ts +3 -0
  20. package/dist/src/utils/ampPreviewSanitizer.d.ts +5 -0
  21. package/dist/stores/preview.js +21 -15
  22. package/dist/utils/ampPreviewSanitizer.js +46 -0
  23. package/package.json +1 -1
@@ -1,23 +1,18 @@
1
- import o from "./DesktopPreview.vue2.js";
1
+ import t from "./DesktopPreview.vue2.js";
2
2
  /* empty css */
3
- import r from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
- var a = function() {
5
- var s = this, e = s._self._c, t = 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(t.trans("email-editor.desktop-preview")) + " ")]), e("div", { ref: "containerRef", staticClass: "desktop-preview d-f f-d-c o-h s-1" }, [e(t.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" }, [t.isContainerReady ? e("iframe", { staticClass: "desktop-preview__iframe d-b w-1 h-1 b-c-4 bor-s-n", attrs: { sandbox: `
7
- allow-same-origin
8
- allow-popups
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
- "cf946232"
13
+ "f5ff6219"
19
14
  );
20
- const f = n.exports;
15
+ const _ = n.exports;
21
16
  export {
22
- f as default
17
+ _ as default
23
18
  };
@@ -1,20 +1,20 @@
1
- import e from "./ContentView.vue2.js";
1
+ import a from "./ContentView.vue2.js";
2
2
  /* empty css */
3
- import n from "../../../../_virtual/_plugin-vue2_normalizer.js";
4
- var o = function() {
5
- var t = this, s = t._self._c, a = t._self._setupProxy;
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(a.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(a.trans("newsletter.inbox")))])], 1), s("div", { staticClass: "d-f a-i-c" }, [s(a.InIcons, { staticClass: "i-c-52", attrs: { name: "line-chevron-down" } }), s(a.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", { ref: "iframeRef", staticClass: "iframe-scaled d-b b-c-4 bor-s-n", attrs: { sandbox: "allow-same-origin allow-popups allow-forms allow-scripts allow-popups-to-escape-sandbox", srcdoc: a.previewStore.previewHtml }, on: { load: a.onLoad } })])]);
9
- }, i = [], r = /* @__PURE__ */ n(
10
- e,
11
- o,
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
- "f255b2bb"
15
+ "a7102458"
16
16
  );
17
- const d = r.exports;
17
+ const p = c.exports;
18
18
  export {
19
- d as default
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.isRendered ? s(t.OrgStrategyDetailModal, { staticClass: "assign-strategy-drawer", attrs: { "description-status": "", "description-text": t.drawerDescription, "footer-button-group-options": t.footerButtonGroupOptions, show: t.store.assignStrategyDrawerStatus, 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() {
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 p, computed as o, watch as R, nextTick as P } from "vue";
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 U } from "../../../../composables/useToaster.js";
4
- import { useTranslations as G } from "../../../../composables/useTranslations.js";
5
- import { DOTTED_DATE_LOCALE as M } from "../../../../enums/date.js";
6
- import { URLS as $ } from "../../../../enums/extensions/recommendationBlock.js";
7
- import { ToasterTypeOptions as f } from "../../../../enums/toaster.js";
8
- import { useRecommendationExtensionStore as z } from "../../../../extensions/Blocks/Recommendation/store/recommendation.js";
9
- import { commitStrategyChange as D } from "../../../../extensions/Blocks/Recommendation/utils/strategyCommit.js";
10
- import H from "./StrategyInfoBoxContent.vue.js";
11
- import { formatShortDate as F } from "../../../../utils/dateUtil.js";
12
- import { asText as O } from "../../../../utils/genericUtil.js";
13
- import { escapeHtml as K } from "../../../../utils/htmlEscape.js";
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 lt = /* @__PURE__ */ N({
15
+ const it = /* @__PURE__ */ N({
16
16
  __name: "AssignStrategyDrawer",
17
- setup(V) {
18
- const g = () => import("@useinsider/design-system-organisms"), S = (t, r) => ({
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 g()).OrgStrategyDetailModal,
21
+ loader: async () => (await d()).OrgStrategyDetailModal,
22
22
  loadingComponent: S(480, 240),
23
23
  delay: 0
24
24
  }), x = E({
25
- loader: async () => (await g()).OrgStrategyDropdown
26
- }), i = "guido-edit-strategy-", A = { width: 480, height: 42 }, a = G(), e = z(), { showToaster: c } = U(), n = p(null), d = "legacy", l = p(!1), m = p(!1), C = o(() => e.strategiesLoading || e.legacyConversionLoading), L = o(() => a(
27
- "email-editor.assign-strategy-description",
28
- { url: $.RECOMMENDATION_STRATEGIES_PANEL_PATH }
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 ? d : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
31
+ n.value = r || (e.isLegacyStrategyBlock ? m : null), l.value = !1, e.invalidateStrategies(), e.fetchStrategies().catch(() => {
38
32
  c({
39
- type: f.Error,
33
+ type: p.Error,
40
34
  message: a("discovery-strategy.error-description")
41
35
  });
42
36
  });
43
- }, { immediate: !0 });
37
+ });
44
38
  const v = (t) => {
45
- const r = O(t.updated_at || t.created_at);
39
+ const r = g(t.updated_at || t.created_at);
46
40
  if (!r)
47
41
  return "";
48
- const s = F(r, M);
42
+ const s = H(r, G);
49
43
  return a("recommendation-strategy.last-updated-on", { value: s });
50
- }, T = o(() => ({
44
+ }, _ = o(() => ({
51
45
  text: a("ds-steps.legacy-strategy"),
52
- value: d,
46
+ value: m,
53
47
  hidden: !0
54
- })), u = o(() => e.strategies.map((t) => ({
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: K(O(t.name)),
57
+ titleText: f(g(t.name)),
64
58
  descriptionStatus: !0,
65
59
  descriptionText: v(t),
66
- slot: H,
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
- }))), k = o(() => e.isLegacyStrategyBlock ? [T.value, ...u.value] : u.value), B = (t) => {
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, y = e.recommendationConfigs.strategyId === r;
85
- e.openStrategyEdit(r) && (String(n.value ?? "") === r && (n.value = null), y && (e.removeStrategy(), s !== null && D(s, "Removed recommendation strategy")));
86
- }, _ = o(() => {
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: g, 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: d, showSelectionError: l, isRendered: m, strategiesLoading: C, drawerDescription: L, lastUpdatedText: v, legacyStrategyOption: T, remoteStrategyOptions: u, strategyOptions: k, onInfoBoxButtonClick: B, selectedStrategy: _, footerButtonGroupOptions: b, closeDrawer: () => {
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 = _.value;
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 (y) {
113
- console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed", y);
106
+ } catch (u) {
107
+ console.error("[AssignStrategyDrawer] resolveStrategyUrlTemplate failed", u);
114
108
  }
115
109
  if (!r) {
116
110
  c({
117
- type: f.Error,
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: f.Success,
125
- message: a("email-editor.strategy-assigned-success", { strategyName: t.name })
126
- }), e.closeAssignStrategyDrawer(), s !== null && await D(s, "Assigned recommendation strategy");
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
- lt as default
127
+ it as default
134
128
  };
@@ -12,9 +12,9 @@ var i = function() {
12
12
  l,
13
13
  !1,
14
14
  null,
15
- "e48cebe9"
15
+ "c8351f74"
16
16
  );
17
- const f = d.exports;
17
+ const u = d.exports;
18
18
  export {
19
- f as default
19
+ u as default
20
20
  };
@@ -1,8 +1,9 @@
1
1
  import { ToasterTypeOptions as a } from "../enums/toaster.js";
2
- import { useActionsApi as m } from "./useActionsApi.js";
3
- import { useHtmlCompiler as p } from "./useHtmlCompiler.js";
4
- import { useToaster as d } from "./useToaster.js";
5
- const H = () => {
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 } = m(), { showToaster: n } = d(), { compileHtml: i } = p();
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
- H as useExport
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 X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as U, VALID_DYNAMIC_VARIABLE_REGEX as j } from "../enums/html-validator.js";
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 re } from "../stores/recommendation.js";
14
- import { base64EncodeWithSpecialChars as oe } from "../utils/base64.js";
15
- import { computed as ie } from "vue";
16
- import { useHttp as ae } from "./useHttp.js";
17
- import { useToaster as ce } from "./useToaster.js";
18
- import { useTranslations as le } from "./useTranslations.js";
19
- const me = /recommendation-id="(\d+)"/g;
20
- function ue(s) {
21
- return [...s.matchAll(me)].map((m) => m[1]);
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 de(s, m) {
24
- return m.some((f) => s.startsWith(`${f}_`));
25
+ function pe(s, l) {
26
+ return l.some((f) => s.startsWith(`${f}_`));
25
27
  }
26
- const fe = /^(\d+)_\d+_(.+)$/;
27
- function ge(s) {
28
- const m = s.match(fe);
29
- return m ? { recoId: m[1], attribute: m[2] } : null;
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 pe(s) {
32
- const m = new Set(J);
33
+ function ye(s) {
34
+ const l = new Set(J);
33
35
  return Object.values(s).forEach((f) => {
34
- m.add(ee(f).toLowerCase());
35
- }), m;
36
+ l.add(ee(f).toLowerCase());
37
+ }), l;
36
38
  }
37
- function Ee(s, m, f, o, d) {
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(m.map((C) => C.toLowerCase())), E = [];
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 = ge(g);
47
- if (y && o.has(y.recoId)) {
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
- de(g, f) || g.includes(".") || E.push(g);
55
+ pe(g, f) || g.includes(".") || E.push(g);
54
56
  }), E;
55
57
  }
56
- function Ce(s) {
57
- return (s.replace(Y, "$1").match($) ?? []).filter((o) => {
58
- const d = o.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
59
- return U.includes(p) ? !1 : j.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
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 Ve = () => {
63
- const { showToaster: s } = ce(), { post: m } = ae(), { config: f } = V(), o = le(), d = re(), u = Q(), p = ie(
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 pe(u.filterList);
78
+ return ye(u.filterList);
77
79
  }, C = async (e) => {
78
- const n = await m(
79
- "/newsletter/template-library/check-template-html-body",
80
- { html: oe(e) }
81
- ), { status: r, message: a } = n.data;
82
- return r || s({
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: r === void 0 ? a : o("newsletter.invalid-url-link-for-toaster")
85
- }), o(X), a === o(P) && s({
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: o("newsletter.already-in-progress")
88
- }), r;
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 r = !0;
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 [l] = i;
96
- g(l) && !t.includes(l) && (s({
97
+ const [m] = i;
98
+ g(m) && !t.includes(m) && (s({
97
99
  type: c.Warning,
98
- message: o("custom-fields.invalid-custom-fields")
99
- }), r = !1);
100
+ message: r("custom-fields.invalid-custom-fields")
101
+ }), o = !1);
100
102
  }
101
- }), r;
103
+ }), o;
102
104
  }, R = async (e, t, n) => {
103
- const r = n ? await C(e) : !0;
104
- return S(e, t) && r;
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: o("newsletter.html-content-is-empty")
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: o("custom-fields.missing-closing-braces")
114
+ message: r("custom-fields.missing-closing-braces")
113
115
  }), t < n && s({
114
116
  type: c.Warning,
115
- message: o("custom-fields.missing-opening-braces")
117
+ message: r("custom-fields.missing-opening-braces")
116
118
  }), t === n;
117
119
  }, O = (e) => {
118
- const t = Ce(e).length === 0;
120
+ const t = ve(e).length === 0;
119
121
  return t || s({
120
122
  type: c.Warning,
121
- message: o("custom-fields.invalid-custom-fields")
123
+ message: r("custom-fields.invalid-custom-fields")
122
124
  }), t;
123
- }, b = (e, t, n, r) => {
125
+ }, b = (e, t, n, o) => {
124
126
  if (p.value)
125
127
  return !0;
126
- const a = Ee(
128
+ const a = he(
127
129
  e,
128
130
  t,
129
- ue(e),
131
+ ge(e),
130
132
  n,
131
- r
133
+ o
132
134
  );
133
135
  if (a.length > 0) {
134
136
  const i = `
135
137
  <ul>
136
- ${a.map((l) => `<li>${l}</li>`).join("")}
138
+ ${a.map((m) => `<li>${m}</li>`).join("")}
137
139
  </ul>
138
140
  `;
139
141
  return s({
140
142
  type: c.Error,
141
- message: o("custom-fields.invalid-custom-fields") + i
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 r = !0;
149
+ let o = !0;
148
150
  if (t && t.forEach((a) => {
149
- const i = a.match(H), l = a.match(K), v = (i == null ? void 0 : i.join("")) || "";
150
- (!i || a !== v) && !l && (s({
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: o("newsletter.display-conditions-invalid-syntax")
153
- }), r = !1), i && i.forEach((h) => {
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: o("custom-conditions.wrong-equality-operators")
157
- }), r = !1);
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((l) => l === "if"), i = n.filter((l) => l === "endif");
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: o("custom-conditions.missing-if-endif-tag")
168
- }), r = !1);
169
+ message: r("custom-conditions.missing-if-endif-tag")
170
+ }), o = !1);
169
171
  }
170
- return r;
172
+ return o;
171
173
  }, N = (e) => {
172
- const t = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, r = t === n;
173
- return r || s({
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: o("custom-conditions.no-space-after-braces")
176
- }), r;
177
- }, L = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, r) => n + r, 0) > 0 ? (s({
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: o("custom-conditions.no-braces-inside-if-tag")
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: o(t ? ne : se)
188
+ message: r(t ? ne : se)
187
189
  }), !1;
188
- }, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((t) => t.filters.find((n) => n.value === "")) !== void 0 ? (s({
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: o("newsletter.fill-all-necessary-fields")
191
- }), !1) : !0, x = (e) => {
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: o("newsletter.invalid-image-type")
197
+ message: r("newsletter.invalid-image-type")
196
198
  }), !1);
197
199
  }, D = (e) => {
198
- const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(q);
199
- return Array.from(r).find((i) => {
200
- var l;
201
- return !((l = i.id) != null && l.trim());
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: o("unsubscribe-templates.select-checkbox-groups")
206
+ message: r("unsubscribe-templates.select-checkbox-groups")
205
207
  }), !1) : !0;
206
208
  }, k = (e) => {
207
- const r = new DOMParser().parseFromString(e, "text/html").querySelectorAll(Z);
208
- return Array.from(r).find((i) => {
209
- var l;
210
- return !((l = i.id) != null && l.trim());
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: o("unsubscribe-templates.select-radio-button-groups")
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 r = [
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, r, n) && _(e) && A(e) && O(e) && b(e, r, a, i) && w(e) && N(e) && L(e) && B() && F() && x(e) && D(e) && k(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
- pe as buildPartnerAttributeNameSet,
228
- Ee as findInvalidCustomFields,
229
- Ce as getInvalidDynamicContentTags,
230
- ue as getRecommendationBlockIds,
231
- ge as parseRecommendationVariable,
232
- Ve as useHtmlValidator
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
  };