@useinsider/guido 3.20.1 → 3.21.0-beta.0df5409

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 (90) hide show
  1. package/dist/components/Guido.vue.js +1 -1
  2. package/dist/components/Guido.vue2.js +65 -64
  3. package/dist/components/organisms/AutoSaveController.vue2.js +10 -9
  4. package/dist/components/organisms/header/EditorActions.vue.js +4 -4
  5. package/dist/components/organisms/header/EditorActions.vue2.js +53 -51
  6. package/dist/components/organisms/validation/ValidationErrorDrawer.vue.js +3 -3
  7. package/dist/components/organisms/validation/ValidationErrorDrawer.vue2.js +23 -22
  8. package/dist/composables/useActionsApi.js +80 -63
  9. package/dist/composables/useAutoSave.js +46 -44
  10. package/dist/composables/useGuidoStateBridge.js +3 -3
  11. package/dist/composables/useLegacyStrategyConversion.js +16 -16
  12. package/dist/composables/useSave.js +26 -23
  13. package/dist/composables/useSaveValidation.js +113 -114
  14. package/dist/composables/useSaveValidationRollout.js +17 -6
  15. package/dist/composables/useStripo.js +11 -10
  16. package/dist/extensions/Blocks/Items/block.js +43 -42
  17. package/dist/extensions/Blocks/Recommendation/block.js +33 -29
  18. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +78 -83
  19. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +1 -2
  20. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +2 -12
  21. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +104 -86
  22. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +348 -263
  23. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -50
  24. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +16 -21
  25. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +44 -40
  26. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +14 -19
  27. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +104 -102
  28. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +18 -23
  29. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +312 -286
  30. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +24 -20
  31. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +6 -7
  32. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  33. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +113 -151
  34. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +221 -203
  35. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +28 -0
  36. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  37. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +25 -0
  38. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +111 -40
  39. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +31 -35
  40. package/dist/extensions/Blocks/Unsubscribe/block.js +70 -75
  41. package/dist/guido.css +1 -1
  42. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +271 -192
  43. package/dist/package.json.js +1 -1
  44. package/dist/services/settingsApi.js +11 -0
  45. package/dist/src/components/Guido.vue.d.ts +1 -1
  46. package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
  47. package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
  48. package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
  49. package/dist/src/composables/useActionsApi.d.ts +5 -1
  50. package/dist/src/composables/useAutoSave.d.ts +4 -1
  51. package/dist/src/composables/useSaveValidationRollout.d.ts +1 -0
  52. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +1 -0
  53. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +8 -0
  54. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +40 -0
  55. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +1 -0
  56. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
  57. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +1 -0
  58. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +11 -0
  59. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +3 -6
  60. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +7 -0
  61. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +2 -0
  62. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  63. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +21 -12
  64. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +6 -3
  65. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +6 -5
  66. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -3
  67. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +21 -9
  68. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +19 -13
  69. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +7 -0
  70. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +7 -0
  71. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +7 -0
  72. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +7 -0
  73. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +7 -0
  74. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +10 -8
  75. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +9 -5
  76. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +7 -0
  77. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +9 -1
  78. package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +17 -0
  79. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +6 -0
  80. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +18 -11
  81. package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -6
  82. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +1 -0
  83. package/dist/src/extensions/Blocks/controlFactories.d.ts +22 -0
  84. package/dist/src/services/settingsApi.d.ts +6 -0
  85. package/dist/src/stores/editor.d.ts +3 -1
  86. package/dist/src/stores/setup-settings.d.ts +4 -0
  87. package/dist/static/styles/components/button.css.js +5 -0
  88. package/dist/stores/editor.js +5 -0
  89. package/dist/stores/setup-settings.js +10 -0
  90. package/package.json +4 -4
