@useinsider/guido 3.19.0-beta.2854f4f → 3.19.0-beta.4b9be3a
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/components/organisms/base/Toaster.vue2.js +12 -13
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +11 -13
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +57 -74
- package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +37 -23
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +18 -20
- package/dist/composables/useActionsApi.js +24 -20
- package/dist/composables/useCortexBlueprintBridge.js +120 -54
- package/dist/composables/useCustomInterfaceAppearance.js +46 -56
- package/dist/composables/useEmailTemplateApplier.js +96 -51
- package/dist/composables/useHtmlValidator.js +82 -87
- package/dist/composables/useRecommendation.js +35 -40
- package/dist/composables/useStripo.js +30 -30
- package/dist/composables/useToaster.js +20 -14
- package/dist/enums/extensions/recommendationBlock.js +31 -38
- package/dist/extensions/Blocks/Recommendation/block.js +42 -61
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +20 -21
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +35 -40
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +52 -84
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +74 -74
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +140 -260
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +16 -26
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +12 -21
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +4 -3
- package/dist/src/composables/useEmailTemplateApplier.d.ts +26 -5
- package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -10
- package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -9
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +2 -7
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -86
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +0 -4
- package/dist/src/stores/guido-email-editor.d.ts +32 -10
- package/dist/src/stores/onboarding.d.ts +0 -377
- package/dist/static/styles/components/recommendation-strategy.css.js +4 -34
- package/dist/stores/guido-email-editor.js +3 -1
- package/dist/stores/onboarding.js +36 -41
- package/dist/utils/templatePreparation.js +55 -55
- package/package.json +1 -1
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +0 -21
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +0 -47
- package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +0 -24
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/utils/strategyCommit.d.ts +0 -14
- package/dist/static/styles/components/skeleton.css.js +0 -23
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { filterAmpErrors as v } from "../utils/ampErrorFilter.js";
|
|
2
2
|
import { useToaster as y } from "./useToaster.js";
|
|
3
|
-
const D = 1e4,
|
|
4
|
-
const
|
|
5
|
-
() =>
|
|
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`)),
|
|
6
6
|
l
|
|
7
|
-
),
|
|
8
|
-
clearTimeout(
|
|
7
|
+
), d = (r) => (t) => {
|
|
8
|
+
clearTimeout(c), r(t);
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
try {
|
|
11
|
+
w(d(A), d(s));
|
|
12
|
+
} catch (r) {
|
|
13
|
+
clearTimeout(c), s(r instanceof Error ? r : new Error(String(r)));
|
|
14
|
+
}
|
|
11
15
|
}), I = () => {
|
|
12
|
-
const { handleError: n } = y(), l = (t = {}) =>
|
|
16
|
+
const { handleError: n } = y(), l = (t = {}) => p(
|
|
13
17
|
"compileEmail",
|
|
14
|
-
|
|
18
|
+
T,
|
|
15
19
|
(e, a) => {
|
|
16
20
|
const o = { ...{
|
|
17
21
|
minimize: !0,
|
|
@@ -32,9 +36,9 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
32
36
|
forceAmp: !1,
|
|
33
37
|
resetDataSavedFlag: !1,
|
|
34
38
|
disableLineHeightsReplace: !0
|
|
35
|
-
}, ...t },
|
|
36
|
-
callback: (
|
|
37
|
-
|
|
39
|
+
}, ...t }, u = {
|
|
40
|
+
callback: (m, C, f, S, g) => {
|
|
41
|
+
m ? a(m) : e({
|
|
38
42
|
html: C,
|
|
39
43
|
ampHtml: f,
|
|
40
44
|
ampErrors: v(S ?? []),
|
|
@@ -43,22 +47,22 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
43
47
|
},
|
|
44
48
|
...o
|
|
45
49
|
};
|
|
46
|
-
window.StripoEditorApi.actionsApi.compileEmail(
|
|
50
|
+
window.StripoEditorApi.actionsApi.compileEmail(u);
|
|
47
51
|
}
|
|
48
52
|
);
|
|
49
53
|
return {
|
|
50
54
|
getCompiledEmail: l,
|
|
51
|
-
getTemplateData: () =>
|
|
55
|
+
getTemplateData: () => p(
|
|
52
56
|
"getTemplateData",
|
|
53
|
-
|
|
57
|
+
T,
|
|
54
58
|
(t) => {
|
|
55
|
-
const e = ({ html: a, css: i, width: o, height: E, utmParams:
|
|
59
|
+
const e = ({ html: a, css: i, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
|
|
56
60
|
html: a,
|
|
57
61
|
css: i,
|
|
58
62
|
width: o,
|
|
59
63
|
height: E,
|
|
60
|
-
utmParams:
|
|
61
|
-
syncModulesIds:
|
|
64
|
+
utmParams: u,
|
|
65
|
+
syncModulesIds: m
|
|
62
66
|
});
|
|
63
67
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
64
68
|
}
|
|
@@ -105,13 +109,13 @@ const D = 1e4, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
|
105
109
|
}),
|
|
106
110
|
updateHtmlAndCss: (t, e) => {
|
|
107
111
|
const { actionsApi: a } = window.StripoEditorApi;
|
|
108
|
-
return
|
|
112
|
+
return p("updateHtmlAndCss", D, (i) => {
|
|
109
113
|
a.updateHtmlAndCss(t, e, () => i());
|
|
110
114
|
});
|
|
111
115
|
},
|
|
112
|
-
editorSave: () =>
|
|
116
|
+
editorSave: () => p(
|
|
113
117
|
"save",
|
|
114
|
-
|
|
118
|
+
T,
|
|
115
119
|
(t) => {
|
|
116
120
|
window.StripoEditorApi.actionsApi.save((e) => {
|
|
117
121
|
if (e) {
|
|
@@ -1,70 +1,136 @@
|
|
|
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", it = "guido:debug:ai", ot = 2, lt = 500, ct = (E, u) => `${E}:${u ?? 1}`;
|
|
9
|
+
let y = 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(it) === "1";
|
|
12
15
|
} catch {
|
|
13
16
|
return !1;
|
|
14
17
|
}
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
if (!
|
|
18
|
+
}, Et = () => {
|
|
19
|
+
const E = k();
|
|
20
|
+
if (!E)
|
|
18
21
|
return;
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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)
|
|
29
61
|
return;
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
62
|
+
const { blueprintId: r } = t, n = (h = t.blueprintData) == null ? void 0 : h.html;
|
|
63
|
+
if (!r || !n)
|
|
32
64
|
return;
|
|
33
|
-
|
|
34
|
-
|
|
65
|
+
const e = ct(r, t.version);
|
|
66
|
+
if (!t.applyRequested) {
|
|
67
|
+
F(e);
|
|
68
|
+
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");
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const a = b.get(e);
|
|
81
|
+
if (a === n || !P(e))
|
|
35
82
|
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
|
+
}));
|
|
36
96
|
}
|
|
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
|
-
});
|
|
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
|
+
}
|
|
60
115
|
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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());
|
|
66
132
|
});
|
|
67
133
|
};
|
|
68
134
|
export {
|
|
69
|
-
|
|
135
|
+
Et as useCortexBlueprintBridge
|
|
70
136
|
};
|
|
@@ -1,77 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import T from "../static/styles/components/wide-panel.css.js";
|
|
1
|
+
import S from "../static/assets/icons/line-change.svg.js";
|
|
2
|
+
import i from "../static/assets/icons/line-delete.svg.js";
|
|
3
|
+
import n from "../static/assets/icons/line-plus.svg.js";
|
|
4
|
+
import p from "../static/styles/base.css.js";
|
|
5
|
+
import s from "../static/styles/components/alert-message.css.js";
|
|
6
|
+
import C from "../static/styles/components/amp-block.css.js";
|
|
7
|
+
import a from "../static/styles/components/base-input.css.js";
|
|
8
|
+
import f from "../static/styles/components/button-group.css.js";
|
|
9
|
+
import c from "../static/styles/components/button.css.js";
|
|
10
|
+
import u from "../static/styles/components/combobox.css.js";
|
|
11
|
+
import l from "../static/styles/components/counter.css.js";
|
|
12
|
+
import d from "../static/styles/components/dropdown-menu.css.js";
|
|
13
|
+
import h from "../static/styles/components/loader.css.js";
|
|
14
|
+
import g from "../static/styles/components/narrow-panel.css.js";
|
|
15
|
+
import I from "../static/styles/components/popup.css.js";
|
|
16
|
+
import w from "../static/styles/components/recommendation-strategy.css.js";
|
|
17
|
+
import y from "../static/styles/components/switcher.css.js";
|
|
18
|
+
import b from "../static/styles/components/tabs.css.js";
|
|
19
|
+
import B from "../static/styles/components/tools.css.js";
|
|
20
|
+
import $ from "../static/styles/components/version-history.css.js";
|
|
21
|
+
import P from "../static/styles/components/wide-panel.css.js";
|
|
23
22
|
import x from "../static/styles/variables.css.js";
|
|
24
|
-
function r(
|
|
25
|
-
return `--guido-icon-${
|
|
23
|
+
function r(t, o) {
|
|
24
|
+
return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(o.trim())}");`;
|
|
26
25
|
}
|
|
27
|
-
const
|
|
28
|
-
${r("line-change",
|
|
29
|
-
${r("line-delete",
|
|
30
|
-
${r("line-plus",
|
|
31
|
-
}`,
|
|
26
|
+
const A = `:host {
|
|
27
|
+
${r("line-change", S)}
|
|
28
|
+
${r("line-delete", i)}
|
|
29
|
+
${r("line-plus", n)}
|
|
30
|
+
}`, R = [
|
|
32
31
|
x,
|
|
33
32
|
// Must be on top
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
A,
|
|
34
|
+
p,
|
|
36
35
|
// Must be on top
|
|
36
|
+
s,
|
|
37
37
|
C,
|
|
38
|
+
a,
|
|
39
|
+
f,
|
|
38
40
|
c,
|
|
41
|
+
u,
|
|
39
42
|
l,
|
|
40
43
|
d,
|
|
41
|
-
u,
|
|
42
44
|
h,
|
|
43
45
|
g,
|
|
44
|
-
w,
|
|
45
|
-
y,
|
|
46
46
|
I,
|
|
47
|
-
|
|
47
|
+
y,
|
|
48
|
+
b,
|
|
48
49
|
B,
|
|
49
|
-
D,
|
|
50
50
|
$,
|
|
51
51
|
P,
|
|
52
|
-
|
|
53
|
-
T,
|
|
54
|
-
b
|
|
52
|
+
w
|
|
55
53
|
// Last: overrides button.css / wide-panel.css defaults
|
|
56
54
|
].join(`
|
|
57
55
|
|
|
58
|
-
`),
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const t = (n = document.querySelector("ui-editor")) == null ? void 0 : n.shadowRoot;
|
|
67
|
-
if (t) {
|
|
68
|
-
t.adoptedStyleSheets.includes(o) || (t.adoptedStyleSheets = [...t.adoptedStyleSheets, o]);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
Date.now() < i && requestAnimationFrame(m);
|
|
72
|
-
};
|
|
73
|
-
m();
|
|
56
|
+
`), Y = () => ({ importCss: () => {
|
|
57
|
+
const o = new CSSStyleSheet();
|
|
58
|
+
o.replaceSync(R);
|
|
59
|
+
const e = document.querySelector("ui-editor");
|
|
60
|
+
if (!e)
|
|
61
|
+
return;
|
|
62
|
+
const m = e.shadowRoot;
|
|
63
|
+
m && (m.adoptedStyleSheets = [o]);
|
|
74
64
|
} });
|
|
75
65
|
export {
|
|
76
|
-
|
|
66
|
+
Y as useCustomInterfaceAppearance
|
|
77
67
|
};
|
|
@@ -1,59 +1,104 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useConfig as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as z } from "./useConfig.js";
|
|
3
|
+
import { useEditorLock as I } from "./useEditorLock.js";
|
|
4
|
+
import { useToaster as N } from "./useToaster.js";
|
|
5
|
+
import { useTranslations as q } from "./useTranslations.js";
|
|
6
|
+
import { ToasterTypeOptions as D } from "../enums/toaster.js";
|
|
7
|
+
import { useDynamicContentStore as K } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useEditorStore as R } from "../stores/editor.js";
|
|
9
|
+
import { flattenDynamicContentList as F } from "../utils/genericUtil.js";
|
|
10
|
+
import { extractUsedDynamicContent as G } from "../utils/registerUsedDynamicContent.js";
|
|
11
|
+
import { ref as $, watch as j } from "vue";
|
|
12
|
+
const J = 250, h = 12e4, p = { status: "superseded" }, S = { status: "failed", error: new Error("Blueprint has no html to apply") }, a = $({}), v = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), ce = () => {
|
|
13
|
+
const { updateHtmlAndCss: i } = x(), { runExclusive: A } = I(), { showToaster: f } = N(), E = q(), { template: M } = z(), U = K(), T = R(), w = (e, t) => {
|
|
14
|
+
m.get(e) !== t && (m.set(e, t), f({
|
|
15
|
+
type: D.Error,
|
|
16
|
+
message: E("newsletter.ai-template-failed-apply")
|
|
17
|
+
}));
|
|
18
|
+
}, O = () => {
|
|
19
|
+
var e, t;
|
|
20
|
+
return T.isStripoInitialized && typeof ((t = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : t.updateHtmlAndCss) == "function";
|
|
21
|
+
}, b = (e) => {
|
|
22
|
+
a.value[e] === void 0 && (a.value = { ...a.value, [e]: "pending" });
|
|
23
|
+
}, l = (e, t) => {
|
|
24
|
+
a.value = { ...a.value, [e]: t };
|
|
25
|
+
}, P = (e) => {
|
|
26
|
+
var t;
|
|
19
27
|
try {
|
|
20
|
-
r(t
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
});
|
|
28
|
+
const r = F((t = M.value) == null ? void 0 : t.dynamicContentList), n = G(e, r);
|
|
29
|
+
n.length > 0 && U.registerDynamicContent(n);
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}, _ = (e, t) => {
|
|
33
|
+
m.delete(e), v.get(e) !== t && (v.set(e, t), f({
|
|
34
|
+
type: D.Success,
|
|
35
|
+
message: E("newsletter.ai-template-applied")
|
|
36
|
+
}));
|
|
37
|
+
}, g = async (e, t, r) => {
|
|
38
|
+
const n = (u.get(e) ?? 0) + 1;
|
|
39
|
+
u.set(e, n), l(e, "applying");
|
|
40
|
+
try {
|
|
41
|
+
await A(() => i(t, r));
|
|
42
|
+
} catch (o) {
|
|
43
|
+
return u.get(e) !== n ? p : (console.error("[guido:apply] editor did not acknowledge the template apply", o), l(e, "failed"), w(e, t), { status: "failed", error: o });
|
|
37
44
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
return u.get(e) !== n ? p : (l(e, "applied"), P(t), _(e, t), { status: "applied" });
|
|
46
|
+
}, H = (e) => {
|
|
47
|
+
const t = s.get(e);
|
|
48
|
+
t && (clearTimeout(t.timer), s.delete(e), t.settle(p));
|
|
49
|
+
}, y = (e) => {
|
|
50
|
+
const t = c.get(e);
|
|
51
|
+
t && (clearTimeout(t.timer), c.delete(e), t.settle(p));
|
|
52
|
+
}, B = () => {
|
|
53
|
+
[...c.keys()].forEach(y);
|
|
54
|
+
}, L = (e, t, r) => new Promise((n) => {
|
|
55
|
+
H(e);
|
|
56
|
+
const o = setTimeout(() => {
|
|
57
|
+
s.delete(e), l(e, "failed"), w(e, t), n({
|
|
58
|
+
status: "failed",
|
|
59
|
+
error: new Error(`Editor did not become ready within ${h}ms`)
|
|
60
|
+
});
|
|
61
|
+
}, h);
|
|
62
|
+
s.set(e, { html: t, css: r, timer: o, settle: n }), l(e, "applying");
|
|
63
|
+
}), C = (e, t, r) => O() ? g(e, t, r) : L(e, t, r), Q = async () => {
|
|
64
|
+
if (s.size === 0)
|
|
65
|
+
return;
|
|
66
|
+
const e = [...s.entries()];
|
|
67
|
+
s.clear(), e.forEach(([, o]) => clearTimeout(o.timer));
|
|
68
|
+
const t = e.pop();
|
|
69
|
+
if (e.forEach(([o, d]) => {
|
|
70
|
+
l(o, "failed"), d.settle({ status: "failed", error: new Error("Displaced by a newer apply") });
|
|
71
|
+
}), !t)
|
|
72
|
+
return;
|
|
73
|
+
const [r, n] = t;
|
|
74
|
+
n.settle(await g(r, n.html, n.css));
|
|
41
75
|
};
|
|
42
|
-
return
|
|
43
|
-
|
|
76
|
+
return j(() => T.isStripoInitialized, (e) => {
|
|
77
|
+
e && Q();
|
|
78
|
+
}, { immediate: !0 }), { applyStatus: a, markPending: b, applyTemplate: (e, t) => {
|
|
79
|
+
const { html: r } = t;
|
|
80
|
+
return r ? (B(), C(e, r, t.css ?? "")) : Promise.resolve(S);
|
|
44
81
|
}, applyTemplateDebounced: (e, t) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
82
|
+
const { html: r } = t;
|
|
83
|
+
if (!r)
|
|
84
|
+
return Promise.resolve(S);
|
|
85
|
+
const n = t.css ?? "";
|
|
86
|
+
return new Promise((o) => {
|
|
87
|
+
y(e);
|
|
88
|
+
const d = setTimeout(() => {
|
|
89
|
+
c.delete(e), C(e, r, n).then(o);
|
|
90
|
+
}, J);
|
|
91
|
+
c.set(e, { timer: d, settle: o });
|
|
92
|
+
});
|
|
52
93
|
} };
|
|
53
|
-
},
|
|
54
|
-
|
|
94
|
+
}, le = () => {
|
|
95
|
+
c.forEach((i) => {
|
|
96
|
+
clearTimeout(i.timer), i.settle(p);
|
|
97
|
+
}), c.clear(), s.forEach((i) => {
|
|
98
|
+
clearTimeout(i.timer), i.settle(p);
|
|
99
|
+
}), s.clear(), u.clear(), m.clear(), a.value = {};
|
|
55
100
|
};
|
|
56
101
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
102
|
+
le as resetEmailTemplateApplier,
|
|
103
|
+
ce as useEmailTemplateApplier
|
|
59
104
|
};
|