@useinsider/guido 3.19.0-beta.e11b9a3 → 3.19.0-beta.e424587

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 (89) hide show
  1. package/README.md +0 -1
  2. package/dist/@types/config/schemas.js +37 -39
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +82 -79
  5. package/dist/components/organisms/AutoSaveController.vue2.js +8 -10
  6. package/dist/components/organisms/header/EditorActions.vue.js +5 -5
  7. package/dist/components/organisms/header/EditorActions.vue2.js +46 -83
  8. package/dist/components/organisms/header/LeftSlot.vue.js +5 -5
  9. package/dist/components/organisms/header/LeftSlot.vue2.js +12 -16
  10. package/dist/components/wrappers/WpDrawer.vue.js +7 -9
  11. package/dist/components/wrappers/WpDrawer.vue2.js +1 -1
  12. package/dist/composables/useAutoSave.js +44 -46
  13. package/dist/composables/useCortexBlueprintBridge.js +122 -54
  14. package/dist/composables/useEmailTemplateApplier.js +111 -50
  15. package/dist/composables/useHtmlCompiler.js +26 -37
  16. package/dist/composables/useHtmlValidator.js +0 -2
  17. package/dist/composables/useSave.js +45 -93
  18. package/dist/composables/validators/useCouponBlockValidator.js +21 -24
  19. package/dist/composables/validators/useUnsubscribeBlockValidator.js +27 -34
  20. package/dist/config/compiler/itemsCompilerRules.js +14 -5
  21. package/dist/config/compiler/utils/itemsCompilerUtils.js +48 -21
  22. package/dist/config/migrator/itemsBlockMigrator.js +245 -253
  23. package/dist/config/migrator/recommendationMigrator.js +28 -21
  24. package/dist/config/migrator/recommendationPartnerMigrator.js +36 -30
  25. package/dist/extensions/Blocks/Items/block.js +78 -67
  26. package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
  27. package/dist/extensions/Blocks/Items/constants/cardWidth.js +20 -0
  28. package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
  29. package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
  30. package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
  31. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
  32. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +1 -1
  33. package/dist/extensions/Blocks/Items/template.js +219 -204
  34. package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
  35. package/dist/guido.css +1 -1
  36. package/dist/src/@types/config/schemas.d.ts +0 -4
  37. package/dist/src/components/Guido.vue.d.ts +1 -17
  38. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -17
  39. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -17
  40. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -17
  41. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +3 -4
  42. package/dist/src/composables/useAutoSave.d.ts +1 -4
  43. package/dist/src/composables/useConfig.d.ts +0 -2
  44. package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
  45. package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
  46. package/dist/src/composables/useGuidoActions.d.ts +2 -0
  47. package/dist/src/composables/useHtmlValidator.d.ts +0 -21
  48. package/dist/src/composables/useSave.d.ts +1 -6
  49. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
  50. package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -10
  51. package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +5 -0
  52. package/dist/src/extensions/Blocks/Items/block.d.ts +5 -0
  53. package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
  54. package/dist/src/extensions/Blocks/Items/constants/cardWidth.d.ts +12 -0
  55. package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
  56. package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
  57. package/dist/src/mock/cortexChatStore.d.ts +12 -0
  58. package/dist/src/stores/config.d.ts +0 -32
  59. package/dist/src/stores/guido-email-editor.d.ts +20 -10
  60. package/dist/src/stores/onboarding.d.ts +4 -0
  61. package/dist/src/stores/recommendation.d.ts +5 -0
  62. package/dist/src/utils/dateUtil.d.ts +10 -0
  63. package/dist/src/utils/genericUtil.d.ts +3 -0
  64. package/dist/src/utils/liquidProtection.d.ts +3 -0
  65. package/dist/src/utils/templatePreparation.d.ts +0 -30
  66. package/dist/static/styles/components/version-history.css.js +2 -6
  67. package/dist/stores/config.js +67 -84
  68. package/dist/stores/guido-email-editor.js +3 -1
  69. package/dist/stores/onboarding.js +4 -0
  70. package/dist/utils/liquidProtection.js +5 -0
  71. package/dist/utils/pairProductVariables.js +71 -71
  72. package/dist/utils/templatePreparation.js +36 -39
  73. package/package.json +1 -1
  74. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +0 -20
  75. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +0 -50
  76. package/dist/composables/useSaveValidation.js +0 -284
  77. package/dist/composables/useSaveValidationRollout.js +0 -20
  78. package/dist/enums/save-validation.js +0 -4
  79. package/dist/services/settingsApi.js +0 -11
  80. package/dist/src/@types/save-validation.d.ts +0 -19
  81. package/dist/src/components/organisms/validation/ValidationErrorDrawer.vue.d.ts +0 -2
  82. package/dist/src/composables/useSaveValidation.d.ts +0 -6
  83. package/dist/src/composables/useSaveValidationRollout.d.ts +0 -4
  84. package/dist/src/enums/save-validation.d.ts +0 -27
  85. package/dist/src/services/settingsApi.d.ts +0 -6
  86. package/dist/src/stores/save-validation.d.ts +0 -22
  87. package/dist/src/stores/setup-settings.d.ts +0 -4
  88. package/dist/stores/save-validation.js +0 -30
  89. package/dist/stores/setup-settings.js +0 -10
