@useinsider/guido 3.8.1 → 3.8.2-beta.189e91c

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 (86) hide show
  1. package/dist/@types/config/schemas.js +70 -66
  2. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +8 -8
  3. package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +15 -12
  4. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
  5. package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +16 -15
  6. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
  7. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +42 -37
  8. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
  9. package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +40 -37
  10. package/dist/composables/useHtmlCompiler.js +13 -10
  11. package/dist/composables/useHtmlValidator.js +180 -133
  12. package/dist/composables/usePreviewInteractionGuard.js +17 -0
  13. package/dist/composables/usePreviewMode.js +15 -14
  14. package/dist/composables/useRecommendationPreview.js +111 -0
  15. package/dist/composables/useSave.js +14 -14
  16. package/dist/composables/validators/useUnsubscribeBlockValidator.js +26 -17
  17. package/dist/config/compiler/htmlCompilerRules.js +38 -10
  18. package/dist/config/compiler/recommendationCompilerRules.js +84 -109
  19. package/dist/config/compiler/utils/recommendationCompilerUtils.js +98 -89
  20. package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
  21. package/dist/config/migrator/recommendation/extractors.js +44 -22
  22. package/dist/config/migrator/recommendation/htmlBuilder.js +170 -163
  23. package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
  24. package/dist/config/migrator/recommendationMigrator.js +30 -31
  25. package/dist/extensions/Blocks/Recommendation/block.js +60 -41
  26. package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
  27. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
  28. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +26 -20
  29. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +359 -264
  30. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +96 -83
  31. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +43 -31
  32. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
  33. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
  34. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +55 -45
  35. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +175 -166
  36. package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
  37. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  38. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
  39. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
  40. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
  41. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +6 -3
  42. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +130 -96
  43. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +43 -53
  44. package/dist/extensions/Blocks/Recommendation/templates/index.js +20 -16
  45. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +86 -80
  46. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -40
  47. package/dist/extensions/Blocks/Recommendation/templates/utils.js +155 -102
  48. package/dist/extensions/Blocks/Unsubscribe/block.js +40 -37
  49. package/dist/extensions/Blocks/Unsubscribe/control.js +19 -16
  50. package/dist/guido.css +1 -1
  51. package/dist/src/@types/config/schemas.d.ts +16 -0
  52. package/dist/src/composables/useConfig.d.ts +4 -0
  53. package/dist/src/composables/useHtmlValidator.d.ts +27 -0
  54. package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
  55. package/dist/src/composables/usePreviewInteractionGuard.d.ts +3 -0
  56. package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
  57. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +1 -0
  58. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
  59. package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
  60. package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
  61. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
  62. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
  63. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  64. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  65. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +21 -0
  66. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +36 -3
  67. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
  68. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
  69. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +5 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -0
  73. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  74. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +13 -1
  75. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
  76. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
  77. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +10 -1
  78. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
  79. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +51 -1
  80. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
  81. package/dist/src/stores/config.d.ts +36 -0
  82. package/dist/src/stores/unsubscribe.d.ts +11 -1
  83. package/dist/src/utils/ampErrorFilter.d.ts +1 -0
  84. package/dist/stores/unsubscribe.js +8 -7
  85. package/dist/utils/ampErrorFilter.js +6 -5
  86. package/package.json +1 -1
@@ -1,16 +1,16 @@
1
- import { defineComponent as v, ref as b, computed as f, watch as _ } from "vue";
1
+ import { defineComponent as _, ref as b, computed as f, watch as v } from "vue";
2
2
  import U from "../../wrappers/WpDrawer.vue.js";
3
- import { useToaster as N } from "../../../composables/useToaster.js";
4
- import { useTranslations as w } from "../../../composables/useTranslations.js";
3
+ import { useToaster as w } from "../../../composables/useToaster.js";
4
+ import { useTranslations as N } from "../../../composables/useTranslations.js";
5
5
  import { ACADEMY_LINKS as D } from "../../../enums/academy.js";
6
- import { ToasterTypeOptions as P } from "../../../enums/toaster.js";
7
- import { PAGE_TYPES as l, getTypeTranslations as R, UNSUBSCRIBE_PAGES_LINK as G } from "../../../enums/unsubscribe.js";
8
- import { useUnsubscribeStore as I } from "../../../stores/unsubscribe.js";
6
+ import { ToasterTypeOptions as I } from "../../../enums/toaster.js";
7
+ import { PAGE_TYPES as l, getTypeTranslations as R, UNSUBSCRIBE_PAGES_LINK as P } from "../../../enums/unsubscribe.js";
8
+ import { useUnsubscribeStore as G } from "../../../stores/unsubscribe.js";
9
9
  import { InSegments as L } from "@useinsider/design-system-vue";
