@useinsider/guido 3.15.1-beta.6da4177 → 3.16.0-beta.20cd2fe

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 (93) hide show
  1. package/dist/@types/config/schemas.js +118 -100
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +78 -75
  4. package/dist/components/organisms/header/AutoSaveStatus.vue.js +17 -0
  5. package/dist/components/organisms/header/AutoSaveStatus.vue2.js +21 -0
  6. package/dist/components/organisms/header/EditorActions.vue.js +11 -11
  7. package/dist/components/organisms/header/EditorActions.vue2.js +34 -50
  8. package/dist/components/organisms/header/EditorActionsMenu.vue.js +20 -0
  9. package/dist/components/organisms/header/EditorActionsMenu.vue2.js +39 -0
  10. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  11. package/dist/components/organisms/header/LeftSlot.vue2.js +28 -23
  12. package/dist/components/organisms/header/MiddleSlot.vue.js +4 -4
  13. package/dist/components/organisms/header/MiddleSlot.vue2.js +8 -7
  14. package/dist/components/organisms/header/RightSlot.vue.js +6 -6
  15. package/dist/components/organisms/header/RightSlot.vue2.js +17 -15
  16. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue.js +18 -0
  17. package/dist/components/organisms/header/accessibility/AccessibilityToolbar.vue2.js +37 -0
  18. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue.js +24 -0
  19. package/dist/components/organisms/header/accessibility/ColorVisionSelect.vue2.js +48 -0
  20. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue.js +18 -0
  21. package/dist/components/organisms/onboarding/EditorTabBarOnboarding.vue2.js +74 -0
  22. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +43 -34
  23. package/dist/composables/useAccessibilityApi.js +31 -0
  24. package/dist/composables/useActionsApi.js +30 -22
  25. package/dist/composables/useEmailTemplateApplier.js +25 -23
  26. package/dist/composables/useHtmlValidator.js +85 -83
  27. package/dist/composables/useTimerClone.js +21 -19
  28. package/dist/config/i18n/en/labels.json.js +28 -4
  29. package/dist/config/migrator/checkboxMigrator.js +20 -19
  30. package/dist/config/migrator/radioButtonMigrator.js +26 -25
  31. package/dist/extensions/Blocks/Checkbox/constants/controlIds.js +4 -0
  32. package/dist/extensions/Blocks/Checkbox/constants/selectors.js +6 -0
  33. package/dist/extensions/Blocks/Checkbox/controls/blockBackground/index.js +10 -0
  34. package/dist/extensions/Blocks/Checkbox/extension.js +6 -5
  35. package/dist/extensions/Blocks/Checkbox/settingsPanel.js +15 -14
  36. package/dist/extensions/Blocks/Checkbox/template.js +10 -9
  37. package/dist/extensions/Blocks/Items/block.js +44 -42
  38. package/dist/extensions/Blocks/Items/template.js +86 -86
  39. package/dist/extensions/Blocks/RadioButton/constants/controlIds.js +4 -0
  40. package/dist/extensions/Blocks/RadioButton/constants/selectors.js +6 -0
  41. package/dist/extensions/Blocks/RadioButton/controls/blockBackground/index.js +10 -0
  42. package/dist/extensions/Blocks/RadioButton/extension.js +5 -4
  43. package/dist/extensions/Blocks/RadioButton/settingsPanel.js +12 -11
  44. package/dist/extensions/Blocks/RadioButton/template.js +16 -9
  45. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +5 -9
  46. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +98 -113
  47. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +21 -0
  48. package/dist/extensions/Blocks/controlFactories.js +117 -115
  49. package/dist/guido.css +1 -1
  50. package/dist/library.js +11 -7
  51. package/dist/node_modules/@vueuse/core/index.js +102 -0
  52. package/dist/node_modules/@vueuse/shared/index.js +40 -28
  53. package/dist/node_modules/valibot/dist/index.js +230 -216
  54. package/dist/public/trackingIds.js +8 -0
  55. package/dist/src/@types/config/schemas.d.ts +24 -0
  56. package/dist/src/components/organisms/header/EditorActionsMenu.vue.d.ts +2 -0
  57. package/dist/src/components/organisms/header/accessibility/AccessibilityToolbar.vue.d.ts +2 -0
  58. package/dist/src/components/organisms/header/accessibility/ColorVisionSelect.vue.d.ts +2 -0
  59. package/dist/src/components/organisms/onboarding/EditorTabBarOnboarding.vue.d.ts +2 -0
  60. package/dist/src/composables/useAccessibilityApi.d.ts +15 -0
  61. package/dist/src/composables/useActionsApi.d.ts +3 -3
  62. package/dist/src/composables/useConfig.d.ts +6 -0
  63. package/dist/src/extensions/Blocks/Checkbox/constants/controlIds.d.ts +7 -0
  64. package/dist/src/extensions/Blocks/Checkbox/constants/index.d.ts +10 -0
  65. package/dist/src/extensions/Blocks/Checkbox/constants/selectors.d.ts +16 -0
  66. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +14 -0
  67. package/dist/src/extensions/Blocks/RadioButton/constants/controlIds.d.ts +7 -0
  68. package/dist/src/extensions/Blocks/RadioButton/constants/index.d.ts +10 -0
  69. package/dist/src/extensions/Blocks/RadioButton/constants/selectors.d.ts +16 -0
  70. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +14 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -0
  72. package/dist/src/extensions/Blocks/_Boilerplate/constants/controlIds.d.ts +7 -0
  73. package/dist/src/extensions/Blocks/_Boilerplate/constants/index.d.ts +10 -0
  74. package/dist/src/extensions/Blocks/_Boilerplate/constants/selectors.d.ts +16 -0
  75. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +14 -0
  76. package/dist/src/library.d.ts +1 -0
  77. package/dist/src/public/trackingIds.d.ts +9 -0
  78. package/dist/src/stores/config.d.ts +54 -0
  79. package/dist/src/stores/editor.d.ts +132 -0
  80. package/dist/src/stores/onboarding.d.ts +377 -0
  81. package/dist/src/stores/version-history.d.ts +1 -1
  82. package/dist/src/utils/linkTrackingIds.d.ts +30 -0
  83. package/dist/src/utils/timeUtil.d.ts +10 -0
  84. package/dist/stores/editor.js +9 -2
  85. package/dist/stores/onboarding.js +23 -14
  86. package/dist/utils/linkTrackingIds.js +56 -0
  87. package/dist/utils/pairProductVariables.js +105 -99
  88. package/dist/utils/templatePreparation.js +72 -61
  89. package/dist/utils/timeUtil.js +6 -17
  90. package/package.json +5 -1
  91. package/dist/components/organisms/header/AutoSaveToggle.vue.js +0 -22
  92. package/dist/components/organisms/header/AutoSaveToggle.vue2.js +0 -19
  93. /package/dist/src/components/organisms/header/{AutoSaveToggle.vue.d.ts → AutoSaveStatus.vue.d.ts} +0 -0
