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

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 (95) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +7 -6
  3. package/dist/components/Guido.vue.js +10 -10
  4. package/dist/components/Guido.vue2.js +82 -76
  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/RemoveStrategyModal.vue.js +17 -0
  8. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +57 -0
  9. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  10. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  11. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  12. package/dist/composables/useRecommendation.js +41 -34
  13. package/dist/composables/useStripo.js +14 -14
  14. package/dist/config/i18n/en/labels.json.js +1 -1
  15. package/dist/config/migrator/index.js +9 -8
  16. package/dist/config/migrator/recommendation/compositionMapper.js +20 -20
  17. package/dist/config/migrator/recommendation/extractors.js +29 -24
  18. package/dist/config/migrator/recommendation/htmlBuilder.js +116 -130
  19. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  20. package/dist/config/migrator/recommendationMigrator.js +31 -25
  21. package/dist/config/migrator/recommendationTitleMigrator.js +119 -0
  22. package/dist/enums/academy.js +2 -1
  23. package/dist/enums/date.js +5 -3
  24. package/dist/enums/extensions/recommendationBlock.js +3 -1
  25. package/dist/extensions/Blocks/Items/block.js +49 -98
  26. package/dist/extensions/Blocks/Items/controls/price/currencyLocation.js +24 -25
  27. package/dist/extensions/Blocks/Items/controls/price/currencySymbol.js +11 -12
  28. package/dist/extensions/Blocks/Items/template.js +152 -153
  29. package/dist/extensions/Blocks/Recommendation/block.js +35 -29
  30. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +1 -1
  31. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
  32. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +29 -27
  33. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +35 -28
  34. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +309 -236
  35. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +247 -180
  36. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
  37. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +1 -0
  38. package/dist/extensions/Blocks/Recommendation/controls/title/index.js +44 -0
  39. package/dist/extensions/Blocks/Recommendation/extension.js +31 -29
  40. package/dist/extensions/Blocks/Recommendation/services/configService.js +54 -36
  41. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +23 -4
  42. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +177 -80
  43. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +3 -3
  44. package/dist/extensions/Blocks/Recommendation/templates/titleRows.js +33 -0
  45. package/dist/extensions/Blocks/Recommendation/templates/utils.js +85 -107
  46. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +22 -0
  47. package/dist/extensions/Blocks/common-control.js +22 -19
  48. package/dist/guido.css +1 -1
  49. package/dist/services/recommendationApi.js +69 -30
  50. package/dist/src/@types/config/schemas.d.ts +2 -0
  51. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  52. package/dist/src/components/organisms/extensions/recommendation/RemoveStrategyModal.vue.d.ts +2 -0
  53. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +15 -0
  54. package/dist/src/composables/useConfig.d.ts +2 -0
  55. package/dist/src/composables/useRecommendation.d.ts +1 -0
  56. package/dist/src/config/migrator/recommendation/extractors.d.ts +8 -0
  57. package/dist/src/config/migrator/recommendationTitleMigrator.d.ts +5 -0
  58. package/dist/src/enums/academy.d.ts +1 -0
  59. package/dist/src/enums/date.d.ts +1 -0
  60. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  61. package/dist/src/extensions/Blocks/Items/block.d.ts +0 -21
  62. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +2 -1
  63. package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +7 -0
  64. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +3 -6
  65. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +2 -2
  66. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +12 -0
  67. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +11 -0
  68. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -0
  69. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +48 -8
  70. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +1 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +86 -0
  73. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +12 -1
  74. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +188 -10
  75. package/dist/src/extensions/Blocks/Recommendation/templates/titleRows.d.ts +13 -0
  76. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +7 -0
  77. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +31 -0
  78. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  79. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  80. package/dist/src/services/recommendationApi.d.ts +4 -1
  81. package/dist/src/stores/config.d.ts +18 -0
  82. package/dist/src/stores/save-as-template.d.ts +4 -3
  83. package/dist/src/utils/genericUtil.d.ts +5 -0
  84. package/dist/static/assets/icons/line-change.svg.js +5 -0
  85. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  86. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  87. package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
  88. package/dist/static/styles/customEditorStyle.css.js +3 -1
  89. package/dist/utils/dateUtil.js +23 -10
  90. package/dist/utils/genericUtil.js +28 -27
  91. package/dist/utils/pairProductVariables.js +59 -60
  92. package/dist/utils/templatePreparation.js +47 -45
  93. package/package.json +2 -1
  94. package/dist/extensions/Blocks/Items/constants/currency.js +0 -11
  95. package/dist/src/extensions/Blocks/Items/constants/currency.d.ts +0 -19
