@useinsider/guido 3.20.1-beta.2c8da49 → 3.20.1-beta.2d09f29

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 (72) hide show
  1. package/dist/composables/useActionsApi.js +64 -80
  2. package/dist/composables/useFullStoryBridge.js +10 -9
  3. package/dist/composables/useGuidoStateBridge.js +3 -3
  4. package/dist/composables/useLegacyStrategyConversion.js +16 -16
  5. package/dist/composables/useStripo.js +10 -11
  6. package/dist/config/migrator/fullStoryScriptMigrator.js +5 -0
  7. package/dist/config/migrator/index.js +11 -10
  8. package/dist/extensions/Blocks/Items/block.js +42 -43
  9. package/dist/extensions/Blocks/Recommendation/block.js +29 -33
  10. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +83 -78
  11. package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +2 -1
  12. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +12 -2
  13. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +86 -104
  14. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +263 -348
  15. package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +50 -48
  16. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +21 -16
  17. package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +40 -44
  18. package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +19 -14
  19. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +102 -104
  20. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +23 -18
  21. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +286 -312
  22. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +20 -24
  23. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +7 -6
  24. package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +8 -8
  25. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +151 -113
  26. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +205 -219
  27. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +1 -1
  28. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +40 -111
  29. package/dist/extensions/Blocks/Recommendation/utils/strategyCommit.js +35 -31
  30. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +192 -271
  31. package/dist/package.json.js +1 -1
  32. package/dist/src/composables/useActionsApi.d.ts +1 -5
  33. package/dist/src/config/migrator/fullStoryScriptMigrator.d.ts +1 -0
  34. package/dist/src/extensions/Blocks/Checkbox/controls/blockBackground/index.d.ts +0 -1
  35. package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +0 -8
  36. package/dist/src/extensions/Blocks/Items/controls/index.d.ts +0 -40
  37. package/dist/src/extensions/Blocks/RadioButton/controls/blockBackground/index.d.ts +0 -1
  38. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -1
  39. package/dist/src/extensions/Blocks/Recommendation/controls/blockBackground/index.d.ts +0 -1
  40. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -11
  41. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +6 -3
  42. package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +0 -7
  43. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -2
  44. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +5 -5
  45. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +12 -21
  46. package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +3 -6
  47. package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +5 -6
  48. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +3 -6
  49. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +9 -21
  50. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +13 -19
  51. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -7
  52. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -7
  53. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -7
  54. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -7
  55. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -7
  56. package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +8 -10
  57. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +5 -9
  58. package/dist/src/extensions/Blocks/Recommendation/controls/title/index.d.ts +0 -7
  59. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -8
  60. package/dist/src/extensions/Blocks/Recommendation/utils/nodeConfigWriter.d.ts +11 -18
  61. package/dist/src/extensions/Blocks/_Boilerplate/controls/blockBackground/index.d.ts +0 -1
  62. package/dist/src/extensions/Blocks/controlFactories.d.ts +0 -22
  63. package/dist/src/stores/editor.d.ts +1 -3
  64. package/dist/src/utils/fullStoryScripts.d.ts +6 -0
  65. package/dist/static/styles/components/button.css.js +0 -5
  66. package/dist/stores/editor.js +0 -5
  67. package/dist/utils/fullStoryScripts.js +8 -0
  68. package/package.json +3 -3
  69. package/dist/extensions/Blocks/Recommendation/utils/blockRefresh.js +0 -28
  70. package/dist/extensions/Blocks/Recommendation/utils/currencySettings.js +0 -25
  71. package/dist/src/extensions/Blocks/Recommendation/utils/blockRefresh.d.ts +0 -17
  72. package/dist/src/extensions/Blocks/Recommendation/utils/currencySettings.d.ts +0 -6
@@ -1,33 +1,31 @@
1
- import { useToaster as L } from "../../../../composables/useToaster.js";
2
- import { useTranslations as U } from "../../../../composables/useTranslations.js";
3
- import { getRecommendationFeedSourceMaps as F, strategyEditPath as z, strategyCreatePath as B, getOperatorOptions as M, PriceAttributes as N } from "../../../../enums/extensions/recommendationBlock.js";
4
- import { ToasterTypeOptions as E } from "../../../../enums/toaster.js";
5
- import { useRecommendationApi as O } from "../../../../services/recommendationApi.js";
1
+ import { useToaster as U } from "../../../../composables/useToaster.js";
2
+ import { useTranslations as M } from "../../../../composables/useTranslations.js";
3
+ import { getRecommendationFeedSourceMaps as w, strategyEditPath as N, strategyCreatePath as B, getOperatorOptions as z, PriceAttributes as E } from "../../../../enums/extensions/recommendationBlock.js";
4
+ import { ToasterTypeOptions as O } from "../../../../enums/toaster.js";
5
+ import { useRecommendationApi as A } from "../../../../services/recommendationApi.js";
6
6
  import { useConfigStore as R } from "../../../../stores/config.js";
7
- import { defineStore as V } from "pinia";
7
+ import { defineStore as x } from "pinia";
8
8
  import "../constants/selectors.js";
