@useinsider/guido 3.2.0-beta.caa22bf → 3.2.0-beta.ccaf9f5

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 (79) hide show
  1. package/README.md +0 -92
  2. package/dist/@types/config/schemas.js +94 -150
  3. package/dist/components/Guido.vue.js +1 -1
  4. package/dist/components/Guido.vue2.js +75 -75
  5. package/dist/composables/useCortexBlueprintBridge.js +38 -0
  6. package/dist/composables/useEmailTemplateApplier.js +41 -0
  7. package/dist/composables/useRecommendation.js +26 -46
  8. package/dist/composables/useSave.js +18 -21
  9. package/dist/composables/useStripo.js +16 -14
  10. package/dist/config/compiler/recommendationCompilerRules.js +27 -27
  11. package/dist/config/migrator/index.js +9 -9
  12. package/dist/config/migrator/radioButtonMigrator.js +44 -64
  13. package/dist/config/migrator/recommendationMigrator.js +290 -74
  14. package/dist/enums/displayConditions.js +80 -0
  15. package/dist/enums/extensions/recommendationBlock.js +1 -2
  16. package/dist/extensions/Blocks/RadioButton/template.js +1 -1
  17. package/dist/extensions/Blocks/Recommendation/block.js +32 -35
  18. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
  19. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +24 -25
  20. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +181 -228
  21. package/dist/extensions/Blocks/Recommendation/services/configService.js +29 -65
  22. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +90 -130
  23. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +251 -0
  24. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +8 -8
  25. package/dist/extensions/Blocks/Recommendation/templates/utils.js +1 -1
  26. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +22 -13
  27. package/dist/guido.css +1 -1
  28. package/dist/node_modules/valibot/dist/index.js +235 -450
  29. package/dist/src/@types/config/defaults.d.ts +1 -5
  30. package/dist/src/@types/config/index.d.ts +3 -3
  31. package/dist/src/@types/config/schemas.d.ts +0 -213
  32. package/dist/src/@types/config/types.d.ts +1 -9
  33. package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
  34. package/dist/src/composables/useConfig.d.ts +0 -56
  35. package/dist/src/composables/useCortexBlueprintBridge.d.ts +17 -0
  36. package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
  37. package/dist/src/composables/useRecommendation.d.ts +1 -10
  38. package/dist/src/config/migrator/index.d.ts +1 -2
  39. package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -13
  40. package/dist/src/enums/displayConditions.d.ts +2 -0
  41. package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
  42. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -10
  43. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -34
  44. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
  45. package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +3 -0
  46. package/dist/src/library.d.ts +1 -1
  47. package/dist/src/stores/config.d.ts +0 -504
  48. package/dist/utils/templatePreparation.js +32 -72
  49. package/package.json +1 -5
  50. package/dist/composables/validators/useCouponBlockValidator.js +0 -24
  51. package/dist/config/migrator/recommendation/compositionMapper.js +0 -98
  52. package/dist/config/migrator/recommendation/extractors.js +0 -27
  53. package/dist/config/migrator/recommendation/htmlBuilder.js +0 -496
  54. package/dist/config/migrator/recommendation/parseLegacyConfig.js +0 -33
  55. package/dist/config/migrator/recommendation/settingsMapper.js +0 -70
  56. package/dist/config/migrator/recommendation/themeMapper.js +0 -93
  57. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMap.js +0 -21
  58. package/dist/src/composables/useRecommendation.test.d.ts +0 -1
  59. package/dist/src/composables/validators/useCouponBlockValidator.d.ts +0 -3
  60. package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +0 -2
  61. package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +0 -1
  62. package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -7
  63. package/dist/src/config/migrator/recommendation/extractors.test.d.ts +0 -1
  64. package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -11
  65. package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +0 -15
  66. package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +0 -1
  67. package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +0 -7
  68. package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +0 -1
  69. package/dist/src/config/migrator/recommendation/themeMapper.d.ts +0 -5
  70. package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +0 -1
  71. package/dist/src/config/migrator/recommendation/types.d.ts +0 -205
  72. package/dist/src/config/migrator/recommendationMigrator.test.d.ts +0 -1
  73. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +0 -1
  74. package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +0 -1
  75. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.d.ts +0 -21
  76. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMap.test.d.ts +0 -1
  77. package/dist/src/utils/htmlEscape.d.ts +0 -5
  78. package/dist/src/utils/htmlEscape.test.d.ts +0 -1
  79. package/dist/utils/htmlEscape.js +0 -13