@@ -1,31 +1,37 @@
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";
4
- import { extractCurrencyFromBlock as v, extractTitleText as C, extractCardBgColor as M, isPartnerManagedBlock as S } from "./recommendation/extractors.js";
2
+ import { DEFAULT_NODE_CONFIG as b } from "../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
3
+ import { ATTR_RECOMMENDATION_TITLE as y } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
4
+ import { useTemplateStore as T } from "../../stores/template.js";
5
+ import { mapComposition as v } from "./recommendation/compositionMapper.js";
6
+ import { extractCurrencyFromBlock as C, extractTitleText as M, hasVisibleTitle as R, extractCardBgColor as S, isPartnerManagedBlock as h } from "./recommendation/extractors.js";
5
7
  import { buildBlockHtml as w } from "./recommendation/htmlBuilder.js";
6
- import { parseRecommendationId as x, parseLegacyConfig as R } from "./recommendation/parseLegacyConfig.js";
7
- import { mapSettings as T } from "./recommendation/settingsMapper.js";
8
- const h = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
9
- function B(i, t, a) {
10
- var d;
8
+ import { parseRecommendationId as x, parseLegacyConfig as E } from "./recommendation/parseLegacyConfig.js";
9
+ import { mapSettings as A } from "./recommendation/settingsMapper.js";
10
+ const H = 'td[esd-dev-product-config][class*="ins-recommendation-v3-block-"]:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"][esd-dev-product-config]:not(.recommendation-block-v2)';
11
+ function B(n, t, a) {
12
+ var l;
11
13
  const o = x(t);
12
14
  if (o === null)
13
15
  return console.warn(
14
16
  "[RecommendationMigrator] Skipping block — missing/invalid `ins-recommendation-v3-campaign-id`"
15
17
  ), !1;
16
- const r = R(t);
18
+ const r = E(t);
17
19
  if (!r)
18
20
  return console.warn(
19
21
  `[RecommendationMigrator] Aborting block id=${o} — \`esd-dev-product-config\` missing or unable to be parsed`
20
22
  ), !1;
21
- const n = a[String(o)] ?? {
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
+ const i = a[String(o)] ?? {
24
+ currencySettings: C(t)
25
+ }, c = A(i, r, o), e = v((l = r.composition) == null ? void 0 : l.variables), d = M(t);
26
+ e.titleVariable || (e.visibility[y] = R(t));
27
+ const p = S(t), g = {
24
28
  ...c,
29
+ strategyId: "",
25
30
  composition: e.composition,
26
31
  visibility: e.visibility,
32
+ previousTitleHtml: b.previousTitleHtml,
27
33
  textTrimming: e.anyTextTrimming
28
- }, m = S(t), u = `
34
+ }, m = h(t), u = `
29
35
  <table>
30
36
  <tbody>
31
37
  <tr>
@@ -33,10 +39,10 @@ function B(i, t, a) {
33
39
  <table width="100%" cellpadding="0" cellspacing="0">
34
40
  <tbody>
35
41
  <tr>${w({
36
- nodeConfig: p,
42
+ nodeConfig: g,
37
43
  composition: e,
38
- cardBg: g,
39
- titleText: l,
44
+ cardBg: p,
45
+ titleText: d,
40
46
  legacyId: t.getAttribute("id") ?? void 0,
41
47
  legacyBgColor: t.getAttribute("bgcolor") ?? void 0,
42
48
  preserveInnerHtml: m ? t.innerHTML : void 0,
@@ -48,15 +54,15 @@ function B(i, t, a) {
48
54
  </tr>
49
55
  </tbody>
50
56
  </table>
51
- `, s = i.parseFromString(u, "text/html").querySelector("td.esd-structure");
57
+ `, s = n.parseFromString(u, "text/html").querySelector("td.esd-structure");
52
58
  return !s || !t.parentNode ? (console.warn(
53
59
  `[RecommendationMigrator] Aborting block id=${o} — failed to construct new HTML element`
54
60
  ), !1) : (t.parentNode.replaceChild(s, t), !0);
55
61
  }
56
- function q(i, t = {}) {
57
- const a = new DOMParser(), o = a.parseFromString(i, "text/html"), r = Array.from(o.querySelectorAll(h));
62
+ function G(n, t = {}) {
63
+ const a = new DOMParser(), o = a.parseFromString(n, "text/html"), r = Array.from(o.querySelectorAll(H));
58
64
  try {
59
- b().$patch((e) => {
65
+ T().$patch((e) => {
60
66
  e.migrations = {
61
67
  ...e.migrations,
62
68
  [f.Recommendation]: r.length
@@ -65,16 +71,16 @@ function q(i, t = {}) {
65
71
  } catch {
66
72
  }
67
73
  if (r.length === 0)
68
- return i;
69
- let n = 0;
74
+ return n;
75
+ let i = 0;
70
76
  return r.forEach((c) => {
71
77
  try {
72
- B(a, c, t) && (n += 1);
78
+ B(a, c, t) && (i += 1);
73
79
  } catch (e) {
74
80
  console.error("[RecommendationMigrator] Unexpected error migrating block:", e);
75
81
  }
76
- }), n > 0 && console.info(`[RecommendationMigrator] Migrated ${n} legacy Recommendation block(s)`), o.documentElement.outerHTML;
82
+ }), i > 0 && console.info(`[RecommendationMigrator] Migrated ${i} legacy Recommendation block(s)`), o.documentElement.outerHTML;
77
83
  }
78
84
  export {
79
- q as migrateRecommendation
85
+ G as migrateRecommendation
80
86
  };
@@ -0,0 +1,119 @@
1
+ var R = Object.defineProperty;
2
+ var f = (s, t, e) => t in s ? R(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
+ var a = (s, t, e) => f(s, typeof t != "symbol" ? t + "" : t, e);
4
+ import { RecommendationBlockId as d } from "../../extensions/Blocks/Recommendation/constants/blockIds.js";
5
+ import { BLOCK_ROOT_SELECTOR as u, CSS_CLASS_SKIP_COMPILE as m, ATTR_DATA_ATTRIBUTE_TYPE as S, ATTR_RECOMMENDATION_TITLE as l, CONTAINER_SELECTOR as E, CSS_CLASS_TITLE_CELL as c, CSS_CLASS_SPACER as C, CSS_CLASS_ATTRIBUTE_ROW as A, ATTR_DATA_VISIBILITY as L } from "../../extensions/Blocks/Recommendation/constants/selectors.js";
6
+ const p = u.slice(1), g = `${u}:not(.${m})`, O = `[${S}="${l}"]`, h = "td.esd-block-text", _ = "table.container > tbody", T = "esd-ext-config";
7
+ class y {
8
+ constructor() {
9
+ a(this, "parser");
10
+ this.parser = new DOMParser();
11
+ }
12
+ migrate(t) {
13
+ try {
14
+ if (!t.includes(p))
15
+ return t;
16
+ const e = this.parser.parseFromString(t, "text/html");
17
+ return Array.from(e.querySelectorAll(g)).reduce(
18
+ (n, o) => this._migrateBlock(o) || n,
19
+ !1
20
+ ) ? e.documentElement.outerHTML : t;
21
+ } catch (e) {
22
+ return console.error("RecommendationTitleMigrator failed:", e), t;
23
+ }
24
+ }
25
+ /** Migrates one block. Returns `true` when the block was changed. */
26
+ _migrateBlock(t) {
27
+ if (t.querySelector(O) || this._hasRecordedTitleState(t))
28
+ return !1;
29
+ const e = this._findTitleCell(t), i = e !== null && (e.textContent ?? "").trim().length > 0;
30
+ return i ? this._tagExistingTitle(t, e) : this._removeTitleRemnants(t, e), this._writeVisibility(t, i), !0;
31
+ }
32
+ /** The only `esd-block-text` cell outside the product containers is the title. */
33
+ _findTitleCell(t) {
34
+ return Array.from(t.querySelectorAll(h)).find((e) => !e.closest(E) && this._isTitlePosition(t, e)) ?? null;
35
+ }
36
+ _isTitlePosition(t, e) {
37
+ var r;
38
+ const i = this._wrapperRowOf(t, e);
39
+ return e.classList.contains(c) || i !== null && i === ((r = i.parentElement) == null ? void 0 : r.firstElementChild);
40
+ }
41
+ /**
42
+ * Stamps the attribute-row tagging onto the title's wrapper row and the spacer
43
+ * below it, so one toggle governs the pair and the compiler drops both when off.
44
+ */
45
+ _tagExistingTitle(t, e) {
46
+ e.classList.add(c), e.setAttribute("esd-extension-block-id", d.TITLE);
47
+ const i = this._wrapperRowOf(t, e);
48
+ if (!i)
49
+ return;
50
+ this._tagRow(i);
51
+ const r = i.nextElementSibling;
52
+ r && this._isSpacerRow(r) && this._tagRow(r);
53
+ }
54
+ /** The `<tr>` inside `table.container > tbody` that wraps the title's own table. */
55
+ _wrapperRowOf(t, e) {
56
+ if (!e)
57
+ return null;
58
+ const i = t.querySelector(_);
59
+ return Array.from((i == null ? void 0 : i.children) ?? []).find((r) => r.contains(e)) ?? null;
60
+ }
61
+ /**
62
+ * Direct children only — a product-container row holds spacer cells further down,
63
+ * and `querySelector` would happily reach them. (`:scope >` is unsupported in happy-dom.)
64
+ */
65
+ _isSpacerRow(t) {
66
+ return Array.from(t.children).some((e) => e.classList.contains(C));
67
+ }
68
+ _tagRow(t) {
69
+ t.classList.add(A), t.setAttribute(S, l), t.setAttribute(L, "1");
70
+ }
71
+ /**
72
+ * A deleted title leaves nothing to tag — the toggle re-injects the markup only
73
+ * when the user switches it back on. Its leftovers (an emptied wrapper row, the
74
+ * spacer that trailed it) would otherwise render as blank padding on top.
75
+ */
76
+ _removeTitleRemnants(t, e) {
77
+ var o;
78
+ const i = this._wrapperRowOf(t, e), r = i == null ? void 0 : i.nextElementSibling;
79
+ if (r && this._isSpacerRow(r) && r.remove(), i) {
80
+ i.remove();
81
+ return;
82
+ }
83
+ const n = (o = t.querySelector(_)) == null ? void 0 : o.firstElementChild;
84
+ n && this._isSpacerRow(n) && n.remove();
85
+ }
86
+ /**
87
+ * Mirrors the resolved state into the persisted config blob, so a saved module
88
+ * whose `data-*` attributes Stripo strips on re-drop still restores the toggle.
89
+ */
90
+ _writeVisibility(t, e) {
91
+ const i = this._readConfig(t);
92
+ if (!i)
93
+ return;
94
+ const r = typeof i.visibility == "object" && i.visibility !== null ? i.visibility : {};
95
+ i.visibility = { ...r, [l]: e }, t.setAttribute(T, JSON.stringify(i));
96
+ }
97
+ _hasRecordedTitleState(t) {
98
+ var i;
99
+ const e = (i = this._readConfig(t)) == null ? void 0 : i.visibility;
100
+ return typeof e == "object" && e !== null && l in e;
101
+ }
102
+ _readConfig(t) {
103
+ const e = t.getAttribute(T);
104
+ if (!e)
105
+ return null;
106
+ try {
107
+ const i = JSON.parse(e);
108
+ return typeof i == "object" && i !== null ? i : null;
109
+ } catch {
110
+ return null;
111
+ }
112
+ }
113
+ }
114
+ function v(s) {
115
+ return new y().migrate(s);
116
+ }
117
+ export {
118
+ v as migrateRecommendationTitle
119
+ };
@@ -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
  };
@@ -1,15 +1,14 @@
1
- import { currencyLocationMaps as p } from "../../../../../enums/extensions/recommendationBlock.js";
2
- import { UEAttr as N, ModificationDescription as I } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
- import { CommonControl as L } from "../../../common-control.js";
4
- import { ITEMS_CURRENCY_ATTR as T, currencyPositionFromLocation as E } from "../../constants/currency.js";
1
+ import { currencyLocationMaps as u } from "../../../../../enums/extensions/recommendationBlock.js";
2
+ import { UEAttr as R, ModificationDescription as L } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
3
+ import { CommonControl as N } from "../../../common-control.js";
5
4
  import { ItemsBlockControlId as m } from "../../enums/controlEnums.js";
6
- import { getItemsBlockConfig as l, setItemsBlockConfig as O, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
7
- const b = m.PRICE_CURRENCY_LOCATION, c = {
5
+ import { getItemsBlockConfig as C, setItemsBlockConfig as I, escapeReplacement as T } from "../../utils/nodeConfigUtils.js";
6
+ const E = m.PRICE_CURRENCY_LOCATION, c = {
8
7
  CURRENCY_LOCATION: "currencyLocation"
9
8
  };
10
- class Y extends L {
9
+ class A extends N {
11
10
  getId() {
12
- return b;
11
+ return E;
13
12
  }
14
13
  getTemplate() {
15
14
  return `
@@ -19,32 +18,32 @@ class Y extends L {
19
18
  `;
20
19
  }
21
20
  onRender() {
22
- const e = l(this.currentNode);
23
- this.api.setUIEAttribute(c.CURRENCY_LOCATION, N.SELECTPICKER.items, p), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
21
+ const e = C(this.currentNode);
22
+ this.api.setUIEAttribute(c.CURRENCY_LOCATION, R.SELECTPICKER.items, u), this.api.updateValues({ [c.CURRENCY_LOCATION]: (e == null ? void 0 : e.priceCurrencyLocation) ?? "0" }), this.api.onValueChanged(c.CURRENCY_LOCATION, (t) => {
24
23
  this._onCurrencyLocationChange(t);
25
24
  });
26
25
  }
27
26
  onTemplateNodeUpdated(e) {
28
27
  super.onTemplateNodeUpdated(e), this.handleBlockInstanceChange(() => {
29
- const t = l(this.currentNode);
28
+ const t = C(this.currentNode);
30
29
  this.api.updateValues({ [c.CURRENCY_LOCATION]: (t == null ? void 0 : t.priceCurrencyLocation) ?? "0" });
31
30
  });
32
31
  }
33
32
  _onCurrencyLocationChange(e) {
34
- if (console.debug("Currency location changed to: ", e), O(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
33
+ if (console.debug("Currency location changed to: ", e), I(this.currentNode, this.api, { priceCurrencyLocation: e }), !this.currentNode)
35
34
  return;
36
35
  const t = this._getPriceBlocks();
37
36
  if (!t || t.length === 0)
38
37
  return;
39
- const r = l(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = E(n), s = this.api.getDocumentModifier();
40
- t.forEach((h) => {
41
- const a = this._getParagraph(h);
42
- if (!a)
38
+ const r = C(this.currentNode), n = e || "0", o = (r == null ? void 0 : r.priceCurrencySymbol) ?? "", i = this.api.getDocumentModifier();
39
+ t.forEach((a) => {
40
+ const s = this._getParagraph(a);
41
+ if (!s)
43
42
  return;
44
- const d = a.getInnerHTML().trim() || "", C = a.getInnerText().trim() || "", u = (o == null ? void 0 : o.trim()) || "", _ = this._removeCurrencySymbol(C, u), g = this._detectSymbolInText(C) || u, R = this._buildPriceContent(_, g, n), y = d.replace(C, f(R));
45
- s.modifyHtml(a).setInnerHtml(y).setAttribute(T.POSITION, i);
46
- }), s.apply(new I(
47
- `Updated currency location to ${i}`
43
+ const h = s.getInnerHTML().trim() || "", l = s.getInnerText().trim() || "", p = (o == null ? void 0 : o.trim()) || "", d = this._removeCurrencySymbol(l, p), g = this._detectSymbolInText(l) || p, _ = this._buildPriceContent(d, g, n), y = h.replace(l, T(_));
44
+ i.modifyHtml(s).setInnerHtml(y);
45
+ }), i.apply(new L(
46
+ `Updated currency location to ${n === "1" ? "after" : "before"}`
48
47
  ));
49
48
  }
50
49
  _getPriceBlocks() {
@@ -66,8 +65,8 @@ class Y extends L {
66
65
  } else {
67
66
  const o = r.match(/([^0-9.,\s]+)/);
68
67
  if (o && o[1]) {
69
- const i = o[1].trim(), s = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
70
- n = r.replace(s, "").trim();
68
+ const i = o[1].trim(), a = new RegExp(`\\s*${this._escapeRegex(i)}\\s*`);
69
+ n = r.replace(a, "").trim();
71
70
  }
72
71
  }
73
72
  return n;
@@ -86,13 +85,13 @@ class Y extends L {
86
85
  this._GuSelect({
87
86
  name: c.CURRENCY_LOCATION,
88
87
  placeholder: "",
89
- options: p
88
+ options: u
90
89
  })
91
90
  ])}
92
91
  `;
93
92
  }
94
93
  }
95
94
  export {
96
- b as CONTROL_BLOCK_ID,
97
- Y as PriceCurrencyLocationControl
95
+ E as CONTROL_BLOCK_ID,
96
+ A as PriceCurrencyLocationControl
98
97
  };
@@ -1,21 +1,20 @@
1
1
  var R = Object.defineProperty;
2
2
  var N = (s, c, e) => c in s ? R(s, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[c] = e;
3
3
  var h = (s, c, e) => N(s, typeof c != "symbol" ? c + "" : c, e);
4
- import { ModificationDescription as E } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
- import { CommonControl as B } from "../../../common-control.js";
6
- import { ITEMS_CURRENCY_ATTR as T } from "../../constants/currency.js";
4
+ import { ModificationDescription as B } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
5
+ import { CommonControl as E } from "../../../common-control.js";
7
6
  import { ItemsBlockControlId as y } from "../../enums/controlEnums.js";
8
- import { getItemsBlockConfig as p, setItemsBlockConfig as Y, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
9
- const x = y.PRICE_CURRENCY_SYMBOL, u = {
7
+ import { getItemsBlockConfig as p, setItemsBlockConfig as x, escapeReplacement as f } from "../../utils/nodeConfigUtils.js";
8
+ const I = y.PRICE_CURRENCY_SYMBOL, u = {
10
9
  CURRENCY_SYMBOL: "currencySymbol"
11
10
  };
12
- class $ extends B {
11
+ class P extends E {
13
12
  constructor() {
14
13
  super(...arguments);
15
14
  h(this, "originalPriceContents", /* @__PURE__ */ new Map());
16
15
  }
17
16
  getId() {
18
- return x;
17
+ return I;
19
18
  }
20
19
  getTemplate() {
21
20
  return `
@@ -43,7 +42,7 @@ class $ extends B {
43
42
  var a;
44
43
  console.debug("Currency symbol changed to: ", e);
45
44
  const t = p(this.currentNode), o = ((a = t == null ? void 0 : t.priceCurrencySymbol) == null ? void 0 : a.trim()) || "";
46
- if (Y(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
45
+ if (x(this.currentNode, this.api, { priceCurrencySymbol: e }), !this.currentNode)
47
46
  return;
48
47
  const r = this._getPriceBlocks();
49
48
  if (!r || r.length === 0)
@@ -54,8 +53,8 @@ class $ extends B {
54
53
  if (!m)
55
54
  return;
56
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));
57
- i.modifyHtml(m).setInnerHtml(b).setAttribute(T.SYMBOL, n);
58
- }), i.apply(new E(
56
+ i.modifyHtml(m).setInnerHtml(b).setAttribute("data-currency_symbol", n);
57
+ }), i.apply(new B(
59
58
  `Updated currency symbol to ${n || "removed"}`
60
59
  ));
61
60
  }
@@ -116,6 +115,6 @@ class $ extends B {
116
115
  }
117
116
  }
118
117
  export {
119
- x as CONTROL_BLOCK_ID,
120
- $ as PriceCurrencySymbolControl
118
+ I as CONTROL_BLOCK_ID,
119
+ P as PriceCurrencySymbolControl
121
120
  };