@@ -0,0 +1,74 @@
1
+ import { defineComponent as p, computed as d, watch as x } from "vue";
2
+ import { useRibbonOffset as B } from "../../../composables/useRibbonOffset.js";
3
+ import { useTranslations as m } from "../../../composables/useTranslations.js";
4
+ import { useOnboardingStore as k } from "../../../stores/onboarding.js";
5
+ import { InOnboard as T } from "@useinsider/design-system-vue";
6
+ const y = /* @__PURE__ */ p({
7
+ __name: "EditorTabBarOnboarding",
8
+ setup(f) {
9
+ const n = "editorTabBarOnboarding", t = m(), i = k(), { getTopPosition: a } = B(), r = () => i.next(n), c = () => i.previous(n), s = () => void i.close(n), b = d(() => [
10
+ {
11
+ classes: "guido-tab-bar-onboarding",
12
+ right: "150px",
13
+ top: a(56),
14
+ position: "Right Top",
15
+ title: t("email-editor.onboarding-kebab-title"),
16
+ description: t("email-editor.onboarding-kebab-description"),
17
+ imageSource: "",
18
+ backButtonClick: () => {
19
+ },
20
+ nextButtonType: "text",
21
+ nextButtonText: t("action-builder.next"),
22
+ nextButtonClick: r
23
+ },
24
+ {
25
+ classes: "guido-tab-bar-onboarding",
26
+ right: "320px",
27
+ top: a(56),
28
+ position: "Right Top",
29
+ title: t("email-editor.onboarding-autosave-title"),
30
+ description: t("email-editor.onboarding-autosave-description"),
31
+ imageSource: "",
32
+ backButtonType: "text",
33
+ backButtonText: t("action-builder.back"),
34
+ backButtonClick: c,
35
+ nextButtonType: "text",
36
+ nextButtonText: t("action-builder.next"),
37
+ nextButtonClick: r
38
+ },
39
+ {
40
+ classes: "guido-tab-bar-onboarding",
41
+ right: "150px",
42
+ top: a(56),
43
+ position: "Right Top",
44
+ title: t("email-editor.onboarding-accessibility-title"),
45
+ description: t("email-editor.onboarding-accessibility-description"),
46
+ imageSource: "",
47
+ backButtonType: "text",
48
+ backButtonText: t("action-builder.back"),
49
+ backButtonClick: c,
50
+ nextButtonType: "text",
51
+ nextButtonText: t("action-builder.ok"),
52
+ nextButtonClick: s
53
+ }
54
+ ]), u = d(
55
+ () => i.onboardings.editorTabBarOnboarding.config.length > 0 && i.onboardings.editorTabBarOnboarding.isActive
56
+ ), g = () => {
57
+ var o, e;
58
+ (e = (o = i.getEditorTabBarCurrentCard) == null ? void 0 : o.nextButtonClick) == null || e.call(o);
59
+ }, l = () => {
60
+ var o, e;
61
+ (e = (o = i.getEditorTabBarCurrentCard) == null ? void 0 : o.backButtonClick) == null || e.call(o);
62
+ };
63
+ return x(
64
+ () => i.onboardings.editorTabBarOnboarding.isActive,
65
+ (o) => {
66
+ o && i.setConfig(n, b.value);
67
+ },
68
+ { immediate: !0 }
69
+ ), { __sfc: !0, ONBOARDING: n, trans: t, onboardingStore: i, getTopPosition: a, goNext: r, goBack: c, finish: s, onboardingCardsConfig: b, isVisible: u, handleNext: g, handleBack: l, InOnboard: T };
70
+ }
71
+ });
72
+ export {
73
+ y as default
74
+ };
@@ -1,46 +1,55 @@
1
- import { defineComponent as b, computed as e, onMounted as O, watch as t } from "vue";
2
- import u from "./AMPOnboarding.vue.js";
3
- import v from "./GenericOnboarding.vue.js";
4
- import l from "./ItemsOnboarding.vue.js";
5
- import y from "./NewVersionPopup.vue.js";
6
- import S from "./TextBlockOnboarding.vue.js";
7
- import h from "./VersionHistoryOnboarding.vue.js";
8
- import { usePartner as w } from "../../../composables/usePartner.js";
9
- import { useEditorStore as P } from "../../../stores/editor.js";
10
- import { useOnboardingStore as _ } from "../../../stores/onboarding.js";
11
- import { usePreviewStore as A } from "../../../stores/preview.js";
12
- const G = /* @__PURE__ */ b({
1
+ import { defineComponent as O, computed as a, onMounted as u, watch as e } from "vue";
2
+ import l from "./AMPOnboarding.vue.js";
3
+ import v from "./EditorTabBarOnboarding.vue.js";
4
+ import y from "./GenericOnboarding.vue.js";
5
+ import S from "./ItemsOnboarding.vue.js";
6
+ import h from "./NewVersionPopup.vue.js";
7
+ import w from "./TextBlockOnboarding.vue.js";
8
+ import P from "./VersionHistoryOnboarding.vue.js";
9
+ import { useConfig as A } from "../../../composables/useConfig.js";
10
+ import { usePartner as T } from "../../../composables/usePartner.js";
11
+ import { useEditorStore as _ } from "../../../stores/editor.js";
12
+ import { useOnboardingStore as H } from "../../../stores/onboarding.js";
13
+ import { usePreviewStore as B } from "../../../stores/preview.js";
14
+ const j = /* @__PURE__ */ O({
13
15
  __name: "OnboardingWrapper",
14
16
  emits: ["onboarding-finished"],
15
- setup(H, { emit: f }) {
16
- const o = _(), r = P(), s = A(), { isTestPartner: a } = w(), p = e(() => r.isStripoInitialized), d = e(() => a()), m = [
17
- { type: "newVersionPopup", component: y },
18
- { type: "genericOnboarding", component: v },
19
- { type: "textBlockOnboarding", component: S },
20
- { type: "versionHistoryOnboarding", component: h },
21
- { type: "ampOnboarding", component: u },
22
- { type: "itemsOnboarding", component: l }
23
- ], c = (n) => d.value || !p.value ? !1 : n === "newVersionPopup" ? o.shouldShowOnboarding(n) : o.isActive(n), g = e(() => m.filter((n) => c(n.type)));
24
- return O(async () => {
17
+ setup(M, { emit: g }) {
18
+ const o = H(), i = _(), d = B(), { isTestPartner: p } = T(), { isFeatureEnabled: m } = A(), t = a(() => i.isStripoInitialized), s = a(() => p()), b = [
19
+ { type: "newVersionPopup", component: h },
20
+ { type: "genericOnboarding", component: y },
21
+ { type: "textBlockOnboarding", component: w },
22
+ { type: "versionHistoryOnboarding", component: P },
23
+ { type: "ampOnboarding", component: l },
24
+ { type: "itemsOnboarding", component: S },
25
+ { type: "editorTabBarOnboarding", component: v }
26
+ ], c = (n) => s.value || !t.value ? !1 : n === "newVersionPopup" ? o.shouldShowOnboarding(n) : o.isActive(n), f = a(() => b.filter((n) => c(n.type)));
27
+ return u(async () => {
25
28
  await o.fetchUserModalState();
26
- }), t(
27
- () => r.isVersionHistoryOpen,
28
- (n, i) => {
29
- n && !i && o.shouldShowOnboarding("versionHistoryOnboarding") && o.start("versionHistoryOnboarding"), !n && i && o.isActive("versionHistoryOnboarding") && o.close("versionHistoryOnboarding");
29
+ }), e(
30
+ () => i.isVersionHistoryOpen,
31
+ (n, r) => {
32
+ n && !r && o.shouldShowOnboarding("versionHistoryOnboarding") && o.start("versionHistoryOnboarding"), !n && r && o.isActive("versionHistoryOnboarding") && o.close("versionHistoryOnboarding");
30
33
  }
31
- ), t(
32
- () => s.emailFormat,
33
- (n, i) => {
34
- i !== "AMP" && n === "AMP" && o.shouldShowOnboarding("ampOnboarding") && o.start("ampOnboarding");
34
+ ), e(
35
+ () => d.emailFormat,
36
+ (n, r) => {
37
+ r !== "AMP" && n === "AMP" && o.shouldShowOnboarding("ampOnboarding") && o.start("ampOnboarding");
35
38
  }
36
- ), t(
37
- () => r.isPreviewModeOpen,
39
+ ), e(
40
+ () => i.isPreviewModeOpen,
38
41
  (n) => {
39
42
  !n && o.isActive("ampOnboarding") && o.close("ampOnboarding");
40
43
  }
41
- ), { __sfc: !0, emit: f, onboardingStore: o, editorStore: r, previewStore: s, isTestPartner: a, isStripoReady: p, isTestPartnerActive: d, onboardingConfigs: m, shouldShow: c, visibleOnboardings: g };
44
+ ), e(
45
+ t,
46
+ (n) => {
47
+ n && m("accessibilityTesting") && !s.value && !o.isOnboardingActive() && o.shouldShowOnboarding("editorTabBarOnboarding") && o.start("editorTabBarOnboarding");
48
+ },
49
+ { immediate: !0 }
50
+ ), { __sfc: !0, emit: g, onboardingStore: o, editorStore: i, previewStore: d, isTestPartner: p, isFeatureEnabled: m, isStripoReady: t, isTestPartnerActive: s, onboardingConfigs: b, shouldShow: c, visibleOnboardings: f };
42
51
  }
43
52
  });
44
53
  export {
45
- G as default
54
+ j as default
46
55
  };
@@ -0,0 +1,31 @@
1
+ import { useEditorStore as r } from "../stores/editor.js";
2
+ const A = () => {
3
+ const e = r(), i = () => window.StripoEditorApi.accessibilityApi, s = () => {
4
+ i().openAccessibilityTestingMode(), e.isAccessibilityTestingOpen = !0;
5
+ }, o = () => {
6
+ i().closeAccessibilityTestingMode(), e.isAccessibilityTestingOpen = !1, e.imagesHidden = !1, e.colorVisionDeficiency = "";
7
+ }, g = () => e.isAccessibilityTestingOpen ? o() : s(), l = () => i().isAccessibilityTestingModeOpen(), t = () => {
8
+ i().showImages(), e.imagesHidden = !1;
9
+ }, c = () => {
10
+ i().hideImages(), e.imagesHidden = !0;
11
+ };
12
+ return {
13
+ openAccessibilityTestingMode: s,
14
+ closeAccessibilityTestingMode: o,
15
+ toggleAccessibilityTestingMode: g,
16
+ isAccessibilityTestingModeOpen: l,
17
+ showImages: t,
18
+ hideImages: c,
19
+ toggleImages: () => e.imagesHidden ? t() : c(),
20
+ setColorVisionDeficiency: (n) => {
21
+ i().setColorVisionDeficiency(n), e.colorVisionDeficiency = n;
22
+ },
23
+ getColorVisionDeficiency: () => i().getColorVisionDeficiency(),
24
+ switchToDesktopPreview: () => i().switchToDesktopPreview(),
25
+ switchToMobilePreview: () => i().switchToMobilePreview(),
26
+ toggleCodeEditor: () => i().emitToggleCodeEditor()
27
+ };
28
+ };
29
+ export {
30
+ A as useAccessibilityApi
31
+ };
@@ -1,7 +1,7 @@
1
- import { filterAmpErrors as w } from "../utils/ampErrorFilter.js";
1
+ import { filterAmpErrors as T } from "../utils/ampErrorFilter.js";
2
2
  import { useToaster as A } from "./useToaster.js";
3
- const D = () => {
4
- const { handleError: n } = A(), s = (t = {}) => new Promise((e, a) => {
3
+ const p = 1e4, D = () => {
4
+ const { handleError: r } = A(), l = (t = {}) => new Promise((e, a) => {
5
5
  const o = { ...{
6
6
  minimize: !0,
7
7
  utmEntity: {
@@ -21,29 +21,29 @@ const D = () => {
21
21
  forceAmp: !1,
22
22
  resetDataSavedFlag: !1,
23
23
  disableLineHeightsReplace: !0
24
- }, ...t }, l = {
25
- callback: (r, p, d, c, u) => {
26
- r ? a(r) : e({
27
- html: p,
28
- ampHtml: d,
29
- ampErrors: w(c ?? []),
30
- displayConditions: u
24
+ }, ...t }, n = {
25
+ callback: (m, d, c, u, w) => {
26
+ m ? a(m) : e({
27
+ html: d,
28
+ ampHtml: c,
29
+ ampErrors: T(u ?? []),
30
+ displayConditions: w
31
31
  });
32
32
  },
33
33
  ...o
34
34
  };
35
- window.StripoEditorApi.actionsApi.compileEmail(l);
35
+ window.StripoEditorApi.actionsApi.compileEmail(n);
36
36
  });
37
37
  return {
38
- getCompiledEmail: s,
38
+ getCompiledEmail: l,
39
39
  getTemplateData: () => new Promise((t) => {
40
- const e = ({ html: a, css: i, width: o, height: m, utmParams: l, syncModulesIds: r }) => t({
40
+ const e = ({ html: a, css: i, width: o, height: s, utmParams: n, syncModulesIds: m }) => t({
41
41
  html: a,
42
42
  css: i,
43
43
  width: o,
44
- height: m,
45
- utmParams: l,
46
- syncModulesIds: r
44
+ height: s,
45
+ utmParams: n,
46
+ syncModulesIds: m
47
47
  });
48
48
  window.StripoEditorApi.actionsApi.getTemplateData(e);
49
49
  }),
@@ -57,7 +57,7 @@ const D = () => {
57
57
  displayConditions: a,
58
58
  ampHtml: i = "",
59
59
  ampErrors: o = []
60
- } = await s({ minimize: !1, resetDataSavedFlag: !1, ...t });
60
+ } = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
61
61
  return {
62
62
  html: e,
63
63
  ampHtml: i,
@@ -65,7 +65,7 @@ const D = () => {
65
65
  displayConditions: a
66
66
  };
67
67
  } catch (e) {
68
- return n(e, "Error loading preview"), {
68
+ return r(e, "Error loading preview"), {
69
69
  html: "",
70
70
  ampHtml: "",
71
71
  ampErrors: [],
@@ -81,19 +81,27 @@ const D = () => {
81
81
  }
82
82
  try {
83
83
  window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
84
- i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
84
+ i ? (r(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
85
85
  });
86
86
  } catch (i) {
87
- n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
87
+ r(i, "Failed to call updateTimerInClonedTemplate"), t(null);
88
88
  }
89
89
  }),
90
90
  updateHtmlAndCss: (t, e) => {
91
- window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
91
+ const { actionsApi: a } = window.StripoEditorApi;
92
+ return new Promise((i, o) => {
93
+ const s = new Error(
94
+ `updateHtmlAndCss did not report completion within ${p}ms`
95
+ ), n = setTimeout(() => o(s), p);
96
+ a.updateHtmlAndCss(t, e, () => {
97
+ clearTimeout(n), i();
98
+ });
99
+ });
92
100
  },
93
101
  editorSave: () => new Promise((t) => {
94
102
  window.StripoEditorApi.actionsApi.save((e) => {
95
103
  if (e) {
96
- n(e, "Failed to save template"), t(!1);
104
+ r(e, "Failed to save template"), t(!1);
97
105
  return;
98
106
  }
99
107
  t(!0);
@@ -1,55 +1,57 @@
1
- import { useActionsApi as d } from "./useActionsApi.js";
2
- import { useConfig as D } from "./useConfig.js";
3
- import { useToaster as h } from "./useToaster.js";
1
+ import { useActionsApi as C } from "./useActionsApi.js";
2
+ import { useConfig as h } from "./useConfig.js";
3
+ import { useToaster as D } from "./useToaster.js";
4
4
  import { useTranslations as E } from "./useTranslations.js";
5
5
  import { ToasterTypeOptions as f } from "../enums/toaster.js";
6
6
  import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
7
- import { flattenDynamicContentList as S } from "../utils/genericUtil.js";
8
- import { extractUsedDynamicContent as O } from "../utils/registerUsedDynamicContent.js";
9
- import { ref as U } from "vue";
10
- const w = 250, o = U({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
11
- const { updateHtmlAndCss: c } = d(), { showToaster: m } = h(), y = E(), { template: T } = D(), v = A(), g = (e, t) => {
7
+ import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
8
+ import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
9
+ import { ref as O } from "vue";
10
+ const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
11
+ const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
12
12
  const a = y(e);
13
13
  return a === e ? t : a;
14
- }, C = (e) => {
14
+ }, v = (e) => {
15
15
  o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
16
16
  }, l = (e, t, a) => {
17
- var n;
17
+ var c;
18
18
  o.value = { ...o.value, [e]: "applying" };
19
19
  try {
20
- c(t, a), o.value = { ...o.value, [e]: "applied" };
20
+ r(t, a).catch((n) => {
21
+ console.warn("Editor did not acknowledge the template apply.", n);
22
+ }), o.value = { ...o.value, [e]: "applied" };
21
23
  try {
22
- const r = S((n = T.value) == null ? void 0 : n.dynamicContentList), p = O(t, r);
23
- p.length > 0 && v.registerDynamicContent(p);
24
+ const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
25
+ i.length > 0 && d.registerDynamicContent(i);
24
26
  } catch {
25
27
  }
26
28
  u.get(e) !== t && (u.set(e, t), m({
27
29
  type: f.Success,
28
30
  message: g("newsletter.ai-template-applied", "Template applied to the editor")
29
31
  }));
30
- } catch (r) {
32
+ } catch (n) {
31
33
  o.value = { ...o.value, [e]: "failed" }, m({
32
34
  type: f.Error,
33
- message: r instanceof Error ? r.message : "Failed to apply template"
35
+ message: n instanceof Error ? n.message : "Failed to apply template"
34
36
  });
35
37
  }
36
- }, i = (e) => {
38
+ }, p = (e) => {
37
39
  const t = s[e];
38
40
  t && (clearTimeout(t), delete s[e]);
39
41
  };
40
- return { applyStatus: o, markPending: C, applyTemplate: (e, t) => {
41
- t.html && (i(e), l(e, t.html, t.css ?? ""));
42
+ return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
43
+ t.html && (p(e), l(e, t.html, t.css ?? ""));
42
44
  }, applyTemplateDebounced: (e, t) => {
43
45
  if (!t.html)
44
46
  return;
45
- i(e);
46
- const { html: a } = t, n = t.css ?? "";
47
+ p(e);
48
+ const { html: a } = t, c = t.css ?? "";
47
49
  s[e] = setTimeout(() => {
48
- delete s[e], l(e, a, n);
49
- }, w);
50
+ delete s[e], l(e, a, c);
51
+ }, U);
50
52
  } };
51
53
  }, G = () => {
52
- Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((c) => delete s[c]), o.value = {};
54
+ Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
53
55
  };
54
56
  export {
55
57
  G as resetEmailTemplateApplier,