@useinsider/guido 3.17.0-beta.ec8eabb → 3.17.0-beta.edf4165

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 (61) hide show
  1. package/README.md +1 -0
  2. package/dist/@types/config/schemas.js +7 -6
  3. package/dist/components/Guido.vue.js +8 -8
  4. package/dist/components/Guido.vue2.js +100 -97
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +21 -0
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +106 -0
  7. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue.js +19 -0
  8. package/dist/components/organisms/extensions/recommendation/StrategyInfoBoxContent.vue2.js +63 -0
  9. package/dist/components/organisms/header/EditorActions.vue.js +1 -1
  10. package/dist/components/organisms/header/EditorActions.vue2.js +36 -44
  11. package/dist/composables/useActionsApi.js +67 -82
  12. package/dist/composables/useAutoSave.js +26 -31
  13. package/dist/composables/useCustomInterfaceAppearance.js +52 -38
  14. package/dist/composables/useGuidoStateBridge.js +30 -31
  15. package/dist/composables/useRecommendation.js +41 -34
  16. package/dist/composables/useSave.js +36 -40
  17. package/dist/config/migrator/recommendation/settingsMapper.js +17 -17
  18. package/dist/config/migrator/recommendationMigrator.js +5 -4
  19. package/dist/enums/academy.js +2 -1
  20. package/dist/enums/date.js +5 -3
  21. package/dist/enums/extensions/recommendationBlock.js +3 -1
  22. package/dist/extensions/Blocks/Recommendation/block.js +26 -21
  23. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +34 -34
  24. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +96 -95
  25. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +162 -166
  26. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +124 -0
  27. package/dist/extensions/Blocks/Recommendation/services/configService.js +35 -35
  28. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +165 -79
  29. package/dist/extensions/Blocks/common-control.js +22 -19
  30. package/dist/guido.css +1 -1
  31. package/dist/services/recommendationApi.js +69 -30
  32. package/dist/src/@types/config/schemas.d.ts +2 -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 +15 -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/date.d.ts +1 -0
  39. package/dist/src/enums/extensions/recommendationBlock.d.ts +2 -0
  40. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +2 -6
  41. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
  42. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +10 -4
  43. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +16 -0
  44. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +150 -10
  45. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -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/stores/save-as-template.d.ts +4 -3
  51. package/dist/src/utils/genericUtil.d.ts +5 -0
  52. package/dist/static/assets/icons/line-change.svg.js +5 -0
  53. package/dist/static/assets/icons/line-delete.svg.js +5 -0
  54. package/dist/static/assets/icons/line-plus.svg.js +5 -0
  55. package/dist/static/styles/components/recommendation-strategy.css.js +155 -0
  56. package/dist/utils/dateUtil.js +23 -10
  57. package/dist/utils/genericUtil.js +28 -27
  58. package/dist/utils/templatePreparation.js +35 -34
  59. package/package.json +2 -1
  60. package/dist/composables/useEditorLock.js +0 -18
  61. package/dist/src/composables/useEditorLock.d.ts +0 -11
