@useinsider/guido 3.16.0-beta.f1a5d40 → 3.16.0-beta.ff4f1bd

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 (73) hide show
  1. package/README.md +6 -5
  2. package/dist/@types/config/schemas.js +12 -6
  3. package/dist/components/Guido.vue.js +6 -6
  4. package/dist/components/Guido.vue2.js +31 -30
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +18 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +61 -0
  7. package/dist/composables/useRecommendation.js +43 -36
  8. package/dist/config/migrator/recommendationMigrator.js +6 -4
  9. package/dist/enums/extensions/recommendationBlock.js +25 -23
  10. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +13 -11
  11. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +112 -90
  12. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +106 -0
  13. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +188 -53
  14. package/dist/guido.css +1 -1
  15. package/dist/node_modules/@useinsider/design-system-organisms/dist/index-5JHlb8rM.js +524 -0
  16. package/dist/node_modules/@useinsider/design-system-organisms/dist/index.js +8450 -0
  17. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InAccordion.js +174 -0
  18. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InBasicTextInput.js +381 -0
  19. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InBox.js +236 -0
  20. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InBulkActions.js +70 -0
  21. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InButton.js +350 -0
  22. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InButtonV2.js +371 -0
  23. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InCheckBox.js +152 -0
  24. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InChips.js +141 -0
  25. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InCustomDropDown.js +1047 -0
  26. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDataTableV2.js +96050 -0
  27. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDatePicker.js +2042 -0
  28. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDrawer.js +166 -0
  29. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InDropDown.js +1098 -0
  30. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InIcons.js +55 -0
  31. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InInfoBox.js +265 -0
  32. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InLinks.js +184 -0
  33. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InLoading.js +50 -0
  34. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InModals.js +453 -0
  35. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InNoData.js +145 -0
  36. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InOnPageMessage.js +176 -0
  37. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InProgress.js +266 -0
  38. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InRadioButton.js +114 -0
  39. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InSegments.js +200 -0
  40. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InSelect.js +451 -0
  41. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InSkeleton.js +49 -0
  42. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InStatusText.js +119 -0
  43. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTabs.js +4309 -0
  44. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTagsText.js +129 -0
  45. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTextInput.js +503 -0
  46. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InToasts.js +253 -0
  47. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InToggle.js +107 -0
  48. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTooltip.js +134 -0
  49. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/InTooltipV2.js +464 -0
  50. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/_commonjsHelpers.BItOPCY9.js +28 -0
  51. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/_plugin-vue2_normalizer.WQT2Fc8L.js +23 -0
  52. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/clickOutside.qP9M0QCm.js +29 -0
  53. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/helpers.CgHNyjAJ.js +109 -0
  54. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/index.Bw_06igr.js +2339 -0
  55. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/localLocalesMixin.DYMhydo2.js +16 -0
  56. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/useLocalLocales.Ckuhy7d-.js +17 -0
  57. package/dist/node_modules/@useinsider/design-system-organisms/node_modules/@useinsider/design-system-vue/dist/chunks/vue-property-decorator.BtlM7Epa.js +188 -0
  58. package/dist/services/recommendationApi.js +77 -28
  59. package/dist/src/@types/config/schemas.d.ts +12 -0
  60. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  61. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  62. package/dist/src/composables/useConfig.d.ts +2 -0
  63. package/dist/src/composables/useRecommendation.d.ts +1 -0
  64. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  65. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +6 -3
  66. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +26 -0
  67. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +199 -10
  68. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  69. package/dist/src/mock/api/recommendation-strategies.d.ts +41 -0
  70. package/dist/src/services/recommendationApi.d.ts +4 -1
  71. package/dist/src/stores/config.d.ts +18 -0
  72. package/dist/utils/templatePreparation.js +37 -34
  73. package/package.json +3 -2
@@ -1,36 +1,39 @@
1
1
  var f = Object.defineProperty;
