@useinsider/guido 3.3.0-beta.b7e5793 → 3.3.0-beta.d5c796a

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 (34) hide show
  1. package/dist/components/Guido.vue.js +1 -1
  2. package/dist/components/Guido.vue2.js +42 -40
  3. package/dist/components/organisms/header/AiStatusPill.vue.js +18 -0
  4. package/dist/components/organisms/header/AiStatusPill.vue2.js +13 -0
  5. package/dist/components/organisms/header/MiddleSlot.vue.js +7 -7
  6. package/dist/components/organisms/header/MiddleSlot.vue2.js +8 -7
  7. package/dist/composables/useCortexBlueprintBridge.js +91 -0
  8. package/dist/composables/useEmailTemplateApplier.js +41 -0
  9. package/dist/composables/useGuidoStateBridge.js +48 -0
  10. package/dist/composables/useHtmlValidator.js +36 -41
  11. package/dist/composables/useRecommendation.js +2 -2
  12. package/dist/enums/extensions/recommendationBlock.js +41 -95
  13. package/dist/enums/unsubscribe.js +24 -25
  14. package/dist/extensions/Blocks/Checkbox/control.js +23 -23
  15. package/dist/extensions/Blocks/RadioButton/control.js +15 -15
  16. package/dist/extensions/Blocks/Recommendation/block.js +36 -43
  17. package/dist/extensions/Blocks/Recommendation/services/configService.js +26 -33
  18. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +26 -35
  19. package/dist/guido.css +1 -1
  20. package/dist/src/components/organisms/header/AiStatusPill.vue.d.ts +2 -0
  21. package/dist/src/composables/useCortexBlueprintBridge.d.ts +28 -0
  22. package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
  23. package/dist/src/composables/useGuidoStateBridge.d.ts +22 -0
  24. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -5
  25. package/dist/src/enums/unsubscribe.d.ts +3 -8
  26. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +3 -11
  27. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -7
  28. package/dist/src/stores/ai-status.d.ts +41 -0
  29. package/dist/src/stores/guido-email-editor.d.ts +41 -0
  30. package/dist/stores/ai-status.js +25 -0
  31. package/dist/stores/guido-email-editor.js +20 -0
  32. package/package.json +1 -1
  33. package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +0 -33
  34. package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -21
@@ -12,7 +12,7 @@ var t = function() {
12
12
  n,
13
13
  !1,
14
14
  null,
15
- "1a4e7084"
15
+ "cdee3452"
16
16
  );
17
17
  const l = s.exports;
