@useinsider/guido 3.19.0-beta.4b9be3a → 3.19.0-beta.4e3e6c4

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 (88) hide show
  1. package/README.md +21 -3
  2. package/dist/@types/config/schemas.js +59 -51
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +84 -87
  5. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  6. package/dist/components/organisms/base/AuthErrorModal.vue2.js +29 -0
  7. package/dist/components/organisms/base/Toaster.vue2.js +13 -12
  8. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
  9. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +78 -57
  10. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  11. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  12. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +28 -42
  13. package/dist/components/organisms/header/EditorActions.vue.js +4 -4
  14. package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
  15. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -24
  16. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  17. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  18. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
  19. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +47 -0
  20. package/dist/components/wrappers/WpModal.vue.js +1 -1
  21. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  22. package/dist/composables/useActionsApi.js +44 -43
  23. package/dist/composables/useAuthError.js +52 -0
  24. package/dist/composables/useCodeEditorApi.js +23 -9
  25. package/dist/composables/useCortexBlueprintBridge.js +54 -120
  26. package/dist/composables/useCustomInterfaceAppearance.js +65 -51
  27. package/dist/composables/useEmailTemplateApplier.js +51 -96
  28. package/dist/composables/useHtmlValidator.js +87 -82
  29. package/dist/composables/useHttp.js +61 -54
  30. package/dist/composables/useLegacyStrategyConversion.js +61 -0
  31. package/dist/composables/useRecommendation.js +40 -35
  32. package/dist/composables/useStripo.js +30 -30
  33. package/dist/composables/useToaster.js +18 -22
  34. package/dist/composables/useTranslations.js +3 -2
  35. package/dist/composables/useVersionHistoryApi.js +33 -24
  36. package/dist/composables/validators/useLiquidValidator.js +15 -15
  37. package/dist/enums/extensions/recommendationBlock.js +49 -33
  38. package/dist/extensions/Blocks/Recommendation/block.js +61 -42
  39. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +21 -20
  40. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +100 -94
  41. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +130 -55
  42. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
  43. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +273 -92
  44. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  45. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +26 -16
  46. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +24 -0
  47. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +21 -12
  48. package/dist/guido.css +1 -1
  49. package/dist/services/recommendationApi.js +46 -37
  50. package/dist/src/@types/config/schemas.d.ts +16 -0
  51. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  52. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  53. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
  54. package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
  55. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  56. package/dist/src/composables/useAuthError.d.ts +12 -0
  57. package/dist/src/composables/useConfig.d.ts +4 -0
  58. package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -4
  59. package/dist/src/composables/useEmailTemplateApplier.d.ts +5 -26
  60. package/dist/src/composables/useHttp.d.ts +2 -0
  61. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  62. package/dist/src/enums/extensions/recommendationBlock.d.ts +7 -1
  63. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
  64. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +1 -0
  65. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  66. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +2 -0
  67. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +10 -0
  68. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +7 -2
  69. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +162 -1
  70. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  71. package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +14 -0
  72. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +4 -0
  73. package/dist/src/services/recommendationApi.d.ts +2 -1
  74. package/dist/src/stores/config.d.ts +322 -0
  75. package/dist/src/stores/guido-email-editor.d.ts +10 -32
  76. package/dist/src/stores/onboarding.d.ts +808 -10
  77. package/dist/src/utils/stripoEditorApi.d.ts +4 -0
  78. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  79. package/dist/static/assets/icons/line-info.svg.js +5 -0
  80. package/dist/static/styles/components/recommendation-strategy.css.js +104 -9
  81. package/dist/static/styles/components/skeleton.css.js +23 -0
  82. package/dist/stores/config.js +74 -60
  83. package/dist/stores/guido-email-editor.js +1 -3
  84. package/dist/stores/onboarding.js +46 -36
  85. package/dist/stores/unsubscribe.js +3 -3
  86. package/dist/utils/stripoEditorApi.js +11 -0
  87. package/dist/utils/templatePreparation.js +55 -55
  88. package/package.json +2 -1
