@useinsider/guido 2.1.0-beta.1e94a90 → 2.1.0-beta.2169bf2

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 (80) hide show
  1. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  2. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  3. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  5. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +5 -3
  6. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +1 -1
  7. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +23 -21
  8. package/dist/components/organisms/extensions/recommendation/LogicAdapter.vue2.js +11 -9
  9. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  10. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  11. package/dist/composables/useRecommendation.js +9 -9
  12. package/dist/composables/useStripo.js +25 -23
  13. package/dist/composables/useVersionHistoryApi.js +1 -1
  14. package/dist/config/compiler/utils/recommendationCompilerUtils.js +1 -1
  15. package/dist/config/i18n/en/index.js +11 -0
  16. package/dist/config/i18n/en/labels.json.js +7 -0
  17. package/dist/config/i18n/en/toasters.json.js +56 -0
  18. package/dist/config/i18n/en/tooltips.json.js +82 -0
  19. package/dist/config/i18n/index.js +7 -0
  20. package/dist/config/migrator/itemsBlockMigrator.js +65 -64
  21. package/dist/config/migrator/recommendationMigrator.js +1 -1
  22. package/dist/extensions/Blocks/Recommendation/block.js +1 -1
  23. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -33
  24. package/dist/extensions/Blocks/Recommendation/constants/layout.js +16 -14
  25. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -13
  26. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +9 -9
  27. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +1 -1
  28. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +41 -29
  29. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +16 -16
  30. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +30 -32
  31. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +172 -101
  32. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +9 -9
  33. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +46 -38
  34. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +16 -16
  35. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +291 -217
  36. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +14 -14
  37. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +10 -10
  38. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +5 -5
  39. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +14 -14
  40. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +9 -9
  41. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.js +3 -3
  42. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.js +1 -1
  43. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +9 -9
  44. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.js +3 -3
  45. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.js +13 -13
  46. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +3 -3
  47. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +223 -99
  48. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +106 -55
  49. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +2 -2
  50. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +1 -1
  51. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +2 -2
  52. package/dist/extensions/Blocks/Recommendation/templates/utils.js +32 -32
  53. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  54. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  55. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  56. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  57. package/dist/guido.css +1 -1
  58. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +3 -1
  59. package/dist/src/config/i18n/en/index.d.ts +1 -0
  60. package/dist/src/config/i18n/index.d.ts +16 -0
  61. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +6 -0
  62. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +3 -3
  63. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +6 -2
  64. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +8 -1
  65. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +33 -10
  66. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +27 -14
  67. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +50 -17
  68. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -0
  69. package/dist/src/extensions/Blocks/Recommendation/templates/grid/migration.d.ts +1 -1
  70. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +4 -2
  71. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +1 -1
  72. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +1 -1
  73. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +8 -0
  74. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  75. package/dist/static/styles/components/notification.css.js +18 -0
  76. package/dist/static/styles/components/tools.css.js +6 -2
  77. package/dist/static/styles/customEditorStyle.css.js +50 -23
  78. package/dist/static/styles/variables.css.js +2 -0
  79. package/dist/stores/unsubscribe.js +37 -34
  80. package/package.json +2 -2
