@useinsider/guido 3.18.2-beta.32d291d → 3.18.2-beta.3718ee1

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 (47) hide show
  1. package/README.md +3 -21
  2. package/dist/@types/config/schemas.js +51 -59
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +53 -55
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +57 -82
  7. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +22 -24
  8. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +24 -28
  9. package/dist/composables/useCustomInterfaceAppearance.js +42 -46
  10. package/dist/enums/extensions/recommendationBlock.js +31 -40
  11. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +4 -4
  12. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +76 -77
  13. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +28 -72
  14. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +44 -45
  15. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +6 -3
  16. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +46 -110
  17. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
  18. package/dist/guido.css +1 -1
  19. package/dist/services/recommendationApi.js +37 -46
  20. package/dist/src/@types/config/schemas.d.ts +0 -16
  21. package/dist/src/composables/useConfig.d.ts +0 -4
  22. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -5
  23. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -2
  24. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -4
  25. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -70
  26. package/dist/src/services/recommendationApi.d.ts +1 -2
  27. package/dist/src/stores/config.d.ts +0 -322
  28. package/dist/src/stores/onboarding.d.ts +10 -808
  29. package/dist/static/styles/components/recommendation-strategy.css.js +5 -70
  30. package/dist/stores/config.js +60 -74
  31. package/dist/stores/onboarding.js +36 -46
  32. package/package.json +1 -1
  33. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +0 -18
  34. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +0 -25
  35. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +0 -21
  36. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +0 -46
  37. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +0 -21
  38. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +0 -46
  39. package/dist/composables/useLegacyStrategyConversion.js +0 -61
  40. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +0 -42
  41. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +0 -2
  42. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +0 -2
  43. package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +0 -2
  44. package/dist/src/composables/useLegacyStrategyConversion.d.ts +0 -3
  45. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +0 -32
  46. package/dist/static/assets/icons/filled-arrow-rising.svg.js +0 -5
  47. package/dist/static/assets/icons/line-info.svg.js +0 -5
@@ -1,6 +1,6 @@
1
1
  var m = Object.defineProperty;
2
- var C = (g, l, t) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[l] = t;
3
- var r = (g, l, t) => C(g, typeof l != "symbol" ? l + "" : l, t);
2
+ var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
3
+ var n = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, 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";
@@ -12,16 +12,16 @@ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
12
  import { AlgorithmControl as T } from "./algorithm.js";
13
13
  import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
14
14
  import { CurrencyControl as P } from "./currency.js";
15
- import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
15
+ import { CURRENCY_CONTROL_ID as ht } from "./currency.js";
16
16
  import { FiltersControl as S } from "./filters.js";
17
- import { FILTERS_CONTROL_ID as ht } from "./filters.js";
17
+ import { FILTERS_CONTROL_ID as gt } from "./filters.js";
18
18
  import { LayoutOrientationControl as O } from "./layoutOrientation.js";
19
19
  import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
20
20
  import { LocaleControl as L } from "./locale.js";
21
21
  import { LOCALE_CONTROL_ID as yt } from "./locale.js";
22
- import { PricePlacementControl as k } from "./pricePlacement.js";
22
+ import { PricePlacementControl as E } from "./pricePlacement.js";
23
23
  import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
24
- import { ProductCountControl as E } from "./productCount.js";
24
+ import { ProductCountControl as k } from "./productCount.js";
25
25
  import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
26
26
  import { ProductLayoutControl as F } from "./productLayout.js";
27
27
  import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.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 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";
32
+ import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as kt, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
34
34
  import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
35
35
  const $ = "ui-elements-recommendation-block";
