@useinsider/guido 3.15.1-beta.6da4177 → 3.16.0-beta.0faee0c

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 (59) hide show
  1. package/dist/@types/config/schemas.js +108 -92
  2. package/dist/components/Guido.vue.js +1 -1
  3. package/dist/components/Guido.vue2.js +78 -75
  4. package/dist/composables/useActionsApi.js +30 -22
  5. package/dist/composables/useEmailTemplateApplier.js +25 -23
  6. package/dist/composables/useHtmlValidator.js +85 -83
  7. package/dist/composables/useStripo.js +30 -29
  8. package/dist/composables/useTimerClone.js +21 -19
  9. package/dist/config/migrator/checkboxMigrator.js +20 -19
  10. package/dist/config/migrator/radioButtonMigrator.js +26 -25
  11. package/dist/extensions/Blocks/Checkbox/constants/controlIds.js +4 -0
  12. package/dist/extensions/Blocks/Checkbox/constants/selectors.js +6 -0
  13. package/dist/extensions/Blocks/Checkbox/controls/blockBackground/index.js +10 -0
  14. package/dist/extensions/Blocks/Checkbox/extension.js +6 -5
  15. package/dist/extensions/Blocks/Checkbox/settingsPanel.js +15 -14
  16. package/dist/extensions/Blocks/Checkbox/template.js +10 -9
  17. package/dist/extensions/Blocks/Items/block.js +44 -42
  18. package/dist/extensions/Blocks/Items/template.js +86 -86
  19. package/dist/extensions/Blocks/RadioButton/constants/controlIds.js +4 -0
  20. package/dist/extensions/Blocks/RadioButton/constants/selectors.js +6 -0
  21. package/dist/extensions/Blocks/RadioButton/controls/blockBackground/index.js +10 -0
  22. package/dist/extensions/Blocks/RadioButton/extension.js +5 -4
  23. package/dist/extensions/Blocks/RadioButton/settingsPanel.js +12 -11
  24. package/dist/extensions/Blocks/RadioButton/template.js +16 -9
  25. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +5 -9
  26. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +98 -113
  27. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +21 -0
  28. package/dist/extensions/Blocks/controlFactories.js +117 -115
  29. package/dist/guido.css +1 -1
  30. package/dist/library.js +11 -7
  31. package/dist/node_modules/valibot/dist/index.js +230 -216
  32. package/dist/public/trackingIds.js +8 -0
  33. package/dist/src/@types/config/schemas.d.ts +20 -0
  34. package/dist/src/composables/useActionsApi.d.ts +1 -1
  35. package/dist/src/composables/useConfig.d.ts +4 -0
  36. package/dist/src/extensions/Blocks/Checkbox/constants/controlIds.d.ts +7 -0
  37. package/dist/src/extensions/Blocks/Checkbox/constants/index.d.ts +10 -0
  38. package/dist/src/extensions/Blocks/Checkbox/constants/selectors.d.ts +16 -0
  39. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +14 -0
  40. package/dist/src/extensions/Blocks/RadioButton/constants/controlIds.d.ts +7 -0
  41. package/dist/src/extensions/Blocks/RadioButton/constants/index.d.ts +10 -0
  42. package/dist/src/extensions/Blocks/RadioButton/constants/selectors.d.ts +16 -0
  43. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +14 -0
  44. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -0
  45. package/dist/src/extensions/Blocks/_Boilerplate/constants/controlIds.d.ts +7 -0
  46. package/dist/src/extensions/Blocks/_Boilerplate/constants/index.d.ts +10 -0
  47. package/dist/src/extensions/Blocks/_Boilerplate/constants/selectors.d.ts +16 -0
  48. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +14 -0
  49. package/dist/src/library.d.ts +1 -0
  50. package/dist/src/public/trackingIds.d.ts +9 -0
  51. package/dist/src/stores/config.d.ts +36 -0
  52. package/dist/src/stores/editor.d.ts +25 -0
  53. package/dist/src/utils/linkTrackingIds.d.ts +30 -0
  54. package/dist/stores/editor.js +4 -1
  55. package/dist/stores/onboarding.js +11 -7
  56. package/dist/utils/linkTrackingIds.js +56 -0
  57. package/dist/utils/pairProductVariables.js +105 -99
  58. package/dist/utils/templatePreparation.js +72 -61
  59. package/package.json +5 -1