@@ -1,14 +1,8 @@
1
- import { ModificationDescription as h } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { CURRENT_CONFIG_VERSION as l, DEFAULT_NODE_CONFIG as r } from "../constants/defaultConfig.js";
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 === " ";
7
- }
8
- function N(e) {
9
- return e === "." || e === "," || e === " " || e === "";
10
- }
11
- class V {
1
+ import { ModificationDescription as f } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { CURRENT_CONFIG_VERSION as u, DEFAULT_NODE_CONFIG as e } from "../constants/defaultConfig.js";
3
+ import { setCurrencyAttributes as g } from "../controls/main/utils.js";
4
+ import { hasMinimalConfig as a } from "../types/nodeConfig.js";
5
+ class C {
12
6
  // ========================================================================
13
7
  // Read Operations
14
8
  // ========================================================================
@@ -48,7 +42,7 @@ class V {
48
42
  return !1;
49
43
  try {
50
44
  const t = i.getNodeConfig();
51
- return A(t);
45
+ return a(t);
52
46
  } catch {
53
47
  return !1;
54
48
  }
@@ -83,8 +77,8 @@ class V {
83
77
  * @returns The new complete configuration
84
78
  */
85
79
  static updateConfig(i, t, o, n) {
86
- const c = this.getConfig(t), u = this.deepMerge(c, o);
87
- return this.saveConfig(i, t, u, n), u;
80
+ const s = this.getConfig(t), r = this.deepMerge(s, o);
81
+ return this.saveConfig(i, t, r, n), r;
88
82
  }
89
83
  /**
90
84
  * Initialize configuration for a new block
@@ -101,7 +95,7 @@ class V {
101
95
  */
102
96
  static initializeConfig(i, t, o) {
103
97
  const n = o ? this.mergeWithDefaults(o) : this.cloneDefaults();
104
- return this.saveConfig(i, t, n, "Initialize recommendation block"), D({
98
+ return this.saveConfig(i, t, n, "Initialize recommendation block"), g({
105
99
  currentNode: t,
106
100
  documentModifier: i.getDocumentModifier(),
107
101
  currency: n.currency
@@ -118,9 +112,9 @@ class V {
118
112
  */
119
113
  static saveConfig(i, t, o, n) {
120
114
  try {
121
- i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new h(n));
122
- } catch (c) {
123
- console.warn("[RecommendationConfigService] Failed to save config:", c);
115
+ i.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new f(n));
116
+ } catch (s) {
117
+ console.warn("[RecommendationConfigService] Failed to save config:", s);
124
118
  }
125
119
  }
126
120
  // ========================================================================
@@ -131,53 +125,23 @@ class V {
131
125
  *
132
126
  * Reads existing data-attributes and creates a proper node config.
133
127
  * Used when loading templates created before node config was implemented.
134
- *
135
- * Sources, in priority order (later overrides earlier):
136
- * 1. `esd-ext-config` JSON blob — emitted by the recommendation migrator and
137
- * by hand-authored new templates. Carries the full RecommendationNodeConfig
138
- * (strategy, language, currency, filters, productIds, etc.) which the
139
- * discrete data-* attrs below cannot capture.
140
- * 2. Discrete `data-*` attributes — runtime source of truth for
141
- * layout/composition/spacing; controls keep these in sync as the user
142
- * edits, so we let them override the JSON blob if they disagree.
143
- * 3. `currency-*` attributes — durable currency source on the block element.
144
128
  * @param api - Stripo extension API with document modifier
145
129
  * @param node - The block node to migrate
146
130
  * @returns The migrated configuration
147
131
  */
148
132
  static migrateFromDataAttributes(i, t) {
149
133
  const o = {
150
- configVersion: l
134
+ configVersion: u
151
135
  };
152
136
  if ("getAttribute" in t && typeof t.getAttribute == "function") {
153
- const n = t.getAttribute("esd-ext-config");
154
- if (n)
155
- try {
156
- const s = JSON.parse(n);
157
- s && typeof s == "object" && (Object.assign(o, s), o.configVersion = l);
158
- } catch {
159
- }
160
- const c = t.getAttribute("data-layout");
161
- c === "list" || c === "horizontal" ? o.layout = "list" : (c === "grid" || c === "vertical") && (o.layout = "grid");
162
- const u = t.getAttribute("data-card-composition");
163
- u && (o.composition = u.split(",").filter(Boolean));
164
- const p = t.getAttribute("data-column-spacing");
165
- p && (o.columnSpacing = parseInt(p) || r.columnSpacing);
166
- const b = t.getAttribute("data-row-spacing");
167
- if (b && (o.rowSpacing = parseInt(b) || r.rowSpacing), !o.currency) {
168
- 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");
169
- if (s || y || d || f || g || m) {
170
- const a = r.currency, C = m ? parseInt(m) : NaN;
171
- o.currency = {
172
- code: s ?? a.code,
173
- symbol: y ?? a.symbol,
174
- alignment: d === "0" ? "before" : "after",
175
- decimalCount: Number.isFinite(C) ? C : a.decimalCount,
176
- decimalSeparator: S(g) ? g : a.decimalSeparator,
177
- thousandSeparator: N(f) ? f : a.thousandSeparator
178
- };
179
- }
180
- }
137
+ const n = t.getAttribute("data-layout");
138
+ n === "list" || n === "horizontal" ? o.layout = "list" : (n === "grid" || n === "vertical") && (o.layout = "grid");
139
+ const s = t.getAttribute("data-card-composition");
140
+ s && (o.composition = s.split(",").filter(Boolean));
141
+ const r = t.getAttribute("data-column-spacing");
142
+ r && (o.columnSpacing = parseInt(r) || e.columnSpacing);
143
+ const c = t.getAttribute("data-row-spacing");
144
+ c && (o.rowSpacing = parseInt(c) || e.rowSpacing);
181
145
  }
182
146
  return this.initializeConfig(i, t, o);
183
147
  }
@@ -187,7 +151,7 @@ class V {
187
151
  * @returns True if migration is needed
188
152
  */
189
153
  static needsMigration(i) {
190
- return i ? this.hasConfig(i) ? this.getConfigVersion(i) < l : !0 : !1;
154
+ return i ? this.hasConfig(i) ? this.getConfigVersion(i) < u : !0 : !1;
191
155
  }
192
156
  // ========================================================================
193
157
  // Internal Helpers
@@ -197,12 +161,12 @@ class V {
197
161
  */
198
162
  static cloneDefaults() {
199
163
  return {
200
- ...r,
201
- currency: { ...r.currency },
202
- omnibusPrice: { ...r.omnibusPrice },
203
- omnibusDiscount: { ...r.omnibusDiscount },
204
- composition: [...r.composition],
205
- visibility: { ...r.visibility },
164
+ ...e,
165
+ currency: { ...e.currency },
166
+ omnibusPrice: { ...e.omnibusPrice },
167
+ omnibusDiscount: { ...e.omnibusDiscount },
168
+ composition: [...e.composition],
169
+ visibility: { ...e.visibility },
206
170
  filters: [],
207
171
  productIds: [],
208
172
  recommendationId: 0
@@ -272,5 +236,5 @@ class V {
272
236
  }
273
237
  }
274
238
  export {
275
- V as RecommendationConfigService
239
+ C as RecommendationConfigService
276
240
  };
@@ -1,15 +1,15 @@
1
- import { RecommendationFeedSourceMaps as S, getOperatorOptions as R, PriceAttributes as y } from "../../../../enums/extensions/recommendationBlock.js";
1
+ import { RecommendationFeedSourceMaps as g, getOperatorOptions as R, PriceAttributes as k } from "../../../../enums/extensions/recommendationBlock.js";
2
2
  import { useRecommendationApi as C } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as G } from "../../../../stores/config.js";
4
- import { defineStore as P } from "pinia";
3
+ import { useConfigStore as y } from "../../../../stores/config.js";
4
+ import { defineStore as G } from "pinia";
5
5
  import { DEFAULT_CARDS_IN_ROW as F } from "../constants/layout.js";
6
- import { EXCLUDED_ALGORITHM_IDS as D } from "../constants/defaultConfig.js";
7
- import { getDefaultProducts as g } from "../templates/utils.js";
6
+ import { EXCLUDED_ALGORITHM_IDS as w } from "../constants/defaultConfig.js";
7
+ import { getDefaultProducts as S } from "../templates/utils.js";
8
8
  import { generateCompleteFilterQuery as b } from "../utils/filterUtil.js";
9
- import { isFilterValid as w } from "../validation/filterSchema.js";
9
+ import { isFilterValid as D } from "../validation/filterSchema.js";
10
10
  const h = C();
11
- let u = null, m = null, d = null;
12
- function k() {
11
+ let m = null, u = null, d = null;
12
+ function I() {
13
13
  return {
14
14
  cardsInRow: F,
15
15
  currencySettings: {
@@ -37,9 +37,9 @@ function k() {
37
37
  customAttributes: []
38
38
  };
39
39
  }
40
- function I() {
40
+ function P() {
41
41
  return {
42
- recommendationConfigs: k(),
42
+ recommendationConfigs: I(),
43
43
  recommendationProducts: [],
44
44
  filterStatus: !1,
45
45
  filterSelectionDrawerStatus: !1,
@@ -57,7 +57,7 @@ const v = () => ({
57
57
  blockStates: {},
58
58
  currentRecommendationId: null,
59
59
  configVersion: 0
60
- }), _ = P("guidoRecommendationExtension", {
60
+ }), z = G("guidoRecommendationExtension", {
61
61
  state: () => v(),
62
62
  getters: {
63
63
  // ====================================================================
@@ -68,7 +68,7 @@ const v = () => ({
68
68
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
69
69
  */
70
70
  recommendationConfigs(t) {
71
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : k();
71
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : I();
72
72
  },
73
73
  /**
74
74
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -102,45 +102,45 @@ const v = () => ({
102
102
  },
103
103
  hasValidFilters() {
104
104
  const { filters: t } = this.recommendationConfigs;
105
- return t.length ? t.every((e) => e.isValid) : !1;
105
+ return t.length ? t.every((r) => r.isValid) : !1;
106
106
  },
107
107
  getFilterGroupCount() {
108
108
  const { filters: t } = this.recommendationConfigs;
109
- return t.length ? new Set(t.map((e) => e.filterGroup)).size : 0;
109
+ return t.length ? new Set(t.map((r) => r.filterGroup)).size : 0;
110
110
  },
111
111
  getUniqueFilterGroups() {
112
112
  const { filters: t } = this.recommendationConfigs;
113
- return [...new Set(t.map((e) => e.filterGroup))].sort((e, r) => e - r);
113
+ return [...new Set(t.map((r) => r.filterGroup))].sort((r, e) => r - e);
114
114
  },
115
115
  getActivePredictiveAlgorithms: (t) => {
116
- const e = [];
117
- return t.activePredictiveAlgorithms.filter((r) => !D.includes(r)).forEach((r) => {
118
- e.push(...S.filter((n) => n.id === r));
119
- }), e.map((r) => ({
120
- text: r.name,
121
- value: r.key
116
+ const r = [];
117
+ return t.activePredictiveAlgorithms.filter((e) => !w.includes(e)).forEach((e) => {
118
+ r.push(...g.filter((n) => n.id === e));
119
+ }), r.map((e) => ({
120
+ text: e.name,
121
+ value: e.key
122
122
  }));
123
123
  },
124
- getLanguages: (t) => Object.entries(t.languages).map(([e, r]) => ({
125
- text: r,
126
- value: e
124
+ getLanguages: (t) => Object.entries(t.languages).map(([r, e]) => ({
125
+ text: e,
126
+ value: r
127
127
  })),
128
- getCurrencySymbolList: (t) => t.currencyList.map((e) => ({
129
- text: e.text,
130
- value: e.text
128
+ getCurrencySymbolList: (t) => t.currencyList.map((r) => ({
129
+ text: r.text,
130
+ value: r.text
131
131
  })),
132
132
  getFilterList() {
133
133
  return Object.values(this.filterList).map((t) => {
134
- let e;
135
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : y.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
134
+ let r;
135
+ return t.type === "productAttribute" ? r = `product_attributes.${t.attributeName}` : k.includes(t.attributeName) ? r = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : r = t.attributeName, {
136
136
  text: t.displayName,
137
- value: e,
137
+ value: r,
138
138
  type: t.attributeType
139
139
  };
140
140
  });
141
141
  },
142
142
  getSelectedFilterGroup() {
143
- return (t) => [...this.recommendationConfigs.filters].filter((e) => e.filterGroup === t);
143
+ return (t) => [...this.recommendationConfigs.filters].filter((r) => r.filterGroup === t);
144
144
  }
145
145
  },
146
146
  actions: {
@@ -154,7 +154,7 @@ const v = () => ({
154
154
  setCurrentBlock(t) {
155
155
  this.blockStates[t] || (this.blockStates = {
156
156
  ...this.blockStates,
157
- [t]: I()
157
+ [t]: P()
158
158
  }), this.currentRecommendationId = t;
159
159
  },
160
160
  /**
@@ -162,13 +162,13 @@ const v = () => ({
162
162
  * Resets currentRecommendationId if it was the deleted block.
163
163
  */
164
164
  removeBlockState(t) {
165
- const e = t.toString();
166
- if (this.recommendationCampaignUrls[e]) {
165
+ const r = t.toString();
166
+ if (this.recommendationCampaignUrls[r]) {
167
167
  const n = { ...this.recommendationCampaignUrls };
168
- delete n[e], this.recommendationCampaignUrls = n;
168
+ delete n[r], this.recommendationCampaignUrls = n;
169
169
  }
170
- const r = { ...this.blockStates };
171
- if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
170
+ const e = { ...this.blockStates };
171
+ if (delete e[t], this.blockStates = e, this.currentRecommendationId === t) {
172
172
  const n = Object.keys(this.blockStates).map(Number);
173
173
  this.currentRecommendationId = n.length > 0 ? n[0] : null;
174
174
  }
@@ -180,75 +180,37 @@ const v = () => ({
180
180
  markBlockInitialized(t) {
181
181
  this.blockStates[t] && (this.blockStates[t].isInitialized = !0);
182
182
  },
183
- /**
184
- * Seeds the URL-relevant fields of a block from a persisted node config.
185
- *
186
- * Used at save-time to ensure the campaign URL is built from the
187
- * persisted truth (the `esd-ext-config` blob in the raw HTML) even when
188
- * the user never selected the block in this editor session — without
189
- * this seed, `_syncNodeConfigToStore` would never have run for that
190
- * block and the store would hold default values (USD/en_US/mostPopular)
191
- * instead of the real config.
192
- *
193
- * Creates the block entry if missing; otherwise patches only the URL-
194
- * relevant subset and leaves runtime fields (e.g., `recommendedProducts`,
195
- * `isInitialized`) alone.
196
- */
197
- seedBlockUrlConfig(t, e) {
198
- const r = (o, s) => o === "." || o === "," || o === " " ? o : s, n = {
199
- name: e.currencyCode,
200
- value: e.currencyCode,
201
- symbol: e.currencyCode,
202
- alignment: e.currencyAlignment === "before" ? "0" : "1",
203
- decimalCount: String(e.currencyDecimalCount),
204
- decimalSeparator: r(e.currencyDecimalSeparator, ","),
205
- thousandSeparator: r(e.currencyThousandSeparator, ".")
206
- }, c = !this.blockStates[t], i = c ? I() : this.blockStates[t];
207
- i.recommendationConfigs = {
208
- ...i.recommendationConfigs,
209
- strategy: e.strategy,
210
- language: e.language,
211
- size: e.size,
212
- productIds: e.productIds,
213
- filters: e.filters,
214
- shuffleProducts: e.shuffleProducts,
215
- currencySettings: n
216
- }, c && (this.blockStates = {
217
- ...this.blockStates,
218
- [t]: i
219
- });
220
- },
221
183
  /**
222
184
  * Patches the current block's recommendationConfigs.
223
185
  * Replaces `store.$patch({ recommendationConfigs: { ... } })` pattern.
224
186
  */
225
- patchCurrentBlockConfig(t, e = {}) {
187
+ patchCurrentBlockConfig(t, r = {}) {
226
188
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
227
189
  return;
228
- const r = this.blockStates[this.currentRecommendationId];
229
- r.recommendationConfigs = {
230
- ...r.recommendationConfigs,
190
+ const e = this.blockStates[this.currentRecommendationId];
191
+ e.recommendationConfigs = {
192
+ ...e.recommendationConfigs,
231
193
  ...t,
232
194
  currencySettings: {
233
- ...r.recommendationConfigs.currencySettings,
195
+ ...e.recommendationConfigs.currencySettings,
234
196
  ...t.currencySettings || {}
235
197
  }
236
198
  };
237
- const { triggerRefetch: n = !0 } = e;
199
+ const { triggerRefetch: n = !0 } = r;
238
200
  n && this.configVersion++;
239
201
  },
240
202
  /**
241
203
  * Creates a filter with the first available attribute and operator pre-selected.
242
204
  */
243
- createDefaultFilter(t, e) {
244
- const [r] = this.getFilterList, [n] = R(r == null ? void 0 : r.type);
205
+ createDefaultFilter(t, r) {
206
+ const [e] = this.getFilterList, [n] = R(e == null ? void 0 : e.type);
245
207
  return {
246
208
  type: "standardFilter",
247
- attribute: (r == null ? void 0 : r.value) ?? "",
209
+ attribute: (e == null ? void 0 : e.value) ?? "",
248
210
  operator: (n == null ? void 0 : n.value) ?? "",
249
211
  innerGroupOperator: "*",
250
212
  outerGroupOperator: "*",
251
- filterNumber: e,
213
+ filterNumber: r,
252
214
  filterGroup: t,
253
215
  isValid: !1,
254
216
  value: ""
@@ -293,43 +255,43 @@ const v = () => ({
293
255
  // ====================================================================
294
256
  async fetchRecommendationCreateData() {
295
257
  if (!this.activePredictiveAlgorithms.length) {
296
- if (u) {
297
- await u;
258
+ if (m) {
259
+ await m;
298
260
  return;
299
261
  }
300
- u = (async () => {
262
+ m = (async () => {
301
263
  const {
302
264
  activePredictiveAlgorithms: t,
303
- languages: e,
304
- currencies: r
265
+ languages: r,
266
+ currencies: e
305
267
  } = await h.fetchRecommendationCreateData();
306
- if (this.activePredictiveAlgorithms = t, this.languages = e, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
268
+ if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
307
269
  const n = this.blockStates[this.currentRecommendationId];
308
270
  n.filterStatus = !!n.recommendationConfigs.filters.length;
309
271
  }
310
- this.currencyList = r;
272
+ this.currencyList = e;
311
273
  })();
312
274
  try {
313
- await u;
275
+ await m;
314
276
  } finally {
315
- u = null;
277
+ m = null;
316
278
  }
317
279
  }
318
280
  },
319
281
  async fetchRecommendationFilters() {
320
282
  if (!Object.keys(this.filterList).length) {
321
- if (m) {
322
- await m;
283
+ if (u) {
284
+ await u;
323
285
  return;
324
286
  }
325
- m = (async () => {
287
+ u = (async () => {
326
288
  const t = await h.fetchRecommendationFilters();
327
289
  this.filterList = t;
328
290
  })();
329
291
  try {
330
- await m;
292
+ await u;
331
293
  } finally {
332
- m = null;
294
+ u = null;
333
295
  }
334
296
  }
335
297
  },
@@ -344,8 +306,8 @@ const v = () => ({
344
306
  deleteFilterGroup(t) {
345
307
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
346
308
  return;
347
- 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]));
348
- e.recommendationConfigs.filters = r.map((i) => ({
309
+ const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.filter((i) => i.filterGroup !== t), n = [...new Set(e.map((i) => i.filterGroup))].sort((i, o) => i - o), c = new Map(n.map((i, o) => [i, o + 1]));
310
+ r.recommendationConfigs.filters = e.map((i) => ({
349
311
  ...i,
350
312
  filterGroup: c.get(i.filterGroup) ?? i.filterGroup
351
313
  }));
@@ -353,47 +315,47 @@ const v = () => ({
353
315
  updateFilter(t) {
354
316
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
355
317
  return;
356
- const e = this.blockStates[this.currentRecommendationId], r = e.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
357
- if (r !== -1) {
358
- const n = [...e.recommendationConfigs.filters];
359
- n[r] = {
318
+ const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
319
+ if (e !== -1) {
320
+ const n = [...r.recommendationConfigs.filters];
321
+ n[e] = {
360
322
  ...t,
361
- isValid: w(t)
362
- }, e.recommendationConfigs.filters = n;
323
+ isValid: D(t)
324
+ }, r.recommendationConfigs.filters = n;
363
325
  }
364
326
  },
365
327
  deleteFilter(t) {
366
328
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
367
329
  return;
368
- const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
369
- if (r !== -1) {
370
- let n = [...e.recommendationConfigs.filters];
371
- if (n.splice(r, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
330
+ const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
331
+ if (e !== -1) {
332
+ let n = [...r.recommendationConfigs.filters];
333
+ if (n.splice(e, 1), n.some((i) => i.filterGroup === t.filterGroup)) {
372
334
  let i = 1;
373
335
  n = n.map((o) => o.filterGroup === t.filterGroup ? { ...o, filterNumber: i++ } : o);
374
336
  } else {
375
- const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, a) => s - a), o = new Map(i.map((s, a) => [s, a + 1]));
337
+ const i = [...new Set(n.map((s) => s.filterGroup))].sort((s, l) => s - l), o = new Map(i.map((s, l) => [s, l + 1]));
376
338
  n = n.map((s) => ({
377
339
  ...s,
378
340
  filterGroup: o.get(s.filterGroup) ?? s.filterGroup
379
341
  }));
380
342
  }
381
- e.recommendationConfigs.filters = n;
343
+ r.recommendationConfigs.filters = n;
382
344
  }
383
345
  },
384
346
  addFilter(t) {
385
347
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
386
348
  return;
387
- const e = this.blockStates[this.currentRecommendationId], r = [...e.recommendationConfigs.filters], c = r.filter(
349
+ const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], c = e.filter(
388
350
  (o) => o.filterGroup === t.filterGroup
389
- ).length + 1, i = r.findLastIndex((o) => o.filterGroup === t.filterGroup);
390
- i !== -1 ? r.splice(i + 1, 0, {
351
+ ).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
352
+ i !== -1 ? e.splice(i + 1, 0, {
391
353
  ...t,
392
354
  filterNumber: c
393
- }) : r.push({
355
+ }) : e.push({
394
356
  ...t,
395
357
  filterNumber: c
396
- }), e.recommendationConfigs.filters = r;
358
+ }), r.recommendationConfigs.filters = e;
397
359
  },
398
360
  generateFilterQuery() {
399
361
  return b(this.recommendationConfigs.filters);
@@ -417,31 +379,29 @@ const v = () => ({
417
379
  },
418
380
  async _doFetchProducts() {
419
381
  var p;
420
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = r.filters.filter((l) => l.isValid), c = b(n), i = ((p = S.find((l) => l.key === r.strategy)) == null ? void 0 : p.path) || "", o = G(), s = parseInt(r.size) || 6, a = {
421
- locale: r.language,
422
- currency: r.currencySettings.value,
382
+ const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((a) => a.isValid), c = b(n), i = ((p = g.find((a) => a.key === e.strategy)) == null ? void 0 : p.path) || "", o = y(), s = {
383
+ locale: e.language,
384
+ currency: e.currencySettings.value,
423
385
  partnerName: o.partnerName,
424
- size: r.size,
386
+ size: e.size,
425
387
  details: !0,
426
388
  campaignId: o.variationId
427
389
  };
428
- r.strategy === "manualMerchandising" ? a.productId = r.productIds.slice(0, s).join(",") : r.strategy === "similarViewed" && (a.productId = "{itemId}"), r.strategy === "userBased" && (a.userId = "{user_id}"), c && (a.filter = c), r.shuffleProducts && (a.shuffle = !0);
390
+ e.strategy === "manualMerchandising" ? s.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (s.productId = "{itemId}"), e.strategy === "userBased" && (s.userId = "{user_id}"), c && (s.filter = c), e.shuffleProducts && (s.shuffle = !0);
391
+ const l = parseInt(e.size) || 6;
429
392
  let f;
430
393
  try {
431
- f = await h.fetchRecommendationProducts(i, a);
394
+ f = await h.fetchRecommendationProducts(i, s);
432
395
  } catch {
433
396
  f = [];
434
397
  }
435
398
  if (this.blockStates[t]) {
436
- const l = f.length > 0 ? f : g(s);
437
- l.length < s ? this.blockStates[t].recommendationProducts = [
438
- ...l,
439
- ...g(s - l.length)
440
- ] : l.length > s ? this.blockStates[t].recommendationProducts = l.slice(0, s) : this.blockStates[t].recommendationProducts = l;
399
+ const a = f.length > 0 ? f : S(l);
400
+ this.blockStates[t].recommendationProducts = a.length < l ? [...a, ...S(l - a.length)] : a;
441
401
  }
442
402
  }
443
403
  }
444
404
  });
445
405
  export {
446
- _ as useRecommendationExtensionStore
406
+ z as useRecommendationExtensionStore
447
407
  };