@useinsider/guido 3.9.1-beta.6e7cd3e → 3.9.1-beta.8a96896
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/organisms/header/AiStatusPill.vue.js +18 -0
- package/dist/components/organisms/header/AiStatusPill.vue2.js +17 -0
- package/dist/components/organisms/header/EditorToolbar.vue.js +2 -2
- package/dist/components/organisms/header/EditorToolbar.vue2.js +7 -6
- package/dist/composables/useAiStatus.js +13 -0
- package/dist/composables/useCortexBlueprintBridge.js +49 -42
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +106 -119
- package/dist/enums/defaults.js +7 -4
- package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +1 -1
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +75 -69
- package/dist/guido.css +1 -1
- package/dist/services/blankTemplate.js +34 -0
- package/dist/services/stripoApi.js +13 -18
- package/dist/src/components/organisms/header/AiStatusPill.vue.d.ts +2 -0
- package/dist/src/composables/useAiStatus.d.ts +11 -0
- package/dist/src/enums/defaults.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +6 -0
- package/dist/src/services/blankTemplate.d.ts +11 -0
- package/dist/src/stores/guido-ai-status.d.ts +10 -0
- package/dist/stores/guido-ai-status.js +12 -0
- package/dist/utils/pairProductVariables.js +65 -64
- package/package.json +1 -1
- package/dist/static/templates/empty/index.html.js +0 -74
- package/dist/static/templates/empty/style.css.js +0 -779
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import e from "./AiStatusPill.vue2.js";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import i from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
|
+
var l = function() {
|
|
5
|
+
var s = this, t = s._self._c, a = s._self._setupProxy;
|
|
6
|
+
return a.isGenerating ? t("span", { staticClass: "d-f a-i-c ml-2 f-s-1 ai-status-pill", attrs: { "data-testid": "ai-status-pill" } }, [t(a.InLoading, { attrs: { "color-class": "i-c-53", size: "16" } }), t("span", { staticClass: "ml-1 t-c-53 ai-status-pill__label" }, [s._v(" " + s._s(a.label) + " ")])], 1) : s._e();
|
|
7
|
+
}, r = [], _ = /* @__PURE__ */ i(
|
|
8
|
+
e,
|
|
9
|
+
l,
|
|
10
|
+
r,
|
|
11
|
+
!1,
|
|
12
|
+
null,
|
|
13
|
+
"ee17b74e"
|
|
14
|
+
);
|
|
15
|
+
const f = _.exports;
|
|
16
|
+
export {
|
|
17
|
+
f as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { defineComponent as i, computed as a } from "vue";
|
|
2
|
+
import { useAiStatus as m } from "../../../composables/useAiStatus.js";
|
|
3
|
+
import { useTranslations as _ } from "../../../composables/useTranslations.js";
|
|
4
|
+
import { InLoading as u } from "@useinsider/design-system-vue";
|
|
5
|
+
const g = /* @__PURE__ */ i({
|
|
6
|
+
__name: "AiStatusPill",
|
|
7
|
+
setup(c) {
|
|
8
|
+
const t = "newsletter.ai-generating", n = "AI is generating…", { isGenerating: o } = m(), e = _(), r = a(() => {
|
|
9
|
+
const s = e(t);
|
|
10
|
+
return s === t ? n : s;
|
|
11
|
+
});
|
|
12
|
+
return { __sfc: !0, AI_GENERATING_KEY: t, AI_GENERATING_FALLBACK: n, isGenerating: o, trans: e, label: r, InLoading: u };
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
export {
|
|
16
|
+
g as default
|
|
17
|
+
};
|
|
@@ -3,14 +3,14 @@ import i from "./EditorToolbar.vue2.js";
|
|
|
3
3
|
import s from "../../../_virtual/_plugin-vue2_normalizer.js";
|
|
4
4
|
var n = function() {
|
|
5
5
|
var e = this, o = e._self._c, t = e._self._setupProxy;
|
|
6
|
-
return o("div", { staticClass: "d-f editor-toolbar" }, [o(t.InButtonV2, { attrs: { id: "guido__undo-button", "left-icon": "line-undo", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isUndoButtonDisabled, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__undo-button"), "tooltip-text": t.trans("action-builder.undo") } }), o(t.InButtonV2, { attrs: { id: "guido__redo-button", "left-icon": "line-redo", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isRedoButtonDisabled, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__redo-button"), "tooltip-text": t.trans("action-builder.redo") } }), o(t.InButtonV2, { attrs: { id: "guido__code-button", "data-testid": "Code Editor", "left-icon": "line-code", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isCodeEditorButtonDisabled, "label-text-status": !1, "selected-status": t.editorStore.isCodeEditorOpen, "tooltip-options": t.getTooltipOptions("guido__code-button"), "tooltip-text": t.codeEditorTooltipText } }), o(t.InButtonV2, { attrs: { id: "guido__preview-button", "left-icon": "line-show-on", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isPreviewButtonDisabled, "label-text-status": !1, "selected-status": t.editorStore.isPreviewModeOpen, "tooltip-options": t.getTooltipOptions("guido__preview-button"), "tooltip-text": t.previewTooltipText }, on: { click: t.handlePreviewToggle } }), o(t.ViewOptions, { staticClass: "ml-2" })], 1);
|
|
6
|
+
return o("div", { staticClass: "d-f editor-toolbar" }, [o(t.AiStatusPill), o(t.InButtonV2, { attrs: { id: "guido__undo-button", "left-icon": "line-undo", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isUndoButtonDisabled, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__undo-button"), "tooltip-text": t.trans("action-builder.undo") } }), o(t.InButtonV2, { attrs: { id: "guido__redo-button", "left-icon": "line-redo", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isRedoButtonDisabled, "label-text-status": !1, "tooltip-options": t.getTooltipOptions("guido__redo-button"), "tooltip-text": t.trans("action-builder.redo") } }), o(t.InButtonV2, { attrs: { id: "guido__code-button", "data-testid": "Code Editor", "left-icon": "line-code", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isCodeEditorButtonDisabled, "label-text-status": !1, "selected-status": t.editorStore.isCodeEditorOpen, "tooltip-options": t.getTooltipOptions("guido__code-button"), "tooltip-text": t.codeEditorTooltipText } }), o(t.InButtonV2, { attrs: { id: "guido__preview-button", "left-icon": "line-show-on", styling: "ghost", type: "secondary", "disabled-status": t.editorStore.isPreviewButtonDisabled, "label-text-status": !1, "selected-status": t.editorStore.isPreviewModeOpen, "tooltip-options": t.getTooltipOptions("guido__preview-button"), "tooltip-text": t.previewTooltipText }, on: { click: t.handlePreviewToggle } }), o(t.ViewOptions, { staticClass: "ml-2" })], 1);
|
|
7
7
|
}, d = [], l = /* @__PURE__ */ s(
|
|
8
8
|
i,
|
|
9
9
|
n,
|
|
10
10
|
d,
|
|
11
11
|
!1,
|
|
12
12
|
null,
|
|
13
|
-
"
|
|
13
|
+
"f2eb03d4"
|
|
14
14
|
);
|
|
15
15
|
const _ = l.exports;
|
|
16
16
|
export {
|
|
@@ -4,14 +4,15 @@ import { useTranslations as l } from "../../../composables/useTranslations.js";
|
|
|
4
4
|
import { useEditorStore as d } from "../../../stores/editor.js";
|
|
5
5
|
import { getTooltipOptions as w } from "../../../utils/tooltipUtils.js";
|
|
6
6
|
import { InButtonV2 as c } from "@useinsider/design-system-vue";
|
|
7
|
-
import a from "./
|
|
8
|
-
|
|
7
|
+
import a from "./AiStatusPill.vue.js";
|
|
8
|
+
import f from "./ViewOptions.vue.js";
|
|
9
|
+
const x = /* @__PURE__ */ p({
|
|
9
10
|
__name: "EditorToolbar",
|
|
10
|
-
setup(
|
|
11
|
-
const o = d(), e = l(), { openPreviewMode: t, closePreviewMode: r } = m(),
|
|
12
|
-
return { __sfc: !0, editorStore: o, trans: e, openPreviewMode: t, closePreviewMode: r, previewTooltipText:
|
|
11
|
+
setup(u) {
|
|
12
|
+
const o = d(), e = l(), { openPreviewMode: t, closePreviewMode: r } = m(), s = i(() => o.isPreviewModeOpen ? e("newsletter.close-email-preview") : e("newsletter.email-preview")), n = i(() => o.isCodeEditorOpen ? e("newsletter.close-html-editor") : e("newsletter.html-editor"));
|
|
13
|
+
return { __sfc: !0, editorStore: o, trans: e, openPreviewMode: t, closePreviewMode: r, previewTooltipText: s, codeEditorTooltipText: n, handlePreviewToggle: () => o.isPreviewModeOpen ? r() : t(), getTooltipOptions: w, InButtonV2: c, AiStatusPill: a, ViewOptions: f };
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
16
|
export {
|
|
16
|
-
|
|
17
|
+
x as default
|
|
17
18
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { useAiStatusStore as i } from "../stores/guido-ai-status.js";
|
|
2
|
+
import { storeToRefs as o } from "pinia";
|
|
3
|
+
const G = () => {
|
|
4
|
+
const t = i(), { isGenerating: n, activeTool: r } = o(t);
|
|
5
|
+
return { isGenerating: n, activeTool: r, startGenerating: (e = "") => {
|
|
6
|
+
t.isGenerating && t.activeTool === e || t.$patch({ isGenerating: !0, activeTool: e });
|
|
7
|
+
}, stopGenerating: () => {
|
|
8
|
+
!t.isGenerating && t.activeTool === "" || t.$patch({ isGenerating: !1, activeTool: "" });
|
|
9
|
+
} };
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
G as useAiStatus
|
|
13
|
+
};
|
|
@@ -1,70 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { useAiStatus as m } from "./useAiStatus.js";
|
|
2
|
+
import { useEmailTemplateApplier as B, resetEmailTemplateApplier as D } from "./useEmailTemplateApplier.js";
|
|
3
|
+
import { useToaster as R } from "./useToaster.js";
|
|
4
|
+
import { useTranslations as x } from "./useTranslations.js";
|
|
5
|
+
import { ToasterTypeOptions as G } from "../enums/toaster.js";
|
|
6
|
+
import { getActivePinia as L } from "pinia";
|
|
7
|
+
import { watch as M, onUnmounted as k } from "vue";
|
|
8
|
+
const C = "email_template", F = "chat", U = "guido:debug:ai", $ = () => {
|
|
8
9
|
if (typeof window > "u")
|
|
9
10
|
return !1;
|
|
10
11
|
try {
|
|
11
|
-
return window.localStorage.getItem(
|
|
12
|
+
return window.localStorage.getItem(U) === "1";
|
|
12
13
|
} catch {
|
|
13
14
|
return !1;
|
|
14
15
|
}
|
|
15
|
-
},
|
|
16
|
-
const c =
|
|
16
|
+
}, z = () => {
|
|
17
|
+
const c = L();
|
|
17
18
|
if (!c)
|
|
18
19
|
return;
|
|
19
|
-
const
|
|
20
|
+
const u = c._s, p = u == null ? void 0 : u.get(F);
|
|
20
21
|
if (!p)
|
|
21
22
|
return;
|
|
22
|
-
const { markPending:
|
|
23
|
-
const
|
|
24
|
-
return
|
|
25
|
-
},
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
if (
|
|
23
|
+
const { markPending: y, applyTemplate: A, applyTemplateDebounced: E } = B(), { startGenerating: h, stopGenerating: f } = m(), { showToaster: b } = R(), w = x(), _ = (e, r) => {
|
|
24
|
+
const o = w(e);
|
|
25
|
+
return o === e ? r : o;
|
|
26
|
+
}, n = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), d = $(), S = (e, r) => {
|
|
27
|
+
d && console.debug(`[guido:cortex] msg=${e ?? "?"} type=${(r == null ? void 0 : r.type) ?? "?"}`, r);
|
|
28
|
+
}, v = (e) => {
|
|
29
|
+
if (e.blueprintType !== C)
|
|
29
30
|
return;
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
31
|
+
const r = e.blueprintId, o = e.blueprintData;
|
|
32
|
+
if (!r || !(o != null && o.html))
|
|
32
33
|
return;
|
|
33
|
-
if (!
|
|
34
|
-
|
|
34
|
+
if (!e.applyRequested) {
|
|
35
|
+
y(r);
|
|
35
36
|
return;
|
|
36
37
|
}
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
}, s = (
|
|
40
|
-
type:
|
|
41
|
-
message:
|
|
42
|
-
}), !0),
|
|
38
|
+
const t = n.get(r);
|
|
39
|
+
t === void 0 ? (n.set(r, o.html), A(r, o)) : t !== o.html && (n.set(r, o.html), E(r, o));
|
|
40
|
+
}, s = (e) => e === void 0 || a.has(e) ? !1 : (a.add(e), b({
|
|
41
|
+
type: G.Alert,
|
|
42
|
+
message: _("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
|
|
43
|
+
}), !0), I = M(
|
|
43
44
|
() => p.messages,
|
|
44
|
-
(
|
|
45
|
-
Array.isArray(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
(e) => {
|
|
46
|
+
if (!Array.isArray(e))
|
|
47
|
+
return;
|
|
48
|
+
let r = !1, o = "";
|
|
49
|
+
e.forEach((t) => {
|
|
50
|
+
const l = t == null ? void 0 : t.id, P = (t == null ? void 0 : t.isError) === !0 || (t == null ? void 0 : t.isCancelled) === !0;
|
|
51
|
+
(t == null ? void 0 : t.isError) === !0 && s(l) && d && console.debug(`[guido:cortex] message-level error id=${l}`, t);
|
|
52
|
+
const T = t == null ? void 0 : t.segments;
|
|
53
|
+
Array.isArray(T) && T.forEach((i) => {
|
|
54
|
+
if (i)
|
|
55
|
+
switch (S(l, i), i.type) {
|
|
52
56
|
case "blueprint":
|
|
53
|
-
|
|
57
|
+
v(i);
|
|
58
|
+
break;
|
|
59
|
+
case "tool":
|
|
60
|
+
!P && i.isRunning === !0 && (r = !0, o = i.name ?? "");
|
|
54
61
|
break;
|
|
55
62
|
case "error":
|
|
56
|
-
s(
|
|
63
|
+
s(l);
|
|
57
64
|
break;
|
|
58
65
|
}
|
|
59
66
|
});
|
|
60
|
-
});
|
|
67
|
+
}), r ? h(o) : f();
|
|
61
68
|
},
|
|
62
69
|
{ deep: !0, immediate: !0 }
|
|
63
70
|
);
|
|
64
|
-
|
|
65
|
-
|
|
71
|
+
k(() => {
|
|
72
|
+
I(), f(), n.clear(), a.clear(), D();
|
|
66
73
|
});
|
|
67
74
|
};
|
|
68
75
|
export {
|
|
69
|
-
|
|
76
|
+
z as useCortexBlueprintBridge
|
|
70
77
|
};
|
|
@@ -1,189 +1,176 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
import { isIgnoredRecommendationBlock as
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
return n === "before" ? `${
|
|
1
|
+
import { useConfig as _ } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as q } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as C } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as E } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
|
|
6
|
+
function P(t, r, e, n, s = "") {
|
|
7
|
+
const c = `{{${s}${t}_${r}_${e}}}`, o = `{{${s}${t}_${r}_currency}}`;
|
|
8
|
+
return n === "before" ? `${o} ${c}` : `${c} ${o}`;
|
|
9
9
|
}
|
|
10
10
|
function m(t) {
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
[
|
|
14
|
-
return
|
|
11
|
+
let r = t;
|
|
12
|
+
for (; r.children.length === 1; )
|
|
13
|
+
[r] = r.children;
|
|
14
|
+
return r;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
switch (
|
|
16
|
+
function b(t, r, e, n, s, c) {
|
|
17
|
+
switch (r) {
|
|
18
18
|
case "productImage": {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
19
|
+
const o = t.querySelector("img");
|
|
20
|
+
o && (o.setAttribute("src", `{{${c}${e}_${n}_image_url}}`), o.setAttribute("alt", `{{${c}${e}_${n}_name}}`));
|
|
21
|
+
const i = t.querySelector("a");
|
|
22
|
+
i && (i.setAttribute("href", `{{${c}${e}_${n}_url}}`), i.classList.add(C));
|
|
23
23
|
break;
|
|
24
24
|
}
|
|
25
25
|
case "productName": {
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case "productPrice": {
|
|
31
|
-
const r = t.querySelector(".product-price p") ?? t.querySelector("p");
|
|
32
|
-
r && (m(r).textContent = f(
|
|
33
|
-
e,
|
|
34
|
-
n,
|
|
35
|
-
"price",
|
|
36
|
-
s,
|
|
37
|
-
i
|
|
38
|
-
));
|
|
39
|
-
const c = t.querySelector(".product-old-price p");
|
|
40
|
-
c && (m(c).textContent = f(
|
|
41
|
-
e,
|
|
42
|
-
n,
|
|
43
|
-
"original_price",
|
|
44
|
-
s,
|
|
45
|
-
i
|
|
46
|
-
));
|
|
26
|
+
const o = t.querySelector("p");
|
|
27
|
+
o && (m(o).textContent = `{{${c}${e}_${n}_name}}`);
|
|
47
28
|
break;
|
|
48
29
|
}
|
|
30
|
+
// Inline mode ("Move to next line" OFF) merges BOTH prices into one row
|
|
31
|
+
// anchored on whichever attribute comes first in the composition, so
|
|
32
|
+
// substitute by cell content, not by the row's anchor (SD-145161).
|
|
33
|
+
case "productPrice":
|
|
49
34
|
case "productOldPrice": {
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
35
|
+
const o = (d, l) => {
|
|
36
|
+
d && (m(d).textContent = P(
|
|
37
|
+
e,
|
|
38
|
+
n,
|
|
39
|
+
l,
|
|
40
|
+
s,
|
|
41
|
+
c
|
|
42
|
+
));
|
|
43
|
+
}, i = t.querySelector(".product-price p"), a = t.querySelector(".product-old-price p"), u = !i && !a ? t.querySelector("p") : null;
|
|
44
|
+
o(i ?? (r === "productPrice" ? u : null), "price"), o(a ?? (r === "productOldPrice" ? u : null), "original_price");
|
|
58
45
|
break;
|
|
59
46
|
}
|
|
60
47
|
case "productButton": {
|
|
61
|
-
const
|
|
62
|
-
|
|
48
|
+
const o = t.querySelector("a");
|
|
49
|
+
o && o.setAttribute("href", `{{${c}${e}_${n}_url}}`);
|
|
63
50
|
break;
|
|
64
51
|
}
|
|
65
52
|
case "productOmnibusPrice": {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
const
|
|
70
|
-
|
|
53
|
+
const o = t.querySelector(".omnibus-price-value");
|
|
54
|
+
if (o) {
|
|
55
|
+
o.textContent = `{{${c}${e}_${n}_omnibus_price}}`;
|
|
56
|
+
const i = o.closest("p");
|
|
57
|
+
i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
|
|
71
58
|
}
|
|
72
59
|
break;
|
|
73
60
|
}
|
|
74
61
|
case "productOmnibusDiscount": {
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
const
|
|
79
|
-
|
|
62
|
+
const o = t.querySelector(".omnibus-discount-value");
|
|
63
|
+
if (o) {
|
|
64
|
+
o.textContent = `{{${c}${e}_${n}_omnibus_discount}}`;
|
|
65
|
+
const i = o.closest("p");
|
|
66
|
+
i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
|
|
80
67
|
}
|
|
81
68
|
break;
|
|
82
69
|
}
|
|
83
70
|
default: {
|
|
84
|
-
const
|
|
85
|
-
if (
|
|
86
|
-
const
|
|
87
|
-
|
|
71
|
+
const o = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
|
|
72
|
+
if (o) {
|
|
73
|
+
const i = o.getAttribute("product-attr"), a = o.querySelector("p");
|
|
74
|
+
a && (m(a).textContent = `{{${c}${e}_${n}_${i}}}`);
|
|
88
75
|
}
|
|
89
76
|
break;
|
|
90
77
|
}
|
|
91
78
|
}
|
|
92
79
|
}
|
|
93
|
-
function R(t,
|
|
94
|
-
t.querySelectorAll(".recommendation-product-row").forEach((
|
|
95
|
-
|
|
96
|
-
const u =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}) :
|
|
80
|
+
function R(t, r, e, n) {
|
|
81
|
+
t.querySelectorAll(".recommendation-product-row").forEach((c, o) => {
|
|
82
|
+
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
83
|
+
const u = a.getAttribute("data-attribute-type") || "", d = a.querySelectorAll(".attribute-cell");
|
|
84
|
+
d.length > 0 ? d.forEach((l) => {
|
|
85
|
+
b(l, u, r, o, e, n);
|
|
86
|
+
}) : b(a, u, r, o, e, n);
|
|
100
87
|
});
|
|
101
88
|
});
|
|
102
89
|
}
|
|
103
|
-
function W(t,
|
|
90
|
+
function W(t, r, e, n) {
|
|
104
91
|
const s = t.querySelectorAll(".recommendation-product-row");
|
|
105
92
|
if (!s.length)
|
|
106
93
|
return;
|
|
107
|
-
const [
|
|
108
|
-
s.forEach((
|
|
109
|
-
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const g = u *
|
|
113
|
-
|
|
94
|
+
const [c] = s, o = c.querySelector("[data-attribute-type]"), i = o ? o.querySelectorAll(".attribute-cell").length : 1;
|
|
95
|
+
s.forEach((a, u) => {
|
|
96
|
+
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
97
|
+
const p = l.getAttribute("data-attribute-type") || "";
|
|
98
|
+
l.querySelectorAll(".attribute-cell").forEach(($, S) => {
|
|
99
|
+
const g = u * i + S;
|
|
100
|
+
b($, p, r, g, e, n);
|
|
114
101
|
});
|
|
115
102
|
});
|
|
116
103
|
});
|
|
117
104
|
}
|
|
118
|
-
function v(t,
|
|
119
|
-
t.querySelectorAll(".ins-recommendation-product-container").forEach((
|
|
120
|
-
W(
|
|
105
|
+
function v(t, r, e, n) {
|
|
106
|
+
t.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
107
|
+
W(c, r, e, n);
|
|
121
108
|
});
|
|
122
109
|
}
|
|
123
|
-
function O(t,
|
|
110
|
+
function O(t, r, e) {
|
|
124
111
|
const n = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
|
|
125
|
-
n === "list" ? R(t,
|
|
112
|
+
n === "list" ? R(t, r, s, e) : v(t, r, s, e);
|
|
126
113
|
}
|
|
127
|
-
function
|
|
128
|
-
const n = new RegExp(`${
|
|
114
|
+
function f(t, r, e) {
|
|
115
|
+
const n = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(n);
|
|
129
116
|
return s ? parseInt(s[1]) : e;
|
|
130
117
|
}
|
|
131
|
-
function
|
|
132
|
-
const
|
|
133
|
-
return
|
|
118
|
+
function y(t) {
|
|
119
|
+
const r = t.trim();
|
|
120
|
+
return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
|
|
134
121
|
}
|
|
135
|
-
function
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
return
|
|
122
|
+
function A(t) {
|
|
123
|
+
const r = t.getAttribute("width");
|
|
124
|
+
if (r && y(r))
|
|
125
|
+
return r.trim();
|
|
139
126
|
const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
|
|
140
|
-
return e &&
|
|
127
|
+
return e && y(e[1]) ? e[1] : null;
|
|
141
128
|
}
|
|
142
|
-
function
|
|
129
|
+
function M(t, r) {
|
|
143
130
|
let e = t.parentElement;
|
|
144
|
-
for (; e && e !==
|
|
145
|
-
if (e.tagName === "TD" &&
|
|
131
|
+
for (; e && e !== r; ) {
|
|
132
|
+
if (e.tagName === "TD" && A(e))
|
|
146
133
|
return e;
|
|
147
134
|
e = e.parentElement;
|
|
148
135
|
}
|
|
149
136
|
return null;
|
|
150
137
|
}
|
|
151
|
-
function
|
|
152
|
-
const
|
|
153
|
-
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((
|
|
154
|
-
if (
|
|
138
|
+
function T(t) {
|
|
139
|
+
const r = t.getAttribute("style") || "", e = f(r, "width", 600), n = f(r, "padding", 0) * 2, s = Math.max(0, e - n);
|
|
140
|
+
s !== 0 && t.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
141
|
+
if (c.hasAttribute("width"))
|
|
155
142
|
return;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
143
|
+
const o = M(c, t);
|
|
144
|
+
if (!o)
|
|
158
145
|
return;
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
163
|
-
const
|
|
164
|
-
|
|
146
|
+
const i = A(o), a = f(o.getAttribute("style") || "", "padding", 0) * 2, u = i.endsWith("%") ? Math.floor(s * parseFloat(i) / 100) : parseInt(i), d = Math.max(1, u - a);
|
|
147
|
+
c.setAttribute("width", String(d));
|
|
148
|
+
const l = c.getAttribute("style") || "";
|
|
149
|
+
if (!/\bwidth\s*:\s*\d/i.test(l)) {
|
|
150
|
+
const p = l && !l.trim().endsWith(";") ? "; " : "";
|
|
151
|
+
c.setAttribute("style", `${l}${p}width: ${d}px`);
|
|
165
152
|
}
|
|
166
153
|
});
|
|
167
154
|
}
|
|
168
|
-
function B(t,
|
|
155
|
+
function B(t, r) {
|
|
169
156
|
const e = t.match(/<!DOCTYPE[^>]*>/i);
|
|
170
157
|
return (e ? `${e[0]}
|
|
171
|
-
` : "") +
|
|
158
|
+
` : "") + r.documentElement.outerHTML;
|
|
172
159
|
}
|
|
173
160
|
function G(t) {
|
|
174
|
-
const
|
|
161
|
+
const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), n = e.querySelectorAll(".recommendation-block-v2");
|
|
175
162
|
if (!n.length)
|
|
176
163
|
return t;
|
|
177
|
-
const { buildCampaignUrl: s } =
|
|
178
|
-
|
|
179
|
-
const { isFeatureEnabled:
|
|
164
|
+
const { buildCampaignUrl: s } = q(), c = E();
|
|
165
|
+
c.recommendationCampaignUrls = {};
|
|
166
|
+
const { isFeatureEnabled: o } = _(), i = o("liquidSyntax") ? "reco_" : "";
|
|
180
167
|
return n.forEach((u) => {
|
|
181
|
-
var
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
}), B(
|
|
168
|
+
var l, p;
|
|
169
|
+
const d = u.getAttribute("recommendation-id");
|
|
170
|
+
d && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (p = u.parentNode) == null || p.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((h) => h.remove()), s(d), w(u) || O(u, d, i), T(u));
|
|
171
|
+
}), B(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
185
172
|
}
|
|
186
173
|
export {
|
|
187
|
-
|
|
174
|
+
P as formatPriceVariable,
|
|
188
175
|
G as prepareRecommendationBlocks
|
|
189
176
|
};
|
package/dist/enums/defaults.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
},
|
|
3
|
+
}, s = 2, a = 13, t = "https://email-static.useinsider.com", o = `${t}/templates/campaign/default.html`, l = `${t}/templates/campaign/default.css`, E = {
|
|
4
4
|
SAVED_MODULES: "savedModules",
|
|
5
5
|
DEFAULT_MODULES: "defaultModules"
|
|
6
6
|
};
|
|
7
7
|
export {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
l as BLANK_TEMPLATE_CSS_URL,
|
|
9
|
+
o as BLANK_TEMPLATE_HTML_URL,
|
|
10
|
+
t as EMAIL_STATIC_BASE_URL,
|
|
11
|
+
s as EditorType,
|
|
12
|
+
a as MAX_DEFAULT_TEMPLATE_ID,
|
|
13
|
+
E as ModuleFolderDefaults,
|
|
11
14
|
e as TemplateTypes
|
|
12
15
|
};
|
|
@@ -53,7 +53,7 @@ class P extends E {
|
|
|
53
53
|
if (!m)
|
|
54
54
|
return;
|
|
55
55
|
const g = m.getInnerHTML().trim() || "", C = m.getInnerText().trim() || "", _ = this._removeCurrencySymbol(C, o), S = this._buildPriceContent(_, n, l), b = g.replace(C, f(S));
|
|
56
|
-
i.modifyHtml(m).setInnerHtml(b)
|
|
56
|
+
i.modifyHtml(m).setInnerHtml(b);
|
|
57
57
|
}), i.apply(new B(
|
|
58
58
|
`Updated currency symbol to ${n || "removed"}`
|
|
59
59
|
));
|