@@ -1,14 +1,14 @@
1
- import { ModificationDescription as C } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
1
+ import { ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { PRE_RRS_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as c } from "../constants/defaultConfig.js";
3
3
  import { setCurrencyAttributes as D } from "../controls/main/utils.js";
4
- import { hasMinimalConfig as A } from "../types/nodeConfig.js";
5
- function S(e) {
6
- return e === "." || e === "," || e === " ";
4
+ import { hasMinimalConfig as S } from "../types/nodeConfig.js";
5
+ function A(n) {
6
+ return n === "." || n === "," || n === " ";
7
7
  }
8
- function N(e) {
9
- return e === "." || e === "," || e === " " || e === "";
8
+ function N(n) {
9
+ return n === "." || n === "," || n === " " || n === "";
10
10
  }
11
- class M {
11
+ class F {
12
12
  // ========================================================================
13
13
  // Read Operations
14
14
  // ========================================================================
@@ -48,7 +48,7 @@ class M {
48
48
  return !1;
49
49
  try {
50
50
  const t = i.getNodeConfig();
51
- return A(t);
51
+ return S(t);
52
52
  } catch {
53
53
  return !1;
54
54
  }
@@ -82,9 +82,9 @@ class M {
82
82
  * @param description - Human-readable description for undo/redo
83
83
  * @returns The new complete configuration
84
84
  */
85
- static updateConfig(i, t, o, n) {
85
+ static updateConfig(i, t, o, e) {
86
86
  const r = this.getConfig(t), u = this.deepMerge(r, o);
87
- return this.saveConfig(i, t, u, n), u;
87
+ return this.saveConfig(i, t, u, e), u;
88
88
  }
89
89
  /**
90
90
  * Initialize configuration for a new block
@@ -107,12 +107,12 @@ class M {
107
107
  static initializeConfig(i, t, o) {
108
108
  if (this.hasConfig(t))
109
109
  return { config: o ? this.updateConfig(i, t, o, "Initialize recommendation block") : this.getConfig(t), wasFreshDrop: !1 };
110
- const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
111
- return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
110
+ const e = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
111
+ return this.saveConfig(i, t, e, "Initialize recommendation block"), D({
112
112
  currentNode: t,
113
113
  documentModifier: i.getDocumentModifier(),
114
- currency: n.currency
115
- }), { config: n, wasFreshDrop: !0 };
114
+ currency: e.currency
115
+ }), { config: e, wasFreshDrop: !0 };
116
116
  }
117
117
  /**
118
118
  * Save complete configuration to a node
@@ -123,9 +123,9 @@ class M {
123
123
  * @param config - Complete configuration to save
124
124
  * @param description - Human-readable description for undo/redo
125
125
  */
126
- static saveConfig(i, t, o, n) {
126
+ static saveConfig(i, t, o, e) {
127
127
  try {
128
- i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new C(n));
128
+ i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(e));
129
129
  } catch (r) {
130
130
  console.warn("[RecommendationConfigService] Failed to save config:", r);
131
131
  }
@@ -154,33 +154,33 @@ class M {
154
154
  */
155
155
  static migrateFromDataAttributes(i, t) {
156
156
  const o = {
157
- configVersion: l
157
+ configVersion: C
158
158
  };
159
159
  if ("getAttribute" in t && typeof t.getAttribute == "function") {
160
- const n = t.getAttribute("esd-ext-config");
161
- if (n)
160
+ const e = t.getAttribute("esd-ext-config");
161
+ if (e)
162
162
  try {
163
- const s = JSON.parse(n);
164
- s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
163
+ const s = JSON.parse(e);
164
+ s && typeof s == "object" && Object.assign(o, s);
165
165
  } catch {
166
166
  }
167
167
  const r = t.getAttribute("data-layout");
168
168
  r === "list" || r === "horizontal" ? o.layout = "list" : (r === "grid" || r === "vertical") && (o.layout = "grid");
169
169
  const u = t.getAttribute("data-card-composition");
170
170
  u && (o.composition = u.split(",").filter(Boolean));
171
- const b = t.getAttribute("data-column-spacing");
172
- b && (o.columnSpacing = parseInt(b) || c.columnSpacing);
173
- const p = t.getAttribute("data-row-spacing");
174
- if (p && (o.rowSpacing = parseInt(p) || c.rowSpacing), !o.currency) {
175
- const s = t.getAttribute("currency"), y = t.getAttribute("currency-symbol"), d = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
176
- if (s || y || d || f || g || m) {
177
- const a = c.currency, h = m ? parseInt(m) : NaN;
171
+ const l = t.getAttribute("data-column-spacing");
172
+ l && (o.columnSpacing = parseInt(l) || c.columnSpacing);
173
+ const b = t.getAttribute("data-row-spacing");
174
+ if (b && (o.rowSpacing = parseInt(b) || c.rowSpacing), !o.currency) {
175
+ const s = t.getAttribute("currency"), p = t.getAttribute("currency-symbol"), y = t.getAttribute("currency-alignment"), f = t.getAttribute("currency-thousand-separator"), g = t.getAttribute("currency-decimal-separator"), m = t.getAttribute("currency-decimal-count");
176
+ if (s || p || y || f || g || m) {
177
+ const a = c.currency, d = m ? parseInt(m) : NaN;
178
178
  o.currency = {
179
179
  code: s ?? a.code,
180
- symbol: y ?? a.symbol,
181
- alignment: d === "0" ? "before" : "after",
182
- decimalCount: Number.isFinite(h) ? h : a.decimalCount,
183
- decimalSeparator: S(g) ? g : a.decimalSeparator,
180
+ symbol: p ?? a.symbol,
181
+ alignment: y === "0" ? "before" : "after",
182
+ decimalCount: Number.isFinite(d) ? d : a.decimalCount,
183
+ decimalSeparator: A(g) ? g : a.decimalSeparator,
184
184
  thousandSeparator: N(f) ? f : a.thousandSeparator
185
185
  };
186
186
  }
@@ -194,7 +194,7 @@ class M {
194
194
  * @returns True if migration is needed
195
195
  */
196
196
  static needsMigration(i) {
197
- return i ? this.hasConfig(i) ? this.getConfigVersion(i) < l : !0 : !1;
197
+ return i ? !this.hasConfig(i) : !1;
198
198
  }
199
199
  // ========================================================================
200
200
  // Internal Helpers
@@ -279,5 +279,5 @@ class M {
279
279
  }
280
280
  }
281
281
  export {
282
- M as RecommendationConfigService
282
+ F as RecommendationConfigService
283
283
  };
@@ -1,21 +1,22 @@
1
- import { getRecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as C } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as y } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as G } from "../../../../stores/config.js";
4
- import { defineStore as P } from "pinia";
1
+ import { getRecommendationFeedSourceMaps as I, getOperatorOptions as G, PriceAttributes as D } from "../../../../enums/extensions/recommendationBlock.js";
2
+ import { useRecommendationApi as P } from "../../../../services/recommendationApi.js";
3
+ import { useConfigStore as F } from "../../../../stores/config.js";
4
+ import { defineStore as v } from "pinia";
5
5
  import "../constants/selectors.js";
6
- import { DEFAULT_MOBILE_CARDS_IN_ROW as F, DEFAULT_CARDS_IN_ROW as D } from "../constants/layout.js";
7
- import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
8
- import { getDefaultProducts as S } from "../templates/utils.js";
9
- import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
10
- import { getPartnerRecommendationParams as v } from "../utils/partnerCustomizations.js";
11
- import { sanitizeProductIds as N } from "../utils/productIds.js";
12
- import { isFilterValid as x } from "../validation/filterSchema.js";
13
- import { isConfigValid as L } from "../validation/requiredFields.js";
14
- const h = y();
15
- let m = null, u = null, d = null;
16
- function k() {
6
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as _, DEFAULT_CARDS_IN_ROW as U } from "../constants/layout.js";
7
+ import { DEFAULT_NODE_CONFIG as N, EXCLUDED_ALGORITHM_IDS as L } from "../constants/defaultConfig.js";
8
+ import { getDefaultProducts as k } from "../templates/utils.js";
9
+ import { generateCompleteFilterQuery as R } from "../utils/filterUtil.js";
10
+ import { getPartnerRecommendationParams as x } from "../utils/partnerCustomizations.js";
11
+ import { sanitizeProductIds as A } from "../utils/productIds.js";
12
+ import { isFilterValid as B } from "../validation/filterSchema.js";
13
+ import { isConfigValid as z } from "../validation/requiredFields.js";
14
+ const m = P();
15
+ let f = null, g = null, h = null, S = null;
16
+ const p = /* @__PURE__ */ new Map();
17
+ function w() {
17
18
  return {
18
- cardsInRow: D,
19
+ cardsInRow: U,
19
20
  currencySettings: {
20
21
  name: "USD",
21
22
  value: "USD",
@@ -29,13 +30,14 @@ function k() {
29
30
  productIds: [],
30
31
  id: 1,
31
32
  language: "en_US",
32
- mobileCardsInRow: F,
33
+ mobileCardsInRow: _,
33
34
  mobileLayoutEnabled: !1,
34
35
  orientation: "grid",
35
36
  recommendedProducts: [],
36
37
  sendProductRequestFlag: !1,
37
38
  shuffleProducts: !1,
38
39
  strategy: "mostPopular",
40
+ strategyId: "",
39
41
  textTrimming: !0,
40
42
  unresponsive: !1,
41
43
  size: "6",
@@ -44,28 +46,32 @@ function k() {
44
46
  priceHideIfSameAsDiscounted: !1
45
47
  };
46
48
  }
47
- function I() {
49
+ function C() {
48
50
  return {
49
- recommendationConfigs: k(),
51
+ recommendationConfigs: w(),
50
52
  recommendationProducts: [],
51
53
  filterStatus: !1,
52
54
  filterSelectionDrawerStatus: !1,
55
+ assignStrategyDrawerStatus: !1,
53
56
  filterGroup: 1,
54
57
  isInitialized: !1,
55
58
  filterSnapshot: null
56
59
  };
57
60
  }
58
- const U = () => ({
61
+ const O = () => ({
59
62
  recommendationCampaignUrls: {},
60
63
  activePredictiveAlgorithms: [],
61
64
  languages: {},
62
65
  currencyList: [],
63
66
  filterList: {},
67
+ strategies: [],
68
+ strategiesLoading: !1,
69
+ strategyUrlTemplates: {},
64
70
  blockStates: {},
65
71
  currentRecommendationId: null,
66
72
  configVersion: 0
67
- }), H = P("guidoRecommendationExtension", {
68
- state: () => U(),
73
+ }), Y = v("guidoRecommendationExtension", {
74
+ state: () => O(),
69
75
  getters: {
70
76
  // ====================================================================
71
77
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -75,7 +81,7 @@ const U = () => ({
75
81
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
76
82
  */
77
83
  recommendationConfigs(t) {
78
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
84
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : w();
79
85
  },
80
86
  /**
81
87
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -89,6 +95,13 @@ const U = () => ({
89
95
  filterSelectionDrawerStatus(t) {
90
96
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
91
97
  },
98
+ assignStrategyDrawerStatus(t) {
99
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].assignStrategyDrawerStatus : !1;
100
+ },
101
+ assignedStrategy(t) {
102
+ const { strategyId: e } = this.recommendationConfigs;
103
+ return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
104
+ },
92
105
  /**
93
106
  * Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
94
107
  */
@@ -120,9 +133,9 @@ const U = () => ({
120
133
  return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
121
134
  },
122
135
  getActivePredictiveAlgorithms: (t) => {
123
- const e = g(), r = [];
124
- return t.activePredictiveAlgorithms.filter((n) => !w.includes(n)).forEach((n) => {
125
- r.push(...e.filter((c) => c.id === n));
136
+ const e = I(), r = [];
137
+ return t.activePredictiveAlgorithms.filter((n) => !L.includes(n)).forEach((n) => {
138
+ r.push(...e.filter((s) => s.id === n));
126
139
  }), r.map((n) => ({
127
140
  text: n.name,
128
141
  value: n.key
@@ -139,7 +152,7 @@ const U = () => ({
139
152
  getFilterList() {
140
153
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
141
154
  let e;
142
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : C.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
155
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : D.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
143
156
  text: t.displayName,
144
157
  value: e,
145
158
  type: t.attributeType
@@ -161,7 +174,7 @@ const U = () => ({
161
174
  setCurrentBlock(t) {
162
175
  this.blockStates[t] || (this.blockStates = {
163
176
  ...this.blockStates,
164
- [t]: I()
177
+ [t]: C()
165
178
  }), this.currentRecommendationId = t;
166
179
  },
167
180
  /**
@@ -193,10 +206,10 @@ const U = () => ({
193
206
  [e]: o
194
207
  };
195
208
  }
196
- const n = t.toString(), c = e.toString(), i = this.recommendationCampaignUrls[n];
209
+ const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
197
210
  i && (this.recommendationCampaignUrls = {
198
211
  ...this.recommendationCampaignUrls,
199
- [c]: i
212
+ [s]: i
200
213
  });
201
214
  },
202
215
  /**
@@ -221,7 +234,7 @@ const U = () => ({
221
234
  * `isInitialized`) alone.
222
235
  */
223
236
  seedBlockUrlConfig(t, e) {
224
- const r = (o, s) => o === "." || o === "," || o === " " ? o : s, n = {
237
+ const r = (o, c) => o === "." || o === "," || o === " " ? o : c, n = {
225
238
  name: e.currencyCode,
226
239
  value: e.currencyCode,
227
240
  symbol: e.currencyCode,
@@ -229,17 +242,18 @@ const U = () => ({
229
242
  decimalCount: String(e.currencyDecimalCount),
230
243
  decimalSeparator: r(e.currencyDecimalSeparator, ","),
231
244
  thousandSeparator: r(e.currencyThousandSeparator, ".")
232
- }, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
245
+ }, s = !this.blockStates[t], i = s ? C() : this.blockStates[t];
233
246
  i.recommendationConfigs = {
234
247
  ...i.recommendationConfigs,
235
248
  strategy: e.strategy,
249
+ strategyId: e.strategyId,
236
250
  language: e.language,
237
251
  size: e.size,
238
252
  productIds: e.productIds,
239
253
  filters: e.filters,
240
254
  shuffleProducts: e.shuffleProducts,
241
255
  currencySettings: n
242
- }, c && (this.blockStates = {
256
+ }, s && (this.blockStates = {
243
257
  ...this.blockStates,
244
258
  [t]: i
245
259
  });
@@ -267,7 +281,7 @@ const U = () => ({
267
281
  * Creates a filter with the first available attribute and operator pre-selected.
268
282
  */
269
283
  createDefaultFilter(t, e) {
270
- const [r] = this.getFilterList, [n] = R(r == null ? void 0 : r.type);
284
+ const [r] = this.getFilterList, [n] = G(r == null ? void 0 : r.type);
271
285
  return {
272
286
  type: "standardFilter",
273
287
  attribute: (r == null ? void 0 : r.value) ?? "",
@@ -314,21 +328,65 @@ const U = () => ({
314
328
  const t = this.blockStates[this.currentRecommendationId];
315
329
  t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
316
330
  },
331
+ openAssignStrategyDrawer() {
332
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !0);
333
+ },
334
+ closeAssignStrategyDrawer() {
335
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].assignStrategyDrawerStatus = !1);
336
+ },
337
+ async fetchStrategies() {
338
+ if (S) {
339
+ await S;
340
+ return;
341
+ }
342
+ S = (async () => {
343
+ this.strategiesLoading = !0;
344
+ try {
345
+ this.strategies = await m.fetchRecommendationStrategies();
346
+ } finally {
347
+ this.strategiesLoading = !1;
348
+ }
349
+ })();
350
+ try {
351
+ await S;
352
+ } finally {
353
+ S = null;
354
+ }
355
+ },
356
+ async resolveStrategyUrlTemplate(t, e) {
357
+ const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
358
+ if (s)
359
+ return s;
360
+ const { full_path: i = "" } = await m.generateStrategyEndpoint(t, e) ?? {};
361
+ return n && i && (this.strategyUrlTemplates = {
362
+ ...this.strategyUrlTemplates,
363
+ [n]: i
364
+ }), i;
365
+ },
366
+ assignStrategy(t) {
367
+ this.patchCurrentBlockConfig({
368
+ strategyId: String(t.strategy_id),
369
+ ...t.size !== void 0 ? { size: String(t.size) } : {}
370
+ });
371
+ },
372
+ removeStrategy() {
373
+ this.patchCurrentBlockConfig({ strategyId: "", size: N.size });
374
+ },
317
375
  // ====================================================================
318
376
  // Shared Data Fetching (fetched once, used by all blocks)
319
377
  // ====================================================================
320
378
  async fetchRecommendationCreateData() {
321
379
  if (!this.activePredictiveAlgorithms.length) {
322
- if (m) {
323
- await m;
380
+ if (f) {
381
+ await f;
324
382
  return;
325
383
  }
326
- m = (async () => {
384
+ f = (async () => {
327
385
  const {
328
386
  activePredictiveAlgorithms: t,
329
387
  languages: e,
330
388
  currencies: r
331
- } = await h.fetchRecommendationCreateData();
389
+ } = await m.fetchRecommendationCreateData();
332
390
  if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
333
391
  const n = this.blockStates[this.currentRecommendationId];
334
392
  n.filterStatus = !!n.recommendationConfigs.filters.length;
@@ -336,26 +394,26 @@ const U = () => ({
336
394
  this.currencyList = r;
337
395
  })();
338
396
  try {
339
- await m;
397
+ await f;
340
398
  } finally {
341
- m = null;
399
+ f = null;
342
400
  }
343
401
  }
344
402
  },
345
403
  async fetchRecommendationFilters() {
346
404
  if (!Object.keys(this.filterList).length) {
347
- if (u) {
348
- await u;
405
+ if (g) {
406
+ await g;
349
407
  return;
350
408
  }
351
- u = (async () => {
352
- const t = await h.fetchRecommendationFilters();
409
+ g = (async () => {
410
+ const t = await m.fetchRecommendationFilters();
353
411
  this.filterList = t;
354
412
  })();
355
413
  try {
356
- await u;
414
+ await g;
357
415
  } finally {
358
- u = null;
416
+ g = null;
359
417
  }
360
418
  }
361
419
  },
@@ -370,10 +428,10 @@ const U = () => ({
370
428
  deleteFilterGroup(t) {
371
429
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
372
430
  return;
373
- const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(r.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
431
+ const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(r.map((i) => i.filterGroup))].sort((i, o) => i - o), s = new Map(n.map((i, o) => [i, o + 1]));
374
432
  e.recommendationConfigs.filters = r.map((i) => ({
375
433
  ...i,
376
- filterGroup: c.get(i.filterGroup) ?? i.filterGroup
434
+ filterGroup: s.get(i.filterGroup) ?? i.filterGroup
377
435
  }));
378
436
  },
379
437
  updateFilter(t) {
@@ -384,7 +442,7 @@ const U = () => ({
384
442
  const n = [...e.recommendationConfigs.filters];
385
443
  n[r] = {
386
444
  ...t,
387
- isValid: x(t)
445
+ isValid: B(t)
388
446
  }, e.recommendationConfigs.filters = n;
389
447
  }
390
448
  },
@@ -398,10 +456,10 @@ const U = () => ({
398
456
  let i = 1;
399
457
  n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
400
458
  } else {
401
- const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
402
- n = n.map((s) => ({
403
- ...s,
404
- filterGroup: o.get(s.filterGroup) ?? s.filterGroup
459
+ const i = [...new Set(n.map((c) => c.filterGroup))].sort((c, a) => c - a), o = new Map(i.map((c, a) => [c, a + 1]));
460
+ n = n.map((c) => ({
461
+ ...c,
462
+ filterGroup: o.get(c.filterGroup) ?? c.filterGroup
405
463
  }));
406
464
  }
407
465
  e.recommendationConfigs.filters = n;
@@ -410,19 +468,19 @@ const U = () => ({
410
468
  addFilter(t) {
411
469
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
412
470
  return;
413
- const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], c = r.filter(
471
+ const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
414
472
  (o) => o.filterGroup === t.filterGroup
415
473
  ).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
416
474
  i !== -1 ? r.splice(i + 1, 0, {
417
475
  ...t,
418
- filterNumber: c
476
+ filterNumber: s
419
477
  }) : r.push({
420
478
  ...t,
421
- filterNumber: c
479
+ filterNumber: s
422
480
  }), e.recommendationConfigs.filters = r;
423
481
  },
424
482
  generateFilterQuery() {
425
- return b(this.recommendationConfigs.filters);
483
+ return R(this.recommendationConfigs.filters);
426
484
  },
427
485
  /**
428
486
  * Validation-only check invoked at save-CTA time. Defined as an action
@@ -430,55 +488,83 @@ const U = () => ({
430
488
  * every block's recommendationConfigs across user edits.
431
489
  */
432
490
  hasInvalidBlock() {
433
- return Object.values(this.blockStates).some((t) => !L(t.recommendationConfigs, this));
491
+ return Object.values(this.blockStates).some((t) => !z(t.recommendationConfigs, this));
434
492
  },
435
493
  // ====================================================================
436
494
  // Per-Block Product Fetching
437
495
  // ====================================================================
438
496
  async fetchRecommendationProducts() {
439
497
  if (!(this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])) {
440
- if (d) {
441
- await d;
498
+ if (h) {
499
+ await h;
442
500
  return;
443
501
  }
444
- d = this._doFetchProducts();
502
+ h = this._doFetchProducts();
445
503
  try {
446
- await d;
504
+ await h;
447
505
  } finally {
448
- d = null;
506
+ h = null;
449
507
  }
450
508
  }
451
509
  },
452
510
  async _doFetchProducts() {
453
- var p;
454
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p = g().find((l) => l.key === r.strategy)) == null ? void 0 : p.path) || "", o = G(), s = parseInt(r.size) || 6, a = {
511
+ var d;
512
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = F();
513
+ if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
514
+ await this._doFetchStrategyProducts(t);
515
+ return;
516
+ }
517
+ const s = r.filters.filter((u) => u.isValid), i = R(s), o = ((d = I().find((u) => u.key === r.strategy)) == null ? void 0 : d.path) || "", c = parseInt(r.size) || 6, a = {
455
518
  locale: r.language,
456
519
  currency: r.currencySettings.value,
457
- partnerName: o.partnerName,
520
+ partnerName: n.partnerName,
458
521
  size: r.size,
459
522
  details: !0,
460
- campaignId: o.variationId
523
+ campaignId: n.variationId
461
524
  };
462
- r.strategy === "manualMerchandising" ? a.productId = N(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0), Object.assign(
525
+ r.strategy === "manualMerchandising" ? a.productId = A(r.productIds) : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), i && (a.filter = i), r.shuffleProducts && (a.shuffle = !0), Object.assign(
463
526
  a,
464
- v(o.partnerName, r.strategy)
527
+ x(n.partnerName, r.strategy)
465
528
  );
466
- let f;
529
+ let l;
467
530
  try {
468
- f = await h.fetchRecommendationProducts(i, a);
531
+ l = await m.fetchRecommendationProducts(o, a);
469
532
  } catch {
470
- f = [];
533
+ l = [];
471
534
  }
472
- if (this.blockStates[t]) {
473
- const l = f.length > 0 ? f : S(s);
474
- l.length < s ? this.blockStates[t].recommendationProducts = [
475
- ...l,
476
- ...S(s - l.length)
477
- ] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
535
+ this._setBlockProducts(t, l, c);
536
+ },
537
+ async _doFetchStrategyProducts(t) {
538
+ const e = (p.get(t) ?? 0) + 1;
539
+ p.set(t, e);
540
+ const { recommendationConfigs: r } = this.blockStates[t];
541
+ let n = [], s = parseInt(r.size) || 6;
542
+ try {
543
+ await this.fetchStrategies();
544
+ const i = this.strategies.find(
545
+ (o) => String(o.strategy_id) === r.strategyId
546
+ );
547
+ if (i) {
548
+ s = parseInt(String(i.size ?? "")) || s;
549
+ const o = r.currencySettings.value, a = (await this.resolveStrategyUrlTemplate(i, o)).replaceAll("{locale}", r.language).replaceAll("{currency}", o), l = a.indexOf("?"), d = l === -1 ? a : a.slice(0, l), u = (l === -1 ? "" : a.slice(l + 1)).split("&").filter((b) => b && !b.startsWith("user_id=")), y = u.length ? `${d}?${u.join("&")}` : d;
550
+ y && (n = await m.fetchRecommendationProductsByUrl(y));
551
+ }
552
+ } catch {
553
+ n = [];
478
554
  }
555
+ p.get(t) === e && this._setBlockProducts(t, n, s);
556
+ },
557
+ _setBlockProducts(t, e, r) {
558
+ if (!this.blockStates[t])
559
+ return;
560
+ const n = e.length > 0 ? e : k(r);
561
+ this.blockStates[t].recommendationProducts = [
562
+ ...n.slice(0, r),
563
+ ...k(Math.max(0, r - n.length))
564
+ ];
479
565
  }
480
566
  }
481
567
  });
482
568
  export {
483
- H as useRecommendationExtensionStore
569
+ Y as useRecommendationExtensionStore
484
570
  };