@useinsider/guido 2.1.0-beta.7ffef92 → 2.1.0-beta.814593d

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 (47) hide show
  1. package/dist/@types/config/schemas.js +1 -1
  2. package/dist/components/organisms/base/Toaster.vue.js +4 -4
  3. package/dist/components/organisms/base/Toaster.vue2.js +12 -9
  4. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +5 -5
  5. package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +2 -2
  6. package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +13 -11
  7. package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +24 -55
  8. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue.js +3 -3
  9. package/dist/components/organisms/extensions/recommendation/FilterSelectionDrawer.vue2.js +21 -34
  10. package/dist/components/organisms/extensions/recommendation/Filters.vue.js +9 -9
  11. package/dist/components/organisms/extensions/recommendation/Filters.vue2.js +35 -44
  12. package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
  13. package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +1 -1
  14. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +1 -1
  15. package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +2 -2
  16. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +1 -1
  17. package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +19 -19
  18. package/dist/composables/useStripo.js +25 -23
  19. package/dist/composables/useVersionHistoryApi.js +1 -1
  20. package/dist/config/i18n/en/index.js +11 -0
  21. package/dist/config/i18n/en/labels.json.js +7 -0
  22. package/dist/config/i18n/en/toasters.json.js +56 -0
  23. package/dist/config/i18n/en/tooltips.json.js +82 -0
  24. package/dist/config/i18n/index.js +7 -0
  25. package/dist/config/migrator/itemsBlockMigrator.js +65 -64
  26. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +39 -58
  27. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +57 -93
  28. package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +8 -8
  29. package/dist/extensions/Blocks/Unsubscribe/block.js +29 -29
  30. package/dist/extensions/Blocks/Unsubscribe/control.js +12 -9
  31. package/dist/extensions/Blocks/Unsubscribe/elements/preview.js +13 -11
  32. package/dist/extensions/Blocks/Unsubscribe/styles.css.js +31 -1
  33. package/dist/guido.css +1 -1
  34. package/dist/src/components/organisms/extensions/recommendation/FilterItem.vue.d.ts +0 -1
  35. package/dist/src/components/organisms/extensions/recommendation/Filters.vue.d.ts +1 -15
  36. package/dist/src/config/i18n/en/index.d.ts +1 -0
  37. package/dist/src/config/i18n/index.d.ts +16 -0
  38. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +0 -5
  39. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -18
  40. package/dist/src/extensions/Blocks/Unsubscribe/control.d.ts +1 -0
  41. package/dist/static/styles/components/notification.css.js +18 -0
  42. package/dist/static/styles/components/tools.css.js +6 -2
  43. package/dist/static/styles/variables.css.js +2 -0
  44. package/dist/stores/unsubscribe.js +37 -34
  45. package/package.json +2 -2
  46. package/dist/extensions/Blocks/Recommendation/validation/filterSchema.js +0 -29
  47. package/dist/src/extensions/Blocks/Recommendation/validation/filterSchema.d.ts +0 -15
