@useinsider/guido 3.24.0-beta.0aa04e8 → 3.24.0-beta.172ae7a

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 (41) hide show
  1. package/README.md +9 -0
  2. package/dist/@types/config/schemas.js +18 -16
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +88 -84
  5. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.js +17 -0
  6. package/dist/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue2.js +30 -0
  7. package/dist/composables/useActionsApi.js +2 -2
  8. package/dist/composables/useEditorTrackingIds.js +49 -0
  9. package/dist/composables/useModuleRepair.js +32 -23
  10. package/dist/config/migrator/index.js +10 -9
  11. package/dist/config/migrator/legacyUnsubscribeTextMigrator.js +16 -0
  12. package/dist/config/migrator/unsubscribeMigrator.js +98 -94
  13. package/dist/enums/academy.js +2 -1
  14. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  15. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  16. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  17. package/dist/extensions/Blocks/Unsubscribe/block.js +96 -104
  18. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +3 -4
  19. package/dist/guido.css +1 -1
  20. package/dist/package.json.js +1 -1
  21. package/dist/services/templateLibraryApi.js +39 -36
  22. package/dist/src/@types/config/schemas.d.ts +4 -0
  23. package/dist/src/components/organisms/unsubscribe/LegacyUnsubscribeConvertedModal.vue.d.ts +2 -0
  24. package/dist/src/composables/useConfig.d.ts +2 -0
  25. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  26. package/dist/src/composables/useModuleRepair.d.ts +2 -11
  27. package/dist/src/config/migrator/legacyUnsubscribeTextMigrator.d.ts +1 -0
  28. package/dist/src/enums/academy.d.ts +1 -0
  29. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  30. package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +0 -1
  31. package/dist/src/stores/config.d.ts +20 -0
  32. package/dist/src/stores/editor.d.ts +27 -0
  33. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +10 -0
  34. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  35. package/dist/stores/editor.js +1 -0
  36. package/dist/utils/legacyUnsubscribeConversion.js +49 -0
  37. package/dist/utils/linkTrackingIds.js +82 -48
  38. package/dist/utils/templatePreparation.js +30 -33
  39. package/package.json +1 -1
  40. package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +0 -5
  41. package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +0 -1
@@ -1,18 +1,19 @@
1
1
  import { migrateCheckbox as i } from "./checkboxMigrator.js";
2
2
  import { migrateCouponBlock as e } from "./couponBlockMigrator.js";
3
3
  import { migrateFullStoryScripts as a } from "./fullStoryScriptMigrator.js";
4
- import { migrateItemsBlock as n } from "./itemsBlockMigrator.js";
5
- import { migrateProductNameLink as c } from "./productNameLinkMigrator.js";
6
- import { migrateRadioButton as g } from "./radioButtonMigrator.js";
7
- import { migrateRecommendation as p } from "./recommendationMigrator.js";
8
- import { migrateRecommendationPartnerScope as f } from "./recommendationPartnerMigrator.js";
4
+ import { migrateItemsBlock as c } from "./itemsBlockMigrator.js";
5
+ import { migrateLegacyUnsubscribeText as g } from "./legacyUnsubscribeTextMigrator.js";
6
+ import { migrateProductNameLink as n } from "./productNameLinkMigrator.js";
7
+ import { migrateRadioButton as p } from "./radioButtonMigrator.js";
8
+ import { migrateRecommendation as f } from "./recommendationMigrator.js";
9
+ import { migrateRecommendationPartnerScope as s } from "./recommendationPartnerMigrator.js";
9
10
  import { migrateRecommendationTitle as l } from "./recommendationTitleMigrator.js";
10
- import { migrateSocialIcons as s } from "./socialIconMigrator.js";
11
+ import { migrateSocialIcons as u } from "./socialIconMigrator.js";
11
12
  import { migrateUnsubscribe as d } from "./unsubscribeMigrator.js";