@@ -0,0 +1,46 @@
1
+ import { defineComponent as d, computed as g, watch as l } from "vue";
2
+ import { useRibbonOffset as b } from "../../../composables/useRibbonOffset.js";
3
+ import { useTranslations as p } from "../../../composables/useTranslations.js";
4
+ import { ACADEMY_LINKS as u } from "../../../enums/academy.js";
5
+ import { useOnboardingStore as y } from "../../../stores/onboarding.js";
6
+ import { InOnboard as f } from "@useinsider/design-system-vue";
7
+ const A = /* @__PURE__ */ d({
8
+ __name: "RecommendationLegacyStrategyOnboarding",
9
+ setup(O) {
10
+ const n = "recommendationLegacyStrategyOnboarding", o = p(), t = y(), { getTopPosition: i } = b(), r = `<a href="${u.EMAIL_RECOMMENDATION_BLOCK}" target="_blank" rel="noopener noreferrer">${o("action-builder.visit-academy")}</a>`, a = () => [
11
+ {
12
+ classes: "guido-recommendation-legacy-strategy-onboarding",
13
+ right: "40px",
14
+ top: i(485),
15
+ position: "Top Right",
16
+ title: o("email-editor.onboarding-recommendation-strategy-legacy-title"),
17
+ description: o("email-editor.onboarding-recommendation-strategy-legacy-description", {
18
+ academyLink: r
19
+ }),
20
+ imageSource: "",
21
+ backButtonClick: () => {
22
+ },
23
+ nextButtonType: "text",
24
+ nextButtonText: o("action-builder.ok"),
25
+ nextButtonClick: () => {
26
+ t.close(n);
27
+ }
28
+ }
29
+ ], s = g(
30
+ () => t.onboardings.recommendationLegacyStrategyOnboarding.config.length > 0 && t.onboardings.recommendationLegacyStrategyOnboarding.isActive
31
+ ), m = () => {
32
+ var e, c;
33
+ (c = (e = t.getRecommendationLegacyStrategyCurrentCard) == null ? void 0 : e.nextButtonClick) == null || c.call(e);
34
+ };
35
+ return l(
36
+ () => t.isActive(n),
37
+ (e) => {
38
+ e && t.setConfig(n, a());
39
+ },
40
+ { immediate: !0 }
41
+ ), { __sfc: !0, ONBOARDING_TYPE: n, trans: o, onboardingStore: t, getTopPosition: i, academyLink: r, buildOnboardingCards: a, isVisible: s, handleNext: m, InOnboard: f };
42
+ }
43
+ });
44
+ export {
45
+ A as default
46
+ };
@@ -0,0 +1,21 @@
1
+ import d from "./RecommendationStrategyOnboarding.vue2.js";
2
+ /* empty css */
3
+ import g from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var m = function() {
5
+ var e, n, r, i, a;
6
+ var t = this, s = t._self._c, o = t._self._setupProxy;
7
+ return o.isVisible ? s(o.InOnboard, { key: "guido__recommendation-strategy-onboard", staticClass: "w-21-s p-a z-11", class: (e = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : e.classes, attrs: { id: "guido__recommendation-strategy-onboard", "is-multiple-page": "", visible: "", "image-source": "", title: "", "left-position": (n = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : n.left, "pages-config": o.onboardingStore.onboardings.recommendationStrategyOnboarding.config, "pointer-position": (r = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : r.position, "right-position": (i = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : i.right, "top-position": (a = o.onboardingStore.getRecommendationStrategyCurrentCard) == null ? void 0 : a.top }, on: { close: function(p) {
8
+ return o.onboardingStore.close(o.ONBOARDING_TYPE);
9
+ }, nextButtonClick: o.handleNext } }) : t._e();
10
+ }, c = [], _ = /* @__PURE__ */ g(
11
+ d,
12
+ m,
13
+ c,
14
+ !1,
15
+ null,
16
+ "ec2027ff"
17
+ );
18
+ const S = _.exports;
19
+ export {
20
+ S as default
21
+ };
@@ -0,0 +1,47 @@
1
+ import { defineComponent as g, computed as p, watch as b } from "vue";
2
+ import { useRibbonOffset as u } from "../../../composables/useRibbonOffset.js";
3
+ import { useTranslations as l } from "../../../composables/useTranslations.js";
4
+ import { ACADEMY_LINKS as f } from "../../../enums/academy.js";
5
+ import { useRecommendationExtensionStore as O } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
6
+ import { useOnboardingStore as _ } from "../../../stores/onboarding.js";
7
+ import { InOnboard as y } from "@useinsider/design-system-vue";
8
+ const h = /* @__PURE__ */ g({
9
+ __name: "RecommendationStrategyOnboarding",
10
+ setup(C) {
11
+ const n = "recommendationStrategyOnboarding", e = l(), t = _(), i = O(), { getTopPosition: r } = u(), a = `<a href="${f.EMAIL_RECOMMENDATION_BLOCK}" target="_blank" rel="noopener noreferrer">${e("action-builder.visit-academy")}</a>`, m = () => [
12
+ {
13
+ classes: "guido-recommendation-strategy-onboarding",
14
+ // Sits in the gap left of the settings panel and points at the strategy section, which
15
+ // starts 208px down: the panel header and its tab row are fixed chrome above it.
16
+ right: "426px",
17
+ top: r(208),
18
+ position: "Right Top",
19
+ title: e("email-editor.onboarding-recommendation-strategy-title"),
20
+ description: e("email-editor.onboarding-recommendation-strategy-description", {
21
+ academyLink: a
22
+ }),
23
+ imageSource: "",
24
+ backButtonClick: () => {
25
+ },
26
+ nextButtonType: "text",
27
+ nextButtonText: e("action-builder.ok"),
28
+ nextButtonClick: () => {
29
+ t.close(n);
30
+ }
31
+ }
32
+ ], c = p(() => i.strategyPanelOpen && t.onboardings.recommendationStrategyOnboarding.config.length > 0 && t.onboardings.recommendationStrategyOnboarding.isActive), d = () => {
33
+ var o, s;
34
+ (s = (o = t.getRecommendationStrategyCurrentCard) == null ? void 0 : o.nextButtonClick) == null || s.call(o);
35
+ };
36
+ return b(
37
+ () => t.isActive(n),
38
+ (o) => {
39
+ o && t.setConfig(n, m());
40
+ },
41
+ { immediate: !0 }
42
+ ), { __sfc: !0, ONBOARDING_TYPE: n, trans: e, onboardingStore: t, recommendationStore: i, getTopPosition: r, academyLink: a, buildOnboardingCards: m, isVisible: c, handleNext: d, InOnboard: y };
43
+ }
44
+ });
45
+ export {
46
+ h as default
47
+ };
@@ -2,7 +2,7 @@ import r from "./WpModal.vue2.js";
2
2
  import s from "../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var i = function() {
4
4
  var t = this, o = t._self._c, e = t._self._setupProxy;
5
- return o(e.InModalV2, { attrs: { id: t.id, "description-status": "", status: "", "close-button-status": t.closeButtonStatus, "close-on-outside-click": t.closeOnOutsideClick, "description-text": t.description, "footer-button-group-options": t.footerButtonOptions, "footer-status": t.footerStatus, size: t.size, "title-text": t.title }, on: { cancelOrBackButtonEvent: function(n) {
5
+ return o(e.InModalV2, { attrs: { id: t.id, "description-status": "", status: "", "close-button-status": t.closeButtonStatus, "close-on-outside-click": t.closeOnOutsideClick, "description-text": t.description, "footer-button-group-options": t.footerButtonOptions, "footer-status": t.footerStatus, size: t.size, state: t.state, "title-text": t.title }, on: { cancelOrBackButtonEvent: function(n) {
6
6
  return e.emit("close");
7
7
  }, onCloseEvent: function(n) {
8
8
  return e.emit("close");
@@ -1,11 +1,12 @@
1
1
  import { defineComponent as e } from "vue";
2
2
  import { InModalV2 as o } from "@useinsider/design-system-vue";
3
- const u = /* @__PURE__ */ e({
3
+ const n = /* @__PURE__ */ e({
4
4
  __name: "WpModal",
5
5
  props: {
6
6
  id: null,
7
7
  title: null,
8
8
  description: { default: "" },
9
+ state: { default: "default" },
9
10
  size: { default: "small" },
10
11
  footerButtonOptions: { default: void 0 },
11
12
  closeButtonStatus: { type: Boolean, default: !0 },
@@ -13,10 +14,10 @@ const u = /* @__PURE__ */ e({
13
14
  footerStatus: { type: Boolean, default: !0 }
14
15
  },
15
16
  emits: ["close", "primary-action", "secondary-action"],
16
- setup(l, { emit: t }) {
17
+ setup(a, { emit: t }) {
17
18
  return { __sfc: !0, emit: t, InModalV2: o };
18
19
  }
19
20
  });
20
21
  export {
21
- u as default
22
+ n as default
22
23
  };
@@ -1,22 +1,23 @@
1
- import { filterAmpErrors as v } from "../utils/ampErrorFilter.js";
2
- import { useToaster as y } from "./useToaster.js";
3
- const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
4
- const c = setTimeout(
5
- () => s(new Error(`${n} did not report completion within ${l}ms`)),
1
+ import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
2
+ import { getEditorApi as s } from "../utils/stripoEditorApi.js";
3
+ import { useToaster as D } from "./useToaster.js";
4
+ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
5
+ const f = setTimeout(
6
+ () => p(new Error(`${n} did not report completion within ${l}ms`)),
6
7
  l
7
- ), d = (r) => (t) => {
8
- clearTimeout(c), r(t);
9
- };
8
+ ), c = (t) => (e) => {
9
+ clearTimeout(f), t(e);
10
+ }, d = c(p);
10
11
  try {
11
- w(d(A), d(s));
12
- } catch (r) {
13
- clearTimeout(c), s(r instanceof Error ? r : new Error(String(r)));
12
+ A(c(C), d);
13
+ } catch (t) {
14
+ d(t);
14
15
  }
15
- }), I = () => {
16
- const { handleError: n } = y(), l = (t = {}) => p(
16
+ }), P = () => {
17
+ const { handleError: n } = D(), l = (t = {}) => r(
17
18
  "compileEmail",
18
19
  T,
19
- (e, a) => {
20
+ (e, i) => {
20
21
  const o = { ...{
21
22
  minimize: !0,
22
23
  utmEntity: {
@@ -37,52 +38,52 @@ const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
37
38
  resetDataSavedFlag: !1,
38
39
  disableLineHeightsReplace: !0
39
40
  }, ...t }, u = {
40
- callback: (m, C, f, S, g) => {
41
- m ? a(m) : e({
42
- html: C,
43
- ampHtml: f,
44
- ampErrors: v(S ?? []),
45
- displayConditions: g
41
+ callback: (m, g, w, S, v) => {
42
+ m ? i(m) : e({
43
+ html: g,
44
+ ampHtml: w,
45
+ ampErrors: y(S ?? []),
46
+ displayConditions: v
46
47
  });
47
48
  },
48
49
  ...o
49
50
  };
50
- window.StripoEditorApi.actionsApi.compileEmail(u);
51
+ s().actionsApi.compileEmail(u);
51
52
  }
52
53
  );
53
54
  return {
54
55
  getCompiledEmail: l,
55
- getTemplateData: () => p(
56
+ getTemplateData: () => r(
56
57
  "getTemplateData",
57
58
  T,
58
59
  (t) => {
59
- const e = ({ html: a, css: i, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
60
- html: a,
61
- css: i,
60
+ const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
61
+ html: i,
62
+ css: a,
62
63
  width: o,
63
64
  height: E,
64
65
  utmParams: u,
65
66
  syncModulesIds: m
66
67
  });
67
- window.StripoEditorApi.actionsApi.getTemplateData(e);
68
+ s().actionsApi.getTemplateData(e);
68
69
  }
69
70
  ),
70
71
  activateCustomViewStyles: (t = !0) => {
71
- window.StripoEditorApi.actionsApi.activateCustomViewStyles(t);
72
+ s().actionsApi.activateCustomViewStyles(t);
72
73
  },
73
74
  getPreviewData: async (t) => {
74
75
  try {
75
76
  const {
76
77
  html: e,
77
- displayConditions: a,
78
- ampHtml: i = "",
78
+ displayConditions: i,
79
+ ampHtml: a = "",
79
80
  ampErrors: o = []
80
81
  } = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
81
82
  return {
82
83
  html: e,
83
- ampHtml: i,
84
+ ampHtml: a,
84
85
  ampErrors: o,
85
- displayConditions: a
86
+ displayConditions: i
86
87
  };
87
88
  } catch (e) {
88
89
  return n(e, "Error loading preview"), {
@@ -94,30 +95,30 @@ const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
94
95
  }
95
96
  },
96
97
  updateTimerInClonedTemplate: () => new Promise((t) => {
97
- var e, a;
98
- if (typeof ((a = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : a.updateTimerInClonedTemplate) != "function") {
98
+ var e, i;
99
+ if (typeof ((i = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : i.updateTimerInClonedTemplate) != "function") {
99
100
  t(null);
100
101
  return;
101
102
  }
102
103
  try {
103
- window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((i, o) => {
104
- i ? (n(i, "Failed to update timer in cloned template"), t(null)) : t(o || null);
104
+ window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((a, o) => {
105
+ a ? (n(a, "Failed to update timer in cloned template"), t(null)) : t(o || null);
105
106
  });
106
- } catch (i) {
107
- n(i, "Failed to call updateTimerInClonedTemplate"), t(null);
107
+ } catch (a) {
108
+ n(a, "Failed to call updateTimerInClonedTemplate"), t(null);
108
109
  }
109
110
  }),
110
111
  updateHtmlAndCss: (t, e) => {
111
- const { actionsApi: a } = window.StripoEditorApi;
112
- return p("updateHtmlAndCss", D, (i) => {
113
- a.updateHtmlAndCss(t, e, () => i());
112
+ const { actionsApi: i } = s();
113
+ return r("updateHtmlAndCss", h, (a) => {
114
+ i.updateHtmlAndCss(t, e, () => a());
114
115
  });
115
116
  },
116
- editorSave: () => p(
117
+ editorSave: () => r(
117
118
  "save",
118
119
  T,
119
120
  (t) => {
120
- window.StripoEditorApi.actionsApi.save((e) => {
121
+ s().actionsApi.save((e) => {
121
122
  if (e) {
122
123
  n(e, "Failed to save template"), t(!1);
123
124
  return;
@@ -129,5 +130,5 @@ const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
129
130
  };
130
131
  };
131
132
  export {
132
- I as useActionsApi
133
+ P as useActionsApi
133
134
  };
@@ -0,0 +1,52 @@
1
+ import { ToasterTypeOptions as l } from "../enums/toaster.js";
2
+ import { ref as p } from "vue";
3
+ import { useToaster as u } from "./useToaster.js";
4
+ import { useTranslations as f } from "./useTranslations.js";
5
+ const d = ["accessExpired", "domainRestricted", "ipRestricted", "insiderAccessRestricted"], n = p(null), a = (e) => {
6
+ try {
7
+ return new URL(e, window.location.href).origin === window.location.origin;
8
+ } catch {
9
+ return !0;
10
+ }
11
+ }, g = (e) => {
12
+ try {
13
+ const o = new URL(e, window.location.href);
14
+ return o.origin === window.location.origin ? o.href : "";
15
+ } catch {
16
+ return "";
17
+ }
18
+ }, w = (e) => {
19
+ try {
20
+ const o = JSON.parse(e);
21
+ return o && typeof o == "object" && Object.keys(o).length ? o : null;
22
+ } catch {
23
+ return null;
24
+ }
25
+ }, y = (e) => typeof (e == null ? void 0 : e.message) == "string" ? e.message : "", s = (e) => y(e) || f()("user-management.collaborate-forbidden-action"), c = (e) => {
26
+ u().showToaster({ type: l.Error, message: e });
27
+ }, R = (e, o, t) => {
28
+ if (t && !a(t))
29
+ return;
30
+ const r = w(o);
31
+ if (e === 403) {
32
+ c(s(r));
33
+ return;
34
+ }
35
+ if (e === 401 && (r == null ? void 0 : r.type) === "groupLevelAccess") {
36
+ c(s(r));
37
+ return;
38
+ }
39
+ if (e === 401 && typeof (r == null ? void 0 : r.type) == "string" && d.includes(r.type)) {
40
+ const i = typeof r.redirect == "string" ? g(r.redirect) : "";
41
+ if (i) {
42
+ window.location.replace(i);
43
+ return;
44
+ }
45
+ }
46
+ e !== 401 && e !== 419 || n.value || (window.isSessionExpired = !0, n.value = { status: e, data: r });
47
+ }, T = () => ({ authError: n });
48
+ export {
49
+ a as isPanelOrigin,
50
+ R as reportAuthError,
51
+ T as useAuthError
52
+ };
@@ -1,11 +1,25 @@
1
- const i = () => ({
2
- openCodeEditor: () => {
3
- window.StripoEditorApi.codeEditorApi.openCodeEditor();
4
- },
5
- closeCodeEditor: () => {
6
- window.StripoEditorApi.codeEditorApi.closeCodeEditor();
7
- }
8
- });
1
+ import { ToasterTypeOptions as d } from "../enums/toaster.js";
2
+ import { findEditorApi as s, EDITOR_NOT_READY_MESSAGE as p } from "../utils/stripoEditorApi.js";
3
+ import { useToaster as E } from "./useToaster.js";
4
+ const T = () => {
5
+ const { showToaster: i } = E(), t = (o) => {
6
+ var r;
7
+ const e = (r = s()) == null ? void 0 : r.codeEditorApi;
8
+ if (!e) {
9
+ i({ type: d.Error, message: p });
10
+ return;
11
+ }
12
+ o(e);
13
+ };
14
+ return {
15
+ openCodeEditor: () => {
16
+ t((o) => o.openCodeEditor());
17
+ },
18
+ closeCodeEditor: () => {
19
+ t((o) => o.closeCodeEditor());
20
+ }
21
+ };
22
+ };
9
23
  export {
10
- i as useCodeEditorApi
24
+ T as useCodeEditorApi
11
25
  };
@@ -1,136 +1,70 @@
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", it = "guido:debug:ai", ot = 2, lt = 500, ct = (E, u) => `${E}:${u ?? 1}`;
9
- let y = null;
10
- const at = () => {
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 = () => {
11
8
  if (typeof window > "u")
12
9
  return !1;
13
10
  try {
14
- return window.localStorage.getItem(it) === "1";
11
+ return window.localStorage.getItem(M) === "1";
15
12
  } catch {
16
13
  return !1;
17
14
  }
18
- }, Et = () => {
19
- const E = k();
20
- if (!E)
15
+ }, H = () => {
16
+ const c = v();
17
+ if (!c)
21
18
  return;
22
- const u = W(), M = Symbol("cortexBlueprintBridge");
23
- y = M, u.$patch((t) => {
24
- t.bridgeActive = !0;
25
- });
26
- const { markPending: F, applyTemplate: H, applyTemplateDebounced: O } = z(), { showToaster: C } = Q(), G = V(), b = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
27
- let s = null;
28
- const d = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set(), D = at();
29
- let w = null, m = null, A;
30
- const K = (t, r) => {
31
- D && 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), B = (t, r, n, e) => {
33
- if (y !== M)
34
- return;
35
- const i = u.applyAcks[t], c = Math.max(Date.now(), ((i == null ? void 0 : i.ackAt) ?? 0) + 1), a = { status: r, requestedAt: n, ackAt: c };
36
- e !== void 0 && (a.error = Y(e)), u.$patch((o) => {
37
- o.applyAcks = { ...o.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, o, h;
41
- const e = ((a = r.blueprintData) == null ? void 0 : a.html) ?? "", i = ((o = r.blueprintData) == null ? void 0 : o.css) ?? "", c = r.applyRequestedAt ?? 0;
42
- d.set(t, (d.get(t) ?? 0) + 1);
43
- try {
44
- const l = n === "debounced" ? await O(t, { html: e, css: i }) : await H(t, { html: e, css: i });
45
- if (l.status === "superseded")
46
- return;
47
- if (l.status === "applied") {
48
- b.set(t, e), p.delete(t), B(t, "applied", c);
49
- return;
50
- }
51
- const S = p.get(t), j = (S == null ? void 0 : S.html) === e ? S.count + 1 : 1;
52
- p.set(t, { html: e, count: j }), B(t, "failed", c, l.error);
53
- } finally {
54
- d.set(t, (d.get(t) ?? 1) - 1);
55
- const l = T.get(t);
56
- l && !I(t) && (T.delete(t), P(t) && (((h = l.blueprintData) == null ? void 0 : h.html) ?? "") !== e && v(t, l, n));
57
- }
58
- }, N = (t) => {
59
- var h;
60
- if (t.blueprintType !== rt)
61
- return;
62
- const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
63
- if (!r || !n)
64
- return;
65
- const e = ct(r, t.version);
66
- if (!t.applyRequested) {
67
- F(e);
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)
68
29
  return;
69
- }
70
- const i = t.applyRequestedAt ?? 0, c = _.get(e);
71
- if (c === void 0 || i > c) {
72
- const l = c === void 0;
73
- if (_.set(e, i), p.delete(e), (!s || i >= s.requestedAt) && (s = { key: e, requestedAt: i }), l && U().has(e)) {
74
- b.set(e, n);
75
- return;
76
- }
77
- v(e, t, "immediate");
30
+ const t = r.blueprintId, e = r.blueprintData;
31
+ if (!t || !(e != null && e.html))
78
32
  return;
79
- }
80
- const a = b.get(e);
81
- if (a === n || !P(e))
33
+ if (!r.applyRequested) {
34
+ d(t);
82
35
  return;
83
- const o = p.get(e);
84
- if (!((o == null ? void 0 : o.html) === n && o.count >= ot)) {
85
- if (a === void 0) {
86
- if (I(e)) {
87
- T.set(e, t);
88
- return;
89
- }
90
- v(e, t, "immediate");
91
- return;
92
- }
93
- f.get(e) !== n && (f.set(e, n), v(e, t, "debounced").finally(() => {
94
- f.get(e) === n && f.delete(e);
95
- }));
96
36
  }
97
- }, R = (t) => t === void 0 || g.has(t) ? !1 : (g.add(t), C({
98
- type: Z.Error,
99
- message: G("newsletter.ai-template-failed")
100
- }), !0), X = (t) => {
101
- Array.isArray(t) && t.forEach((r) => {
102
- const n = r == null ? void 0 : r.id;
103
- (r == null ? void 0 : r.isError) === !0 && R(n) && D && console.debug(`[guido:cortex] message-level error id=${n}`, r);
104
- const e = r == null ? void 0 : r.segments;
105
- Array.isArray(e) && e.forEach((i) => {
106
- if (i)
107
- switch (K(n, i), i.type) {
108
- case "blueprint":
109
- N(i);
110
- break;
111
- case "error":
112
- R(n);
113
- break;
114
- }
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
+ });
115
60
  });
116
- });
117
- }, $ = () => {
118
- w !== null && (clearInterval(w), w = null);
119
- }, q = () => {
120
- var t;
121
- return (t = E._s) == null ? void 0 : t.get(nt);
122
- }, L = (t) => {
123
- A = t, m = et(() => t.messages, X, { deep: !0, immediate: !0 });
124
- }, x = q();
125
- x ? L(x) : w = setInterval(() => {
126
- const t = q();
127
- t && ($(), L(t));
128
- }, lt), tt(() => {
129
- $(), m == null || m(), A = void 0, b.clear(), f.clear(), _.clear(), p.clear(), s = null, d.clear(), T.clear(), g.clear(), y === M && (y = null, u.$patch((t) => {
130
- t.bridgeActive = !1, t.applyAcks = {};
131
- }), J());
61
+ },
62
+ { deep: !0, immediate: !0 }
63
+ );
64
+ D(() => {
65
+ m(), i.clear(), a.clear(), _();
132
66
  });
133
67
  };
134
68
  export {
135
- Et as useCortexBlueprintBridge
69
+ H as useCortexBlueprintBridge
136
70
  };