@@ -1,8 +1,8 @@
1
- var m = Object.defineProperty;
2
- var h = (c, s, t) => s in c ? m(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
- var n = (c, s, t) => h(c, typeof s != "symbol" ? s + "" : s, t);
4
- import { CommonControl as f } from "../../../common-control.js";
5
- import { RecommendationConfigService as l } from "../../services/configService.js";
1
+ var d = Object.defineProperty;
2
+ var m = (c, s, t) => s in c ? d(c, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[s] = t;
3
+ var n = (c, s, t) => m(c, typeof s != "symbol" ? s + "" : s, t);
4
+ import { CommonControl as h } from "../../../common-control.js";
5
+ import { RecommendationConfigService as f } from "../../services/configService.js";
6
6
  import { useRecommendationExtensionStore as C } from "../../store/recommendation.js";
7
7
  import { AlgorithmControl as p } from "./algorithm.js";
8
8
  import { ALGORITHM_CONTROL_ID as W } from "./algorithm.js";
@@ -10,17 +10,17 @@ import { CurrencyControl as g } from "./currency.js";
10
10
  import { CURRENCY_CONTROL_ID as H } from "./currency.js";
11
11
  import { FiltersControl as R } from "./filters.js";
12
12
  import { FILTERS_CONTROL_ID as j } from "./filters.js";
13
- import { LocaleControl as N } from "./locale.js";
13
+ import { LocaleControl as y } from "./locale.js";
14
14
  import { LOCALE_CONTROL_ID as K } from "./locale.js";
15
- import { ProductLayoutControl as y } from "./productLayout.js";
15
+ import { ProductLayoutControl as _ } from "./productLayout.js";
16
16
  import { PRODUCT_LAYOUT_CONTROL_ID as J } from "./productLayout.js";
17
- import { ShuffleControl as _ } from "./shuffle.js";
17
+ import { ShuffleControl as N } from "./shuffle.js";
18
18
  import { SHUFFLE_CONTROL_ID as X } from "./shuffle.js";
19
- import { regenerateProductRowsWithStyles as b, getBlockElement as I, updateProductContentInPlace as P } from "./utils.js";
20
- import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as it, regenerateProductRows as nt, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
- import { useDebounceFn as u } from "../../../../../node_modules/@vueuse/shared/index.js";
19
+ import { regenerateProductRowsWithStyles as b, getBlockElement as P, updateProductContentInPlace as I } from "./utils.js";
20
+ import { formatProductPrice as tt, getCardComposition as et, getCurrentLayout as ot, reapplySpacing as rt, regenerateMobileProductRows as nt, regenerateProductRows as it, setCurrencyAttributes as st, updatePricesInPlace as ct, updateSingleProductContent as at } from "./utils.js";
21
+ import { useDebounceFn as l } from "../../../../../node_modules/@vueuse/shared/index.js";
22
22
  const T = "recommendation-id", S = "ui-elements-recommendation-block";
23
- class z extends f {
23
+ class $ extends h {
24
24
  constructor() {
25
25
  super(...arguments);
26
26
  n(this, "store", C());
@@ -36,19 +36,19 @@ class z extends f {
36
36
  /**
37
37
  * Debounced product fetch to prevent rapid API calls during config changes
38
38
  */
39
- n(this, "_debouncedFetchProducts", u(() => {
39
+ n(this, "_debouncedFetchProducts", l(() => {
40
40
  this.store.fetchRecommendationProducts();
41
41
  }, 500));
42
42
  /**
43
43
  * Debounced regeneration when products arrive from API
44
44
  * Tries in-place update first to preserve styles, falls back to full regeneration
45
45
  */
46
- n(this, "_debouncedRegenerateWithProducts", u(() => {
46
+ n(this, "_debouncedRegenerateWithProducts", l(() => {
47
47
  const t = this.store.recommendationProducts;
48
48
  if (!this.currentNode || !this.api)
49
49
  return;
50
50
  const e = this.api.getDocumentModifier();
51
- P({
51
+ I({
52
52
  currentNode: this.currentNode,
53
53
  documentModifier: e,
54
54
  products: t
@@ -59,7 +59,7 @@ class z extends f {
59
59
  return S;
60
60
  }
61
61
  getTemplate() {
62
- return this.algorithmControl = new p(), this.localeControl = new N(), this.currencyControl = new g(), this.productLayoutControl = new y(), this.filtersControl = new R(), this.shuffleControl = new _(), `
62
+ return this.algorithmControl = new p(), this.localeControl = new y(), this.currencyControl = new g(), this.productLayoutControl = new _(), this.filtersControl = new R(), this.shuffleControl = new N(), `
63
63
  <div class="recommendation-controls-container">
64
64
  ${this.algorithmControl.getTemplate()}
65
65
  ${this.localeControl.getTemplate()}
@@ -95,19 +95,19 @@ class z extends f {
95
95
  });
96
96
  }
97
97
  onTemplateNodeUpdated(t) {
98
- var r;
98
+ var i;
99
99
  super.onTemplateNodeUpdated(t);
100
100
  const e = this._getRecommendationIdFromNode(t);
101
- e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((r = this.store.blockStates[e]) != null && r.isInitialized) && this._fetchBlockData(e), [
101
+ e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), this._syncNodeConfigToStore(), e !== null && !((i = this.store.blockStates[e]) != null && i.isInitialized) && this._fetchBlockData(e), [
102
102
  this.algorithmControl,
103
103
  this.localeControl,
104
104
  this.currencyControl,
105
105
  this.productLayoutControl,
106
106
  this.filtersControl,
107
107
  this.shuffleControl
108
- ].forEach((i) => {
108
+ ].forEach((r) => {
109
109
  var a;
110
- i != null && i.api && (i.currentNode = t, (a = i.onTemplateNodeUpdated) == null || a.call(i, t));
110
+ r != null && r.api && (r.currentNode = t, (a = r.onTemplateNodeUpdated) == null || a.call(r, t));
111
111
  });
112
112
  }
113
113
  onDestroy() {
@@ -152,17 +152,13 @@ class z extends f {
152
152
  * values are being prepared for the upcoming initial fetch.
153
153
  */
154
154
  _syncNodeConfigToStore() {
155
- var r;
156
- const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
155
+ const t = f.getConfig(this.currentNode);
157
156
  this.store.patchCurrentBlockConfig({
158
157
  strategy: t.strategy,
159
158
  language: t.language,
160
159
  size: t.size,
161
160
  productIds: t.productIds,
162
- // Only sync filters from node config during initial load.
163
- // After initialization, the Pinia store is the source of truth
164
- // for filters (edited via the filter drawer).
165
- ...o ? {} : { filters: t.filters },
161
+ filters: t.filters,
166
162
  shuffleProducts: t.shuffleProducts,
167
163
  currencySettings: {
168
164
  name: t.currency.code,
@@ -185,26 +181,26 @@ class z extends f {
185
181
  this.store.fetchRecommendationFilters(),
186
182
  this.store.fetchRecommendationCreateData(),
187
183
  this.store.fetchRecommendationProducts()
188
- ])).forEach((o, r) => {
184
+ ])).forEach((o, i) => {
189
185
  o.status === "rejected" && console.warn(`Recommendation block: ${[
190
186
  "fetchRecommendationFilters",
191
187
  "fetchRecommendationCreateData",
192
188
  "fetchRecommendationProducts"
193
- ][r]} failed`, o.reason);
189
+ ][i]} failed`, o.reason);
194
190
  });
195
191
  }
196
192
  /**
197
193
  * Reads the recommendation-id attribute from the block element within the node
198
194
  */
199
195
  _getRecommendationIdFromNode(t) {
200
- const e = I(t);
196
+ const e = P(t);
201
197
  if (!e || !("getAttribute" in e))
202
198
  return null;
203
199
  const o = e.getAttribute(T);
204
200
  if (!o)
205
201
  return null;
206
- const r = parseInt(o);
207
- return Number.isNaN(r) ? null : r;
202
+ const i = parseInt(o);
203
+ return Number.isNaN(i) ? null : i;
208
204
  }
209
205
  /**
210
206
  * Listen to store changes that require product refresh or regeneration.
@@ -217,27 +213,12 @@ class z extends f {
217
213
  const { store: t } = this;
218
214
  let e = t.recommendationProducts, o = t.$state.configVersion;
219
215
  this.storeUnsubscription = t.$subscribe(() => {
220
- const r = t.$state.configVersion;
221
- r !== o && (o = r, this._persistFiltersToNodeConfig(), this._debouncedFetchProducts());
222
- const i = t.recommendationProducts, a = i !== e, d = Array.isArray(i) && i.length > 0;
223
- a && d && (e = i, this._debouncedRegenerateWithProducts());
216
+ const i = t.$state.configVersion;
217
+ i !== o && (o = i, this._debouncedFetchProducts());
218
+ const r = t.recommendationProducts, a = r !== e, u = Array.isArray(r) && r.length > 0;
219
+ a && u && (e = r, this._debouncedRegenerateWithProducts());
224
220
  });
225
221
  }
226
- /**
227
- * Persists the current filter state from Pinia store to the Stripo node config.
228
- * This ensures filters survive template save/reload cycles.
229
- */
230
- _persistFiltersToNodeConfig() {
231
- if (!this.currentNode || !this.api)
232
- return;
233
- const { filters: t } = this.store.recommendationConfigs;
234
- l.updateConfig(
235
- this.api,
236
- this.currentNode,
237
- { filters: t },
238
- "Update recommendation filters"
239
- );
240
- }
241
222
  }
242
223
  export {
243
224
  W as ALGORITHM_CONTROL_ID,
@@ -248,22 +229,22 @@ export {
248
229
  j as FILTERS_CONTROL_ID,
249
230
  R as FiltersControl,
250
231
  K as LOCALE_CONTROL_ID,
251
- N as LocaleControl,
232
+ y as LocaleControl,
252
233
  J as PRODUCT_LAYOUT_CONTROL_ID,
253
- y as ProductLayoutControl,
254
- z as RecommendationBlockControl,
234
+ _ as ProductLayoutControl,
235
+ $ as RecommendationBlockControl,
255
236
  X as SHUFFLE_CONTROL_ID,
256
- _ as ShuffleControl,
237
+ N as ShuffleControl,
257
238
  tt as formatProductPrice,
258
- I as getBlockElement,
239
+ P as getBlockElement,
259
240
  et as getCardComposition,
260
241
  ot as getCurrentLayout,
261
242
  rt as reapplySpacing,
262
- it as regenerateMobileProductRows,
263
- nt as regenerateProductRows,
243
+ nt as regenerateMobileProductRows,
244
+ it as regenerateProductRows,
264
245
  b as regenerateProductRowsWithStyles,
265
246
  st as setCurrencyAttributes,
266
247
  ct as updatePricesInPlace,
267
- P as updateProductContentInPlace,
248
+ I as updateProductContentInPlace,
268
249
  at as updateSingleProductContent
269
250
  };
@@ -1,15 +1,14 @@
1
- import { RecommendationFeedSourceMaps as d, getOperatorOptions as S, PriceAttributes as p } from "../../../../enums/extensions/recommendationBlock.js";
2
- import { useRecommendationApi as b } from "../../../../services/recommendationApi.js";
3
- import { useConfigStore as I } from "../../../../stores/config.js";
4
- import { defineStore as R } from "pinia";
5
- import { DEFAULT_CARDS_IN_ROW as k } from "../constants/layout.js";
6
- import { getDefaultProducts as C } from "../templates/utils.js";
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
7
  import { generateCompleteFilterQuery as f } from "../utils/filterUtil.js";
8
- import { isFilterValid as y } from "../validation/filterSchema.js";
9
- const m = b();
8
+ const m = p();
10
9
  function h() {
11
10
  return {
12
- cardsInRow: k,
11
+ cardsInRow: R,
13
12
  currencySettings: {
14
13
  name: "USD",
15
14
  value: "USD",
@@ -33,18 +32,17 @@ function h() {
33
32
  size: "6"
34
33
  };
35
34
  }
36
- function G() {
35
+ function C() {
37
36
  return {
38
37
  recommendationConfigs: h(),
39
38
  recommendationProducts: [],
40
39
  filterStatus: !1,
41
40
  filterSelectionDrawerStatus: !1,
42
41
  filterGroup: 1,
43
- isInitialized: !1,
44
- filterSnapshot: null
42
+ isInitialized: !1
45
43
  };
46
44
  }
47
- const F = () => ({
45
+ const y = () => ({
48
46
  recommendationCampaignUrls: {},
49
47
  activePredictiveAlgorithms: [],
50
48
  languages: {},
@@ -53,8 +51,8 @@ const F = () => ({
53
51
  blockStates: {},
54
52
  currentRecommendationId: null,
55
53
  configVersion: 0
56
- }), V = R("guidoRecommendationExtension", {
57
- state: () => F(),
54
+ }), A = I("guidoRecommendationExtension", {
55
+ state: () => y(),
58
56
  getters: {
59
57
  // ====================================================================
60
58
  // Proxy Getters — Backward Compatible Access to Current Block State
@@ -96,17 +94,9 @@ const F = () => ({
96
94
  hasFilters() {
97
95
  return !!this.recommendationConfigs.filters.length;
98
96
  },
99
- hasValidFilters() {
100
- const { filters: t } = this.recommendationConfigs;
101
- return t.length ? t.every((r) => r.isValid) : !1;
102
- },
103
97
  getFilterGroupCount() {
104
98
  const { filters: t } = this.recommendationConfigs;
105
- return t.length ? new Set(t.map((r) => r.filterGroup)).size : 0;
106
- },
107
- getUniqueFilterGroups() {
108
- const { filters: t } = this.recommendationConfigs;
109
- return [...new Set(t.map((r) => r.filterGroup))].sort((r, e) => r - e);
99
+ return t.length && t[t.length - 1].filterGroup || 0;
110
100
  },
111
101
  getActivePredictiveAlgorithms: (t) => {
112
102
  const r = [];
@@ -127,7 +117,7 @@ const F = () => ({
127
117
  })),
128
118
  getFilterList() {
129
119
  return Object.values(this.filterList).map((t) => {
130
- const r = t.type === "defaultAttribute", e = p.includes(t.attributeName);
120
+ const r = t.type === "defaultAttribute", e = S.includes(t.attributeName);
131
121
  let n = r ? t.attributeName : `product_attributes.${t.attributeName}`;
132
122
  return n = e ? `${n}.${this.recommendationConfigs.currencySettings.value}` : n, {
133
123
  text: t.displayName,
@@ -151,7 +141,7 @@ const F = () => ({
151
141
  setCurrentBlock(t) {
152
142
  this.blockStates[t] || (this.blockStates = {
153
143
  ...this.blockStates,
154
- [t]: G()
144
+ [t]: C()
155
145
  }), this.currentRecommendationId = t;
156
146
  },
157
147
  /**
@@ -191,56 +181,33 @@ const F = () => ({
191
181
  const { triggerRefetch: n = !0 } = r;
192
182
  n && this.configVersion++;
193
183
  },
194
- /**
195
- * Creates a filter with the first available attribute and operator pre-selected.
196
- */
197
- createDefaultFilter(t, r) {
198
- const [e] = this.getFilterList, [n] = S(e == null ? void 0 : e.type);
199
- return {
200
- type: "standardFilter",
201
- attribute: (e == null ? void 0 : e.value) ?? "",
202
- operator: (n == null ? void 0 : n.value) ?? "",
203
- innerGroupOperator: "*",
204
- outerGroupOperator: "*",
205
- filterNumber: r,
206
- filterGroup: t,
207
- isValid: !1,
208
- value: ""
209
- };
210
- },
211
184
  /**
212
185
  * Opens the filter selection drawer for the current block.
213
- * Saves a snapshot of current filters for cancel/revert.
214
- * If no filters exist, initializes with a default filter
186
+ * If no filters exist, initializes with a default empty filter
215
187
  * so the user has a starting point for input.
216
188
  */
217
189
  openFilterDrawer() {
218
190
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
219
191
  return;
220
192
  const t = this.blockStates[this.currentRecommendationId];
221
- t.filterSnapshot = JSON.parse(
222
- JSON.stringify(t.recommendationConfigs.filters)
223
- ), t.recommendationConfigs.filters.length || (t.recommendationConfigs.filters = [this.createDefaultFilter(1, 1)]), t.filterSelectionDrawerStatus = !0;
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;
224
205
  },
225
206
  /**
226
- * Closes the filter selection drawer for the current block.
227
- * Called after successful apply — discards the snapshot.
207
+ * Closes the filter selection drawer for the current block
228
208
  */
229
209
  closeFilterDrawer() {
230
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
231
- return;
232
- const t = this.blockStates[this.currentRecommendationId];
233
- t.filterSnapshot = null, t.filterSelectionDrawerStatus = !1;
234
- },
235
- /**
236
- * Cancels the filter selection drawer and reverts filters
237
- * to the snapshot taken when the drawer was opened.
238
- */
239
- cancelFilterDrawer() {
240
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
241
- return;
242
- const t = this.blockStates[this.currentRecommendationId];
243
- t.filterSnapshot !== null && (t.recommendationConfigs.filters = t.filterSnapshot, t.filterSnapshot = null), t.filterSelectionDrawerStatus = !1;
210
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].filterSelectionDrawerStatus = !1);
244
211
  },
245
212
  // ====================================================================
246
213
  // Shared Data Fetching (fetched once, used by all blocks)
@@ -267,18 +234,18 @@ const F = () => ({
267
234
  // Per-Block Filter Actions
268
235
  // ====================================================================
269
236
  addFilterGroup(t) {
270
- this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push(
271
- this.createDefaultFilter(t, 1)
272
- );
273
- },
274
- deleteFilterGroup(t) {
275
- if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
276
- return;
277
- 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), s = new Map(n.map((i, o) => [i, o + 1]));
278
- r.recommendationConfigs.filters = e.map((i) => ({
279
- ...i,
280
- filterGroup: s.get(i.filterGroup) ?? i.filterGroup
281
- }));
237
+ this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || this.blockStates[this.currentRecommendationId].recommendationConfigs.filters.push({
238
+ type: "standardFilter",
239
+ attribute: "",
240
+ operatorReplace: "",
241
+ operator: "",
242
+ innerGroupOperator: "",
243
+ outerGroupOperator: "",
244
+ value: "",
245
+ filterNumber: 1,
246
+ isValid: !0,
247
+ filterGroup: t
248
+ });
282
249
  },
283
250
  updateFilter(t) {
284
251
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
@@ -286,10 +253,7 @@ const F = () => ({
286
253
  const r = this.blockStates[this.currentRecommendationId], e = r.recommendationConfigs.filters.findIndex((n) => n.filterNumber === t.filterNumber && n.filterGroup === t.filterGroup);
287
254
  if (e !== -1) {
288
255
  const n = [...r.recommendationConfigs.filters];
289
- n[e] = {
290
- ...t,
291
- isValid: y(t)
292
- }, r.recommendationConfigs.filters = n;
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;
293
257
  }
294
258
  },
295
259
  deleteFilter(t) {
@@ -304,15 +268,15 @@ const F = () => ({
304
268
  addFilter(t) {
305
269
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
306
270
  return;
307
- const r = this.blockStates[this.currentRecommendationId], e = [...r.recommendationConfigs.filters], s = e.filter(
308
- (o) => o.filterGroup === t.filterGroup
309
- ).length + 1, i = e.findLastIndex((o) => o.filterGroup === t.filterGroup);
310
- i !== -1 ? e.splice(i + 1, 0, {
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, {
311
275
  ...t,
312
- filterNumber: s
276
+ filterNumber: o
313
277
  }) : e.push({
314
278
  ...t,
315
- filterNumber: s
279
+ filterNumber: o
316
280
  }), r.recommendationConfigs.filters = e;
317
281
  },
318
282
  generateFilterQuery() {
@@ -325,26 +289,26 @@ const F = () => ({
325
289
  var u;
326
290
  if (this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId])
327
291
  return;
328
- const t = this.currentRecommendationId, r = this.blockStates[t], { recommendationConfigs: e } = r, n = e.filters.filter((l) => l.isValid), s = f(n), i = ((u = d.find((l) => l.key === e.strategy)) == null ? void 0 : u.path) || "", o = I(), c = {
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 = {
329
293
  locale: e.language,
330
294
  currency: e.currencySettings.value,
331
- partnerName: o.partnerName,
295
+ partnerName: i.partnerName,
332
296
  size: e.size,
333
297
  details: !0,
334
- campaignId: o.variationId
298
+ campaignId: i.variationId
335
299
  };
336
- e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), s && (c.filter = s), e.shuffleProducts && (c.shuffle = !0);
300
+ e.strategy === "manualMerchandising" ? c.productId = e.productIds.join(",") : e.strategy === "similarViewed" && (c.productId = "{itemId}"), o && (c.filter = o), e.shuffleProducts && (c.shuffle = !0);
337
301
  const g = parseInt(e.size) || 6;
338
302
  let a;
339
303
  try {
340
- a = await m.fetchRecommendationProducts(i, c);
304
+ a = await m.fetchRecommendationProducts(s, c);
341
305
  } catch {
342
306
  a = [];
343
307
  }
344
- this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : C(g));
308
+ this.blockStates[t] && (this.blockStates[t].recommendationProducts = a.length > 0 ? a : k(g));
345
309
  }
346
310
  }
347
311
  });
348
312
  export {
349
- V as useRecommendationExtensionStore
313
+ A as useRecommendationExtensionStore
350
314
  };
@@ -1,22 +1,22 @@
1
1
  function l(t) {
2
2
  if (t.length === 0)
3
3
  return "";
4
- const o = t.sort((r, e) => r.filterNumber - e.filterNumber), n = o.map((r) => `[${r.attribute}][${r.operator}][${r.value}]`), [p, ...i] = n;
5
- let u = p;
6
- for (let r = 0; r < i.length; r++) {
7
- const e = o[r].innerGroupOperator;
8
- u += `${e}${i[r]}`;
4
+ const o = t.sort((r, e) => r.filterNumber - e.filterNumber), n = o.map((r) => `[${r.attribute}][${r.operatorReplace}][${r.value}]`), [i, ...p] = n;
5
+ let u = i;
6
+ for (let r = 0; r < p.length; r++) {
7
+ const e = o[r + 1].innerGroupOperator;
8
+ u += `${e}${p[r]}`;
9
9
  }
10
10
  return `(${u})`;
11
11
  }
12
12
  function f(t) {
13
13
  if (!t || t.length === 0)
14
14
  return "";
15
- const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), n = Object.keys(o).map(Number).sort((r, e) => r - e), p = n.map((r) => {
15
+ const o = t.reduce((r, e) => (r[e.filterGroup] || (r[e.filterGroup] = []), r[e.filterGroup].push(e), r), {}), n = Object.keys(o).map(Number).sort((r, e) => r - e), i = n.map((r) => {
16
16
  const e = o[r];
17
17
  return l(e);
18
- }), [i, ...u] = p;
19
- let s = i;
18
+ }), [p, ...u] = i;
19
+ let s = p;
20
20
  for (let r = 0; r < u.length; r++) {
21
21
  const e = n[r + 1], c = o[e][0].outerGroupOperator;
22
22
  s += `${c}${u[r]}`;
@@ -1,17 +1,17 @@
1
1
  var d = Object.defineProperty;
2
- var _ = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
- var u = (n, i, e) => _(n, typeof i != "symbol" ? i + "" : i, e);
2
+ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
3
+ var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
4
4
  import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
5
5
  import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
6
- import { Block as h, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
+ import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
7
  import { getDefaultTemplate as L } from "./template.js";
8
8
  import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
9
9
  import { parsePageList as p } from "./utils/utils.js";
10
- const g = "unsubscribe-block", v = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", T = {
10
+ const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
11
11
  [E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
12
12
  [E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
13
13
  };
14
- class R extends h {
14
+ class R extends _ {
15
15
  constructor() {
16
16
  super();
17
17
  u(this, "selectEventListener", null);
@@ -19,7 +19,7 @@ class R extends h {
19
19
  u(this, "currentNode");
20
20
  }
21
21
  getId() {
22
- return g;
22
+ return v;
23
23
  }
24
24
  getIcon() {
25
25
  return "unsubscribe-icon";
@@ -47,8 +47,8 @@ class R extends h {
47
47
  }
48
48
  _setupSelectEventListener() {
49
49
  this._removeSelectEventListener(), this.selectEventListener = (e) => {
50
- const s = e, { collectionType: t, selectedPages: r } = s.detail;
51
- this._updateBlock(t, r.join(","));
50
+ const r = e, { collectionType: s, selectedPages: t } = r.detail;
51
+ this._updateBlock(s, t.join(","));
52
52
  }, document.addEventListener(a.SELECT, this.selectEventListener);
53
53
  }
54
54
  _removeSelectEventListener() {
@@ -74,17 +74,17 @@ class R extends h {
74
74
  _removeEventListeners() {
75
75
  this._removeSelectEventListener(), this._removeCancelEventListener();
76
76
  }
77
- _updateBlock(e, s) {
77
+ _updateBlock(e, r) {
78
78
  if (!this.currentNode || !("querySelector" in this.currentNode))
79
79
  return;
80
- const t = this.currentNode.querySelector(v);
81
- if (!t)
80
+ const s = this.currentNode.querySelector(g);
81
+ if (!s)
82
82
  return;
83
- const r = this._getMergeTag(e);
84
- this.api.getDocumentModifier().modifyHtml(t).setAttribute("href", r).apply(new b(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, s).apply(new b("Updated unsubscribe block metadata"));
83
+ const t = this._getMergeTag(e);
84
+ this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
85
85
  }
86
86
  _getMergeTag(e) {
87
- return T[e] ?? B;
87
+ return B[e] ?? T;
88
88
  }
89
89
  _openDrawer() {
90
90
  if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
@@ -97,24 +97,24 @@ class R extends h {
97
97
  }
98
98
  _checkExistingBlocks() {
99
99
  const e = c();
100
- e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((t) => {
101
- if ("getAttribute" in t) {
102
- const r = t.getAttribute(o.PAGE_TYPE);
103
- if (r) {
104
- const l = Number(r);
100
+ e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
101
+ if ("getAttribute" in s) {
102
+ const t = s.getAttribute(o.PAGE_TYPE);
103
+ if (t) {
104
+ const l = Number(t);
105
105
  l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
106
106
  }
107
107
  }
108
108
  });
109
109
  }
110
- _loadBlockState(e) {
110
+ async _loadBlockState(e) {
111
111
  if (!("getAttribute" in e))
112
112
  return;
113
- const s = e.getAttribute(o.PAGE_TYPE), t = e.getAttribute(o.PAGE_LIST);
114
- if (!s || !t)
113
+ const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
114
+ if (!r || !s)
115
115
  return;
116
- const r = c(), l = Number(s), m = p(t);
117
- r.setCollectionWithoutAutoSelection(l), r.loadSelectedTemplates(m);
116
+ const t = c(), l = Number(r), m = p(s);
117
+ await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
118
118
  }
119
119
  _resetStoreState() {
120
120
  c().$reset();
@@ -122,14 +122,14 @@ class R extends h {
122
122
  _removeBlockTemplatesFromStore(e) {
123
123
  if (!("getAttribute" in e))
124
124
  return;
125
- const s = e.getAttribute(o.PAGE_LIST);
126
- if (!s)
125
+ const r = e.getAttribute(o.PAGE_LIST);
126
+ if (!r)
127
127
  return;
128
- const t = c(), r = p(s);
129
- t.removeUnsubscribePages(r);
128
+ const s = c(), t = p(r);
129
+ s.removeUnsubscribePages(t);
130
130
  }
131
131
  }
132
132
  export {
133
- g as UNSUBSCRIBE_BLOCK_ID,
133
+ v as UNSUBSCRIBE_BLOCK_ID,
134
134
  R as UnsubscribeBlock
135
135
  };