@useinsider/guido 3.17.0-beta.ddd4dde → 3.17.0-beta.e23d5cd

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 (62) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +7 -6
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +77 -73
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
  7. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  8. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  9. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  10. package/dist/composables/useRecommendation.js +41 -34
  11. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  12. package/dist/config/migrator/recommendationMigrator.js +5 -4
  13. package/dist/enums/academy.js +2 -1
  14. package/dist/enums/date.js +5 -3
  15. package/dist/enums/extensions/recommendationBlock.js +3 -1
  16. package/dist/extensions/Blocks/Items/block.js +49 -98
  17. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
  18. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +11 -12
  19. package/dist/extensions/Blocks/Items/template.js +152 -153
  20. package/dist/extensions/Blocks/Recommendation/block.js +26 -21
  21. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -34
  22. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
  23. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +238 -185
  24. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
  25. package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
  26. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +165 -79
  27. package/dist/extensions/Blocks/common-control.js +22 -19
  28. package/dist/guido.css +1 -1
  29. package/dist/services/recommendationApi.js +69 -30
  30. package/dist/src/@types/config/schemas.d.ts +2 -0
  31. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  32. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
  33. package/dist/src/composables/useConfig.d.ts +2 -0
  34. package/dist/src/composables/useRecommendation.d.ts +1 -0
  35. package/dist/src/enums/academy.d.ts +1 -0
  36. package/dist/src/enums/date.d.ts +1 -0
  37. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  38. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -21
  39. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +2 -6
  40. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +44 -8
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
  43. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  44. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +150 -10
  45. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -0
  46. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  47. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  48. package/dist/src/services/recommendationApi.d.ts +4 -1
  49. package/dist/src/stores/config.d.ts +18 -0
  50. package/dist/src/stores/save-as-template.d.ts +4 -3
  51. package/dist/src/utils/genericUtil.d.ts +5 -0
  52. package/dist/static/assets/icons/line-change.svg.js +5 -0
  53. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  54. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  55. package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
  56. package/dist/utils/dateUtil.js +23 -10
  57. package/dist/utils/genericUtil.js +28 -27
  58. package/dist/utils/pairProductVariables.js +59 -60
  59. package/dist/utils/templatePreparation.js +35 -34
  60. package/package.json +2 -1
  61. package/dist/extensions/Blocks/Items/constants/currency.js +0 -11
  62. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -19