@@ -1,11 +1,11 @@
1
1
  import { useActionsApi as f } from "./useActionsApi.js";
2
- import { useHttp as w } from "./useHttp.js";
3
- import { useToaster as H } from "./useToaster.js";
4
- import { useStripoApi as y } from "../services/stripoApi.js";
5
- const O = () => {
6
- const { handleError: c } = H(), { getToken: u } = y(), { post: d } = w(), { updateHtmlAndCss: l } = f(), s = (t) => /esd-timer-id="(\d+)"/.test(t), i = async (t, e) => {
2
+ import { useHttp as H } from "./useHttp.js";
3
+ import { useToaster as h } from "./useToaster.js";
4
+ import { useStripoApi as k } from "../services/stripoApi.js";
5
+ const S = () => {
6
+ const { handleError: c } = h(), { getToken: l } = k(), { post: p } = H(), { updateHtmlAndCss: u } = f(), s = (t) => /esd-timer-id="(\d+)"/.test(t), i = async (t, e) => {
7
7
  try {
8
- return (await d(
8
+ return (await p(
9
9
  "https://plugins.stripo.email/api/v1/timers/clone",
10
10
  { html: t },
11
11
  {
@@ -25,29 +25,31 @@ const O = () => {
25
25
  cloneTimersOnSave: async (t) => {
26
26
  if (!s(t))
27
27
  return t;
28
- const e = await u();
28
+ const e = await l();
29
29
  return e && await i(t, e) || t;
30
30
  },
31
31
  updateTimersOnLoad: async (t) => {
32
- var e, r, o, m;
32
+ var e, r, n, d;
33
33
  try {
34
- const n = (r = (e = window.UIEditor) == null ? void 0 : e.getHtml) == null ? void 0 : r.call(e);
35
- if (!n || !s(n))
34
+ const o = (r = (e = window.UIEditor) == null ? void 0 : e.getHtml) == null ? void 0 : r.call(e);
35
+ if (!o || !s(o))
36
36
  return;
37
- const p = await t();
38
- if (!p)
37
+ const m = await t();
38
+ if (!m)
39
39
  return;
40
- const a = await i(n, p);
41
- if (!a || a === n)
40
+ const a = await i(o, m);
41
+ if (!a || a === o)
42
42
  return;
43
- const T = ((m = (o = window.UIEditor) == null ? void 0 : o.getCss) == null ? void 0 : m.call(o)) || "";
44
- l(a, T);
45
- } catch (n) {
46
- c(n, "Failed to update timer blocks");
43
+ const T = ((d = (n = window.UIEditor) == null ? void 0 : n.getCss) == null ? void 0 : d.call(n)) || "";
44
+ u(a, T).catch((w) => {
45
+ console.warn("Editor did not acknowledge the timer-block update.", w);
46
+ });
47
+ } catch (o) {
48
+ c(o, "Failed to update timer blocks");
47
49
  }
48
50
  }
49
51
  };
50
52
  };
51
53
  export {
52
- O as useTimerClone
54
+ S as useTimerClone
53
55
  };
@@ -1,36 +1,37 @@
1
- var h = Object.defineProperty;
2
- var g = (r, t, e) => t in r ? h(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var l = (r, t, e) => g(r, typeof t != "symbol" ? t + "" : t, e);
4
- import f from "../../extensions/Blocks/Checkbox/template.js";
5
- import { extractTextFromElement as m, buildTextBlock as p } from "./textBlockMigration.js";
6
- class C {
1
+ var g = Object.defineProperty;
2
+ var x = (r, t, e) => t in r ? g(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var m = (r, t, e) => x(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import { CSS_CLASS_CHECKBOX_BLOCK as b, CSS_CLASS_CHECKBOX_BLOCK_V2 as T, BLOCK_ROOT_SELECTOR as f } from "../../extensions/Blocks/Checkbox/constants/selectors.js";
5
+ import h from "../../extensions/Blocks/Checkbox/template.js";
6
+ import { extractTextFromElement as p, buildTextBlock as C } from "./textBlockMigration.js";
7
+ class O {
7
8
  constructor() {
8
- l(this, "parser");
9
+ m(this, "parser");
9
10
  this.parser = new DOMParser();
10
11
  }
11
12
  migrate(t) {
12
13
  try {
13
- const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.checkbox-block");
14
- if (n.length === 0)
14
+ const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll(`td.${b}`);
15
+ if (i.length === 0)
15
16
  return t;
16
- let i = !1;
17
- return n.forEach((o) => {
18
- if (o.classList.contains("checkbox-block-v2"))
17
+ let s = !1;
18
+ return i.forEach((o) => {
19
+ if (o.classList.contains(T))
19
20
  return;
20
- const b = o.getAttribute("id"), s = m(o, "ins-title"), a = m(o, "ins-description"), u = p(s, s.containerClass), x = p(a, a.containerClass), d = f.replace("{-{-TITLE-}-}", u).replace("{-{-DESCRIPTION-}-}", x), c = this.parser.parseFromString(
21
+ const l = o.getAttribute("id"), c = p(o, "ins-title"), a = p(o, "ins-description"), u = C(c, c.containerClass), S = C(a, a.containerClass), d = h.replace("{-{-TITLE-}-}", u).replace("{-{-DESCRIPTION-}-}", S), n = this.parser.parseFromString(
21
22
  `<table id="tempDoc"><tbody><tr>${d}</tr></tbody></table>`,
22
23
  "text/html"
23
- ).querySelector(".checkbox-block-v2");
24
- c && o.parentNode && (c.setAttribute("id", b || ""), o.parentNode.replaceChild(c, o), i = !0);
25
- }), i ? e.documentElement.outerHTML : t;
24
+ ).querySelector(f);
25
+ n && o.parentNode && (n.setAttribute("id", l || ""), o.parentNode.replaceChild(n, o), s = !0);
26
+ }), s ? e.documentElement.outerHTML : t;
26
27
  } catch (e) {
27
28
  return console.error("CheckboxMigrator failed:", e), t;
28
29
  }
29
30
  }
30
31
  }
31
- function E(r) {
32
- return new C().migrate(r);
32
+ function D(r) {
33
+ return new O().migrate(r);
33
34
  }
34
35
  export {
35
- E as migrateCheckbox
36
+ D as migrateCheckbox
36
37
  };
@@ -1,53 +1,54 @@
1
- var q = Object.defineProperty;
2
- var C = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var g = (o, t, e) => C(o, typeof t != "symbol" ? t + "" : t, e);
1
+ var R = Object.defineProperty;
2
+ var b = (n, t, e) => t in n ? R(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var g = (n, t, e) => b(n, typeof t != "symbol" ? t + "" : t, e);
4
+ import { CSS_CLASS_RADIO_BUTTON_BLOCK as C, CSS_CLASS_RADIO_BUTTON_BLOCK_V2 as T, BLOCK_ROOT_SELECTOR as A } from "../../extensions/Blocks/RadioButton/constants/selectors.js";
4
5
  import N from "../../extensions/Blocks/RadioButton/template.js";
5
- import { extractTextFromElement as b, buildTextBlock as f } from "./textBlockMigration.js";
6
- class R {
6
+ import { extractTextFromElement as S, buildTextBlock as f } from "./textBlockMigration.js";
7
+ class _ {
7
8
  constructor() {
8
9
  g(this, "parser");
9
10
  this.parser = new DOMParser();
10
11
  }
11
12
  migrate(t) {
12
13
  try {
13
- const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.radio-button-block"), a = e.querySelectorAll("td.radio-button-v2");
14
- if (n.length === 0 && a.length === 0)
14
+ const e = this.parser.parseFromString(t, "text/html"), o = e.querySelectorAll(`td.${C}`), a = e.querySelectorAll(`td.${T}`);
15
+ if (o.length === 0 && a.length === 0)
15
16
  return t;
16
- let i = !1;
17
- return n.forEach((r) => {
18
- if (r.classList.contains("radio-button-v2"))
17
+ let s = !1;
18
+ return o.forEach((r) => {
19
+ if (r.classList.contains(T))
19
20
  return;
20
- const s = r.getAttribute("id"), c = b(r, "ins-title"), d = b(r, "ins-description"), u = b(r, "ins-subscribe"), l = b(r, "ins-unsubscribe"), p = f(c, c.containerClass), m = f(d, d.containerClass), h = f(u), S = f(l), T = N.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", h).replace("{-{-NO-}-}", S), y = this.parser.parseFromString(
21
- `<table id="tempDoc"><tbody><tr>${T}</tr></tbody></table>`,
21
+ const i = r.getAttribute("id"), c = S(r, "ins-title"), p = S(r, "ins-description"), l = S(r, "ins-subscribe"), u = S(r, "ins-unsubscribe"), d = f(c, c.containerClass), m = f(p, p.containerClass), h = f(l), L = f(u), O = N.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", h).replace("{-{-NO-}-}", L), y = this.parser.parseFromString(
22
+ `<table id="tempDoc"><tbody><tr>${O}</tr></tbody></table>`,
22
23
  "text/html"
23
- ).querySelector(".radio-button-v2");
24
- y && r.parentNode && (y.setAttribute("id", s || ""), r.parentNode.replaceChild(y, r), i = !0);
25
- }), i = this.healRadioButtonV2(e) || i, i ? e.documentElement.outerHTML : t;
24
+ ).querySelector(A);
25
+ y && r.parentNode && (y.setAttribute("id", i || ""), r.parentNode.replaceChild(y, r), s = !0);
26
+ }), s = this.healRadioButtonV2(e) || s, s ? e.documentElement.outerHTML : t;
26
27
  } catch (e) {
27
28
  return console.error("RadioButtonMigrator failed:", e), t;
28
29
  }
29
30
  }
30
31
  healRadioButtonV2(t) {
31
32
  let e = !1;
32
- return t.querySelectorAll("td.radio-button-v2").forEach((n) => {
33
+ return t.querySelectorAll(`td.${T}`).forEach((o) => {
33
34
  var m;
34
- n.classList.contains("radio-button-block") || (n.classList.add("radio-button-block"), e = !0);
35
- const a = n.querySelector("input#radioYes"), i = n.querySelector("input#radioNo");
36
- if (!a || !i)
35
+ o.classList.contains(C) || (o.classList.add(C), e = !0);
36
+ const a = o.querySelector("input#radioYes"), s = o.querySelector("input#radioNo");
37
+ if (!a || !s)
37
38
  return;
38
39
  const r = ((m = a.parentElement) == null ? void 0 : m.querySelector(":scope > p")) || null;
39
40
  if (!r && !a.hasAttribute("align"))
40
41
  return;
41
- const s = a.closest("tr"), c = i.closest("tr");
42
- if (!s || !c || s === c || !s.parentNode)
42
+ const i = a.closest("tr"), c = s.closest("tr");
43
+ if (!i || !c || i === c || !i.parentNode)
43
44
  return;
44
- const d = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", u = c.cloneNode(!0), l = u.querySelector("input#radioNo"), p = u.querySelector("p");
45
- l && (l.setAttribute("id", "radioYes"), l.removeAttribute("align")), p && (p.innerHTML = d), s.parentNode.replaceChild(u, s), e = !0;
45
+ const p = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", l = c.cloneNode(!0), u = l.querySelector("input#radioNo"), d = l.querySelector("p");
46
+ u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), d && (d.innerHTML = p), i.parentNode.replaceChild(l, i), e = !0;
46
47
  }), e;
47
48
  }
48
49
  }
49
- function w(o) {
50
- return new R().migrate(o);
50
+ function w(n) {
51
+ return new _().migrate(n);
51
52
  }
52
53
  export {
53
54
  w as migrateRadioButton
@@ -0,0 +1,4 @@
1
+ var r = /* @__PURE__ */ ((o) => (o.BLOCK_BACKGROUND = "checkbox-block-background-color-control", o))(r || {});
2
+ export {
3
+ r as CheckboxControlId
4
+ };
@@ -0,0 +1,6 @@
1
+ const c = "checkbox-block", C = "checkbox-block-v2", S = `.${C}`;
2
+ export {
3
+ S as BLOCK_ROOT_SELECTOR,
4
+ c as CSS_CLASS_CHECKBOX_BLOCK,
5
+ C as CSS_CLASS_CHECKBOX_BLOCK_V2
6
+ };
@@ -0,0 +1,10 @@
1
+ import { createBlockBackgroundColorControl as o } from "../../../controlFactories.js";
2
+ import { CheckboxControlId as r } from "../../constants/controlIds.js";
3
+ import { BLOCK_ROOT_SELECTOR as C } from "../../constants/selectors.js";
4
+ const k = o(
5
+ r.BLOCK_BACKGROUND,
6
+ C
7
+ );
8
+ export {
9
+ k as CheckboxBlockBackgroundControl
10
+ };
@@ -1,9 +1,10 @@
1
1
  import { ExtensionBuilder as o } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { CheckboxBlock as t } from "./block.js";
3
- import { CheckboxControl as e } from "./control.js";
4
- import { CheckboxIconsRegistry as r } from "./iconsRegistry.js";
5
- import { CheckboxBlockSettings as i } from "./settingsPanel.js";
6
- const d = new o().addBlock(t).withSettingsPanelRegistry(i).addControl(e).withIconsRegistry(r).build();
3
+ import { CheckboxControl as r } from "./control.js";
4
+ import { CheckboxBlockBackgroundControl as e } from "./controls/blockBackground/index.js";
5
+ import { CheckboxIconsRegistry as i } from "./iconsRegistry.js";
6
+ import { CheckboxBlockSettings as n } from "./settingsPanel.js";
7
+ const C = new o().addBlock(t).withSettingsPanelRegistry(n).addControl(r).addControl(e).withIconsRegistry(i).build();
7
8
  export {
8
- d as default
9
+ C as default
9
10
  };
@@ -1,25 +1,26 @@
1
- import { SettingsPanelRegistry as C, SettingsPanelTab as t, SettingsTab as e, ContainerControls as n, TextControls as r } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CHECKBOX_BLOCK_ID as s } from "./block.js";
3
- import { CHECKBOX_CONTROL_BLOCK_ID as T } from "./control.js";
4
- class l extends C {
5
- registerBlockControls(o) {
6
- o[s] = [
7
- new t(
8
- e.SETTINGS,
1
+ import { SettingsPanelRegistry as r, SettingsPanelTab as o, SettingsTab as t, ContainerControls as C } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CHECKBOX_BLOCK_ID as n } from "./block.js";
3
+ import { CheckboxControlId as i } from "./constants/controlIds.js";
4
+ import { CHECKBOX_CONTROL_BLOCK_ID as s } from "./control.js";
5
+ class T extends r {
6
+ registerBlockControls(e) {
7
+ e[n] = [
8
+ new o(
9
+ t.SETTINGS,
9
10
  [
10
- T,
11
- n.EXTERNAL_INDENTS
11
+ s,
12
+ C.EXTERNAL_INDENTS
12
13
  ]
13
14
  ),
14
- new t(
15
- e.STYLES,
15
+ new o(
16
+ t.STYLES,
16
17
  [
17
- r.TEXT_BLOCK_BACKGROUND_COLOR
18
+ i.BLOCK_BACKGROUND
18
19
  ]
19
20
  )
20
21
  ];
21
22
  }
22
23
  }
23
24
  export {
24
- l as CheckboxBlockSettings
25
+ T as CheckboxBlockSettings
25
26
  };
@@ -1,9 +1,10 @@
1
1
  import { BlockType as t } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CSS_CLASS_CHECKBOX_BLOCK as l, CSS_CLASS_CHECKBOX_BLOCK_V2 as a } from "./constants/selectors.js";
2
3
  const e = {
3
4
  TITLE: "Unsubscribe From All Email Lists",
4
5
  DESCRIPTION: "You will still receive important transactional and billing-related emails."
5
- }, l = `
6
- <td align="left" class="checkbox-block checkbox-block-v2 esd-block-checkbox es-p20">
6
+ }, i = `
7
+ <td align="left" class="${l} ${a} esd-block-checkbox es-p20">
7
8
  <table cellpadding="0" cellspacing="0" role="presentation" width="100%">
8
9
  <tbody>
9
10
  <tr>
@@ -26,13 +27,13 @@ const e = {
26
27
  </tbody>
27
28
  </table>
28
29
  </td>
29
- `, o = `
30
+ `, d = `
30
31
  <td
31
32
  align="left"
32
33
  esd-extension-block-id="checkbox-block"
33
34
  class="
34
- checkbox-block
35
- checkbox-block-v2
35
+ ${l}
36
+ ${a}
36
37
  esd-block-checkbox
37
38
  esd-checkbox-block
38
39
  esd-extension-block es-p20"
@@ -60,10 +61,10 @@ const e = {
60
61
  </table>
61
62
  </td>
62
63
  `;
63
- function a() {
64
- return l.replace("{-{-TITLE-}-}", `<p path="1">${e.TITLE}</p>`).replace("{-{-DESCRIPTION-}-}", `<p path="1">${e.DESCRIPTION}</p>`);
64
+ function n() {
65
+ return i.replace("{-{-TITLE-}-}", `<p path="1">${e.TITLE}</p>`).replace("{-{-DESCRIPTION-}-}", `<p path="1">${e.DESCRIPTION}</p>`);
65
66
  }
66
67
  export {
67
- o as default,
68
- a as getDefaultTemplate
68
+ d as default,
69
+ n as getDefaultTemplate
69
70
  };
@@ -1,12 +1,12 @@
1
- import { BlockId as f } from "../../../enums/block.js";
2
- import { useOnboardingStore as g } from "../../../stores/onboarding.js";
3
- import { getMigrationBannerHtml as y } from "../../../utils/migrationBannerHtml.js";
4
- import { Block as I, BlockCompositionType as C, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { SETTINGS_ENUMS as d, DefaultConfigValues as m } from "./enums/settingsEnums.js";
6
- import { getDefaultTemplate as b } from "./template.js";
7
- import { getItemsBlockContainer as l, getItemsBlockConfig as u, deriveItemNumber as h, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
- const p = f.Items;
9
- class O extends I {
1
+ import { BlockId as g } from "../../../enums/block.js";
2
+ import { useOnboardingStore as y } from "../../../stores/onboarding.js";
3
+ import { getMigrationBannerHtml as I } from "../../../utils/migrationBannerHtml.js";
4
+ import { Block as C, BlockCompositionType as b, ModificationDescription as c } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { SETTINGS_ENUMS as l, DefaultConfigValues as d } from "./enums/settingsEnums.js";
6
+ import { getDefaultTemplate as h } from "./template.js";
7
+ import { getItemsBlockContainer as u, getItemsBlockConfig as f, deriveItemNumber as D, getDefaultItemsBlockConfig as N } from "./utils/nodeConfigUtils.js";
8
+ const p = g.Items;
9
+ class E extends C {
10
10
  getId() {
11
11
  return p;
12
12
  }
@@ -14,7 +14,7 @@ class O extends I {
14
14
  return "items-icon";
15
15
  }
16
16
  getBlockCompositionType() {
17
- return C.CONTAINER;
17
+ return b.CONTAINER;
18
18
  }
19
19
  getName() {
20
20
  return this.api.translate("Items");
@@ -23,20 +23,20 @@ class O extends I {
23
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
24
24
  }
25
25
  getSettingsPanelTitleHtml() {
26
- return y(
26
+ return I(
27
27
  p,
28
28
  this.api.translate("Items"),
29
29
  this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
30
30
  );
31
31
  }
32
32
  getTemplate() {
33
- return b({
34
- orientation: d.ORIENTATION.VERTICAL,
35
- itemsType: d.ITEMS_TYPE.CART_ITEMS,
33
+ return h({
34
+ orientation: l.ORIENTATION.VERTICAL,
35
+ itemsType: l.ITEMS_TYPE.CART_ITEMS,
36
36
  itemId: "{{Abandoned Cart Item (1) Url}}",
37
- currencySymbol: m.productPriceCurrencySymbolControlValue,
38
- currencyLocation: m.productPriceCurrencyLocationControlValue,
39
- formattedPrice: m.productPriceFormattedControlValue === "1"
37
+ currencySymbol: d.productPriceCurrencySymbolControlValue,
38
+ currencyLocation: d.productPriceCurrencyLocationControlValue,
39
+ formattedPrice: d.productPriceFormattedControlValue === "1"
40
40
  });
41
41
  }
42
42
  allowInnerBlocksDND() {
@@ -45,23 +45,23 @@ class O extends I {
45
45
  canBeSavedAsModule() {
46
46
  return !0;
47
47
  }
48
- onCreated(e) {
49
- const t = this.api.getDocumentModifier(), o = this.api.getDocumentRootCssNode();
50
- o.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(o).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
- const i = l(e);
52
- if (!i)
48
+ onCreated(n) {
49
+ const t = this.api.getDocumentModifier(), a = this.api.getDocumentRootCssNode();
50
+ a.querySelector('[product-attr="imageSrc"] img') || t.modifyCss(a).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
51
+ const e = u(n);
52
+ if (!e)
53
53
  return;
54
- const r = i.getNodeConfig(), s = r && Object.keys(r).length > 0, n = u(e);
55
- if (n != null && n.initialized)
56
- if (s)
57
- n.blockInstanceId || this.api.getDocumentModifier().modifyHtml(i).setNodeConfig({ ...n, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
54
+ const o = e.getNodeConfig(), r = o && Object.keys(o).length > 0, i = f(n);
55
+ if (i != null && i.initialized)
56
+ if (r)
57
+ i.blockInstanceId || this.api.getDocumentModifier().modifyHtml(e).setNodeConfig({ ...i, blockInstanceId: String(Date.now()) }).apply(new c("Assign block instance ID to block"));
58
58
  else {
59
- const a = this.api.getDocumentModifier();
60
- a.modifyHtml(i).setNodeConfig(n), this._stampProductTdDomAttributes(i, n, a), a.apply(new c("Migrate legacy config to nodeConfig"));
59
+ const s = this.api.getDocumentModifier();
60
+ s.modifyHtml(e).setNodeConfig(i), this._stampProductTdDomAttributes(e, i, s), s.apply(new c("Migrate legacy config to nodeConfig"));
61
61
  }
62
62
  else {
63
- const a = N();
64
- this.api.getDocumentModifier().modifyHtml(i).setNodeConfig(a).apply(new c("Initialize Items block with default configuration")), g().startOnboarding("itemsOnboarding");
63
+ const s = N(), m = this.api.getDocumentModifier();
64
+ m.modifyHtml(e).setNodeConfig(s), this._stampProductTdDomAttributes(e, s, m, !0), m.apply(new c("Initialize Items block with default configuration")), y().startOnboarding("itemsOnboarding");
65
65
  }
66
66
  }
67
67
  /**
@@ -70,18 +70,18 @@ class O extends I {
70
70
  * into nodeConfig, so without this a reused module would reset to defaults.
71
71
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
72
72
  */
73
- onDocumentChanged(e) {
74
- const t = l(e);
73
+ onDocumentChanged(n) {
74
+ const t = u(n);
75
75
  if (!t)
76
76
  return;
77
- const o = t.getNodeConfig();
78
- if (o && Object.keys(o).length > 0)
77
+ const a = t.getNodeConfig();
78
+ if (a && Object.keys(a).length > 0)
79
79
  return;
80
- const r = u(e);
81
- if (!(r != null && r.initialized))
80
+ const o = f(n);
81
+ if (!(o != null && o.initialized))
82
82
  return;
83
- const s = this.api.getDocumentModifier();
84
- s.modifyHtml(t).setNodeConfig(r), this._stampProductTdDomAttributes(t, r, s), s.apply(new c("Recover Items block config from saved module"));
83
+ const r = this.api.getDocumentModifier();
84
+ r.modifyHtml(t).setNodeConfig(o), this._stampProductTdDomAttributes(t, o, r), r.apply(new c("Recover Items block config from saved module"));
85
85
  }
86
86
  /**
87
87
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -91,12 +91,14 @@ class O extends I {
91
91
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
92
92
  * relies on this td-level fallback in pairProductVariables.
93
93
  */
94
- _stampProductTdDomAttributes(e, t, o) {
95
- const i = h(t.itemsSelectValue, t.type);
96
- o.modifyHtml(e).setAttribute("data-type", t.type), o.modifyHtml(e).setAttribute("data-number", i), o.modifyHtml(e).setAttribute("data-nodup", String(t.priceHideDiscount));
94
+ _stampProductTdDomAttributes(n, t, a, e = !1) {
95
+ const o = D(t.itemsSelectValue, t.type), r = (i, s) => {
96
+ e && n.getAttribute(i) || a.modifyHtml(n).setAttribute(i, s);
97
+ };
98
+ r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
97
99
  }
98
100
  }
99
101
  export {
100
102
  p as BLOCK_ID,
101
- O as ItemsBlock
103
+ E as ItemsBlock
102
104
  };