9
- import { DEFAULT_MOBILE_CARDS_IN_ROW as A, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
10
- import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as T, EXCLUDED_ALGORITHM_IDS as j } from "../constants/defaultConfig.js";
11
- import { getDefaultProducts as w } from "../templates/utils.js";
12
- import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
13
- import { isLegacyStrategyConfig as $ } from "../utils/legacyStrategyMigration.js";
14
- import { getPartnerRecommendationParams as q } from "../utils/partnerCustomizations.js";
15
- import { sanitizeProductIds as K } from "../utils/productIds.js";
16
- import { isFilterValid as H } from "../validation/filterSchema.js";
17
- import { getInvalidFields as J, isConfigValid as Q } from "../validation/requiredFields.js";
18
- const m = O();
19
- let p = null, y = null;
20
- const I = /* @__PURE__ */ new Map();
21
- let k = null, b = 0;
22
- const u = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map();
23
- function W(t) {
24
- const e = _.get(t);
25
- return e && e.token === u.get(t) ? e.outcome : !1;
9
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as T, DEFAULT_CARDS_IN_ROW as V } from "../constants/layout.js";
10
+ import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as j, EXCLUDED_ALGORITHM_IDS as $ } from "../constants/defaultConfig.js";
11
+ import { getDefaultProducts as P } from "../templates/utils.js";
12
+ import { generateCompleteFilterQuery as G } from "../utils/filterUtil.js";
13
+ import { isLegacyStrategyConfig as q } from "../utils/legacyStrategyMigration.js";
14
+ import { getPartnerRecommendationParams as K } from "../utils/partnerCustomizations.js";
15
+ import { sanitizeProductIds as H } from "../utils/productIds.js";
16
+ import { isFilterValid as J } from "../validation/filterSchema.js";
17
+ import { getInvalidFields as Q, isConfigValid as W } from "../validation/requiredFields.js";
18
+ const u = A();
19
+ let S = null, y = null, p = null, I = "", k = null, b = 0;
20
+ const m = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map();
21
+ function X(t) {
22
+ const e = D.get(t);
23
+ return e && e.token === m.get(t) ? e.outcome : !1;
26
24
  }
27
25
  let l = null;