2
- var p = (d, l, t) => l in d ? f(d, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[l] = t;
3
- var s = (d, l, t) => p(d, typeof l != "symbol" ? l + "" : l, t);
4
- import { CommonControl as g } from "../../../common-control.js";
5
- import { DEFAULT_NODE_CONFIG as c } from "../../constants/defaultConfig.js";
2
+ var p = (d, a, t) => a in d ? f(d, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[a] = t;
3
+ var s = (d, a, t) => p(d, typeof a != "symbol" ? a + "" : a, t);
4
+ import { useConfig as g } from "../../../../../composables/useConfig.js";
5
+ import { CommonControl as y } from "../../../common-control.js";
6
+ import { DEFAULT_NODE_CONFIG as l } from "../../constants/defaultConfig.js";
6
7
  import { RecommendationConfigService as m } from "../../services/configService.js";
7
- import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
8
- import { AlgorithmControl as N } from "./algorithm.js";
9
- import { ALGORITHM_CONTROL_ID as tt } from "./algorithm.js";
10
- import { CurrencyControl as R } from "./currency.js";
11
- import { CURRENCY_CONTROL_ID as ot } from "./currency.js";
12
- import { FiltersControl as I } from "./filters.js";
13
- import { FILTERS_CONTROL_ID as nt } from "./filters.js";
14
- import { LayoutOrientationControl as _ } from "./layoutOrientation.js";
15
- import { LAYOUT_ORIENTATION_CONTROL_ID as st } from "./layoutOrientation.js";
16
- import { LocaleControl as b } from "./locale.js";
17
- import { LOCALE_CONTROL_ID as lt } from "./locale.js";
18
- import { PricePlacementControl as T } from "./pricePlacement.js";
19
- import { PRICE_PLACEMENT_CONTROL_ID as ut } from "./pricePlacement.js";
8
+ import { useRecommendationExtensionStore as I } from "../../store/recommendation.js";
9
+ import { AlgorithmControl as R } from "./algorithm.js";
10
+ import { ALGORITHM_CONTROL_ID as nt } from "./algorithm.js";
11
+ import { CurrencyControl as N } from "./currency.js";
12
+ import { CURRENCY_CONTROL_ID as st } from "./currency.js";
13
+ import { FiltersControl as T } from "./filters.js";
14
+ import { FILTERS_CONTROL_ID as at } from "./filters.js";
15
+ import { LayoutOrientationControl as b } from "./layoutOrientation.js";
16
+ import { LAYOUT_ORIENTATION_CONTROL_ID as ut } from "./layoutOrientation.js";
17
+ import { LocaleControl as _ } from "./locale.js";
18
+ import { LOCALE_CONTROL_ID as mt } from "./locale.js";
19
+ import { PricePlacementControl as O } from "./pricePlacement.js";
20
+ import { PRICE_PLACEMENT_CONTROL_ID as Ct } from "./pricePlacement.js";
20
21
  import { ProductCountControl as P } from "./productCount.js";
21
- import { PRODUCT_COUNT_CONTROL_ID as mt } from "./productCount.js";
22
- import { ProductLayoutControl as O } from "./productLayout.js";
23
- import { PRODUCT_LAYOUT_CONTROL_ID as Ct } from "./productLayout.js";
24
- import { ShuffleControl as L } from "./shuffle.js";
25
- import { SHUFFLE_CONTROL_ID as pt } from "./shuffle.js";
26
- import { setCurrencyAttributes as S, getBlockElement as k, isPartnerManagedBlock as D, updateProductContentInPlace as E, regenerateProductRowsWithStyles as A } from "./utils.js";
27
- import { adjustProductsToSize as yt, formatProductPrice as Nt, getCardComposition as Rt, getCurrentLayout as It, regenerateMobileProductRows as _t, updatePricesInPlace as bt, updateSingleProductContent as Tt } from "./utils.js";
22
+ import { PRODUCT_COUNT_CONTROL_ID as pt } from "./productCount.js";
23
+ import { ProductLayoutControl as L } from "./productLayout.js";
24
+ import { PRODUCT_LAYOUT_CONTROL_ID as yt } from "./productLayout.js";
25
+ import { ShuffleControl as S } from "./shuffle.js";
26
+ import { SHUFFLE_CONTROL_ID as Rt } from "./shuffle.js";
27
+ import { StrategyControl as k } from "./strategy.js";
28
+ import { STRATEGY_CONTROL_ID as Tt } from "./strategy.js";
29
+ import { setCurrencyAttributes as D, getBlockElement as E, isPartnerManagedBlock as v, updateProductContentInPlace as A, regenerateProductRowsWithStyles as w } from "./utils.js";
30
+ import { adjustProductsToSize as _t, formatProductPrice as Ot, getCardComposition as Pt, getCurrentLayout as Lt, regenerateMobileProductRows as St, updatePricesInPlace as kt, updateSingleProductContent as Dt } from "./utils.js";
28
31
  import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
29
- const v = "recommendation-id", w = "ui-elements-recommendation-block";
30
- class Q extends g {
32
+ const x = "recommendation-id", B = "ui-elements-recommendation-block";
33
+ class et extends y {
31
34
  constructor() {
32
35
  super(...arguments);
33
- s(this, "store", y());
36
+ s(this, "store", I());
34
37
  s(this, "storeUnsubscription", () => {
35
38
  });
36
39
  s(this, "syncedBlockIds", /* @__PURE__ */ new Set());
@@ -44,6 +47,7 @@ class Q extends g {
44
47
  s(this, "shuffleControl", null);
45
48
  s(this, "pricePlacementControl", null);
46
49
  s(this, "layoutOrientationControl", null);
50
+ s(this, "strategyControl", null);
47
51
  /**
48
52
  * Debounced product fetch to prevent rapid API calls during config changes
49
53
  */
@@ -63,14 +67,14 @@ class Q extends g {
63
67
  */
64
68
  s(this, "_debouncedRegenerateWithProducts", h(() => {
65
69
  const t = this.store.recommendationProducts;
66
- if (!this.currentNode || !this.api || D(this.currentNode))
70
+ if (!this.currentNode || !this.api || v(this.currentNode))
67
71
  return;
68
72
  const e = this.api.getDocumentModifier();
69
- E({
73
+ A({
70
74
  currentNode: this.currentNode,
71
75
  documentModifier: e,
72
76
  products: t
73
- }) || A({
77
+ }) || w({
74
78
  currentNode: this.currentNode,
75
79
  documentModifier: e,
76
80
  products: t
@@ -78,10 +82,11 @@ class Q extends g {
78
82
  }, 100));
79
83
  }
80
84
  getId() {
81
- return w;
85
+ return B;
82
86
  }
83
87
  getTemplate() {
84
- return this.algorithmControl = new N(), this.localeControl = new b(), this.currencyControl = new R(), this.productCountControl = new P(), this.productLayoutControl = new O(), this.filtersControl = new I(), this.shuffleControl = new L(), this.pricePlacementControl = new T(), this.layoutOrientationControl = new _(), [
88
+ const t = g().isFeatureEnabled("reusableRecommendationStrategy");
89
+ return this.algorithmControl = t ? null : new R(), this.localeControl = new _(), this.currencyControl = new N(), this.productCountControl = t ? null : new P(), this.productLayoutControl = new L(), this.filtersControl = t ? null : new T(), this.shuffleControl = t ? null : new S(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new b(), this.strategyControl = t ? new k() : null, [
85
90
  this.algorithmControl,
86
91
  this.localeControl,
87
92
  this.currencyControl,
@@ -90,10 +95,20 @@ class Q extends g {
90
95
  this.filtersControl,
91
96
  this.shuffleControl,
92
97
  this.pricePlacementControl,
93
- this.layoutOrientationControl
94
- ].forEach((e) => {
95
- e.api = this.api;
96
- }), `
98
+ this.layoutOrientationControl,
99
+ this.strategyControl
100
+ ].forEach((o) => {
101
+ o && (o.api = this.api);
102
+ }), t ? `
103
+ <div class="recommendation-controls-container">
104
+ ${this.layoutOrientationControl.getTemplate()}
105
+ ${this.strategyControl.getTemplate()}
106
+ ${this.productLayoutControl.getTemplate()}
107
+ ${this.localeControl.getTemplate()}
108
+ ${this.pricePlacementControl.getTemplate()}
109
+ ${this.currencyControl.getTemplate()}
110
+ </div>
111
+ ` : `
97
112
  <div class="recommendation-controls-container">
98
113
  ${this.layoutOrientationControl.getTemplate()}
99
114
  ${this.productCountControl.getTemplate()}
@@ -131,7 +146,8 @@ class Q extends g {
131
146
  this.productLayoutControl,
132
147
  this.filtersControl,
133
148
  this.shuffleControl,
134
- this.pricePlacementControl
149
+ this.pricePlacementControl,
150
+ this.strategyControl
135
151
  ].forEach((n) => {
136
152
  var i;
137
153
  n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
@@ -147,7 +163,8 @@ class Q extends g {
147
163
  this.productLayoutControl,
148
164
  this.filtersControl,
149
165
  this.shuffleControl,
150
- this.pricePlacementControl
166
+ this.pricePlacementControl,
167
+ this.strategyControl
151
168
  ].forEach((e) => {
152
169
  var o;
153
170
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
@@ -167,7 +184,8 @@ class Q extends g {
167
184
  this.productLayoutControl,
168
185
  this.filtersControl,
169
186
  this.shuffleControl,
170
- this.pricePlacementControl
187
+ this.pricePlacementControl,
188
+ this.strategyControl
171
189
  ].forEach((e) => {
172
190
  var o;
173
191
  e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
@@ -189,6 +207,7 @@ class Q extends g {
189
207
  const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
190
208
  this.store.patchCurrentBlockConfig({
191
209
  strategy: t.strategy,
210
+ strategyId: t.strategyId,
192
211
  language: t.language,
193
212
  size: t.size,
194
213
  productIds: t.productIds,
@@ -251,26 +270,26 @@ class Q extends g {
251
270
  return;
252
271
  const t = m.getConfig(this.currentNode), e = {};
253
272
  let o = null, r = null, n = null;
254
- if (t.currency.code === c.currency.code) {
273
+ if (t.currency.code === l.currency.code) {
255
274
  const { currencyList: i } = this.store;
256
275
  i.length > 0 && (i.some(
257
- (u) => u.value === `price.${c.currency.code}`
276
+ (u) => u.value === `price.${l.currency.code}`
258
277
  ) || (o = i[0].value.replace("price.", ""), e.currency = {
259
- ...c.currency,
278
+ ...l.currency,
260
279
  code: o,
261
280
  symbol: o
262
281
  }));
263
282
  }
264
- if (t.strategy === c.strategy) {
283
+ if (t.strategy === l.strategy) {
265
284
  const i = this.store.getActivePredictiveAlgorithms;
266
285
  i.length > 0 && (i.some(
267
- (u) => u.value === c.strategy
286
+ (u) => u.value === l.strategy
268
287
  ) || (r = i[0].value, e.strategy = r));
269
288
  }
270
- if (t.language === c.language) {
289
+ if (t.language === l.language) {
271
290
  const i = this.store.getLanguages;
272
291
  i.length > 0 && (i.some(
273
- (u) => u.value === c.language
292
+ (u) => u.value === l.language
274
293
  ) || (n = i[0].value, e.language = n));
275
294
  }
276
295
  !o && !r && !n || (m.updateConfig(
@@ -278,7 +297,7 @@ class Q extends g {
278
297
  this.currentNode,
279
298
  e,
280
299
  "Applied smart defaults"
281
- ), o && e.currency && S({
300
+ ), o && e.currency && D({
282
301
  currentNode: this.currentNode,
283
302
  documentModifier: this.api.getDocumentModifier(),
284
303
  currency: e.currency
@@ -288,10 +307,10 @@ class Q extends g {
288
307
  name: o,
289
308
  value: o,
290
309
  symbol: o,
291
- alignment: c.currency.alignment === "before" ? "0" : "1",
292
- decimalCount: c.currency.decimalCount.toString(),
293
- decimalSeparator: c.currency.decimalSeparator,
294
- thousandSeparator: c.currency.thousandSeparator
310
+ alignment: l.currency.alignment === "before" ? "0" : "1",
311
+ decimalCount: l.currency.decimalCount.toString(),
312
+ decimalSeparator: l.currency.decimalSeparator,
313
+ thousandSeparator: l.currency.thousandSeparator
295
314
  }
296
315
  } : {},
297
316
  ...r ? { strategy: r } : {},
@@ -302,10 +321,10 @@ class Q extends g {
302
321
  * Reads the recommendation-id attribute from the block element within the node
303
322
  */
304
323
  _getRecommendationIdFromNode(t) {
305
- const e = k(t);
324
+ const e = E(t);
306
325
  if (!e || !("getAttribute" in e))
307
326
  return null;
308
- const o = e.getAttribute(v);
327
+ const o = e.getAttribute(x);
309
328
  if (!o)
310
329
  return null;
311
330
  const r = parseInt(o);
@@ -335,57 +354,60 @@ class Q extends g {
335
354
  }
336
355
  const i = t.$state.configVersion;
337
356
  i !== o && (o = i, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
338
- const a = t.recommendationProducts, u = a !== e, C = Array.isArray(a) && a.length > 0;
339
- u && C && (e = a, this._debouncedRegenerateWithProducts());
357
+ const c = t.recommendationProducts, u = c !== e, C = Array.isArray(c) && c.length > 0;
358
+ u && C && (e = c, this._debouncedRegenerateWithProducts());
340
359
  });
341
360
  }
342
361
  /**
343
- * Persists the current filter state from Pinia store to the Stripo node config.
344
- * This ensures filters survive template save/reload cycles.
362
+ * Persists the current filter + strategy state from Pinia store to the
363
+ * Stripo node config. This ensures they survive template save/reload cycles
364
+ * (strategyId must be in esd-ext-config before any save — SD-149105).
345
365
  */
346
366
  _persistFiltersToNodeConfig() {
347
367
  if (!this.currentNode || !this.api)
348
368
  return;
349
- const { filters: t } = this.store.recommendationConfigs;
369
+ const { filters: t, strategyId: e } = this.store.recommendationConfigs;
350
370
  m.updateConfig(
351
371
  this.api,
352
372
  this.currentNode,
353
- { filters: t },
373
+ { filters: t, strategyId: e },
354
374
  "Update recommendation filters"
355
375
  );
356
376
  }
357
377
  }
358
378
  export {
359
- tt as ALGORITHM_CONTROL_ID,
360
- N as AlgorithmControl,
361
- w as CONTROL_BLOCK_ID,
362
- ot as CURRENCY_CONTROL_ID,
363
- R as CurrencyControl,
364
- nt as FILTERS_CONTROL_ID,
365
- I as FiltersControl,
366
- st as LAYOUT_ORIENTATION_CONTROL_ID,
367
- lt as LOCALE_CONTROL_ID,
368
- _ as LayoutOrientationControl,
369
- b as LocaleControl,
370
- ut as PRICE_PLACEMENT_CONTROL_ID,
371
- mt as PRODUCT_COUNT_CONTROL_ID,
372
- Ct as PRODUCT_LAYOUT_CONTROL_ID,
373
- T as PricePlacementControl,
379
+ nt as ALGORITHM_CONTROL_ID,
380
+ R as AlgorithmControl,
381
+ B as CONTROL_BLOCK_ID,
382
+ st as CURRENCY_CONTROL_ID,
383
+ N as CurrencyControl,
384
+ at as FILTERS_CONTROL_ID,
385
+ T as FiltersControl,
386
+ ut as LAYOUT_ORIENTATION_CONTROL_ID,
387
+ mt as LOCALE_CONTROL_ID,
388
+ b as LayoutOrientationControl,
389
+ _ as LocaleControl,
390
+ Ct as PRICE_PLACEMENT_CONTROL_ID,
391
+ pt as PRODUCT_COUNT_CONTROL_ID,
392
+ yt as PRODUCT_LAYOUT_CONTROL_ID,
393
+ O as PricePlacementControl,
374
394
  P as ProductCountControl,
375
- O as ProductLayoutControl,
376
- Q as RecommendationBlockControl,
377
- pt as SHUFFLE_CONTROL_ID,
378
- L as ShuffleControl,
379
- yt as adjustProductsToSize,
380
- Nt as formatProductPrice,
381
- k as getBlockElement,
382
- Rt as getCardComposition,
383
- It as getCurrentLayout,
384
- D as isPartnerManagedBlock,
385
- _t as regenerateMobileProductRows,
386
- A as regenerateProductRowsWithStyles,
387
- S as setCurrencyAttributes,
388
- bt as updatePricesInPlace,
389
- E as updateProductContentInPlace,
390
- Tt as updateSingleProductContent
395
+ L as ProductLayoutControl,
396
+ et as RecommendationBlockControl,
397
+ Rt as SHUFFLE_CONTROL_ID,
398
+ Tt as STRATEGY_CONTROL_ID,
399
+ S as ShuffleControl,
400
+ k as StrategyControl,
401
+ _t as adjustProductsToSize,
402
+ Ot as formatProductPrice,
403
+ E as getBlockElement,
404
+ Pt as getCardComposition,
405
+ Lt as getCurrentLayout,
406
+ v as isPartnerManagedBlock,
407
+ St as regenerateMobileProductRows,
408
+ w as regenerateProductRowsWithStyles,
409
+ D as setCurrencyAttributes,
410
+ kt as updatePricesInPlace,
411
+ A as updateProductContentInPlace,
412
+ Dt as updateSingleProductContent
391
413
  };
@@ -0,0 +1,106 @@
1
+ var d = Object.defineProperty;
2
+ var l = (a, e, t) => e in a ? d(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
+ var o = (a, e, t) => l(a, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CommonControl as m } from "../../../common-control.js";
5
+ import { useRecommendationExtensionStore as y } from "../../store/recommendation.js";
6
+ const h = "recommendation-strategy-control", u = "https://academy.insiderone.com/docs/new-editor-email-recommendation-block", c = {
7
+ ASSIGN: "assignStrategy",
8
+ CHANGE: "changeStrategy",
9
+ REMOVE: "removeStrategy"
10
+ };
11
+ class b extends m {
12
+ constructor() {
13
+ super(...arguments);
14
+ o(this, "store", y());
15
+ o(this, "storeUnsubscription", () => {
16
+ });
17
+ o(this, "listeners", []);
18
+ }
19
+ getId() {
20
+ return h;
21
+ }
22
+ getTemplate() {
23
+ const t = this.api.translate(
24
+ "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
25
+ ), s = this.api.translate("For more information, you can"), n = this.api.translate("visit Academy");
26
+ return `
27
+ <div class="strategy-control-container">
28
+ ${this._GuOneColumn([
29
+ this._GuLabel({ text: this.api.translate("Recommendation Strategy") })
30
+ ])}
31
+ <div class="container">
32
+ <p class="strategy-control-description">
33
+ ${t}
34
+ ${s}
35
+ <!-- cspell:disable-next-line -->
36
+ <a href="${u}" target="_blank" rel="noopener noreferrer">${n}</a>.
37
+ </p>
38
+ </div>
39
+ <div data-strategy-empty-state>
40
+ ${this._GuOneColumn([
41
+ this._GuButton({
42
+ name: c.ASSIGN,
43
+ label: this.api.translate("+ Assign Strategy"),
44
+ id: "guido__btn-assign-strategy"
45
+ })
46
+ ])}
47
+ <!-- Create round-trip ships in a later phase; kept visible-but-disabled per design -->
48
+ <div style="pointer-events: none; opacity: 0.5;">
49
+ ${this._GuOneColumn([
50
+ this._GuButton({
51
+ name: "createStrategy",
52
+ label: this.api.translate("Create New Strategy"),
53
+ id: "guido__btn-create-strategy"
54
+ })
55
+ ])}
56
+ </div>
57
+ </div>
58
+ <div data-strategy-assigned-state style="display: none;">
59
+ ${this._GuTwoColumns([
60
+ '<span class="strategy-control-name" data-strategy-name></span>',
61
+ `${this._GuButton({
62
+ name: c.CHANGE,
63
+ label: this.api.translate("Change"),
64
+ id: "guido__btn-change-strategy"
65
+ })}
66
+ ${this._GuButton({
67
+ name: c.REMOVE,
68
+ label: this.api.translate("Remove"),
69
+ id: "guido__btn-remove-strategy"
70
+ })}`
71
+ ])}
72
+ </div>
73
+ </div>
74
+ `;
75
+ }
76
+ onRender() {
77
+ this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
78
+ this._renderState();
79
+ }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
80
+ });
81
+ }
82
+ onDestroy() {
83
+ this.storeUnsubscription(), this.listeners.forEach(({ element: t, handler: s }) => t.removeEventListener("click", s)), this.listeners = [];
84
+ }
85
+ _setupButtonListeners() {
86
+ const t = (s, n) => {
87
+ const i = this.getContainer().querySelector(s);
88
+ i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
89
+ };
90
+ t("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), t("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), t("#guido__btn-remove-strategy", () => this.store.removeStrategy());
91
+ }
92
+ /**
93
+ * Toggles empty vs assigned state from the store's current block config.
94
+ * Display name comes from the listing; falls back to the raw id while the
95
+ * listing loads (or when the strategy is no longer listed).
96
+ */
97
+ _renderState() {
98
+ var g;
99
+ const t = this.getContainer(), s = t.querySelector("[data-strategy-empty-state]"), n = t.querySelector("[data-strategy-assigned-state]"), i = t.querySelector("[data-strategy-name]"), { strategyId: r } = this.store.recommendationConfigs;
100
+ !s || !n || (s.style.display = r ? "none" : "", n.style.display = r ? "" : "none", i && r && (i.textContent = ((g = this.store.assignedStrategy) == null ? void 0 : g.name) ?? `#${r}`));
101
+ }
102
+ }
103
+ export {
104
+ h as STRATEGY_CONTROL_ID,
105
+ b as StrategyControl
106
+ };