@useinsider/guido 3.16.0 → 3.17.0-beta.1631b31

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 (58) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +12 -6
  3. package/dist/components/Guido.vue.js +9 -9
  4. package/dist/components/Guido.vue2.js +77 -73
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +69 -0
  7. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  8. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +13 -0
  9. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  10. package/dist/composables/useRecommendation.js +43 -35
  11. package/dist/composables/useStripo.js +30 -29
  12. package/dist/config/migrator/itemsBlockMigrator.js +1 -1
  13. package/dist/config/migrator/recommendation/settingsMapper.js +19 -17
  14. package/dist/config/migrator/recommendationMigrator.js +6 -4
  15. package/dist/enums/academy.js +2 -1
  16. package/dist/enums/date.js +4 -3
  17. package/dist/enums/extensions/recommendationBlock.js +4 -1
  18. package/dist/enums/recommendation.js +17 -17
  19. package/dist/extensions/Blocks/Items/enums/productEnums.js +45 -45
  20. package/dist/extensions/Blocks/Recommendation/block.js +26 -21
  21. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +36 -34
  22. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
  23. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +37 -26
  24. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +163 -159
  25. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +142 -0
  26. package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
  27. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +222 -78
  28. package/dist/extensions/Blocks/Recommendation/utils/productIds.js +6 -0
  29. package/dist/extensions/Blocks/common-control.js +22 -19
  30. package/dist/guido.css +1 -1
  31. package/dist/services/recommendationApi.js +75 -30
  32. package/dist/src/@types/config/schemas.d.ts +12 -0
  33. package/dist/src/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.d.ts +3 -0
  34. package/dist/src/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.d.ts +17 -0
  35. package/dist/src/composables/useConfig.d.ts +2 -0
  36. package/dist/src/composables/useRecommendation.d.ts +1 -0
  37. package/dist/src/enums/academy.d.ts +1 -0
  38. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  39. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +7 -6
  40. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  41. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +16 -3
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +30 -0
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +206 -10
  44. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  45. package/dist/src/extensions/Blocks/Recommendation/utils/productIds.d.ts +6 -0
  46. package/dist/src/extensions/Blocks/common-control.d.ts +4 -1
  47. package/dist/src/mock/api/recommendation-strategies.d.ts +2 -0
  48. package/dist/src/services/recommendationApi.d.ts +4 -1
  49. package/dist/src/stores/config.d.ts +18 -0
  50. package/dist/src/utils/strategyInfoBox.d.ts +35 -0
  51. package/dist/static/assets/icons/line-change.svg.js +5 -0
  52. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  53. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  54. package/dist/static/styles/components/recommendation-strategy.css.js +188 -0
  55. package/dist/utils/dateUtil.js +29 -10
  56. package/dist/utils/strategyInfoBox.js +68 -0
  57. package/dist/utils/templatePreparation.js +37 -34
  58. package/package.json +2 -1
