@useinsider/guido 3.19.0-beta.f05f865 → 3.19.0-beta.f10986f
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.
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +60 -54
- package/dist/composables/useAutoSave.js +11 -11
- package/dist/composables/useCortexBlueprintBridge.js +122 -54
- package/dist/composables/useEmailTemplateApplier.js +111 -50
- package/dist/config/migrator/itemsBlockMigrator.js +236 -248
- package/dist/config/migrator/recommendationMigrator.js +28 -21
- package/dist/config/migrator/recommendationPartnerMigrator.js +36 -30
- package/dist/extensions/Blocks/Items/constants/cardLayout.js +20 -0
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +18 -17
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +114 -105
- package/dist/extensions/Blocks/Items/enums/productEnums.js +14 -9
- package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +11 -9
- package/dist/extensions/Blocks/Items/template.js +219 -204
- package/dist/extensions/Blocks/Recommendation/utils/partnerCustomizations.js +3 -1
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +2 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +18 -5
- package/dist/src/composables/useGuidoActions.d.ts +2 -0
- package/dist/src/extensions/Blocks/Items/constants/cardLayout.d.ts +44 -0
- package/dist/src/extensions/Blocks/Items/enums/productEnums.d.ts +3 -0
- package/dist/src/extensions/Blocks/Items/template.d.ts +19 -0
- package/dist/src/mock/cortexChatStore.d.ts +12 -0
- package/dist/src/stores/guido-email-editor.d.ts +20 -10
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/recommendation.d.ts +5 -0
- package/dist/src/utils/dateUtil.d.ts +10 -0
- package/dist/src/utils/genericUtil.d.ts +3 -0
- package/dist/static/styles/components/version-history.css.js +2 -6
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +4 -0
- package/dist/utils/pairProductVariables.js +71 -71
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent as se, defineAsyncComponent as m, ref as
|
|
1
|
+
import { defineComponent as se, defineAsyncComponent as m, ref as W, computed as p, watch as G, onMounted as ie, onUnmounted as ce } from "vue";
|
|
2
2
|
import { useCortexBlueprintBridge as de } from "../composables/useCortexBlueprintBridge.js";
|
|
3
3
|
import { useEditorLock as me } from "../composables/useEditorLock.js";
|
|
4
4
|
import { provideGuidoActions as le } from "../composables/useGuidoActions.js";
|
|
@@ -7,10 +7,10 @@ import { usePartner as pe } from "../composables/usePartner.js";
|
|
|
7
7
|
import { useSaveValidationRollout as fe } from "../composables/useSaveValidationRollout.js";
|
|
8
8
|
import { useStripo as ye } from "../composables/useStripo.js";
|
|
9
9
|
import { useTimerClone as ge } from "../composables/useTimerClone.js";
|
|
10
|
-
import { migrate as
|
|
11
|
-
import { ModuleFolderDefaults as
|
|
10
|
+
import { migrate as V } from "../config/migrator/index.js";
|
|
11
|
+
import { ModuleFolderDefaults as $ } from "../enums/defaults.js";
|
|
12
12
|
import { RIBBON_SELECTOR as Se } from "../enums/onboarding.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
13
|
+
import { useRecommendationExtensionStore as E } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
14
14
|
import ve from "./organisms/AutoSaveController.vue.js";
|
|
15
15
|
import be from "./organisms/base/AuthErrorModal.vue.js";
|
|
16
16
|
import he from "./organisms/base/Toaster.vue.js";
|
|
@@ -19,16 +19,16 @@ import we from "./organisms/header/HeaderWrapper.vue.js";
|
|
|
19
19
|
import De from "./organisms/LoadingWrapper.vue.js";
|
|
20
20
|
import Ce from "./organisms/save-as-template/SaveAsTemplateDrawer.vue.js";
|
|
21
21
|
import ke from "./organisms/unsubscribe/UnsubscribeWrapper.vue.js";
|
|
22
|
-
import
|
|
23
|
-
import { useStripoApi as
|
|
22
|
+
import Fe from "./organisms/validation/ValidationErrorDrawer.vue.js";
|
|
23
|
+
import { useStripoApi as Re } from "../services/stripoApi.js";
|
|
24
24
|
import { useConfigStore as Me } from "../stores/config.js";
|
|
25
25
|
import { useDynamicContentStore as Te } from "../stores/dynamic-content.js";
|
|
26
|
-
import { useEditorStore as
|
|
26
|
+
import { useEditorStore as w } from "../stores/editor.js";
|
|
27
27
|
import { usePreviewStore as Ie } from "../stores/preview.js";
|
|
28
28
|
import { useSaveValidationStore as Le } from "../stores/save-validation.js";
|
|
29
29
|
import { useTemplateStore as Ue } from "../stores/template.js";
|
|
30
30
|
import { useUnsubscribeStore as Ae } from "../stores/unsubscribe.js";
|
|
31
|
-
import { readTrackFloor as
|
|
31
|
+
import { readTrackFloor as z } from "../utils/linkTrackingIds.js";
|
|
32
32
|
const lt = /* @__PURE__ */ se({
|
|
33
33
|
__name: "Guido",
|
|
34
34
|
props: {
|
|
@@ -36,8 +36,8 @@ const lt = /* @__PURE__ */ se({
|
|
|
36
36
|
ready: { type: Boolean, default: !0 }
|
|
37
37
|
},
|
|
38
38
|
emits: ["dynamic-content:open", "back", "save:start", "save:complete", "on-change", "ready", "onboarding:finished", "test-email:click"],
|
|
39
|
-
setup(
|
|
40
|
-
const s =
|
|
39
|
+
setup(H, { expose: q, emit: r }) {
|
|
40
|
+
const s = H, K = m(
|
|
41
41
|
() => import("./organisms/email-preview/PreviewContainer.vue.js")
|
|
42
42
|
), j = m(
|
|
43
43
|
() => import("./organisms/onboarding/OnboardingWrapper.vue.js")
|
|
@@ -47,32 +47,32 @@ const lt = /* @__PURE__ */ se({
|
|
|
47
47
|
() => import("./organisms/extensions/recommendation/RemoveStrategyModal.vue.js")
|
|
48
48
|
), X = m(
|
|
49
49
|
() => import("./organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js")
|
|
50
|
-
),
|
|
50
|
+
), D = W(), f = W(), y = Te(), C = Ae(), o = Me();
|
|
51
51
|
s.ready && o.init(s.config);
|
|
52
|
-
const c =
|
|
52
|
+
const c = w(), Y = Ie(), l = p(() => c.hasChanges), { isTestPartner: Z } = pe(), { isEnabled: ee } = fe(), k = () => {
|
|
53
53
|
var t;
|
|
54
|
-
return (t =
|
|
55
|
-
},
|
|
54
|
+
return (t = D.value) == null ? void 0 : t.handleSave(!0);
|
|
55
|
+
}, F = (t) => {
|
|
56
56
|
c.loadingStatus = t;
|
|
57
57
|
};
|
|
58
58
|
de(), ue();
|
|
59
|
-
const
|
|
59
|
+
const g = () => {
|
|
60
60
|
var t, e;
|
|
61
61
|
return {
|
|
62
62
|
emailId: o.templateId,
|
|
63
63
|
userId: o.userId,
|
|
64
64
|
username: o.username,
|
|
65
65
|
partnerName: o.partnerName,
|
|
66
|
-
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) ||
|
|
67
|
-
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) ||
|
|
66
|
+
savedModulesFolderName: ((t = o.editor) == null ? void 0 : t.savedModulesFolderName) || $.SAVED_MODULES,
|
|
67
|
+
defaultModulesFolderName: ((e = o.editor) == null ? void 0 : e.defaultModulesFolderName) || $.DEFAULT_MODULES
|
|
68
68
|
};
|
|
69
|
-
}, { initPlugin:
|
|
70
|
-
let
|
|
71
|
-
const { getDefaultTemplate:
|
|
69
|
+
}, { initPlugin: R, preloadRuntime: M } = ye(), { runExclusive: T, beginMount: I, isCurrentMount: S } = me();
|
|
70
|
+
let u = 0;
|
|
71
|
+
const { getDefaultTemplate: L } = Re(), { cloneTimersOnSave: U, hasTimerBlocks: A } = ge(), te = p(() => {
|
|
72
72
|
var t;
|
|
73
73
|
return !((t = o.ui) != null && t.showHeader);
|
|
74
|
-
}), oe =
|
|
75
|
-
() => !!
|
|
74
|
+
}), oe = p(() => o.isFeatureEnabled("reusableRecommendationStrategy")), ne = p(
|
|
75
|
+
() => !!E().recommendationConfigs.strategyId
|
|
76
76
|
);
|
|
77
77
|
le({
|
|
78
78
|
onBack: () => {
|
|
@@ -82,74 +82,80 @@ const lt = /* @__PURE__ */ se({
|
|
|
82
82
|
console.debug("guido:save:start"), r("save:start");
|
|
83
83
|
},
|
|
84
84
|
onSaveComplete: (t) => {
|
|
85
|
-
const e = { ...t, metadata:
|
|
85
|
+
const e = { ...t, metadata: g() };
|
|
86
86
|
console.debug("guido:save:complete", e), r("save:complete", e);
|
|
87
87
|
},
|
|
88
88
|
onTestEmailClick: () => {
|
|
89
89
|
console.debug("guido:test-email:click"), r("test-email:click");
|
|
90
90
|
}
|
|
91
91
|
});
|
|
92
|
-
const
|
|
93
|
-
console.debug("dynamic-content:close", t),
|
|
94
|
-
},
|
|
92
|
+
const B = (t) => {
|
|
93
|
+
console.debug("dynamic-content:close", t), y.setSelectedDynamicContent(t), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: t }));
|
|
94
|
+
}, N = () => {
|
|
95
95
|
console.debug("dynamic-content:close", "Without Data"), document.dispatchEvent(new CustomEvent("dynamic-content:close", { detail: { text: "", value: "" } }));
|
|
96
96
|
};
|
|
97
|
-
|
|
97
|
+
G(() => l.value, () => {
|
|
98
98
|
r("on-change", l.value);
|
|
99
99
|
});
|
|
100
|
-
const
|
|
100
|
+
const v = (t) => {
|
|
101
101
|
const e = t, { attribute: a, position: d } = e.detail;
|
|
102
102
|
console.debug("dynamic-content:open", e.detail), r("dynamic-content:open", a, d);
|
|
103
103
|
};
|
|
104
104
|
let i = null;
|
|
105
|
-
const
|
|
105
|
+
const b = () => {
|
|
106
106
|
var e;
|
|
107
107
|
const t = document.querySelector(Se);
|
|
108
|
-
(e =
|
|
109
|
-
},
|
|
108
|
+
(e = f.value) == null || e.style.setProperty("--ribbon-offset", `${(t == null ? void 0 : t.offsetHeight) ?? 0}px`);
|
|
109
|
+
}, h = async () => {
|
|
110
110
|
var t;
|
|
111
111
|
try {
|
|
112
112
|
o.initialized || o.init(s.config), c.templateId = o.templateId;
|
|
113
|
-
const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "",
|
|
114
|
-
|
|
115
|
-
const
|
|
113
|
+
const e = o.template, a = (e == null ? void 0 : e.html) || "", d = (e == null ? void 0 : e.css) || "", P = (e == null ? void 0 : e.preselectedDynamicContent) || [];
|
|
114
|
+
C.selectedUnsubscribePages = (e == null ? void 0 : e.selectedUnsubscribePages) || [];
|
|
115
|
+
const _ = ((t = e == null ? void 0 : e.migration) == null ? void 0 : t.recommendationConfigs) ?? {}, O = o.isFeatureEnabled("linkTrackingIds"), x = {
|
|
116
116
|
partnerName: o.partnerName,
|
|
117
117
|
campaignUrls: e == null ? void 0 : e.recommendationCampaignUrls,
|
|
118
118
|
rrsEnabled: o.isFeatureEnabled("reusableRecommendationStrategy")
|
|
119
119
|
};
|
|
120
120
|
let n = {
|
|
121
|
-
html: a && await
|
|
121
|
+
html: a && await V(a, _, x),
|
|
122
122
|
css: d
|
|
123
123
|
};
|
|
124
|
-
n.html || (n = await
|
|
125
|
-
const re =
|
|
126
|
-
|
|
124
|
+
n.html || (n = await L(), n.html = await V(n.html, _, x));
|
|
125
|
+
const re = O ? z(n.html, (e == null ? void 0 : e.trackIdCounter) || 0) : 0;
|
|
126
|
+
A(n.html) && (n.html = await U(n.html)), O && (c.trackIdSessionFloor = Math.max(re, z(n.html)));
|
|
127
127
|
const ae = {
|
|
128
|
-
preselectedDynamicContentList:
|
|
128
|
+
preselectedDynamicContentList: P,
|
|
129
129
|
onReady: () => {
|
|
130
130
|
console.debug("guido:ready"), r("ready");
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
|
-
|
|
133
|
+
u = I(), await R(n, g(), ae), y.selectedDynamicContentList = P;
|
|
134
134
|
} catch (e) {
|
|
135
135
|
console.error("Failed to initialize Stripo editor:", e);
|
|
136
136
|
}
|
|
137
137
|
};
|
|
138
138
|
return ie(async () => {
|
|
139
139
|
var e;
|
|
140
|
-
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"),
|
|
141
|
-
const t = (e =
|
|
142
|
-
if (t && (i = new ResizeObserver(
|
|
143
|
-
await
|
|
140
|
+
console.debug("Guido says happy coding 🎉"), console.debug("🚗 Ka-Chow"), E().$reset(), w().$reset(), Ue().$reset(), Le().$reset(), b();
|
|
141
|
+
const t = (e = f.value) == null ? void 0 : e.parentElement;
|
|
142
|
+
if (t && (i = new ResizeObserver(b), i.observe(t)), M(), s.ready)
|
|
143
|
+
await h();
|
|
144
144
|
else {
|
|
145
|
-
const a =
|
|
146
|
-
d && (a(),
|
|
145
|
+
const a = G(() => s.ready, (d) => {
|
|
146
|
+
d && (a(), h());
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
|
-
document.addEventListener("dynamic-content:open",
|
|
149
|
+
document.addEventListener("dynamic-content:open", v);
|
|
150
150
|
}), ce(() => {
|
|
151
|
-
i == null || i.disconnect(), document.removeEventListener("dynamic-content:open",
|
|
152
|
-
|
|
151
|
+
if (i == null || i.disconnect(), document.removeEventListener("dynamic-content:open", v), E().disposeStrategyPageReturn(), S(u))
|
|
152
|
+
try {
|
|
153
|
+
w().isStripoInitialized = !1;
|
|
154
|
+
} catch (t) {
|
|
155
|
+
console.debug("Failed to close the editor readiness gate on unmount", t);
|
|
156
|
+
}
|
|
157
|
+
T(async () => {
|
|
158
|
+
if (S(u))
|
|
153
159
|
try {
|
|
154
160
|
window.UIEditor.removeEditor();
|
|
155
161
|
} catch {
|
|
@@ -158,13 +164,13 @@ const lt = /* @__PURE__ */ se({
|
|
|
158
164
|
}), o.reset();
|
|
159
165
|
}), q({
|
|
160
166
|
dynamicContent: {
|
|
161
|
-
insert:
|
|
162
|
-
close:
|
|
167
|
+
insert: B,
|
|
168
|
+
close: N
|
|
163
169
|
},
|
|
164
170
|
hasChanges: l,
|
|
165
|
-
saveSilent:
|
|
166
|
-
setLoading:
|
|
167
|
-
}), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef:
|
|
171
|
+
saveSilent: k,
|
|
172
|
+
setLoading: F
|
|
173
|
+
}), { __sfc: !0, PreviewContainer: K, OnboardingWrapper: j, AssignStrategyDrawer: J, RemoveStrategyModal: Q, LegacyStrategyUpdatedModal: X, headerWrapperRef: D, wrapperRef: f, dynamicContentStore: y, unsubscribeStore: C, props: s, configStore: o, editorStore: c, previewStore: Y, hasChanges: l, isTestPartner: Z, isSaveValidationEnabled: ee, saveSilent: k, setLoading: F, emit: r, buildMetadata: g, initPlugin: R, preloadRuntime: M, runExclusive: T, beginMount: I, isCurrentMount: S, mountGeneration: u, getDefaultTemplate: L, cloneTimersOnSave: U, hasTimerBlocks: A, noHeader: te, isRrsEnabled: oe, hasAssignedStrategy: ne, insertDynamicContent: B, closeDynamicContent: N, handleDynamicContentOpen: v, ribbonObserver: i, updateRibbonOffset: b, startEditor: h, AutoSaveController: ve, AuthErrorModal: be, Toaster: he, FilterSelectionDrawer: Ee, HeaderWrapper: we, LoadingWrapper: De, SaveAsTemplateDrawer: Ce, UnsubscribeWrapper: ke, ValidationErrorDrawer: Fe };
|
|
168
174
|
}
|
|
169
175
|
});
|
|
170
176
|
export {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useConfig as E } from "./useConfig.js";
|
|
2
|
-
import { useEditorLock as
|
|
3
|
-
import { useAutosaveStore as
|
|
4
|
-
import { useEditorStore as
|
|
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
5
|
import { computed as y, watch as I, onUnmounted as L } from "vue";
|
|
6
6
|
const w = 18e4, v = 6e4, R = (b) => {
|
|
7
|
-
const { isFeatureEnabled: S } = E(), o =
|
|
7
|
+
const { isFeatureEnabled: S } = E(), o = A(), t = p(), { isEditorBusy: g } = f();
|
|
8
8
|
let i = null, c = 0;
|
|
9
9
|
const u = y(
|
|
10
10
|
() => S("autosave") && t.isOn
|
|
11
11
|
), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
|
|
12
12
|
hasChanges: o.hasChanges,
|
|
13
13
|
isInSaveableState: o.isInSaveableState
|
|
14
|
-
}),
|
|
14
|
+
}), l = async (e) => {
|
|
15
15
|
if (!u.value) {
|
|
16
16
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
|
|
17
17
|
return;
|
|
@@ -28,7 +28,7 @@ const w = 18e4, v = 6e4, R = (b) => {
|
|
|
28
28
|
console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
31
|
+
e === "visibility" && (c = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
|
|
32
32
|
try {
|
|
33
33
|
if (await b() === void 0) {
|
|
34
34
|
console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
|
|
@@ -53,22 +53,22 @@ const w = 18e4, v = 6e4, R = (b) => {
|
|
|
53
53
|
});
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
l("visibility");
|
|
57
57
|
}, d = () => {
|
|
58
58
|
i && (clearInterval(i), i = null);
|
|
59
|
-
},
|
|
59
|
+
}, r = () => {
|
|
60
60
|
document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
|
|
61
61
|
};
|
|
62
62
|
I(
|
|
63
63
|
u,
|
|
64
64
|
(e) => {
|
|
65
65
|
console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
|
|
66
|
-
console.debug("guido:autosave:interval-tick"),
|
|
67
|
-
}, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(),
|
|
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);
|
|
68
68
|
},
|
|
69
69
|
{ immediate: !0 }
|
|
70
70
|
), L(() => {
|
|
71
|
-
d(),
|
|
71
|
+
d(), r(), t.status = s.IDLE, t.lastSavedAt = null;
|
|
72
72
|
});
|
|
73
73
|
};
|
|
74
74
|
export {
|
|
@@ -1,70 +1,138 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
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(
|
|
14
|
+
return window.localStorage.getItem(ot) === "1";
|
|
12
15
|
} catch {
|
|
13
16
|
return !1;
|
|
14
17
|
}
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
+
}, bt = () => {
|
|
19
|
+
const b = k();
|
|
20
|
+
if (!b)
|
|
18
21
|
return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
|
31
|
-
if (!
|
|
64
|
+
const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
|
|
65
|
+
if (!r || !n)
|
|
32
66
|
return;
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
Array.isArray(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
137
|
+
bt as useCortexBlueprintBridge
|
|
70
138
|
};
|