@useinsider/guido 2.2.0-beta.8abc7b6 → 2.2.0-beta.953ff70

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 (133) hide show
  1. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +14 -15
  2. package/dist/composables/useHtmlValidator.js +104 -114
  3. package/dist/composables/useRecommendation.js +21 -54
  4. package/dist/config/compiler/recommendationCompilerRules.js +39 -45
  5. package/dist/config/migrator/itemsBlockMigrator.js +97 -101
  6. package/dist/config/migrator/recommendationMigrator.js +2 -2
  7. package/dist/enums/extensions/recommendationBlock.js +1 -1
  8. package/dist/enums/recommendation.js +15 -16
  9. package/dist/extensions/Blocks/Recommendation/block.js +9 -133
  10. package/dist/extensions/Blocks/Recommendation/cardCompositionControl.js +187 -0
  11. package/dist/extensions/Blocks/Recommendation/constants.js +13 -0
  12. package/dist/extensions/Blocks/Recommendation/control.js +336 -0
  13. package/dist/extensions/Blocks/Recommendation/controls/cardBackgroundColorControl.js +68 -0
  14. package/dist/extensions/Blocks/Recommendation/controls/index.js +245 -0
  15. package/dist/extensions/Blocks/Recommendation/controls/nameTextTrimControl.js +74 -0
  16. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textAfter.js → omnibusDiscountTextAfterControl.js} +14 -16
  17. package/dist/extensions/Blocks/Recommendation/controls/{omnibusDiscount/textBefore.js → omnibusDiscountTextBeforeControl.js} +14 -16
  18. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textAfter.js → omnibusPriceTextAfterControl.js} +14 -16
  19. package/dist/extensions/Blocks/Recommendation/controls/{omnibusPrice/textBefore.js → omnibusPriceTextBeforeControl.js} +12 -14
  20. package/dist/extensions/Blocks/Recommendation/controls/spacingControl.js +188 -0
  21. package/dist/extensions/Blocks/Recommendation/extension.js +17 -40
  22. package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +3 -19
  23. package/dist/extensions/Blocks/Recommendation/recommendation.css.js +4 -13
  24. package/dist/extensions/Blocks/Recommendation/settingsPanel.js +10 -21
  25. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +207 -254
  26. package/dist/extensions/Blocks/Recommendation/templates/blockTemplate.js +181 -0
  27. package/dist/extensions/Blocks/Recommendation/templates/migrationTemplate.js +189 -0
  28. package/dist/extensions/Blocks/Recommendation/templates/templateUtils.js +209 -0
  29. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +9 -9
  30. package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +15 -26
  31. package/dist/extensions/Blocks/controlFactories.js +93 -125
  32. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +186 -242
  33. package/dist/services/recommendationApi.js +8 -11
  34. package/dist/services/templateLibraryApi.js +13 -16
  35. package/dist/src/components/wrappers/WpDrawer.vue.d.ts +1 -1
  36. package/dist/src/composables/useRecommendation.d.ts +0 -1
  37. package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -67
  38. package/dist/src/extensions/Blocks/Recommendation/{controls/cardComposition/index.d.ts → cardCompositionControl.d.ts} +3 -23
  39. package/dist/src/extensions/Blocks/Recommendation/{constants/controlIds.d.ts → constants.d.ts} +24 -0
  40. package/dist/src/extensions/Blocks/Recommendation/control.d.ts +38 -0
  41. package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +589 -21
  42. package/dist/src/extensions/Blocks/Recommendation/controls/nameTextTrimControl.d.ts +16 -0
  43. package/dist/src/extensions/Blocks/Recommendation/extension.d.ts +0 -9
  44. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +468 -138
  45. package/dist/src/extensions/Blocks/Recommendation/templates/blockTemplate.d.ts +16 -0
  46. package/dist/src/extensions/Blocks/Recommendation/templates/{grid/migration.d.ts → migrationTemplate.d.ts} +4 -11
  47. package/dist/src/extensions/Blocks/Recommendation/templates/templateUtils.d.ts +52 -0
  48. package/dist/static/styles/customEditorStyle.css.js +11 -35
  49. package/dist/utils/pairProductVariables.js +56 -57
  50. package/dist/utils/templatePreparation.js +14 -15
  51. package/package.json +1 -1
  52. package/dist/config/compiler/utils/recommendationCompilerUtils.js +0 -121
  53. package/dist/extensions/Blocks/Recommendation/constants/blockIds.js +0 -4
  54. package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +0 -4
  55. package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +0 -66
  56. package/dist/extensions/Blocks/Recommendation/constants/layout.js +0 -22
  57. package/dist/extensions/Blocks/Recommendation/constants/selectors.js +0 -21
  58. package/dist/extensions/Blocks/Recommendation/controls/button/index.js +0 -64
  59. package/dist/extensions/Blocks/Recommendation/controls/cardBackground/index.js +0 -80
  60. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +0 -232
  61. package/dist/extensions/Blocks/Recommendation/controls/image/index.js +0 -19
  62. package/dist/extensions/Blocks/Recommendation/controls/layout/index.js +0 -92
  63. package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +0 -102
  64. package/dist/extensions/Blocks/Recommendation/controls/main/currency.js +0 -209
  65. package/dist/extensions/Blocks/Recommendation/controls/main/filters.js +0 -52
  66. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +0 -250
  67. package/dist/extensions/Blocks/Recommendation/controls/main/locale.js +0 -70
  68. package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +0 -160
  69. package/dist/extensions/Blocks/Recommendation/controls/main/shuffle.js +0 -67
  70. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +0 -307
  71. package/dist/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.js +0 -21
  72. package/dist/extensions/Blocks/Recommendation/controls/name/index.js +0 -46
  73. package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +0 -108
  74. package/dist/extensions/Blocks/Recommendation/controls/oldPrice/index.js +0 -44
  75. package/dist/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.js +0 -48
  76. package/dist/extensions/Blocks/Recommendation/controls/omnibusPrice/index.js +0 -48
  77. package/dist/extensions/Blocks/Recommendation/controls/price/index.js +0 -44
  78. package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +0 -222
  79. package/dist/extensions/Blocks/Recommendation/services/configService.js +0 -240
  80. package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +0 -228
  81. package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
  82. package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +0 -66
  83. package/dist/extensions/Blocks/Recommendation/templates/index.js +0 -12
  84. package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +0 -169
  85. package/dist/extensions/Blocks/Recommendation/templates/list/template.js +0 -73
  86. package/dist/extensions/Blocks/Recommendation/templates/utils.js +0 -134
  87. package/dist/extensions/Blocks/Recommendation/types/nodeConfig.js +0 -6
  88. package/dist/extensions/Blocks/Recommendation/utils/priceFormatter.js +0 -29
  89. package/dist/extensions/Blocks/Recommendation/utils/tagName.js +0 -46
  90. package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +0 -17
  91. package/dist/src/extensions/Blocks/Recommendation/constants/blockIds.d.ts +0 -13
  92. package/dist/src/extensions/Blocks/Recommendation/constants/defaultConfig.d.ts +0 -49
  93. package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +0 -13
  94. package/dist/src/extensions/Blocks/Recommendation/constants/layout.d.ts +0 -41
  95. package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -35
  96. package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +0 -143
  97. package/dist/src/extensions/Blocks/Recommendation/controls/cardBackground/index.d.ts +0 -31
  98. package/dist/src/extensions/Blocks/Recommendation/controls/image/index.d.ts +0 -35
  99. package/dist/src/extensions/Blocks/Recommendation/controls/layout/index.d.ts +0 -37
  100. package/dist/src/extensions/Blocks/Recommendation/controls/main/algorithm.d.ts +0 -29
  101. package/dist/src/extensions/Blocks/Recommendation/controls/main/currency.d.ts +0 -52
  102. package/dist/src/extensions/Blocks/Recommendation/controls/main/filters.d.ts +0 -22
  103. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -79
  104. package/dist/src/extensions/Blocks/Recommendation/controls/main/locale.d.ts +0 -24
  105. package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -60
  106. package/dist/src/extensions/Blocks/Recommendation/controls/main/shuffle.d.ts +0 -23
  107. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -221
  108. package/dist/src/extensions/Blocks/Recommendation/controls/mobileLayout/cssRules.d.ts +0 -29
  109. package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +0 -97
  110. package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +0 -34
  111. package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +0 -95
  112. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +0 -100
  113. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textAfter.d.ts +0 -15
  114. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/textBefore.d.ts +0 -15
  115. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +0 -100
  116. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textAfter.d.ts +0 -15
  117. package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/textBefore.d.ts +0 -15
  118. package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +0 -95
  119. package/dist/src/extensions/Blocks/Recommendation/controls/spacing/index.d.ts +0 -83
  120. package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +0 -151
  121. package/dist/src/extensions/Blocks/Recommendation/services/index.d.ts +0 -6
  122. package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +0 -20
  123. package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +0 -33
  124. package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +0 -41
  125. package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +0 -8
  126. package/dist/src/extensions/Blocks/Recommendation/templates/list/migration.d.ts +0 -25
  127. package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +0 -18
  128. package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +0 -66
  129. package/dist/src/extensions/Blocks/Recommendation/types/index.d.ts +0 -7
  130. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -166
  131. package/dist/src/extensions/Blocks/Recommendation/utils/priceFormatter.d.ts +0 -33
  132. package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
  133. package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +0 -77
