@useinsider/guido 3.18.1-beta.fefef3c → 3.18.2-beta.3e1d9ab

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 (56) hide show
  1. package/README.md +3 -21
  2. package/dist/@types/config/schemas.js +51 -59
  3. package/dist/components/Guido.vue.js +4 -4
  4. package/dist/components/Guido.vue2.js +53 -55
  5. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue.js +7 -7
  6. package/dist/components/organisms/extensions/recommendation/AssignStrategyDrawer.vue2.js +57 -82
  7. package/dist/components/organisms/extensions/recommendation/RemoveStrategyModal.vue2.js +22 -24
  8. package/dist/components/organisms/onboarding/OnboardingWrapper.vue2.js +24 -28
  9. package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +34 -34
  10. package/dist/composables/useCustomInterfaceAppearance.js +42 -46
  11. package/dist/composables/useHttp.js +24 -22
  12. package/dist/enums/extensions/recommendationBlock.js +14 -17
  13. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +85 -80
  14. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +28 -72
  15. package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +44 -45
  16. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +48 -93
  17. package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +7 -7
  18. package/dist/guido.css +1 -1
  19. package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +29 -28
  20. package/dist/package.json.js +1 -1
  21. package/dist/services/recommendationApi.js +84 -93
  22. package/dist/services/templateLibraryApi.js +17 -14
  23. package/dist/src/@types/config/schemas.d.ts +0 -16
  24. package/dist/src/composables/useConfig.d.ts +0 -4
  25. package/dist/src/enums/extensions/recommendationBlock.d.ts +0 -3
  26. package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +5 -1
  27. package/dist/src/extensions/Blocks/Recommendation/controls/main/strategy.d.ts +0 -2
  28. package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -4
  29. package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +13 -54
  30. package/dist/src/services/recommendationApi.d.ts +1 -2
  31. package/dist/src/stores/config.d.ts +0 -322
  32. package/dist/src/stores/onboarding.d.ts +10 -808
  33. package/dist/src/utils/genericUtil.d.ts +6 -0
  34. package/dist/src/utils/liquidDynamicContent.d.ts +20 -0
  35. package/dist/static/styles/components/recommendation-strategy.css.js +5 -70
  36. package/dist/stores/config.js +60 -74
  37. package/dist/stores/onboarding.js +36 -46
  38. package/dist/utils/genericUtil.js +63 -54
  39. package/dist/utils/liquidDynamicContent.js +15 -0
  40. package/dist/utils/templatePreparation.js +54 -52
  41. package/package.json +3 -3
  42. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.js +0 -18
  43. package/dist/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue2.js +0 -25
  44. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.js +0 -21
  45. package/dist/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue2.js +0 -46
  46. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.js +0 -21
  47. package/dist/components/organisms/onboarding/RecommendationStrategyOnboarding.vue2.js +0 -46
  48. package/dist/composables/useLegacyStrategyConversion.js +0 -61
  49. package/dist/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.js +0 -72
  50. package/dist/src/components/organisms/extensions/recommendation/LegacyStrategyUpdatedModal.vue.d.ts +0 -2
  51. package/dist/src/components/organisms/onboarding/RecommendationLegacyStrategyOnboarding.vue.d.ts +0 -2
  52. package/dist/src/components/organisms/onboarding/RecommendationStrategyOnboarding.vue.d.ts +0 -2
  53. package/dist/src/composables/useLegacyStrategyConversion.d.ts +0 -3
  54. package/dist/src/extensions/Blocks/Recommendation/utils/legacyStrategyMigration.d.ts +0 -44
  55. package/dist/static/assets/icons/filled-arrow-rising.svg.js +0 -5
  56. package/dist/static/assets/icons/line-info.svg.js +0 -5