@@ -1,53 +1,60 @@
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";
1
+ var C = Object.defineProperty;
2
+ var g = (d, c, t) => c in d ? C(d, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[c] = t;
3
+ var n = (d, c, t) => g(d, typeof c != "symbol" ? c + "" : c, t);
4
+ import { useConfig as p } from "../../../../../composables/useConfig.js";
5
+ import { CommonControl as y } from "../../../common-control.js";
6
+ import { CURRENT_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } 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";
8
+ import { useRecommendationExtensionStore as N } from "../../store/recommendation.js";
9
+ import { AlgorithmControl as I } from "./algorithm.js";
10
+ import { ALGORITHM_CONTROL_ID as it } from "./algorithm.js";
10
11
  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";
12
+ import { CURRENCY_CONTROL_ID as at } from "./currency.js";
13
+ import { FiltersControl as b } from "./filters.js";
14
+ import { FILTERS_CONTROL_ID as lt } from "./filters.js";
15
+ import { LayoutOrientationControl as T } from "./layoutOrientation.js";
16
+ import { LAYOUT_ORIENTATION_CONTROL_ID as dt } from "./layoutOrientation.js";
17
+ import { LocaleControl as S } from "./locale.js";
18
+ import { LOCALE_CONTROL_ID as ht } 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 _t } from "./productLayout.js";
25
+ import { ShuffleControl as k } from "./shuffle.js";
26
+ import { SHUFFLE_CONTROL_ID as It } from "./shuffle.js";
27
+ import { StrategyControl as E } from "./strategy.js";
28
+ import { STRATEGY_CONTROL_ID as bt } from "./strategy.js";
29
+ import { setCurrencyAttributes as D, getBlockElement as w, isPartnerManagedBlock as B, updateProductContentInPlace as A, regenerateProductRowsWithStyles as v } from "./utils.js";
30
+ import { adjustProductsToSize as St, formatProductPrice as Ot, getCardComposition as Pt, getCurrentLayout as Lt, regenerateMobileProductRows as kt, updatePricesInPlace as Et, 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", F = "ui-elements-recommendation-block";
33
+ class ot extends y {
31
34
  constructor() {
32
35
  super(...arguments);
33
- s(this, "store", y());
34
- s(this, "storeUnsubscription", () => {
36
+ n(this, "store", N());
37
+ n(this, "storeUnsubscription", () => {
35
38
  });
36
- s(this, "syncedBlockIds", /* @__PURE__ */ new Set());
39
+ n(this, "syncedBlockIds", /* @__PURE__ */ new Set());
37
40
  // Sub-control instances for lifecycle management
38
- s(this, "algorithmControl", null);
39
- s(this, "localeControl", null);
40
- s(this, "currencyControl", null);
41
- s(this, "productCountControl", null);
42
- s(this, "productLayoutControl", null);
43
- s(this, "filtersControl", null);
44
- s(this, "shuffleControl", null);
45
- s(this, "pricePlacementControl", null);
46
- s(this, "layoutOrientationControl", null);
41
+ n(this, "algorithmControl", null);
42
+ n(this, "localeControl", null);
43
+ n(this, "currencyControl", null);
44
+ n(this, "productCountControl", null);
45
+ n(this, "productLayoutControl", null);
46
+ n(this, "filtersControl", null);
47
+ n(this, "shuffleControl", null);
48
+ n(this, "pricePlacementControl", null);
49
+ n(this, "layoutOrientationControl", null);
50
+ n(this, "strategyControl", null);
51
+ // Whether this host may hand out NEW strategies. An already-assigned block
52
+ // keeps the strategy panel either way (SD-149105).
53
+ n(this, "rrsEnabled", !1);
47
54
  /**
48
55
  * Debounced product fetch to prevent rapid API calls during config changes
49
56
  */
50
- s(this, "_debouncedFetchProducts", h(() => {
57
+ n(this, "_debouncedFetchProducts", h(() => {
51
58
  this.store.fetchRecommendationProducts();
52
59
  }, 500));
53
60
  /**
@@ -61,16 +68,16 @@ class Q extends g {
61
68
  * count. The store pads products to the configured size, so in-place only
62
69
  * fails when the size actually changed.
63
70
  */
64
- s(this, "_debouncedRegenerateWithProducts", h(() => {
71
+ n(this, "_debouncedRegenerateWithProducts", h(() => {
65
72
  const t = this.store.recommendationProducts;
66
- if (!this.currentNode || !this.api || D(this.currentNode))
73
+ if (!this.currentNode || !this.api || B(this.currentNode))
67
74
  return;
68
75
  const e = this.api.getDocumentModifier();
69
- E({
76
+ A({
70
77
  currentNode: this.currentNode,
71
78
  documentModifier: e,
72
79
  products: t
73
- }) || A({
80
+ }) || v({
74
81
  currentNode: this.currentNode,
75
82
  documentModifier: e,
76
83
  products: t
@@ -78,23 +85,32 @@ class Q extends g {
78
85
  }, 100));
79
86
  }
80
87
  getId() {
81
- return w;
88
+ return F;
82
89
  }
83
- 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 _(), [
90
+ /** Every sub-control the coordinator owns, in panel order. */
91
+ get _subControls() {
92
+ return [
93
+ this.layoutOrientationControl,
94
+ this.productCountControl,
85
95
  this.algorithmControl,
86
96
  this.localeControl,
87
97
  this.currencyControl,
88
- this.productCountControl,
89
98
  this.productLayoutControl,
90
99
  this.filtersControl,
91
100
  this.shuffleControl,
92
101
  this.pricePlacementControl,
93
- this.layoutOrientationControl
94
- ].forEach((e) => {
95
- e.api = this.api;
102
+ this.strategyControl
103
+ ];
104
+ }
105
+ getTemplate() {
106
+ return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
107
+ var e;
108
+ return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
109
+ }), this.algorithmControl = new I(), this.localeControl = new S(), this.currencyControl = new R(), this.productCountControl = new P(), this.productLayoutControl = new L(), this.filtersControl = new b(), this.shuffleControl = new k(), this.pricePlacementControl = new O(), this.layoutOrientationControl = new T(), this.strategyControl = new E(), this._subControls.forEach((t) => {
110
+ t && (t.api = this.api);
96
111
  }), `
97
112
  <div class="recommendation-controls-container">
113
+ ${this.strategyControl.getTemplate()}
98
114
  ${this.layoutOrientationControl.getTemplate()}
99
115
  ${this.productCountControl.getTemplate()}
100
116
  ${this.productLayoutControl.getTemplate()}
@@ -107,50 +123,43 @@ class Q extends g {
107
123
  </div>
108
124
  `;
109
125
  }
126
+ /**
127
+ * Shows the selected block's own set of controls. A block is strategy-backed
128
+ * when a flag-on session stamped its config version, or when it already
129
+ * carries a strategy — an assignment must stay editable however it arrived.
130
+ */
131
+ _showControlsForBlock(t) {
132
+ var i;
133
+ const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
134
+ if (!e || this._getRecommendationIdFromNode(t) === null)
135
+ return;
136
+ const o = m.getConfig(t), r = !!o.strategyId || this.rrsEnabled && (o.configVersion ?? 0) >= _;
137
+ e.classList.toggle("strategy-block", r);
138
+ }
110
139
  async onRender() {
111
140
  var o;
112
141
  const t = this._getRecommendationIdFromNode(this.currentNode), e = t ?? this.store.currentRecommendationId;
113
- if (e !== null && this.store.setCurrentBlock(e), t !== null && !this.syncedBlockIds.has(t) && (this.syncedBlockIds.add(t), this._syncNodeConfigToStore()), this._listenStateUpdates(), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
142
+ if (e !== null && this.store.setCurrentBlock(e), t !== null && !this.syncedBlockIds.has(t) && (this.syncedBlockIds.add(t), this._syncNodeConfigToStore()), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && ((o = this.store.blockStates[e]) != null && o.isInitialized)) {
114
143
  this._initializeSubControls();
115
144
  return;
116
145
  }
117
146
  await this._fetchBlockData(e), this._initializeSubControls();
118
147
  }
119
148
  onTemplateNodeUpdated(t) {
120
- var r;
149
+ var o;
121
150
  super.onTemplateNodeUpdated(t);
122
151
  const e = this._getRecommendationIdFromNode(t);
123
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.syncedBlockIds.has(e) && (this.syncedBlockIds.add(e), this._syncNodeConfigToStore()), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e).then(() => {
152
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && !this.syncedBlockIds.has(e) && (this.syncedBlockIds.add(e), this._syncNodeConfigToStore()), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
124
153
  this._initializeSubControls();
125
- }), [
126
- this.layoutOrientationControl,
127
- this.productCountControl,
128
- this.algorithmControl,
129
- this.localeControl,
130
- this.currencyControl,
131
- this.productLayoutControl,
132
- this.filtersControl,
133
- this.shuffleControl,
134
- this.pricePlacementControl
135
- ].forEach((n) => {
154
+ }), this._subControls.forEach((r) => {
136
155
  var i;
137
- n != null && n.api && (n.currentNode = t, (i = n.onTemplateNodeUpdated) == null || i.call(n, t));
156
+ r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
138
157
  });
139
158
  }
140
159
  onDestroy() {
141
- this.storeUnsubscription(), [
142
- this.layoutOrientationControl,
143
- this.productCountControl,
144
- this.algorithmControl,
145
- this.localeControl,
146
- this.currencyControl,
147
- this.productLayoutControl,
148
- this.filtersControl,
149
- this.shuffleControl,
150
- this.pricePlacementControl
151
- ].forEach((e) => {
152
- var o;
153
- return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
160
+ this.storeUnsubscription(), this._subControls.forEach((t) => {
161
+ var e;
162
+ return (e = t == null ? void 0 : t.onDestroy) == null ? void 0 : e.call(t);
154
163
  });
155
164
  }
156
165
  /**
@@ -158,19 +167,9 @@ class Q extends g {
158
167
  * Each sub-control manages its own form values and event listeners
159
168
  */
160
169
  _initializeSubControls() {
161
- [
162
- this.layoutOrientationControl,
163
- this.productCountControl,
164
- this.algorithmControl,
165
- this.localeControl,
166
- this.currencyControl,
167
- this.productLayoutControl,
168
- this.filtersControl,
169
- this.shuffleControl,
170
- this.pricePlacementControl
171
- ].forEach((e) => {
172
- var o;
173
- e && (e.api = this.api, e.currentNode = this.currentNode, (o = e.onRender) == null || o.call(e));
170
+ this._subControls.forEach((t) => {
171
+ var e;
172
+ t && (t.api = this.api, t.currentNode = this.currentNode, (e = t.onRender) == null || e.call(t));
174
173
  });
175
174
  }
176
175
  /**
@@ -189,6 +188,7 @@ class Q extends g {
189
188
  const t = m.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
190
189
  this.store.patchCurrentBlockConfig({
191
190
  strategy: t.strategy,
191
+ strategyId: t.strategyId,
192
192
  language: t.language,
193
193
  size: t.size,
194
194
  productIds: t.productIds,
@@ -250,35 +250,35 @@ class Q extends g {
250
250
  if (!this.currentNode || !this.api)
251
251
  return;
252
252
  const t = m.getConfig(this.currentNode), e = {};
253
- let o = null, r = null, n = null;
254
- if (t.currency.code === c.currency.code) {
255
- const { currencyList: i } = this.store;
256
- i.length > 0 && (i.some(
257
- (u) => u.value === `price.${c.currency.code}`
258
- ) || (o = i[0].value.replace("price.", ""), e.currency = {
259
- ...c.currency,
253
+ let o = null, r = null, i = null;
254
+ if (t.currency.code === a.currency.code) {
255
+ const { currencyList: s } = this.store;
256
+ s.length > 0 && (s.some(
257
+ (u) => u.value === `price.${a.currency.code}`
258
+ ) || (o = s[0].value.replace("price.", ""), e.currency = {
259
+ ...a.currency,
260
260
  code: o,
261
261
  symbol: o
262
262
  }));
263
263
  }
264
- if (t.strategy === c.strategy) {
265
- const i = this.store.getActivePredictiveAlgorithms;
266
- i.length > 0 && (i.some(
267
- (u) => u.value === c.strategy
268
- ) || (r = i[0].value, e.strategy = r));
264
+ if (t.strategy === a.strategy) {
265
+ const s = this.store.getActivePredictiveAlgorithms;
266
+ s.length > 0 && (s.some(
267
+ (u) => u.value === a.strategy
268
+ ) || (r = s[0].value, e.strategy = r));
269
269
  }
270
- if (t.language === c.language) {
271
- const i = this.store.getLanguages;
272
- i.length > 0 && (i.some(
273
- (u) => u.value === c.language
274
- ) || (n = i[0].value, e.language = n));
270
+ if (t.language === a.language) {
271
+ const s = this.store.getLanguages;
272
+ s.length > 0 && (s.some(
273
+ (u) => u.value === a.language
274
+ ) || (i = s[0].value, e.language = i));
275
275
  }
276
- !o && !r && !n || (m.updateConfig(
276
+ !o && !r && !i || (m.updateConfig(
277
277
  this.api,
278
278
  this.currentNode,
279
279
  e,
280
280
  "Applied smart defaults"
281
- ), o && e.currency && S({
281
+ ), o && e.currency && D({
282
282
  currentNode: this.currentNode,
283
283
  documentModifier: this.api.getDocumentModifier(),
284
284
  currency: e.currency
@@ -288,24 +288,24 @@ class Q extends g {
288
288
  name: o,
289
289
  value: o,
290
290
  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
291
+ alignment: a.currency.alignment === "before" ? "0" : "1",
292
+ decimalCount: a.currency.decimalCount.toString(),
293
+ decimalSeparator: a.currency.decimalSeparator,
294
+ thousandSeparator: a.currency.thousandSeparator
295
295
  }
296
296
  } : {},
297
297
  ...r ? { strategy: r } : {},
298
- ...n ? { language: n } : {}
298
+ ...i ? { language: i } : {}
299
299
  }, { triggerRefetch: !1 }));
300
300
  }
301
301
  /**
302
302
  * Reads the recommendation-id attribute from the block element within the node
303
303
  */
304
304
  _getRecommendationIdFromNode(t) {
305
- const e = k(t);
305
+ const e = w(t);
306
306
  if (!e || !("getAttribute" in e))
307
307
  return null;
308
- const o = e.getAttribute(v);
308
+ const o = e.getAttribute(x);
309
309
  if (!o)
310
310
  return null;
311
311
  const r = parseInt(o);
@@ -328,64 +328,68 @@ class Q extends g {
328
328
  const { store: t } = this;
329
329
  let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
330
330
  this.storeUnsubscription = t.$subscribe(() => {
331
- const n = t.currentRecommendationId;
332
- if (n !== r) {
333
- r = n, e = t.recommendationProducts, o = t.$state.configVersion;
331
+ const i = t.currentRecommendationId;
332
+ if (i !== r) {
333
+ r = i, e = t.recommendationProducts, o = t.$state.configVersion;
334
334
  return;
335
335
  }
336
- const i = t.$state.configVersion;
337
- 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());
336
+ const s = t.$state.configVersion;
337
+ s !== o && (o = s, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
338
+ const l = t.recommendationProducts, u = l !== e, f = Array.isArray(l) && l.length > 0;
339
+ u && f && (e = l, this._debouncedRegenerateWithProducts());
340
340
  });
341
341
  }
342
342
  /**
343
- * Persists the current filter state from Pinia store to the Stripo node config.
344
- * This ensures filters survive template save/reload cycles.
343
+ * Persists filter + strategy state to the Stripo node config so it survives
344
+ * save/reload (strategyId must reach esd-ext-config before any save).
345
+ * `size` rides along: assigning a strategy writes it to the store only, and a
346
+ * stale node config would rebuild the block against the old slot count.
345
347
  */
346
348
  _persistFiltersToNodeConfig() {
347
349
  if (!this.currentNode || !this.api)
348
350
  return;
349
- const { filters: t } = this.store.recommendationConfigs;
350
- m.updateConfig(
351
+ const { filters: t, strategyId: e, size: o } = this.store.recommendationConfigs, r = m.getConfig(this.currentNode);
352
+ JSON.stringify(r.filters) === JSON.stringify(t) && r.strategyId === e && r.size === o || m.updateConfig(
351
353
  this.api,
352
354
  this.currentNode,
353
- { filters: t },
355
+ { filters: t, strategyId: e, size: o },
354
356
  "Update recommendation filters"
355
357
  );
356
358
  }
357
359
  }
358
360
  export {
359
- tt as ALGORITHM_CONTROL_ID,
360
- N as AlgorithmControl,
361
- w as CONTROL_BLOCK_ID,
362
- ot as CURRENCY_CONTROL_ID,
361
+ it as ALGORITHM_CONTROL_ID,
362
+ I as AlgorithmControl,
363
+ F as CONTROL_BLOCK_ID,
364
+ at as CURRENCY_CONTROL_ID,
363
365
  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,
366
+ lt as FILTERS_CONTROL_ID,
367
+ b as FiltersControl,
368
+ dt as LAYOUT_ORIENTATION_CONTROL_ID,
369
+ ht as LOCALE_CONTROL_ID,
370
+ T as LayoutOrientationControl,
371
+ S as LocaleControl,
372
+ Ct as PRICE_PLACEMENT_CONTROL_ID,
373
+ pt as PRODUCT_COUNT_CONTROL_ID,
374
+ _t as PRODUCT_LAYOUT_CONTROL_ID,
375
+ O as PricePlacementControl,
374
376
  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
377
+ L as ProductLayoutControl,
378
+ ot as RecommendationBlockControl,
379
+ It as SHUFFLE_CONTROL_ID,
380
+ bt as STRATEGY_CONTROL_ID,
381
+ k as ShuffleControl,
382
+ E as StrategyControl,
383
+ St as adjustProductsToSize,
384
+ Ot as formatProductPrice,
385
+ w as getBlockElement,
386
+ Pt as getCardComposition,
387
+ Lt as getCurrentLayout,
388
+ B as isPartnerManagedBlock,
389
+ kt as regenerateMobileProductRows,
390
+ v as regenerateProductRowsWithStyles,
391
+ D as setCurrencyAttributes,
392
+ Et as updatePricesInPlace,
393
+ A as updateProductContentInPlace,
394
+ Dt as updateSingleProductContent
391
395
  };
@@ -0,0 +1,142 @@
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 {
9
+ constructor() {
10
+ super(...arguments);
11
+ o(this, "store", u());
12
+ o(this, "storeUnsubscription", () => {
13
+ });
14
+ o(this, "listeners", []);
15
+ // The store subscription fires on EVERY mutation of a store six controls
16
+ // share, so the last painted state is kept to skip the DOM work.
17
+ o(this, "lastPaintedState", null);
18
+ }
19
+ getId() {
20
+ return p;
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
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
26
+ return `
27
+ <div class="strategy-control-container">
28
+ <div class="strategy-control-header">
29
+ <h3 class="strategy-control-title">${this.api.translate("Recommendation Strategy")}</h3>
30
+ </div>
31
+ <div class="strategy-control-description-row">
32
+ <p class="strategy-control-description">
33
+ ${t}
34
+ ${e}
35
+ <a
36
+ href="${m.EMAIL_RECOMMENDATION_BLOCK}"
37
+ target="_blank"
38
+ rel="noopener noreferrer">${a}</a>.
39
+ </p>
40
+ </div>
41
+ <div data-strategy-empty-state>
42
+ ${this._GuTwoColumns([
43
+ this._GuButton({
44
+ name: "assignStrategy",
45
+ label: this.api.translate("Assign Strategy"),
46
+ id: "guido__btn-assign-strategy",
47
+ className: "strategy-control-cta on"
48
+ }),
49
+ // Create round-trip ships with SD-149916; until then the CTA
50
+ // stays inert at full contrast, as the design draws it.
51
+ this._GuButton({
52
+ name: "createStrategy",
53
+ label: this.api.translate("Create New Strategy"),
54
+ id: "guido__btn-create-strategy",
55
+ className: "strategy-control-cta primary",
56
+ disabled: !0
57
+ })
58
+ ], "strategy-control-cta-row")}
59
+ </div>
60
+ <div data-strategy-assigned-state style="display: none;">
61
+ <div class="strategy-control-name-band">
62
+ <span class="strategy-control-name" data-strategy-name></span>
63
+ </div>
64
+ <div class="strategy-control-actions">
65
+ ${this._strategyAction({
66
+ id: "guido__btn-change-strategy",
67
+ label: this.api.translate("Change"),
68
+ modifier: "change"
69
+ })}
70
+ ${this._strategyAction({
71
+ id: "guido__btn-remove-strategy",
72
+ label: this.api.translate("Remove"),
73
+ modifier: "remove"
74
+ })}
75
+ </div>
76
+ </div>
77
+ </div>
78
+ `;
79
+ }
80
+ /**
81
+ * Change / Remove are icon+text actions in the design, not buttons — and
82
+ * `ue-button` cannot pair a caption with an arbitrary icon, so these are
83
+ * plain elements. Click wiring is by id, which works on any element.
84
+ *
85
+ * The icon is a CSS mask, not inline SVG: Stripo re-creates the control's
86
+ * markup through Angular, which rebuilds `<svg>` outside the SVG namespace
87
+ * (the view-box attribute comes back lowercased) and it never paints.
88
+ */
89
+ _strategyAction({ id: t, label: e, modifier: a }) {
90
+ return `
91
+ <button
92
+ id="${t}"
93
+ type="button"
94
+ class="strategy-control-action strategy-control-action--${a}">
95
+ <span>${e}</span>
96
+ </button>
97
+ `;
98
+ }
99
+ onRender() {
100
+ this._teardown(), this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
101
+ this._renderState();
102
+ }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
103
+ });
104
+ }
105
+ onDestroy() {
106
+ this._teardown();
107
+ }
108
+ _teardown() {
109
+ this.storeUnsubscription(), this.storeUnsubscription = () => {
110
+ }, this.lastPaintedState = null, this.listeners.forEach(({ element: t, handler: e }) => t.removeEventListener("click", e)), this.listeners = [];
111
+ }
112
+ _setupButtonListeners() {
113
+ const t = this.getContainer();
114
+ if (!t)
115
+ return;
116
+ const e = (a, n) => {
117
+ const i = t.querySelector(a);
118
+ i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
119
+ };
120
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.removeStrategy());
121
+ }
122
+ /**
123
+ * Toggles empty vs assigned state from the store's current block config.
124
+ * Display name comes from the listing; falls back to the raw id while the
125
+ * listing loads (or when the strategy is no longer listed).
126
+ */
127
+ _renderState() {
128
+ var l;
129
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
130
+ if (a === this.lastPaintedState)
131
+ return;
132
+ const n = this.getContainer();
133
+ if (!n)
134
+ return;
135
+ const i = n.querySelector("[data-strategy-empty-state]"), c = n.querySelector("[data-strategy-assigned-state]"), g = n.querySelector("[data-strategy-name]");
136
+ !i || !c || (i.style.display = t ? "none" : "", c.style.display = t ? "" : "none", g && t && (g.textContent = e || `#${t}`), this.lastPaintedState = a);
137
+ }
138
+ }
139
+ export {
140
+ p as STRATEGY_CONTROL_ID,
141
+ f as StrategyControl
142
+ };