@@ -1,14 +1,13 @@
1
- import { RecommendationFeedSourceMaps as d, PriceAttributes as S } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as p } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as b } from "../../../../stores/config.js";
4
- import { defineStore as I } from "pinia";
5
- import { DEFAULT_CARDS_IN_ROW as R } from "../constants/layout.js";
6
- import { getDefaultProducts as k } from "../templates/utils.js";
7
- import { generateCompleteFilterQuery as f } from "../utils/filterUtil.js";
8
- const m = p();
9
- function h() {
10
- return {
11
- cardsInRow: R,
1
+ import { RecommendationFeedSourceMaps as n, PriceAttributes as u } from "../../../../enums/extensions/recommendationBlock.js";
2
+ import { useRecommendationApi as l } from "../../../../services/recommendationApi.js";
3
+ import { useConfigStore as c } from "../../../../stores/config.js";
4
+ import { defineStore as p } from "pinia";
5
+ import { generateCompleteFilterQuery as m } from "../utils/filterUtil.js";
6
+ const a = l(), d = () => ({
7
+ recommendationCampaignUrls: {},
8
+ recommendationProducts: [],
9
+ recommendationConfigs: {
10
+ cardsInRow: 3,
12
11
  currencySettings: {
13
12
  name: "USD",
14
13
  value: "USD",
@@ -18,223 +17,178 @@ function h() {
18
17
  decimalSeparator: ",",
19
18
  thousandSeparator: "."
20
19
  },
21
- filters: [],
22
- productIds: [],
20
+ filters: [
21
+ {
22
+ type: "standardFilter",
23
+ attribute: "product_attributes.rating_star",
24
+ operatorReplace: "=",
25
+ operator: "=",
26
+ innerGroupOperator: "*",
27
+ outerGroupOperator: "*",
28
+ value: "5",
29
+ filterGroup: 1,
30
+ filterNumber: 1,
31
+ isValid: !0
32
+ },
33
+ {
34
+ type: "standardFilter",
35
+ attribute: "gender",
36
+ operatorReplace: "=",
37
+ operator: "=",
38
+ innerGroupOperator: "|",
39
+ outerGroupOperator: "*",
40
+ value: "male",
41
+ filterGroup: 1,
42
+ filterNumber: 2,
43
+ isValid: !0
44
+ },
45
+ {
46
+ type: "standardFilter",
47
+ attribute: "size",
48
+ operatorReplace: "=",
49
+ operator: "=",
50
+ innerGroupOperator: "*",
51
+ outerGroupOperator: "*",
52
+ value: "L",
53
+ filterGroup: 1,
54
+ filterNumber: 3,
55
+ isValid: !0
56
+ },
57
+ {
58
+ type: "standardFilter",
59
+ attribute: "price.USD",
60
+ operatorReplace: ">",
61
+ operator: ">",
62
+ innerGroupOperator: "*",
63
+ outerGroupOperator: "*",
64
+ value: "20",
65
+ filterGroup: 2,
66
+ filterNumber: 1,
67
+ isValid: !0
68
+ },
69
+ {
70
+ type: "standardFilter",
71
+ attribute: "url",
72
+ operatorReplace: "~",
73
+ operator: "~",
74
+ innerGroupOperator: "|",
75
+ outerGroupOperator: "*",
76
+ value: "user",
77
+ filterGroup: 2,
78
+ filterNumber: 2,
79
+ isValid: !0
80
+ },
81
+ {
82
+ type: "standardFilter",
83
+ attribute: "category",
84
+ operatorReplace: "!~",
85
+ operator: "!~",
86
+ innerGroupOperator: "*",
87
+ outerGroupOperator: "|",
88
+ value: "t-shirt",
89
+ filterGroup: 3,
90
+ filterNumber: 1,
91
+ isValid: !0
92
+ },
93
+ {
94
+ type: "standardFilter",
95
+ attribute: "omnibus_price.USD",
96
+ operatorReplace: ">",
97
+ operator: ">",
98
+ innerGroupOperator: "*",
99
+ outerGroupOperator: "|",
100
+ value: "31",
101
+ filterGroup: 3,
102
+ filterNumber: 2,
103
+ isValid: !0
104
+ },
105
+ {
106
+ type: "standardFilter",
107
+ attribute: "omnibus_discount.USD",
108
+ operatorReplace: "<",
109
+ operator: "%3C",
110
+ innerGroupOperator: "|",
111
+ outerGroupOperator: "|",
112
+ value: "20",
113
+ filterGroup: 3,
114
+ filterNumber: 3,
115
+ isValid: !0
116
+ }
117
+ ],
118
+ productIds: ["22", "12"],
23
119
  id: 1,
24
- language: "en_US",
25
- orientation: "grid",
120
+ language: "tr_TR",
121
+ orientation: "vertical",
26
122
  recommendedProducts: [],
27
123
  sendProductRequestFlag: !1,
28
124
  shuffleProducts: !1,
29
125
  strategy: "mostPopular",
30
126
  textTrimming: !0,
31
127
  unresponsive: !1,
32
- size: "6"
33
- };
34
- }
35
- function C() {
36
- return {
37
- recommendationConfigs: h(),
38
- recommendationProducts: [],
39
- filterStatus: !1,
40
- filterSelectionDrawerStatus: !1,
41
- filterGroup: 1,
42
- isInitialized: !1
43
- };
44
- }
45
- const y = () => ({
46
- recommendationCampaignUrls: {},
128
+ size: "9"
129
+ },
47
130
  activePredictiveAlgorithms: [],
48
131
  languages: {},
49
132
  currencyList: [],
133
+ filterStatus: !1,
134
+ filterSelectionDrawerStatus: !1,
50
135
  filterList: {},
51
- blockStates: {},
52
- currentRecommendationId: null,
53
- configVersion: 0
54
- }), A = I("guidoRecommendationExtension", {
55
- state: () => y(),
136
+ filterGroup: 1
137
+ }), y = p("guidoRecommendationExtension", {
138
+ state: () => d(),
56
139
  getters: {
57
- // ====================================================================
58
- // Proxy Getters — Backward Compatible Access to Current Block State
59
- // ====================================================================
60
- /**
61
- * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationConfigs
62
- * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
63
- */
64
- recommendationConfigs(t) {
65
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : h();
66
- },
67
- /**
68
- * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
69
- */
70
- recommendationProducts(t) {
71
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationProducts : [];
72
- },
73
- /**
74
- * Proxy getter: delegates to blockStates[currentRecommendationId].filterSelectionDrawerStatus
75
- */
76
- filterSelectionDrawerStatus(t) {
77
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterSelectionDrawerStatus : !1;
78
- },
79
- /**
80
- * Proxy getter: delegates to blockStates[currentRecommendationId].filterStatus
81
- */
82
- filterStatus(t) {
83
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterStatus : !1;
84
- },
85
- /**
86
- * Proxy getter: delegates to blockStates[currentRecommendationId].filterGroup
87
- */
88
- filterGroup(t) {
89
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].filterGroup : 1;
90
- },
91
- // ====================================================================
92
- // Existing Getters (now reading through proxy)
93
- // ====================================================================
94
- hasFilters() {
95
- return !!this.recommendationConfigs.filters.length;
96
- },
97
- getFilterGroupCount() {
98
- const { filters: t } = this.recommendationConfigs;
140
+ hasFilters: (e) => !!e.recommendationConfigs.filters.length,
141
+ getFilterGroupCount: (e) => {
142
+ const { filters: t } = e.recommendationConfigs;
99
143
  return t.length && t[t.length - 1].filterGroup || 0;
100
144
  },
101
- getActivePredictiveAlgorithms: (t) => {
102
- const r = [];
103
- return t.activePredictiveAlgorithms.forEach((e) => {
104
- r.push(...d.filter((n) => n.id === e));
105
- }), r.map((e) => ({
106
- text: e.name,
107
- value: e.key
145
+ getActivePredictiveAlgorithms: (e) => {
146
+ const t = [];
147
+ return e.activePredictiveAlgorithms.forEach((r) => {
148
+ t.push(...n.filter((i) => i.id === r));
149
+ }), t.map((r) => ({
150
+ text: r.name,
151
+ value: r.key
108
152
  }));
109
153
  },
110
- getLanguages: (t) => Object.entries(t.languages).map(([r, e]) => ({
111
- text: e,
112
- value: r
154
+ getLanguages: (e) => Object.entries(e.languages).map(([t, r]) => ({
155
+ text: r,
156
+ value: t
113
157
  })),
114
- getCurrencySymbolList: (t) => t.currencyList.map((r) => ({
115
- text: r.text,
116
- value: r.text
158
+ getCurrencySymbolList: (e) => e.currencyList.map((t) => ({
159
+ text: t.text,
160
+ value: t.text
117
161
  })),
118
- getFilterList() {
119
- return Object.values(this.filterList).map((t) => {
120
- const r = t.type === "defaultAttribute", e = S.includes(t.attributeName);
121
- let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
122
- return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
123
- text: t.displayName,
124
- value: n,
125
- type: t.attributeType
126
- };
127
- });
128
- },
129
- getSelectedFilterGroup() {
130
- return (t) => [...this.recommendationConfigs.filters].filter((r) => r.filterGroup === t);
131
- }
162
+ getFilterList: (e) => Object.values(e.filterList).map((t) => {
163
+ const r = t.type === "defaultAttribute", i = u.includes(t.attributeName);
164
+ let o = r ? t.attributeName : `product_attributes.${t.attributeName}`;
165
+ return o = i ? `${o}.${e.recommendationConfigs.currencySettings.value}` : o, {
166
+ text: t.displayName,
167
+ value: o,
168
+ type: t.attributeType
169
+ };
170
+ }),
171
+ getSelectedFilterGroup: (e) => (t) => [...e.recommendationConfigs.filters].filter((r) => r.filterGroup === t)
132
172
  },
133
173
  actions: {
134
- // ====================================================================
135
- // Block Lifecycle Actions
136
- // ====================================================================
137
- /**
138
- * Sets the currently active block ID.
139
- * Creates a new entry in blockStates if one doesn't exist.
140
- */
141
- setCurrentBlock(t) {
142
- this.blockStates[t] || (this.blockStates = {
143
- ...this.blockStates,
144
- [t]: C()
145
- }), this.currentRecommendationId = t;
146
- },
147
- /**
148
- * Removes a block's state from the store.
149
- * Resets currentRecommendationId if it was the deleted block.
150
- */
151
- removeBlockState(t) {
152
- const r = { ...this.blockStates };
153
- if (delete r[t], this.blockStates = r, this.currentRecommendationId === t) {
154
- const e = Object.keys(this.blockStates).map(Number);
155
- this.currentRecommendationId = e.length > 0 ? e[0] : null;
156
- }
157
- },
158
- /**
159
- * Marks a block as initialized (initial API data has been fetched).
160
- * Automatically cleaned up when removeBlockState deletes the block entry.
161
- */
162
- markBlockInitialized(t) {
163
- this.blockStates[t] && (this.blockStates[t].isInitialized = !0);
164
- },
165
- /**
166
- * Patches the current block's recommendationConfigs.
167
- * Replaces `store.$patch({ recommendationConfigs: { ... } })` pattern.
168
- */
169
- patchCurrentBlockConfig(t, r = {}) {
170
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
171
- return;
172
- const e = this.blockStates[this.currentRecommendationId];
173
- e.recommendationConfigs = {
174
- ...e.recommendationConfigs,
175
- ...t,
176
- currencySettings: {
177
- ...e.recommendationConfigs.currencySettings,
178
- ...t.currencySettings || {}
179
- }
180
- };
181
- const { triggerRefetch: n = !0 } = r;
182
- n && this.configVersion++;
183
- },
184
- /**
185
- * Opens the filter selection drawer for the current block.
186
- * If no filters exist, initializes with a default empty filter
187
- * so the user has a starting point for input.
188
- */
189
- openFilterDrawer() {
190
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
191
- return;
192
- const t = this.blockStates[this.currentRecommendationId];
193
- t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [{
194
- type: "standardFilter",
195
- attribute: "",
196
- operatorReplace: "",
197
- operator: "",
198
- innerGroupOperator: "*",
199
- outerGroupOperator: "*",
200
- filterNumber: 1,
201
- filterGroup: 1,
202
- isValid: !1,
203
- value: ""
204
- }]), t.filterSelectionDrawerStatus = !0;
205
- },
206
- /**
207
- * Closes the filter selection drawer for the current block
208
- */
209
- closeFilterDrawer() {
210
- this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].filterSelectionDrawerStatus = !1);
211
- },
212
- // ====================================================================
213
- // Shared Data Fetching (fetched once, used by all blocks)
214
- // ====================================================================
215
174
  async fetchRecommendationCreateData() {
216
175
  if (this.activePredictiveAlgorithms.length)
217
176
  return;
218
177
  const {
219
- activePredictiveAlgorithms: t,
220
- languages: r,
221
- currencies: e
222
- } = await m.fetchRecommendationCreateData();
223
- if (this.activePredictiveAlgorithms = t, this.languages = r, this.currentRecommendationId !== null && this.blockStates[this.currentRecommendationId]) {
224
- const n = this.blockStates[this.currentRecommendationId];
225
- n.filterStatus = !!n.recommendationConfigs.filters.length;
226
- }
227
- this.currencyList = e;
178
+ activePredictiveAlgorithms: e,
179
+ languages: t,
180
+ currencies: r
181
+ } = await a.fetchRecommendationCreateData();
182
+ this.activePredictiveAlgorithms = e, this.languages = t;
183
+ const [i] = r;
184
+ this.recommendationConfigs.currencySettings.name = i.text, this.recommendationConfigs.currencySettings.value = i.value, this.currencyList = r, this.filterStatus = !!this.recommendationConfigs.filters.length;
228
185
  },
229
186
  async fetchRecommendationFilters() {
230
- const t = await m.fetchRecommendationFilters();
231
- this.filterList = t;
187
+ const e = await a.fetchRecommendationFilters();
188
+ this.filterList = e;
232
189
  },
233
- // ====================================================================
234
- // Per-Block Filter Actions
235
- // ====================================================================
236
- addFilterGroup(t) {
237
- this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push({
190
+ addFilterGroup(e) {
191
+ this.recommendationConfigs.filters.push({
238
192
  type: "standardFilter",
239
193
  attribute: "",
240
194
  operatorReplace: "",
@@ -244,71 +198,70 @@ const y = () => ({
244
198
  value: "",
245
199
  filterNumber: 1,
246
200
  isValid: !0,
247
- filterGroup: t
201
+ filterGroup: e
248
202
  });
249
203
  },
250
- updateFilter(t) {
251
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
252
- return;
253
- const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
254
- if (e !== -1) {
255
- const n = [...r.recommendationConfigs.filters];
256
- n[e] = t, t.value.length && t.operator && t.attribute && t.innerGroupOperator && t.outerGroupOperator ? n[e].isValid = !0 : n[e].isValid = !1, r.recommendationConfigs.filters = n;
204
+ updateFilter(e) {
205
+ const t = this.recommendationConfigs.filters.findIndex((r) => r.filterNumber === e.filterNumber && r.filterGroup === e.filterGroup);
206
+ if (t !== -1) {
207
+ const r = [...this.recommendationConfigs.filters];
208
+ r[t] = e, e.value.length && e.operator && e.attribute && e.innerGroupOperator && e.outerGroupOperator ? r[t].isValid = !0 : r[t].isValid = !1, this.$patch({
209
+ recommendationConfigs: {
210
+ filters: r
211
+ }
212
+ });
257
213
  }
258
214
  },
259
- deleteFilter(t) {
260
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
261
- return;
262
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters].findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
263
- if (e !== -1) {
264
- const n = [...r.recommendationConfigs.filters];
265
- n.splice(e, 1), r.recommendationConfigs.filters = n;
215
+ deleteFilter(e) {
216
+ const t = [...this.recommendationConfigs.filters].findIndex((r) => r.filterNumber === e.filterNumber && r.filterGroup === e.filterGroup);
217
+ if (t !== -1) {
218
+ const r = [...this.recommendationConfigs.filters];
219
+ r.splice(t, 1), this.$patch({
220
+ recommendationConfigs: {
221
+ filters: r
222
+ }
223
+ });
266
224
  }
267
225
  },
268
- addFilter(t) {
269
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
270
- return;
271
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], o = e.filter(
272
- (i) => i.filterGroup === t.filterGroup
273
- ).length + 1, s = e.findLastIndex((i) => i.filterGroup === t.filterGroup);
274
- s !== -1 ? e.splice(s + 1, 0, {
275
- ...t,
276
- filterNumber: o
277
- }) : e.push({
278
- ...t,
279
- filterNumber: o
280
- }), r.recommendationConfigs.filters = e;
226
+ addFilter(e) {
227
+ const t = [...this.recommendationConfigs.filters], r = t.findLastIndex((i) => i.filterGroup === e.filterGroup);
228
+ r !== -1 ? t.splice(r + 1, 0, {
229
+ ...e,
230
+ filterNumber: r + 2
231
+ }) : t.push({
232
+ ...e,
233
+ filterNumber: 1
234
+ }), this.$patch({
235
+ recommendationConfigs: {
236
+ filters: t
237
+ }
238
+ });
281
239
  },
282
240
  generateFilterQuery() {
283
- return f(this.recommendationConfigs.filters);
241
+ return m(this.recommendationConfigs.filters);
284
242
  },
285
- // ====================================================================
286
- // Per-Block Product Fetching
287
- // ====================================================================
288
243
  async fetchRecommendationProducts() {
289
- var u;
290
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
291
- return;
292
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((l) => l.isValid), o = f(n), s = ((u = d.find((l) => l.key === e.strategy)) == null ? void 0 : u.path) || "", i = b(), c = {
293
- locale: e.language,
294
- currency: e.currencySettings.value,
295
- partnerName: i.partnerName,
296
- size: e.size,
297
- details: !0,
298
- campaignId: i.variationId
299
- };
300
- e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), o && (c.filter = o), e.shuffleProducts && (c.shuffle = !0);
301
- const g = parseInt(e.size) || 6;
302
- let a;
303
- try {
304
- a = await m.fetchRecommendationProducts(s, c);
305
- } catch {
306
- a = [];
307
- }
308
- this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : k(g));
244
+ var o;
245
+ const e = this.generateFilterQuery(), t = ((o = n.find((s) => s.key === this.recommendationConfigs.strategy)) == null ? void 0 : o.path) || "", r = c(), i = await a.fetchRecommendationProducts(
246
+ t,
247
+ {
248
+ // TODO: Here will be optimized and filled carefully
249
+ locale: this.recommendationConfigs.language,
250
+ currency: this.recommendationConfigs.currencySettings.value,
251
+ partnerName: r.partnerName,
252
+ productId: this.recommendationConfigs.strategy === "manualMerchandising" ? this.recommendationConfigs.productIds.join(",") : "{itemId}",
253
+ size: this.recommendationConfigs.size,
254
+ details: !0,
255
+ campaignId: "{campaignId}",
256
+ filter: e
257
+ }
258
+ );
259
+ this.$patch({
260
+ recommendationProducts: i
261
+ });
309
262
  }
310
263
  }
311
264
  });
312
265
  export {
313
- A as useRecommendationExtensionStore
266
+ y as useRecommendationExtensionStore
314
267
  };