@@ -1,14 +1,16 @@
1
- import { getCsrfToken as H } from "../utils/genericUtil.js";
2
- import { ref as p, computed as T } from "vue";
3
- const k = (b = {}) => {
4
- const h = p(!1), a = p(null), u = p(null), g = T(() => h.value), y = T(() => a.value !== null), v = {
1
+ import { getCsrfToken as O } from "../utils/genericUtil.js";
2
+ import { ref as m, computed as T } from "vue";
3
+ const X = (b = {}) => {
4
+ const p = m(!1), a = m(null), u = m(null), g = T(() => p.value), y = T(() => a.value !== null), v = {
5
5
  baseURL: "",
6
6
  timeout: 1e4,
7
7
  retry: 0,
8
8
  retryDelay: 1e3,
9
9
  headers: {
10
10
  "Content-Type": "application/json",
11
- "X-CSRF-TOKEN": H()
11
+ "X-CSRF-TOKEN": O(),
12
+ Accept: "application/json",
13
+ "X-Requested-With": "XMLHttpRequest"
12
14
  },
13
15
  ...b
14
16
  }, w = (e, s) => {
@@ -22,22 +24,22 @@ const k = (b = {}) => {
22
24
  }, e);
23
25
  }), x = (e) => new Promise((s) => {
24
26
  setTimeout(s, e);
25
- }), i = async (e, s, t, D = {}) => {
26
- a.value = null, h.value = !0, u.value = new AbortController();
27
- const n = { ...v, ...D }, L = w(s, n.baseURL), c = {
27
+ }), i = async (e, s, t, L = {}) => {
28
+ a.value = null, p.value = !0, u.value = new AbortController();
29
+ const n = { ...v, ...L }, D = w(s, n.baseURL), c = {
28
30
  method: e,
29
31
  headers: { ...n.headers },
30
32
  signal: u.value.signal,
31
33
  ...n
32
34
  };
33
35
  t && ["POST", "PUT", "PATCH"].includes(e) && (t instanceof FormData ? (delete c.headers["Content-Type"], c.body = t) : c.body = JSON.stringify(t));
34
- const E = async (m = 0) => {
36
+ const E = async (h = 0) => {
35
37
  try {
36
- const o = [fetch(L, c)];
38
+ const o = [fetch(D, c)];
37
39
  n.timeout && o.push(P(n.timeout));
38
40
  const r = await Promise.race(o);
39
41
  if (!r.ok) {
40
- const O = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(O);
42
+ const H = `HTTP Error: ${r.status} ${r.statusText}`, d = new Error(H);
41
43
  throw d.status = r.status, d.statusText = r.statusText, d.response = r, d;
42
44
  }
43
45
  let f;
@@ -50,19 +52,19 @@ const k = (b = {}) => {
50
52
  };
51
53
  } catch (o) {
52
54
  const r = o instanceof Error && o.name === "AbortError";
53
- if (m < (n.retry || 0) && !r)
54
- return await x(n.retryDelay || 1e3), E(m + 1);
55
+ if (h < (n.retry || 0) && !r)
56
+ return await x(n.retryDelay || 1e3), E(h + 1);
55
57
  throw o instanceof Error ? o.name === "AbortError" ? a.value = { message: "Request was cancelled" } : a.value = { message: o.message } : a.value = o, o;
56
58
  }
57
59
  };
58
60
  try {
59
61
  return await E();
60
62
  } finally {
61
- h.value = !1, u.value = null;
63
+ p.value = !1, u.value = null;
62
64
  }
63
- }, C = (e, s) => i("GET", e, void 0, s), $ = (e, s, t) => i("POST", e, s, t), R = (e, s, t) => i("PUT", e, s, t), U = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), W = (e) => {
65
+ }, C = (e, s) => i("GET", e, void 0, s), R = (e, s, t) => i("POST", e, s, t), $ = (e, s, t) => i("PUT", e, s, t), q = (e, s, t) => i("PATCH", e, s, t), A = (e, s) => i("DELETE", e, void 0, s), U = (e) => {
64
66
  u.value && u.value.abort(e);
65
- }, q = () => {
67
+ }, W = () => {
66
68
  a.value = null;
67
69
  };
68
70
  return {
@@ -73,14 +75,14 @@ const k = (b = {}) => {
73
75
  // Methods
74
76
  request: i,
75
77
  get: C,
76
- post: $,
77
- put: R,
78
- patch: U,
78
+ post: R,
79
+ put: $,
80
+ patch: q,
79
81
  delete: A,
80
- cancel: W,
81
- clearError: q
82
+ cancel: U,
83
+ clearError: W
82
84
  };
83
85
  };
84
86
  export {
85
- k as useHttp
87
+ X as useHttp
86
88
  };
@@ -4,11 +4,10 @@ const l = {
4
4
  // Relative path → same-origin as the embedding inone dashboard.
5
5
  PRODUCT_ATTRIBUTES_PATH: "/product-attributes/get-attributes",
6
6
  RECOMMENDATION_STRATEGIES_PATH: "/api/recommendation-strategies",
7
- RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies",
8
- NEWSLETTER_RECOMMENDATIONS_PATH: "/newsletter/recommendations"
9
- }, c = "migrate-strategies", d = "template", m = {
7
+ RECOMMENDATION_STRATEGIES_PANEL_PATH: "/discovery/recommendation-strategies"
8
+ }, c = {
10
9
  CLIENT_ID: "clientId"
11
- }, p = () => {
10
+ }, d = () => {
12
11
  const e = r();
13
12
  return [
14
13
  {
@@ -72,14 +71,14 @@ const l = {
72
71
  path: "top-sellers"
73
72
  }
74
73
  ];
75
- }, v = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], h = [
74
+ }, m = ["discount", "omnibus_price", "omnibus_discount", "price", "original_price"], p = [
76
75
  { text: "before the amount", value: "0" },
77
76
  { text: "after the amount", value: "1" }
78
- ], x = [
77
+ ], v = [
79
78
  { text: "dot(.)", value: "." },
80
79
  { text: "comma(,)", value: "," },
81
80
  { text: "space( )", value: " " }
82
- ], E = [
81
+ ], h = [
83
82
  { text: "0", value: "0" },
84
83
  { text: "1", value: "1" },
85
84
  { text: "2", value: "2" },
@@ -108,7 +107,7 @@ const l = {
108
107
  ], i = [
109
108
  { text: "true", value: "==" },
110
109
  { text: "false", value: "!=" }
111
- ], T = (e) => {
110
+ ], x = (e) => {
112
111
  if (!e)
113
112
  return t;
114
113
  switch (e) {
@@ -127,17 +126,15 @@ const l = {
127
126
  }
128
127
  };
129
128
  export {
130
- c as MIGRATE_STRATEGIES_SEGMENT,
131
129
  a as OP_ANY_OF,
132
- v as PriceAttributes,
133
- m as QUERY_PARAMS,
134
- d as TEMPLATE_MIGRATION_SCOPE_SEGMENT,
130
+ m as PriceAttributes,
131
+ c as QUERY_PARAMS,
135
132
  l as URLS,
136
- E as currencyDecimalCounts,
137
- h as currencyLocationMaps,
138
- x as currencyOperators,
139
- T as getOperatorOptions,
140
- p as getRecommendationFeedSourceMaps,
133
+ h as currencyDecimalCounts,
134
+ p as currencyLocationMaps,
135
+ v as currencyOperators,
136
+ x as getOperatorOptions,
137
+ d as getRecommendationFeedSourceMaps,
141
138
  n as operatorOptionsForArrayOfStrings,
142
139
  i as operatorOptionsForBooleans,
143
140
  s as operatorOptionsForDates,
@@ -1,6 +1,6 @@
1
1
  var m = Object.defineProperty;
2
- var C = (g, l, t) => l in g ? m(g, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[l] = t;
3
- var r = (g, l, t) => C(g, typeof l != "symbol" ? l + "" : l, t);
2
+ var C = (h, l, t) => l in h ? m(h, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : h[l] = t;
3
+ var n = (h, l, t) => C(h, typeof l != "symbol" ? l + "" : l, t);
4
4
  import { useConfig as p } from "../../../../../composables/useConfig.js";
5
5
  import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
6
6
  import { CommonControl as N } from "../../../common-control.js";
@@ -12,9 +12,9 @@ import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
12
  import { AlgorithmControl as T } from "./algorithm.js";
13
13
  import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
14
14
  import { CurrencyControl as P } from "./currency.js";
15
- import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
15
+ import { CURRENCY_CONTROL_ID as ht } from "./currency.js";
16
16
  import { FiltersControl as S } from "./filters.js";
17
- import { FILTERS_CONTROL_ID as ht } from "./filters.js";
17
+ import { FILTERS_CONTROL_ID as gt } from "./filters.js";
18
18
  import { LayoutOrientationControl as O } from "./layoutOrientation.js";
19
19
  import { LAYOUT_ORIENTATION_CONTROL_ID as Ct } from "./layoutOrientation.js";
20
20
  import { LocaleControl as L } from "./locale.js";
@@ -23,44 +23,42 @@ import { PricePlacementControl as E } from "./pricePlacement.js";
23
23
  import { PRICE_PLACEMENT_CONTROL_ID as _t } from "./pricePlacement.js";
24
24
  import { ProductCountControl as k } from "./productCount.js";
25
25
  import { PRODUCT_COUNT_CONTROL_ID as Rt } from "./productCount.js";
26
- import { ProductLayoutControl as D } from "./productLayout.js";
26
+ import { ProductLayoutControl as F } from "./productLayout.js";
27
27
  import { PRODUCT_LAYOUT_CONTROL_ID as Tt } from "./productLayout.js";
28
- import { ShuffleControl as F } from "./shuffle.js";
28
+ import { ShuffleControl as D } from "./shuffle.js";
29
29
  import { SHUFFLE_CONTROL_ID as St } from "./shuffle.js";
30
30
  import { StrategyControl as w } from "./strategy.js";
31
31
  import { STRATEGY_CONTROL_ID as Lt } from "./strategy.js";
32
- import { setCurrencyAttributes as A, getBlockElement as B, isPartnerManagedBlock as v, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
33
- import { adjustProductsToSize as kt, formatProductPrice as Dt, getCardComposition as Ft, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
32
+ import { setCurrencyAttributes as A, getBlockElement as v, isPartnerManagedBlock as x, updateProductContentInPlace as B, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as kt, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as vt, updatePricesInPlace as xt, updateSingleProductContent as Bt } from "./utils.js";
34
34
  import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
35
35
  const $ = "ui-elements-recommendation-block";
36
36
  class at extends N {
37
37
  constructor() {
38
38
  super(...arguments);
39
- r(this, "store", R());
40
- r(this, "storeUnsubscription", () => {
39
+ n(this, "store", R());
40
+ n(this, "storeUnsubscription", () => {
41
41
  });
42
- // blockId -> fingerprint of the node config as it looked at the last sync.
43
- r(this, "syncedConfigs", /* @__PURE__ */ new Map());
44
42
  // A config change waiting to reach the node config. Deferred so it can ride the
45
43
  // re-render's single apply() — one user action must cost one undo press.
46
- r(this, "pendingNodeConfigWrite", null);
47
- r(this, "pendingConfigFlushTimer", null);
44
+ n(this, "pendingNodeConfigWrite", null);
45
+ n(this, "pendingConfigFlushTimer", null);
48
46
  // Sub-control instances for lifecycle management
49
- r(this, "algorithmControl", null);
50
- r(this, "localeControl", null);
51
- r(this, "currencyControl", null);
52
- r(this, "productCountControl", null);
53
- r(this, "productLayoutControl", null);
54
- r(this, "filtersControl", null);
55
- r(this, "shuffleControl", null);
56
- r(this, "pricePlacementControl", null);
57
- r(this, "layoutOrientationControl", null);
58
- r(this, "strategyControl", null);
59
- r(this, "rrsEnabled", !1);
47
+ n(this, "algorithmControl", null);
48
+ n(this, "localeControl", null);
49
+ n(this, "currencyControl", null);
50
+ n(this, "productCountControl", null);
51
+ n(this, "productLayoutControl", null);
52
+ n(this, "filtersControl", null);
53
+ n(this, "shuffleControl", null);
54
+ n(this, "pricePlacementControl", null);
55
+ n(this, "layoutOrientationControl", null);
56
+ n(this, "strategyControl", null);
57
+ n(this, "rrsEnabled", !1);
60
58
  /**
61
59
  * Debounced product fetch to prevent rapid API calls during config changes
62
60
  */
63
- r(this, "_debouncedFetchProducts", f(async () => {
61
+ n(this, "_debouncedFetchProducts", f(async () => {
64
62
  try {
65
63
  await this.store.fetchRecommendationProducts();
66
64
  } finally {
@@ -78,16 +76,16 @@ class at extends N {
78
76
  * count. The store pads products to the configured size, so in-place only
79
77
  * fails when the size actually changed.
80
78
  */
81
- r(this, "_debouncedRegenerateWithProducts", f(() => {
79
+ n(this, "_debouncedRegenerateWithProducts", f(() => {
82
80
  const t = this.store.recommendationProducts;
83
81
  if (!this.currentNode || !this.api)
84
82
  return;
85
83
  const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
86
- if (v(this.currentNode)) {
84
+ if (x(this.currentNode)) {
87
85
  o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
88
86
  return;
89
87
  }
90
- x({
88
+ B({
91
89
  currentNode: this.currentNode,
92
90
  documentModifier: e,
93
91
  products: t
@@ -120,7 +118,7 @@ class at extends N {
120
118
  return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
121
119
  var o;
122
120
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
123
- }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new D(), this.filtersControl = new S(), this.shuffleControl = new F(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
121
+ }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new k(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
124
122
  e && (e.api = this.api);
125
123
  }), `
126
124
  <div class="recommendation-controls-container">
@@ -142,8 +140,8 @@ class at extends N {
142
140
  const e = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
143
141
  if (!e)
144
142
  return;
145
- const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
146
- e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
143
+ const o = this._getRecommendationIdFromNode(t) === null ? null : c.getConfig(t), r = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _);
144
+ e.classList.toggle("strategy-block", r);
147
145
  }
148
146
  async onRender() {
149
147
  var o;
@@ -161,9 +159,9 @@ class at extends N {
161
159
  const e = this._getRecommendationIdFromNode(t);
162
160
  e !== null && e !== this.store.currentRecommendationId && this.store.setCurrentBlock(e), e !== null && this._syncNodeConfigIfChanged(e), this._showControlsForBlock(t), e !== null && !((o = this.store.blockStates[e]) != null && o.isInitialized) && this._fetchBlockData(e).then(() => {
163
161
  this._initializeSubControls();
164
- }), this._subControls.forEach((n) => {
165
- var s;
166
- n != null && n.api && (n.currentNode = t, (s = n.onTemplateNodeUpdated) == null || s.call(n, t));
162
+ }), this._subControls.forEach((r) => {
163
+ var i;
164
+ r != null && r.api && (r.currentNode = t, (i = r.onTemplateNodeUpdated) == null || i.call(r, t));
167
165
  });
168
166
  }
169
167
  onDestroy() {
@@ -200,21 +198,29 @@ class at extends N {
200
198
  * fingerprint diff on this hook is the only way to notice (SD-149105).
201
199
  * An unchanged fingerprint means the move came from us, so runtime store
202
200
  * edits are never clobbered (SD-141049).
201
+ *
202
+ * The fingerprint is kept on the block's own store state so deleting the
203
+ * block drops it with the state it describes. A control-owned memo outlived
204
+ * that state and made a re-dropped saved module keep the defaults its wiped
205
+ * state was rebuilt with (SD-150347).
203
206
  */
204
207
  _syncNodeConfigIfChanged(t) {
205
208
  this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== t && this._flushPendingNodeConfig();
206
- const e = JSON.stringify(c.getConfig(this.currentNode)), o = this.syncedConfigs.get(t);
207
- this.syncedConfigs.set(t, e), o !== e && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
209
+ const e = this.store.blockStates[t];
210
+ if (!e)
211
+ return;
212
+ const o = JSON.stringify(c.getConfig(this.currentNode)), r = e.syncedConfigFingerprint;
213
+ e.syncedConfigFingerprint = o, r !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
208
214
  }
209
215
  _capturePendingNodeConfigWrite() {
210
216
  const t = this.store.currentRecommendationId;
211
217
  if (!this.currentNode || !this.api || t === null)
212
218
  return;
213
- const { filters: e, strategyId: o, size: n, nodeConfigVersion: s } = this.store.recommendationConfigs;
219
+ const { filters: e, strategyId: o, size: r } = this.store.recommendationConfigs;
214
220
  this.pendingNodeConfigWrite = {
215
221
  blockId: t,
216
222
  node: this.currentNode,
217
- updates: { filters: e, strategyId: o, size: n, configVersion: s }
223
+ updates: { filters: e, strategyId: o, size: r }
218
224
  };
219
225
  }
220
226
  /**
@@ -257,12 +263,11 @@ class at extends N {
257
263
  JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
258
264
  }
259
265
  _syncNodeConfigToStore() {
260
- var n;
261
- const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
266
+ var r;
267
+ const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((r = this.store.blockStates[e]) == null ? void 0 : r.isInitialized);
262
268
  this.store.patchCurrentBlockConfig({
263
269
  strategy: t.strategy,
264
270
  strategyId: t.strategyId,
265
- nodeConfigVersion: t.configVersion,
266
271
  language: t.language,
267
272
  size: t.size,
268
273
  productIds: t.productIds,
@@ -301,8 +306,8 @@ class at extends N {
301
306
  t !== null && this.store.markBlockInitialized(t), (await Promise.allSettled([
302
307
  this.store.fetchRecommendationCreateData(),
303
308
  this.store.fetchRecommendationFilters()
304
- ])).forEach((o, n) => {
305
- o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][n]} failed`, o.reason);
309
+ ])).forEach((o, r) => {
310
+ o.status === "rejected" && console.warn(`Recommendation block: ${["fetchRecommendationCreateData", "fetchRecommendationFilters"][r]} failed`, o.reason);
306
311
  }), this._applySmartDefaults();
307
312
  try {
308
313
  await this.store.fetchRecommendationProducts();
@@ -324,30 +329,30 @@ class at extends N {
324
329
  if (!this.currentNode || !this.api)
325
330
  return;
326
331
  const t = c.getConfig(this.currentNode), e = {};
327
- let o = null, n = null, s = null;
332
+ let o = null, r = null, i = null;
328
333
  if (t.currency.code === a.currency.code) {
329
- const { currencyList: i } = this.store;
330
- i.length > 0 && (i.some(
334
+ const { currencyList: s } = this.store;
335
+ s.length > 0 && (s.some(
331
336
  (d) => d.value === `price.${a.currency.code}`
332
- ) || (o = i[0].value.replace("price.", ""), e.currency = {
337
+ ) || (o = s[0].value.replace("price.", ""), e.currency = {
333
338
  ...a.currency,
334
339
  code: o,
335
340
  symbol: o
336
341
  }));
337
342
  }
338
343
  if (t.strategy === a.strategy) {
339
- const i = this.store.getActivePredictiveAlgorithms;
340
- i.length > 0 && (i.some(
344
+ const s = this.store.getActivePredictiveAlgorithms;
345
+ s.length > 0 && (s.some(
341
346
  (d) => d.value === a.strategy
342
- ) || (n = i[0].value, e.strategy = n));
347
+ ) || (r = s[0].value, e.strategy = r));
343
348
  }
344
349
  if (t.language === a.language) {
345
- const i = this.store.getLanguages;
346
- i.length > 0 && (i.some(
350
+ const s = this.store.getLanguages;
351
+ s.length > 0 && (s.some(
347
352
  (d) => d.value === a.language
348
- ) || (s = i[0].value, e.language = s));
353
+ ) || (i = s[0].value, e.language = i));
349
354
  }
350
- !o && !n && !s || (c.updateConfig(
355
+ !o && !r && !i || (c.updateConfig(
351
356
  this.api,
352
357
  this.currentNode,
353
358
  e,
@@ -368,22 +373,22 @@ class at extends N {
368
373
  thousandSeparator: a.currency.thousandSeparator
369
374
  }
370
375
  } : {},
371
- ...n ? { strategy: n } : {},
372
- ...s ? { language: s } : {}
376
+ ...r ? { strategy: r } : {},
377
+ ...i ? { language: i } : {}
373
378
  }, { triggerRefetch: !1 }));
374
379
  }
375
380
  /**
376
381
  * Reads the recommendation-id attribute from the block element within the node
377
382
  */
378
383
  _getRecommendationIdFromNode(t) {
379
- const e = B(t);
384
+ const e = v(t);
380
385
  if (!e || !("getAttribute" in e))
381
386
  return null;
382
387
  const o = e.getAttribute(I);
383
388
  if (!o)
384
389
  return null;
385
- const n = parseInt(o);
386
- return Number.isNaN(n) ? null : n;
390
+ const r = parseInt(o);
391
+ return Number.isNaN(r) ? null : r;
387
392
  }
388
393
  /**
389
394
  * Listen to store changes that require product refresh or regeneration.
@@ -400,17 +405,17 @@ class at extends N {
400
405
  */
401
406
  _listenStateUpdates() {
402
407
  const { store: t } = this;
403
- let e = t.recommendationProducts, o = t.$state.configVersion, n = t.currentRecommendationId;
408
+ let e = t.recommendationProducts, o = t.$state.configVersion, r = t.currentRecommendationId;
404
409
  this.storeUnsubscription = t.$subscribe(() => {
405
- const s = t.currentRecommendationId;
406
- if (s !== n) {
407
- n = s, e = t.recommendationProducts, o = t.$state.configVersion;
410
+ const i = t.currentRecommendationId;
411
+ if (i !== r) {
412
+ r = i, e = t.recommendationProducts, o = t.$state.configVersion;
408
413
  return;
409
414
  }
410
- const i = t.$state.configVersion;
411
- i !== o && (o = i, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
412
- const u = t.recommendationProducts, d = u !== e, h = Array.isArray(u) && u.length > 0;
413
- d && h && (e = u, this._debouncedRegenerateWithProducts());
415
+ const s = t.$state.configVersion;
416
+ s !== o && (o = s, this._capturePendingNodeConfigWrite(), this._debouncedFetchProducts());
417
+ const u = t.recommendationProducts, d = u !== e, g = Array.isArray(u) && u.length > 0;
418
+ d && g && (e = u, this._debouncedRegenerateWithProducts());
414
419
  });
415
420
  }
416
421
  }
@@ -418,9 +423,9 @@ export {
418
423
  ut as ALGORITHM_CONTROL_ID,
419
424
  T as AlgorithmControl,
420
425
  $ as CONTROL_BLOCK_ID,
421
- gt as CURRENCY_CONTROL_ID,
426
+ ht as CURRENCY_CONTROL_ID,
422
427
  P as CurrencyControl,
423
- ht as FILTERS_CONTROL_ID,
428
+ gt as FILTERS_CONTROL_ID,
424
429
  S as FiltersControl,
425
430
  Ct as LAYOUT_ORIENTATION_CONTROL_ID,
426
431
  yt as LOCALE_CONTROL_ID,
@@ -431,23 +436,23 @@ export {
431
436
  Tt as PRODUCT_LAYOUT_CONTROL_ID,
432
437
  E as PricePlacementControl,
433
438
  k as ProductCountControl,
434
- D as ProductLayoutControl,
439
+ F as ProductLayoutControl,
435
440
  at as RecommendationBlockControl,
436
441
  St as SHUFFLE_CONTROL_ID,
437
442
  Lt as STRATEGY_CONTROL_ID,
438
- F as ShuffleControl,
443
+ D as ShuffleControl,
439
444
  w as StrategyControl,
440
445
  kt as adjustProductsToSize,
441
- Dt as formatProductPrice,
442
- B as getBlockElement,
443
- Ft as getCardComposition,
446
+ Ft as formatProductPrice,
447
+ v as getBlockElement,
448
+ Dt as getCardComposition,
444
449
  wt as getCurrentLayout,
445
450
  At as getMainContainerTbody,
446
- v as isPartnerManagedBlock,
447
- Bt as regenerateMobileProductRows,
451
+ x as isPartnerManagedBlock,
452
+ vt as regenerateMobileProductRows,
448
453
  U as regenerateProductRowsWithStyles,
449
454
  A as setCurrencyAttributes,
450
- vt as updatePricesInPlace,
451
- x as updateProductContentInPlace,
452
- xt as updateSingleProductContent
455
+ xt as updatePricesInPlace,
456
+ B as updateProductContentInPlace,
457
+ Bt as updateSingleProductContent
453
458
  };
@@ -1,32 +1,26 @@
1
- var p = Object.defineProperty;
2
- var v = (i, s, t) => s in i ? p(i, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[s] = t;
3
- var r = (i, s, t) => v(i, typeof s != "symbol" ? s + "" : s, t);
4
- import { useLegacyStrategyConversion as _ } from "../../../../../composables/useLegacyStrategyConversion.js";
5
- import { ACADEMY_LINKS as b } from "../../../../../enums/academy.js";
6
- import { useOnboardingStore as S } from "../../../../../stores/onboarding.js";
7
- import { CommonControl as f } from "../../../common-control.js";
8
- import { useRecommendationExtensionStore as $ } from "../../store/recommendation.js";
9
- const C = "recommendation-strategy-control";
10
- class N extends f {
1
+ var d = Object.defineProperty;
2
+ var y = (r, s, t) => s in r ? d(r, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[s] = t;
3
+ var o = (r, s, t) => y(r, typeof s != "symbol" ? s + "" : s, t);
4
+ import { ACADEMY_LINKS as m } from "../../../../../enums/academy.js";
5
+ import { CommonControl as h } from "../../../common-control.js";
6
+ import { useRecommendationExtensionStore as u } from "../../store/recommendation.js";
7
+ const p = "recommendation-strategy-control";
8
+ class f extends h {
11
9
  constructor() {
12
10
  super(...arguments);
13
- r(this, "store", $());
14
- r(this, "onboardingStore", S());
15
- r(this, "legacyConversion", _());
16
- r(this, "storeUnsubscription", () => {
11
+ o(this, "store", u());
12
+ o(this, "storeUnsubscription", () => {
17
13
  });
18
- r(this, "listeners", []);
19
- r(this, "lastPaintedState", null);
14
+ o(this, "listeners", []);
15
+ o(this, "lastPaintedState", null);
20
16
  }
21
17
  getId() {
22
- return C;
18
+ return p;
23
19
  }
24
20
  getTemplate() {
25
21
  const t = this.api.translate(
26
22
  "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
27
- ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), n = this.api.translate(
28
- "Note that this is an older version of the Recommendation Strategy. We recommend you update it to the new Recommendation Strategy for an improved experience."
29
- );
23
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy");
30
24
  return `
31
25
  <div class="strategy-control-container">
32
26
  <div class="strategy-control-header">
@@ -37,7 +31,7 @@ class N extends f {
37
31
  ${t}
38
32
  ${e}
39
33
  <a
40
- href="${b.EMAIL_RECOMMENDATION_BLOCK}"
34
+ href="${m.EMAIL_RECOMMENDATION_BLOCK}"
41
35
  target="_blank"
42
36
  rel="noopener noreferrer">${a}</a>.
43
37
  </p>
@@ -59,33 +53,6 @@ class N extends f {
59
53
  })
60
54
  ], "strategy-control-cta-row")}
61
55
  </div>
62
- <div data-strategy-legacy-state style="display: none;">
63
- <div class="strategy-control-notice-row">
64
- <div class="strategy-control-notice">
65
- <p class="strategy-control-notice-text">${n}</p>
66
- </div>
67
- </div>
68
- <div class="strategy-control-name-band">
69
- <span class="strategy-control-name">${o}</span>
70
- ${this._strategyAction({
71
- id: "guido__btn-update-legacy-strategy",
72
- label: this.api.translate("Update"),
73
- modifier: "update"
74
- })}
75
- </div>
76
- <div class="strategy-control-actions">
77
- ${this._strategyAction({
78
- id: "guido__btn-change-legacy-strategy",
79
- label: this.api.translate("Change"),
80
- modifier: "change"
81
- })}
82
- ${this._strategyAction({
83
- id: "guido__btn-remove-legacy-strategy",
84
- label: this.api.translate("Remove"),
85
- modifier: "remove"
86
- })}
87
- </div>
88
- </div>
89
56
  <div data-strategy-assigned-state style="display: none;">
90
57
  <div class="strategy-control-name-band">
91
58
  <span class="strategy-control-name" data-strategy-name></span>
@@ -121,8 +88,6 @@ class N extends f {
121
88
  this._renderState();
122
89
  }), this.store.recommendationConfigs.strategyId && !this.store.strategies.length && this.store.fetchStrategies().catch(() => {
123
90
  });
124
- const t = this.store.currentRecommendationId, e = t !== null && !!this.store.blockStates[t], a = this.store.isLegacyStrategyBlock;
125
- e && !this.store.recommendationConfigs.strategyId && !a && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding"), e && a && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding");
126
91
  }
127
92
  onDestroy() {
128
93
  this._teardown();
@@ -135,34 +100,25 @@ class N extends f {
135
100
  const t = this.getContainer();
136
101
  if (!t)
137
102
  return;
138
- const e = (a, o) => {
139
- const n = t.querySelector(a);
140
- n && (n.addEventListener("click", o), this.listeners.push({ element: n, handler: o }));
103
+ const e = (a, n) => {
104
+ const i = t.querySelector(a);
105
+ i && (i.addEventListener("click", n), this.listeners.push({ element: i, handler: n }));
141
106
  };
142
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-legacy-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-remove-legacy-strategy", () => this.store.openRemoveStrategyModal()), e("#guido__btn-update-legacy-strategy", () => {
143
- this.legacyConversion.convertLegacyStrategy();
144
- });
107
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-change-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-remove-strategy", () => this.store.openRemoveStrategyModal());
145
108
  }
146
109
  _renderState() {
147
- var h;
148
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((h = this.store.assignedStrategy) == null ? void 0 : h.name) ?? "" : "", a = this.store.legacyConversionLoading, o = this.store.isLegacyStrategyBlock, n = `${t}\0${e}\0${a}\0${o}`;
149
- if (n === this.lastPaintedState)
150
- return;
151
- const c = this.getContainer();
152
- if (!c)
110
+ var l;
111
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((l = this.store.assignedStrategy) == null ? void 0 : l.name) ?? "" : "", a = `${t}\0${e}`;
112
+ if (a === this.lastPaintedState)
153
113
  return;
154
- const d = c.querySelector("[data-strategy-empty-state]"), y = c.querySelector("[data-strategy-assigned-state]"), g = c.querySelector("[data-strategy-legacy-state]"), m = c.querySelector("[data-strategy-name]");
155
- if (!d || !y || !g)
114
+ const n = this.getContainer();
115
+ if (!n)
156
116
  return;
157
- const u = t ? y : o ? g : d;
158
- [d, y, g].forEach((l) => {
159
- l.style.display = l === u ? "" : "none";
160
- }), g.querySelectorAll("button").forEach((l) => {
161
- l.disabled = a;
162
- }), g.classList.toggle("is-converting", a), m && t && (m.textContent = e || `#${t}`), this.lastPaintedState = n;
117
+ const i = n.querySelector("[data-strategy-empty-state]"), c = n.querySelector("[data-strategy-assigned-state]"), g = n.querySelector("[data-strategy-name]");
118
+ !i || !c || (i.style.display = t ? "none" : "", c.style.display = t ? "" : "none", g && t && (g.textContent = e || `#${t}`), this.lastPaintedState = a);
163
119
  }
164
120
  }
165
121
  export {
166
- C as STRATEGY_CONTROL_ID,
167
- N as StrategyControl
122
+ p as STRATEGY_CONTROL_ID,
123
+ f as StrategyControl
168
124
  };