12
- const h = async (o, t = {}, r) => {
13
+ const U = async (o, t = {}, r) => {
13
14
  let m = o;
14
- return m = i(m), m = g(m), m = await d(m), m = e(m), m = p(m, t), r && (m = f(m, r)), m = l(m), m = n(m), m = c(m), m = s(m), m = a(m), m;
15
+ return m = i(m), m = p(m), m = g(m), m = await d(m), m = e(m), m = f(m, t), r && (m = s(m, r)), m = l(m), m = c(m), m = n(m), m = u(m), m = a(m), m;
15
16
  };
16
17
  export {
17
- h as migrate
18
+ U as migrate
18
19
  };
@@ -0,0 +1,16 @@
1
+ import { useConfigStore as o } from "../../stores/config.js";
2
+ import { useEditorStore as s } from "../../stores/editor.js";
3
+ import { hasLegacyUnsubscribeClass as c, convertLegacyUnsubscribeInDocumentHtml as i } from "../../utils/legacyUnsubscribeConversion.js";
4
+ const b = (e) => {
5
+ try {
6
+ if (!c(e) || !o().isFeatureEnabled("legacyUnsubscribeConversion"))
7
+ return e;
8
+ const { html: r, converted: t } = i(e);
9
+ return t && (s().isLegacyUnsubscribeModalRequested = !0), r;
10
+ } catch (r) {
11
+ return console.error("LegacyUnsubscribeTextMigrator failed:", r), e;
12
+ }
13
+ };
14
+ export {
15
+ b as migrateLegacyUnsubscribeText
16
+ };
@@ -1,142 +1,146 @@
1
- var $ = Object.defineProperty;
2
- var _ = (f, e, t) => e in f ? $(f, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : f[e] = t;
3
- var y = (f, e, t) => _(f, typeof e != "symbol" ? e + "" : e, t);
4
- import { MERGE_TAGS as l, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
5
- import { UNSUBSCRIBE_BLOCK_SELECTOR as A, DATA_ATTRIBUTES as T, UNSUBSCRIBE_MERGE_TAG_REGEX as E } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
6
- import { swapMergeTagInHref as B } from "../../extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js";
7
- import { useUnsubscribeStore as N } from "../../stores/unsubscribe.js";
8
- import { escapeHtml as h } from "../../utils/htmlEscape.js";
9
- const S = "unsubscribe", R = "You can ", M = " from our emails, if you need to.", C = "{-{-UNSUBSCRIBE-LINK-}-}";
10
- class P {
1
+ var x = Object.defineProperty;
2
+ var B = (c, e, r) => e in c ? x(c, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : c[e] = r;
3
+ var A = (c, e, r) => B(c, typeof e != "symbol" ? e + "" : e, r);
4
+ import { MERGE_TAGS as f, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
5
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as h, DATA_ATTRIBUTES as k } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
6
+ import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
7
+ class $ {
11
8
  constructor() {
12
- y(this, "parser");
9
+ A(this, "parser");
13
10
  this.parser = new DOMParser();
14
11
  }
15
12
  async migrate(e) {
16
13
  try {
17
- const t = this.parser.parseFromString(e, "text/html"), r = t.querySelectorAll("td.unsubscribe-block");
18
- if (r.length) {
19
- const s = N();
20
- await s.fetchTemplates(), this.migrateLegacyBlocks(r, s, this.collectBlockTags(t));
14
+ const r = this.parser.parseFromString(e, "text/html"), t = r.querySelectorAll("td.unsubscribe-block");
15
+ if (t.length) {
16
+ const s = C();
17
+ await s.fetchTemplates(), this.migrateLegacyBlocks(t, s);
21
18
  }
22
- const n = this.repairUnsubscribeLinks(t);
23
- return !r.length && !n ? e : t.documentElement.outerHTML;
24
- } catch (t) {
25
- return console.error("UnsubscribeMigrator failed:", t), e;
19
+ const n = this.repairUnsubscribeLinks(r);
20
+ return !t.length && !n ? e : r.documentElement.outerHTML;
21
+ } catch (r) {
22
+ return console.error("UnsubscribeMigrator failed:", r), e;
26
23
  }
27
24
  }
28
- migrateLegacyBlocks(e, t, r) {
29
- e.forEach((n) => {
30
- const s = n.getAttribute("id"), i = this.extractPaddingClass(n), c = n.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(n, r), b = this.getCollectionTypeFromMergeTag(a.linkHref), u = t.getSelectedUnsubscribePagesByCollection(b);
25
+ migrateLegacyBlocks(e, r) {
26
+ e.forEach((t) => {
27
+ const n = t.getAttribute("id"), s = this.extractPaddingClass(t), l = t.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(t), o = this.getCollectionTypeFromMergeTag(a.linkHref), b = r.getSelectedUnsubscribePagesByCollection(o);
31
28
  console.debug("[UnsubscribeMigrator]", {
32
29
  mergeTag: a.linkHref,
33
- collectionType: b,
34
- pageIds: u,
35
- paddingClass: i,
36
- bgColor: c
30
+ collectionType: o,
31
+ pageIds: b,
32
+ paddingClass: s,
33
+ bgColor: l
37
34
  });
38
- const o = this.buildUnsubscribeBlock(
35
+ const u = this.buildUnsubscribeBlock(
39
36
  a,
37
+ o,
40
38
  b,
41
- u,
42
- i,
43
- c
44
- ), g = this.parser.parseFromString(
45
- `<table id="tempDoc"><tbody><tr>${o}</tr></tbody></table>`,
39
+ s,
40
+ l
41
+ ), i = this.parser.parseFromString(
42
+ `<table id="tempDoc"><tbody><tr>${u}</tr></tbody></table>`,
46
43
  "text/html"
47
- ).querySelector(A);
48
- g && n.parentNode && (g.setAttribute("id", s || ""), n.parentNode.replaceChild(g, n));
44
+ ).querySelector(h);
45
+ i && t.parentNode && (i.setAttribute("id", n || ""), t.parentNode.replaceChild(i, t));
49
46
  });
50
47
  }
51
- collectBlockTags(e) {
52
- const t = e.querySelectorAll(`td.unsubscribe-block, ${A}`), r = /* @__PURE__ */ new Set();
53
- return t.forEach((n) => {
54
- var a, b, u;
55
- const s = Number(n.getAttribute(T.PAGE_TYPE)), i = l[s], c = (u = (b = (a = this.findLinkCandidates(n).primary) == null ? void 0 : a.getAttribute("href")) == null ? void 0 : b.match(E)) == null ? void 0 : u[0];
56
- i ? r.add(i) : c && r.add(l[this.getCollectionTypeFromMergeTag(c)]);
57
- }), r;
58
- }
59
48
  // Re-derives the typed merge tag from data-unsubscribe-page-type for any v2
60
49
  // block whose anchor href is missing or the legacy default. Returns true when
61
50
  // at least one href was rewritten. Typed tags and custom URLs are left intact.
62
51
  repairUnsubscribeLinks(e) {
63
- const t = e.querySelectorAll(`${A}[${T.PAGE_TYPE}]`);
64
- let r = !1;
65
- return t.forEach((n) => {
52
+ const r = e.querySelectorAll(`${h}[${k.PAGE_TYPE}]`);
53
+ let t = !1;
54
+ return r.forEach((n) => {
66
55
  const s = n.querySelector('a[data-unsubscribe-link="true"], a.unsubscribe-link');
67
56
  if (!s)
68
57
  return;
69
- const i = s.getAttribute("href") || "";
70
- if (i && i !== l.default)
58
+ const l = s.getAttribute("href") || "";
59
+ if (l && l !== f.default)
71
60
  return;
72
- const c = Number(n.getAttribute(T.PAGE_TYPE)), a = l[c];
73
- a && (s.setAttribute("href", a), r = !0);
74
- }), r;
61
+ const a = Number(n.getAttribute(k.PAGE_TYPE)), o = f[a];
62
+ o && (s.setAttribute("href", o), t = !0);
63
+ }), t;
75
64
  }
76
65
  extractPaddingClass(e) {
77
- const r = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
78
- return r ? r[0] : "";
79
- }
80
- hasVisibleContent(e) {
81
- var t;
82
- return !!((t = e.textContent) != null && t.trim() || e.querySelector("img"));
66
+ const t = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
67
+ return t ? t[0] : "";
83
68
  }
84
- findLinkCandidates(e) {
85
- const t = Array.from(/* @__PURE__ */ new Set([
86
- ...Array.from(e.querySelectorAll("a.unsubscribe-link")),
87
- ...Array.from(e.querySelectorAll('a[href*="unsubscribe"]'))
88
- ])), r = (i) => E.test(i.getAttribute("href") || ""), n = (i) => this.hasVisibleContent(i), s = t.find((i) => n(i) && r(i)) ?? t.find((i) => n(i) && i.classList.contains("unsubscribe-link")) ?? t.find(r) ?? t.find(n) ?? t[0];
89
- return { candidates: t, primary: s };
90
- }
91
- extractUnsubscribeContent(e, t) {
92
- const r = e.cloneNode(!0), { candidates: n, primary: s } = this.findLinkCandidates(r), i = (s == null ? void 0 : s.closest("p")) ?? null, c = i || r.querySelector("p"), a = {
93
- footerHtml: "",
94
- linkText: S,
95
- linkHref: l.default,
96
- linkStyle: "",
97
- align: "center",
98
- paragraphStyle: ""
69
+ extractUnsubscribeContent(e) {
70
+ var d;
71
+ const r = e.querySelector("a.unsubscribe-link") || e.querySelector('a[href*="unsubscribe"]'), t = (r == null ? void 0 : r.closest("p")) || e.querySelector("p");
72
+ if (!t)
73
+ return {
74
+ textBefore: "You can ",
75
+ linkText: "unsubscribe",
76
+ linkHref: "{{ins-unsubscribe-link}}",
77
+ linkStyle: "",
78
+ textAfter: " from our emails, if you need to.",
79
+ isBold: !1,
80
+ isItalic: !1,
81
+ align: "center",
82
+ paragraphStyle: ""
83
+ };
84
+ const n = e.getAttribute("align") || t.getAttribute("align") || "center", s = t.getAttribute("style") || "";
85
+ if (!r)
86
+ return {
87
+ textBefore: "You can ",
88
+ linkText: "unsubscribe",
89
+ linkHref: "{{ins-unsubscribe-link}}",
90
+ linkStyle: "",
91
+ textAfter: " from our emails, if you need to.",
92
+ isBold: !1,
93
+ isItalic: !1,
94
+ align: n,
95
+ paragraphStyle: s
96
+ };
97
+ const l = ((d = r.textContent) == null ? void 0 : d.trim()) || "unsubscribe", a = r.getAttribute("href") || "{{ins-unsubscribe-link}}", o = r.getAttribute("style") || "", b = t.textContent || "", u = b.indexOf(l), g = u >= 0 ? b.substring(0, u).trim() : "You can ", i = u >= 0 ? b.substring(u + l.length).trim() : " from our emails, if you need to.", m = !!t.querySelector("b, strong"), y = !!t.querySelector("i, em");
98
+ return {
99
+ textBefore: g,
100
+ linkText: l,
101
+ linkHref: this.normalizeUnsubscribeHref(a),
102
+ linkStyle: o,
103
+ textAfter: i,
104
+ isBold: m,
105
+ isItalic: y,
106
+ align: n,
107
+ paragraphStyle: s
99
108
  };
100
- if (!c || (a.align = e.getAttribute("align") || c.getAttribute("align") || "center", i || (a.paragraphStyle = c.getAttribute("style") || ""), !s))
101
- return a;
102
- if (a.linkText = this.hasVisibleContent(s) ? s.innerHTML.trim() : S, a.linkHref = this.normalizeUnsubscribeHref(s.getAttribute("href") || l.default), a.linkStyle = s.getAttribute("style") || "", i) {
103
- const b = this.getCollectionTypeFromMergeTag(a.linkHref), u = l[b];
104
- r.querySelectorAll("a[href]").forEach((o) => {
105
- var m;
106
- const d = o.getAttribute("href") || "", g = (m = d.match(E)) == null ? void 0 : m[0];
107
- g && o.setAttribute("href", B(d, t.has(g) ? g : u));
108
- }), n.filter((o) => o !== s && !this.hasVisibleContent(o)).forEach((o) => o.replaceWith(...Array.from(o.childNodes))), s.replaceWith(r.ownerDocument.createTextNode(C)), a.footerHtml = r.innerHTML.trim();
109
- }
110
- return a;
111
109
  }
112
- buildUnsubscribeBlock(e, t, r, n, s) {
113
- const i = e.linkStyle ? ` style="${h(e.linkStyle)}"` : "", a = Object.values(l).includes(e.linkHref) ? l[t] : e.linkHref, u = `<a ${`href="${h(a)}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${i}>${e.linkText}</a>`, o = e.paragraphStyle ? ` style="${h(e.paragraphStyle)}"` : "", d = e.footerHtml ? e.footerHtml.replace(C, () => u) : `<p path="1"${o}>${R}${u}${M}</p>`, g = e.align ? ` align="${e.align}"` : "", m = s ? ` bgcolor="${s}"` : "", U = r.length > 0 ? ` ${T.PAGE_LIST}="${r.join(",")}"` : "", L = ` ${T.PAGE_TYPE}="${t}"`, k = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
110
+ buildUnsubscribeBlock(e, r, t, n, s) {
111
+ const l = e.linkStyle ? ` style="${e.linkStyle}"` : "", u = `<a ${`href="${Object.values(f).includes(e.linkHref) ? f[r] : e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${l}>${e.linkText}</a>`, g = [];
112
+ e.textBefore && g.push(e.textBefore), g.push(u), e.textAfter && g.push(e.textAfter);
113
+ let i = g.join(" ");
114
+ e.isBold && e.isItalic ? i = `<strong path="1,0"><em path="1,0,0">${i}</em></strong>` : e.isBold ? i = `<strong path="1,0">${i}</strong>` : e.isItalic && (i = `<em path="1,0">${i}</em>`);
115
+ const m = e.align ? ` align="${e.align}"` : "", y = s ? ` bgcolor="${s}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", T = t.length > 0 ? ` ${k.PAGE_LIST}="${t.join(",")}"` : "", E = ` ${k.PAGE_TYPE}="${r}"`, S = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
114
116
  return `
115
117
  <td
116
118
  data-migration="true"
117
119
  esd-extension-block-id="unsubscribe-block"
118
- class="${n ? `${k} ${n}` : k}"
119
- ${g}${m}${L}${U}
120
+ class="${n ? `${S} ${n}` : S}"
121
+ ${m}${y}${E}${T}
120
122
  >
121
- ${d}
123
+ <p path="1"${d}>
124
+ ${i}
125
+ </p>
122
126
  </td>
123
127
  `;
124
128
  }
125
129
  getCollectionTypeFromMergeTag(e) {
126
- return e === l[p.SUBSCRIPTION_PREFERENCE_CENTER] ? p.SUBSCRIPTION_PREFERENCE_CENTER : e === l[p.GLOBAL_UNSUBSCRIBE] ? p.GLOBAL_UNSUBSCRIBE : p.GLOBAL_UNSUBSCRIBE;
130
+ return e === f[p.SUBSCRIPTION_PREFERENCE_CENTER] ? p.SUBSCRIPTION_PREFERENCE_CENTER : e === f[p.GLOBAL_UNSUBSCRIBE] ? p.GLOBAL_UNSUBSCRIBE : p.GLOBAL_UNSUBSCRIBE;
127
131
  }
128
132
  normalizeUnsubscribeHref(e) {
129
- if (Object.values(l).includes(e))
133
+ if (Object.values(f).includes(e))
130
134
  return e;
131
- const r = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
132
- return r ? r[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
135
+ const t = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
136
+ return t ? t[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
133
137
  `[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
134
138
  ), "{{ins-unsubscribe-link}}") : e;
135
139
  }
136
140
  }
137
- async function q(f) {
138
- return new P().migrate(f);
141
+ async function M(c) {
142
+ return new $().migrate(c);
139
143
  }
140
144
  export {
141
- q as migrateUnsubscribe
145
+ M as migrateUnsubscribe
142
146
  };
@@ -2,7 +2,8 @@ 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
4
  AMP_FOR_EMAILS: `${e}/docs/amp-for-emails`,
5
- EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`
5
+ EMAIL_RECOMMENDATION_BLOCK: `${e}/docs/new-editor-email-recommendation-block`,
6
+ LEGACY_UNSUBSCRIBE_MODULE: `${e}/docs/new-editor-add-unsubscribe-pages-into-emails`
6
7
  };
7
8
  export {
8
9
  o as ACADEMY_LINKS
@@ -17,9 +17,9 @@ import { CurrencyControl as U } from "./currency.js";
17
17
  import { CURRENCY_CONTROL_ID as Ie } from "./currency.js";
18
18
  import { FiltersControl as v } from "./filters.js";
19
19
  import { FILTERS_CONTROL_ID as ke } from "./filters.js";
20
- import { LayoutOrientationControl as A } from "./layoutOrientation.js";
20
+ import { LayoutOrientationControl as w } from "./layoutOrientation.js";
21
21
  import { LAYOUT_ORIENTATION_CONTROL_ID as Oe } from "./layoutOrientation.js";
22
- import { LocaleControl as w } from "./locale.js";
22
+ import { LocaleControl as A } from "./locale.js";
23
23
  import { LOCALE_CONTROL_ID as Be } from "./locale.js";
24
24
  import { PricePlacementControl as V } from "./pricePlacement.js";
25
25
  import { PRICE_PLACEMENT_CONTROL_ID as Le } from "./pricePlacement.js";
@@ -28,7 +28,7 @@ import { PRODUCT_COUNT_CONTROL_ID as Ee } from "./productCount.js";
28
28
  import { ProductLayoutControl as x } from "./productLayout.js";
29
29
  import { PRODUCT_LAYOUT_CONTROL_ID as ve } from "./productLayout.js";
30
30
  import { ShuffleControl as M } from "./shuffle.js";
31
- import { SHUFFLE_CONTROL_ID as we } from "./shuffle.js";
31
+ import { SHUFFLE_CONTROL_ID as Ae } from "./shuffle.js";
32
32
  import { StrategyControl as G } from "./strategy.js";
33
33
  import { STRATEGY_CONTROL_ID as We } from "./strategy.js";
34
34
  import { setCurrencyAttributes as $, getBlockElement as z, isPartnerManagedBlock as H, updateProductContentInPlace as Y, regenerateProductRowsWithStyles as j } from "./utils.js";
@@ -128,7 +128,7 @@ class _e extends I {
128
128
  return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
129
129
  var o;
130
130
  return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
131
- }), this.algorithmControl = new E(), this.localeControl = new w(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new A(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
131
+ }), this.algorithmControl = new E(), this.localeControl = new A(), this.currencyControl = new U(), this.productCountControl = new W(), this.productLayoutControl = new x(), this.filtersControl = new v(), this.shuffleControl = new M(), this.pricePlacementControl = new V(), this.layoutOrientationControl = new w(), this.strategyControl = this.rrsEnabled ? new G() : null, this._subControls.forEach((t) => {
132
132
  t && (t.api = this.api);
133
133
  }), `
134
134
  <div class="recommendation-controls-container">
@@ -452,7 +452,9 @@ class _e extends I {
452
452
  e,
453
453
  this._getNodeConfigUpdates(n.recommendationConfigs),
454
454
  h
455
- ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e }), (i || o) && this._refreshOutsidePanel(e, i);
455
+ ) && console.error("[recommendation] config write outside the panel did not reach a node", { blockId: e });
456
+ const s = o && n.drawnProducts !== n.recommendationProducts;
457
+ (i || s) && this._refreshOutsidePanel(e, i);
456
458
  } catch (n) {
457
459
  console.error("[recommendation] finishing the block outside the panel failed", n);
458
460
  }
@@ -552,8 +554,8 @@ export {
552
554
  v as FiltersControl,
553
555
  Oe as LAYOUT_ORIENTATION_CONTROL_ID,
554
556
  Be as LOCALE_CONTROL_ID,
555
- A as LayoutOrientationControl,
556
- w as LocaleControl,
557
+ w as LayoutOrientationControl,
558
+ A as LocaleControl,
557
559
  Le as PRICE_PLACEMENT_CONTROL_ID,
558
560
  Ee as PRODUCT_COUNT_CONTROL_ID,
559
561
  ve as PRODUCT_LAYOUT_CONTROL_ID,
@@ -561,7 +563,7 @@ export {
561
563
  W as ProductCountControl,
562
564
  x as ProductLayoutControl,
563
565
  _e as RecommendationBlockControl,
564
- we as SHUFFLE_CONTROL_ID,
566
+ Ae as SHUFFLE_CONTROL_ID,
565
567
  We as STRATEGY_CONTROL_ID,
566
568
  M as ShuffleControl,
567
569
  G as StrategyControl,
@@ -1,6 +1,6 @@
1
1
  import { useToaster as L } from "../../../../composables/useToaster.js";
2
2
  import { useTranslations as U } from "../../../../composables/useTranslations.js";
3
- import { getRecommendationFeedSourceMaps as F, strategyEditPath as z, strategyCreatePath as B, getOperatorOptions as M, PriceAttributes as N } from "../../../../enums/extensions/recommendationBlock.js";
3
+ import { getRecommendationFeedSourceMaps as w, strategyEditPath as z, strategyCreatePath as B, getOperatorOptions as M, PriceAttributes as N } from "../../../../enums/extensions/recommendationBlock.js";
4
4
  import { ToasterTypeOptions as E } from "../../../../enums/toaster.js";
5
5
  import { useRecommendationApi as O } from "../../../../services/recommendationApi.js";
6
6
  import { useConfigStore as R } from "../../../../stores/config.js";
@@ -8,21 +8,21 @@ import { defineStore as V } from "pinia";
8
8
  import "../constants/selectors.js";
9
9
  import { DEFAULT_MOBILE_CARDS_IN_ROW as A, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
10
10
  import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as T, EXCLUDED_ALGORITHM_IDS as j } from "../constants/defaultConfig.js";
11
- import { getDefaultProducts as w } from "../templates/utils.js";
11
+ import { getDefaultProducts as F } from "../templates/utils.js";
12
12
  import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
13
13
  import { isLegacyStrategyConfig as $ } from "../utils/legacyStrategyMigration.js";
14
14
  import { getPartnerRecommendationParams as q } from "../utils/partnerCustomizations.js";
15
15
  import { sanitizeProductIds as K } from "../utils/productIds.js";
16
16
  import { isFilterValid as H } from "../validation/filterSchema.js";
17
17
  import { getInvalidFields as J, isConfigValid as Q } from "../validation/requiredFields.js";
18
- const m = O();
18
+ const u = O();
19
19
  let p = null, y = null;
20
20
  const I = /* @__PURE__ */ new Map();
21
21
  let k = null, b = 0;
22
- const u = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
22
+ const m = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
23
23
  function W(t) {
24
24
  const e = _.get(t);
25
- return e && e.token === u.get(t) ? e.outcome : !1;
25
+ return e && e.token === m.get(t) ? e.outcome : !1;
26
26
  }
27
27
  let l = null;
28
28
  const X = () => {
@@ -80,7 +80,8 @@ function G() {
80
80
  syncedConfigFingerprint: null,
81
81
  legacyConversionLoading: !1,
82
82
  configVersion: 0,
83
- adoptedSizeVersion: 0
83
+ adoptedSizeVersion: 0,
84
+ drawnProducts: null
84
85
  };
85
86
  }
86
87
  const Y = () => ({
@@ -173,7 +174,7 @@ const Y = () => ({
173
174
  return [...new Set(t.map((e) => e.filterGroup))].sort((e, n) => e - n);
174
175
  },
175
176
  getActivePredictiveAlgorithms: (t) => {
176
- const e = F(), n = [];
177
+ const e = w(), n = [];
177
178
  return t.activePredictiveAlgorithms.filter((r) => !j.includes(r)).forEach((r) => {
178
179
  n.push(...e.filter((o) => o.id === r));
179
180
  }), n.map((r) => ({
@@ -245,7 +246,7 @@ const Y = () => ({
245
246
  const n = this.blockStates[t];
246
247
  if (n) {
247
248
  const s = structuredClone(n);
248
- s.recommendationConfigs.id = e, s.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (s.isInitialized = !1, s.syncedConfigFingerprint = null), this.blockStates = {
249
+ s.recommendationConfigs.id = e, s.drawnProducts = null, s.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (s.isInitialized = !1, s.syncedConfigFingerprint = null), this.blockStates = {
249
250
  ...this.blockStates,
250
251
  [e]: s
251
252
  };
@@ -256,6 +257,9 @@ const Y = () => ({
256
257
  [o]: i
257
258
  });
258
259
  },
260
+ markProductsDrawn(t, e) {
261
+ this.blockStates[t] && (this.blockStates[t].drawnProducts = e);
262
+ },
259
263
  /**
260
264
  * Marks a block as initialized (initial API data has been fetched).
261
265
  * Automatically cleaned up when removeBlockState deletes the block entry.
@@ -401,7 +405,7 @@ const Y = () => ({
401
405
  const t = b, e = (async () => {
402
406
  this.strategiesLoading = !0;
403
407
  try {
404
- const n = await m.fetchRecommendationStrategies();
408
+ const n = await u.fetchRecommendationStrategies();
405
409
  if (t !== b)
406
410
  return;
407
411
  this.strategies = n, this.strategiesFetched = !0;
@@ -495,7 +499,7 @@ const Y = () => ({
495
499
  const n = typeof t.updated_at == "string" ? t.updated_at : "", r = n ? `${t.strategy_id}:${n}:${e}` : "", o = r ? this.strategyUrlTemplates[r] : void 0;
496
500
  if (o)
497
501
  return o;
498
- const { full_path: i = "" } = await m.generateStrategyEndpoint(t, e) ?? {};
502
+ const { full_path: i = "" } = await u.generateStrategyEndpoint(t, e) ?? {};
499
503
  return r && i && (this.strategyUrlTemplates = {
500
504
  ...this.strategyUrlTemplates,
501
505
  [r]: i
@@ -513,7 +517,7 @@ const Y = () => ({
513
517
  throw new Error("[Guido] convertLegacyStrategy called without an active block");
514
518
  this.blockStates[n].legacyConversionLoading = !0;
515
519
  try {
516
- const r = await m.migrateLegacyStrategy(t, e);
520
+ const r = await u.migrateLegacyStrategy(t, e);
517
521
  this.invalidateStrategies();
518
522
  try {
519
523
  await this.fetchStrategies();
@@ -562,7 +566,7 @@ const Y = () => ({
562
566
  activePredictiveAlgorithms: t,
563
567
  languages: e,
564
568
  currencies: n
565
- } = await m.fetchRecommendationCreateData();
569
+ } = await u.fetchRecommendationCreateData();
566
570
  if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
567
571
  const r = this.blockStates[this.currentRecommendationId];
568
572
  r.filterStatus = !!r.recommendationConfigs.filters.length;
@@ -583,7 +587,7 @@ const Y = () => ({
583
587
  return;
584
588
  }
585
589
  y = (async () => {
586
- const t = await m.fetchRecommendationFilters();
590
+ const t = await u.fetchRecommendationFilters();
587
591
  this.filterList = t;
588
592
  })();
589
593
  try {
@@ -709,14 +713,14 @@ const Y = () => ({
709
713
  await this._doFetchStrategyProducts(e);
710
714
  return;
711
715
  }
712
- const i = (u.get(e) ?? 0) + 1;
713
- u.set(e, i);
716
+ const i = (m.get(e) ?? 0) + 1;
717
+ m.set(e, i);
714
718
  const s = parseInt(r.size) || 6;
715
719
  if (!r.strategy) {
716
720
  this._setBlockProducts(e, [], s);
717
721
  return;
718
722
  }
719
- const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S = F().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", c = {
723
+ const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S = w().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", c = {
720
724
  locale: r.language,
721
725
  currency: r.currencySettings.value,
722
726
  partnerName: o.partnerName,
@@ -730,11 +734,11 @@ const Y = () => ({
730
734
  );
731
735
  let g;
732
736
  try {
733
- g = await m.fetchRecommendationProducts(f, c);
737
+ g = await u.fetchRecommendationProducts(f, c);
734
738
  } catch {
735
739
  g = [];
736
740
  }
737
- u.get(e) === i && this._setBlockProducts(e, g, s);
741
+ m.get(e) === i && this._setBlockProducts(e, g, s);
738
742
  },
739
743
  /**
740
744
  * Block-scoped counterpart of `fetchRecommendationProducts`, which only serves the selected block:
@@ -773,8 +777,8 @@ const Y = () => ({
773
777
  return !0;
774
778
  },
775
779
  _doFetchStrategyProducts(t, e = {}) {
776
- const n = (u.get(t) ?? 0) + 1;
777
- u.set(t, n);
780
+ const n = (m.get(t) ?? 0) + 1;
781
+ m.set(t, n);
778
782
  const r = this._loadStrategyProducts(t, n, e);
779
783
  return _.set(t, { token: n, outcome: r }), r;
780
784
  },
@@ -789,20 +793,20 @@ const Y = () => ({
789
793
  if (s) {
790
794
  i = parseInt(String(s.size ?? "")) || i;
791
795
  const a = r.currencySettings.value, f = (await this.resolveStrategyUrlTemplate(s, a)).replaceAll("{locale}", r.language).replaceAll("{currency}", a), c = f.indexOf("?"), g = c === -1 ? f : f.slice(0, c), S = (c === -1 ? "" : f.slice(c + 1)).split("&").filter((v) => v && !v.startsWith("user_id=")), h = S.length ? `${g}?${S.join("&")}` : g;
792
- h && (o = await m.fetchRecommendationProductsByUrl(h));
796
+ h && (o = await u.fetchRecommendationProductsByUrl(h));
793
797
  }
794
798
  } catch {
795
799
  o = [];
796
800
  }
797
- return u.get(t) !== e ? W(t) : !o.length && n ? !1 : (this._setBlockProducts(t, o, i), o.length > 0);
801
+ return m.get(t) !== e ? W(t) : !o.length && n ? !1 : (this._setBlockProducts(t, o, i), o.length > 0);
798
802
  },
799
803
  _setBlockProducts(t, e, n) {
800
804
  if (!this.blockStates[t])
801
805
  return;
802
- const r = e.length > 0 ? e : w(n);
806
+ const r = e.length > 0 ? e : F(n);
803
807
  this.blockStates[t].recommendationProducts = [
804
808
  ...r.slice(0, n),
805
- ...w(Math.max(0, n - r.length))
809
+ ...F(Math.max(0, n - r.length))
806
810
  ];
807
811
  }
808
812
  }
@@ -1,13 +1,13 @@
1
1
  import { ModificationDescription as a } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
2
  import { RECOMMENDATION_ID_ATTR as m } from "../constants/selectors.js";
3
- import { isPartnerManagedBlock as y, updateProductContentInPlace as I, regenerateProductRowsWithStyles as N } from "../controls/main/utils.js";
3
+ import { isPartnerManagedBlock as N, updateProductContentInPlace as I, regenerateProductRowsWithStyles as O } from "../controls/main/utils.js";
4
4
  import { RecommendationConfigService as c } from "../services/configService.js";
5
- import { useRecommendationExtensionStore as O } from "../store/recommendation.js";
5
+ import { useRecommendationExtensionStore as C } from "../store/recommendation.js";
6
6
  let r = null;
7
- function $(t) {
7
+ function T(t) {
8
8
  r = t;
9
9
  }
10
- function C(t) {
10
+ function p(t) {
11
11
  const n = r == null ? void 0 : r.getDocumentRootHtmlNode();
12
12
  return !n || !("querySelector" in n) ? null : n.querySelector(`[${m}="${t}"]`) ?? null;
13
13
  }
@@ -19,18 +19,18 @@ function R(t, n) {
19
19
  const o = c.getConfig(t);
20
20
  return ["filters", "strategy", "strategyId", "size", "productIds"].some((e) => e in n && JSON.stringify(o[e]) !== JSON.stringify(n[e]));
21
21
  }
22
- const p = "Updated product IDs";
23
- function S(t, n) {
22
+ const S = "Updated product IDs";
23
+ function y(t, n) {
24
24
  if (!("productIds" in n))
25
25
  return !1;
26
26
  const o = c.getConfig(t);
27
27
  return JSON.stringify(o.productIds) !== JSON.stringify(n.productIds);
28
28
  }
29
29
  function h(t, n, o) {
30
- return S(t, n) ? p : o;
30
+ return y(t, n) ? S : o;
31
31
  }
32
- function k(t, n, o) {
33
- const e = C(t);
32
+ function $(t, n, o) {
33
+ const e = p(t);
34
34
  if (!r || !e)
35
35
  return !1;
36
36
  if (R(e, n)) {
@@ -40,7 +40,7 @@ function k(t, n, o) {
40
40
  return !0;
41
41
  }
42
42
  function P(t, n) {
43
- const o = O(), e = o.currentRecommendationId;
43
+ const o = C(), e = o.currentRecommendationId;
44
44
  if (e === t || !o.blockStates[t]) {
45
45
  n();
46
46
  return;
@@ -52,16 +52,17 @@ function P(t, n) {
52
52
  o.$patch({ currentRecommendationId: e });
53
53
  }
54
54
  }
55
- function q(t) {
55
+ function k(t) {
56
56
  const n = r == null ? void 0 : r.getDocumentRootHtmlNode();
57
57
  return !n || !("querySelectorAll" in n) ? [] : n.querySelectorAll(`[${m}="${t}"]`).map((o) => c.getConfig(o));
58
58
  }
59
- function w(t, n, o, e) {
60
- const i = C(t);
59
+ function q(t, n, o, e) {
60
+ const i = p(t);
61
61
  if (!r || !i)
62
62
  return !1;
63
- const f = r.getDocumentModifier(), d = D(i, n), g = S(i, n), s = g ? p : e, l = { currentNode: i, documentModifier: f, products: o, ...g ? { description: s } : {} };
64
- if (c.stageConfig(f, i, n), y(i))
63
+ C().markProductsDrawn(t, o);
64
+ const f = r.getDocumentModifier(), d = D(i, n), g = y(i, n), s = g ? S : e, l = { currentNode: i, documentModifier: f, products: o, ...g ? { description: s } : {} };
65
+ if (c.stageConfig(f, i, n), N(i))
65
66
  return d && f.apply(new a(s)), !0;
66
67
  let u = !1;
67
68
  return P(t, () => {
@@ -70,16 +71,16 @@ function w(t, n, o, e) {
70
71
  onApplied: () => {
71
72
  u = !0;
72
73
  }
73
- }) || (u = N(l));
74
+ }) || (u = O(l));
74
75
  }), !u && d && f.apply(new a(s)), !0;
75
76
  }
76
77
  export {
77
- p as PRODUCT_IDS_DESCRIPTION,
78
- w as commitBlockChangeOutsidePanel,
78
+ S as PRODUCT_IDS_DESCRIPTION,
79
+ q as commitBlockChangeOutsidePanel,
79
80
  R as hasEditedConfigChange,
80
- S as isProductIdsChange,
81
+ y as isProductIdsChange,
81
82
  h as pickConfigDescription,
82
- q as readBlockNodeConfigs,
83
- $ as registerNodeConfigWriter,
84
- k as writeBlockConfigOutsidePanel
83
+ k as readBlockNodeConfigs,
84
+ T as registerNodeConfigWriter,
85
+ $ as writeBlockConfigOutsidePanel
85
86
  };