18
18
  export {
@@ -1,38 +1,40 @@
1
- import { defineComponent as J, defineAsyncComponent as I, ref as W, computed as B, watch as Q, onMounted as X, onUnmounted as Y } from "vue";
2
- import { provideGuidoActions as Z } from "../composables/useGuidoActions.js";
3
- import { usePartner as ee } from "../composables/usePartner.js";
4
- import { useStripo as oe } from "../composables/useStripo.js";
5
- import { useTimerClone as te } from "../composables/useTimerClone.js";
6
- import { migrate as H } from "../config/migrator/index.js";
7
- import { ModuleFolderDefaults as x } from "../enums/defaults.js";
8
- import { RIBBON_SELECTOR as ne } from "../enums/onboarding.js";
9
- import re from "./organisms/AutoSaveController.vue.js";
10
- import se from "./organisms/base/Toaster.vue.js";
11
- import ce from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
12
- import ae from "./organisms/header/HeaderWrapper.vue.js";
13
- import ie from "./organisms/LoadingWrapper.vue.js";
14
- import me from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
15
- import de from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
16
- import { useStripoApi as le } from "../services/stripoApi.js";
17
- import { useConfigStore as ue } from "../stores/config.js";
18
- import { useDynamicContentStore as pe } from "../stores/dynamic-content.js";
19
- import { useEditorStore as fe } from "../stores/editor.js";
20
- import { usePreviewStore as ve } from "../stores/preview.js";
21
- import { useUnsubscribeStore as ye } from "../stores/unsubscribe.js";
22
- const We = /* @__PURE__ */ J({
1
+ import { defineComponent as J, defineAsyncComponent as R, ref as I, computed as W, watch as Q, onMounted as X, onUnmounted as Y } from "vue";
2
+ import { useCortexBlueprintBridge as Z } from "../composables/useCortexBlueprintBridge.js";
3
+ import { provideGuidoActions as ee } from "../composables/useGuidoActions.js";
4
+ import { useGuidoStateBridge as oe } from "../composables/useGuidoStateBridge.js";
5
+ import { usePartner as te } from "../composables/usePartner.js";
6
+ import { useStripo as ne } from "../composables/useStripo.js";
7
+ import { useTimerClone as re } from "../composables/useTimerClone.js";
8
+ import { migrate as x } from "../config/migrator/index.js";
9
+ import { ModuleFolderDefaults as G } from "../enums/defaults.js";
10
+ import { RIBBON_SELECTOR as se } from "../enums/onboarding.js";
11
+ import ce from "./organisms/AutoSaveController.vue.js";
12
+ import ae from "./organisms/base/Toaster.vue.js";
13
+ import ie from "./organisms/extensions/recommendation/FilterSelectionDrawer.vue.js";
14
+ import me from "./organisms/header/HeaderWrapper.vue.js";
15
+ import de from "./organisms/LoadingWrapper.vue.js";
16
+ import le from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
17
+ import ue from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
18
+ import { useStripoApi as pe } from "../services/stripoApi.js";
19
+ import { useConfigStore as fe } from "../stores/config.js";
20
+ import { useDynamicContentStore as ve } from "../stores/dynamic-content.js";
21
+ import { useEditorStore as ye } from "../stores/editor.js";
22
+ import { usePreviewStore as he } from "../stores/preview.js";
23
+ import { useUnsubscribeStore as Se } from "../stores/unsubscribe.js";
24
+ const He = /* @__PURE__ */ J({
23
25
  __name: "Guido",
24
26
  props: {
25
27
  config: null
26
28
  },
27
29
  emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
28
- setup(G, { expose: z, emit: n }) {
29
- const g = G, q = I(
30
+ setup(H, { expose: z, emit: n }) {
31
+ const g = H, q = R(
30
32
  () => import("./organisms/email-preview/PreviewContainer.vue.js")
31
- ), K = I(
33
+ ), K = R(
32
34
  () => import("./organisms/onboarding/OnboardingWrapper.vue.js")
33
- ), w = W(), u = W(), p = pe(), E = ye(), i = ue();
35
+ ), w = I(), u = I(), p = ve(), E = Se(), i = fe();
34
36
  i.init(g.config);
35
- const f = fe(), V = ve(), m = B(() => f.hasChanges), { isTestPartner: $ } = ee(), D = () => {
37
+ const f = ye(), V = he(), m = W(() => f.hasChanges), { isTestPartner: $ } = te(), D = () => {
36
38
  var e;
37
39
  return (e = w.value) == null ? void 0 : e.handleSave(!0);
38
40
  }, {
@@ -42,8 +44,8 @@ const We = /* @__PURE__ */ J({
42
44
  username: k,
43
45
  template: o,
44
46
  editor: s
45
- } = i, d = (o == null ? void 0 : o.html) || "", F = (o == null ? void 0 : o.css) || "", y = (o == null ? void 0 : o.preselectedDynamicContent) || [], L = (s == null ? void 0 : s.savedModulesFolderName) || x.SAVED_MODULES, U = (s == null ? void 0 : s.defaultModulesFolderName) || x.DEFAULT_MODULES;
46
- f.templateId = v;
47
+ } = i, d = (o == null ? void 0 : o.html) || "", F = (o == null ? void 0 : o.css) || "", y = (o == null ? void 0 : o.preselectedDynamicContent) || [], L = (s == null ? void 0 : s.savedModulesFolderName) || G.SAVED_MODULES, U = (s == null ? void 0 : s.defaultModulesFolderName) || G.DEFAULT_MODULES;
48
+ f.templateId = v, Z(), oe();
47
49
  const h = {
48
50
  emailId: v,
49
51
  userId: C,
@@ -56,11 +58,11 @@ const We = /* @__PURE__ */ J({
56
58
  onReady: () => {
57
59
  console.debug("guido:ready"), n("ready");
58
60
  }
59
- }, { initPlugin: M } = oe(h, _), { getDefaultTemplate: O } = le(), { cloneTimersOnSave: P, hasTimerBlocks: A } = te(), j = B(() => {
61
+ }, { initPlugin: M } = ne(h, _), { getDefaultTemplate: O } = pe(), { cloneTimersOnSave: P, hasTimerBlocks: A } = re(), j = W(() => {
60
62
  var e;
61
63
  return !((e = i.ui) != null && e.showHeader);
62
64
  });
63
- Z({
65
+ ee({
64
66
  onBack: () => {
65
67
  console.debug("guido:back"), n("back");
66
68
  },
@@ -75,9 +77,9 @@ const We = /* @__PURE__ */ J({
75
77
  console.debug("guido:test-email:click"), n("test-email:click");
76
78
  }
77
79
  });
78
- const N = (e) => {
80
+ const B = (e) => {
79
81
  console.debug("dynamic-content:close", e), p.setSelectedDynamicContent(e), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: e }));
80
- }, R = () => {
82
+ }, N = () => {
81
83
  console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
82
84
  };
83
85
  Q(() => m.value, () => {
@@ -90,7 +92,7 @@ const We = /* @__PURE__ */ J({
90
92
  let c = null;
91
93
  const b = () => {
92
94
  var t;
93
- const e = document.querySelector(ne);
95
+ const e = document.querySelector(se);
94
96
  (t = u.value) == null || t.style.setProperty("--ribbon-offset", `${(e == null ? void 0 : e.offsetHeight) ?? 0}px`);
95
97
  };
96
98
  return X(async () => {
@@ -102,10 +104,10 @@ const We = /* @__PURE__ */ J({
102
104
  E.selectedUnsubscribePages = (o == null ? void 0 : o.selectedUnsubscribePages) || [];
103
105
  const a = ((l = o == null ? void 0 : o.migration) == null ? void 0 : l.recommendationConfigs) ?? {};
104
106
  let r = {
105
- html: d && await H(d, a),
107
+ html: d && await x(d, a),
106
108
  css: F
107
109
  };
108
- r.html || (r = await O(), r.html = await H(r.html, a)), A(r.html) && (r.html = await P(r.html)), await M(r), p.selectedDynamicContentList = y;
110
+ r.html || (r = await O(), r.html = await x(r.html, a)), A(r.html) && (r.html = await P(r.html)), await M(r), p.selectedDynamicContentList = y;
109
111
  } catch (a) {
110
112
  console.error("Failed to initialize Stripo editor:", a);
111
113
  }
@@ -120,14 +122,14 @@ const We = /* @__PURE__ */ J({
120
122
  i.reset();
121
123
  }), z({
122
124
  dynamicContent: {
123
- insert: N,
124
- close: R
125
+ insert: B,
126
+ close: N
125
127
  },
126
128
  hasChanges: m,
127
129
  saveSilent: D
128
- }), { __sfc: !0, PreviewContainer: q, OnboardingWrapper: K, headerWrapperRef: w, wrapperRef: u, dynamicContentStore: p, unsubscribeStore: E, props: g, configStore: i, editorStore: f, previewStore: V, hasChanges: m, isTestPartner: $, saveSilent: D, templateId: v, userId: C, partnerName: T, username: k, templateConfig: o, editorConfig: s, html: d, css: F, preselectedDynamicContentList: y, savedModulesFolderName: L, defaultModulesFolderName: U, emit: n, metadata: h, options: _, initPlugin: M, getDefaultTemplate: O, cloneTimersOnSave: P, hasTimerBlocks: A, noHeader: j, insertDynamicContent: N, closeDynamicContent: R, handleDynamicContentOpen: S, ribbonObserver: c, updateRibbonOffset: b, AutoSaveController: re, Toaster: se, FilterSelectionDrawer: ce, HeaderWrapper: ae, LoadingWrapper: ie, SaveAsTemplateDrawer: me, UnsubscribeWrapper: de };
130
+ }), { __sfc: !0, PreviewContainer: q, OnboardingWrapper: K, headerWrapperRef: w, wrapperRef: u, dynamicContentStore: p, unsubscribeStore: E, props: g, configStore: i, editorStore: f, previewStore: V, hasChanges: m, isTestPartner: $, saveSilent: D, templateId: v, userId: C, partnerName: T, username: k, templateConfig: o, editorConfig: s, html: d, css: F, preselectedDynamicContentList: y, savedModulesFolderName: L, defaultModulesFolderName: U, emit: n, metadata: h, options: _, initPlugin: M, getDefaultTemplate: O, cloneTimersOnSave: P, hasTimerBlocks: A, noHeader: j, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: S, ribbonObserver: c, updateRibbonOffset: b, AutoSaveController: ce, Toaster: ae, FilterSelectionDrawer: ie, HeaderWrapper: me, LoadingWrapper: de, SaveAsTemplateDrawer: le, UnsubscribeWrapper: ue };
129
131
  }
130
132
  });
131
133
  export {
132
- We as default
134
+ He as default
133
135
  };
@@ -0,0 +1,18 @@
1
+ import l from "./AiStatusPill.vue2.js";
2
+ /* empty css */
3
+ import e from "../../../_virtual/_plugin-vue2_normalizer.js";
4
+ var i = function() {
5
+ var s = this, t = s._self._c, a = s._self._setupProxy;
6
+ return a.showStatusPill ? t("div", { staticClass: "ai-status-pill", attrs: { "aria-live": "polite", role: "status" } }, [t("span", { staticClass: "ai-status-pill__dot" }), t("span", { staticClass: "ai-status-pill__label" }, [s._v(s._s(a.statusLabel))])]) : s._e();
7
+ }, _ = [], r = /* @__PURE__ */ e(
8
+ l,
9
+ i,
10
+ _,
11
+ !1,
12
+ null,
13
+ "dea97ab5"
14
+ );
15
+ const c = r.exports;
16
+ export {
17
+ c as default
18
+ };
@@ -0,0 +1,13 @@
1
+ import { defineComponent as e } from "vue";
2
+ import { useAiStatusStore as r } from "../../../stores/ai-status.js";
3
+ import { storeToRefs as a } from "pinia";
4
+ const f = /* @__PURE__ */ e({
5
+ __name: "AiStatusPill",
6
+ setup(i) {
7
+ const t = r(), { showStatusPill: s, statusLabel: o } = a(t);
8
+ return { __sfc: !0, aiStatus: t, showStatusPill: s, statusLabel: o };
9
+ }
10
+ });
11
+ export {
12
+ f as default
13
+ };
@@ -1,17 +1,17 @@
1
- import i from "./MiddleSlot.vue2.js";
1
+ import r from "./MiddleSlot.vue2.js";
2
2
  import s from "../../../_virtual/_plugin-vue2_normalizer.js";
3
3
  var t = function() {
4
- var r = this, e = r._self._c, o = r._self._setupProxy;
5
- return e("div", [o.editorStore.isVersionHistoryOpen ? e("div", { staticClass: "d-f" }, [e(o.VersionHistory), e(o.VersionHistoryViewOptions)], 1) : o.editorStore.isPreviewModeOpen ? e("div", { staticClass: "d-f" }, [e(o.EmailSizeIndicator), e(o.AmpToggle)], 1) : r._e(), e(o.EditorToolbar, { directives: [{ name: "show", rawName: "v-show", value: o.editorStore.isEditorToolbarVisible, expression: "editorStore.isEditorToolbarVisible" }] })], 1);
6
- }, n = [], a = /* @__PURE__ */ s(
7
- i,
4
+ var o = this, e = o._self._c, i = o._self._setupProxy;
5
+ return e("div", { staticClass: "d-f a-i-c" }, [i.editorStore.isVersionHistoryOpen ? e("div", { staticClass: "d-f" }, [e(i.VersionHistory), e(i.VersionHistoryViewOptions)], 1) : i.editorStore.isPreviewModeOpen ? e("div", { staticClass: "d-f" }, [e(i.EmailSizeIndicator), e(i.AmpToggle)], 1) : o._e(), e(i.EditorToolbar, { directives: [{ name: "show", rawName: "v-show", value: i.editorStore.isEditorToolbarVisible, expression: "editorStore.isEditorToolbarVisible" }] }), e(i.AiStatusPill)], 1);
6
+ }, a = [], n = /* @__PURE__ */ s(
7
+ r,
8
8
  t,
9
- n,
9
+ a,
10
10
  !1,
11
11
  null,
12
12
  null
13
13
  );
14
- const c = a.exports;
14
+ const c = n.exports;
15
15
  export {
16
16
  c as default
17
17
  };
@@ -2,15 +2,16 @@ import { defineComponent as o } from "vue";
2
2
  import r from "../email-preview/amp/AmpToggle.vue.js";
3
3
  import t from "../email-preview/desktop-preview/EmailSizeIndicator.vue.js";
4
4
  import { useEditorStore as i } from "../../../stores/editor.js";
5
- import e from "./EditorToolbar.vue.js";
6
- import m from "./version-history/VersionHistory.vue.js";
7
- import p from "./version-history/ViewOptions.vue.js";
8
- const S = /* @__PURE__ */ o({
5
+ import e from "./AiStatusPill.vue.js";
6
+ import m from "./EditorToolbar.vue.js";
7
+ import p from "./version-history/VersionHistory.vue.js";
8
+ import s from "./version-history/ViewOptions.vue.js";
9
+ const V = /* @__PURE__ */ o({
9
10
  __name: "MiddleSlot",
10
- setup(s) {
11
- return { __sfc: !0, editorStore: i(), AmpToggle: r, EmailSizeIndicator: t, EditorToolbar: e, VersionHistory: m, VersionHistoryViewOptions: p };
11
+ setup(f) {
12
+ return { __sfc: !0, editorStore: i(), AmpToggle: r, EmailSizeIndicator: t, AiStatusPill: e, EditorToolbar: m, VersionHistory: p, VersionHistoryViewOptions: s };
12
13
  }
13
14
  });
14
15
  export {
15
- S as default
16
+ V as default
16
17
  };
@@ -0,0 +1,91 @@
1
+ import { useEmailTemplateApplier as _, resetEmailTemplateApplier as k } from "./useEmailTemplateApplier.js";
2
+ import { useToaster as g } from "./useToaster.js";
3
+ import { useTranslations as I } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as T } from "../enums/toaster.js";
5
+ import { useAiStatusStore as P } from "../stores/ai-status.js";
6
+ import { getActivePinia as W } from "pinia";
7
+ import { watch as B, onUnmounted as D } from "vue";
8
+ const v = "email_template", x = "chat", L = "guido:debug:ai", M = () => {
9
+ if (typeof window > "u")
10
+ return !1;
11
+ try {
12
+ return window.localStorage.getItem(L) === "1";
13
+ } catch {
14
+ return !1;
15
+ }
16
+ }, F = () => {
17
+ const u = W();
18
+ if (!u)
19
+ return;
20
+ const c = u._s, p = c == null ? void 0 : c.get(x);
21
+ if (!p)
22
+ return;
23
+ const { applyTemplate: E, applyTemplateDebounced: A } = _(), i = P(), { showToaster: f } = g(), y = I(), d = (t, r) => {
24
+ const e = y(t);
25
+ return e === t ? r : e;
26
+ }, l = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = M(), b = (t, r) => {
27
+ h && console.debug(`[guido:cortex] msg=${t ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
28
+ }, m = (t) => {
29
+ if (t.blueprintType !== v)
30
+ return;
31
+ const r = t.blueprintId, e = t.blueprintData;
32
+ if (!r || !(e != null && e.html))
33
+ return;
34
+ const n = l.get(r);
35
+ n === void 0 ? (l.set(r, e.html), E(r, e)) : n !== e.html && (l.set(r, e.html), A(r, e));
36
+ }, S = (t) => {
37
+ const r = t.toolCallId ?? "?", e = t.isRunning ? "run" : "done", n = t.error ? "err" : "ok", o = `tool:${r}:${e}:${n}`;
38
+ if (!s.has(o)) {
39
+ if (s.add(o), t.error === !0) {
40
+ i.$patch({ isWorking: !1, currentTool: "", lastError: "tool_error" });
41
+ return;
42
+ }
43
+ t.isRunning === !0 ? i.$patch({
44
+ isWorking: !0,
45
+ currentTool: t.name ?? "",
46
+ lastError: ""
47
+ }) : i.$patch({ isWorking: !1, currentTool: "" });
48
+ }
49
+ }, w = (t, r) => {
50
+ r && a.has(r) || (r && a.add(r), i.$patch({ isWorking: !1, currentTool: "", lastError: t.content ?? "error" }), f({
51
+ type: T.Alert,
52
+ message: d("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
53
+ }));
54
+ }, $ = B(
55
+ () => p.messages,
56
+ (t) => {
57
+ Array.isArray(t) && t.forEach((r) => {
58
+ const e = r == null ? void 0 : r.id;
59
+ (r == null ? void 0 : r.isError) === !0 && e && !a.has(e) && (a.add(e), i.$patch({ isWorking: !1, currentTool: "", lastError: "message_error" }), f({
60
+ type: T.Alert,
61
+ message: d(
62
+ "newsletter.ai-template-failed",
63
+ "AI couldn't generate the template. Please try again."
64
+ )
65
+ }), h && console.debug(`[guido:cortex] message-level error id=${e}`, r));
66
+ const n = r == null ? void 0 : r.segments;
67
+ Array.isArray(n) && n.forEach((o) => {
68
+ if (o)
69
+ switch (b(e, o), o.type) {
70
+ case "blueprint":
71
+ m(o);
72
+ break;
73
+ case "tool":
74
+ S(o);
75
+ break;
76
+ case "error":
77
+ w(o, e);
78
+ break;
79
+ }
80
+ });
81
+ });
82
+ },
83
+ { deep: !0, immediate: !0 }
84
+ );
85
+ D(() => {
86
+ $(), l.clear(), s.clear(), a.clear(), i.$patch({ isWorking: !1, currentTool: "", lastError: "" }), k();
87
+ });
88
+ };
89
+ export {
90
+ F as useCortexBlueprintBridge
91
+ };
@@ -0,0 +1,41 @@
1
+ import { useActionsApi as u } from "./useActionsApi.js";
2
+ import { useToaster as T } from "./useToaster.js";
3
+ import { useTranslations as f } from "./useTranslations.js";
4
+ import { ToasterTypeOptions as n } from "../enums/toaster.js";
5
+ import { ref as y } from "vue";
6
+ const h = 250, s = y({}), o = {}, j = () => {
7
+ const { updateHtmlAndCss: l } = u(), { showToaster: r } = T(), i = f(), c = (e, t, p) => {
8
+ s.value = { ...s.value, [e]: "applying" };
9
+ try {
10
+ l(t, p), s.value = { ...s.value, [e]: "applied" }, r({
11
+ type: n.Success,
12
+ message: i("newsletter.ai-template-applied")
13
+ });
14
+ } catch (a) {
15
+ s.value = { ...s.value, [e]: "failed" }, r({
16
+ type: n.Alert,
17
+ message: a instanceof Error ? a.message : "Failed to apply template"
18
+ });
19
+ }
20
+ }, m = (e) => {
21
+ const t = o[e];
22
+ t && (clearTimeout(t), delete o[e]);
23
+ };
24
+ return { applyStatus: s, applyTemplate: (e, t) => {
25
+ t.html && (m(e), c(e, t.html, t.css ?? ""));
26
+ }, applyTemplateDebounced: (e, t) => {
27
+ if (!t.html)
28
+ return;
29
+ m(e);
30
+ const { html: p } = t, a = t.css ?? "";
31
+ o[e] = setTimeout(() => {
32
+ delete o[e], c(e, p, a);
33
+ }, h);
34
+ } };
35
+ }, w = () => {
36
+ Object.values(o).forEach(clearTimeout), Object.keys(o).forEach((l) => delete o[l]), s.value = {};
37
+ };
38
+ export {
39
+ w as resetEmailTemplateApplier,
40
+ j as useEmailTemplateApplier
41
+ };
@@ -0,0 +1,48 @@
1
+ import { useActionsApi as g } from "./useActionsApi.js";
2
+ import { useConfigStore as I } from "../stores/config.js";
3
+ import { useEditorStore as b } from "../stores/editor.js";
4
+ import { useGuidoEmailEditorStore as E } from "../stores/guido-email-editor.js";
5
+ import { watch as c, onUnmounted as T } from "vue";
6
+ const w = 500, z = () => {
7
+ const i = b(), a = E(), l = I(), { getTemplateData: m } = g();
8
+ let e = null, n = !1;
9
+ const r = () => {
10
+ e && (clearTimeout(e), e = null);
11
+ }, s = async () => {
12
+ var t, o;
13
+ if (!(n || !i.isStripoInitialized))
14
+ try {
15
+ const { html: f, css: h } = await m(), S = ((o = (t = l.config) == null ? void 0 : t.identity) == null ? void 0 : o.templateId) ?? "";
16
+ if (n)
17
+ return;
18
+ a.$patch({
19
+ html: f ?? "",
20
+ css: h ?? "",
21
+ templateId: S,
22
+ lastUpdatedAt: Date.now()
23
+ });
24
+ } catch {
25
+ }
26
+ }, u = () => {
27
+ r(), e = setTimeout(() => {
28
+ e = null, s();
29
+ }, w);
30
+ }, d = c(
31
+ () => i.isStripoInitialized,
32
+ (t) => {
33
+ t && s();
34
+ },
35
+ { immediate: !0 }
36
+ ), p = c(
37
+ () => i.hasChanges,
38
+ (t, o) => {
39
+ i.isStripoInitialized && (t ? u() : o && (r(), s()));
40
+ }
41
+ );
42
+ T(() => {
43
+ n = !0, r(), d(), p();
44
+ });
45
+ };
46
+ export {
47
+ z as useGuidoStateBridge
48
+ };
@@ -1,37 +1,35 @@
1
- import { useConfig as _ } from "./useConfig.js";
2
- import { TemplateTypes as H } from "../enums/defaults.js";
3
- import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
1
+ import { useConfig as L } from "./useConfig.js";
2
+ import { TemplateTypes as V } from "../enums/defaults.js";
3
+ import { DISPLAY_CONDITIONS_REGEX as _, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as H, CampaignCouldNotBeSavedKey as P, CanNotMakeAnyChangesForRunningKey as G } from "../enums/html-validator.js";
4
4
  import { ToasterTypeOptions as c } from "../enums/toaster.js";
5
- import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
6
- import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
7
- import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
8
- import { useRecommendationStore as K } from "../stores/recommendation.js";
9
- import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
10
- import { useHttp as U } from "./useHttp.js";
11
- import { useToaster as Y } from "./useToaster.js";
12
- import { useTranslations as Z } from "./useTranslations.js";
13
- const J = /recommendation-id="(\d+)"/g;
14
- function Q(a) {
15
- return [...a.matchAll(J)].map((u) => u[1]);
5
+ import { itemsBlockDynamicVariables as M } from "../extensions/Blocks/Items/enums/productEnums.js";
6
+ import { useRecommendationStore as $ } from "../stores/recommendation.js";
7
+ import { base64EncodeWithSpecialChars as X } from "../utils/base64.js";
8
+ import { useHttp as j } from "./useHttp.js";
9
+ import { useToaster as q } from "./useToaster.js";
10
+ import { useTranslations as z } from "./useTranslations.js";
11
+ const K = /recommendation-id="(\d+)"/g;
12
+ function U(a) {
13
+ return [...a.matchAll(K)].map((u) => u[1]);
16
14
  }
17
- function ee(a, u) {
15
+ function Y(a, u) {
18
16
  return u.some((d) => a.startsWith(`${d}_`));
19
17
  }
20
- const ge = () => {
18
+ const ce = () => {
21
19
  var y, h;
22
- const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
20
+ const { showToaster: a } = q(), { post: u } = j(), { config: d } = L(), r = z(), g = $(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === V.transactional, b = async (e) => {
23
21
  const t = await u(
24
22
  "/newsletter/template-library/check-template-html-body",
25
- { html: z(e) }
23
+ { html: X(e) }
26
24
  ), { status: n, message: l } = t.data;
27
25
  return n || a({
28
26
  type: c.Alert,
29
27
  message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
30
- }), r(M), l === r($) && a({
28
+ }), r(P), l === r(G) && a({
31
29
  type: c.Alert,
32
30
  message: r("newsletter.already-in-progress")
33
31
  }), n;
34
- }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
32
+ }, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), S = (e) => ["if", "endif"].includes(e.toLowerCase()), E = (e, s) => {
35
33
  const t = e.match(/({%(.*?)%})/g);
36
34
  let n = !0;
37
35
  return t !== null && !p && t.forEach((l) => {
@@ -44,13 +42,13 @@ const ge = () => {
44
42
  }), n = !1);
45
43
  }
46
44
  }), n;
47
- }, k = async (e, s, t) => {
45
+ }, A = async (e, s, t) => {
48
46
  const n = t ? await b(e) : !0;
49
- return A(e, s) && n;
50
- }, x = (e) => e.length > 0 ? !0 : (a({
47
+ return E(e, s) && n;
48
+ }, I = (e) => e.length > 0 ? !0 : (a({
51
49
  type: c.Warning,
52
50
  message: r("newsletter.html-content-is-empty")
53
- }), !1), I = (e) => {
51
+ }), !1), k = (e) => {
54
52
  const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
55
53
  return s > t && a({
56
54
  type: c.Warning,
@@ -59,7 +57,7 @@ const ge = () => {
59
57
  type: c.Warning,
60
58
  message: r("custom-fields.missing-opening-braces")
61
59
  }), s === t;
62
- }, F = (e) => {
60
+ }, x = (e) => {
63
61
  const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
64
62
  return s || a({
65
63
  type: c.Warning,
@@ -68,10 +66,10 @@ const ge = () => {
68
66
  }, T = (e, s) => {
69
67
  const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
70
68
  if (t && !p) {
71
- const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
69
+ const n = new Set(s.map((i) => i.toLowerCase())), l = U(e), o = [];
72
70
  if (t.forEach((i) => {
73
71
  const m = i.slice(2, -2).trim().toLowerCase();
74
- (!n.has(m) || m === "") && !ee(m, l) && o.push(m);
72
+ (!n.has(m) || m === "") && !Y(m, l) && o.push(m);
75
73
  }), o.length > 0) {
76
74
  const i = `
77
75
  <ul>
@@ -85,11 +83,11 @@ const ge = () => {
85
83
  }
86
84
  }
87
85
  return !0;
88
- }, R = (e) => {
86
+ }, F = (e) => {
89
87
  const s = e.match(/{%(.*?)%}/g), t = [];
90
88
  let n = !0;
91
89
  if (s && s.forEach((l) => {
92
- const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
90
+ const o = l.match(_), i = l.match(H), m = (o == null ? void 0 : o.join("")) || "";
93
91
  (!o || l !== m) && !i && (a({
94
92
  type: c.Alert,
95
93
  message: r("newsletter.display-conditions-invalid-syntax")
@@ -100,7 +98,7 @@ const ge = () => {
100
98
  }), n = !1);
101
99
  const v = f.match(/^[a-zA-Z]*$/g);
102
100
  v && v.forEach((C) => {
103
- E(C) && t.push(C);
101
+ S(C) && t.push(C);
104
102
  });
105
103
  });
106
104
  }), t.length) {
@@ -111,28 +109,25 @@ const ge = () => {
111
109
  }), n = !1);
112
110
  }
113
111
  return n;
114
- }, B = (e) => {
112
+ }, W = (e) => {
115
113
  const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
116
114
  return n || a({
117
115
  type: c.Warning,
118
116
  message: r("custom-conditions.no-space-after-braces")
119
117
  }), n;
120
- }, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
118
+ }, N = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
121
119
  type: c.Warning,
122
120
  message: r("custom-conditions.no-braces-inside-if-tag")
123
- }), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
124
- type: c.Alert,
125
- message: r(j)
126
121
  }), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
127
122
  type: c.Alert,
128
123
  message: r("newsletter.fill-all-necessary-fields")
129
- }), !1) : !0, D = (e) => {
124
+ }), !1) : !0, B = (e) => {
130
125
  const s = /src="[^"]*\.(svg|pst)"/gm;
131
126
  return e.match(s) === null ? !0 : (a({
132
127
  type: c.Alert,
133
128
  message: r("newsletter.invalid-image-type")
134
129
  }), !1);
135
- }, L = (e) => {
130
+ }, R = (e) => {
136
131
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
137
132
  return Array.from(n).find((o) => {
138
133
  var i;
@@ -141,7 +136,7 @@ const ge = () => {
141
136
  type: c.Alert,
142
137
  message: r("unsubscribe-templates.select-checkbox-groups")
143
138
  }), !1) : !0;
144
- }, V = (e) => {
139
+ }, D = (e) => {
145
140
  const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
146
141
  return Array.from(n).find((o) => {
147
142
  var i;
@@ -155,12 +150,12 @@ const ge = () => {
155
150
  var o, i;
156
151
  const n = [
157
152
  ...s.map((m) => m.value),
158
- ...q,
153
+ ...M,
159
154
  ...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
160
155
  ];
161
- return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
156
+ return await A(e, n, t) && I(e) && k(e) && x(e) && T(e, n) && F(e) && W(e) && N(e) && O() && B(e) && R(e) && D(e);
162
157
  } };
163
158
  };
164
159
  export {
165
- ge as useHtmlValidator
160
+ ce as useHtmlValidator
166
161
  };
@@ -1,4 +1,4 @@
1
- import { getRecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
1
+ import { RecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
2
2
  import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
3
3
  import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
4
  import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
@@ -63,7 +63,7 @@ const w = () => ({
63
63
  shuffleProducts: o.shuffleProducts
64
64
  };
65
65
  }
66
- const f = ((l = I().find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
66
+ const f = ((l = I.find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
67
67
  if (t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising") {
68
68
  const i = parseInt(e.size) || 6;
69
69
  t.set("productId", e.productIds.slice(0, i).join(","));