@@ -1,53 +1,67 @@
1
- import S from "../static/styles/base.css.js";
2
- import m from "../static/styles/components/alert-message.css.js";
3
- import e from "../static/styles/components/amp-block.css.js";
4
- import i from "../static/styles/components/base-input.css.js";
5
- import p from "../static/styles/components/button-group.css.js";
6
- import n from "../static/styles/components/button.css.js";
7
- import s from "../static/styles/components/combobox.css.js";
8
- import C from "../static/styles/components/counter.css.js";
9
- import f from "../static/styles/components/dropdown-menu.css.js";
10
- import a from "../static/styles/components/loader.css.js";
11
- import u from "../static/styles/components/narrow-panel.css.js";
12
- import c from "../static/styles/components/popup.css.js";
13
- import d from "../static/styles/components/switcher.css.js";
14
- import l from "../static/styles/components/tabs.css.js";
15
- import h from "../static/styles/components/tools.css.js";
16
- import w from "../static/styles/components/version-history.css.js";
17
- import y from "../static/styles/components/wide-panel.css.js";
18
- import B from "../static/styles/variables.css.js";
19
- const b = [
20
- B,
21
- // Must be on top
22
- S,
1
+ import S from "../static/assets/icons/line-change.svg.js";
2
+ import i from "../static/assets/icons/line-delete.svg.js";
3
+ import n from "../static/assets/icons/line-plus.svg.js";
4
+ import p from "../static/styles/base.css.js";
5
+ import s from "../static/styles/components/alert-message.css.js";
6
+ import C from "../static/styles/components/amp-block.css.js";
7
+ import a from "../static/styles/components/base-input.css.js";
8
+ import f from "../static/styles/components/button-group.css.js";
9
+ import c from "../static/styles/components/button.css.js";
10
+ import u from "../static/styles/components/combobox.css.js";
11
+ import l from "../static/styles/components/counter.css.js";
12
+ import d from "../static/styles/components/dropdown-menu.css.js";
13
+ import h from "../static/styles/components/loader.css.js";
14
+ import g from "../static/styles/components/narrow-panel.css.js";
15
+ import I from "../static/styles/components/popup.css.js";
16
+ import w from "../static/styles/components/recommendation-strategy.css.js";
17
+ import y from "../static/styles/components/switcher.css.js";
18
+ import b from "../static/styles/components/tabs.css.js";
19
+ import B from "../static/styles/components/tools.css.js";
20
+ import $ from "../static/styles/components/version-history.css.js";
21
+ import P from "../static/styles/components/wide-panel.css.js";
22
+ import x from "../static/styles/variables.css.js";
23
+ function r(t, o) {
24
+ return `--guido-icon-${t}: url("data:image/svg+xml,${encodeURIComponent(o.trim())}");`;
25
+ }
26
+ const A = `:host {
27
+ ${r("line-change", S)}
28
+ ${r("line-delete", i)}
29
+ ${r("line-plus", n)}
30
+ }`, R = [
31
+ x,
23
32
  // Must be on top
24
- m,
25
- e,
26
- i,
33
+ A,
27
34
  p,
28
- n,
35
+ // Must be on top
29
36
  s,
30
37
  C,
31
- f,
32
38
  a,
33
- u,
39
+ f,
34
40
  c,
35
- d,
41
+ u,
36
42
  l,
43
+ d,
37
44
  h,
38
- w,
39
- y
45
+ g,
46
+ I,
47
+ y,
48
+ b,
49
+ B,
50
+ $,
51
+ P,
52
+ w
53
+ // Last: overrides button.css / wide-panel.css defaults
40
54
  ].join(`
41
55
 
42
- `), v = () => ({ importCss: () => {
56
+ `), Y = () => ({ importCss: () => {
43
57
  const o = new CSSStyleSheet();
44
- o.replaceSync(b);
45
- const r = document.querySelector("ui-editor");
46
- if (!r)
58
+ o.replaceSync(R);
59
+ const e = document.querySelector("ui-editor");
60
+ if (!e)
47
61
  return;
48
- const t = r.shadowRoot;
49
- t && (t.adoptedStyleSheets = [o]);
62
+ const m = e.shadowRoot;
63
+ m && (m.adoptedStyleSheets = [o]);
50
64
  } });
51
65
  export {
52
- v as useCustomInterfaceAppearance
66
+ Y as useCustomInterfaceAppearance
53
67
  };
@@ -1,22 +1,22 @@
1
- import { getRecommendationFeedSourceMaps as I, URLS as R } from "../enums/extensions/recommendationBlock.js";
2
- import { MinDeviceViewport as C, DefaultPadding as b } from "../enums/recommendation.js";
1
+ import { getRecommendationFeedSourceMaps as y, URLS as I } from "../enums/extensions/recommendationBlock.js";
2
+ import { MinDeviceViewport as C, DefaultPadding as R } from "../enums/recommendation.js";
3
3
  import { useRecommendationExtensionStore as l } from "../extensions/Blocks/Recommendation/store/recommendation.js";
4
- import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
- import { getPartnerRecommendationParams as y } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
4
+ import { generateCompleteFilterQuery as b } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
5
+ import { getPartnerRecommendationParams as h } from "../extensions/Blocks/Recommendation/utils/partnerCustomizations.js";
6
6
  import { sanitizeProductIds as x } from "../extensions/Blocks/Recommendation/utils/productIds.js";
7
7
  import { useConfigStore as P } from "../stores/config.js";
8
8
  const B = () => ({
9
9
  calculateCardWidth: ({
10
- mobileLeftPadding: a,
11
- mobileRightPadding: s,
12
- cardsInRow: c,
10
+ mobileLeftPadding: i,
11
+ mobileRightPadding: c,
12
+ cardsInRow: s,
13
13
  unresponsive: n
14
14
  }) => {
15
- const r = n ? c : 1, e = a + s + (r - 1) * b;
16
- return (C - e) / r;
15
+ const o = n ? s : 1, e = i + c + (o - 1) * R;
16
+ return (C - e) / o;
17
17
  },
18
- getRecommendationCampaignData: (a) => {
19
- const s = l(), c = Number(a), n = s.blockStates[c];
18
+ getRecommendationCampaignData: (i) => {
19
+ const c = l(), s = Number(i), n = c.blockStates[s];
20
20
  if (!n)
21
21
  return {
22
22
  textTrimming: !1,
@@ -30,47 +30,54 @@ const B = () => ({
30
30
  discountBeforeTextValue: "",
31
31
  discountAfterTextValue: ""
32
32
  };
33
- const { recommendationConfigs: r } = n, e = r.orientation === "grid" ? "vertical" : "horizontal";
33
+ const { recommendationConfigs: o } = n, e = o.orientation === "grid" ? "vertical" : "horizontal";
34
34
  return {
35
- textTrimming: r.textTrimming,
35
+ textTrimming: o.textTrimming,
36
36
  orientation: e,
37
37
  mobileLeftPadding: 0,
38
38
  mobileRightPadding: 0,
39
- cardsInRow: r.cardsInRow,
40
- unresponsive: r.unresponsive,
39
+ cardsInRow: o.cardsInRow,
40
+ unresponsive: o.unresponsive,
41
41
  priceBeforeTextValue: "",
42
42
  priceAfterTextValue: "",
43
43
  discountBeforeTextValue: "",
44
44
  discountAfterTextValue: ""
45
45
  };
46
46
  },
47
- buildCampaignUrl: (a, s) => {
47
+ buildCampaignUrl: (i, c) => {
48
48
  var m;
49
- const c = l(), n = P(), r = Number(a);
49
+ const s = l(), n = P(), o = Number(i);
50
50
  let e;
51
- if (s)
52
- e = s;
51
+ if (c)
52
+ e = c;
53
53
  else {
54
- const i = c.blockStates[r];
55
- if (!i)
54
+ const a = s.blockStates[o];
55
+ if (!a)
56
56
  return "";
57
- const { recommendationConfigs: o } = i;
57
+ const { recommendationConfigs: r } = a;
58
58
  e = {
59
- strategy: o.strategy,
60
- language: o.language,
61
- currencyCode: o.currencySettings.value,
62
- size: o.size,
63
- productIds: o.productIds,
64
- filters: o.filters,
65
- shuffleProducts: o.shuffleProducts
59
+ strategy: r.strategy,
60
+ strategyId: r.strategyId,
61
+ language: r.language,
62
+ currencyCode: r.currencySettings.value,
63
+ size: r.size,
64
+ productIds: r.productIds,
65
+ filters: r.filters,
66
+ shuffleProducts: r.shuffleProducts
66
67
  };
67
68
  }
68
- const f = ((m = I().find((i) => i.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
69
+ if (e.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy"))
70
+ return s.recommendationCampaignUrls[i] = {
71
+ strategyId: e.strategyId,
72
+ locale: e.language,
73
+ currency: e.currencyCode
74
+ }, "";
75
+ const g = ((m = y().find((a) => a.key === e.strategy)) == null ? void 0 : m.path) || "", t = new URLSearchParams();
69
76
  t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising" ? t.set("productId", x(e.productIds)) : e.strategy === "similarViewed" && t.set("productId", "{itemId}"), e.strategy === "userBased" && t.set("userId", "{user_id}");
70
- const g = e.filters.filter((i) => i.isValid), d = h(g);
71
- d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(y(n.partnerName, e.strategy)).forEach(([i, o]) => t.set(i, o));
72
- const p = decodeURIComponent(t.toString()), u = `${R.RECOMMENDATION_API_URL}/v2/${f}?${p}`;
73
- return c.recommendationCampaignUrls[a] = u, u;
77
+ const f = e.filters.filter((a) => a.isValid), d = b(f);
78
+ d && t.set("filter", d), e.shuffleProducts && t.set("shuffle", "true"), Object.entries(h(n.partnerName, e.strategy)).forEach(([a, r]) => t.set(a, r));
79
+ const p = decodeURIComponent(t.toString()), u = `${I.RECOMMENDATION_API_URL}/v2/${g}?${p}`;
80
+ return s.recommendationCampaignUrls[i] = u, u;
74
81
  }
75
82
  });
76
83
  export {
@@ -1,10 +1,10 @@
1
- import { CURRENT_CONFIG_VERSION as s, DEFAULT_CURRENCY as i } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
- import { DEFAULT_CARDS_IN_ROW as m, DEFAULT_MOBILE_ROW_SPACING as p, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as f, DEFAULT_COLUMN_SPACING as S, DEFAULT_MOBILE_CARDS_IN_ROW as a } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
1
+ import { PRE_RRS_CONFIG_VERSION as s, DEFAULT_CURRENCY as i } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
2
+ import { DEFAULT_CARDS_IN_ROW as m, DEFAULT_MOBILE_ROW_SPACING as p, DEFAULT_MOBILE_COLUMN_SPACING as d, DEFAULT_ROW_SPACING as S, DEFAULT_COLUMN_SPACING as f, DEFAULT_MOBILE_CARDS_IN_ROW as a } from "../../../extensions/Blocks/Recommendation/constants/layout.js";
3
3
  import { mapLegacyStrategy as l } from "../../../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
4
4
  function c(t) {
5
5
  return t === "0" || t === 0 ? "before" : "after";
6
6
  }
7
- function I(t) {
7
+ function _(t) {
8
8
  if (typeof t == "number" && Number.isFinite(t))
9
9
  return t;
10
10
  if (typeof t == "string") {
@@ -14,13 +14,13 @@ function I(t) {
14
14
  }
15
15
  return i.decimalCount;
16
16
  }
17
- function _(t) {
17
+ function I(t) {
18
18
  return t === "." || t === "," || t === " " || t === "" ? t : ",";
19
19
  }
20
- function N(t) {
20
+ function A(t) {
21
21
  return t === "." || t === "," || t === " " ? t : ".";
22
22
  }
23
- function A(t) {
23
+ function L(t) {
24
24
  if (!t || typeof t != "object")
25
25
  return { ...i };
26
26
  const o = t, n = o.value ?? o.name ?? i.code, r = o.symbol ?? n;
@@ -28,18 +28,18 @@ function A(t) {
28
28
  code: n,
29
29
  symbol: r,
30
30
  alignment: c(o.alignment),
31
- decimalCount: I(o.decimalCount),
32
- decimalSeparator: N(o.decimalSeparator),
33
- thousandSeparator: _(o.thousandSeparator)
31
+ decimalCount: _(o.decimalCount),
32
+ decimalSeparator: A(o.decimalSeparator),
33
+ thousandSeparator: I(o.thousandSeparator)
34
34
  };
35
35
  }
36
- function L(t) {
36
+ function N(t) {
37
37
  return t === "horizontal" || t === "list" ? "list" : "grid";
38
38
  }
39
39
  function R(t) {
40
40
  return l(t) || "mostPopular";
41
41
  }
42
- function U(t, o, n) {
42
+ function O(t, o, n) {
43
43
  const r = o.rowCount ?? t.cardsInRow ?? m, u = o.totalCount ?? (typeof t.size == "string" ? parseInt(t.size) : t.size) ?? 6;
44
44
  return {
45
45
  recommendationId: n,
@@ -48,15 +48,15 @@ function U(t, o, n) {
48
48
  size: String(u),
49
49
  shuffleProducts: !!t.shuffleProducts,
50
50
  language: t.language ?? "en_US",
51
- currency: A(t.currencySettings),
51
+ currency: L(t.currencySettings),
52
52
  filters: (t.filters ?? []).map((e) => ({ ...e })),
53
- layout: L(t.orientation ?? o.orientation),
53
+ layout: N(t.orientation ?? o.orientation),
54
54
  cardsInRow: r,
55
55
  mobileCardsInRow: a,
56
56
  mobileLayoutEnabled: !1,
57
57
  previousMobileCardsInRow: a,
58
- columnSpacing: S,
59
- rowSpacing: f,
58
+ columnSpacing: f,
59
+ rowSpacing: S,
60
60
  mobileColumnSpacing: d,
61
61
  mobileRowSpacing: p,
62
62
  omnibusPrice: { textBefore: "", textAfter: "" },
@@ -70,6 +70,6 @@ function U(t, o, n) {
70
70
  };
71
71
  }
72
72
  export {
73
- A as mapCurrency,
74
- U as mapSettings
73
+ L as mapCurrency,
74
+ O as mapSettings
75
75
  };
@@ -1,6 +1,6 @@
1
1
  import { BlockId as f } from "../../enums/block.js";
2
- import { useTemplateStore as b } from "../../stores/template.js";
3
- import { mapComposition as y } from "./recommendation/compositionMapper.js";
2
+ import { useTemplateStore as y } from "../../stores/template.js";
3
+ import { mapComposition as b } from "./recommendation/compositionMapper.js";
4
4
  import { extractCurrencyFromBlock as v, extractTitleText as C, extractCardBgColor as M, isPartnerManagedBlock as S } from "./recommendation/extractors.js";
5
5
  import { buildBlockHtml as w } from "./recommendation/htmlBuilder.js";
6
6
  import { parseRecommendationId as x, parseLegacyConfig as R } from "./recommendation/parseLegacyConfig.js";
@@ -20,8 +20,9 @@ function B(i, t, a) {
20
20
  ), !1;
21
21
  const n = a[String(o)] ?? {
22
22
  currencySettings: v(t)
23
- }, c = T(n, r, o), e = y((d = r.composition) == null ? void 0 : d.variables), l = C(t), g = M(t), p = {
23
+ }, c = T(n, r, o), e = b((d = r.composition) == null ? void 0 : d.variables), l = C(t), g = M(t), p = {
24
24
  ...c,
25
+ strategyId: "",
25
26
  composition: e.composition,
26
27
  visibility: e.visibility,
27
28
  textTrimming: e.anyTextTrimming
@@ -56,7 +57,7 @@ function B(i, t, a) {
56
57
  function q(i, t = {}) {
57
58
  const a = new DOMParser(), o = a.parseFromString(i, "text/html"), r = Array.from(o.querySelectorAll(h));
58
59
  try {
59
- b().$patch((e) => {
60
+ y().$patch((e) => {
60
61
  e.migrations = {
61
62
  ...e.migrations,
62
63
  [f.Recommendation]: r.length
@@ -1,7 +1,8 @@
1
1
  const e = "https://academy.insiderone.com", o = {
2
2
  EMAIL_EDITOR: `${e}/docs/email-drag-and-drop-editor`,
3
3
  GLOBAL_UNSUBSCRIBE: `${e}/docs/global-unsubscribe-preference-center`,
4
- AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`
4
+ AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
5
+ EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
5
6
  };
6
7
  export {
7
8
  o as ACADEMY_LINKS
@@ -1,5 +1,7 @@
1
- const t = "tr-TR", L = "default";
1
+ const T = "tr-TR", t = "tr-TR", E = "default", L = "UTC";
2
2
  export {
3
- L as DEFAULT,
4
- t as DEFAULT_LOCALE
3
+ E as DEFAULT,
4
+ T as DEFAULT_LOCALE,
5
+ L as DEFAULT_TZ,
6
+ t as DOTTED_DATE_LOCALE
5
7
  };
@@ -2,7 +2,9 @@ import { useTranslations as r } from "../../composables/useTranslations.js";
2
2
  const l = {
3
3
  RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
4
4
  // Relative path → same-origin as the embedding inone dashboard.
5
- PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes"
5
+ PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
6
+ RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
7
+ RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
6
8
  }, c = {
7
9
  CLIENT_ID: "clientId"
8
10
  }, d = () => {
@@ -1,30 +1,20 @@
1
- var D = Object.defineProperty;
2
- var k = (l, a, t) => a in l ? D(l, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[a] = t;
3
- var I = (l, a, t) => k(l, typeof a != "symbol" ? a + "" : a, t);
4
- import { BlockId as N } from "../../../enums/block.js";
5
- import { useOnboardingStore as T } from "../../../stores/onboarding.js";
6
- import { getMigrationBannerHtml as _ } from "../../../utils/migrationBannerHtml.js";
7
- import { Block as A, BlockCompositionType as M, ModificationDescription as m } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
8
- import { currencyPositionFromLocation as O, ITEMS_CURRENCY_ATTR as d } from "./constants/currency.js";
9
- import { ItemsBlockId as R } from "./enums/controlEnums.js";
10
- import { SETTINGS_ENUMS as b, DefaultConfigValues as f } from "./enums/settingsEnums.js";
11
- import { getDefaultTemplate as E } from "./template.js";
12
- import { getItemsBlockContainer as h, getItemsBlockConfig as C, deriveItemNumber as H, getDefaultItemsBlockConfig as B } from "./utils/nodeConfigUtils.js";
13
- const S = N.Items, P = "Reconcile Items currency DOM attributes";
14
- class G extends A {
15
- constructor() {
16
- super(...arguments);
17
- /** Block instances whose currency attrs were already self-healed this session (SD-147588 — undo-safe). */
18
- I(this, "_currencyHealed", /* @__PURE__ */ new Set());
19
- }
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 {
20
10
  getId() {
21
- return S;
11
+ return p;
22
12
  }
23
13
  getIcon() {
24
14
  return "items-icon";
25
15
  }
26
16
  getBlockCompositionType() {
27
- return M.CONTAINER;
17
+ return b.CONTAINER;
28
18
  }
29
19
  getName() {
30
20
  return this.api.translate("Items");
@@ -33,20 +23,20 @@ class G extends A {
33
23
  return this.api.translate("Items lets you display personalized products based on user behavior.");
34
24
  }
35
25
  getSettingsPanelTitleHtml() {
36
- return _(
37
- S,
26
+ return I(
27
+ p,
38
28
  this.api.translate("Items"),
39
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.")
40
30
  );
41
31
  }
42
32
  getTemplate() {
43
- return E({
44
- orientation: b.ORIENTATION.VERTICAL,
45
- itemsType: b.ITEMS_TYPE.CART_ITEMS,
33
+ return h({
34
+ orientation: l.ORIENTATION.VERTICAL,
35
+ itemsType: l.ITEMS_TYPE.CART_ITEMS,
46
36
  itemId: "{{Abandoned Cart Item (1) Url}}",
47
- currencySymbol: f.productPriceCurrencySymbolControlValue,
48
- currencyLocation: f.productPriceCurrencyLocationControlValue,
49
- formattedPrice: f.productPriceFormattedControlValue === "1"
37
+ currencySymbol: d.productPriceCurrencySymbolControlValue,
38
+ currencyLocation: d.productPriceCurrencyLocationControlValue,
39
+ formattedPrice: d.productPriceFormattedControlValue === "1"
50
40
  });
51
41
  }
52
42
  allowInnerBlocksDND() {
@@ -55,27 +45,24 @@ class G extends A {
55
45
  canBeSavedAsModule() {
56
46
  return !0;
57
47
  }
58
- onCreated(t) {
59
- const o = this.api.getDocumentModifier(), s = this.api.getDocumentRootCssNode();
60
- s.querySelector('[product-attr="imageSrc"] img') || o.modifyCss(s).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
61
- const r = h(t);
62
- if (!r)
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)
63
53
  return;
64
- const i = r.getNodeConfig(), c = i && Object.keys(i).length > 0, e = C(t);
65
- if (e != null && e.initialized) {
66
- if (!c) {
67
- const u = this.api.getDocumentModifier();
68
- u.modifyHtml(r).setNodeConfig(e), this._stampProductTdDomAttributes(r, e, u), u.apply(new m("Migrate legacy config to nodeConfig"));
69
- return;
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
+ else {
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"));
70
61
  }
71
- } else {
72
- const u = B(), g = this.api.getDocumentModifier();
73
- g.modifyHtml(r).setNodeConfig(u), this._stampProductTdDomAttributes(r, u, g, !0), g.apply(new m("Initialize Items block with default configuration")), T().startOnboarding("itemsOnboarding");
74
- return;
62
+ else {
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");
75
65
  }
76
- const n = e.blockInstanceId || String(Date.now()), p = this.api.getDocumentModifier();
77
- let y = !1;
78
- e.blockInstanceId || (p.modifyHtml(r).setNodeConfig({ ...e, blockInstanceId: n }), y = !0), this._shouldReconcileCurrency(e) && this._reconcileCurrencyDomAttributes(r, e, p) && (y = !0), y && p.apply(new m("Assign Items block instance ID and reconcile currency")), this._markCurrencyHealed(n);
79
66
  }
80
67
  /**
81
68
  * Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
@@ -83,24 +70,18 @@ class G extends A {
83
70
  * into nodeConfig, so without this a reused module would reset to defaults.
84
71
  * Guarded to the nodeConfig-empty case so it runs once and never loops.
85
72
  */
86
- onDocumentChanged(t) {
87
- const o = h(t);
88
- if (!o)
73
+ onDocumentChanged(n) {
74
+ const t = u(n);
75
+ if (!t)
89
76
  return;
90
- const s = o.getNodeConfig();
91
- if (s && Object.keys(s).length > 0) {
92
- const e = C(t);
93
- if (e != null && e.initialized && this._shouldReconcileCurrency(e)) {
94
- const n = this.api.getDocumentModifier();
95
- this._reconcileCurrencyDomAttributes(o, e, n) && n.apply(new m(P)), this._markCurrencyHealed(e.blockInstanceId);
96
- }
77
+ const a = t.getNodeConfig();
78
+ if (a && Object.keys(a).length > 0)
97
79
  return;
98
- }
99
- const i = C(t);
100
- if (!(i != null && i.initialized))
80
+ const o = f(n);
81
+ if (!(o != null && o.initialized))
101
82
  return;
102
- const c = this.api.getDocumentModifier();
103
- c.modifyHtml(o).setNodeConfig(i), this._stampProductTdDomAttributes(o, i, c), c.apply(new m("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"));
104
85
  }
105
86
  /**
106
87
  * Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
@@ -110,44 +91,14 @@ class G extends A {
110
91
  * restored before export. The name `<a>` carries no data-type/data-number of its own and
111
92
  * relies on this td-level fallback in pairProductVariables.
112
93
  */
113
- _stampProductTdDomAttributes(t, o, s, r = !1) {
114
- const i = H(o.itemsSelectValue, o.type), c = (e, n) => {
115
- r && t.getAttribute(e) || s.modifyHtml(t).setAttribute(e, n);
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);
116
97
  };
117
- c("data-type", o.type), c("data-number", i), c("data-nodup", String(o.priceHideDiscount));
118
- }
119
- /**
120
- * Whether the currency self-heal should run for this block. Two guards (SD-147588):
121
- * 1. Config is only authoritative when the symbol was actually customized — a symbol still at
122
- * the 'USD' sentinel may be a migrator default, so we trust the DOM's real value over a
123
- * defaulted config and never overwrite it.
124
- * 2. Heal each instance at most once per session, so the auto-fix can't fight undo (undo
125
- * re-drifts the attr, which would otherwise re-trigger the heal forever).
126
- */
127
- _shouldReconcileCurrency(t) {
128
- const o = (t.priceCurrencySymbol ?? "").trim();
129
- return !o || o === f.productPriceCurrencySymbolControlValue ? !1 : !t.blockInstanceId || !this._currencyHealed.has(t.blockInstanceId);
130
- }
131
- /** Marks a block instance's currency as reconciled so it is not healed again (undo-safe). */
132
- _markCurrencyHealed(t) {
133
- t && this._currencyHealed.add(t);
134
- }
135
- /**
136
- * Stamps the export-read currency attrs onto every price `<p>` from config, so a template whose
137
- * attrs drifted (e.g. a location toggle before the sync fix) self-heals to match the editor.
138
- * Config is the source of truth — never derive from visible text. Callers gate this with
139
- * `_shouldReconcileCurrency`. Returns true only when an attr actually changed, so the caller can
140
- * skip an empty apply that would otherwise re-trigger onDocumentChanged and loop (SD-147588).
141
- */
142
- _reconcileCurrencyDomAttributes(t, o, s) {
143
- const r = O(o.priceCurrencyLocation), i = (o.priceCurrencySymbol ?? "").trim(), c = t.querySelectorAll(`.${R.PRICE} p`);
144
- let e = !1;
145
- return c.forEach((n) => {
146
- n.getAttribute(d.POSITION) !== r && (s.modifyHtml(n).setAttribute(d.POSITION, r), e = !0), i && n.getAttribute(d.SYMBOL) !== i && (s.modifyHtml(n).setAttribute(d.SYMBOL, i), e = !0);
147
- }), e;
98
+ r("data-type", t.type), r("data-number", o), r("data-nodup", String(t.priceHideDiscount));
148
99
  }
149
100
  }
150
101
  export {
151
- S as BLOCK_ID,
152
- G as ItemsBlock
102
+ p as BLOCK_ID,
103
+ E as ItemsBlock
153
104
  };