@useinsider/guido 3.19.0-beta.2854f4f → 3.19.0-beta.3906ea8

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 (40) hide show
  1. package/README.md +21 -3
  2. package/dist/@types/config/schemas.js +59 -51
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +57 -55
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +3 -3
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +56 -52
  7. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +18 -0
  8. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +25 -0
  9. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +18 -18
  10. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +28 -26
  11. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +21 -0
  12. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +46 -0
  13. package/dist/composables/useCustomInterfaceAppearance.js +54 -50
  14. package/dist/composables/useLegacyStrategyConversion.js +61 -0
  15. package/dist/enums/extensions/recommendationBlock.js +34 -25
  16. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +73 -72
  17. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +81 -38
  18. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +169 -108
  19. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +42 -0
  20. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +10 -10
  21. package/dist/guido.css +1 -1
  22. package/dist/services/recommendationApi.js +46 -37
  23. package/dist/src/@types/config/schemas.d.ts +16 -0
  24. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +2 -0
  25. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +2 -0
  26. package/dist/src/composables/useConfig.d.ts +4 -0
  27. package/dist/src/composables/useLegacyStrategyConversion.d.ts +3 -0
  28. package/dist/src/enums/extensions/recommendationBlock.d.ts +5 -1
  29. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +1 -0
  30. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +76 -1
  31. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +32 -0
  32. package/dist/src/services/recommendationApi.d.ts +2 -1
  33. package/dist/src/stores/config.d.ts +322 -0
  34. package/dist/src/stores/onboarding.d.ts +421 -0
  35. package/dist/static/assets/icons/filled-arrow-rising.svg.js +5 -0
  36. package/dist/static/assets/icons/line-info.svg.js +5 -0
  37. package/dist/static/styles/components/recommendation-strategy.css.js +70 -5
  38. package/dist/stores/config.js +74 -60
  39. package/dist/stores/onboarding.js +6 -1
  40. package/package.json +2 -2
