@useinsider/guido 3.9.0-beta.fd95a10 → 3.9.1-beta.1211472

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/components/organisms/header/EditorToolbar.vue.js +2 -2
  2. package/dist/components/organisms/header/EditorToolbar.vue2.js +6 -7
  3. package/dist/composables/useCortexBlueprintBridge.js +35 -48
  4. package/dist/composables/useEmailTemplateApplier.js +11 -9
  5. package/dist/config/compiler/utils/recommendationCompilerUtils.js +153 -114
  6. package/dist/config/migrator/itemsBlockMigrator.js +159 -114
  7. package/dist/config/migrator/unsubscribeMigrator.js +89 -67
  8. package/dist/extensions/Blocks/Items/block.js +57 -37
  9. package/dist/extensions/Blocks/Items/controls/name/trimming.js +17 -18
  10. package/dist/extensions/Blocks/Items/controls/settingsControl.js +67 -78
  11. package/dist/extensions/Blocks/Items/layouts/horizontal.html.js +13 -9
  12. package/dist/extensions/Blocks/Items/layouts/vertical.html.js +26 -14
  13. package/dist/extensions/Blocks/Items/template.js +245 -247
  14. package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +53 -45
  15. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +15 -15
  16. package/dist/guido.css +1 -1
  17. package/dist/package.json.js +1 -1
  18. package/dist/src/composables/useCortexBlueprintBridge.d.ts +5 -2
  19. package/dist/src/composables/useEmailTemplateApplier.d.ts +8 -3
  20. package/dist/src/extensions/Blocks/Items/block.d.ts +9 -0
  21. package/dist/src/extensions/Blocks/Items/template.d.ts +7 -0
  22. package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +12 -0
  23. package/package.json +2 -2
  24. package/dist/components/organisms/header/AiStatusPill.vue.js +0 -18
  25. package/dist/components/organisms/header/AiStatusPill.vue2.js +0 -17
  26. package/dist/composables/useAiStatus.js +0 -12
  27. package/dist/src/components/organisms/header/AiStatusPill.vue.d.ts +0 -2
  28. package/dist/src/composables/useAiStatus.d.ts +0 -25
  29. package/dist/src/stores/ai-status.d.ts +0 -24
  30. package/dist/stores/ai-status.js +0 -15
@@ -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" }), o(t.AiStatusPill)], 1);
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);
7
7
  }, d = [], l = /* @__PURE__ */ s(
8
8
  i,
9
9
  n,
10
10
  d,
11
11
  !1,
12
12
  null,
13
- "ec30d292"
13
+ "173c3a40"
14
14
  );
15
15
  const _ = l.exports;