@@ -1,114 +1,77 @@
1
- import { defineComponent as I, computed as u, ref as c } from "vue";
2
- import { useActionsApi as P } from "../../../composables/useActionsApi.js";
3
- import { useConfig as j } from "../../../composables/useConfig.js";
4
- import { useExport as G } from "../../../composables/useExport.js";
5
- import { useTestEmailClick as J } from "../../../composables/useGuidoActions.js";
6
- import { useHtmlCompiler as K } from "../../../composables/useHtmlCompiler.js";
7
- import { useSave as N } from "../../../composables/useSave.js";
8
- import { useSaveValidation as Q } from "../../../composables/useSaveValidation.js";
9
- import { useSaveValidationRollout as U } from "../../../composables/useSaveValidationRollout.js";
10
- import { useToaster as W } from "../../../composables/useToaster.js";
11
- import { useTranslations as X } from "../../../composables/useTranslations.js";
12
- import { useVersionHistoryApi as Y } from "../../../composables/useVersionHistoryApi.js";
13
- import { useLiquidValidator as Z } from "../../../composables/validators/useLiquidValidator.js";
14
- import { ToasterTypeOptions as $ } from "../../../enums/toaster.js";
15
- import { useEditorStore as tt } from "../../../stores/editor.js";
16
- import { useSaveValidationStore as et } from "../../../stores/save-validation.js";
17
- import { useTemplateStore as ot } from "../../../stores/template.js";
18
- import { getTooltipOptions as rt } from "../../../utils/tooltipUtils.js";
19
- import { InButtonV2 as it } from "@useinsider/design-system-vue";
20
- import { storeToRefs as st } from "pinia";
21
- import at from "./MigrationConfirmModal.vue.js";
22
- const Ot = /* @__PURE__ */ I({
1
+ import { defineComponent as q, ref as n, computed as x } from "vue";
2
+ import { useActionsApi as b } from "../../../composables/useActionsApi.js";
3
+ import { useConfig as k } from "../../../composables/useConfig.js";
4
+ import { useExport as B } from "../../../composables/useExport.js";
5
+ import { useTestEmailClick as D } from "../../../composables/useGuidoActions.js";
6
+ import { useHtmlCompiler as L } from "../../../composables/useHtmlCompiler.js";
7
+ import { useSave as R } from "../../../composables/useSave.js";
8
+ import { useToaster as z } from "../../../composables/useToaster.js";
9
+ import { useTranslations as I } from "../../../composables/useTranslations.js";
10
+ import { useVersionHistoryApi as P } from "../../../composables/useVersionHistoryApi.js";
11
+ import { useLiquidValidator as j } from "../../../composables/validators/useLiquidValidator.js";
12
+ import { useEditorStore as G } from "../../../stores/editor.js";
13
+ import { useTemplateStore as J } from "../../../stores/template.js";
14
+ import { getTooltipOptions as K } from "../../../utils/tooltipUtils.js";
15
+ import { InButtonV2 as N } from "@useinsider/design-system-vue";
16
+ import { storeToRefs as Q } from "pinia";
17
+ import U from "./MigrationConfirmModal.vue.js";
18
+ const ft = /* @__PURE__ */ q({
23
19
  __name: "EditorActions",
24
- setup(nt, { expose: b }) {
25
- const { config: p, isFeatureEnabled: f } = j(), { exportHtml: d } = G(), { save: v } = N(), { validateCurrentTemplate: y } = Q(), { isEnabled: s } = U(), { showToaster: S, hideToaster: g, handleError: i } = W(), { openVersionHistory: h, closeVersionHistory: T } = Y(), { getCompiledEmail: V } = P(), { compileHtml: E } = K(), { validateLiquidSyntax: H } = Z(), e = tt(), w = et(), x = ot(), { hasMigrations: C } = st(x), r = X(), k = u(() => s.value ? r("email-editor.save-and-continue") : "Save"), a = c(!1), n = c(!1), _ = c(), l = J(), q = () => {
20
+ setup(W, { expose: w }) {
21
+ const { config: l, isFeatureEnabled: m } = k(), { exportHtml: c } = B(), { save: p } = R(), { openVersionHistory: u, closeVersionHistory: f } = P(), { getCompiledEmail: d } = b(), { compileHtml: v } = L(), { validateLiquidSyntax: y } = j(), { handleError: r } = z(), e = G(), g = J(), { hasMigrations: S } = Q(g), s = I(), i = n(!1), a = n(!1), H = n(), h = D(), _ = () => {
26
22
  if (e.isVersionHistoryOpen) {
27
- T();
23
+ f();
28
24
  return;
29
25
  }
30
- h();
31
- }, B = async () => {
32
- a.value = !0, await d(), a.value = !1;
33
- }, L = () => {
26
+ u();
27
+ }, C = async () => {
28
+ i.value = !0, await c(), i.value = !1;
29
+ }, A = () => {
34
30
  e.isSaveAsTemplateDrawerOpen = !0;
35
- }, R = u(() => e.isVersionHistoryOpen ? r("newsletter.close-version-history") : r("newsletter.version-history")), D = u(
31
+ }, M = x(() => e.isVersionHistoryOpen ? s("newsletter.close-version-history") : s("newsletter.version-history")), O = x(
36
32
  () => {
37
33
  var t, o;
38
- return ((o = (t = p.value) == null ? void 0 : t.features) == null ? void 0 : o.versionHistory) && !e.isPreviewModeOpen;
34
+ return ((o = (t = l.value) == null ? void 0 : t.features) == null ? void 0 : o.versionHistory) && !e.isPreviewModeOpen;
39
35
  }
40
- ), A = async (t) => {
41
- n.value = !0, t || (e.loadingStatus = !0);
36
+ ), V = async (t) => {
37
+ a.value = !0, t || (e.loadingStatus = !0);
42
38
  let o;
43
39
  try {
44
- o = await v(t);
45
- } catch (M) {
46
- i(M, "Failed to save template");
40
+ o = await p(t);
41
+ } catch (T) {
42
+ r(T, "Failed to save template");
47
43
  } finally {
48
- n.value = !1, !t && !o && (e.loadingStatus = !1);
44
+ a.value = !1, !t && !o && (e.loadingStatus = !1);
49
45
  }
50
46
  return o;
51
- }, O = (t) => {
47
+ }, E = (t) => {
52
48
  var o;
53
- if (!t && C.value) {
54
- (o = _.value) == null || o.open();
49
+ if (!t && S.value) {
50
+ (o = H.value) == null || o.open();
55
51
  return;
56
52
  }
57
- return A(t);
58
- }, m = async () => {
59
- e.loadingStatus = !0;
60
- try {
61
- return await y();
62
- } catch (t) {
63
- return i(t, "Failed to prepare test email"), null;
64
- } finally {
65
- e.loadingStatus = !1;
66
- }
53
+ return V(t);
67
54
  }, F = async () => {
68
- const t = await m();
69
- t != null && t.length ? w.open(t, "test") : t && g();
70
- }, z = async () => {
71
- if (s.value) {
72
- const t = await m();
73
- if (!t)
74
- return;
75
- if (t.length) {
76
- S({
77
- type: $.Error,
78
- message: r("email-editor.validation-errors-found"),
79
- actionButton: {
80
- text: r("email-editor.check-errors"),
81
- onClick: () => {
82
- F();
83
- }
84
- },
85
- autoHide: !1
86
- });
87
- return;
88
- }
89
- l();
90
- return;
91
- }
92
- if (f("liquidSyntax")) {
55
+ if (m("liquidSyntax")) {
93
56
  e.loadingStatus = !0;
94
57
  try {
95
- const { html: t } = await V({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: o } = E(t);
96
- if (!await H(o))
58
+ const { html: t } = await d({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: o } = v(t);
59
+ if (!await y(o))
97
60
  return;
98
61
  } catch (t) {
99
- i(t, "Failed to prepare test email");
62
+ r(t, "Failed to prepare test email");
100
63
  return;
101
64
  } finally {
102
65
  e.loadingStatus = !1;
103
66
  }
104
67
  }
105
- l();
68
+ h();
106
69
  };
107
- return b({
108
- handleSave: O
109
- }), { __sfc: !0, config: p, isFeatureEnabled: f, exportHtml: d, save: v, validateCurrentTemplate: y, isEnabled: s, showToaster: S, hideToaster: g, handleError: i, openVersionHistory: h, closeVersionHistory: T, getCompiledEmail: V, compileHtml: E, validateLiquidSyntax: H, editorStore: e, saveValidationStore: w, templateStore: x, hasMigrations: C, trans: r, saveLabel: k, isExporting: a, isSaving: n, migrationModalRef: _, testEmailClick: l, handleVersionHistory: q, handleExport: B, handleSaveAs: L, versionHistoryTooltipText: R, isVersionHistoryButtonVisible: D, executeSave: A, handleSave: O, collectTestErrors: m, openTestErrors: F, handleTestEmail: z, getTooltipOptions: rt, InButtonV2: it, MigrationConfirmModal: at };
70
+ return w({
71
+ handleSave: E
72
+ }), { __sfc: !0, config: l, isFeatureEnabled: m, exportHtml: c, save: p, openVersionHistory: u, closeVersionHistory: f, getCompiledEmail: d, compileHtml: v, validateLiquidSyntax: y, handleError: r, editorStore: e, templateStore: g, hasMigrations: S, trans: s, isExporting: i, isSaving: a, migrationModalRef: H, testEmailClick: h, handleVersionHistory: _, handleExport: C, handleSaveAs: A, versionHistoryTooltipText: M, isVersionHistoryButtonVisible: O, executeSave: V, handleSave: E, handleTestEmail: F, getTooltipOptions: K, InButtonV2: N, MigrationConfirmModal: U };
110
73
  }
111
74
  });
112
75
  export {
113
- Ot as default
76
+ ft as default
114
77
  };
@@ -1,16 +1,16 @@
1
1
  import o from "./LeftSlot.vue2.js";
2
2
  /* empty css */
3
- import n from "../../../_virtual/_plugin-vue2_normalizer.js";
4
- var a = function() {
3
+ import a from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var n = function() {
5
5
  var e = this, s = e._self._c, t = e._self._setupProxy;
6
6
  return s("div", { staticClass: "d-f a-i-c" }, [s(t.InButtonV2, { attrs: { id: "guido__back-button", "left-icon": "line-arrow-left", styling: "ghost", type: "secondary", "disabled-status": t.isBackButtonDisabled, "label-text": t.backButtonLabel, "skeleton-sizing": { width: 150, height: 26 }, "skeleton-status": t.editorStore.loadingStatus }, on: { click: t.handleBackClick } })], 1);
7
- }, i = [], r = /* @__PURE__ */ n(
7
+ }, i = [], r = /* @__PURE__ */ a(
8
8
  o,
9
- a,
9
+ n,
10
10
  i,
11
11
  !1,
12
12
  null,
13
- "b8f24f34"
13
+ "73199fa4"
14
14
  );
15
15
  const f = r.exports;
16
16
  export {
@@ -1,19 +1,19 @@
1
- import { defineComponent as m, computed as p, ref as d } from "vue";
1
+ import { defineComponent as l, computed as p, ref as d } from "vue";
2
2
  import { useConfig as k } from "../../../composables/useConfig.js";
3
3
  import { useBack as B } from "../../../composables/useGuidoActions.js";
4
4
  import { usePreviewMode as b } from "../../../composables/usePreviewMode.js";
5
5
  import { useTranslations as v } from "../../../composables/useTranslations.js";
6
6
  import { useVersionHistoryApi as _ } from "../../../composables/useVersionHistoryApi.js";
7
- import { useEditorStore as y } from "../../../stores/editor.js";
7
+ import { useEditorStore as V } from "../../../stores/editor.js";
8
8
  import { InButtonV2 as w } from "@useinsider/design-system-vue";
9
- import { useDebounceFn as V } from "../../../node_modules/@vueuse/shared/index.js";
10
- const D = /* @__PURE__ */ m({
9
+ import { useDebounceFn as y } from "../../../node_modules/@vueuse/shared/index.js";
10
+ const D = /* @__PURE__ */ l({
11
11
  __name: "LeftSlot",
12
12
  setup(C) {
13
- const e = y(), i = B(), { closeVersionHistory: n } = _(), { closePreviewMode: s } = b(), o = v(), { config: t } = k(), l = p(() => {
14
- var u, f;
15
- return e.isVersionHistoryOpen || e.isPreviewModeOpen ? o("email-editor.back-to-editor") : (f = (u = t.value) == null ? void 0 : u.ui) != null && f.backButtonLabel ? t.value.ui.backButtonLabel : o("email-editor.back-to-design");
16
- }), r = d(!1), a = () => {
13
+ const e = V(), i = B(), { closeVersionHistory: n } = _(), { closePreviewMode: s } = b(), o = v(), { config: t } = k(), f = p(() => {
14
+ var u, m;
15
+ return e.isVersionHistoryOpen || e.isPreviewModeOpen ? o("email-editor.back-to-editor") : (m = (u = t.value) == null ? void 0 : u.ui) != null && m.backButtonLabel ? t.value.ui.backButtonLabel : o("email-editor.back-to-design");
16
+ }), r = d(!1), c = () => {
17
17
  if (e.isVersionHistoryOpen) {
18
18
  n();
19
19
  return;
@@ -23,15 +23,11 @@ const D = /* @__PURE__ */ m({
23
23
  return;
24
24
  }
25
25
  i();
26
- }, c = V(async () => {
27
- try {
28
- await a();
29
- } finally {
30
- r.value = !1;
31
- }
26
+ }, a = y(() => {
27
+ c(), r.value = !1;
32
28
  }, 500);
33
- return { __sfc: !0, editorStore: e, handleBack: i, closeVersionHistory: n, closePreviewMode: s, trans: o, config: t, backButtonLabel: l, isBackButtonDisabled: r, executeBackAction: a, debouncedBackAction: c, handleBackClick: () => {
34
- r.value = !0, c();
29
+ return { __sfc: !0, editorStore: e, handleBack: i, closeVersionHistory: n, closePreviewMode: s, trans: o, config: t, backButtonLabel: f, isBackButtonDisabled: r, executeBackAction: c, debouncedBackAction: a, handleBackClick: () => {
30
+ r.value = !0, a();
35
31
  }, InButtonV2: w };
36
32
  }
37
33
  });
@@ -1,19 +1,17 @@
1
1
  import r from "./WpDrawer.vue2.js";
2
2
  import s from "../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var u = function() {
4
- var t = this, o = t._self._c, e = t._self._setupProxy;
5
- return o(e.InDrawer, { class: t.className, attrs: { id: t.id, "footer-status": "", "close-on-outside-click": t.closeOnOutsideClick, "description-status": t.descriptionStatus, "description-text": t.descriptionText, "footer-button-group-options": t.footerButtonGroupOptions, size: t.size, status: t.status, "title-text": t.titleText }, on: { cancelOrBackButtonEvent: function(n) {
4
+ var t = this, n = t._self._c, e = t._self._setupProxy;
5
+ return n(e.InDrawer, { class: t.className, attrs: { id: t.id, "footer-status": "", "close-on-outside-click": t.closeOnOutsideClick, "description-status": t.descriptionStatus, "description-text": t.descriptionText, "footer-button-group-options": t.footerButtonGroupOptions, size: t.size, status: t.status, "title-text": t.titleText }, on: { cancelOrBackButtonEvent: function(o) {
6
6
  return e.emit("cancelOrBackButtonEvent");
7
- }, onCloseEvent: function(n) {
7
+ }, onCloseEvent: function(o) {
8
8
  return e.emit("onCloseEvent");
9
- }, primaryButtonEvent: function(n) {
9
+ }, primaryButtonEvent: function(o) {
10
10
  return e.emit("primaryButtonEvent");
11
- }, secondaryButtonEvent: function(n) {
12
- return e.emit("secondaryButtonEvent");
13
11
  } }, scopedSlots: t._u([t.$slots.headerBottomSlot ? { key: "headerBottomSlot", fn: function() {
14
12
  return [t._t("headerBottomSlot")];
15
13
  }, proxy: !0 } : null, { key: "contentSlot", fn: function() {
16
- return [o("div", [t._t("default")], 2)];
14
+ return [n("div", [t._t("default")], 2)];
17
15
  }, proxy: !0 }], null, !0) });
18
16
  }, i = [], c = /* @__PURE__ */ s(
19
17
  r,
@@ -23,7 +21,7 @@ var u = function() {
23
21
  null,
24
22
  null
25
23
  );
26
- const p = c.exports;
24
+ const f = c.exports;
27
25
  export {
28
- p as default
26
+ f as default
29
27
  };
@@ -13,7 +13,7 @@ const r = /* @__PURE__ */ e({
13
13
  status: { type: Boolean },
14
14
  titleText: null
15
15
  },
16
- emits: ["cancelOrBackButtonEvent", "onCloseEvent", "primaryButtonEvent", "secondaryButtonEvent"],
16
+ emits: ["cancelOrBackButtonEvent", "onCloseEvent", "primaryButtonEvent"],
17
17
  setup(n, { emit: t }) {
18
18
  return { __sfc: !0, emit: t, InDrawer: o };
19
19
  }
@@ -1,78 +1,76 @@
1
- import { useConfig as p } from "./useConfig.js";
2
- import { useEditorLock as y } from "./useEditorLock.js";
3
- import { useAutosaveStore as I, AUTOSAVE_STATUS as a } from "../stores/autosave.js";
4
- import { useEditorStore as L } from "../stores/editor.js";
5
- import { computed as w, watch as V, onUnmounted as k } from "vue";
6
- const D = 18e4, b = 6e4, _ = (g, { clearsChanges: h = () => !0 } = {}) => {
7
- const { isFeatureEnabled: m } = p(), s = L(), t = I(), { isEditorBusy: f } = y();
8
- let o = null, l = 0, u = -1;
9
- const d = w(
10
- () => m("autosave") && t.isOn
11
- ), A = () => s.hasChanges && s.isInSaveableState && s.changeSeq !== u, E = () => ({
12
- hasChanges: s.hasChanges,
13
- isInSaveableState: s.isInSaveableState,
14
- isUnchangedSinceLastSave: s.changeSeq === u
15
- }), r = async (e) => {
16
- if (!d.value) {
1
+ import { useConfig as E } from "./useConfig.js";
2
+ import { useEditorLock as f } from "./useEditorLock.js";
3
+ import { useAutosaveStore as p, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
4
+ import { useEditorStore as A } from "../stores/editor.js";
5
+ import { computed as y, watch as I, onUnmounted as L } from "vue";
6
+ const w = 18e4, v = 6e4, R = (b) => {
7
+ const { isFeatureEnabled: S } = E(), o = A(), t = p(), { isEditorBusy: g } = f();
8
+ let i = null, c = 0;
9
+ const u = y(
10
+ () => S("autosave") && t.isOn
11
+ ), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
12
+ hasChanges: o.hasChanges,
13
+ isInSaveableState: o.isInSaveableState
14
+ }), l = async (e) => {
15
+ if (!u.value) {
17
16
  console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
18
17
  return;
19
18
  }
20
- if (!A()) {
21
- console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: E() });
19
+ if (!m()) {
20
+ console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: h() });
22
21
  return;
23
22
  }
24
- if (t.status === a.SAVING) {
23
+ if (t.status === s.SAVING) {
25
24
  console.debug("guido:autosave:skipped", { trigger: e, reason: "already-saving" });
26
25
  return;
27
26
  }
28
- if (f()) {
27
+ if (g()) {
29
28
  console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
30
29
  return;
31
30
  }
32
- console.debug("guido:autosave:save-start", { trigger: e }), t.status = a.SAVING, e === "visibility" && (l = Date.now());
33
- const n = s.changeSeq;
31
+ e === "visibility" && (c = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
34
32
  try {
35
- if (await g() === void 0) {
36
- console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = a.ERROR;
33
+ if (await b() === void 0) {
34
+ console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
37
35
  return;
38
36
  }
39
- u = n, h() && (s.hasChanges = !1), t.status = a.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
40
- } catch (S) {
41
- console.debug("guido:autosave:error", { trigger: e, error: S }), t.status = a.ERROR;
37
+ o.hasChanges = !1, t.status = s.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
38
+ } catch (a) {
39
+ console.debug("guido:autosave:error", { trigger: e, error: a }), t.status = s.ERROR;
42
40
  }
43
- }, i = () => {
41
+ }, n = () => {
44
42
  const { visibilityState: e } = document;
45
43
  if (console.debug("guido:autosave:visibility-change", {
46
44
  visibilityState: e,
47
- isActive: d.value
45
+ isActive: u.value
48
46
  }), e !== "hidden")
49
47
  return;
50
- const n = Date.now() - l;
51
- if (n < b) {
48
+ const a = Date.now() - c;
49
+ if (a < v) {
52
50
  console.debug("guido:autosave:visibility-debounced", {
53
- sinceLastMs: n,
54
- debounceMs: b
51
+ sinceLastMs: a,
52
+ debounceMs: v
55
53
  });
56
54
  return;
57
55
  }
58
- r("visibility");
59
- }, c = () => {
60
- o && (clearInterval(o), o = null);
61
- }, v = () => {
62
- document.removeEventListener("visibilitychange", i), window.removeEventListener("pagehide", i);
56
+ l("visibility");
57
+ }, d = () => {
58
+ i && (clearInterval(i), i = null);
59
+ }, r = () => {
60
+ document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
63
61
  };
64
- V(
65
- d,
62
+ I(
63
+ u,
66
64
  (e) => {
67
- console.debug("guido:autosave:active-changed", { active: e }), e ? (c(), o = setInterval(() => {
68
- console.debug("guido:autosave:interval-tick"), r("interval");
69
- }, D), document.addEventListener("visibilitychange", i), window.addEventListener("pagehide", i)) : (c(), v(), t.status = a.IDLE);
65
+ console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
66
+ console.debug("guido:autosave:interval-tick"), l("interval");
67
+ }, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), r(), t.status = s.IDLE);
70
68
  },
71
69
  { immediate: !0 }
72
- ), k(() => {
73
- c(), v(), t.status = a.IDLE, t.lastSavedAt = null;
70
+ ), L(() => {
71
+ d(), r(), t.status = s.IDLE, t.lastSavedAt = null;
74
72
  });
75
73
  };
76
74
  export {
77
- _ as useAutoSave
75
+ R as useAutoSave
78
76
  };
@@ -1,70 +1,138 @@
1
- import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
2
- import { useToaster as I } from "./useToaster.js";
3
- import { useTranslations as P } from "./useTranslations.js";
4
- import { ToasterTypeOptions as S } from "../enums/toaster.js";
5
- import { getActivePinia as v } from "pinia";
6
- import { watch as B, onUnmounted as D } from "vue";
7
- const x = "email_template", L = "chat", M = "guido:debug:ai", R = () => {
1
+ import { useEmailTemplateApplier as z, resetEmailTemplateApplier as J } from "./useEmailTemplateApplier.js";
2
+ import { useToaster as Q } from "./useToaster.js";
3
+ import { useTranslations as V } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as Z } from "../enums/toaster.js";
5
+ import { useGuidoEmailEditorStore as W } from "../stores/guido-email-editor.js";
6
+ import { getActivePinia as k } from "pinia";
7
+ import { onUnmounted as tt, watch as et } from "vue";
8
+ const rt = "email_template", nt = "chat", ot = "guido:debug:ai", it = 2, lt = 500, ct = (b, p) => `${b}:${p ?? 1}`;
9
+ let S = null;
10
+ const at = () => {
8
11
  if (typeof window > "u")
9
12
  return !1;
10
13
  try {
11
- return window.localStorage.getItem(M) === "1";
14
+ return window.localStorage.getItem(ot) === "1";
12
15
  } catch {
13
16
  return !1;
14
17
  }
15
- }, H = () => {
16
- const c = v();
17
- if (!c)
18
+ }, bt = () => {
19
+ const b = k();
20
+ if (!b)
18
21
  return;
19
- const l = c._s, p = l == null ? void 0 : l.get(L);
20
- if (!p)
21
- return;
22
- const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: E } = I(), h = P(), y = (r, t) => {
23
- const e = h(r);
24
- return e === r ? t : e;
25
- }, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), A = (r, t) => {
26
- u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
27
- }, b = (r) => {
28
- if (r.blueprintType !== x)
22
+ const p = W(), M = Symbol("cortexBlueprintBridge");
23
+ S = M, p.$patch((t) => {
24
+ t.bridgeActive = !0;
25
+ });
26
+ const { markPending: F, applyTemplate: H, applyTemplateDebounced: O } = z(), { showToaster: C } = Q(), G = V(), E = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
27
+ let s = null;
28
+ const d = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), B = at();
29
+ let w = null, m = null, A;
30
+ const K = (t, r) => {
31
+ B && console.debug(`[guido:cortex] msg=${t ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
32
+ }, U = () => new Set((A == null ? void 0 : A.appliedBlueprintKeys) ?? []), Y = (t) => t instanceof Error ? t.message : String(t), D = (t, r, n, e) => {
33
+ if (S !== M)
34
+ return;
35
+ const o = p.applyAcks[t], c = Math.max(Date.now(), ((o == null ? void 0 : o.ackAt) ?? 0) + 1), a = { status: r, requestedAt: n, ackAt: c };
36
+ e !== void 0 && (a.error = Y(e)), p.$patch((l) => {
37
+ l.applyAcks = { ...l.applyAcks, [t]: a };
38
+ });
39
+ }, I = (t) => (d.get(t) ?? 0) > 0, P = (t) => (s == null ? void 0 : s.key) === t, v = async (t, r, n) => {
40
+ var a, l, h;
41
+ const e = ((a = r.blueprintData) == null ? void 0 : a.html) ?? "", o = ((l = r.blueprintData) == null ? void 0 : l.css) ?? "", c = r.applyRequestedAt ?? 0;
42
+ d.set(t, (d.get(t) ?? 0) + 1);
43
+ try {
44
+ const i = n === "debounced" ? await O(t, { html: e, css: o }) : await H(t, { html: e, css: o });
45
+ if (i.status === "superseded")
46
+ return;
47
+ if (i.status === "applied") {
48
+ E.set(t, e), u.delete(t), D(t, "applied", c);
49
+ return;
50
+ }
51
+ const y = u.get(t), j = (y == null ? void 0 : y.html) === e ? y.count + 1 : 1;
52
+ u.set(t, { html: e, count: j }), D(t, "failed", c, i.error);
53
+ } catch (i) {
54
+ console.error("[guido:apply] apply threw before it could settle", i), D(t, "failed", c, i);
55
+ } finally {
56
+ d.set(t, (d.get(t) ?? 1) - 1);
57
+ const i = T.get(t);
58
+ i && !I(t) && (T.delete(t), P(t) && (((h = i.blueprintData) == null ? void 0 : h.html) ?? "") !== e && v(t, i, n));
59
+ }
60
+ }, N = (t) => {
61
+ var h;
62
+ if (t.blueprintType !== rt)
29
63
  return;
30
- const t = r.blueprintId, e = r.blueprintData;
31
- if (!t || !(e != null && e.html))
64
+ const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
65
+ if (!r || !n)
32
66
  return;
33
- if (!r.applyRequested) {
34
- d(t);
67
+ const e = ct(r, t.version);
68
+ if (!t.applyRequested) {
69
+ F(e);
70
+ return;
71
+ }
72
+ const o = t.applyRequestedAt ?? 0, c = _.get(e);
73
+ if (c === void 0 || o > c) {
74
+ const i = c === void 0;
75
+ if (_.set(e, o), u.delete(e), (!s || o >= s.requestedAt) && (s = { key: e, requestedAt: o }), i && U().has(e)) {
76
+ E.set(e, n);
77
+ return;
78
+ }
79
+ v(e, t, "immediate");
80
+ return;
81
+ }
82
+ const a = E.get(e);
83
+ if (a === n || !P(e))
35
84
  return;
85
+ const l = u.get(e);
86
+ if (!((l == null ? void 0 : l.html) === n && l.count >= it)) {
87
+ if (a === void 0) {
88
+ if (I(e)) {
89
+ T.set(e, t);
90
+ return;
91
+ }
92
+ v(e, t, "immediate");
93
+ return;
94
+ }
95
+ f.get(e) !== n && (f.set(e, n), v(e, t, "debounced").finally(() => {
96
+ f.get(e) === n && f.delete(e);
97
+ }));
36
98
  }
37
- const o = i.get(t);
38
- o === void 0 ? (i.set(t, e.html), f(t, e)) : o !== e.html && (i.set(t, e.html), T(t, e));
39
- }, s = (r) => r === void 0 || a.has(r) ? !1 : (a.add(r), E({
40
- type: S.Error,
41
- message: y("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
42
- }), !0), m = B(
43
- () => p.messages,
44
- (r) => {
45
- Array.isArray(r) && r.forEach((t) => {
46
- const e = t == null ? void 0 : t.id;
47
- (t == null ? void 0 : t.isError) === !0 && s(e) && u && console.debug(`[guido:cortex] message-level error id=${e}`, t);
48
- const o = t == null ? void 0 : t.segments;
49
- Array.isArray(o) && o.forEach((n) => {
50
- if (n)
51
- switch (A(e, n), n.type) {
52
- case "blueprint":
53
- b(n);
54
- break;
55
- case "error":
56
- s(e);
57
- break;
58
- }
59
- });
99
+ }, R = (t) => t === void 0 || g.has(t) ? !1 : (g.add(t), C({
100
+ type: Z.Error,
101
+ message: G("newsletter.ai-template-failed")
102
+ }), !0), X = (t) => {
103
+ Array.isArray(t) && t.forEach((r) => {
104
+ const n = r == null ? void 0 : r.id;
105
+ (r == null ? void 0 : r.isError) === !0 && R(n) && B && console.debug(`[guido:cortex] message-level error id=${n}`, r);
106
+ const e = r == null ? void 0 : r.segments;
107
+ Array.isArray(e) && e.forEach((o) => {
108
+ if (o)
109
+ switch (K(n, o), o.type) {
110
+ case "blueprint":
111
+ N(o);
112
+ break;
113
+ case "error":
114
+ R(n);
115
+ break;
116
+ }
60
117
  });
61
- },
62
- { deep: !0, immediate: !0 }
63
- );
64
- D(() => {
65
- m(), i.clear(), a.clear(), _();
118
+ });
119
+ }, $ = () => {
120
+ w !== null && (clearInterval(w), w = null);
121
+ }, q = () => {
122
+ var t;
123
+ return (t = b._s) == null ? void 0 : t.get(nt);
124
+ }, L = (t) => {
125
+ A = t, m = et(() => t.messages, X, { deep: !0, immediate: !0 });
126
+ }, x = q();
127
+ x ? L(x) : w = setInterval(() => {
128
+ const t = q();
129
+ t && ($(), L(t));
130
+ }, lt), tt(() => {
131
+ $(), m == null || m(), A = void 0, E.clear(), f.clear(), _.clear(), u.clear(), s = null, d.clear(), T.clear(), g.clear(), S === M && (S = null, p.$patch((t) => {
132
+ t.bridgeActive = !1, t.applyAcks = {};
133
+ }), J());
66
134
  });
67
135
  };
68
136
  export {
69
- H as useCortexBlueprintBridge
137
+ bt as useCortexBlueprintBridge
70
138
  };