36
36
  class at extends N {
37
37
  constructor() {
38
38
  super(...arguments);
39
- r(this, "store", R());
40
- r(this, "storeUnsubscription", () => {
39
+ n(this, "store", R());
40
+ n(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
- r(this, "pendingNodeConfigWrite", null);
45
- r(this, "pendingConfigFlushTimer", null);
44
+ n(this, "pendingNodeConfigWrite", null);
45
+ n(this, "pendingConfigFlushTimer", null);
46
46
  // Sub-control instances for lifecycle management
47
- r(this, "algorithmControl", null);
48
- r(this, "localeControl", null);
49
- r(this, "currencyControl", null);
50
- r(this, "productCountControl", null);
51
- r(this, "productLayoutControl", null);
52
- r(this, "filtersControl", null);
53
- r(this, "shuffleControl", null);
54
- r(this, "pricePlacementControl", null);
55
- r(this, "layoutOrientationControl", null);
56
- r(this, "strategyControl", null);
57
- r(this, "rrsEnabled", !1);
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);
58
58
  /**
59
59
  * Debounced product fetch to prevent rapid API calls during config changes
60
60
  */
61
- r(this, "_debouncedFetchProducts", f(async () => {
61
+ n(this, "_debouncedFetchProducts", f(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
- r(this, "_debouncedRegenerateWithProducts", f(() => {
79
+ n(this, "_debouncedRegenerateWithProducts", f(() => {
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 (v(this.currentNode)) {
84
+ if (x(this.currentNode)) {
85
85
  o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
86
86
  return;
87
87
  }
88
- x({
88
+ B({
89
89
  currentNode: this.currentNode,
90
90
  documentModifier: e,
91
91
  products: t
@@ -118,7 +118,7 @@ class at extends N {
118
118
  return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
119
119
  var o;
120
120
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
121
- }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new k(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
121
+ }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
122
122
  e && (e.api = this.api);
123
123
  }), `
124
124
  <div class="recommendation-controls-container">
@@ -140,8 +140,8 @@ class at extends N {
140
140
  const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
141
141
  if (!e)
142
142
  return;
143
- const o = this._getRecommendationIdFromNode(t) === null ? null : c.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);
143
+ const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
144
+ e.classList.toggle("strategy-block", r);
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((n) => {
163
- var s;
164
- n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
162
+ }), this._subControls.forEach((r) => {
163
+ var i;
164
+ r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
165
165
  });
166
166
  }
167
167
  onDestroy() {
@@ -209,18 +209,18 @@ class at extends N {
209
209
  const e = this.store.blockStates[t];
210
210
  if (!e)
211
211
  return;
212
- const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
213
- e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
212
+ const o = JSON.stringify(c.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
213
+ e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
214
214
  }
215
215
  _capturePendingNodeConfigWrite() {
216
216
  const t = this.store.currentRecommendationId;
217
217
  if (!this.currentNode || !this.api || t === null)
218
218
  return;
219
- const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
219
+ const { filters: e, strategyId: o, size: r } = this.store.recommendationConfigs;
220
220
  this.pendingNodeConfigWrite = {
221
221
  blockId: t,
222
222
  node: this.currentNode,
223
- updates: { filters: e, strategyId: o, size: n, configVersion: s }
223
+ updates: { filters: e, strategyId: o, size: r }
224
224
  };
225
225
  }
226
226
  /**
@@ -263,12 +263,11 @@ class at extends N {
263
263
  JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
264
264
  }
265
265
  _syncNodeConfigToStore() {
266
- var n;
267
- const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
266
+ var r;
267
+ const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
268
268
  this.store.patchCurrentBlockConfig({
269
269
  strategy: t.strategy,
270
270
  strategyId: t.strategyId,
271
- nodeConfigVersion: t.configVersion,
272
271
  language: t.language,
273
272
  size: t.size,
274
273
  productIds: t.productIds,
@@ -307,8 +306,8 @@ class at extends N {
307
306
  t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
308
307
  this.store.fetchRecommendationCreateData(),
309
308
  this.store.fetchRecommendationFilters()
310
- ])).forEach((o, n) => {
311
- o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
309
+ ])).forEach((o, r) => {
310
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
312
311
  }), this._applySmartDefaults();
313
312
  try {
314
313
  await this.store.fetchRecommendationProducts();
@@ -330,30 +329,30 @@ class at extends N {
330
329
  if (!this.currentNode || !this.api)
331
330
  return;
332
331
  const t = c.getConfig(this.currentNode), e = {};
333
- let o = null, n = null, s = null;
332
+ let o = null, r = null, i = null;
334
333
  if (t.currency.code === a.currency.code) {
335
- const { currencyList: i } = this.store;
336
- i.length > 0 && (i.some(
334
+ const { currencyList: s } = this.store;
335
+ s.length > 0 && (s.some(
337
336
  (d) => d.value === `price.${a.currency.code}`
338
- ) || (o = i[0].value.replace("price.", ""), e.currency = {
337
+ ) || (o = s[0].value.replace("price.", ""), e.currency = {
339
338
  ...a.currency,
340
339
  code: o,
341
340
  symbol: o
342
341
  }));
343
342
  }
344
343
  if (t.strategy === a.strategy) {
345
- const i = this.store.getActivePredictiveAlgorithms;
346
- i.length > 0 && (i.some(
344
+ const s = this.store.getActivePredictiveAlgorithms;
345
+ s.length > 0 && (s.some(
347
346
  (d) => d.value === a.strategy
348
- ) || (n = i[0].value, e.strategy = n));
347
+ ) || (r = s[0].value, e.strategy = r));
349
348
  }
350
349
  if (t.language === a.language) {
351
- const i = this.store.getLanguages;
352
- i.length > 0 && (i.some(
350
+ const s = this.store.getLanguages;
351
+ s.length > 0 && (s.some(
353
352
  (d) => d.value === a.language
354
- ) || (s = i[0].value, e.language = s));
353
+ ) || (i = s[0].value, e.language = i));
355
354
  }
356
- !o && !n && !s || (c.updateConfig(
355
+ !o && !r && !i || (c.updateConfig(
357
356
  this.api,
358
357
  this.currentNode,
359
358
  e,
@@ -374,22 +373,22 @@ class at extends N {
374
373
  thousandSeparator: a.currency.thousandSeparator
375
374
  }
376
375
  } : {},
377
- ...n ? { strategy: n } : {},
378
- ...s ? { language: s } : {}
376
+ ...r ? { strategy: r } : {},
377
+ ...i ? { language: i } : {}
379
378
  }, { triggerRefetch: !1 }));
380
379
  }
381
380
  /**
382
381
  * Reads the recommendation-id attribute from the block element within the node
383
382
  */
384
383
  _getRecommendationIdFromNode(t) {
385
- const e = B(t);
384
+ const e = v(t);
386
385
  if (!e || !("getAttribute" in e))
387
386
  return null;
388
387
  const o = e.getAttribute(I);
389
388
  if (!o)
390
389
  return null;
391
- const n = parseInt(o);
392
- return Number.isNaN(n) ? null : n;
390
+ const r = parseInt(o);
391
+ return Number.isNaN(r) ? null : r;
393
392
  }
394
393
  /**
395
394
  * Listen to store changes that require product refresh or regeneration.
@@ -406,17 +405,17 @@ class at extends N {
406
405
  */
407
406
  _listenStateUpdates() {
408
407
  const { store: t } = this;
409
- let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
408
+ let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
410
409
  this.storeUnsubscription = t.$subscribe(() => {
411
- const s = t.currentRecommendationId;
412
- if (s !== n) {
413
- n = s, e = t.recommendationProducts, o = t.$state.configVersion;
410
+ const i = t.currentRecommendationId;
411
+ if (i !== r) {
412
+ r = i, e = t.recommendationProducts, o = t.$state.configVersion;
414
413
  return;
415
414
  }
416
- const i = t.$state.configVersion;
417
- i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
418
- const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
419
- d && h && (e = u, this._debouncedRegenerateWithProducts());
415
+ const s = t.$state.configVersion;
416
+ s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
417
+ const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
418
+ d && g && (e = u, this._debouncedRegenerateWithProducts());
420
419
  });
421
420
  }
422
421
  }
@@ -424,9 +423,9 @@ export {
424
423
  ut as ALGORITHM_CONTROL_ID,
425
424
  T as AlgorithmControl,
426
425
  $ as CONTROL_BLOCK_ID,
427
- gt as CURRENCY_CONTROL_ID,
426
+ ht as CURRENCY_CONTROL_ID,
428
427
  P as CurrencyControl,
429
- ht as FILTERS_CONTROL_ID,
428
+ gt as FILTERS_CONTROL_ID,
430
429
  S as FiltersControl,
431
430
  Ct as LAYOUT_ORIENTATION_CONTROL_ID,
432
431
  yt as LOCALE_CONTROL_ID,
@@ -435,25 +434,25 @@ export {
435
434
  _t as PRICE_PLACEMENT_CONTROL_ID,
436
435
  Rt as PRODUCT_COUNT_CONTROL_ID,
437
436
  Tt as PRODUCT_LAYOUT_CONTROL_ID,
438
- k as PricePlacementControl,
439
- E as ProductCountControl,
437
+ E as PricePlacementControl,
438
+ k as ProductCountControl,
440
439
  F as ProductLayoutControl,
441
440
  at as RecommendationBlockControl,
442
441
  St as SHUFFLE_CONTROL_ID,
443
442
  Lt as STRATEGY_CONTROL_ID,
444
443
  D as ShuffleControl,
445
444
  w as StrategyControl,
446
- Et as adjustProductsToSize,
445
+ kt as adjustProductsToSize,
447
446
  Ft as formatProductPrice,
448
- B as getBlockElement,
447
+ v as getBlockElement,
449
448
  Dt as getCardComposition,
450
449
  wt as getCurrentLayout,
451
450
  At as getMainContainerTbody,
452
- v as isPartnerManagedBlock,
453
- Bt as regenerateMobileProductRows,
451
+ x as isPartnerManagedBlock,
452
+ vt as regenerateMobileProductRows,
454
453
  U as regenerateProductRowsWithStyles,
455
454
  A as setCurrencyAttributes,
456
- vt as updatePricesInPlace,
457
- x as updateProductContentInPlace,
458
- xt as updateSingleProductContent
455
+ xt as updatePricesInPlace,
456
+ B as updateProductContentInPlace,
457
+ Bt as updateSingleProductContent
459
458
  };
@@ -1,32 +1,26 @@
1
- var p = Object.defineProperty;
2
- var v = (i, s, t) => s in i ? p(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
- var r = (i, s, t) => v(i, typeof s != "symbol" ? s + "" : s, t);
4
- import { useLegacyStrategyConversion as _ } from "../../../../../composables/useLegacyStrategyConversion.js";
5
- import { ACADEMY_LINKS as b } from "../../../../../enums/academy.js";
6
- import { useOnboardingStore as S } from "../../../../../stores/onboarding.js";
7
- import { CommonControl as f } from "../../../common-control.js";
8
- import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
9
- const C = "recommendation-strategy-control";
10
- class N extends f {
1
+ var d = Object.defineProperty;
2
+ var y = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
+ var o = (r, s, t) => y(r, typeof s != "symbol" ? s + "" : s, t);
4
+ import { ACADEMY_LINKS as m } from "../../../../../enums/academy.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { useRecommendationExtensionStore as u } from "../../store/recommendation.js";
7
+ const p = "recommendation-strategy-control";
8
+ class f extends h {
11
9
  constructor() {
12
10
  super(...arguments);
13
- r(this, "store", $());
14
- r(this, "onboardingStore", S());
15
- r(this, "legacyConversion", _());
16
- r(this, "storeUnsubscription", () => {
11
+ o(this, "store", u());
12
+ o(this, "storeUnsubscription", () => {
17
13
  });
18
- r(this, "listeners", []);
19
- r(this, "lastPaintedState", null);
14
+ o(this, "listeners", []);
15
+ o(this, "lastPaintedState", null);
20
16
  }
21
17
  getId() {
22
- return C;
18
+ return p;
23
19
  }
24
20
  getTemplate() {
25
21
  const t = this.api.translate(
26
22
  "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"), o = this.api.translate("Legacy Strategy"), n = this.api.translate(
28
- "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."
29
- );
23
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
30
24
  return `
31
25
  <div class="strategy-control-container">
32
26
  <div class="strategy-control-header">
@@ -37,7 +31,7 @@ class N extends f {
37
31
  ${t}
38
32
  ${e}
39
33
  <a
40
- href="${b.EMAIL_RECOMMENDATION_BLOCK}"
34
+ href="${m.EMAIL_RECOMMENDATION_BLOCK}"
41
35
  target="_blank"
42
36
  rel="noopener noreferrer">${a}</a>.
43
37
  </p>
@@ -59,33 +53,6 @@ class N extends f {
59
53
  })
60
54
  ], "strategy-control-cta-row")}
61
55
  </div>
62
- <div data-strategy-legacy-state style="display: none;">
63
- <div class="strategy-control-notice-row">
64
- <div class="strategy-control-notice">
65
- <p class="strategy-control-notice-text">${n}</p>
66
- </div>
67
- </div>
68
- <div class="strategy-control-name-band">
69
- <span class="strategy-control-name">${o}</span>
70
- ${this._strategyAction({
71
- id: "guido__btn-update-legacy-strategy",
72
- label: this.api.translate("Update"),
73
- modifier: "update"
74
- })}
75
- </div>
76
- <div class="strategy-control-actions">
77
- ${this._strategyAction({
78
- id: "guido__btn-change-legacy-strategy",
79
- label: this.api.translate("Change"),
80
- modifier: "change"
81
- })}
82
- ${this._strategyAction({
83
- id: "guido__btn-remove-legacy-strategy",
84
- label: this.api.translate("Remove"),
85
- modifier: "remove"
86
- })}
87
- </div>
88
- </div>
89
56
  <div data-strategy-assigned-state style="display: none;">
90
57
  <div class="strategy-control-name-band">
91
58
  <span class="strategy-control-name" data-strategy-name></span>
@@ -121,8 +88,6 @@ class N extends f {
121
88
  this._renderState();
122
89
  }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
123
90
  });
124
- const t = this.store.currentRecommendationId, e = t !== null && !!this.store.blockStates[t], a = this.store.isLegacyStrategyBlock;
125
- e && !this.store.recommendationConfigs.strategyId && !a && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), e && a && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding");
126
91
  }
127
92
  onDestroy() {
128
93
  this._teardown();
@@ -135,34 +100,25 @@ class N extends f {
135
100
  const t = this.getContainer();
136
101
  if (!t)
137
102
  return;
138
- const e = (a, o) => {
139
- const n = t.querySelector(a);
140
- n && (n.addEventListener("click", o), this.listeners.push({ element: n, handler: o }));
103
+ const e = (a, n) => {
104
+ const i = t.querySelector(a);
105
+ i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
141
106
  };
142
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), 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", () => {
143
- this.legacyConversion.convertLegacyStrategy();
144
- });
107
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
145
108
  }
146
109
  _renderState() {
147
- var h;
148
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((h = this.store.assignedStrategy) == null ? void 0 : h.name) ?? "" : "", a = this.store.legacyConversionLoading, o = this.store.isLegacyStrategyBlock, n = `${t}\0${e}\0${a}\0${o}`;
149
- if (n === this.lastPaintedState)
150
- return;
151
- const c = this.getContainer();
152
- if (!c)
110
+ var l;
111
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
112
+ if (a === this.lastPaintedState)
153
113
  return;
154
- const d = c.querySelector("[data-strategy-empty-state]"), y = c.querySelector("[data-strategy-assigned-state]"), g = c.querySelector("[data-strategy-legacy-state]"), m = c.querySelector("[data-strategy-name]");
155
- if (!d || !y || !g)
114
+ const n = this.getContainer();
115
+ if (!n)
156
116
  return;
157
- const u = t ? y : o ? g : d;
158
- [d, y, g].forEach((l) => {
159
- l.style.display = l === u ? "" : "none";
160
- }), g.querySelectorAll("button").forEach((l) => {
161
- l.disabled = a;
162
- }), g.classList.toggle("is-converting", a), m && t && (m.textContent = e || `#${t}`), this.lastPaintedState = n;
117
+ const i = n.querySelector("[data-strategy-empty-state]"), c = n.querySelector("[data-strategy-assigned-state]"), g = n.querySelector("[data-strategy-name]");
118
+ !i || !c || (i.style.display = t ? "none" : "", c.style.display = t ? "" : "none", g && t && (g.textContent = e || `#${t}`), this.lastPaintedState = a);
163
119
  }
164
120
  }
165
121
  export {
166
- C as STRATEGY_CONTROL_ID,
167
- N as StrategyControl
122
+ p as STRATEGY_CONTROL_ID,
123
+ f as StrategyControl
168
124
  };