28
- function D() {
26
+ function L() {
29
27
  return {
30
- cardsInRow: x,
28
+ cardsInRow: V,
31
29
  currencySettings: {
32
30
  name: "USD",
33
31
  value: "USD",
@@ -41,7 +39,7 @@ function D() {
41
39
  productIds: [],
42
40
  id: 1,
43
41
  language: "en_US",
44
- mobileCardsInRow: A,
42
+ mobileCardsInRow: T,
45
43
  mobileLayoutEnabled: !1,
46
44
  orientation: "grid",
47
45
  recommendedProducts: [],
@@ -62,9 +60,9 @@ function D() {
62
60
  priceHideIfSameAsDiscounted: !1
63
61
  };
64
62
  }
65
- function G() {
63
+ function _() {
66
64
  return {
67
- recommendationConfigs: D(),
65
+ recommendationConfigs: L(),
68
66
  recommendationProducts: [],
69
67
  filterStatus: !1,
70
68
  filterSelectionDrawerStatus: !1,
@@ -75,12 +73,10 @@ function G() {
75
73
  isInitialized: !1,
76
74
  filterSnapshot: null,
77
75
  syncedConfigFingerprint: null,
78
- legacyConversionLoading: !1,
79
- configVersion: 0,
80
- adoptedSizeVersion: 0
76
+ legacyConversionLoading: !1
81
77
  };
82
78
  }
83
- const X = () => ({
79
+ const Y = () => ({
84
80
  recommendationCampaignUrls: {},
85
81
  activePredictiveAlgorithms: [],
86
82
  languages: {},
@@ -95,8 +91,8 @@ const X = () => ({
95
91
  currentRecommendationId: null,
96
92
  strategyPanelOpen: !1,
97
93
  configVersion: 0
98
- }), ht = V("guidoRecommendationExtension", {
99
- state: () => X(),
94
+ }), St = x("guidoRecommendationExtension", {
95
+ state: () => Y(),
100
96
  getters: {
101
97
  // ====================================================================
102
98
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -106,7 +102,7 @@ const X = () => ({
106
102
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
107
103
  */
108
104
  recommendationConfigs(t) {
109
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : D();
105
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : L();
110
106
  },
111
107
  /**
112
108
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -127,7 +123,7 @@ const X = () => ({
127
123
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
128
124
  },
129
125
  isLegacyStrategyBlock() {
130
- return R().isFeatureEnabled("reusableRecommendationStrategy") && $(this.recommendationConfigs);
126
+ return R().isFeatureEnabled("reusableRecommendationStrategy") && q(this.recommendationConfigs);
131
127
  },
132
128
  legacyConversionLoading(t) {
133
129
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
@@ -137,7 +133,7 @@ const X = () => ({
137
133
  },
138
134
  assignedStrategy(t) {
139
135
  const { strategyId: e } = this.recommendationConfigs;
140
- return e ? t.strategies.find((n) => String(n.strategy_id) === e) ?? null : null;
136
+ return e ? t.strategies.find((r) => String(r.strategy_id) === e) ?? null : null;
141
137
  },
142
138
  /**
143
139
  * Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
@@ -167,19 +163,19 @@ const X = () => ({
167
163
  },
168
164
  getUniqueFilterGroups() {
169
165
  const { filters: t } = this.recommendationConfigs;
170
- return [...new Set(t.map((e) => e.filterGroup))].sort((e, n) => e - n);
166
+ return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
171
167
  },
172
168
  getActivePredictiveAlgorithms: (t) => {
173
- const e = F(), n = [];
174
- return t.activePredictiveAlgorithms.filter((r) => !j.includes(r)).forEach((r) => {
175
- n.push(...e.filter((o) => o.id === r));
176
- }), n.map((r) => ({
177
- text: r.name,
178
- value: r.key
169
+ const e = w(), r = [];
170
+ return t.activePredictiveAlgorithms.filter((n) => !$.includes(n)).forEach((n) => {
171
+ r.push(...e.filter((s) => s.id === n));
172
+ }), r.map((n) => ({
173
+ text: n.name,
174
+ value: n.key
179
175
  }));
180
176
  },
181
- getLanguages: (t) => Object.entries(t.languages).map(([e, n]) => ({
182
- text: n,
177
+ getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
178
+ text: r,
183
179
  value: e
184
180
  })),
185
181
  getCurrencySymbolList: (t) => t.currencyList.map((e) => ({
@@ -189,7 +185,7 @@ const X = () => ({
189
185
  getFilterList() {
190
186
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
191
187
  let e;
192
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : N.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
188
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : E.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
193
189
  text: t.displayName,
194
190
  value: e,
195
191
  type: t.attributeType
@@ -211,7 +207,7 @@ const X = () => ({
211
207
  setCurrentBlock(t) {
212
208
  this.blockStates[t] || (this.blockStates = {
213
209
  ...this.blockStates,
214
- [t]: G()
210
+ [t]: _()
215
211
  }), this.currentRecommendationId = t;
216
212
  },
217
213
  /**
@@ -221,13 +217,13 @@ const X = () => ({
221
217
  removeBlockState(t) {
222
218
  const e = t.toString();
223
219
  if (this.recommendationCampaignUrls[e]) {
224
- const r = { ...this.recommendationCampaignUrls };
225
- delete r[e], this.recommendationCampaignUrls = r;
220
+ const n = { ...this.recommendationCampaignUrls };
221
+ delete n[e], this.recommendationCampaignUrls = n;
226
222
  }
227
- const n = { ...this.blockStates };
228
- if (delete n[t], this.blockStates = n, this.currentRecommendationId === t) {
229
- const r = Object.keys(this.blockStates).map(Number);
230
- this.currentRecommendationId = r.length > 0 ? r[0] : null;
223
+ const r = { ...this.blockStates };
224
+ if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
225
+ const n = Object.keys(this.blockStates).map(Number);
226
+ this.currentRecommendationId = n.length > 0 ? n[0] : null;
231
227
  }
232
228
  },
233
229
  /**
@@ -239,18 +235,18 @@ const X = () => ({
239
235
  * (SD-149916).
240
236
  */
241
237
  cloneBlockState(t, e) {
242
- const n = this.blockStates[t];
243
- if (n) {
244
- const s = structuredClone(n);
245
- s.recommendationConfigs.id = e, s.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (s.isInitialized = !1, s.syncedConfigFingerprint = null), this.blockStates = {
238
+ const r = this.blockStates[t];
239
+ if (r) {
240
+ const o = structuredClone(r);
241
+ o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
246
242
  ...this.blockStates,
247
- [e]: s
243
+ [e]: o
248
244
  };
249
245
  }
250
- const r = t.toString(), o = e.toString(), i = this.recommendationCampaignUrls[r];
246
+ const n = t.toString(), s = e.toString(), i = this.recommendationCampaignUrls[n];
251
247
  i && (this.recommendationCampaignUrls = {
252
248
  ...this.recommendationCampaignUrls,
253
- [o]: i
249
+ [s]: i
254
250
  });
255
251
  },
256
252
  /**
@@ -275,15 +271,15 @@ const X = () => ({
275
271
  * `isInitialized`) alone.
276
272
  */
277
273
  seedBlockUrlConfig(t, e) {
278
- const n = (s, a) => s === "." || s === "," || s === " " ? s : a, r = {
274
+ const r = (o, a) => o === "." || o === "," || o === " " ? o : a, n = {
279
275
  name: e.currencyCode,
280
276
  value: e.currencyCode,
281
277
  symbol: e.currencySymbol,
282
278
  alignment: e.currencyAlignment === "before" ? "0" : "1",
283
279
  decimalCount: String(e.currencyDecimalCount),
284
- decimalSeparator: n(e.currencyDecimalSeparator, ","),
285
- thousandSeparator: n(e.currencyThousandSeparator, ".")
286
- }, o = !this.blockStates[t], i = o ? G() : this.blockStates[t];
280
+ decimalSeparator: r(e.currencyDecimalSeparator, ","),
281
+ thousandSeparator: r(e.currencyThousandSeparator, ".")
282
+ }, s = !this.blockStates[t], i = s ? _() : this.blockStates[t];
287
283
  i.recommendationConfigs = {
288
284
  ...i.recommendationConfigs,
289
285
  strategy: e.strategy,
@@ -293,8 +289,8 @@ const X = () => ({
293
289
  productIds: e.productIds,
294
290
  filters: e.filters,
295
291
  shuffleProducts: e.shuffleProducts,
296
- currencySettings: r
297
- }, o && (this.blockStates = {
292
+ currencySettings: n
293
+ }, s && (this.blockStates = {
298
294
  ...this.blockStates,
299
295
  [t]: i
300
296
  });
@@ -306,27 +302,27 @@ const X = () => ({
306
302
  patchCurrentBlockConfig(t, e = {}) {
307
303
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
308
304
  return;
309
- const n = this.blockStates[this.currentRecommendationId];
310
- n.recommendationConfigs = {
311
- ...n.recommendationConfigs,
305
+ const r = this.blockStates[this.currentRecommendationId];
306
+ r.recommendationConfigs = {
307
+ ...r.recommendationConfigs,
312
308
  ...t,
313
309
  currencySettings: {
314
- ...n.recommendationConfigs.currencySettings,
310
+ ...r.recommendationConfigs.currencySettings,
315
311
  ...t.currencySettings || {}
316
312
  }
317
313
  };
318
- const { triggerRefetch: r = !0 } = e;
319
- r && (n.configVersion++, this.configVersion++);
314
+ const { triggerRefetch: n = !0 } = e;
315
+ n && this.configVersion++;
320
316
  },
321
317
  /**
322
318
  * Creates a filter with the first available attribute and operator pre-selected.
323
319
  */
324
320
  createDefaultFilter(t, e) {
325
- const [n] = this.getFilterList, [r] = M(n == null ? void 0 : n.type);
321
+ const [r] = this.getFilterList, [n] = z(r == null ? void 0 : r.type);
326
322
  return {
327
323
  type: "standardFilter",
328
- attribute: (n == null ? void 0 : n.value) ?? "",
329
- operator: (r == null ? void 0 : r.value) ?? "",
324
+ attribute: (r == null ? void 0 : r.value) ?? "",
325
+ operator: (n == null ? void 0 : n.value) ?? "",
330
326
  innerGroupOperator: "*",
331
327
  outerGroupOperator: "*",
332
328
  filterNumber: e,
@@ -398,10 +394,10 @@ const X = () => ({
398
394
  const t = b, e = (async () => {
399
395
  this.strategiesLoading = !0;
400
396
  try {
401
- const n = await m.fetchRecommendationStrategies();
397
+ const r = await u.fetchRecommendationStrategies();
402
398
  if (t !== b)
403
399
  return;
404
- this.strategies = n, this.strategiesFetched = !0;
400
+ this.strategies = r, this.strategiesFetched = !0;
405
401
  } finally {
406
402
  this.strategiesLoading = !1, t === b && (this.strategiesSettled = !0);
407
403
  }
@@ -442,20 +438,20 @@ const X = () => ({
442
438
  _armStrategyPageReturn(t) {
443
439
  const e = window.open(t, "_blank");
444
440
  if (!e)
445
- return L().showToaster({
446
- type: E.Error,
447
- message: U()("discovery-strategy.error-description")
441
+ return U().showToaster({
442
+ type: O.Error,
443
+ message: M()("discovery-strategy.error-description")
448
444
  }), !1;
449
445
  e.opener = null, l == null || l();
450
- let n = !1;
451
- const r = () => {
452
- document.hidden || n || (e != null && e.closed && (l == null || l()), n = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
446
+ let r = !1;
447
+ const n = () => {
448
+ document.hidden || r || (e != null && e.closed && (l == null || l()), r = !0, this.invalidateStrategies(), this.fetchStrategies().then(() => this._refreshAssignedStrategyProducts()).catch(() => {
453
449
  }).finally(() => {
454
- n = !1;
450
+ r = !1;
455
451
  }));
456
452
  };
457
- return document.addEventListener("visibilitychange", r), l = () => {
458
- document.removeEventListener("visibilitychange", r), l = null;
453
+ return document.addEventListener("visibilitychange", n), l = () => {
454
+ document.removeEventListener("visibilitychange", n), l = null;
459
455
  }, !0;
460
456
  },
461
457
  /**
@@ -486,16 +482,16 @@ const X = () => ({
486
482
  * edited configuration.
487
483
  */
488
484
  openStrategyEdit(t) {
489
- return this._armStrategyPageReturn(z(t));
485
+ return this._armStrategyPageReturn(N(t));
490
486
  },
491
487
  async resolveStrategyUrlTemplate(t, e) {
492
- const n = typeof t.updated_at == "string" ? t.updated_at : "", r = n ? `${t.strategy_id}:${n}:${e}` : "", o = r ? this.strategyUrlTemplates[r] : void 0;
493
- if (o)
494
- return o;
495
- const { full_path: i = "" } = await m.generateStrategyEndpoint(t, e) ?? {};
496
- return r && i && (this.strategyUrlTemplates = {
488
+ const r = typeof t.updated_at == "string" ? t.updated_at : "", n = r ? `${t.strategy_id}:${r}:${e}` : "", s = n ? this.strategyUrlTemplates[n] : void 0;
489
+ if (s)
490
+ return s;
491
+ const { full_path: i = "" } = await u.generateStrategyEndpoint(t, e) ?? {};
492
+ return n && i && (this.strategyUrlTemplates = {
497
493
  ...this.strategyUrlTemplates,
498
- [r]: i
494
+ [n]: i
499
495
  }), i;
500
496
  },
501
497
  assignStrategy(t) {
@@ -505,27 +501,27 @@ const X = () => ({
505
501
  });
506
502
  },
507
503
  async convertLegacyStrategy(t, e = { scope: "campaign" }) {
508
- const n = this.currentRecommendationId;
509
- if (n === null || !this.blockStates[n])
504
+ const r = this.currentRecommendationId;
505
+ if (r === null || !this.blockStates[r])
510
506
  throw new Error("[Guido] convertLegacyStrategy called without an active block");
511
- this.blockStates[n].legacyConversionLoading = !0;
507
+ this.blockStates[r].legacyConversionLoading = !0;
512
508
  try {
513
- const r = await m.migrateLegacyStrategy(t, e);
509
+ const n = await u.migrateLegacyStrategy(t, e);
514
510
  this.invalidateStrategies();
515
511
  try {
516
512
  await this.fetchStrategies();
517
- } catch (s) {
518
- console.error("[Guido] strategy listing refresh after conversion failed", s);
513
+ } catch (o) {
514
+ console.error("[Guido] strategy listing refresh after conversion failed", o);
519
515
  }
520
- const o = this.strategies.find((s) => String(s.strategy_id) === r), i = this.blockStates[n];
516
+ const s = this.strategies.find((o) => String(o.strategy_id) === n), i = this.blockStates[r];
521
517
  return i && (i.recommendationConfigs = {
522
518
  ...i.recommendationConfigs,
523
- strategyId: r,
519
+ strategyId: n,
524
520
  nodeConfigVersion: C,
525
- ...(o == null ? void 0 : o.size) !== void 0 ? { size: String(o.size) } : {}
526
- }, i.configVersion++), this.currentRecommendationId === n && this.configVersion++, r;
521
+ ...(s == null ? void 0 : s.size) !== void 0 ? { size: String(s.size) } : {}
522
+ }), this.currentRecommendationId === r && this.configVersion++, n;
527
523
  } finally {
528
- this.blockStates[n] && (this.blockStates[n].legacyConversionLoading = !1);
524
+ this.blockStates[r] && (this.blockStates[r].legacyConversionLoading = !1);
529
525
  }
530
526
  },
531
527
  /**
@@ -534,14 +530,14 @@ const X = () => ({
534
530
  * the document never received.
535
531
  */
536
532
  revertLegacyConversion(t, e) {
537
- const n = this.blockStates[t];
538
- n && (n.recommendationConfigs = { ...n.recommendationConfigs, ...e }, n.configVersion++, this.currentRecommendationId === t && this.configVersion++);
533
+ const r = this.blockStates[t];
534
+ r && (r.recommendationConfigs = { ...r.recommendationConfigs, ...e }, this.currentRecommendationId === t && this.configVersion++);
539
535
  },
540
536
  removeStrategy() {
541
537
  this.patchCurrentBlockConfig({
542
538
  strategyId: "",
543
539
  strategy: "",
544
- size: T.size,
540
+ size: j.size,
545
541
  nodeConfigVersion: C
546
542
  });
547
543
  },
@@ -550,26 +546,26 @@ const X = () => ({
550
546
  // ====================================================================
551
547
  async fetchRecommendationCreateData() {
552
548
  if (!this.activePredictiveAlgorithms.length) {
553
- if (p) {
554
- await p;
549
+ if (S) {
550
+ await S;
555
551
  return;
556
552
  }
557
- p = (async () => {
553
+ S = (async () => {
558
554
  const {
559
555
  activePredictiveAlgorithms: t,
560
556
  languages: e,
561
- currencies: n
562
- } = await m.fetchRecommendationCreateData();
557
+ currencies: r
558
+ } = await u.fetchRecommendationCreateData();
563
559
  if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
564
- const r = this.blockStates[this.currentRecommendationId];
565
- r.filterStatus = !!r.recommendationConfigs.filters.length;
560
+ const n = this.blockStates[this.currentRecommendationId];
561
+ n.filterStatus = !!n.recommendationConfigs.filters.length;
566
562
  }
567
- this.currencyList = n;
563
+ this.currencyList = r;
568
564
  })();
569
565
  try {
570
- await p;
566
+ await S;
571
567
  } finally {
572
- p = null;
568
+ S = null;
573
569
  }
574
570
  }
575
571
  },
@@ -580,7 +576,7 @@ const X = () => ({
580
576
  return;
581
577
  }
582
578
  y = (async () => {
583
- const t = await m.fetchRecommendationFilters();
579
+ const t = await u.fetchRecommendationFilters();
584
580
  this.filterList = t;
585
581
  })();
586
582
  try {
@@ -601,59 +597,59 @@ const X = () => ({
601
597
  deleteFilterGroup(t) {
602
598
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
603
599
  return;
604
- const e = this.blockStates[this.currentRecommendationId], n = e.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), r = [...new Set(n.map((i) => i.filterGroup))].sort((i, s) => i - s), o = new Map(r.map((i, s) => [i, s + 1]));
605
- e.recommendationConfigs.filters = n.map((i) => ({
600
+ 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]));
601
+ e.recommendationConfigs.filters = r.map((i) => ({
606
602
  ...i,
607
- filterGroup: o.get(i.filterGroup) ?? i.filterGroup
603
+ filterGroup: s.get(i.filterGroup) ?? i.filterGroup
608
604
  }));
609
605
  },
610
606
  updateFilter(t) {
611
607
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
612
608
  return;
613
- const e = this.blockStates[this.currentRecommendationId], n = e.recommendationConfigs.filters.findIndex((r) => r.filterNumber === t.filterNumber && r.filterGroup === t.filterGroup);
614
- if (n !== -1) {
615
- const r = [...e.recommendationConfigs.filters];
616
- r[n] = {
609
+ const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
610
+ if (r !== -1) {
611
+ const n = [...e.recommendationConfigs.filters];
612
+ n[r] = {
617
613
  ...t,
618
- isValid: H(t)
619
- }, e.recommendationConfigs.filters = r;
614
+ isValid: J(t)
615
+ }, e.recommendationConfigs.filters = n;
620
616
  }
621
617
  },
622
618
  deleteFilter(t) {
623
619
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
624
620
  return;
625
- const e = this.blockStates[this.currentRecommendationId], n = [...e.recommendationConfigs.filters].findIndex((r) => r.filterNumber === t.filterNumber && r.filterGroup === t.filterGroup);
626
- if (n !== -1) {
627
- let r = [...e.recommendationConfigs.filters];
628
- if (r.splice(n, 1), r.some((i) => i.filterGroup === t.filterGroup)) {
621
+ const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
622
+ if (r !== -1) {
623
+ let n = [...e.recommendationConfigs.filters];
624
+ if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
629
625
  let i = 1;
630
- r = r.map((s) => s.filterGroup === t.filterGroup ? { ...s, filterNumber: i++ } : s);
626
+ n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
631
627
  } else {
632
- const i = [...new Set(r.map((a) => a.filterGroup))].sort((a, d) => a - d), s = new Map(i.map((a, d) => [a, d + 1]));
633
- r = r.map((a) => ({
628
+ const i = [...new Set(n.map((a) => a.filterGroup))].sort((a, f) => a - f), o = new Map(i.map((a, f) => [a, f + 1]));
629
+ n = n.map((a) => ({
634
630
  ...a,
635
- filterGroup: s.get(a.filterGroup) ?? a.filterGroup
631
+ filterGroup: o.get(a.filterGroup) ?? a.filterGroup
636
632
  }));
637
633
  }
638
- e.recommendationConfigs.filters = r;
634
+ e.recommendationConfigs.filters = n;
639
635
  }
640
636
  },
641
637
  addFilter(t) {
642
638
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
643
639
  return;
644
- const e = this.blockStates[this.currentRecommendationId], n = [...e.recommendationConfigs.filters], o = n.filter(
645
- (s) => s.filterGroup === t.filterGroup
646
- ).length + 1, i = n.findLastIndex((s) => s.filterGroup === t.filterGroup);
647
- i !== -1 ? n.splice(i + 1, 0, {
640
+ const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], s = r.filter(
641
+ (o) => o.filterGroup === t.filterGroup
642
+ ).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
643
+ i !== -1 ? r.splice(i + 1, 0, {
648
644
  ...t,
649
- filterNumber: o
650
- }) : n.push({
645
+ filterNumber: s
646
+ }) : r.push({
651
647
  ...t,
652
- filterNumber: o
653
- }), e.recommendationConfigs.filters = n;
648
+ filterNumber: s
649
+ }), e.recommendationConfigs.filters = r;
654
650
  },
655
651
  generateFilterQuery() {
656
- return P(this.recommendationConfigs.filters);
652
+ return G(this.recommendationConfigs.filters);
657
653
  },
658
654
  /**
659
655
  * Validation-only check invoked at save-CTA time. Defined as an action
@@ -661,77 +657,70 @@ const X = () => ({
661
657
  * every block's recommendationConfigs across user edits.
662
658
  */
663
659
  hasInvalidBlock() {
664
- return Object.values(this.blockStates).some((t) => !Q(t.recommendationConfigs, this));
660
+ return Object.values(this.blockStates).some((t) => !W(t.recommendationConfigs, this));
665
661
  },
666
662
  /**
667
663
  * Which required fields are missing across the design's blocks, so the save
668
664
  * toaster can name the cause instead of always showing the generic message.
669
665
  */
670
666
  invalidBlockFields() {
671
- return Object.values(this.blockStates).flatMap((t) => J(t.recommendationConfigs, this));
667
+ return Object.values(this.blockStates).flatMap((t) => Q(t.recommendationConfigs, this));
672
668
  },
673
669
  // ====================================================================
674
670
  // Per-Block Product Fetching
675
671
  // ====================================================================
676
672
  async fetchRecommendationProducts() {
677
- this.currentRecommendationId !== null && await this.fetchRecommendationProductsForBlock(this.currentRecommendationId);
678
- },
679
- /**
680
- * Fetches one block's products whether or not it is selected: the panel teardown and the
681
- * strategy drawer refresh the block they were handed after the user may have moved on.
682
- */
683
- async fetchRecommendationProductsForBlock(t) {
684
- var i;
685
- const e = this.blockStates[t];
686
- if (!e)
673
+ if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
687
674
  return;
688
- const n = [e.configVersion, e.adoptedSizeVersion, b].join(":"), r = I.get(t);
689
- if ((r == null ? void 0 : r.key) === n) {
690
- await r.promise;
675
+ const t = [
676
+ this.currentRecommendationId,
677
+ this.configVersion,
678
+ b
679
+ ].join(":");
680
+ if (p && I === t) {
681
+ await p;
691
682
  return;
692
683
  }
693
- const o = this._doFetchProducts(t);
694
- I.set(t, { key: n, promise: o });
684
+ I = t, p = this._doFetchProducts();
695
685
  try {
696
- await o;
686
+ await p;
697
687
  } finally {
698
- ((i = I.get(t)) == null ? void 0 : i.promise) === o && I.delete(t);
688
+ I === t && (p = null, I = "");
699
689
  }
700
690
  },
701
- // Captures the block ID up front so the write lands on it even if the user switches.
702
- async _doFetchProducts(t) {
703
- var S;
704
- const e = t ?? this.currentRecommendationId, n = this.blockStates[e], { recommendationConfigs: r } = n, o = R();
705
- if (r.strategyId && o.isFeatureEnabled("reusableRecommendationStrategy")) {
706
- await this._doFetchStrategyProducts(e);
691
+ async _doFetchProducts() {
692
+ var h;
693
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = R();
694
+ if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
695
+ await this._doFetchStrategyProducts(t);
707
696
  return;
708
697
  }
709
- const i = (u.get(e) ?? 0) + 1;
710
- u.set(e, i);
711
- const s = parseInt(r.size) || 6;
698
+ const s = (m.get(t) ?? 0) + 1;
699
+ m.set(t, s);
700
+ const i = parseInt(r.size) || 6;
712
701
  if (!r.strategy) {
713
- this._setBlockProducts(e, [], s);
702
+ this._setBlockProducts(t, [], i);
714
703
  return;
715
704
  }
716
- const a = r.filters.filter((h) => h.isValid), d = P(a), f = ((S = F().find((h) => h.key === r.strategy)) == null ? void 0 : S.path) || "", c = {
705
+ const o = r.filters.filter((g) => g.isValid), a = G(o), f = ((h = w().find((g) => g.key === r.strategy)) == null ? void 0 : h.path) || "", c = {
717
706
  locale: r.language,
718
707
  currency: r.currencySettings.value,
719
- partnerName: o.partnerName,
708
+ partnerName: n.partnerName,
720
709
  size: r.size,
721
710
  details: !0,
722
- campaignId: o.variationId
711
+ campaignId: n.variationId
723
712
  };
724
- r.strategy === "manualMerchandising" ? c.productId = K(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), d && (c.filter = d), r.shuffleProducts && (c.shuffle = !0), Object.assign(
713
+ r.strategy === "manualMerchandising" ? c.productId = H(r.productIds) : r.strategy === "similarViewed" && (c.productId = "{itemId}"), r.strategy === "userBased" && (c.userId = "{user_id}"), a && (c.filter = a), r.shuffleProducts && (c.shuffle = !0), Object.assign(
725
714
  c,
726
- q(o.partnerName, r.strategy)
715
+ K(n.partnerName, r.strategy)
727
716
  );
728
- let g;
717
+ let d;
729
718
  try {
730
- g = await m.fetchRecommendationProducts(f, c);
719
+ d = await u.fetchRecommendationProducts(f, c);
731
720
  } catch {
732
- g = [];
721
+ d = [];
733
722
  }
734
- u.get(e) === i && this._setBlockProducts(e, g, s);
723
+ m.get(t) === s && this._setBlockProducts(t, d, i);
735
724
  },
736
725
  /**
737
726
  * Block-scoped counterpart of `fetchRecommendationProducts`, which only serves the selected block:
@@ -739,8 +728,8 @@ const X = () => ({
739
728
  * @returns whether real products arrived
740
729
  */
741
730
  async fetchStrategyProductsForBlock(t, e = {}) {
742
- var n;
743
- return (n = this.blockStates[t]) != null && n.recommendationConfigs.strategyId ? this._doFetchStrategyProducts(t, e) : !1;
731
+ var r;
732
+ return (r = this.blockStates[t]) != null && r.recommendationConfigs.strategyId ? this._doFetchStrategyProducts(t, e) : !1;
744
733
  },
745
734
  /**
746
735
  * Reloads a block's products and adopts its strategy's current size, which may have
@@ -748,8 +737,8 @@ const X = () => ({
748
737
  * @returns whether a fresh listing holds the strategy and its products arrived
749
738
  */
750
739
  async refreshStrategyBlock(t) {
751
- var o;
752
- const e = (o = this.blockStates[t]) == null ? void 0 : o.recommendationConfigs.strategyId;
740
+ var s;
741
+ const e = (s = this.blockStates[t]) == null ? void 0 : s.recommendationConfigs.strategyId;
753
742
  if (!e)
754
743
  return !1;
755
744
  try {
@@ -757,53 +746,50 @@ const X = () => ({
757
746
  } catch {
758
747
  return !1;
759
748
  }
760
- const n = this.strategiesFetched ? this.strategies.find((i) => String(i.strategy_id) === e) : void 0;
761
- if (!n || !await this.fetchStrategyProductsForBlock(t, { keepOnFailure: !0 }))
762
- return !1;
763
- const r = this.blockStates[t];
764
- if ((r == null ? void 0 : r.recommendationConfigs.strategyId) !== e)
749
+ const r = this.strategiesFetched ? this.strategies.find((i) => String(i.strategy_id) === e) : void 0;
750
+ if (!r || !await this.fetchStrategyProductsForBlock(t, { keepOnFailure: !0 }))
765
751
  return !1;
766
- if (n.size !== void 0) {
767
- const i = String(n.size);
768
- r.recommendationConfigs.size !== i && r.adoptedSizeVersion++, r.recommendationConfigs = { ...r.recommendationConfigs, size: i };
769
- }
770
- return !0;
752
+ const n = this.blockStates[t];
753
+ return (n == null ? void 0 : n.recommendationConfigs.strategyId) !== e ? !1 : (r.size !== void 0 && (n.recommendationConfigs = {
754
+ ...n.recommendationConfigs,
755
+ size: String(r.size)
756
+ }), !0);
771
757
  },
772
758
  _doFetchStrategyProducts(t, e = {}) {
773
- const n = (u.get(t) ?? 0) + 1;
774
- u.set(t, n);
775
- const r = this._loadStrategyProducts(t, n, e);
776
- return _.set(t, { token: n, outcome: r }), r;
777
- },
778
- async _loadStrategyProducts(t, e, { keepOnFailure: n = !1 }) {
779
- const { recommendationConfigs: r } = this.blockStates[t];
780
- let o = [], i = parseInt(r.size) || 6;
759
+ const r = (m.get(t) ?? 0) + 1;
760
+ m.set(t, r);
761
+ const n = this._loadStrategyProducts(t, r, e);
762
+ return D.set(t, { token: r, outcome: n }), n;
763
+ },
764
+ async _loadStrategyProducts(t, e, { keepOnFailure: r = !1 }) {
765
+ const { recommendationConfigs: n } = this.blockStates[t];
766
+ let s = [], i = parseInt(n.size) || 6;
781
767
  try {
782
768
  await this.fetchStrategies();
783
- const s = this.strategies.find(
784
- (a) => String(a.strategy_id) === r.strategyId
769
+ const o = this.strategies.find(
770
+ (a) => String(a.strategy_id) === n.strategyId
785
771
  );
786
- if (s) {
787
- i = parseInt(String(s.size ?? "")) || i;
788
- const a = r.currencySettings.value, f = (await this.resolveStrategyUrlTemplate(s, a)).replaceAll("{locale}", r.language).replaceAll("{currency}", a), c = f.indexOf("?"), g = c === -1 ? f : f.slice(0, c), S = (c === -1 ? "" : f.slice(c + 1)).split("&").filter((v) => v && !v.startsWith("user_id=")), h = S.length ? `${g}?${S.join("&")}` : g;
789
- h && (o = await m.fetchRecommendationProductsByUrl(h));
772
+ if (o) {
773
+ i = parseInt(String(o.size ?? "")) || i;
774
+ const a = n.currencySettings.value, c = (await this.resolveStrategyUrlTemplate(o, a)).replaceAll("{locale}", n.language).replaceAll("{currency}", a), d = c.indexOf("?"), h = d === -1 ? c : c.slice(0, d), g = (d === -1 ? "" : c.slice(d + 1)).split("&").filter((F) => F && !F.startsWith("user_id=")), v = g.length ? `${h}?${g.join("&")}` : h;
775
+ v && (s = await u.fetchRecommendationProductsByUrl(v));
790
776
  }
791
777
  } catch {
792
- o = [];
778
+ s = [];
793
779
  }
794
- return u.get(t) !== e ? W(t) : !o.length && n ? !1 : (this._setBlockProducts(t, o, i), o.length > 0);
780
+ return m.get(t) !== e ? X(t) : !s.length && r ? !1 : (this._setBlockProducts(t, s, i), s.length > 0);
795
781
  },
796
- _setBlockProducts(t, e, n) {
782
+ _setBlockProducts(t, e, r) {
797
783
  if (!this.blockStates[t])
798
784
  return;
799
- const r = e.length > 0 ? e : w(n);
785
+ const n = e.length > 0 ? e : P(r);
800
786
  this.blockStates[t].recommendationProducts = [
801
- ...r.slice(0, n),
802
- ...w(Math.max(0, n - r.length))
787
+ ...n.slice(0, r),
788
+ ...P(Math.max(0, r - n.length))
803
789
  ];
804
790
  }
805
791
  }
806
792
  });
807
793
  export {
808
- ht as useRecommendationExtensionStore
794
+ St as useRecommendationExtensionStore
809
795
  };