@@ -1,20 +1,28 @@
1
- import { useTranslations as n } from "../../composables/useTranslations.js";
2
- const o = {
1
+ import { useTranslations as s } from "../../composables/useTranslations.js";
2
+ const a = {
3
3
  RECOMMENDATION_API_URL: "https://recommendationv2.api.useinsider.com",
4
4
  // Relative path → same-origin as the embedding inone dashboard.
5
5
  PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
6
6
  RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
7
7
  RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies",
8
+ NEWSLETTER_RECOMMENDATIONS_PATH: "/newsletter/recommendations",
9
+ MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/migrate-strategies",
10
+ // The template route narrows the recommendations resource before the action: the id
11
+ // travels in the body, not the path.
12
+ TEMPLATE_MIGRATE_STRATEGIES_PATH: "/newsletter/recommendations/template/migrate-strategies",
8
13
  // Smart Recommender hides the Email channel unless the URL asks for it, so a strategy created
9
14
  // without this flag can never be Email-suitable and would never reach the editor's list.
10
15
  RECOMMENDATION_STRATEGY_CREATE_PATH: "/discovery/recommendation-strategies/create?isEmail=true"
11
16
  }, d = (e) => {
12
- const { RECOMMENDATION_STRATEGIES_PANEL_PATH: r } = o;
13
- return `${r}/${e}/edit?isEmail=true`;
17
+ const { RECOMMENDATION_STRATEGIES_PANEL_PATH: n } = a;
18
+ return `${n}/${e}/edit?isEmail=true`;
14
19
  }, m = {
20
+ campaign: a.MIGRATE_STRATEGIES_PATH,
21
+ template: a.TEMPLATE_MIGRATE_STRATEGIES_PATH
22
+ }, T = {
15
23
  CLIENT_ID: "clientId"
16
- }, p = () => {
17
- const e = n();
24
+ }, E = () => {
25
+ const e = s();
18
26
  return [
19
27
  {
20
28
  id: 11,
@@ -77,31 +85,31 @@ const o = {
77
85
  path: "top-sellers"
78
86
  }
79
87
  ];
80
- }, v = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], h = [
88
+ }, p = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], A = [
81
89
  { text: "before the amount", value: "0" },
82
90
  { text: "after the amount", value: "1" }
83
- ], x = [
91
+ ], v = [
84
92
  { text: "dot(.)", value: "." },
85
93
  { text: "comma(,)", value: "," },
86
94
  { text: "space( )", value: " " }
87
- ], E = [
95
+ ], _ = [
88
96
  { text: "0", value: "0" },
89
97
  { text: "1", value: "1" },
90
98
  { text: "2", value: "2" },
91
99
  { text: "3", value: "3" },
92
100
  { text: "4", value: "4" },
93
101
  { text: "5", value: "5" }
94
- ], a = "||", t = [
102
+ ], r = "||", t = [
95
103
  { text: "is exactly", value: "=" },
96
104
  { text: "contains", value: "~" },
97
105
  { text: "does not contain", value: "!~" },
98
- { text: "any of", value: a }
99
- ], s = [
106
+ { text: "any of", value: r }
107
+ ], o = [
100
108
  { text: "is exactly", value: "=" },
101
109
  { text: "is not exactly", value: "!==" },
102
110
  { text: "contains", value: "~" },
103
111
  { text: "does not contain", value: "!~" },
104
- { text: "any of", value: a }
112
+ { text: "any of", value: r }
105
113
  ], i = [
106
114
  { text: "is equal to", value: "=" },
107
115
  { text: "is greater than", value: ">" },
@@ -113,7 +121,7 @@ const o = {
113
121
  ], c = [
114
122
  { text: "true", value: "==" },
115
123
  { text: "false", value: "!=" }
116
- ], b = (e) => {
124
+ ], h = (e) => {
117
125
  if (!e)
118
126
  return t;
119
127
  switch (e) {
@@ -126,22 +134,23 @@ const o = {
126
134
  case "String":
127
135
  return t;
128
136
  case "Strings":
129
- return s;
137
+ return o;
130
138
  default:
131
139
  return t;
132
140
  }
133
141
  };
134
142
  export {
135
- a as OP_ANY_OF,
136
- v as PriceAttributes,
137
- m as QUERY_PARAMS,
138
- o as URLS,
139
- E as currencyDecimalCounts,
140
- h as currencyLocationMaps,
141
- x as currencyOperators,
142
- b as getOperatorOptions,
143
- p as getRecommendationFeedSourceMaps,
144
- s as operatorOptionsForArrayOfStrings,
143
+ m as MIGRATION_PATHS,
144
+ r as OP_ANY_OF,
145
+ p as PriceAttributes,
146
+ T as QUERY_PARAMS,
147
+ a as URLS,
148
+ _ as currencyDecimalCounts,
149
+ A as currencyLocationMaps,
150
+ v as currencyOperators,
151
+ h as getOperatorOptions,
152
+ E as getRecommendationFeedSourceMaps,
153
+ o as operatorOptionsForArrayOfStrings,
145
154
  c as operatorOptionsForBooleans,
146
155
  u as operatorOptionsForDates,
147
156
  i as operatorOptionsForNumbers,
@@ -1,6 +1,6 @@
1
1
  var m = Object.defineProperty;
2
2
  var C = (g, c, t) => c in g ? m(g, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[c] = t;
3
- var n = (g, c, t) => C(g, typeof c != "symbol" ? c + "" : c, t);
3
+ var i = (g, c, t) => C(g, typeof c != "symbol" ? c + "" : c, t);
4
4
  import { useConfig as p } from "../../../../../composables/useConfig.js";
5
5
  import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { CommonControl as N } from "../../../common-control.js";
@@ -10,7 +10,7 @@ import { RecommendationConfigService as l } from "../../services/configService.j
10
10
  import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
11
  import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
12
  import { AlgorithmControl as T } from "./algorithm.js";
13
- import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
13
+ import { ALGORITHM_CONTROL_ID as dt } from "./algorithm.js";
14
14
  import { CurrencyControl as P } from "./currency.js";
15
15
  import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
16
16
  import { FiltersControl as S } from "./filters.js";
@@ -29,36 +29,36 @@ import { ShuffleControl as D } from "./shuffle.js";
29
29
  import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
30
30
  import { StrategyControl as w } from "./strategy.js";
31
31
  import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
32
- import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
33
- import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
32
+ import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
34
34
  import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
35
35
  const W = "ui-elements-recommendation-block";
36
36
  class at extends N {
37
37
  constructor() {
38
38
  super(...arguments);
39
- n(this, "store", R());
40
- n(this, "storeUnsubscription", () => {
39
+ i(this, "store", R());
40
+ i(this, "storeUnsubscription", () => {
41
41
  });
42
42
  // A config change waiting to reach the node config. Deferred so it can ride the
43
43
  // re-render's single apply() — one user action must cost one undo press.
44
- n(this, "pendingNodeConfigWrite", null);
45
- n(this, "pendingConfigFlushTimer", null);
44
+ i(this, "pendingNodeConfigWrite", null);
45
+ i(this, "pendingConfigFlushTimer", null);
46
46
  // Sub-control instances for lifecycle management
47
- n(this, "algorithmControl", null);
48
- n(this, "localeControl", null);
49
- n(this, "currencyControl", null);
50
- n(this, "productCountControl", null);
51
- n(this, "productLayoutControl", null);
52
- n(this, "filtersControl", null);
53
- n(this, "shuffleControl", null);
54
- n(this, "pricePlacementControl", null);
55
- n(this, "layoutOrientationControl", null);
56
- n(this, "strategyControl", null);
57
- n(this, "rrsEnabled", !1);
47
+ i(this, "algorithmControl", null);
48
+ i(this, "localeControl", null);
49
+ i(this, "currencyControl", null);
50
+ i(this, "productCountControl", null);
51
+ i(this, "productLayoutControl", null);
52
+ i(this, "filtersControl", null);
53
+ i(this, "shuffleControl", null);
54
+ i(this, "pricePlacementControl", null);
55
+ i(this, "layoutOrientationControl", null);
56
+ i(this, "strategyControl", null);
57
+ i(this, "rrsEnabled", !1);
58
58
  /**
59
59
  * Debounced product fetch to prevent rapid API calls during config changes
60
60
  */
61
- n(this, "_debouncedFetchProducts", h(async () => {
61
+ i(this, "_debouncedFetchProducts", h(async () => {
62
62
  try {
63
63
  await this.store.fetchRecommendationProducts();
64
64
  } finally {
@@ -76,16 +76,16 @@ class at extends N {
76
76
  * count. The store pads products to the configured size, so in-place only
77
77
  * fails when the size actually changed.
78
78
  */
79
- n(this, "_debouncedRegenerateWithProducts", h(() => {
79
+ i(this, "_debouncedRegenerateWithProducts", h(() => {
80
80
  const t = this.store.recommendationProducts;
81
81
  if (!this.currentNode || !this.api)
82
82
  return;
83
83
  const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
84
- if (x(this.currentNode)) {
84
+ if (v(this.currentNode)) {
85
85
  o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
86
86
  return;
87
87
  }
88
- B({
88
+ x({
89
89
  currentNode: this.currentNode,
90
90
  documentModifier: e,
91
91
  products: t
@@ -136,12 +136,12 @@ class at extends N {
136
136
  `;
137
137
  }
138
138
  _showControlsForBlock(t) {
139
- var i;
140
- const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
139
+ var r;
140
+ const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
141
141
  if (!e)
142
142
  return;
143
- const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
144
- e.classList.toggle("strategy-block", r);
143
+ const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
144
+ e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
145
145
  }
146
146
  async onRender() {
147
147
  var o;
@@ -159,9 +159,9 @@ class at extends N {
159
159
  const e = this._getRecommendationIdFromNode(t);
160
160
  e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
161
161
  this._initializeSubControls();
162
- }), this._subControls.forEach((r) => {
163
- var i;
164
- r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
162
+ }), this._subControls.forEach((n) => {
163
+ var s;
164
+ n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
165
165
  });
166
166
  }
167
167
  onDestroy() {
@@ -209,8 +209,8 @@ class at extends N {
209
209
  const e = this.store.blockStates[t];
210
210
  if (!e)
211
211
  return;
212
- const o = JSON.stringify(l.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
213
- e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
212
+ const o = JSON.stringify(l.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
213
+ e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
214
214
  }
215
215
  /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
216
216
  _isPendingStrategyIdChange() {
@@ -221,11 +221,11 @@ class at extends N {
221
221
  const t = this.store.currentRecommendationId;
222
222
  if (!this.currentNode || !this.api || t === null)
223
223
  return;
224
- const { filters: e, strategy: o, strategyId: r, size: i } = this.store.recommendationConfigs;
224
+ const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs;
225
225
  this.pendingNodeConfigWrite = {
226
226
  blockId: t,
227
227
  node: this.currentNode,
228
- updates: { filters: e, strategy: o, strategyId: r, size: i }
228
+ updates: { filters: e, strategy: o, strategyId: n, size: s, configVersion: r }
229
229
  };
230
230
  }
231
231
  /**
@@ -268,11 +268,12 @@ class at extends N {
268
268
  JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || l.updateConfig(this.api, e, t.updates, "Update recommendation filters");
269
269
  }
270
270
  _syncNodeConfigToStore() {
271
- var r;
272
- const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
271
+ var n;
272
+ const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
273
273
  this.store.patchCurrentBlockConfig({
274
274
  strategy: t.strategy,
275
275
  strategyId: t.strategyId,
276
+ nodeConfigVersion: t.configVersion,
276
277
  language: t.language,
277
278
  size: t.size,
278
279
  productIds: t.productIds,
@@ -311,8 +312,8 @@ class at extends N {
311
312
  t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
312
313
  this.store.fetchRecommendationCreateData(),
313
314
  this.store.fetchRecommendationFilters()
314
- ])).forEach((o, r) => {
315
- o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
315
+ ])).forEach((o, n) => {
316
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
316
317
  }), this._applySmartDefaults();
317
318
  try {
318
319
  await this.store.fetchRecommendationProducts();
@@ -334,30 +335,30 @@ class at extends N {
334
335
  if (!this.currentNode || !this.api)
335
336
  return;
336
337
  const t = l.getConfig(this.currentNode), e = {};
337
- let o = null, r = null, i = null;
338
+ let o = null, n = null, s = null;
338
339
  if (t.currency.code === a.currency.code) {
339
- const { currencyList: s } = this.store;
340
- s.length > 0 && (s.some(
341
- (d) => d.value === `price.${a.currency.code}`
342
- ) || (o = s[0].value.replace("price.", ""), e.currency = {
340
+ const { currencyList: r } = this.store;
341
+ r.length > 0 && (r.some(
342
+ (u) => u.value === `price.${a.currency.code}`
343
+ ) || (o = r[0].value.replace("price.", ""), e.currency = {
343
344
  ...a.currency,
344
345
  code: o,
345
346
  symbol: o
346
347
  }));
347
348
  }
348
349
  if (t.strategy === a.strategy) {
349
- const s = this.store.getActivePredictiveAlgorithms;
350
- s.length > 0 && (s.some(
351
- (d) => d.value === a.strategy
352
- ) || (r = s[0].value, e.strategy = r));
350
+ const r = this.store.getActivePredictiveAlgorithms;
351
+ r.length > 0 && (r.some(
352
+ (u) => u.value === a.strategy
353
+ ) || (n = r[0].value, e.strategy = n));
353
354
  }
354
355
  if (t.language === a.language) {
355
- const s = this.store.getLanguages;
356
- s.length > 0 && (s.some(
357
- (d) => d.value === a.language
358
- ) || (i = s[0].value, e.language = i));
356
+ const r = this.store.getLanguages;
357
+ r.length > 0 && (r.some(
358
+ (u) => u.value === a.language
359
+ ) || (s = r[0].value, e.language = s));
359
360
  }
360
- !o && !r && !i || (l.updateConfig(
361
+ !o && !n && !s || (l.updateConfig(
361
362
  this.api,
362
363
  this.currentNode,
363
364
  e,
@@ -378,22 +379,22 @@ class at extends N {
378
379
  thousandSeparator: a.currency.thousandSeparator
379
380
  }
380
381
  } : {},
381
- ...r ? { strategy: r } : {},
382
- ...i ? { language: i } : {}
382
+ ...n ? { strategy: n } : {},
383
+ ...s ? { language: s } : {}
383
384
  }, { triggerRefetch: !1 }));
384
385
  }
385
386
  /**
386
387
  * Reads the recommendation-id attribute from the block element within the node
387
388
  */
388
389
  _getRecommendationIdFromNode(t) {
389
- const e = v(t);
390
+ const e = B(t);
390
391
  if (!e || !("getAttribute" in e))
391
392
  return null;
392
393
  const o = e.getAttribute(I);
393
394
  if (!o)
394
395
  return null;
395
- const r = parseInt(o);
396
- return Number.isNaN(r) ? null : r;
396
+ const n = parseInt(o);
397
+ return Number.isNaN(n) ? null : n;
397
398
  }
398
399
  /**
399
400
  * Listen to store changes that require product refresh or regeneration.
@@ -410,22 +411,22 @@ class at extends N {
410
411
  */
411
412
  _listenStateUpdates() {
412
413
  const { store: t } = this;
413
- let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
414
+ let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
414
415
  this.storeUnsubscription = t.$subscribe(() => {
415
- const i = t.currentRecommendationId;
416
- if (i !== r) {
417
- r = i, e = t.recommendationProducts, o = t.$state.configVersion;
416
+ const s = t.currentRecommendationId;
417
+ if (s !== n) {
418
+ n = s, e = t.recommendationProducts, o = t.$state.configVersion;
418
419
  return;
419
420
  }
420
- const s = t.$state.configVersion;
421
- s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
422
- const u = t.recommendationProducts, d = u !== e, f = Array.isArray(u) && u.length > 0;
423
- d && f && (e = u, this._debouncedRegenerateWithProducts());
421
+ const r = t.$state.configVersion;
422
+ r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
423
+ const d = t.recommendationProducts, u = d !== e, f = Array.isArray(d) && d.length > 0;
424
+ u && f && (e = d, this._debouncedRegenerateWithProducts());
424
425
  });
425
426
  }
426
427
  }
427
428
  export {
428
- ut as ALGORITHM_CONTROL_ID,
429
+ dt as ALGORITHM_CONTROL_ID,
429
430
  T as AlgorithmControl,
430
431
  W as CONTROL_BLOCK_ID,
431
432
  gt as CURRENCY_CONTROL_ID,
@@ -449,15 +450,15 @@ export {
449
450
  w as StrategyControl,
450
451
  Et as adjustProductsToSize,
451
452
  Ft as formatProductPrice,
452
- v as getBlockElement,
453
+ B as getBlockElement,
453
454
  Dt as getCardComposition,
454
455
  wt as getCurrentLayout,
455
456
  At as getMainContainerTbody,
456
- x as isPartnerManagedBlock,
457
- vt as regenerateMobileProductRows,
457
+ v as isPartnerManagedBlock,
458
+ Bt as regenerateMobileProductRows,
458
459
  U as regenerateProductRowsWithStyles,
459
460
  A as setCurrencyAttributes,
460
- xt as updatePricesInPlace,
461
- B as updateProductContentInPlace,
462
- Bt as updateSingleProductContent
461
+ vt as updatePricesInPlace,
462
+ x as updateProductContentInPlace,
463
+ xt as updateSingleProductContent
463
464
  };
@@ -1,30 +1,34 @@
1
- var u = Object.defineProperty;
2
- var S = (o, n, t) => n in o ? u(o, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[n] = t;
3
- var r = (o, n, t) => S(o, typeof n != "symbol" ? n + "" : n, t);
4
- import { ACADEMY_LINKS as _ } from "../../../../../enums/academy.js";
5
- import { useOnboardingStore as f } from "../../../../../stores/onboarding.js";
6
- import { CommonControl as v } from "../../../common-control.js";
7
- import { RRS_CONFIG_VERSION as b } from "../../constants/defaultConfig.js";
8
- import { RecommendationConfigService as h } from "../../services/configService.js";
9
- import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
10
- const k = "recommendation-strategy-control";
11
- class I extends v {
1
+ var C = Object.defineProperty;
2
+ var $ = (c, n, t) => n in c ? C(c, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[n] = t;
3
+ var i = (c, n, t) => $(c, typeof n != "symbol" ? n + "" : n, t);
4
+ import { useLegacyStrategyConversion as k } from "../../../../../composables/useLegacyStrategyConversion.js";
5
+ import { ACADEMY_LINKS as L } from "../../../../../enums/academy.js";
6
+ import { useOnboardingStore as w } from "../../../../../stores/onboarding.js";
7
+ import { CommonControl as A } from "../../../common-control.js";
8
+ import { RRS_CONFIG_VERSION as N } from "../../constants/defaultConfig.js";
9
+ import { RecommendationConfigService as b } from "../../services/configService.js";
10
+ import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
+ const E = "recommendation-strategy-control";
12
+ class M extends A {
12
13
  constructor() {
13
14
  super(...arguments);
14
- r(this, "store", C());
15
- r(this, "onboardingStore", f());
16
- r(this, "storeUnsubscription", () => {
15
+ i(this, "store", R());
16
+ i(this, "onboardingStore", w());
17
+ i(this, "legacyConversion", k());
18
+ i(this, "storeUnsubscription", () => {
17
19
  });
18
- r(this, "listeners", []);
19
- r(this, "lastPaintedState", null);
20
+ i(this, "listeners", []);
21
+ i(this, "lastPaintedState", null);
20
22
  }
21
23
  getId() {
22
- return k;
24
+ return E;
23
25
  }
24
26
  getTemplate() {
25
27
  const t = this.api.translate(
26
28
  "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
27
- ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
29
+ ), e = this.api.translate("For more information, you can"), s = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), a = this.api.translate(
30
+ "Note that this is an older version of the Recommendation Strategy. We recommend you update it to the new Recommendation Strategy for an improved experience."
31
+ );
28
32
  return `
29
33
  <div class="strategy-control-container">
30
34
  <div data-strategy-loading-state>
@@ -48,9 +52,9 @@ class I extends v {
48
52
  ${t}
49
53
  ${e}
50
54
  <a
51
- href="${_.EMAIL_RECOMMENDATION_BLOCK}"
55
+ href="${L.EMAIL_RECOMMENDATION_BLOCK}"
52
56
  target="_blank"
53
- rel="noopener noreferrer">${a}</a>.
57
+ rel="noopener noreferrer">${s}</a>.
54
58
  </p>
55
59
  </div>
56
60
  <div data-strategy-empty-state style="display: none;">
@@ -69,6 +73,33 @@ class I extends v {
69
73
  })
70
74
  ], "strategy-control-cta-row")}
71
75
  </div>
76
+ <div data-strategy-legacy-state style="display: none;">
77
+ <div class="strategy-control-notice-row">
78
+ <div class="strategy-control-notice">
79
+ <p class="strategy-control-notice-text">${a}</p>
80
+ </div>
81
+ </div>
82
+ <div class="strategy-control-name-band">
83
+ <span class="strategy-control-name">${o}</span>
84
+ ${this._strategyAction({
85
+ id: "guido__btn-update-legacy-strategy",
86
+ label: this.api.translate("Update"),
87
+ modifier: "update"
88
+ })}
89
+ </div>
90
+ <div class="strategy-control-actions">
91
+ ${this._strategyAction({
92
+ id: "guido__btn-change-legacy-strategy",
93
+ label: this.api.translate("Change"),
94
+ modifier: "change"
95
+ })}
96
+ ${this._strategyAction({
97
+ id: "guido__btn-remove-legacy-strategy",
98
+ label: this.api.translate("Remove"),
99
+ modifier: "remove"
100
+ })}
101
+ </div>
102
+ </div>
72
103
  <div data-strategy-assigned-state style="display: none;">
73
104
  <div class="strategy-control-name-band">
74
105
  <span class="strategy-control-name" data-strategy-name></span>
@@ -92,12 +123,12 @@ class I extends v {
92
123
  </div>
93
124
  `;
94
125
  }
95
- _strategyAction({ id: t, label: e, modifier: a }) {
126
+ _strategyAction({ id: t, label: e, modifier: s }) {
96
127
  return `
97
128
  <button
98
129
  id="${t}"
99
130
  type="button"
100
- class="strategy-control-action strategy-control-action--${a}">
131
+ class="strategy-control-action strategy-control-action--${s}">
101
132
  <span>${e}</span>
102
133
  </button>
103
134
  `;
@@ -116,10 +147,10 @@ class I extends v {
116
147
  * strategyId) for an assigned block.
117
148
  */
118
149
  _isNodeUnassigned() {
119
- if (!h.hasConfig(this.currentNode))
150
+ if (!b.hasConfig(this.currentNode))
120
151
  return !1;
121
- const t = h.getConfig(this.currentNode);
122
- return !t.strategyId && (t.configVersion ?? 0) >= b;
152
+ const t = b.getConfig(this.currentNode);
153
+ return !t.strategyId && (t.configVersion ?? 0) >= N;
123
154
  }
124
155
  onDestroy() {
125
156
  this._teardown();
@@ -132,25 +163,37 @@ class I extends v {
132
163
  const t = this.getContainer();
133
164
  if (!t)
134
165
  return;
135
- const e = (a, i) => {
136
- const s = t.querySelector(a);
137
- s && (s.addEventListener("click", i), this.listeners.push({ element: s, handler: i }));
166
+ const e = (s, o) => {
167
+ const a = t.querySelector(s);
168
+ a && (a.addEventListener("click", o), this.listeners.push({ element: a, handler: o }));
138
169
  };
139
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
170
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
171
+ this.legacyConversion.convertLegacyStrategy();
172
+ });
140
173
  }
141
174
  _renderState() {
142
- var p;
143
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((p = this.store.assignedStrategy) == null ? void 0 : p.name) ?? "" : "", a = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), i = `${t}\0${e}\0${a}`;
144
- if (i === this.lastPaintedState)
175
+ var _;
176
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((_ = this.store.assignedStrategy) == null ? void 0 : _.name) ?? "" : "", s = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), o = this.store.legacyConversionLoading, a = this.store.isLegacyStrategyBlock, h = `${t}\0${e}\0${s}\0${o}\0${a}`;
177
+ if (h === this.lastPaintedState)
178
+ return;
179
+ const r = this.getContainer();
180
+ if (!r)
145
181
  return;
146
- const s = this.getContainer();
147
- if (!s)
182
+ const d = r.querySelector("[data-strategy-empty-state]"), y = r.querySelector("[data-strategy-assigned-state]"), g = r.querySelector("[data-strategy-legacy-state]"), p = r.querySelector("[data-strategy-loading-state]"), u = r.querySelector("[data-strategy-content]"), m = r.querySelector("[data-strategy-name]"), v = r.querySelector("[data-strategy-name-skeleton]");
183
+ if (!d || !y || !g)
148
184
  return;
149
- const c = s.querySelector("[data-strategy-empty-state]"), g = s.querySelector("[data-strategy-assigned-state]"), l = s.querySelector("[data-strategy-loading-state]"), y = s.querySelector("[data-strategy-content]"), d = s.querySelector("[data-strategy-name]"), m = s.querySelector("[data-strategy-name-skeleton]");
150
- !c || !g || (l && (l.style.display = "none"), y && (y.style.display = ""), c.style.display = t ? "none" : "", g.style.display = t ? "" : "none", !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), d && (d.style.display = a ? "none" : "", t && !a && (d.textContent = e || `#${t}`)), m && (m.style.display = a ? "block" : "none"), this.lastPaintedState = i);
185
+ p && (p.style.display = "none"), u && (u.style.display = "");
186
+ const f = t ? y : a ? g : d;
187
+ [d, y, g].forEach((l) => {
188
+ l.style.display = l === f ? "" : "none";
189
+ }), g.querySelectorAll("button").forEach((l) => {
190
+ l.disabled = o;
191
+ }), g.classList.toggle("is-converting", o), !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding");
192
+ const S = this.store.currentRecommendationId;
193
+ a && S !== null && this.store.blockStates[S] && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding"), m && (m.style.display = s ? "none" : "", t && !s && (m.textContent = e || `#${t}`)), v && (v.style.display = s ? "block" : "none"), this.lastPaintedState = h;
151
194
  }
152
195
  }
153
196
  export {
154
- k as STRATEGY_CONTROL_ID,
155
- I as StrategyControl
197
+ E as STRATEGY_CONTROL_ID,
198
+ M as StrategyControl
156
199
  };