@useinsider/guido 3.24.0-beta.b9ec78b → 3.24.0-beta.bf47c23

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 (24) hide show
  1. package/dist/composables/useActionsApi.js +2 -2
  2. package/dist/composables/useEditorTrackingIds.js +49 -0
  3. package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
  4. package/dist/config/migrator/recommendationMigrator.js +78 -64
  5. package/dist/config/migrator/unsubscribeMigrator.js +98 -94
  6. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
  7. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
  8. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
  9. package/dist/extensions/Blocks/Unsubscribe/block.js +96 -104
  10. package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +3 -4
  11. package/dist/package.json.js +2 -2
  12. package/dist/services/templateLibraryApi.js +39 -36
  13. package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
  14. package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
  15. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
  16. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
  17. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
  18. package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +0 -1
  19. package/dist/src/utils/linkTrackingIds.d.ts +19 -0
  20. package/dist/utils/linkTrackingIds.js +82 -48
  21. package/dist/utils/templatePreparation.js +30 -33
  22. package/package.json +1 -1
  23. package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +0 -5
  24. package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +0 -1
@@ -1,49 +1,48 @@
1
- var R = Object.defineProperty;
2
- var v = (l, c, e) => c in l ? R(l, c, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[c] = e;
3
- var h = (l, c, e) => v(l, typeof c != "symbol" ? c + "" : c, e);
4
- import { useToaster as D } from "../../../composables/useToaster.js";
5
- import { ToasterTypeOptions as w } from "../../../enums/toaster.js";
6
- import { PAGE_TYPES as B } from "../../../enums/unsubscribe.js";
7
- import { useEditorStore as G } from "../../../stores/editor.js";
8
- import { useUnsubscribeStore as u } from "../../../stores/unsubscribe.js";
9
- import { Block as P, BlockCompositionType as x, ContextActionType as y, ModificationDescription as k, BlockType as M } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
10
- import { getDefaultTemplate as O } from "./template.js";
11
- import { UNSUBSCRIBE_BLOCK_SELECTOR as f, DATA_ATTRIBUTES as o, UNSUBSCRIBE_EVENTS as E, UNSUBSCRIBE_MERGE_TAG_REGEX as I } from "./utils/constants.js";
12
- import { swapMergeTagInHref as q } from "./utils/swapMergeTagInHref.js";
13
- import { parsePageList as L } from "./utils/utils.js";
14
- const F = "unsubscribe-block", _ = 'a[data-unsubscribe-link="true"]', C = "{{ins-unsubscribe-link}}", K = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", H = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", Y = {
15
- [B.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
16
- [B.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
17
- }, V = 3;
18
- let d = null, b = null;
19
- const N = () => {
20
- d && (document.removeEventListener(E.SELECT, d), d = null);
21
- }, U = () => {
22
- b && (document.removeEventListener(E.CANCEL, b), b = null);
23
- }, W = () => {
24
- N(), U();
1
+ var y = Object.defineProperty;
2
+ var I = (c, o, e) => o in c ? y(c, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[o] = e;
3
+ var g = (c, o, e) => I(c, typeof o != "symbol" ? o + "" : o, e);
4
+ import { useToaster as L } from "../../../composables/useToaster.js";
5
+ import { ToasterTypeOptions as C } from "../../../enums/toaster.js";
6
+ import { PAGE_TYPES as m } from "../../../enums/unsubscribe.js";
7
+ import { useEditorStore as N } from "../../../stores/editor.js";
8
+ import { useUnsubscribeStore as a } from "../../../stores/unsubscribe.js";
9
+ import { Block as U, BlockCompositionType as R, ContextActionType as f, ModificationDescription as u, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
10
+ import { getDefaultTemplate as D } from "./template.js";
11
+ import { UNSUBSCRIBE_BLOCK_SELECTOR as B, DATA_ATTRIBUTES as n, UNSUBSCRIBE_EVENTS as h } from "./utils/constants.js";
12
+ import { parsePageList as S } from "./utils/utils.js";
13
+ const w = "unsubscribe-block", E = 'a[data-unsubscribe-link="true"]', P = "{{ins-unsubscribe-link}}", x = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", G = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", M = {
14
+ [m.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
15
+ [m.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
16
+ }, O = 3;
17
+ let d = null, p = null;
18
+ const A = () => {
19
+ d && (document.removeEventListener(h.SELECT, d), d = null);
20
+ }, T = () => {
21
+ p && (document.removeEventListener(h.CANCEL, p), p = null);
22
+ }, q = () => {
23
+ A(), T();
25
24
  };
26
- class se extends P {
25
+ class J extends U {
27
26
  constructor() {
28
27
  super();
29
- h(this, "currentNode");
28
+ g(this, "currentNode");
30
29
  // Per-block "did this instance have a link last time we saw it?" tracking.
31
30
  // Keyed by the stable `data-unsubscribe-block-id` we assign, because
32
31
  // ImmutableHtmlNode instances are recreated on every document mutation and
33
32
  // can't be used as Map keys directly. A singleton boolean here would be
34
33
  // polluted across blocks since Stripo fires onDocumentChanged per-instance.
35
- h(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
34
+ g(this, "linkStateByBlockId", /* @__PURE__ */ new Map());
36
35
  // Per-block prepend retry counter for the leading text guard (SD-143097).
37
- h(this, "guardAttemptsByBlockId", /* @__PURE__ */ new Map());
36
+ g(this, "guardAttemptsByBlockId", /* @__PURE__ */ new Map());
38
37
  }
39
38
  getId() {
40
- return F;
39
+ return w;
41
40
  }
42
41
  getIcon() {
43
42
  return "unsubscribe-icon";
44
43
  }
45
44
  getBlockCompositionType() {
46
- return x.BLOCK;
45
+ return R.BLOCK;
47
46
  }
48
47
  getName() {
49
48
  return this.api.translate("Unsubscribe Block");
@@ -52,16 +51,16 @@ class se extends P {
52
51
  return this.api.translate("Unsubscribe Block Description");
53
52
  }
54
53
  getTemplate() {
55
- return O();
54
+ return D();
56
55
  }
57
56
  getContextActionsIds() {
58
- return [y.MOVE, y.REMOVE];
57
+ return [f.MOVE, f.REMOVE];
59
58
  }
60
59
  onSelect(e) {
61
- if (this.currentNode = e, G().isPreviewModeOpen)
60
+ if (this.currentNode = e, N().isPreviewModeOpen)
62
61
  return;
63
62
  const t = this._getOrAssignBlockId(e);
64
- t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(t), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), t && (u().pendingBlockId = t), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
63
+ t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(t), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), t && (a().pendingBlockId = t), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
65
64
  }
66
65
  onCreated(e) {
67
66
  this._ensureLeadingTextGuard(e);
@@ -69,7 +68,7 @@ class se extends P {
69
68
  onDocumentInit() {
70
69
  try {
71
70
  const e = this.api.getDocumentRoot();
72
- e && "querySelectorAll" in e && e.querySelectorAll(f).forEach((t) => {
71
+ e && "querySelectorAll" in e && e.querySelectorAll(B).forEach((t) => {
73
72
  this._ensureLeadingTextGuard(t);
74
73
  });
75
74
  } catch {
@@ -80,11 +79,11 @@ class se extends P {
80
79
  const t = this._getOrAssignBlockId(e);
81
80
  if (!t)
82
81
  return;
83
- const i = this._hasUnsubscribeLink(e);
84
- this.linkStateByBlockId.get(t) === !0 && !i && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, i);
82
+ const s = this._hasUnsubscribeLink(e);
83
+ this.linkStateByBlockId.get(t) === !0 && !s && this._warnLinkRemoved(), this.linkStateByBlockId.set(t, s);
85
84
  }
86
85
  onDelete(e) {
87
- W(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
86
+ q(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
88
87
  const t = this._readBlockId(e);
89
88
  t && (this.linkStateByBlockId.delete(t), this.guardAttemptsByBlockId.delete(t));
90
89
  }
@@ -96,38 +95,38 @@ class se extends P {
96
95
  _ensureLeadingTextGuard(e) {
97
96
  if (!("querySelector" in e))
98
97
  return;
99
- const t = e.querySelector(_);
98
+ const t = e.querySelector(E);
100
99
  if (!t)
101
100
  return;
102
- let i = t, r = i.parent();
101
+ let s = t, r = s.parent();
103
102
  for (; r && "getTagName" in r && r.getTagName().toLowerCase() !== "p"; )
104
- i = r, r = r.parent();
103
+ s = r, r = r.parent();
105
104
  if (!r || !("getTagName" in r) || r.getTagName().toLowerCase() !== "p")
106
105
  return;
107
- const s = i.previousSibling();
108
- if (!!(s && s.getType() === "text" && s.getTextContent())) {
109
- const a = this._readBlockId(e);
110
- a && this.guardAttemptsByBlockId.delete(a);
106
+ const i = s.previousSibling();
107
+ if (!!(i && i.getType() === "text" && i.getTextContent())) {
108
+ const b = this._readBlockId(e);
109
+ b && this.guardAttemptsByBlockId.delete(b);
111
110
  return;
112
111
  }
113
- const g = this._getOrAssignBlockId(e);
114
- if (!g)
112
+ const k = this._getOrAssignBlockId(e);
113
+ if (!k)
115
114
  return;
116
- const p = this.guardAttemptsByBlockId.get(g) ?? 0;
117
- if (!(p >= V)) {
118
- this.guardAttemptsByBlockId.set(g, p + 1);
115
+ const _ = this.guardAttemptsByBlockId.get(k) ?? 0;
116
+ if (!(_ >= O)) {
117
+ this.guardAttemptsByBlockId.set(k, _ + 1);
119
118
  try {
120
- this.api.getDocumentModifier().modifyHtml(r).prepend(" ").apply(new k("Ensure unsubscribe link text guard"));
121
- } catch (a) {
122
- console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", a);
119
+ this.api.getDocumentModifier().modifyHtml(r).prepend(" ").apply(new u("Ensure unsubscribe link text guard"));
120
+ } catch (b) {
121
+ console.warn("[UnsubscribeBlock] Failed to ensure link text guard:", b);
123
122
  }
124
123
  }
125
124
  }
126
125
  _hasUnsubscribeLink(e) {
127
- return "querySelector" in e ? !!e.querySelector(_) : !1;
126
+ return "querySelector" in e ? !!e.querySelector(E) : !1;
128
127
  }
129
128
  _readBlockId(e) {
130
- return "getAttribute" in e ? e.getAttribute(o.BLOCK_ID) : null;
129
+ return "getAttribute" in e ? e.getAttribute(n.BLOCK_ID) : null;
131
130
  }
132
131
  /**
133
132
  * Returns the block's stable id, assigning one via the document modifier if
@@ -141,13 +140,13 @@ class se extends P {
141
140
  return t;
142
141
  if (!("getAttribute" in e))
143
142
  return null;
144
- const i = this._generateNextBlockId();
143
+ const s = this._generateNextBlockId();
145
144
  try {
146
- this.api.getDocumentModifier().modifyHtml(e).setAttribute(o.BLOCK_ID, i).apply(new k(`Assign unsubscribe block id ${i}`));
145
+ this.api.getDocumentModifier().modifyHtml(e).setAttribute(n.BLOCK_ID, s).apply(new u(`Assign unsubscribe block id ${s}`));
147
146
  } catch (r) {
148
147
  return console.warn("[UnsubscribeBlock] Failed to assign block id:", r), null;
149
148
  }
150
- return i;
149
+ return s;
151
150
  }
152
151
  /**
153
152
  * Generates a unique id by scanning the document for the highest existing
@@ -158,10 +157,10 @@ class se extends P {
158
157
  let e = 0;
159
158
  try {
160
159
  const t = this.api.getDocumentRoot();
161
- t && "querySelectorAll" in t && t.querySelectorAll(f).forEach((r) => {
160
+ t && "querySelectorAll" in t && t.querySelectorAll(B).forEach((r) => {
162
161
  if ("getAttribute" in r) {
163
- const s = r.getAttribute(o.BLOCK_ID), n = s ? parseInt(s) : 0;
164
- n > e && (e = n);
162
+ const i = r.getAttribute(n.BLOCK_ID), l = i ? parseInt(i) : 0;
163
+ l > e && (e = l);
165
164
  }
166
165
  });
167
166
  } catch {
@@ -170,14 +169,14 @@ class se extends P {
170
169
  }
171
170
  _warnLinkRemoved() {
172
171
  try {
173
- const { showToaster: e } = D();
172
+ const { showToaster: e } = L();
174
173
  e({
175
- type: w.Warning,
176
- message: this.api.translate(H),
174
+ type: C.Warning,
175
+ message: this.api.translate(G),
177
176
  actionButton: {
178
177
  text: this.api.translate("Visit Academy"),
179
178
  onClick: () => {
180
- window.open(K, "_blank", "noopener,noreferrer");
179
+ window.open(x, "_blank", "noopener,noreferrer");
181
180
  }
182
181
  }
183
182
  });
@@ -186,62 +185,55 @@ class se extends P {
186
185
  }
187
186
  }
188
187
  _setupSelectEventListener() {
189
- N(), d = (e) => {
190
- const t = e, { collectionType: i, selectedPages: r } = t.detail;
191
- this._updateBlock(i, r.join(","));
192
- }, document.addEventListener(E.SELECT, d);
188
+ A(), d = (e) => {
189
+ const t = e, { collectionType: s, selectedPages: r } = t.detail;
190
+ this._updateBlock(s, r.join(","));
191
+ }, document.addEventListener(h.SELECT, d);
193
192
  }
194
193
  _setupCancelEventListener(e) {
195
- U(), b = (t) => {
196
- const { detail: i } = t;
197
- ((i == null ? void 0 : i.blockId) ?? null) === e && this._handleCancel();
198
- }, document.addEventListener(E.CANCEL, b);
194
+ T(), p = (t) => {
195
+ const { detail: s } = t;
196
+ ((s == null ? void 0 : s.blockId) ?? null) === e && this._handleCancel();
197
+ }, document.addEventListener(h.CANCEL, p);
199
198
  }
200
199
  _handleCancel() {
201
200
  try {
202
201
  if (!this.currentNode)
203
202
  return;
204
- this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${M.EMPTY_CONTAINER}/>`).apply(new k("Removed unsubscribe block due to cancel"));
203
+ this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${v.EMPTY_CONTAINER}/>`).apply(new u("Removed unsubscribe block due to cancel"));
205
204
  } catch (e) {
206
205
  console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
207
206
  }
208
207
  }
209
208
  _updateBlock(e, t) {
210
- var a;
211
209
  if (!this.currentNode || !("querySelector" in this.currentNode))
212
210
  return;
213
- const i = this.currentNode.querySelector(_);
214
- if (!i)
211
+ const s = this.currentNode.querySelector(E);
212
+ if (!s)
215
213
  return;
216
- const r = this._getMergeTag(e), s = this.api.getDocumentModifier(), n = "getAttribute" in i ? i.getAttribute("href") : null, p = [(a = n == null ? void 0 : n.match(I)) == null ? void 0 : a[0], C];
217
- s.modifyHtml(i).setAttribute("href", r), this.currentNode.querySelectorAll("a[href]").forEach((m) => {
218
- var T;
219
- if (!("getAttribute" in m) || m.getAttribute("data-unsubscribe-link") === "true")
220
- return;
221
- const S = m.getAttribute("href") ?? "", A = (T = S.match(I)) == null ? void 0 : T[0];
222
- A && p.includes(A) && s.modifyHtml(m).setAttribute("href", q(S, r));
223
- }), s.modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, t), s.apply(new k(`Updated unsubscribe link to ${r}`));
214
+ const r = this._getMergeTag(e);
215
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", r).apply(new u(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(n.PAGE_TYPE, e.toString()).setAttribute(n.PAGE_LIST, t).apply(new u("Updated unsubscribe block metadata"));
224
216
  }
225
217
  _getMergeTag(e) {
226
- return Y[e] ?? C;
218
+ return M[e] ?? P;
227
219
  }
228
220
  _openDrawer() {
229
221
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
230
222
  try {
231
- const e = u();
223
+ const e = a();
232
224
  e.typeSelectionDrawerStatus = !0;
233
225
  } catch (e) {
234
226
  console.error("[UnsubscribeBlock] Failed to open drawer:", e);
235
227
  }
236
228
  }
237
229
  _checkExistingBlocks() {
238
- const e = u();
239
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((i) => {
240
- if ("getAttribute" in i) {
241
- const r = i.getAttribute(o.PAGE_TYPE);
230
+ const e = a();
231
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(B).forEach((s) => {
232
+ if ("getAttribute" in s) {
233
+ const r = s.getAttribute(n.PAGE_TYPE);
242
234
  if (r) {
243
- const s = Number(r);
244
- s === B.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : s === B.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
235
+ const i = Number(r);
236
+ i === m.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : i === m.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
245
237
  }
246
238
  }
247
239
  });
@@ -249,27 +241,27 @@ class se extends P {
249
241
  async _loadBlockState(e) {
250
242
  if (!("getAttribute" in e))
251
243
  return;
252
- const t = e.getAttribute(o.PAGE_TYPE), i = e.getAttribute(o.PAGE_LIST);
253
- if (!t || !i)
244
+ const t = e.getAttribute(n.PAGE_TYPE), s = e.getAttribute(n.PAGE_LIST);
245
+ if (!t || !s)
254
246
  return;
255
- const r = u(), s = Number(t), n = L(i);
256
- await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(s), r.loadSelectedTemplates(n);
247
+ const r = a(), i = Number(t), l = S(s);
248
+ await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(i), r.loadSelectedTemplates(l);
257
249
  }
258
250
  _resetStoreState() {
259
- u().$reset();
251
+ a().$reset();
260
252
  }
261
253
  _removeBlockTemplatesFromStore(e) {
262
254
  if (!("getAttribute" in e))
263
255
  return;
264
- const t = e.getAttribute(o.PAGE_LIST);
256
+ const t = e.getAttribute(n.PAGE_LIST);
265
257
  if (!t)
266
258
  return;
267
- const i = u(), r = L(t);
268
- i.removeUnsubscribePages(r);
259
+ const s = a(), r = S(t);
260
+ s.removeUnsubscribePages(r);
269
261
  }
270
262
  }
271
263
  export {
272
- F as UNSUBSCRIBE_BLOCK_ID,
273
- se as UnsubscribeBlock,
274
- W as disposeUnsubscribeListeners
264
+ w as UNSUBSCRIBE_BLOCK_ID,
265
+ J as UnsubscribeBlock,
266
+ q as disposeUnsubscribeListeners
275
267
  };
@@ -5,11 +5,10 @@ const s = {
5
5
  PAGE_TYPE: "data-unsubscribe-page-type",
6
6
  PAGE_LIST: "data-unsubscribe-page-list",
7
7
  BLOCK_ID: "data-unsubscribe-block-id"
8
- }, e = ".unsubscribe-block-v2", E = /{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/, c = 'a[data-unsubscribe-link="true"], a.unsubscribe-link';
8
+ }, c = ".unsubscribe-block-v2", u = 'a[data-unsubscribe-link="true"], a.unsubscribe-link';
9
9
  export {
10
10
  b as DATA_ATTRIBUTES,
11
- e as UNSUBSCRIBE_BLOCK_SELECTOR,
11
+ c as UNSUBSCRIBE_BLOCK_SELECTOR,
12
12
  s as UNSUBSCRIBE_EVENTS,
13
- c as UNSUBSCRIBE_LINK_SELECTOR,
14
- E as UNSUBSCRIBE_MERGE_TAG_REGEX
13
+ u as UNSUBSCRIBE_LINK_SELECTOR
15
14
  };
@@ -1,9 +1,9 @@
1
- const o = "3.24.0-beta.b9ec78b", s = { stripo: { version: "2.83.1" } }, e = {
1
+ const o = "3.24.0-beta.bf47c23", s = { stripo: { version: "2.83.1" } }, t = {
2
2
  version: o,
3
3
  guido: s
4
4
  };
5
5
  export {
6
- e as default,
6
+ t as default,
7
7
  s as guido,
8
8
  o as version
9
9
  };
@@ -1,60 +1,63 @@
1
- import { useActionsApi as h } from "../composables/useActionsApi.js";
1
+ import { useActionsApi as A } from "../composables/useActionsApi.js";
2
2
  import { useConfig as S } from "../composables/useConfig.js";
3
- import { useHttp as v } from "../composables/useHttp.js";
3
+ import { useHttp as E } from "../composables/useHttp.js";
4
4
  import { useToaster as x } from "../composables/useToaster.js";
5
- import { useTranslations as A } from "../composables/useTranslations.js";
6
- import { useHtmlDocumentCountValidator as E } from "../composables/validators/useHtmlDocumentCountValidator.js";
5
+ import { useTranslations as P } from "../composables/useTranslations.js";
6
+ import { useHtmlDocumentCountValidator as L } from "../composables/validators/useHtmlDocumentCountValidator.js";
7
7
  import { useLiquidValidator as N } from "../composables/validators/useLiquidValidator.js";
8
8
  import { EditorType as H } from "../enums/defaults.js";
9
- import { ToasterTypeOptions as P } from "../enums/toaster.js";
9
+ import { ToasterTypeOptions as T } from "../enums/toaster.js";
10
10
  import { useRecommendationExtensionStore as D } from "../extensions/Blocks/Recommendation/store/recommendation.js";
11
- import { useSaveAsTemplateStore as L } from "../stores/save-as-template.js";
11
+ import { useSaveAsTemplateStore as q } from "../stores/save-as-template.js";
12
12
  import { base64EncodeWithSpecialChars as r } from "../utils/base64.js";
13
- import { isPlainObject as q } from "../utils/genericUtil.js";
13
+ import { isPlainObject as w } from "../utils/genericUtil.js";
14
14
  import { useTemplatePreparation as F } from "../utils/templatePreparation.js";
15
15
  const Z = () => {
16
- const { get: n, post: m } = v(), { handleError: s, showToaster: l } = x(), { config: c, isFeatureEnabled: p } = S(), { validateLiquidSyntax: T } = N(), { validateSingleHtmlDocument: w } = E(), { getTemplateData: b } = h(), u = A();
16
+ const { get: l, post: c } = E(), { handleError: o, showToaster: i } = x(), { config: p, isFeatureEnabled: u } = S(), { validateLiquidSyntax: b } = N(), { validateSingleHtmlDocument: C } = L(), { getTemplateData: h } = A(), n = P();
17
17
  return {
18
18
  getCategories: async () => {
19
19
  try {
20
- const { data: e = [] } = await n("/newsletter/template-library/get-template-categories");
21
- return e;
20
+ const { data: e } = await l("/newsletter/template-library/get-template-categories");
21
+ return Array.isArray(e) ? e : ((!w(e) || e.type !== "alert") && console.error("[TEMPLATE_LIBRARY_API] Unexpected get-template-categories response", e), i({
22
+ message: n("newsletter.template-library-service-error"),
23
+ type: T.Error
24
+ }), []);
22
25
  } catch (e) {
23
- return s(e, "Failed to fetch template categories"), [];
26
+ return o(e, "Failed to fetch template categories"), [];
24
27
  }
25
28
  },
26
29
  checkTemplateNameAvailability: async (e) => {
27
- const { data: { status: t = !1 } } = await n(
30
+ const { data: { status: t = !1 } } = await l(
28
31
  `/newsletter/template-library/template-name-exists?name=${e}`
29
32
  );
30
33
  return !t;
31
34
  },
32
35
  createCategory: async (e) => {
33
36
  try {
34
- const { data: { id: t } } = await m(
37
+ const { data: { id: t } } = await c(
35
38
  "/newsletter/template-library/create-category",
36
39
  { name: e }
37
40
  );
38
41
  return t.toString();
39
42
  } catch (t) {
40
- return s(t, "Failed to create category"), "";
43
+ return o(t, "Failed to create category"), "";
41
44
  }
42
45
  },
43
46
  createTemplate: async () => {
44
47
  var e, t, d, y;
45
48
  try {
46
- const { prepareTemplateDetails: i } = F(), o = L(), g = await b();
47
- if (!w(g.html))
49
+ const { prepareTemplateDetails: m } = F(), s = q(), g = await h();
50
+ if (!C(g.html))
48
51
  return !1;
49
- const a = await i(g);
50
- if (p("liquidSyntax") && !await T(a.compiledHtml))
52
+ const a = await m(g);
53
+ if (u("liquidSyntax") && !await b(a.compiledHtml))
51
54
  return !1;
52
- const C = {
53
- name: o.getTemplateName,
54
- categories: o.getSelectedCategoryIds,
55
- productId: ((t = (e = c.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
55
+ const v = {
56
+ name: s.getTemplateName,
57
+ categories: s.getSelectedCategoryIds,
58
+ productId: ((t = (e = p.value) == null ? void 0 : e.partner) == null ? void 0 : t.productType) || 0,
56
59
  editorType: H,
57
- messageType: ((y = (d = c.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
60
+ messageType: ((y = (d = p.value) == null ? void 0 : d.partner) == null ? void 0 : y.messageType) || 0,
58
61
  content: r(a.compiledHtml),
59
62
  css: r(a.css),
60
63
  unsubscriptionPreferencePageStatus: !1,
@@ -65,34 +68,34 @@ const Z = () => {
65
68
  recommendationConfigs: r({}),
66
69
  isGuido: !0,
67
70
  // eslint-disable-next-line camelcase
68
- template_engine: p("liquidSyntax") ? 1 : 0,
71
+ template_engine: u("liquidSyntax") ? 1 : 0,
69
72
  stripoConfig: r({
70
73
  editor: "stripo",
71
74
  html: a.rawHtml,
72
75
  css: a.css,
73
76
  dynamicContentList: a.dynamicContentList
74
77
  })
75
- }, { data: f } = await m(
78
+ }, { data: f } = await c(
76
79
  "/newsletter/template-library/create-template",
77
- C
80
+ v
78
81
  );
79
- if (!q(f))
82
+ if (!w(f))
80
83
  throw new Error("Unexpected create-template response");
81
- return f.type === "alert" ? (l({
82
- message: u(
84
+ return f.type === "alert" ? (i({
85
+ message: n(
83
86
  "newsletter.template-library-save-alert",
84
- { templateName: o.getTemplateName }
87
+ { templateName: s.getTemplateName }
85
88
  ),
86
- type: P.Error
87
- }), !1) : (l({
88
- message: u(
89
+ type: T.Error
90
+ }), !1) : (i({
91
+ message: n(
89
92
  "newsletter.template-library-save-success",
90
- { templateName: o.getTemplateName }
93
+ { templateName: s.getTemplateName }
91
94
  ),
92
95
  type: "success"
93
96
  }), !0);
94
- } catch (i) {
95
- return s(i, "Failed to create template"), !1;
97
+ } catch (m) {
98
+ return o(m, "Failed to create template"), !1;
96
99
  }
97
100
  }
98
101
  };
@@ -0,0 +1,7 @@
1
+ export interface EditorTrackingIdsResult {
2
+ changed: boolean;
3
+ nextSeq: number;
4
+ }
5
+ export declare const useEditorTrackingIds: () => {
6
+ writeTrackingIds: (floor: number) => EditorTrackingIdsResult;
7
+ };
@@ -0,0 +1,6 @@
1
+ import type { LegacyProductConfig } from './types';
2
+ /**
3
+ * Rebuilds the `esd-dev-product-config` a pre-Guido block never carried from what it rendered.
4
+ * Null when no product card renders or a card cell cannot be mapped (the rebuild would lose it); other fields default.
5
+ */
6
+ export declare function inferLegacyConfig(block: Element, id: number): LegacyProductConfig | null;
@@ -3,7 +3,7 @@ import type { LegacyProductConfig } from './types';
3
3
  * `esd-dev-product-config` is double-HTML-encoded JSON: serialization
4
4
  * escapes once to embed inside the attribute, and Stripo's templating
5
5
  * layer escapes a second time when round-tripping. Returns `null` when
6
- * the attribute is missing or unable to be parsed — the caller treats
6
+ * the attribute is empty or unable to be parsed — the caller treats
7
7
  * either case as an abort.
8
8
  */
9
9
  export declare function parseLegacyConfig(block: Element): LegacyProductConfig | null;
@@ -1,8 +1,4 @@
1
- /**
2
- * Idempotent: the selector matches only blocks that have
3
- * `esd-dev-product-config` AND lack `recommendation-block-v2`, so
4
- * re-running on a migrated template is a no-op.
5
- */
1
+ /** Idempotent: the selector excludes `recommendation-block-v2`, so re-running on a migrated template is a no-op. */
6
2
  import type { LegacyRecommendationConfig } from '@@/Types/config';
7
3
  /**
8
4
  * Migrate all legacy Recommendation Blocks in the given HTML string.
@@ -57,6 +57,7 @@ interface PerBlockState {
57
57
  legacyConversionLoading: boolean;
58
58
  configVersion: number;
59
59
  adoptedSizeVersion: number;
60
+ drawnProducts: RecommendationProduct[] | null;
60
61
  }
61
62
  /**
62
63
  * Persisted-config subset used by `seedBlockUrlConfig` to reconstruct
@@ -491,6 +492,7 @@ export declare const useRecommendationExtensionStore: import("pinia").StoreDefin
491
492
  * (SD-149916).
492
493
  */
493
494
  cloneBlockState(sourceId: number, newId: number): void;
495
+ markProductsDrawn(id: number, products: RecommendationProduct[]): void;
494
496
  /**
495
497
  * Marks a block as initialized (initial API data has been fetched).
496
498
  * Automatically cleaned up when removeBlockState deletes the block entry.
@@ -9,5 +9,4 @@ export declare const DATA_ATTRIBUTES: {
9
9
  readonly BLOCK_ID: "data-unsubscribe-block-id";
10
10
  };
11
11
  export declare const UNSUBSCRIBE_BLOCK_SELECTOR = ".unsubscribe-block-v2";
12
- export declare const UNSUBSCRIBE_MERGE_TAG_REGEX: RegExp;
13
12
  export declare const UNSUBSCRIBE_LINK_SELECTOR = "a[data-unsubscribe-link=\"true\"], a.unsubscribe-link";
@@ -20,6 +20,25 @@ export declare function readTrackSeq(html: string): number;
20
20
  * Scans the document because a rewrite can strip the seq host but keep the ids.
21
21
  */
22
22
  export declare function readTrackFloor(html: string, persistedCounter?: number): number;
23
+ export interface TrackingIdPlan {
24
+ /** Final id per anchor, in the order the raw values were given. */
25
+ ids: number[];
26
+ reassigned: boolean[];
27
+ nextSeq: number;
28
+ seqChanged: boolean;
29
+ changed: boolean;
30
+ }
31
+ /**
32
+ * The id rule shared by the string transform and the editor-model writer: `rawIds` are the
33
+ * anchors' current `data-ins-track-id` values in document order ('' when absent).
34
+ */
35
+ export declare function planTrackingIds(rawIds: readonly string[], persistedSeq: number, floor?: number): TrackingIdPlan;
36
+ /** Reads a `data-ins-track-seq` attribute value the way readTrackSeq reads it from HTML. */
37
+ export declare function parseTrackSeq(value: string | null): number;
38
+ /** The `data-ins-track-id` value of every `<a>` opening tag in `html`, in order ('' when absent). */
39
+ export declare function readAnchorTrackIds(html: string): string[];
40
+ /** Writes `ids[i]` onto the i-th `<a>` opening tag of `html`; `null` or a missing entry leaves it untouched. */
41
+ export declare function writeAnchorTrackIds(html: string, ids: readonly (number | null)[]): string;
23
42
  /**
24
43
  * Ensures every <a> opening tag carries a unique positive-integer id and the
25
44
  * document records the id high-water mark. Ids are minted above