10
- const W = /* @__PURE__ */ v({
10
+ const W = /* @__PURE__ */ _({
11
11
  __name: "UnsubscribeTypeSelection",
12
- setup(O) {
13
- const t = w(), { showToaster: d } = N(), e = I(), n = b(!1), i = b(!0), o = b(l.GLOBAL_UNSUBSCRIBE), T = t(
12
+ setup(k) {
13
+ const t = N(), { showToaster: d } = w(), e = G(), n = b(!1), o = b(!0), r = b(l.GLOBAL_UNSUBSCRIBE), T = t(
14
14
  "unsubscription-preference.select-unsubscribe-page-description",
15
15
  { action: `<a href="${D.GLOBAL_UNSUBSCRIBE}" target="_blank">${t("ds-rules.visit-academy")}</a>` }
16
16
  ), y = f(() => [
@@ -31,7 +31,7 @@ const W = /* @__PURE__ */ v({
31
31
  disable: e.isSubscriptionPreferencesCenterDisabled,
32
32
  tooltipText: e.isSubscriptionPreferencesCenterDisabled ? t("unsubscription-preference.pref-center-added") : ""
33
33
  }
34
- ]), S = f(
34
+ ]), g = f(
35
35
  () => e.isGlobalUnsubscribeDisabled && e.isSubscriptionPreferencesCenterDisabled
36
36
  ), C = f(() => ({
37
37
  primaryButton: {
@@ -41,8 +41,8 @@ const W = /* @__PURE__ */ v({
41
41
  n.value ? "unsubscription-preference.selecting-type" : "products.select-and-continue"
42
42
  ),
43
43
  loadingStatus: n.value,
44
- disabledStatus: S.value,
45
- skeletonStatus: i.value,
44
+ disabledStatus: g.value,
45
+ skeletonStatus: o.value,
46
46
  skeletonSizing: { width: 168, height: 40 }
47
47
  },
48
48
  cancelOrBackButton: {
@@ -50,59 +50,62 @@ const W = /* @__PURE__ */ v({
50
50
  type: "secondary",
51
51
  labelText: t("products.cancel"),
52
52
  disabledStatus: n.value,
53
- skeletonStatus: i.value,
53
+ skeletonStatus: o.value,
54
54
  skeletonSizing: { width: 78, height: 40 }
55
55
  }
56
- })), m = (s) => {
57
- e.typeSelectionDrawerStatus = !1, document.dispatchEvent(new CustomEvent("unsubscribe:cancel")), s && setTimeout(() => {
56
+ })), S = (s) => {
57
+ e.typeSelectionDrawerStatus = !1, document.dispatchEvent(new CustomEvent("unsubscribe:cancel", {
58
+ detail: { blockId: e.pendingBlockId }
59
+ })), s && setTimeout(() => {
58
60
  s();
59
61
  }, 500);
60
62
  }, E = (s) => {
61
- o.value = s;
62
- }, g = () => {
63
- const s = e.hasTemplatesByCollectionType, r = [];
64
- if (Object.entries(s).forEach(([c, p]) => {
65
- p || r.push(Number(c));
66
- }), r.length === 0)
63
+ r.value = s;
64
+ }, m = () => {
65
+ const s = e.hasTemplatesByCollectionType, a = [];
66
+ if (Object.entries(s).forEach(([i, p]) => {
67
+ p || a.push(Number(i));
68
+ }), a.length === 0)
67
69
  return !0;
68
- const B = R(), a = r.map((c) => B[c]);
70
+ const h = R(), c = a.map((i) => h[i]);
69
71
  let u = "";
70
- if (r.length === 1)
72
+ if (a.length === 1)
71
73
  u = t("unsubscription-preference.create-page-to-continue", {
72
- page: a[0]
74
+ page: c[0]
73
75
  });
74
- else if (r.length === 2)
76
+ else if (a.length === 2)
75
77
  u = t("unsubscription-preference.create-pages-to-continue", {
76
- page1: a[0],
77
- page2: a[1]
78
+ page1: c[0],
79
+ page2: c[1]
78
80
  });
79
81
  else {
80
- const c = a.pop() ?? "", p = a.join(", ");
82
+ const i = c.pop() ?? "", p = c.join(", ");
81
83
  u = t("unsubscription-preference.create-multiple-pages-to-continue", {
82
84
  pages: p,
83
- lastPage: c
85
+ lastPage: i
84
86
  });
85
87
  }
86
88
  return d({
87
- type: P.Warning,
89
+ type: I.Warning,
88
90
  message: u,
89
91
  actionButton: {
90
92
  text: "Go to Unsubscribe Pages",
91
93
  onClick: () => {
92
- window.location.href = G;
94
+ const i = new URL(P, window.location.origin).href;
95
+ window.open(i, "_blank", "noopener");
93
96
  }
94
97
  }
95
98
  }), !1;
96
- }, h = async () => {
97
- if (n.value = !0, await e.fetchTemplates(), e.setCollection(o.value), !g()) {
98
- n.value = !1, m();
99
+ }, B = async () => {
100
+ if (n.value = !0, await e.fetchTemplates(!0), e.setCollection(r.value), !m()) {
101
+ n.value = !1, S();
99
102
  return;
100
103
  }
101
104
  n.value = !1, e.typeSelectionDrawerStatus = !1, e.pageSelectionDrawerStatus = !0;
102
105
  };
103
- return _(() => e.typeSelectionDrawerStatus, (s) => {
104
- s && (i.value = !0, o.value = l.GLOBAL_UNSUBSCRIBE, e.isGlobalUnsubscribeDisabled && (o.value = e.isSubscriptionPreferencesCenterDisabled ? 0 : l.SUBSCRIPTION_PREFERENCE_CENTER), i.value = !1);
105
- }), { __sfc: !0, trans: t, showToaster: d, unsubscribeStore: e, isSelecting: n, skeletonStatus: i, selectedCollection: o, descriptionText: T, segmentList: y, hasNoSelectableType: S, footerButtonGroupOptions: C, closeModal: m, changeCollection: E, validateTemplates: g, selectCollection: h, WpDrawer: U, InSegments: L };
106
+ return v(() => e.typeSelectionDrawerStatus, (s) => {
107
+ s && (o.value = !0, r.value = l.GLOBAL_UNSUBSCRIBE, e.isGlobalUnsubscribeDisabled && (r.value = e.isSubscriptionPreferencesCenterDisabled ? 0 : l.SUBSCRIPTION_PREFERENCE_CENTER), o.value = !1);
108
+ }), { __sfc: !0, trans: t, showToaster: d, unsubscribeStore: e, isSelecting: n, skeletonStatus: o, selectedCollection: r, descriptionText: T, segmentList: y, hasNoSelectableType: g, footerButtonGroupOptions: C, closeModal: S, changeCollection: E, validateTemplates: m, selectCollection: B, WpDrawer: U, InSegments: L };
106
109
  }
107
110
  });
108
111
  export {
@@ -26,24 +26,27 @@ const y = /* @__PURE__ */ new Set([
26
26
  "format-comment-braces",
27
27
  "add-universal-link-flags",
28
28
  // Coupon placeholder replacement (only present when liquidSyntax is enabled).
29
- "liquid-coupon-code"
29
+ "liquid-coupon-code",
30
+ // Editor-only attribute strip — AMP4EMAIL has no `contenteditable`, so leaving
31
+ // it in narrows/breaks rendering. Pure attribute removal, emits nothing.
32
+ "remove-contenteditable"
30
33
  ]), M = () => {
31
- var t, m, r;
32
- const { compiler: e, isFeatureEnabled: a, partner: n } = k(), p = ((t = e.value) == null ? void 0 : t.customRules) || [], l = [
33
- ...!!((m = e.value) != null && m.ignoreDefaultRules) ? [] : R,
34
+ var i, m, r;
35
+ const { compiler: o, isFeatureEnabled: n, partner: a } = k(), p = ((i = o.value) == null ? void 0 : i.customRules) || [], l = [
36
+ ...!!((m = o.value) != null && m.ignoreDefaultRules) ? [] : R,
34
37
  ...v,
35
38
  ...x,
36
39
  ...g,
37
40
  ...b,
38
41
  ...H,
39
- ...a("liquidSyntax") ? C : [],
40
- ...p.map((o, f) => ({
41
- ...o,
42
- priority: o.priority + 1e3 + f
42
+ ...n("liquidSyntax") ? C : [],
43
+ ...p.map((e, f) => ({
44
+ ...e,
45
+ priority: e.priority + 1e3 + f
43
46
  // Ensure additional rules run after default rules
44
47
  }))
45
- ], u = s(l), c = l.filter((o) => y.has(o.id)), d = s(c), i = (r = n.value) == null ? void 0 : r.fallbackFont;
46
- return { compileHtml: (o) => u.compile(o, void 0, i), compileAmpHtml: (o) => d.compile(o, void 0, i) };
48
+ ], u = s(l), c = l.filter((e) => y.has(e.id)), d = s(c), t = (r = a.value) == null ? void 0 : r.fallbackFont;
49
+ return { compileHtml: (e) => u.compile(e, void 0, t), compileAmpHtml: (e) => d.compile(e, void 0, t) };
47
50
  };
48
51
  export {
49
52
  M as useHtmlCompiler
@@ -1,172 +1,219 @@
1
- import { useConfig as V } from "./useConfig.js";
2
- import { TemplateTypes as G } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as H, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M, CampaignCouldNotBeSavedKey as X, CanNotMakeAnyChangesForRunningKey as P, DATA_ATTRIBUTE_REGEX as Y, DYNAMIC_CONTENT_TAG_REGEX as $, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
1
+ import { useConfig as W } from "./useConfig.js";
2
+ import { getIgnoredRecommendationBlockIds as G } from "../config/compiler/utils/recommendationIgnoreUtils.js";
3
+ import { TemplateTypes as H } from "../enums/defaults.js";
4
+ import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as $, CanNotMakeAnyChangesForRunningKey as Y, DATA_ATTRIBUTE_REGEX as U, DYNAMIC_CONTENT_TAG_REGEX as j, ALLOWED_DYNAMIC_SYSTEM_TOKENS as q, VALID_DYNAMIC_VARIABLE_REGEX as K } from "../enums/html-validator.js";
4
5
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as j } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationExtensionStore as U } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
- import { RecommendationRequiredFieldsKey as z } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
- import { useRecommendationStore as Z } from "../stores/recommendation.js";
9
- import { base64EncodeWithSpecialChars as J } from "../utils/base64.js";
10
- import { useHttp as Q } from "./useHttp.js";
11
- import { useToaster as ee } from "./useToaster.js";
12
- import { useTranslations as te } from "./useTranslations.js";
13
- const se = /recommendation-id="(\d+)"/g;
14
- function ne(i) {
15
- return [...i.matchAll(se)].map((d) => d[1]);
6
+ import { itemsBlockDynamicVariables as z } from "../extensions/Blocks/Items/enums/productEnums.js";
7
+ import { RECOMMENDATION_VARIABLE_BUILTIN_ATTRIBUTES as Z } from "../extensions/Blocks/Recommendation/constants/selectors.js";
8
+ import { useRecommendationExtensionStore as J } from "../extensions/Blocks/Recommendation/store/recommendation.js";
9
+ import { resolveProductAttrValue as Q } from "../extensions/Blocks/Recommendation/templates/utils.js";
10
+ import { RecommendationRequiredFieldsKey as ee } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
11
+ import { useRecommendationStore as te } from "../stores/recommendation.js";
12
+ import { base64EncodeWithSpecialChars as ne } from "../utils/base64.js";
13
+ import { useHttp as se } from "./useHttp.js";
14
+ import { useToaster as oe } from "./useToaster.js";
15
+ import { useTranslations as ie } from "./useTranslations.js";
16
+ const re = /recommendation-id="(\d+)"/g;
17
+ function ae(t) {
18
+ return [...t.matchAll(re)].map((m) => m[1]);
16
19
  }
17
- function ie(i, d) {
18
- return d.some((g) => i.startsWith(`${g}_`));
20
+ function ce(t, m) {
21
+ return m.some((f) => t.startsWith(`${f}_`));
19
22
  }
20
- function oe(i) {
21
- return (i.replace(Y, "$1").match($) ?? []).filter((r) => {
22
- const u = r.slice(2, -2), f = u.indexOf("|"), p = (f === -1 ? u : u.slice(0, f)).trim();
23
- return q.includes(p) ? !1 : K.test(p) ? f !== -1 && u.slice(f + 1).trim() === "" : !0;
23
+ const le = /^(\d+)_\d+_(.+)$/;
24
+ function me(t) {
25
+ const m = t.match(le);
26
+ return m ? { recoId: m[1], attribute: m[2] } : null;
27
+ }
28
+ function ue(t) {
29
+ const m = new Set(Z);
30
+ return Object.values(t).forEach((f) => {
31
+ m.add(Q(f.attributeName, t).toLowerCase());
32
+ }), m;
33
+ }
34
+ function de(t, m, f, i, d) {
35
+ const u = t.match(/{{([a-zA-Z0-9_.\s]*)}}/gm);
36
+ if (!u)
37
+ return [];
38
+ const p = new Set(m.map((y) => y.toLowerCase())), h = [];
39
+ return u.forEach((y) => {
40
+ const g = y.slice(2, -2).trim().toLowerCase();
41
+ if (g !== "" && p.has(g))
42
+ return;
43
+ const E = me(g);
44
+ if (E && i.has(E.recoId)) {
45
+ if (!d || d.has(E.attribute))
46
+ return;
47
+ h.push(g);
48
+ return;
49
+ }
50
+ ce(g, f) || g.includes(".") || h.push(g);
51
+ }), h;
52
+ }
53
+ function fe(t) {
54
+ return (t.replace(U, "$1").match(j) ?? []).filter((i) => {
55
+ const d = i.slice(2, -2), u = d.indexOf("|"), p = (u === -1 ? d : d.slice(0, u)).trim();
56
+ return q.includes(p) ? !1 : K.test(p) ? u !== -1 && d.slice(u + 1).trim() === "" : !0;
24
57
  });
25
58
  }
26
- const Ce = () => {
27
- var h, v;
28
- const { showToaster: i } = ee(), { post: d } = Q(), { config: g } = V(), r = te(), u = Z(), f = U(), p = ((v = (h = g.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === G.transactional, A = async (e) => {
29
- const t = await d(
59
+ const xe = () => {
60
+ var I, b;
61
+ const { showToaster: t } = oe(), { post: m } = se(), { config: f } = W(), i = ie(), d = te(), u = J(), p = ((b = (I = f.value) == null ? void 0 : I.partner) == null ? void 0 : b.messageType) === H.transactional, h = async (e) => {
62
+ if (e.size === 0)
63
+ return /* @__PURE__ */ new Set();
64
+ try {
65
+ await u.fetchRecommendationFilters();
66
+ } catch {
67
+ return null;
68
+ }
69
+ return ue(u.filterList);
70
+ }, y = async (e) => {
71
+ const n = await m(
30
72
  "/newsletter/template-library/check-template-html-body",
31
- { html: J(e) }
32
- ), { status: n, message: l } = t.data;
33
- return n || i({
73
+ { html: ne(e) }
74
+ ), { status: o, message: a } = n.data;
75
+ return o || t({
34
76
  type: c.Alert,
35
- message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
36
- }), r(X), l === r(P) && i({
77
+ message: o === void 0 ? a : i("newsletter.invalid-url-link-for-toaster")
78
+ }), i($), a === i(Y) && t({
37
79
  type: c.Alert,
38
- message: r("newsletter.already-in-progress")
39
- }), n;
40
- }, S = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), b = (e) => ["if", "endif"].includes(e.toLowerCase()), I = (e, s) => {
41
- const t = e.match(/({%(.*?)%})/g);
42
- let n = !0;
43
- return t !== null && !p && t.forEach((l) => {
44
- const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
45
- if (o && o.length > 0) {
46
- const [a] = o;
47
- S(a) && !s.includes(a) && (i({
80
+ message: i("newsletter.already-in-progress")
81
+ }), o;
82
+ }, g = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), T = (e, s) => {
83
+ const n = e.match(/({%(.*?)%})/g);
84
+ let o = !0;
85
+ return n !== null && !p && n.forEach((a) => {
86
+ const r = a.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
87
+ if (r && r.length > 0) {
88
+ const [l] = r;
89
+ g(l) && !s.includes(l) && (t({
48
90
  type: c.Warning,
49
- message: r("custom-fields.invalid-custom-fields")
50
- }), n = !1);
91
+ message: i("custom-fields.invalid-custom-fields")
92
+ }), o = !1);
51
93
  }
52
- }), n;
53
- }, T = async (e, s, t) => {
54
- const n = t ? await A(e) : !0;
55
- return I(e, s) && n;
56
- }, w = (e) => e.length > 0 ? !0 : (i({
94
+ }), o;
95
+ }, w = async (e, s, n) => {
96
+ const o = n ? await y(e) : !0;
97
+ return T(e, s) && o;
98
+ }, R = (e) => e.length > 0 ? !0 : (t({
57
99
  type: c.Warning,
58
- message: r("newsletter.html-content-is-empty")
59
- }), !1), x = (e) => {
60
- const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
61
- return s > t && i({
100
+ message: i("newsletter.html-content-is-empty")
101
+ }), !1), _ = (e) => {
102
+ const s = (e.match(/{/gm) || []).length, n = (e.match(/}/gm) || []).length;
103
+ return s > n && t({
62
104
  type: c.Warning,
63
- message: r("custom-fields.missing-closing-braces")
64
- }), s < t && i({
105
+ message: i("custom-fields.missing-closing-braces")
106
+ }), s < n && t({
65
107
  type: c.Warning,
66
- message: r("custom-fields.missing-opening-braces")
67
- }), s === t;
68
- }, _ = (e) => {
69
- const s = oe(e).length === 0;
70
- return s || i({
108
+ message: i("custom-fields.missing-opening-braces")
109
+ }), s === n;
110
+ }, N = (e) => {
111
+ const s = fe(e).length === 0;
112
+ return s || t({
71
113
  type: c.Warning,
72
- message: r("custom-fields.invalid-custom-fields")
114
+ message: i("custom-fields.invalid-custom-fields")
73
115
  }), s;
74
- }, k = (e, s) => {
75
- const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
76
- if (t && !p) {
77
- const n = new Set(s.map((a) => a.toLowerCase())), l = ne(e), o = [];
78
- if (t.forEach((a) => {
79
- const m = a.slice(2, -2).trim().toLowerCase();
80
- (!n.has(m) || m === "") && !ie(m, l) && o.push(m);
81
- }), o.length > 0) {
82
- const a = `
83
- <ul>
84
- ${o.map((m) => `<li>${m}</li>`).join("")}
85
- </ul>
86
- `;
87
- return i({
88
- type: c.Alert,
89
- message: r("custom-fields.invalid-custom-fields") + a
90
- }), !1;
91
- }
116
+ }, x = (e, s, n, o) => {
117
+ if (p)
118
+ return !0;
119
+ const a = de(
120
+ e,
121
+ s,
122
+ ae(e),
123
+ n,
124
+ o
125
+ );
126
+ if (a.length > 0) {
127
+ const r = `
128
+ <ul>
129
+ ${a.map((l) => `<li>${l}</li>`).join("")}
130
+ </ul>
131
+ `;
132
+ return t({
133
+ type: c.Alert,
134
+ message: i("custom-fields.invalid-custom-fields") + r
135
+ }), !1;
92
136
  }
93
137
  return !0;
94
- }, R = (e) => {
95
- const s = e.match(/{%(.*?)%}/g), t = [];
96
- let n = !0;
97
- if (s && s.forEach((l) => {
98
- const o = l.match(H), a = l.match(M), m = (o == null ? void 0 : o.join("")) || "";
99
- (!o || l !== m) && !a && (i({
138
+ }, O = (e) => {
139
+ const s = e.match(/{%(.*?)%}/g), n = [];
140
+ let o = !0;
141
+ if (s && s.forEach((a) => {
142
+ const r = a.match(P), l = a.match(X), v = (r == null ? void 0 : r.join("")) || "";
143
+ (!r || a !== v) && !l && (t({
100
144
  type: c.Alert,
101
- message: r("newsletter.display-conditions-invalid-syntax")
102
- }), n = !1), o && o.forEach((y) => {
103
- y.trim() === "=" && (i({
145
+ message: i("newsletter.display-conditions-invalid-syntax")
146
+ }), o = !1), r && r.forEach((C) => {
147
+ C.trim() === "=" && (t({
104
148
  type: c.Alert,
105
- message: r("custom-conditions.wrong-equality-operators")
106
- }), n = !1);
107
- const C = y.match(/^[a-zA-Z]*$/g);
108
- C && C.forEach((E) => {
109
- b(E) && t.push(E);
149
+ message: i("custom-conditions.wrong-equality-operators")
150
+ }), o = !1);
151
+ const A = C.match(/^[a-zA-Z]*$/g);
152
+ A && A.forEach((S) => {
153
+ E(S) && n.push(S);
110
154
  });
111
155
  });
112
- }), t.length) {
113
- const l = t.filter((a) => a === "if"), o = t.filter((a) => a === "endif");
114
- l.length !== o.length && (i({
156
+ }), n.length) {
157
+ const a = n.filter((l) => l === "if"), r = n.filter((l) => l === "endif");
158
+ a.length !== r.length && (t({
115
159
  type: c.Alert,
116
- message: r("custom-conditions.missing-if-endif-tag")
117
- }), n = !1);
160
+ message: i("custom-conditions.missing-if-endif-tag")
161
+ }), o = !1);
118
162
  }
119
- return n;
120
- }, N = (e) => {
121
- const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
122
- return n || i({
163
+ return o;
164
+ }, k = (e) => {
165
+ const s = (e.match(/{% /gm) || []).length, n = (e.match(/ %}/gm) || []).length, o = s === n;
166
+ return o || t({
123
167
  type: c.Warning,
124
- message: r("custom-conditions.no-space-after-braces")
125
- }), n;
126
- }, D = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (i({
168
+ message: i("custom-conditions.no-space-after-braces")
169
+ }), o;
170
+ }, B = (e) => (e.match(/({%(.*?)%})/g) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, o) => n + o, 0) > 0 ? (t({
127
171
  type: c.Warning,
128
- message: r("custom-conditions.no-braces-inside-if-tag")
129
- }), !1) : !0, F = () => f.hasInvalidBlock() ? (i({
172
+ message: i("custom-conditions.no-braces-inside-if-tag")
173
+ }), !1) : !0, D = () => u.hasInvalidBlock() ? (t({
130
174
  type: c.Alert,
131
- message: r(z)
132
- }), !1) : !0, O = () => u.recommendationConfigs && Object.values(u.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (i({
175
+ message: i(ee)
176
+ }), !1) : !0, F = () => d.recommendationConfigs && Object.values(d.recommendationConfigs).find((s) => s.filters.find((n) => n.value === "")) !== void 0 ? (t({
133
177
  type: c.Alert,
134
- message: r("newsletter.fill-all-necessary-fields")
135
- }), !1) : !0, B = (e) => {
178
+ message: i("newsletter.fill-all-necessary-fields")
179
+ }), !1) : !0, L = (e) => {
136
180
  const s = /src="[^"]*\.(svg|pst)"/gm;
137
- return e.match(s) === null ? !0 : (i({
181
+ return e.match(s) === null ? !0 : (t({
138
182
  type: c.Alert,
139
- message: r("newsletter.invalid-image-type")
183
+ message: i("newsletter.invalid-image-type")
140
184
  }), !1);
141
- }, L = (e) => {
142
- const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
143
- return Array.from(n).find((o) => {
144
- var a;
145
- return !((a = o.id) != null && a.trim());
146
- }) ? (i({
185
+ }, V = (e) => {
186
+ const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
187
+ return Array.from(o).find((r) => {
188
+ var l;
189
+ return !((l = r.id) != null && l.trim());
190
+ }) ? (t({
147
191
  type: c.Alert,
148
- message: r("unsubscribe-templates.select-checkbox-groups")
192
+ message: i("unsubscribe-templates.select-checkbox-groups")
149
193
  }), !1) : !0;
150
- }, W = (e) => {
151
- const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
152
- return Array.from(n).find((o) => {
153
- var a;
154
- return !((a = o.id) != null && a.trim());
155
- }) ? (i({
194
+ }, M = (e) => {
195
+ const o = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
196
+ return Array.from(o).find((r) => {
197
+ var l;
198
+ return !((l = r.id) != null && l.trim());
199
+ }) ? (t({
156
200
  type: c.Alert,
157
- message: r("unsubscribe-templates.select-radio-button-groups")
201
+ message: i("unsubscribe-templates.select-radio-button-groups")
158
202
  }), !1) : !0;
159
203
  };
160
- return { validateHtml: async (e, s, t = !1) => {
161
- var o, a;
162
- const n = [
163
- ...s.map((m) => m.value),
164
- ...j,
165
- ...((a = (o = g.value) == null ? void 0 : o.template) == null ? void 0 : a.customFieldAttributes) ?? []
166
- ];
167
- return await T(e, n, t) && w(e) && x(e) && _(e) && k(e, n) && R(e) && N(e) && D(e) && F() && O() && B(e) && L(e) && W(e);
204
+ return { validateHtml: async (e, s, n = !1) => {
205
+ var v, C;
206
+ const o = [
207
+ ...s.map((A) => A.value),
208
+ ...z,
209
+ ...((C = (v = f.value) == null ? void 0 : v.template) == null ? void 0 : C.customFieldAttributes) ?? []
210
+ ], a = G(e), r = await h(a);
211
+ return await w(e, o, n) && R(e) && _(e) && N(e) && x(e, o, a, r) && O(e) && k(e) && B(e) && D() && F() && L(e) && V(e) && M(e);
168
212
  } };
169
213
  };
170
214
  export {
171
- Ce as useHtmlValidator
215
+ ue as buildPartnerAttributeNameSet,
216
+ de as findInvalidCustomFields,
217
+ me as parseRecommendationVariable,
218
+ xe as useHtmlValidator
172
219
  };
@@ -0,0 +1,17 @@
1
+ const o = ["click", "auxclick", "submit"], c = (t) => {
2
+ t.preventDefault(), t.stopPropagation();
3
+ }, a = () => ({ blockPreviewInteractions: (r) => {
4
+ try {
5
+ const e = r.contentDocument;
6
+ if (!e)
7
+ return;
8
+ o.forEach((n) => {
9
+ e.addEventListener(n, c, !0);
10
+ });
11
+ } catch (e) {
12
+ console.warn("[usePreviewInteractionGuard] Could not guard preview iframe:", e);
13
+ }
14
+ } });
15
+ export {
16
+ a as usePreviewInteractionGuard
17
+ };
@@ -1,28 +1,29 @@
1
- import { useEditorStore as d } from "../stores/editor.js";
2
- import { usePreviewStore as n } from "../stores/preview.js";
3
- import { useActionsApi as p } from "./useActionsApi.js";
4
- import { useCodeEditorApi as c } from "./useCodeEditorApi.js";
5
- import { useHtmlCompiler as u } from "./useHtmlCompiler.js";
6
- const g = () => {
7
- const t = d(), e = n(), { closeCodeEditor: i } = c(), { getPreviewData: a, getCompiledEmail: s } = p(), { compileHtml: m } = u(), r = () => {
1
+ import { useEditorStore as n } from "../stores/editor.js";
2
+ import { usePreviewStore as p } from "../stores/preview.js";
3
+ import { useActionsApi as c } from "./useActionsApi.js";
4
+ import { useCodeEditorApi as u } from "./useCodeEditorApi.js";
5
+ import { useHtmlCompiler as v } from "./useHtmlCompiler.js";
6
+ import { useRecommendationPreview as w } from "./useRecommendationPreview.js";
7
+ const C = () => {
8
+ const t = n(), e = p(), { closeCodeEditor: a } = u(), { getPreviewData: m, getCompiledEmail: s } = c(), { compileHtml: l } = v(), { substituteRecommendationPreview: r } = w(), i = () => {
8
9
  t.isPreviewModeOpen = !1, e.$reset();
9
10
  };
10
11
  return {
11
- closePreviewMode: r,
12
+ closePreviewMode: i,
12
13
  openPreviewMode: () => {
13
- t.isCodeEditorOpen && i(), t.isPreviewModeOpen = !0;
14
+ t.isCodeEditorOpen && a(), t.isPreviewModeOpen = !0;
14
15
  },
15
16
  loadPreviewData: async () => {
16
17
  if (!(t.loadingStatus || e.isLoaded)) {
17
18
  t.loadingStatus = !0;
18
19
  try {
19
- const [o, l] = await Promise.all([
20
- a(),
20
+ const [o, d] = await Promise.all([
21
+ m(),
21
22
  s({ minimize: !0, resetDataSavedFlag: !1 })
22
23
  ]);
23
- e.templateHtml = o.html || "", e.ampHtml = o.ampHtml || "", e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = m(l.html).estimatedSizeKB, e.isLoaded = !0;
24
+ e.templateHtml = r(o.html || ""), e.ampHtml = r(o.ampHtml || ""), e.ampErrors = o.ampErrors || [], e.setEmailFormat(o.ampHtml ? "AMP" : "html"), e.emailSizeKB = l(d.html).estimatedSizeKB, e.isLoaded = !0;
24
25
  } catch (o) {
25
- console.error("Failed to load preview data:", o), r();
26
+ console.error("Failed to load preview data:", o), i();
26
27
  } finally {
27
28
  t.loadingStatus = !1;
28
29
  }
@@ -31,5 +32,5 @@ const g = () => {
31
32
  };
32
33
  };
33
34
  export {
34
- g as usePreviewMode
35
+ C as usePreviewMode
35
36
  };