@useinsider/guido 3.18.1-beta.5cddb72 → 3.18.1-beta.636c82d
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 +46 -52
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +13 -11
- package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +72 -56
- package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +20 -18
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +21 -0
- package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +46 -0
- package/dist/composables/useActionsApi.js +20 -24
- package/dist/composables/useCortexBlueprintBridge.js +54 -113
- package/dist/composables/useEmailTemplateApplier.js +50 -93
- package/dist/composables/useTranslations.js +8 -15
- package/dist/enums/extensions/recommendationBlock.js +38 -31
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +35 -31
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +129 -68
- package/dist/guido.css +1 -1
- package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +2 -0
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -4
- package/dist/src/composables/useEmailTemplateApplier.d.ts +2 -22
- package/dist/src/composables/useTranslations.d.ts +0 -5
- package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +49 -0
- package/dist/src/stores/guido-email-editor.d.ts +7 -29
- package/dist/src/stores/onboarding.d.ts +377 -0
- package/dist/static/styles/components/recommendation-strategy.css.js +21 -4
- package/dist/stores/guido-email-editor.js +1 -5
- package/dist/stores/onboarding.js +41 -36
- package/package.json +1 -1
|
@@ -1,21 +1,17 @@
|
|
|
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, d = 3e4, s = (n, l, u) => new Promise((T, m) => {
|
|
4
|
+
const w = setTimeout(
|
|
5
|
+
() => m(new Error(`${n} did not report completion within ${l}ms`)),
|
|
6
6
|
l
|
|
7
|
-
),
|
|
8
|
-
clearTimeout(
|
|
7
|
+
), p = (A) => (t) => {
|
|
8
|
+
clearTimeout(w), A(t);
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
w(d(A), d(s));
|
|
12
|
-
} catch (r) {
|
|
13
|
-
clearTimeout(c), s(r instanceof Error ? r : new Error(String(r)));
|
|
14
|
-
}
|
|
10
|
+
u(p(T), p(m));
|
|
15
11
|
}), I = () => {
|
|
16
|
-
const { handleError: n } = y(), l = (t = {}) =>
|
|
12
|
+
const { handleError: n } = y(), l = (t = {}) => s(
|
|
17
13
|
"compileEmail",
|
|
18
|
-
|
|
14
|
+
d,
|
|
19
15
|
(e, a) => {
|
|
20
16
|
const o = { ...{
|
|
21
17
|
minimize: !0,
|
|
@@ -36,9 +32,9 @@ const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
|
|
|
36
32
|
forceAmp: !1,
|
|
37
33
|
resetDataSavedFlag: !1,
|
|
38
34
|
disableLineHeightsReplace: !0
|
|
39
|
-
}, ...t },
|
|
40
|
-
callback: (
|
|
41
|
-
|
|
35
|
+
}, ...t }, c = {
|
|
36
|
+
callback: (r, C, f, S, g) => {
|
|
37
|
+
r ? a(r) : e({
|
|
42
38
|
html: C,
|
|
43
39
|
ampHtml: f,
|
|
44
40
|
ampErrors: v(S ?? []),
|
|
@@ -47,22 +43,22 @@ const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
|
|
|
47
43
|
},
|
|
48
44
|
...o
|
|
49
45
|
};
|
|
50
|
-
window.StripoEditorApi.actionsApi.compileEmail(
|
|
46
|
+
window.StripoEditorApi.actionsApi.compileEmail(c);
|
|
51
47
|
}
|
|
52
48
|
);
|
|
53
49
|
return {
|
|
54
50
|
getCompiledEmail: l,
|
|
55
|
-
getTemplateData: () =>
|
|
51
|
+
getTemplateData: () => s(
|
|
56
52
|
"getTemplateData",
|
|
57
|
-
|
|
53
|
+
d,
|
|
58
54
|
(t) => {
|
|
59
|
-
const e = ({ html: a, css: i, width: o, height: E, utmParams:
|
|
55
|
+
const e = ({ html: a, css: i, width: o, height: E, utmParams: c, syncModulesIds: r }) => t({
|
|
60
56
|
html: a,
|
|
61
57
|
css: i,
|
|
62
58
|
width: o,
|
|
63
59
|
height: E,
|
|
64
|
-
utmParams:
|
|
65
|
-
syncModulesIds:
|
|
60
|
+
utmParams: c,
|
|
61
|
+
syncModulesIds: r
|
|
66
62
|
});
|
|
67
63
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
68
64
|
}
|
|
@@ -109,13 +105,13 @@ const D = 1e4, T = 3e4, p = (n, l, w) => new Promise((A, s) => {
|
|
|
109
105
|
}),
|
|
110
106
|
updateHtmlAndCss: (t, e) => {
|
|
111
107
|
const { actionsApi: a } = window.StripoEditorApi;
|
|
112
|
-
return
|
|
108
|
+
return s("updateHtmlAndCss", D, (i) => {
|
|
113
109
|
a.updateHtmlAndCss(t, e, () => i());
|
|
114
110
|
});
|
|
115
111
|
},
|
|
116
|
-
editorSave: () =>
|
|
112
|
+
editorSave: () => s(
|
|
117
113
|
"save",
|
|
118
|
-
|
|
114
|
+
d,
|
|
119
115
|
(t) => {
|
|
120
116
|
window.StripoEditorApi.actionsApi.save((e) => {
|
|
121
117
|
if (e) {
|
|
@@ -1,129 +1,70 @@
|
|
|
1
|
-
import { useEmailTemplateApplier as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import {
|
|
4
|
-
import { ToasterTypeOptions as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
const Z = "email_template", tt = "chat", et = "guido:debug:ai", rt = 2, nt = 500, ot = (A, p) => `${A}:${p ?? 1}`;
|
|
9
|
-
let S = null;
|
|
10
|
-
const it = () => {
|
|
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(
|
|
11
|
+
return window.localStorage.getItem(M) === "1";
|
|
15
12
|
} catch {
|
|
16
13
|
return !1;
|
|
17
14
|
}
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
15
|
+
}, H = () => {
|
|
16
|
+
const c = v();
|
|
17
|
+
if (!c)
|
|
21
18
|
return;
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
r !== void 0 && (a.error = K(r)), p.$patch((c) => {
|
|
33
|
-
c.applyAcks = { ...c.applyAcks, [t]: a };
|
|
34
|
-
});
|
|
35
|
-
}, D = (t) => (d.get(t) ?? 0) > 0, m = async (t, e, o, r) => {
|
|
36
|
-
var c, i, L;
|
|
37
|
-
const n = ((c = o.blueprintData) == null ? void 0 : c.html) ?? "", l = ((i = o.blueprintData) == null ? void 0 : i.css) ?? "", a = o.applyRequestedAt ?? 0;
|
|
38
|
-
d.set(t, (d.get(t) ?? 0) + 1);
|
|
39
|
-
try {
|
|
40
|
-
const s = r === "debounced" ? await x(e, { html: n, css: l }) : await q(e, { html: n, css: l });
|
|
41
|
-
if (s.status === "superseded")
|
|
42
|
-
return;
|
|
43
|
-
if (s.status === "applied") {
|
|
44
|
-
h.set(e, n), u.delete(t), g(t, "applied", a);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const w = u.get(t);
|
|
48
|
-
u.set(t, { html: n, count: (w == null ? void 0 : w.html) === n ? w.count + 1 : 1 }), g(t, "failed", a, s.error);
|
|
49
|
-
} finally {
|
|
50
|
-
d.set(t, (d.get(t) ?? 1) - 1);
|
|
51
|
-
const s = E.get(t);
|
|
52
|
-
s && !D(t) && (E.delete(t), (((L = s.blueprintData) == null ? void 0 : L.html) ?? "") !== n && m(t, e, s, r));
|
|
53
|
-
}
|
|
54
|
-
}, U = (t) => {
|
|
55
|
-
var c;
|
|
56
|
-
if (t.blueprintType !== Z)
|
|
57
|
-
return;
|
|
58
|
-
const { blueprintId: e } = t, o = (c = t.blueprintData) == null ? void 0 : c.html;
|
|
59
|
-
if (!e || !o)
|
|
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)
|
|
60
29
|
return;
|
|
61
|
-
|
|
62
|
-
|
|
30
|
+
const t = r.blueprintId, e = r.blueprintData;
|
|
31
|
+
if (!t || !(e != null && e.html))
|
|
63
32
|
return;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (l === void 0 || n > l) {
|
|
67
|
-
const i = l === void 0;
|
|
68
|
-
if (v.set(r, n), u.delete(r), i && G().has(r)) {
|
|
69
|
-
h.set(e, o);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
m(r, e, t, "immediate");
|
|
33
|
+
if (!r.applyRequested) {
|
|
34
|
+
d(t);
|
|
73
35
|
return;
|
|
74
36
|
}
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Array.isArray(r) && r.forEach((n) => {
|
|
99
|
-
if (n)
|
|
100
|
-
switch (O(o, n), n.type) {
|
|
101
|
-
case "blueprint":
|
|
102
|
-
U(n);
|
|
103
|
-
break;
|
|
104
|
-
case "error":
|
|
105
|
-
B(o);
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
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
|
+
});
|
|
108
60
|
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return (t = A._s) == null ? void 0 : t.get(tt);
|
|
115
|
-
}, F = (t) => {
|
|
116
|
-
f = t, b = W(() => t.messages, k, { deep: !0, immediate: !0 });
|
|
117
|
-
}, I = $();
|
|
118
|
-
I ? F(I) : T = setInterval(() => {
|
|
119
|
-
const t = $();
|
|
120
|
-
t && (P(), F(t));
|
|
121
|
-
}, nt), V(() => {
|
|
122
|
-
P(), b == null || b(), f = void 0, h.clear(), v.clear(), u.clear(), d.clear(), E.clear(), y.clear(), S === _ && (S = null, p.$patch((t) => {
|
|
123
|
-
t.bridgeActive = !1, t.applyAcks = {};
|
|
124
|
-
}), N());
|
|
61
|
+
},
|
|
62
|
+
{ deep: !0, immediate: !0 }
|
|
63
|
+
);
|
|
64
|
+
D(() => {
|
|
65
|
+
m(), i.clear(), a.clear(), _();
|
|
125
66
|
});
|
|
126
67
|
};
|
|
127
68
|
export {
|
|
128
|
-
|
|
69
|
+
H as useCortexBlueprintBridge
|
|
129
70
|
};
|
|
@@ -1,102 +1,59 @@
|
|
|
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
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
}, P = (e) => {
|
|
22
|
-
i.value[e] === void 0 && (i.value = { ...i.value, [e]: "pending" });
|
|
23
|
-
}, m = (e, t) => {
|
|
24
|
-
i.value = { ...i.value, [e]: t };
|
|
25
|
-
}, _ = (e) => {
|
|
26
|
-
var t;
|
|
1
|
+
import { useActionsApi as C } from "./useActionsApi.js";
|
|
2
|
+
import { useConfig as h } from "./useConfig.js";
|
|
3
|
+
import { useToaster as D } from "./useToaster.js";
|
|
4
|
+
import { useTranslations as E } from "./useTranslations.js";
|
|
5
|
+
import { ToasterTypeOptions as f } from "../enums/toaster.js";
|
|
6
|
+
import { useDynamicContentStore as A } from "../stores/dynamic-content.js";
|
|
7
|
+
import { flattenDynamicContentList as w } from "../utils/genericUtil.js";
|
|
8
|
+
import { extractUsedDynamicContent as S } from "../utils/registerUsedDynamicContent.js";
|
|
9
|
+
import { ref as O } from "vue";
|
|
10
|
+
const U = 250, o = O({}), s = {}, u = /* @__PURE__ */ new Map(), z = () => {
|
|
11
|
+
const { updateHtmlAndCss: r } = C(), { showToaster: m } = D(), y = E(), { template: T } = h(), d = A(), g = (e, t) => {
|
|
12
|
+
const a = y(e);
|
|
13
|
+
return a === e ? t : a;
|
|
14
|
+
}, v = (e) => {
|
|
15
|
+
o.value[e] === void 0 && (o.value = { ...o.value, [e]: "pending" });
|
|
16
|
+
}, l = (e, t, a) => {
|
|
17
|
+
var c;
|
|
18
|
+
o.value = { ...o.value, [e]: "applying" };
|
|
27
19
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
try {
|
|
41
|
-
await M(() => a(t, o));
|
|
20
|
+
r(t, a).catch((n) => {
|
|
21
|
+
console.warn("Editor did not acknowledge the template apply.", n);
|
|
22
|
+
}), o.value = { ...o.value, [e]: "applied" };
|
|
23
|
+
try {
|
|
24
|
+
const n = w((c = T.value) == null ? void 0 : c.dynamicContentList), i = S(t, n);
|
|
25
|
+
i.length > 0 && d.registerDynamicContent(i);
|
|
26
|
+
} catch {
|
|
27
|
+
}
|
|
28
|
+
u.get(e) !== t && (u.set(e, t), m({
|
|
29
|
+
type: f.Success,
|
|
30
|
+
message: g("newsletter.ai-template-applied", "Template applied to the editor")
|
|
31
|
+
}));
|
|
42
32
|
} catch (n) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}, H = (e) => {
|
|
47
|
-
const t = r.get(e);
|
|
48
|
-
t && (clearTimeout(t.timer), r.delete(e), t.settle(c));
|
|
49
|
-
}, w = (e) => {
|
|
50
|
-
const t = p.get(e);
|
|
51
|
-
t && (clearTimeout(t.timer), p.delete(e), t.settle(c));
|
|
52
|
-
}, B = (e, t, o) => new Promise((s) => {
|
|
53
|
-
H(e);
|
|
54
|
-
const n = setTimeout(() => {
|
|
55
|
-
r.delete(e), m(e, "failed"), E(e, t), s({
|
|
56
|
-
status: "failed",
|
|
57
|
-
error: new Error(`Editor did not become ready within ${D}ms`)
|
|
33
|
+
o.value = { ...o.value, [e]: "failed" }, m({
|
|
34
|
+
type: f.Error,
|
|
35
|
+
message: n instanceof Error ? n.message : "Failed to apply template"
|
|
58
36
|
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return;
|
|
64
|
-
const e = [...r.entries()];
|
|
65
|
-
r.clear(), e.forEach(([, n]) => clearTimeout(n.timer));
|
|
66
|
-
const t = e.pop();
|
|
67
|
-
if (e.forEach(([n, f]) => {
|
|
68
|
-
m(n, "pending"), f.settle(c);
|
|
69
|
-
}), !t)
|
|
70
|
-
return;
|
|
71
|
-
const [o, s] = t;
|
|
72
|
-
s.settle(await g(o, s.html, s.css));
|
|
37
|
+
}
|
|
38
|
+
}, p = (e) => {
|
|
39
|
+
const t = s[e];
|
|
40
|
+
t && (clearTimeout(t), delete s[e]);
|
|
73
41
|
};
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
}, { immediate: !0 }), { applyStatus: i, markPending: P, applyTemplate: (e, t) => {
|
|
77
|
-
const { html: o } = t;
|
|
78
|
-
return o ? (w(e), C(e, o, t.css ?? "")) : Promise.resolve(S);
|
|
42
|
+
return { applyStatus: o, markPending: v, applyTemplate: (e, t) => {
|
|
43
|
+
t.html && (p(e), l(e, t.html, t.css ?? ""));
|
|
79
44
|
}, applyTemplateDebounced: (e, t) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
p.delete(e), C(e, o, s).then(n);
|
|
88
|
-
}, J);
|
|
89
|
-
p.set(e, { timer: f, settle: n });
|
|
90
|
-
});
|
|
45
|
+
if (!t.html)
|
|
46
|
+
return;
|
|
47
|
+
p(e);
|
|
48
|
+
const { html: a } = t, c = t.css ?? "";
|
|
49
|
+
s[e] = setTimeout(() => {
|
|
50
|
+
delete s[e], l(e, a, c);
|
|
51
|
+
}, U);
|
|
91
52
|
} };
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
clearTimeout(a.timer), a.settle(c);
|
|
95
|
-
}), p.clear(), r.forEach((a) => {
|
|
96
|
-
clearTimeout(a.timer), a.settle(c);
|
|
97
|
-
}), r.clear(), l.clear(), u.clear(), i.value = {};
|
|
53
|
+
}, G = () => {
|
|
54
|
+
Object.values(s).forEach(clearTimeout), Object.keys(s).forEach((r) => delete s[r]), o.value = {};
|
|
98
55
|
};
|
|
99
56
|
export {
|
|
100
|
-
|
|
101
|
-
|
|
57
|
+
G as resetEmailTemplateApplier,
|
|
58
|
+
z as useEmailTemplateApplier
|
|
102
59
|
};
|
|
@@ -4,26 +4,19 @@ import memoize from "../node_modules/lodash-es/memoize.js";
|
|
|
4
4
|
import { ref } from "vue";
|
|
5
5
|
import { useConfig } from "./useConfig.js";
|
|
6
6
|
const useTranslations = () => {
|
|
7
|
-
var o,
|
|
8
|
-
const { config } = useConfig(), translationsPath = ((
|
|
9
|
-
const
|
|
10
|
-
return
|
|
11
|
-
(
|
|
12
|
-
|
|
13
|
-
) :
|
|
7
|
+
var o, e;
|
|
8
|
+
const { config } = useConfig(), translationsPath = ((e = (o = config.value) == null ? void 0 : o.editor) == null ? void 0 : e.translationsPath) || DEFAULT_EDITOR.translationsPath, translations = ref(eval(translationsPath)), trans = (t, n) => {
|
|
9
|
+
const r = translations.value[t];
|
|
10
|
+
return r ? n ? Object.entries(n).reduce(
|
|
11
|
+
(s, [i, a]) => s.replace(new RegExp(`{${i}}`, "g"), String(a)),
|
|
12
|
+
r
|
|
13
|
+
) : r : (console.warn(`Translation key not found: ${t}`), t);
|
|
14
14
|
};
|
|
15
15
|
return memoize(
|
|
16
16
|
trans,
|
|
17
|
-
(
|
|
17
|
+
(t, n) => !n || Object.keys(n).length === 0 ? t : JSON.stringify({ key: t, params: n })
|
|
18
18
|
);
|
|
19
|
-
}, useTranslationWithFallback = () => {
|
|
20
|
-
const o = useTranslations();
|
|
21
|
-
return (r, n) => {
|
|
22
|
-
const t = o(r);
|
|
23
|
-
return t === r ? n : t;
|
|
24
|
-
};
|
|
25
19
|
};
|
|
26
20
|
export {
|
|
27
|
-
useTranslationWithFallback,
|
|
28
21
|
useTranslations
|
|
29
22
|
};
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import { useTranslations as
|
|
2
|
-
const
|
|
1
|
+
import { useTranslations as n } from "../../composables/useTranslations.js";
|
|
2
|
+
const o = {
|
|
3
3
|
RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
|
|
4
4
|
// Relative path → same-origin as the embedding inone dashboard.
|
|
5
5
|
PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
|
|
6
6
|
RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
|
|
7
|
-
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
|
|
8
|
-
|
|
7
|
+
RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies",
|
|
8
|
+
// Smart Recommender hides the Email channel unless the URL asks for it, so a strategy created
|
|
9
|
+
// without this flag can never be Email-suitable and would never reach the editor's list.
|
|
10
|
+
RECOMMENDATION_STRATEGY_CREATE_PATH: "/discovery/recommendation-strategies/create?isEmail=true"
|
|
11
|
+
}, d = (e) => {
|
|
12
|
+
const { RECOMMENDATION_STRATEGIES_PANEL_PATH: r } = o;
|
|
13
|
+
return `${r}/${e}/edit`;
|
|
14
|
+
}, m = {
|
|
9
15
|
CLIENT_ID: "clientId"
|
|
10
|
-
},
|
|
11
|
-
const e =
|
|
16
|
+
}, p = () => {
|
|
17
|
+
const e = n();
|
|
12
18
|
return [
|
|
13
19
|
{
|
|
14
20
|
id: 11,
|
|
@@ -71,14 +77,14 @@ const l = {
|
|
|
71
77
|
path: "top-sellers"
|
|
72
78
|
}
|
|
73
79
|
];
|
|
74
|
-
},
|
|
80
|
+
}, v = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], h = [
|
|
75
81
|
{ text: "before the amount", value: "0" },
|
|
76
82
|
{ text: "after the amount", value: "1" }
|
|
77
|
-
],
|
|
83
|
+
], x = [
|
|
78
84
|
{ text: "dot(.)", value: "." },
|
|
79
85
|
{ text: "comma(,)", value: "," },
|
|
80
86
|
{ text: "space( )", value: " " }
|
|
81
|
-
],
|
|
87
|
+
], b = [
|
|
82
88
|
{ text: "0", value: "0" },
|
|
83
89
|
{ text: "1", value: "1" },
|
|
84
90
|
{ text: "2", value: "2" },
|
|
@@ -90,54 +96,55 @@ const l = {
|
|
|
90
96
|
{ text: "contains", value: "~" },
|
|
91
97
|
{ text: "does not contain", value: "!~" },
|
|
92
98
|
{ text: "any of", value: a }
|
|
93
|
-
],
|
|
99
|
+
], s = [
|
|
94
100
|
{ text: "is exactly", value: "=" },
|
|
95
101
|
{ text: "is not exactly", value: "!==" },
|
|
96
102
|
{ text: "contains", value: "~" },
|
|
97
103
|
{ text: "does not contain", value: "!~" },
|
|
98
104
|
{ text: "any of", value: a }
|
|
99
|
-
],
|
|
105
|
+
], i = [
|
|
100
106
|
{ text: "is equal to", value: "=" },
|
|
101
107
|
{ text: "is greater than", value: ">" },
|
|
102
108
|
{ text: "is less than", value: "<" }
|
|
103
|
-
],
|
|
109
|
+
], u = [
|
|
104
110
|
{ text: "is equal to", value: "=" },
|
|
105
111
|
{ text: "after", value: ">" },
|
|
106
112
|
{ text: "before", value: "<" }
|
|
107
|
-
],
|
|
113
|
+
], c = [
|
|
108
114
|
{ text: "true", value: "==" },
|
|
109
115
|
{ text: "false", value: "!=" }
|
|
110
|
-
],
|
|
116
|
+
], g = (e) => {
|
|
111
117
|
if (!e)
|
|
112
118
|
return t;
|
|
113
119
|
switch (e) {
|
|
114
120
|
case "Boolean":
|
|
115
|
-
return
|
|
121
|
+
return c;
|
|
116
122
|
case "Date":
|
|
117
|
-
return
|
|
123
|
+
return u;
|
|
118
124
|
case "Number":
|
|
119
|
-
return
|
|
125
|
+
return i;
|
|
120
126
|
case "String":
|
|
121
127
|
return t;
|
|
122
128
|
case "Strings":
|
|
123
|
-
return
|
|
129
|
+
return s;
|
|
124
130
|
default:
|
|
125
131
|
return t;
|
|
126
132
|
}
|
|
127
133
|
};
|
|
128
134
|
export {
|
|
129
135
|
a as OP_ANY_OF,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
t as operatorOptionsForStrings
|
|
136
|
+
v as PriceAttributes,
|
|
137
|
+
m as QUERY_PARAMS,
|
|
138
|
+
o as URLS,
|
|
139
|
+
b as currencyDecimalCounts,
|
|
140
|
+
h as currencyLocationMaps,
|
|
141
|
+
x as currencyOperators,
|
|
142
|
+
g as getOperatorOptions,
|
|
143
|
+
p as getRecommendationFeedSourceMaps,
|
|
144
|
+
s as operatorOptionsForArrayOfStrings,
|
|
145
|
+
c as operatorOptionsForBooleans,
|
|
146
|
+
u as operatorOptionsForDates,
|
|
147
|
+
i as operatorOptionsForNumbers,
|
|
148
|
+
t as operatorOptionsForStrings,
|
|
149
|
+
d as strategyEditPath
|
|
143
150
|
};
|