@@ -1,24 +1,41 @@
1
- import { filterAmpErrors as y } from "../utils/ampErrorFilter.js";
2
- import { getEditorApi as s } from "../utils/stripoEditorApi.js";
3
- import { useToaster as D } from "./useToaster.js";
4
- const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
5
- const f = setTimeout(
6
- () => p(new Error(`${n} did not report completion within ${l}ms`)),
7
- l
8
- ), c = (t) => (e) => {
9
- clearTimeout(f), t(e);
10
- }, d = c(p);
1
+ import { flushPendingNodeConfigWrites as P } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
2
+ import { useEditorStore as H } from "../stores/editor.js";
3
+ import { filterAmpErrors as _ } from "../utils/ampErrorFilter.js";
4
+ import { getEditorApi as c } from "../utils/stripoEditorApi.js";
5
+ import { watch as F } from "vue";
6
+ import { useToaster as M } from "./useToaster.js";
7
+ const O = 1e4, C = 3e4, L = 1e3, T = (i, n, r) => new Promise((s, l) => {
8
+ const p = setTimeout(
9
+ () => l(new Error(`${i} did not report completion within ${n}ms`)),
10
+ n
11
+ ), f = (d) => (S) => {
12
+ clearTimeout(p), d(S);
13
+ }, g = f(l);
11
14
  try {
12
- A(c(C), d);
13
- } catch (t) {
14
- d(t);
15
+ r(f(s), g);
16
+ } catch (d) {
17
+ g(d);
15
18
  }
16
- }), P = () => {
17
- const { handleError: n } = D(), l = (t = {}) => r(
19
+ });
20
+ let A = Promise.resolve();
21
+ const h = () => {
22
+ const i = H(), n = i.changeSeq + P();
23
+ return i.changeSeq >= n || (A = new Promise((r) => {
24
+ let s = () => {
25
+ };
26
+ const l = setTimeout(() => {
27
+ s(), r();
28
+ }, L);
29
+ s = F(() => i.changeSeq, (p) => {
30
+ p >= n && (clearTimeout(l), s(), r());
31
+ });
32
+ })), A;
33
+ }, z = () => {
34
+ const { handleError: i } = M(), n = (t) => T(
18
35
  "compileEmail",
19
- T,
20
- (e, i) => {
21
- const o = { ...{
36
+ C,
37
+ (e, o) => {
38
+ const m = { ...{
22
39
  minimize: !0,
23
40
  utmEntity: {
24
41
  utmSource: "",
@@ -37,56 +54,56 @@ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
37
54
  forceAmp: !1,
38
55
  resetDataSavedFlag: !1,
39
56
  disableLineHeightsReplace: !0
40
- }, ...t }, u = {
41
- callback: (m, g, w, S, v) => {
42
- m ? i(m) : e({
43
- html: g,
44
- ampHtml: w,
45
- ampErrors: y(S ?? []),
46
- displayConditions: v
57
+ }, ...t }, E = {
58
+ callback: (u, y, v, D, I) => {
59
+ u ? o(u) : e({
60
+ html: y,
61
+ ampHtml: v,
62
+ ampErrors: _(D ?? []),
63
+ displayConditions: I
47
64
  });
48
65
  },
49
- ...o
66
+ ...m
50
67
  };
51
- s().actionsApi.compileEmail(u);
68
+ c().actionsApi.compileEmail(E);
69
+ }
70
+ ), r = async (t = {}) => (await h(), n(t)), s = () => T(
71
+ "getTemplateData",
72
+ C,
73
+ (t) => {
74
+ const e = ({ html: o, css: a, width: m, height: w, utmParams: E, syncModulesIds: u }) => t({
75
+ html: o,
76
+ css: a,
77
+ width: m,
78
+ height: w,
79
+ utmParams: E,
80
+ syncModulesIds: u
81
+ });
82
+ c().actionsApi.getTemplateData(e);
52
83
  }
53
84
  );
54
85
  return {
55
- getCompiledEmail: l,
56
- getTemplateData: () => r(
57
- "getTemplateData",
58
- T,
59
- (t) => {
60
- const e = ({ html: i, css: a, width: o, height: E, utmParams: u, syncModulesIds: m }) => t({
61
- html: i,
62
- css: a,
63
- width: o,
64
- height: E,
65
- utmParams: u,
66
- syncModulesIds: m
67
- });
68
- s().actionsApi.getTemplateData(e);
69
- }
70
- ),
86
+ getCompiledEmail: r,
87
+ getTemplateData: async ({ flushPendingEdits: t = !0 } = {}) => (t && await h(), s()),
71
88
  activateCustomViewStyles: (t = !0) => {
72
- s().actionsApi.activateCustomViewStyles(t);
89
+ c().actionsApi.activateCustomViewStyles(t);
73
90
  },
74
91
  getPreviewData: async (t) => {
75
92
  try {
76
93
  const {
77
94
  html: e,
78
- displayConditions: i,
95
+ displayConditions: o,
79
96
  ampHtml: a = "",
80
- ampErrors: o = []
81
- } = await l({ minimize: !1, resetDataSavedFlag: !1, ...t });
97
+ ampErrors: m = []
98
+ } = await r({ minimize: !1, resetDataSavedFlag: !1, ...t });
82
99
  return {
83
100
  html: e,
84
101
  ampHtml: a,
85
- ampErrors: o,
86
- displayConditions: i
102
+ ampErrors: m,
103
+ displayConditions: o
87
104
  };
88
105
  } catch (e) {
89
- return n(e, "Error loading preview"), {
106
+ return i(e, "Error loading preview"), {
90
107
  html: "",
91
108
  ampHtml: "",
92
109
  ampErrors: [],
@@ -95,32 +112,32 @@ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
95
112
  }
96
113
  },
97
114
  updateTimerInClonedTemplate: () => new Promise((t) => {
98
- var e, i;
99
- if (typeof ((i = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : i.updateTimerInClonedTemplate) != "function") {
115
+ var e, o;
116
+ if (typeof ((o = (e = window.StripoEditorApi) == null ? void 0 : e.actionsApi) == null ? void 0 : o.updateTimerInClonedTemplate) != "function") {
100
117
  t(null);
101
118
  return;
102
119
  }
103
120
  try {
104
- window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((a, o) => {
105
- a ? (n(a, "Failed to update timer in cloned template"), t(null)) : t(o || null);
121
+ window.StripoEditorApi.actionsApi.updateTimerInClonedTemplate((a, m) => {
122
+ a ? (i(a, "Failed to update timer in cloned template"), t(null)) : t(m || null);
106
123
  });
107
124
  } catch (a) {
108
- n(a, "Failed to call updateTimerInClonedTemplate"), t(null);
125
+ i(a, "Failed to call updateTimerInClonedTemplate"), t(null);
109
126
  }
110
127
  }),
111
128
  updateHtmlAndCss: (t, e) => {
112
- const { actionsApi: i } = s();
113
- return r("updateHtmlAndCss", h, (a) => {
114
- i.updateHtmlAndCss(t, e, () => a());
129
+ const { actionsApi: o } = c();
130
+ return T("updateHtmlAndCss", O, (a) => {
131
+ o.updateHtmlAndCss(t, e, () => a());
115
132
  });
116
133
  },
117
- editorSave: () => r(
134
+ editorSave: () => T(
118
135
  "save",
119
- T,
136
+ C,
120
137
  (t) => {
121
- s().actionsApi.save((e) => {
138
+ c().actionsApi.save((e) => {
122
139
  if (e) {
123
- n(e, "Failed to save template"), t(!1);
140
+ i(e, "Failed to save template"), t(!1);
124
141
  return;
125
142
  }
126
143
  t(!0);
@@ -130,5 +147,5 @@ const h = 1e4, T = 3e4, r = (n, l, A) => new Promise((C, p) => {
130
147
  };
131
148
  };
132
149
  export {
133
- P as useActionsApi
150
+ z as useActionsApi
134
151
  };
@@ -1,76 +1,78 @@
1
- import { useConfig as E } from "./useConfig.js";
2
- import { useEditorLock as f } from "./useEditorLock.js";
3
- import { useAutosaveStore as p, AUTOSAVE_STATUS as s } from "../stores/autosave.js";
4
- import { useEditorStore as A } from "../stores/editor.js";
5
- import { computed as y, watch as I, onUnmounted as L } from "vue";
6
- const w = 18e4, v = 6e4, R = (b) => {
7
- const { isFeatureEnabled: S } = E(), o = A(), t = p(), { isEditorBusy: g } = f();
8
- let i = null, c = 0;
9
- const u = y(
10
- () => S("autosave") && t.isOn
11
- ), m = () => o.hasChanges && o.isInSaveableState, h = () => ({
12
- hasChanges: o.hasChanges,
13
- isInSaveableState: o.isInSaveableState
14
- }), l = async (e) => {
15
- if (!u.value) {
1
+ import { useConfig as p } from "./useConfig.js";
2
+ import { useEditorLock as y } from "./useEditorLock.js";
3
+ import { useAutosaveStore as I, AUTOSAVE_STATUS as a } from "../stores/autosave.js";
4
+ import { useEditorStore as L } from "../stores/editor.js";
5
+ import { computed as w, watch as V, onUnmounted as k } from "vue";
6
+ const D = 18e4, b = 6e4, _ = (g, { clearsChanges: h = () => !0 } = {}) => {
7
+ const { isFeatureEnabled: m } = p(), s = L(), t = I(), { isEditorBusy: f } = y();
8
+ let o = null, l = 0, u = -1;
9
+ const d = w(
10
+ () => m("autosave") && t.isOn
11
+ ), A = () => s.hasChanges && s.isInSaveableState && s.changeSeq !== u, E = () => ({
12
+ hasChanges: s.hasChanges,
13
+ isInSaveableState: s.isInSaveableState,
14
+ isUnchangedSinceLastSave: s.changeSeq === u
15
+ }), r = async (e) => {
16
+ if (!d.value) {
16
17
  console.debug("guido:autosave:skipped", { trigger: e, reason: "not-active" });
17
18
  return;
18
19
  }
19
- if (!m()) {
20
- console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: h() });
20
+ if (!A()) {
21
+ console.debug("guido:autosave:skipped", { trigger: e, reason: "gates-blocked", gates: E() });
21
22
  return;
22
23
  }
23
- if (t.status === s.SAVING) {
24
+ if (t.status === a.SAVING) {
24
25
  console.debug("guido:autosave:skipped", { trigger: e, reason: "already-saving" });
25
26
  return;
26
27
  }
27
- if (g()) {
28
+ if (f()) {
28
29
  console.debug("guido:autosave:skipped", { trigger: e, reason: "editor-busy" });
29
30
  return;
30
31
  }
31
- e === "visibility" && (c = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = s.SAVING;
32
+ e === "visibility" && (l = Date.now()), console.debug("guido:autosave:save-start", { trigger: e }), t.status = a.SAVING;
33
+ const n = s.changeSeq;
32
34
  try {
33
- if (await b() === void 0) {
34
- console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = s.ERROR;
35
+ if (await g() === void 0) {
36
+ console.debug("guido:autosave:blocked", { trigger: e, reason: "save-returned-undefined" }), t.status = a.ERROR;
35
37
  return;
36
38
  }
37
- o.hasChanges = !1, t.status = s.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
38
- } catch (a) {
39
- console.debug("guido:autosave:error", { trigger: e, error: a }), t.status = s.ERROR;
39
+ u = n, h() && (s.hasChanges = !1), t.status = a.SAVED, t.lastSavedAt = /* @__PURE__ */ new Date(), console.debug("guido:autosave:save-complete", { trigger: e, at: t.lastSavedAt });
40
+ } catch (S) {
41
+ console.debug("guido:autosave:error", { trigger: e, error: S }), t.status = a.ERROR;
40
42
  }
41
- }, n = () => {
43
+ }, i = () => {
42
44
  const { visibilityState: e } = document;
43
45
  if (console.debug("guido:autosave:visibility-change", {
44
46
  visibilityState: e,
45
- isActive: u.value
47
+ isActive: d.value
46
48
  }), e !== "hidden")
47
49
  return;
48
- const a = Date.now() - c;
49
- if (a < v) {
50
+ const n = Date.now() - l;
51
+ if (n < b) {
50
52
  console.debug("guido:autosave:visibility-debounced", {
51
- sinceLastMs: a,
52
- debounceMs: v
53
+ sinceLastMs: n,
54
+ debounceMs: b
53
55
  });
54
56
  return;
55
57
  }
56
- l("visibility");
57
- }, d = () => {
58
- i && (clearInterval(i), i = null);
59
- }, r = () => {
60
- document.removeEventListener("visibilitychange", n), window.removeEventListener("pagehide", n);
58
+ r("visibility");
59
+ }, c = () => {
60
+ o && (clearInterval(o), o = null);
61
+ }, v = () => {
62
+ document.removeEventListener("visibilitychange", i), window.removeEventListener("pagehide", i);
61
63
  };
62
- I(
63
- u,
64
+ V(
65
+ d,
64
66
  (e) => {
65
- console.debug("guido:autosave:active-changed", { active: e }), e ? (d(), i = setInterval(() => {
66
- console.debug("guido:autosave:interval-tick"), l("interval");
67
- }, w), document.addEventListener("visibilitychange", n), window.addEventListener("pagehide", n)) : (d(), r(), t.status = s.IDLE);
67
+ console.debug("guido:autosave:active-changed", { active: e }), e ? (c(), o = setInterval(() => {
68
+ console.debug("guido:autosave:interval-tick"), r("interval");
69
+ }, D), document.addEventListener("visibilitychange", i), window.addEventListener("pagehide", i)) : (c(), v(), t.status = a.IDLE);
68
70
  },
69
71
  { immediate: !0 }
70
- ), L(() => {
71
- d(), r(), t.status = s.IDLE, t.lastSavedAt = null;
72
+ ), k(() => {
73
+ c(), v(), t.status = a.IDLE, t.lastSavedAt = null;
72
74
  });
73
75
  };
74
76
  export {
75
- R as useAutoSave
77
+ _ as useAutoSave
76
78
  };
@@ -5,7 +5,7 @@ import { useEditorStore as w } from "../stores/editor.js";
5
5
  import { useGuidoEmailEditorStore as y } from "../stores/guido-email-editor.js";
6
6
  import { watch as c, onUnmounted as z } from "vue";
7
7
  const B = 500, G = () => {
8
- const i = w(), u = y(), d = T(), { getTemplateData: l } = v(), { runExclusive: m, isEditorBusy: p } = C();
8
+ const i = w(), d = y(), l = T(), { getTemplateData: u } = v(), { runExclusive: m, isEditorBusy: p } = C();
9
9
  let o = null, n = !1;
10
10
  const r = () => {
11
11
  o && (clearTimeout(o), o = null);
@@ -21,10 +21,10 @@ const B = 500, G = () => {
21
21
  return;
22
22
  }
23
23
  try {
24
- const { html: E, css: I } = await m(l), b = ((s = (t = d.config) == null ? void 0 : t.identity) == null ? void 0 : s.templateId) ?? "";
24
+ const { html: E, css: I } = await m(() => u({ flushPendingEdits: !1 })), b = ((s = (t = l.config) == null ? void 0 : t.identity) == null ? void 0 : s.templateId) ?? "";
25
25
  if (n)
26
26
  return;
27
- u.$patch({
27
+ d.$patch({
28
28
  html: E ?? "",
29
29
  css: I ?? "",
30
30
  templateId: b,
@@ -1,34 +1,34 @@
1
- import { useRecommendation as C } from "./useRecommendation.js";
1
+ import { useRecommendation as S } from "./useRecommendation.js";
2
2
  import { useToaster as I } from "./useToaster.js";
3
3
  import { useTranslations as v } from "./useTranslations.js";
4
4
  import { ToasterTypeOptions as g } from "../enums/toaster.js";
5
5
  import "../extensions/Blocks/Recommendation/constants/selectors.js";
6
6
  import { CURRENT_CONFIG_VERSION as L } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
7
- import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
- import { resolveMigrationTarget as k, buildLegacyMigrationPayload as R } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
7
+ import { useRecommendationExtensionStore as R } from "../extensions/Blocks/Recommendation/store/recommendation.js";
8
+ import { resolveMigrationTarget as b, buildLegacyMigrationPayload as k } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js";
9
9
  import { commitBlockChangeOutsidePanel as T } from "../extensions/Blocks/Recommendation/utils/nodeConfigWriter.js";
10
10
  import { useConfigStore as h } from "../stores/config.js";
11
11
  const F = () => {
12
- const e = b(), r = h(), { buildCampaignUrl: m } = C(), { showToaster: c } = I(), a = v();
12
+ const e = R(), o = h(), { buildCampaignUrl: m } = S(), { showToaster: c } = I(), a = v();
13
13
  return { convertLegacyStrategy: async () => {
14
14
  const t = e.currentRecommendationId;
15
15
  if (t === null || !e.isLegacyStrategyBlock || e.legacyConversionLoading)
16
16
  return "";
17
- const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = k({
18
- campaignId: r.campaignId,
19
- templateLibraryId: r.templateLibraryId
20
- }), S = R({
17
+ const { strategy: d, productIds: y, size: l, strategyId: p, nodeConfigVersion: u } = e.recommendationConfigs, f = { strategyId: p, size: l, nodeConfigVersion: u }, s = b({
18
+ campaignId: o.campaignId,
19
+ templateLibraryId: o.templateLibraryId
20
+ }), C = k({
21
21
  blockId: t,
22
22
  url: m(String(t)),
23
- campaignId: r.campaignId,
24
- variationId: r.variationId,
23
+ campaignId: o.campaignId,
24
+ variationId: o.variationId,
25
25
  strategy: d,
26
26
  productIds: y,
27
27
  target: s
28
28
  });
29
- let o;
29
+ let r;
30
30
  try {
31
- o = await e.convertLegacyStrategy(S, s);
31
+ r = await e.convertLegacyStrategy(C, s);
32
32
  } catch (i) {
33
33
  return console.error("[useLegacyStrategyConversion] migration failed", i), c({
34
34
  type: g.Error,
@@ -40,7 +40,7 @@ const F = () => {
40
40
  }), "";
41
41
  }
42
42
  try {
43
- await e.fetchStrategyProductsForBlock(t);
43
+ await e.fetchRecommendationProductsForBlock(t);
44
44
  } catch (i) {
45
45
  console.error("[useLegacyStrategyConversion] product refetch failed", i);
46
46
  }
@@ -48,16 +48,16 @@ const F = () => {
48
48
  return n ? T(
49
49
  t,
50
50
  {
51
- strategyId: o,
51
+ strategyId: r,
52
52
  size: n.recommendationConfigs.size,
53
53
  configVersion: L
54
54
  },
55
55
  n.recommendationProducts,
56
56
  "Converted legacy recommendation strategy"
57
- ) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), o) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
57
+ ) ? (e.currentRecommendationId === t && e.openLegacyStrategyUpdatedModal(), r) : (console.error("[useLegacyStrategyConversion] node write failed", t), e.revertLegacyConversion(t, f), c({
58
58
  type: g.Error,
59
59
  message: a("email-editor.legacy-strategy-update-failed")
60
- }), "") : o;
60
+ }), "") : r;
61
61
  } };
62
62
  };
63
63
  export {
@@ -1,4 +1,4 @@
1
- import { useActionsApi as W } from "./useActionsApi.js";
1
+ import { useActionsApi as R } from "./useActionsApi.js";
2
2
  import { useConfig as q } from "./useConfig.js";
3
3
  import { useEditorLock as O } from "./useEditorLock.js";
4
4
  import { useSaveStart as D, useSaveComplete as F } from "./useGuidoActions.js";
@@ -19,37 +19,37 @@ import { useLiquidValidator as et } from "./validators/useLiquidValidator.js";
19
19
  import { useSyncModuleBlockValidator as ot } from "./validators/useSyncModuleBlockValidator.js";
20
20
  import { useUnsubscribeBlockValidator as st } from "./validators/useUnsubscribeBlockValidator.js";
21
21
  const Bt = () => {
22
- const r = D(), f = F(), { validateHtml: p } = _(), { validateLiquidSyntax: v } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: S, validateUnsubscribeBlockHasTemplate: w } = st(), { validateSyncModuleBlocks: n } = ot(), { callbacks: a, isFeatureEnabled: m } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: E, getTemplateData: H } = W(), { showToaster: V } = $(), { getBlockedDomains: x, resolveToast: k } = Z(), { prepareTemplateDetails: d } = X(), { collectSaveValidationErrors: C } = j(), { isEnabled: B } = z(), T = Q(), h = N(), P = K(), { runExclusive: l } = O(), c = async (t, e, o) => {
23
- if (!m("allowlistEnabled"))
22
+ const a = D(), p = F(), { validateHtml: v } = _(), { validateLiquidSyntax: S } = et(), { validateCouponBlockTags: y } = tt(), { validateUnsubscribeBlockUniqueness: w, validateUnsubscribeBlockHasTemplate: E } = st(), { validateSyncModuleBlocks: n } = ot(), { callbacks: r, isFeatureEnabled: d } = q(), { extractSyncModuleData: b } = G(), { setSyncModuleUnsubscriptionPages: g } = J(), { editorSave: H, getTemplateData: V } = R(), { showToaster: x } = $(), { getBlockedDomains: k, resolveToast: C } = Z(), { prepareTemplateDetails: m } = X(), { collectSaveValidationErrors: B } = j(), { isEnabled: h } = z(), T = Q(), P = N(), f = K(), { runExclusive: l } = O(), c = async (t, e, o) => {
23
+ if (!d("allowlistEnabled"))
24
24
  return !1;
25
- const i = await x(t, e);
25
+ const i = await k(t, e);
26
26
  if (!i.length)
27
27
  return !1;
28
28
  if (!o) {
29
- const s = await k(i);
30
- s != null && s.message && V({
29
+ const s = await C(i);
30
+ s != null && s.message && x({
31
31
  type: I.Warning,
32
32
  message: s.message,
33
33
  actionButton: s.actionButton
34
34
  });
35
35
  }
36
36
  return !0;
37
- }, L = async (t) => !y(t.compiledHtml) || !S(t.compiledHtml) || !w(t.compiledHtml) ? !1 : m("liquidSyntax") ? v(t.compiledHtml) : p(t.compiledHtml, t.dynamicContentList, !0), u = async (t, e) => {
38
- if (!await E())
37
+ }, L = async (t) => !y(t.compiledHtml) || !w(t.compiledHtml) || !E(t.compiledHtml) ? !1 : d("liquidSyntax") ? S(t.compiledHtml) : v(t.compiledHtml, t.dynamicContentList, !0), u = async (t, e) => {
38
+ if (!await H())
39
39
  return;
40
40
  const { unsubscribePayload: i, stripoModules: s } = b(t.rawHtml);
41
41
  if (await g(i), t.modules = s, !e.suppress) {
42
- const R = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
43
- f({ ...t, ...R, silent: e.silent });
42
+ const W = e.blankCompiled ? { compiledHtml: "", ampHtml: "" } : {};
43
+ p({ ...t, ...W, silent: e.silent });
44
44
  }
45
45
  return t;
46
46
  }, U = async (t, e) => {
47
47
  var i;
48
- r();
49
- const o = await d();
48
+ a();
49
+ const o = await m();
50
50
  if (n(o.rawHtml, e)) {
51
- if (B.value && !e) {
52
- const s = await C(
51
+ if (h.value && !e) {
52
+ const s = await B(
53
53
  o.compiledHtml,
54
54
  o.dynamicContentList
55
55
  );
@@ -59,31 +59,34 @@ const Bt = () => {
59
59
  }
60
60
  } else if (!await L(o))
61
61
  return;
62
- if (!((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(o)) && !await c(o.compiledHtml, o.css, e))
62
+ if (!((i = r.value) != null && i.externalValidation && !await r.value.externalValidation(o)) && !await c(o.compiledHtml, o.css, e))
63
63
  return u(o, { silent: e, suppress: t });
64
64
  }
65
65
  }, A = async () => {
66
66
  var e;
67
- if (!P.allowSaveWithErrors)
67
+ if (!f.allowSaveWithErrors)
68
68
  return;
69
- r();
70
- const t = await d();
71
- if (n(t.rawHtml, !1) && !((e = a.value) != null && e.externalValidation && !await a.value.externalValidation(t)) && !await c(t.compiledHtml, t.css, !1))
69
+ a();
70
+ const t = await m();
71
+ if (n(t.rawHtml, !1) && !((e = r.value) != null && e.externalValidation && !await r.value.externalValidation(t)) && !await c(t.compiledHtml, t.css, !1))
72
72
  return u(t, { silent: !1, blankCompiled: !0 });
73
73
  }, M = async () => {
74
- r();
75
- const { html: t, css: e } = await H();
74
+ if (!f.allowSaveWithErrors)
75
+ return;
76
+ a();
77
+ const { html: t, css: e } = await V();
76
78
  if (!n(t, !0) || await c(t, e, !0))
77
79
  return;
78
80
  const o = Y(t), i = {
79
- dynamicContentList: h.getSelectedDynamicContentList,
81
+ dynamicContentList: P.getSelectedDynamicContentList,
80
82
  compiledHtml: "",
81
83
  rawHtml: t,
82
84
  css: e,
83
85
  ampHtml: "",
84
86
  ampErrors: [],
85
87
  modules: [],
86
- recommendation: { campaignUrls: {}, configs: {} },
88
+ // No campaignUrls: hosts overwrite their stored map with any object, and raw HTML can't rebuild it.
89
+ recommendation: { configs: {} },
87
90
  unsubscribe: {
88
91
  status: o.length > 0,
89
92
  config: o