@@ -1,15 +1,17 @@
1
- import { RecommendationFeedSourceMaps as d, getOperatorOptions as S, PriceAttributes as p } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as b } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as I } from "../../../../stores/config.js";
4
- import { defineStore as R } from "pinia";
5
- import { DEFAULT_CARDS_IN_ROW as k } from "../constants/layout.js";
6
- import { getDefaultProducts as C } from "../templates/utils.js";
7
- import { generateCompleteFilterQuery as f } from "../utils/filterUtil.js";
8
- import { isFilterValid as y } from "../validation/filterSchema.js";
9
- const m = b();
10
- function h() {
1
+ import { RecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as k } from "../../../../enums/extensions/recommendationBlock.js";
2
+ import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
3
+ import { useConfigStore as C } from "../../../../stores/config.js";
4
+ import { defineStore as G } from "pinia";
5
+ import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
+ import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
7
+ import { getDefaultProducts as S } from "../templates/utils.js";
8
+ import { generateCompleteFilterQuery as I } from "../utils/filterUtil.js";
9
+ import { isFilterValid as D } from "../validation/filterSchema.js";
10
+ const h = y();
11
+ let u = null, m = null, d = null;
12
+ function b() {
11
13
  return {
12
- cardsInRow: k,
14
+ cardsInRow: F,
13
15
  currencySettings: {
14
16
  name: "USD",
15
17
  value: "USD",
@@ -33,9 +35,9 @@ function h() {
33
35
  size: "6"
34
36
  };
35
37
  }
36
- function G() {
38
+ function P() {
37
39
  return {
38
- recommendationConfigs: h(),
40
+ recommendationConfigs: b(),
39
41
  recommendationProducts: [],
40
42
  filterStatus: !1,
41
43
  filterSelectionDrawerStatus: !1,
@@ -44,7 +46,7 @@ function G() {
44
46
  filterSnapshot: null
45
47
  };
46
48
  }
47
- const F = () => ({
49
+ const v = () => ({
48
50
  recommendationCampaignUrls: {},
49
51
  activePredictiveAlgorithms: [],
50
52
  languages: {},
@@ -53,8 +55,8 @@ const F = () => ({
53
55
  blockStates: {},
54
56
  currentRecommendationId: null,
55
57
  configVersion: 0
56
- }), V = R("guidoRecommendationExtension", {
57
- state: () => F(),
58
+ }), E = G("guidoRecommendationExtension", {
59
+ state: () => v(),
58
60
  getters: {
59
61
  // ====================================================================
60
62
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -64,7 +66,7 @@ const F = () => ({
64
66
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
65
67
  */
66
68
  recommendationConfigs(t) {
67
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : h();
69
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : b();
68
70
  },
69
71
  /**
70
72
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -110,8 +112,8 @@ const F = () => ({
110
112
  },
111
113
  getActivePredictiveAlgorithms: (t) => {
112
114
  const r = [];
113
- return t.activePredictiveAlgorithms.forEach((e) => {
114
- r.push(...d.filter((n) => n.id === e));
115
+ return t.activePredictiveAlgorithms.filter((e) => !w.includes(e)).forEach((e) => {
116
+ r.push(...g.filter((n) => n.id === e));
115
117
  }), r.map((e) => ({
116
118
  text: e.name,
117
119
  value: e.key
@@ -127,7 +129,7 @@ const F = () => ({
127
129
  })),
128
130
  getFilterList() {
129
131
  return Object.values(this.filterList).map((t) => {
130
- const r = t.type === "defaultAttribute", e = p.includes(t.attributeName);
132
+ const r = t.type === "defaultAttribute", e = k.includes(t.attributeName);
131
133
  let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
132
134
  return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
133
135
  text: t.displayName,
@@ -151,7 +153,7 @@ const F = () => ({
151
153
  setCurrentBlock(t) {
152
154
  this.blockStates[t] || (this.blockStates = {
153
155
  ...this.blockStates,
154
- [t]: G()
156
+ [t]: P()
155
157
  }), this.currentRecommendationId = t;
156
158
  },
157
159
  /**
@@ -195,7 +197,7 @@ const F = () => ({
195
197
  * Creates a filter with the first available attribute and operator pre-selected.
196
198
  */
197
199
  createDefaultFilter(t, r) {
198
- const [e] = this.getFilterList, [n] = S(e == null ? void 0 : e.type);
200
+ const [e] = this.getFilterList, [n] = R(e == null ? void 0 : e.type);
199
201
  return {
200
202
  type: "standardFilter",
201
203
  attribute: (e == null ? void 0 : e.value) ?? "",
@@ -246,22 +248,46 @@ const F = () => ({
246
248
  // Shared Data Fetching (fetched once, used by all blocks)
247
249
  // ====================================================================
248
250
  async fetchRecommendationCreateData() {
249
- if (this.activePredictiveAlgorithms.length)
250
- return;
251
- const {
252
- activePredictiveAlgorithms: t,
253
- languages: r,
254
- currencies: e
255
- } = await m.fetchRecommendationCreateData();
256
- if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
257
- const n = this.blockStates[this.currentRecommendationId];
258
- n.filterStatus = !!n.recommendationConfigs.filters.length;
251
+ if (!this.activePredictiveAlgorithms.length) {
252
+ if (u) {
253
+ await u;
254
+ return;
255
+ }
256
+ u = (async () => {
257
+ const {
258
+ activePredictiveAlgorithms: t,
259
+ languages: r,
260
+ currencies: e
261
+ } = await h.fetchRecommendationCreateData();
262
+ if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
263
+ const n = this.blockStates[this.currentRecommendationId];
264
+ n.filterStatus = !!n.recommendationConfigs.filters.length;
265
+ }
266
+ this.currencyList = e;
267
+ })();
268
+ try {
269
+ await u;
270
+ } finally {
271
+ u = null;
272
+ }
259
273
  }
260
- this.currencyList = e;
261
274
  },
262
275
  async fetchRecommendationFilters() {
263
- const t = await m.fetchRecommendationFilters();
264
- this.filterList = t;
276
+ if (!Object.keys(this.filterList).length) {
277
+ if (m) {
278
+ await m;
279
+ return;
280
+ }
281
+ m = (async () => {
282
+ const t = await h.fetchRecommendationFilters();
283
+ this.filterList = t;
284
+ })();
285
+ try {
286
+ await m;
287
+ } finally {
288
+ m = null;
289
+ }
290
+ }
265
291
  },
266
292
  // ====================================================================
267
293
  // Per-Block Filter Actions
@@ -274,10 +300,10 @@ const F = () => ({
274
300
  deleteFilterGroup(t) {
275
301
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
276
302
  return;
277
- const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), s = new Map(n.map((i, o) => [i, o + 1]));
303
+ const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
278
304
  r.recommendationConfigs.filters = e.map((i) => ({
279
305
  ...i,
280
- filterGroup: s.get(i.filterGroup) ?? i.filterGroup
306
+ filterGroup: c.get(i.filterGroup) ?? i.filterGroup
281
307
  }));
282
308
  },
283
309
  updateFilter(t) {
@@ -288,7 +314,7 @@ const F = () => ({
288
314
  const n = [...r.recommendationConfigs.filters];
289
315
  n[e] = {
290
316
  ...t,
291
- isValid: y(t)
317
+ isValid: D(t)
292
318
  }, r.recommendationConfigs.filters = n;
293
319
  }
294
320
  },
@@ -297,35 +323,57 @@ const F = () => ({
297
323
  return;
298
324
  const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
299
325
  if (e !== -1) {
300
- const n = [...r.recommendationConfigs.filters];
301
- n.splice(e, 1), r.recommendationConfigs.filters = n;
326
+ let n = [...r.recommendationConfigs.filters];
327
+ if (n.splice(e, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
328
+ let i = 1;
329
+ n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
330
+ } else {
331
+ const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, l) => s - l), o = new Map(i.map((s, l) => [s, l + 1]));
332
+ n = n.map((s) => ({
333
+ ...s,
334
+ filterGroup: o.get(s.filterGroup) ?? s.filterGroup
335
+ }));
336
+ }
337
+ r.recommendationConfigs.filters = n;
302
338
  }
303
339
  },
304
340
  addFilter(t) {
305
341
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
306
342
  return;
307
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], s = e.filter(
343
+ const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], c = e.filter(
308
344
  (o) => o.filterGroup === t.filterGroup
309
345
  ).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
310
346
  i !== -1 ? e.splice(i + 1, 0, {
311
347
  ...t,
312
- filterNumber: s
348
+ filterNumber: c
313
349
  }) : e.push({
314
350
  ...t,
315
- filterNumber: s
351
+ filterNumber: c
316
352
  }), r.recommendationConfigs.filters = e;
317
353
  },
318
354
  generateFilterQuery() {
319
- return f(this.recommendationConfigs.filters);
355
+ return I(this.recommendationConfigs.filters);
320
356
  },
321
357
  // ====================================================================
322
358
  // Per-Block Product Fetching
323
359
  // ====================================================================
324
360
  async fetchRecommendationProducts() {
325
- var u;
326
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
327
- return;
328
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((l) => l.isValid), s = f(n), i = ((u = d.find((l) => l.key === e.strategy)) == null ? void 0 : u.path) || "", o = I(), c = {
361
+ if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
362
+ if (d) {
363
+ await d;
364
+ return;
365
+ }
366
+ d = this._doFetchProducts();
367
+ try {
368
+ await d;
369
+ } finally {
370
+ d = null;
371
+ }
372
+ }
373
+ },
374
+ async _doFetchProducts() {
375
+ var p;
376
+ const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), c = I(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = C(), s = {
329
377
  locale: e.language,
330
378
  currency: e.currencySettings.value,
331
379
  partnerName: o.partnerName,
@@ -333,18 +381,21 @@ const F = () => ({
333
381
  details: !0,
334
382
  campaignId: o.variationId
335
383
  };
336
- e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), s && (c.filter = s), e.shuffleProducts && (c.shuffle = !0);
337
- const g = parseInt(e.size) || 6;
338
- let a;
384
+ e.strategy === "manualMerchandising" ? s.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (s.productId = "{itemId}"), e.strategy === "userBased" && (s.userId = "{user_id}"), c && (s.filter = c), e.shuffleProducts && (s.shuffle = !0);
385
+ const l = parseInt(e.size) || 6;
386
+ let f;
339
387
  try {
340
- a = await m.fetchRecommendationProducts(i, c);
388
+ f = await h.fetchRecommendationProducts(i, s);
341
389
  } catch {
342
- a = [];
390
+ f = [];
391
+ }
392
+ if (this.blockStates[t]) {
393
+ const a = f.length > 0 ? f : S(l);
394
+ this.blockStates[t].recommendationProducts = a.length < l ? [...a, ...S(l - a.length)] : a;
343
395
  }
344
- this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : C(g));
345
396
  }
346
397
  }
347
398
  });
348
399
  export {
349
- V as useRecommendationExtensionStore
400
+ E as useRecommendationExtensionStore
350
401
  };
@@ -141,7 +141,7 @@ const P = {
141
141
  data-text-before="Lowest 30-day price: "
142
142
  data-text-after=""
143
143
  esd-extension-block-id="${s.OMNIBUS_PRICE}">
144
- <p style="font-size: 12px; color: #666666;">
144
+ <p contenteditable="false" style="font-size: 12px; color: #666666;">
145
145
  <span class="omnibus-text-before">Lowest 30-day price: </span>
146
146
  <span class="omnibus-price-value">${c(t, "original_price")}</span>
147
147
  <span class="omnibus-text-after"></span>
@@ -172,7 +172,7 @@ const P = {
172
172
  data-text-before=""
173
173
  data-text-after=""
174
174
  esd-extension-block-id="${s.OMNIBUS_DISCOUNT}">
175
- <p style="font-size: 12px; color: #666666;">
175
+ <p contenteditable="false" style="font-size: 12px; color: #666666;">
176
176
  <span class="omnibus-text-before"></span>
177
177
  <span class="omnibus-discount-value">${g}</span>
178
178
  <span class="omnibus-text-after"></span>
@@ -5,7 +5,7 @@ const u = `
5
5
  align="left"
6
6
  esd-extension-block-id="recommendation-block"
7
7
  esd-handler-name="esd-extension-RecommendationBlock"
8
- class="ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20"
8
+ class="recommendation-block-v2 esd-block-recommendation-v3-block esd-extension-block es-p20"
9
9
  >
10
10
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
11
11
  <tr>
@@ -102,7 +102,7 @@ const $ = {
102
102
  data-text-after=""
103
103
  esd-extension-block-id="${o.OMNIBUS_PRICE}"
104
104
  align="left">
105
- <p style="font-size: 12px; color: #666666; margin: 0;">
105
+ <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
106
106
  <span class="omnibus-text-before">Lowest 30-day price: </span>
107
107
  <span class="omnibus-price-value">${s(t, "original_price")}</span>
108
108
  <span class="omnibus-text-after"></span>
@@ -124,7 +124,7 @@ const $ = {
124
124
  data-text-after=""
125
125
  esd-extension-block-id="${o.OMNIBUS_DISCOUNT}"
126
126
  align="left">
127
- <p style="font-size: 12px; color: #666666; margin: 0;">
127
+ <p contenteditable="false" style="font-size: 12px; color: #666666; margin: 0;">
128
128
  <span class="omnibus-text-before"></span>
129
129
  <span class="omnibus-discount-value">${b}</span>
130
130
  <span class="omnibus-text-after"></span>
@@ -1,28 +1,28 @@
1
- import { ATTR_PRODUCT_IMAGE as n, ATTR_PRODUCT_NAME as o, ATTR_PRODUCT_OLD_PRICE as a, ATTR_PRODUCT_PRICE as c, ATTR_PRODUCT_OMNIBUS_PRICE as l, ATTR_PRODUCT_OMNIBUS_DISCOUNT as i, ATTR_PRODUCT_BUTTON as s } from "../constants/selectors.js";
2
- const g = {
1
+ import { ATTR_PRODUCT_IMAGE as o, ATTR_PRODUCT_NAME as s, ATTR_PRODUCT_OLD_PRICE as r, ATTR_PRODUCT_PRICE as l, ATTR_PRODUCT_OMNIBUS_PRICE as i, ATTR_PRODUCT_OMNIBUS_DISCOUNT as a, ATTR_PRODUCT_BUTTON as c } from "../constants/selectors.js";
2
+ const C = {
3
3
  TITLE: "You May Also Like!"
4
- }, u = [
5
- n,
4
+ }, D = [
6
5
  o,
7
- a,
8
- c,
6
+ s,
7
+ r,
9
8
  l,
10
9
  i,
11
- s
12
- ], b = {
13
- [n]: !0,
10
+ a,
11
+ c
12
+ ], O = {
14
13
  [o]: !0,
15
- [c]: !0,
16
- [a]: !0,
17
- [l]: !1,
14
+ [s]: !0,
15
+ [l]: !0,
16
+ [r]: !0,
18
17
  [i]: !1,
19
- [s]: !0
20
- }, p = `
18
+ [a]: !1,
19
+ [c]: !0
20
+ }, m = `
21
21
  <tr>
22
22
  <td class="spacer" style="height: 10px;"></td>
23
23
  </tr>
24
24
  `, d = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
25
- function R(t) {
25
+ function U(t) {
26
26
  return !t || typeof t != "string" || t.trim() === "" ? d : t.startsWith("http://") ? t.replace("http://", "https://") : t;
27
27
  }
28
28
  function T(t) {
@@ -40,19 +40,19 @@ function T(t) {
40
40
  category: []
41
41
  };
42
42
  }
43
- function D(t = 6) {
43
+ function A(t = 6) {
44
44
  return Array.from(
45
45
  { length: t },
46
- (e, r) => T(String(r + 1))
46
+ (e, n) => T(String(n + 1))
47
47
  );
48
48
  }
49
- function O(t = "grid", e) {
50
- const r = t === "list" ? `
51
- data-layout="list"` : "";
49
+ function I(t = "grid", e) {
50
+ const n = t === "list" ? `
51
+ data-layout="list"` : "", p = e ? ` ${e}` : "";
52
52
  return `
53
53
  <td
54
54
  align="left"
55
- class="ins-recommendation-v3-block-v2 esd-block-recommendation-v3-block es-p20${e ? ` ${e}` : ""}"${r}>
55
+ class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${p}`}"${n}>
56
56
  <table width="100%" cellpadding="0" cellspacing="0" border="0">
57
57
  <tr>
58
58
  <td align="center">
@@ -84,7 +84,7 @@ function O(t = "grid", e) {
84
84
  </table>
85
85
  </td>
86
86
  </tr>
87
- ${p}
87
+ ${m}
88
88
  <tr>
89
89
  <td>
90
90
  <table
@@ -99,7 +99,7 @@ function O(t = "grid", e) {
99
99
  </table>
100
100
  </td>
101
101
  </tr>
102
- <tr>
102
+ <tr class="ins-recommendation-mobile-row"${t === "list" ? ' style="display: none;"' : ""}>
103
103
  <td>
104
104
  <table
105
105
  class="ins-recommendation-product-container
@@ -109,8 +109,8 @@ function O(t = "grid", e) {
109
109
  cellspacing="0"
110
110
  border="0"
111
111
  style="display: none;"
112
- >
113
- {-{-MOBILE_PRODUCT_ROWS-}-}
112
+ >${t === "list" ? "" : `
113
+ {-{-MOBILE_PRODUCT_ROWS-}-}`}
114
114
  </table>
115
115
  </td>
116
116
  </tr>
@@ -123,12 +123,12 @@ function O(t = "grid", e) {
123
123
  `;
124
124
  }
125
125
  export {
126
- g as DEFAULTS,
127
- u as DEFAULT_CARD_COMPOSITION,
128
- b as DEFAULT_CARD_VISIBILITY,
126
+ C as DEFAULTS,
127
+ D as DEFAULT_CARD_COMPOSITION,
128
+ O as DEFAULT_CARD_VISIBILITY,
129
129
  d as PLACEHOLDER_IMAGE,
130
- O as createBlockTemplate,
131
- D as getDefaultProducts,
132
- R as sanitizeImageUrl,
133
- p as spacer
130
+ I as createBlockTemplate,
131
+ A as getDefaultProducts,
132
+ U as sanitizeImageUrl,
133
+ m as spacer
134
134
  };
@@ -1,17 +1,17 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
2
+ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
5
  import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
- import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
7
  import { getDefaultTemplate as L } from "./template.js";
8
8
  import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
9
  import { parsePageList as p } from "./utils/utils.js";
10
- const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
10
+ const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
11
11
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
12
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
13
13
  };
14
- class R extends h {
14
+ class R extends _ {
15
15
  constructor() {
16
16
  super();
17
17
  u(this, "selectEventListener", null);
@@ -19,7 +19,7 @@ class R extends h {
19
19
  u(this, "currentNode");
20
20
  }
21
21
  getId() {
22
- return g;
22
+ return v;
23
23
  }
24
24
  getIcon() {
25
25
  return "unsubscribe-icon";
@@ -47,8 +47,8 @@ class R extends h {
47
47
  }
48
48
  _setupSelectEventListener() {
49
49
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
50
- const s = e, { collectionType: t, selectedPages: r } = s.detail;
51
- this._updateBlock(t, r.join(","));
50
+ const r = e, { collectionType: s, selectedPages: t } = r.detail;
51
+ this._updateBlock(s, t.join(","));
52
52
  }, document.addEventListener(a.SELECT, this.selectEventListener);
53
53
  }
54
54
  _removeSelectEventListener() {
@@ -74,17 +74,17 @@ class R extends h {
74
74
  _removeEventListeners() {
75
75
  this._removeSelectEventListener(), this._removeCancelEventListener();
76
76
  }
77
- _updateBlock(e, s) {
77
+ _updateBlock(e, r) {
78
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
79
  return;
80
- const t = this.currentNode.querySelector(v);
81
- if (!t)
80
+ const s = this.currentNode.querySelector(g);
81
+ if (!s)
82
82
  return;
83
- const r = this._getMergeTag(e);
84
- this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
83
+ const t = this._getMergeTag(e);
84
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
85
85
  }
86
86
  _getMergeTag(e) {
87
- return T[e] ?? B;
87
+ return B[e] ?? T;
88
88
  }
89
89
  _openDrawer() {
90
90
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
@@ -97,24 +97,24 @@ class R extends h {
97
97
  }
98
98
  _checkExistingBlocks() {
99
99
  const e = c();
100
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
101
- if ("getAttribute" in t) {
102
- const r = t.getAttribute(o.PAGE_TYPE);
103
- if (r) {
104
- const l = Number(r);
100
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
101
+ if ("getAttribute" in s) {
102
+ const t = s.getAttribute(o.PAGE_TYPE);
103
+ if (t) {
104
+ const l = Number(t);
105
105
  l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
106
106
  }
107
107
  }
108
108
  });
109
109
  }
110
- _loadBlockState(e) {
110
+ async _loadBlockState(e) {
111
111
  if (!("getAttribute" in e))
112
112
  return;
113
- const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
- if (!s || !t)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
115
115
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
116
+ const t = c(), l = Number(r), m = p(s);
117
+ await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
118
118
  }
119
119
  _resetStoreState() {
120
120
  c().$reset();
@@ -122,14 +122,14 @@ class R extends h {
122
122
  _removeBlockTemplatesFromStore(e) {
123
123
  if (!("getAttribute" in e))
124
124
  return;
125
- const s = e.getAttribute(o.PAGE_LIST);
126
- if (!s)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
127
127
  return;
128
- const t = c(), r = p(s);
129
- t.removeUnsubscribePages(r);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
130
130
  }
131
131
  }
132
132
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
133
+ v as UNSUBSCRIBE_BLOCK_ID,
134
134
  R as UnsubscribeBlock
135
135
  };
@@ -1,18 +1,18 @@
1
- var h = Object.defineProperty;
2
- var d = (a, s, e) => s in a ? h(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
- var u = (a, s, e) => d(a, typeof s != "symbol" ? s + "" : s, e);
1
+ var d = Object.defineProperty;
2
+ var h = (a, s, e) => s in a ? d(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
3
+ var u = (a, s, e) => h(a, typeof s != "symbol" ? s + "" : s, e);
4
4
  import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
5
5
  import { Control as T, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { DATA_ATTRIBUTES as p } from "./utils/constants.js";
7
7
  import { parsePageList as _ } from "./utils/utils.js";
8
- const g = "ui-elements-unsubscribe", r = {
8
+ const v = "ui-elements-unsubscribe", r = {
9
9
  SELECT_BUTTON: "selectTemplateButton",
10
10
  PREV_BUTTON: "prevButton",
11
11
  NEXT_BUTTON: "nextButton",
12
12
  COUNTER_TEXT: "counterText",
13
13
  PREVIEW_IMAGE: "previewImage"
14
14
  };
15
- class N extends T {
15
+ class B extends T {
16
16
  constructor() {
17
17
  super(...arguments);
18
18
  u(this, "currentPreviewIndex", 0);
@@ -22,7 +22,7 @@ class N extends T {
22
22
  u(this, "lastParsedAttribute");
23
23
  }
24
24
  getId() {
25
- return g;
25
+ return v;
26
26
  }
27
27
  getTemplate() {
28
28
  return `
@@ -35,7 +35,7 @@ class N extends T {
35
35
  onTemplateNodeUpdated(e) {
36
36
  if (this.currentNode = e, "getAttribute" in this.currentNode) {
37
37
  const t = this.currentNode.getAttribute(p.PAGE_LIST);
38
- t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updatePreview(), this._updateCounter());
38
+ t && (t !== this.lastParsedAttribute && (this.currentPages = _(t), this.lastParsedAttribute = t, this.currentPreviewIndex = 0), this._updateCounter(), this._loadAndUpdatePreview());
39
39
  }
40
40
  }
41
41
  onRender() {
@@ -73,6 +73,9 @@ class N extends T {
73
73
  _onNextClick() {
74
74
  this.currentPreviewIndex < this.totalTemplates - 1 && (this.currentPreviewIndex++, this._updatePreview(), this._updateCounter());
75
75
  }
76
+ async _loadAndUpdatePreview() {
77
+ await l().fetchTemplates(), this._updatePreview(), this._updateCounter();
78
+ }
76
79
  _updatePreview() {
77
80
  var e;
78
81
  if ((e = this.currentPages) != null && e.length)
@@ -162,6 +165,6 @@ class N extends T {
162
165
  }
163
166
  }
164
167
  export {
165
- g as UNSUBSCRIBE_CONTROL_ID,
166
- N as UnsubscribeControl
168
+ v as UNSUBSCRIBE_CONTROL_ID,
169
+ B as UnsubscribeControl
167
170
  };