16
16
  export {
@@ -4,15 +4,14 @@ 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 "./AiStatusPill.vue.js";
8
- import f from "./ViewOptions.vue.js";
9
- const x = /* @__PURE__ */ p({
7
+ import a from "./ViewOptions.vue.js";
8
+ const h = /* @__PURE__ */ p({
10
9
  __name: "EditorToolbar",
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 };
10
+ setup(f) {
11
+ const o = d(), e = l(), { openPreviewMode: t, closePreviewMode: r } = m(), n = i(() => o.isPreviewModeOpen ? e("newsletter.close-email-preview") : e("newsletter.email-preview")), s = i(() => o.isCodeEditorOpen ? e("newsletter.close-html-editor") : e("newsletter.html-editor"));
12
+ return { __sfc: !0, editorStore: o, trans: e, openPreviewMode: t, closePreviewMode: r, previewTooltipText: n, codeEditorTooltipText: s, handlePreviewToggle: () => o.isPreviewModeOpen ? r() : t(), getTooltipOptions: w, InButtonV2: c, ViewOptions: a };
14
13
  }
15
14
  });
16
15
  export {
17
- x as default
16
+ h as default
18
17
  };
@@ -1,83 +1,70 @@
1
- import { useAiStatus as v } from "./useAiStatus.js";
2
- import { useEmailTemplateApplier as I, resetEmailTemplateApplier as B } from "./useEmailTemplateApplier.js";
3
- import { useToaster as M } from "./useToaster.js";
1
+ import { useEmailTemplateApplier as w, resetEmailTemplateApplier as _ } from "./useEmailTemplateApplier.js";
2
+ import { useToaster as I } from "./useToaster.js";
4
3
  import { useTranslations as P } from "./useTranslations.js";
5
- import { ToasterTypeOptions as D } from "../enums/toaster.js";
6
- import { getActivePinia as L } from "pinia";
7
- import { watch as N, onUnmounted as x } from "vue";
8
- const C = "email_template", G = "chat", R = "guido:debug:ai", U = /* @__PURE__ */ new Set(["done", "error", "cancelled"]), Y = () => {
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 = () => {
9
8
  if (typeof window > "u")
10
9
  return !1;
11
10
  try {
12
- return window.localStorage.getItem(R) === "1";
11
+ return window.localStorage.getItem(M) === "1";
13
12
  } catch {
14
13
  return !1;
15
14
  }
16
- }, q = () => {
17
- const s = L();
18
- if (!s)
15
+ }, H = () => {
16
+ const c = v();
17
+ if (!c)
19
18
  return;
20
- const c = s._s, p = c == null ? void 0 : c.get(G);
19
+ const l = c._s, p = l == null ? void 0 : l.get(L);
21
20
  if (!p)
22
21
  return;
23
- const { applyTemplate: T, applyTemplateDebounced: A } = I(), { showToaster: E } = M(), l = v(), y = P(), h = (r, t) => {
22
+ const { markPending: d, applyTemplate: f, applyTemplateDebounced: T } = w(), { showToaster: h } = I(), y = P(), A = (r, t) => {
24
23
  const e = y(r);
25
24
  return e === r ? t : e;
26
- }, a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Set(), d = Y(), m = (r, t) => {
27
- d && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
25
+ }, i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), u = R(), E = (r, t) => {
26
+ u && console.debug(`[guido:cortex] msg=${r ?? "?"} type=${(t == null ? void 0 : t.type) ?? "?"}`, t);
28
27
  }, b = (r) => {
29
- if (r.blueprintType !== C)
28
+ if (r.blueprintType !== x)
30
29
  return;
31
30
  const t = r.blueprintId, e = r.blueprintData;
32
31
  if (!t || !(e != null && e.html))
33
32
  return;
34
- const n = a.get(t);
35
- n === void 0 ? (a.set(t, e.html), T(t, e)) : n !== e.html && (a.set(t, e.html), A(t, e));
36
- }, f = (r) => r === void 0 || u.has(r) ? !1 : (u.add(r), E({
37
- type: D.Alert,
38
- message: h("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
39
- }), !0), S = (r) => {
40
- const t = r.toolName ?? r.name ?? r.tool;
41
- return typeof t == "string" ? t : "";
42
- }, _ = (r) => {
43
- const t = r[r.length - 1];
44
- if (!t) {
45
- l.stop();
33
+ if (!r.applyRequested) {
34
+ d(t);
46
35
  return;
47
36
  }
48
- const e = Array.isArray(t.segments) ? t.segments : [];
49
- if (t.isError === !0 || t.isCancelled === !0 || e.some((i) => !!i && U.has(i.type ?? ""))) {
50
- l.stop();
51
- return;
52
- }
53
- const o = [...e].reverse().find((i) => (i == null ? void 0 : i.type) === "tool_call");
54
- o && l.start(S(o));
55
- }, w = N(
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), h({
40
+ type: S.Alert,
41
+ message: A("newsletter.ai-template-failed", "AI couldn't generate the template. Please try again.")
42
+ }), !0), m = B(
56
43
  () => p.messages,
57
44
  (r) => {
58
- Array.isArray(r) && (_(r), r.forEach((t) => {
45
+ Array.isArray(r) && r.forEach((t) => {
59
46
  const e = t == null ? void 0 : t.id;
60
- (t == null ? void 0 : t.isError) === !0 && f(e) && d && console.debug(`[guido:cortex] message-level error id=${e}`, t);
61
- const n = t == null ? void 0 : t.segments;
62
- Array.isArray(n) && n.forEach((o) => {
63
- if (o)
64
- switch (m(e, o), o.type) {
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 (E(e, n), n.type) {
65
52
  case "blueprint":
66
- b(o);
53
+ b(n);
67
54
  break;
68
55
  case "error":
69
- f(e);
56
+ s(e);
70
57
  break;
71
58
  }
72
59
  });
73
- }));
60
+ });
74
61
  },
75
62
  { deep: !0, immediate: !0 }
76
63
  );
77
- x(() => {
78
- w(), a.clear(), u.clear(), l.stop(), B();
64
+ D(() => {
65
+ m(), i.clear(), a.clear(), _();
79
66
  });
80
67
  };
81
68
  export {
82
- q as useCortexBlueprintBridge
69
+ H as useCortexBlueprintBridge
83
70
  };
@@ -1,10 +1,12 @@
1
- import { useActionsApi as u } from "./useActionsApi.js";
2
- import { useToaster as T } from "./useToaster.js";
3
- import { useTranslations as f } from "./useTranslations.js";
1
+ import { useActionsApi as T } from "./useActionsApi.js";
2
+ import { useToaster as f } from "./useToaster.js";
3
+ import { useTranslations as y } from "./useTranslations.js";
4
4
  import { ToasterTypeOptions as n } from "../enums/toaster.js";
5
- import { ref as y } from "vue";
6
- const h = 250, s = y({}), o = {}, j = () => {
7
- const { updateHtmlAndCss: l } = u(), { showToaster: r } = T(), i = f(), c = (e, t, p) => {
5
+ import { ref as v } from "vue";
6
+ const h = 250, s = v({}), o = {}, j = () => {
7
+ const { updateHtmlAndCss: l } = T(), { showToaster: r } = f(), i = y(), u = (e) => {
8
+ s.value[e] === void 0 && (s.value = { ...s.value, [e]: "pending" });
9
+ }, c = (e, t, p) => {
8
10
  s.value = { ...s.value, [e]: "applying" };
9
11
  try {
10
12
  l(t, p), s.value = { ...s.value, [e]: "applied" }, r({
@@ -21,7 +23,7 @@ const h = 250, s = y({}), o = {}, j = () => {
21
23
  const t = o[e];
22
24
  t && (clearTimeout(t), delete o[e]);
23
25
  };
24
- return { applyStatus: s, applyTemplate: (e, t) => {
26
+ return { applyStatus: s, markPending: u, applyTemplate: (e, t) => {
25
27
  t.html && (m(e), c(e, t.html, t.css ?? ""));
26
28
  }, applyTemplateDebounced: (e, t) => {
27
29
  if (!t.html)
@@ -32,10 +34,10 @@ const h = 250, s = y({}), o = {}, j = () => {
32
34
  delete o[e], c(e, p, a);
33
35
  }, h);
34
36
  } };
35
- }, w = () => {
37
+ }, k = () => {
36
38
  Object.values(o).forEach(clearTimeout), Object.keys(o).forEach((l) => delete o[l]), s.value = {};
37
39
  };
38
40
  export {
39
- w as resetEmailTemplateApplier,
41
+ k as resetEmailTemplateApplier,
40
42
  j as useEmailTemplateApplier
41
43
  };
@@ -1,181 +1,220 @@
1
- import { useConfig as _ } from "../../../composables/useConfig.js";
2
- import { useRecommendation as g } from "../../../composables/useRecommendation.js";
3
- import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
- import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
- import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
6
- function b(e, n, t, o, c = "") {
7
- const i = `{{${c}${e}_${n}_${t}}}`, r = `{{${c}${e}_${n}_currency}}`;
8
- return o === "before" ? `${r} ${i}` : `${i} ${r}`;
9
- }
10
- function m(e) {
11
- let n = e;
12
- for (; n.children.length === 1; )
13
- [n] = n.children;
14
- return n;
15
- }
16
- function h(e, n, t, o, c, i) {
17
- switch (n) {
1
+ import { useConfig as q } from "../../../composables/useConfig.js";
2
+ import { useRecommendation as E } from "../../../composables/useRecommendation.js";
3
+ import { CSS_CLASS_RECO_BUTTON as w } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useRecommendationExtensionStore as R } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
5
+ import { isIgnoredRecommendationBlock as P } from "./recommendationIgnoreUtils.js";
6
+ function $(t, r, e, o, s = "") {
7
+ const i = `{{${s}${t}_${r}_${e}}}`, n = `{{${s}${t}_${r}_currency}}`;
8
+ return o === "before" ? `${n} ${i}` : `${i} ${n}`;
9
+ }
10
+ function b(t) {
11
+ let r = t;
12
+ for (; r.children.length === 1; )
13
+ [r] = r.children;
14
+ return r;
15
+ }
16
+ function S(t, r, e, o, s, i) {
17
+ switch (r) {
18
18
  case "productImage": {
19
- const r = e.querySelector("img");
20
- r && (r.setAttribute("src", `{{${i}${t}_${o}_image_url}}`), r.setAttribute("alt", `{{${i}${t}_${o}_name}}`));
21
- const s = e.querySelector("a");
22
- s && (s.setAttribute("href", `{{${i}${t}_${o}_url}}`), s.classList.add(q));
19
+ const n = t.querySelector("img");
20
+ n && (n.setAttribute("src", `{{${i}${e}_${o}_image_url}}`), n.setAttribute("alt", `{{${i}${e}_${o}_name}}`));
21
+ const c = t.querySelector("a");
22
+ c && (c.setAttribute("href", `{{${i}${e}_${o}_url}}`), c.classList.add(w));
23
23
  break;
24
24
  }
25
25
  case "productName": {
26
- const r = e.querySelector("p");
27
- r && (m(r).textContent = `{{${i}${t}_${o}_name}}`);
26
+ const n = t.querySelector("p");
27
+ n && (b(n).textContent = `{{${i}${e}_${o}_name}}`);
28
28
  break;
29
29
  }
30
30
  case "productPrice": {
31
- const r = e.querySelector(".product-price p") ?? e.querySelector("p");
32
- r && (m(r).textContent = b(
33
- t,
31
+ const n = t.querySelector(".product-price p") ?? t.querySelector("p");
32
+ n && (b(n).textContent = $(
33
+ e,
34
34
  o,
35
35
  "price",
36
- c,
36
+ s,
37
37
  i
38
38
  ));
39
- const s = e.querySelector(".product-old-price p");
40
- s && (m(s).textContent = b(
41
- t,
39
+ const c = t.querySelector(".product-old-price p");
40
+ c && (b(c).textContent = $(
41
+ e,
42
42
  o,
43
43
  "original_price",
44
- c,
44
+ s,
45
45
  i
46
46
  ));
47
47
  break;
48
48
  }
49
49
  case "productOldPrice": {
50
- const r = e.querySelector("p");
51
- r && (m(r).textContent = b(
52
- t,
50
+ const n = t.querySelector("p");
51
+ n && (b(n).textContent = $(
52
+ e,
53
53
  o,
54
54
  "original_price",
55
- c,
55
+ s,
56
56
  i
57
57
  ));
58
58
  break;
59
59
  }
60
60
  case "productButton": {
61
- const r = e.querySelector("a");
62
- r && r.setAttribute("href", `{{${i}${t}_${o}_url}}`);
61
+ const n = t.querySelector("a");
62
+ n && n.setAttribute("href", `{{${i}${e}_${o}_url}}`);
63
63
  break;
64
64
  }
65
65
  case "productOmnibusPrice": {
66
- const r = e.querySelector(".omnibus-price-value");
67
- if (r) {
68
- r.textContent = `{{${i}${t}_${o}_omnibus_price}}`;
69
- const s = r.closest("p");
70
- s && (s.setAttribute("product-attr", "omnibus_price"), s.setAttribute("composition", "true"));
66
+ const n = t.querySelector(".omnibus-price-value");
67
+ if (n) {
68
+ n.textContent = `{{${i}${e}_${o}_omnibus_price}}`;
69
+ const c = n.closest("p");
70
+ c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
71
71
  }
72
72
  break;
73
73
  }
74
74
  case "productOmnibusDiscount": {
75
- const r = e.querySelector(".omnibus-discount-value");
76
- if (r) {
77
- r.textContent = `{{${i}${t}_${o}_omnibus_discount}}`;
78
- const s = r.closest("p");
79
- s && (s.setAttribute("product-attr", "omnibus_discount"), s.setAttribute("composition", "true"));
75
+ const n = t.querySelector(".omnibus-discount-value");
76
+ if (n) {
77
+ n.textContent = `{{${i}${e}_${o}_omnibus_discount}}`;
78
+ const c = n.closest("p");
79
+ c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
80
80
  }
81
81
  break;
82
82
  }
83
83
  default: {
84
- const r = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
85
- if (r) {
86
- const s = r.getAttribute("product-attr"), a = r.querySelector("p");
87
- a && (m(a).textContent = `{{${i}${t}_${o}_${s}}}`);
84
+ const n = t.getAttribute("product-attr") ? t : t.querySelector("[product-attr]");
85
+ if (n) {
86
+ const c = n.getAttribute("product-attr"), l = n.querySelector("p");
87
+ l && (b(l).textContent = `{{${i}${e}_${o}_${c}}}`);
88
88
  }
89
89
  break;
90
90
  }
91
91
  }
92
92
  }
93
- function E(e, n, t, o) {
94
- e.querySelectorAll(".recommendation-product-row").forEach((i, r) => {
95
- i.querySelectorAll("[data-attribute-type]").forEach((a) => {
96
- const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
97
- p.length > 0 ? p.forEach((l) => {
98
- h(l, u, n, r, t, o);
99
- }) : h(a, u, n, r, t, o);
100
- });
93
+ const T = "name";
94
+ function _(t, r, e, o) {
95
+ const s = `${o}${r}_${e}_${T}`;
96
+ return {
97
+ open: t.createComment(`{% if ${s} and ${s} != "" %}`),
98
+ close: t.createComment("{% endif %}")
99
+ };
100
+ }
101
+ function B(t, r, e) {
102
+ return _(t, r, 0, e);
103
+ }
104
+ function L(t, r, e, o) {
105
+ if (!t.innerHTML.includes("{{"))
106
+ return;
107
+ const { open: s, close: i } = _(t.ownerDocument, r, e, o);
108
+ t.insertBefore(s, t.firstChild), t.appendChild(i);
109
+ }
110
+ function N(t, r, e, o) {
111
+ var n, c;
112
+ if (!t.innerHTML.includes("{{"))
113
+ return;
114
+ const { open: s, close: i } = _(t.ownerDocument, r, e, o);
115
+ (n = t.parentNode) == null || n.insertBefore(s, t), (c = t.parentNode) == null || c.insertBefore(i, t.nextSibling);
116
+ }
117
+ function v(t, r, e, o) {
118
+ t.querySelectorAll(".recommendation-product-row").forEach((i, n) => {
119
+ i.querySelectorAll("[data-attribute-type]").forEach((l) => {
120
+ const u = l.getAttribute("data-attribute-type") || "", p = l.querySelectorAll(".attribute-cell");
121
+ p.length > 0 ? p.forEach((a) => {
122
+ S(a, u, r, n, e, o);
123
+ }) : S(l, u, r, n, e, o);
124
+ }), N(i, r, n, o);
101
125
  });
102
126
  }
103
- function P(e, n, t, o) {
104
- const c = e.querySelectorAll(".recommendation-product-row");
105
- if (!c.length)
127
+ function O(t, r, e, o) {
128
+ const s = t.querySelectorAll(".recommendation-product-row");
129
+ if (!s.length)
106
130
  return;
107
- const [i] = c, r = i.querySelector("[data-attribute-type]"), s = r ? r.querySelectorAll(".attribute-cell").length : 1;
108
- c.forEach((a, u) => {
109
- a.querySelectorAll("[data-attribute-type]").forEach((l) => {
110
- const d = l.getAttribute("data-attribute-type") || "";
111
- l.querySelectorAll(".attribute-cell").forEach((A, $) => {
112
- const S = u * s + $;
113
- h(A, d, n, S, t, o);
131
+ const [i] = s, n = i.querySelector("[data-attribute-type]"), c = n ? n.querySelectorAll(".attribute-cell").length : 1;
132
+ s.forEach((l, u) => {
133
+ l.querySelectorAll("[data-attribute-type]").forEach((a) => {
134
+ const d = a.getAttribute("data-attribute-type") || "";
135
+ a.querySelectorAll(".attribute-cell").forEach((m, f) => {
136
+ const h = u * c + f;
137
+ S(m, d, r, h, e, o), L(m, r, h, o);
114
138
  });
115
139
  });
116
140
  });
117
141
  }
118
- function R(e, n, t, o) {
119
- e.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
120
- P(i, n, t, o);
142
+ function W(t, r, e, o) {
143
+ t.querySelectorAll(".ins-recommendation-product-container").forEach((i) => {
144
+ O(i, r, e, o);
121
145
  });
122
146
  }
123
- function O(e, n, t) {
124
- const o = e.getAttribute("data-layout") || "grid", c = e.getAttribute("currency-alignment") || "after";
125
- o === "list" ? E(e, n, c, t) : R(e, n, c, t);
126
- }
127
- function y(e, n, t) {
128
- const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), c = e.match(o);
129
- return c ? parseInt(c[1]) : t;
130
- }
131
- function T(e, n) {
132
- let t = e.parentElement;
133
- for (; t && t !== n; ) {
134
- if (t.tagName === "TD") {
135
- const o = t.getAttribute("width");
136
- if (o && o.endsWith("%") && parseFloat(o) < 100)
137
- return t;
138
- }
139
- t = t.parentElement;
147
+ function D(t, r, e) {
148
+ const o = t.getAttribute("data-layout") || "grid", s = t.getAttribute("currency-alignment") || "after";
149
+ o === "list" ? v(t, r, s, e) : W(t, r, s, e);
150
+ }
151
+ function A(t, r, e) {
152
+ const o = new RegExp(`${r}\\s*:\\s*(\\d+)\\s*px`, "i"), s = t.match(o);
153
+ return s ? parseInt(s[1]) : e;
154
+ }
155
+ function C(t) {
156
+ const r = t.trim();
157
+ return r.endsWith("%") ? parseFloat(r) < 100 : /^\d+(?:\.\d+)?(?:px)?$/.test(r) && parseInt(r) > 0;
158
+ }
159
+ function g(t) {
160
+ const r = t.getAttribute("width");
161
+ if (r && C(r))
162
+ return r.trim();
163
+ const e = (t.getAttribute("style") || "").match(/(?:^|[;\s])width\s*:\s*(\d+(?:\.\d+)?(?:px|%))/i);
164
+ return e && C(e[1]) ? e[1] : null;
165
+ }
166
+ function M(t, r) {
167
+ let e = t.parentElement;
168
+ for (; e && e !== r; ) {
169
+ if (e.tagName === "TD" && g(e))
170
+ return e;
171
+ e = e.parentElement;
140
172
  }
141
173
  return null;
142
174
  }
143
- function v(e) {
144
- const n = e.getAttribute("style") || "", t = y(n, "width", 600), o = y(n, "padding", 0) * 2, c = Math.max(0, t - o);
145
- c !== 0 && e.querySelectorAll("img.adapt-img").forEach((i) => {
175
+ function G(t) {
176
+ const r = t.getAttribute("style") || "", e = A(r, "width", 600), o = A(r, "padding", 0) * 2, s = Math.max(0, e - o);
177
+ s !== 0 && t.querySelectorAll("img.adapt-img").forEach((i) => {
146
178
  if (i.hasAttribute("width"))
147
179
  return;
148
- const r = T(i, e);
149
- if (!r)
180
+ const n = M(i, t);
181
+ if (!n)
150
182
  return;
151
- const s = r.getAttribute("width"), a = parseFloat(s), u = y(r.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(c * a / 100), l = Math.max(1, p - u);
152
- i.setAttribute("width", String(l));
153
- const d = i.getAttribute("style") || "";
154
- if (!/\bwidth\s*:\s*\d/i.test(d)) {
155
- const f = d && !d.trim().endsWith(";") ? "; " : "";
156
- i.setAttribute("style", `${d}${f}width: ${l}px`);
183
+ const c = g(n), l = A(n.getAttribute("style") || "", "padding", 0) * 2, u = c.endsWith("%") ? Math.floor(s * parseFloat(c) / 100) : parseInt(c), p = Math.max(1, u - l);
184
+ i.setAttribute("width", String(p));
185
+ const a = i.getAttribute("style") || "";
186
+ if (!/\bwidth\s*:\s*\d/i.test(a)) {
187
+ const d = a && !a.trim().endsWith(";") ? "; " : "";
188
+ i.setAttribute("style", `${a}${d}width: ${p}px`);
157
189
  }
158
190
  });
159
191
  }
160
- function W(e, n) {
161
- const t = e.match(/<!DOCTYPE[^>]*>/i);
162
- return (t ? `${t[0]}
163
- ` : "") + n.documentElement.outerHTML;
192
+ function H(t, r) {
193
+ const e = t.match(/<!DOCTYPE[^>]*>/i);
194
+ return (e ? `${e[0]}
195
+ ` : "") + r.documentElement.outerHTML;
164
196
  }
165
- function F(e) {
166
- const n = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), t = new DOMParser().parseFromString(n, "text/html"), o = t.querySelectorAll(".recommendation-block-v2");
197
+ function Y(t) {
198
+ const r = t.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(r, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
167
199
  if (!o.length)
168
- return e;
169
- const { buildCampaignUrl: c } = g(), i = C();
200
+ return t;
201
+ const { buildCampaignUrl: s } = E(), i = R();
170
202
  i.recommendationCampaignUrls = {};
171
- const { isFeatureEnabled: r } = _(), s = r("liquidSyntax") ? "reco_" : "";
203
+ const { isFeatureEnabled: n } = q(), c = n("liquidSyntax") ? "reco_" : "";
172
204
  return o.forEach((u) => {
173
- var l, d;
205
+ var a, d, y, m;
174
206
  const p = u.getAttribute("recommendation-id");
175
- p && ((l = u.parentNode) == null || l.insertBefore(t.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(t.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), c(p), w(u) || O(u, p, s), v(u));
176
- }), W(n, t).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
207
+ if (p) {
208
+ if ((a = u.parentNode) == null || a.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((f) => f.remove()), s(p), !P(u)) {
209
+ D(u, p, c);
210
+ const { open: f, close: h } = B(e, p, c);
211
+ (y = u.parentNode) == null || y.insertBefore(f, u), (m = u.parentNode) == null || m.insertBefore(h, u.nextSibling);
212
+ }
213
+ G(u);
214
+ }
215
+ }), H(r, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
177
216
  }
178
217
  export {
179
- b as formatPriceVariable,
180
- F as prepareRecommendationBlocks
218
+ $ as formatPriceVariable,
219
+ Y as prepareRecommendationBlocks
181
220
  };