@useinsider/guido 3.19.0-beta.acb00a2 → 3.19.0-beta.b539426

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 (65) hide show
  1. package/dist/@types/config/schemas.js +104 -91
  2. package/dist/components/Guido.vue.js +8 -8
  3. package/dist/components/Guido.vue2.js +85 -86
  4. package/dist/components/organisms/base/AuthErrorModal.vue.js +18 -0
  5. package/dist/components/organisms/base/AuthErrorModal.vue2.js +42 -0
  6. package/dist/components/organisms/header/EditorActions.vue.js +4 -4
  7. package/dist/components/organisms/header/EditorActions.vue2.js +23 -25
  8. package/dist/components/wrappers/WpModal.vue.js +1 -1
  9. package/dist/components/wrappers/WpModal.vue2.js +4 -3
  10. package/dist/composables/useActionsApi.js +44 -43
  11. package/dist/composables/useAuthError.js +52 -0
  12. package/dist/composables/useAutoSave.js +11 -11
  13. package/dist/composables/useCodeEditorApi.js +23 -9
  14. package/dist/composables/useCortexBlueprintBridge.js +54 -122
  15. package/dist/composables/useEmailTemplateApplier.js +52 -108
  16. package/dist/composables/useHttp.js +64 -54
  17. package/dist/composables/useLegacyStrategyConversion.js +23 -19
  18. package/dist/composables/useStripo.js +24 -20
  19. package/dist/composables/useToaster.js +17 -15
  20. package/dist/composables/useTranslations.js +3 -2
  21. package/dist/composables/useVersionHistoryApi.js +33 -24
  22. package/dist/composables/validators/useLiquidValidator.js +15 -15
  23. package/dist/config/migrator/index.js +14 -13
  24. package/dist/config/migrator/recommendationMigrator.js +28 -21
  25. package/dist/config/migrator/recommendationPartnerMigrator.js +56 -0
  26. package/dist/enums/extensions/recommendationBlock.js +30 -29
  27. package/dist/extensions/Blocks/Recommendation/block.js +15 -14
  28. package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +105 -96
  29. package/dist/extensions/Blocks/Recommendation/controls/main/index.js +45 -38
  30. package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +72 -49
  31. package/dist/extensions/Blocks/Recommendation/store/recommendation.js +30 -29
  32. package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +72 -70
  33. package/dist/extensions/Blocks/Recommendation/utils/compositionKeys.js +69 -60
  34. package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +25 -0
  35. package/dist/guido.css +1 -1
  36. package/dist/src/@types/config/schemas.d.ts +16 -0
  37. package/dist/src/components/organisms/base/AuthErrorModal.vue.d.ts +2 -0
  38. package/dist/src/components/wrappers/WpModal.vue.d.ts +5 -1
  39. package/dist/src/composables/useAuthError.d.ts +12 -0
  40. package/dist/src/composables/useConfig.d.ts +2 -0
  41. package/dist/src/composables/useCortexBlueprintBridge.d.ts +3 -2
  42. package/dist/src/composables/useEmailTemplateApplier.d.ts +5 -18
  43. package/dist/src/composables/useGuidoActions.d.ts +2 -0
  44. package/dist/src/composables/useHttp.d.ts +2 -0
  45. package/dist/src/config/migrator/index.d.ts +2 -1
  46. package/dist/src/config/migrator/recommendationPartnerMigrator.d.ts +19 -0
  47. package/dist/src/enums/extensions/recommendationBlock.d.ts +1 -1
  48. package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +2 -0
  49. package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +6 -0
  50. package/dist/src/extensions/Blocks/Recommendation/utils/compositionKeys.d.ts +4 -0
  51. package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +33 -0
  52. package/dist/src/mock/cortexChatStore.d.ts +12 -0
  53. package/dist/src/stores/config.d.ts +20 -0
  54. package/dist/src/stores/guido-email-editor.d.ts +10 -20
  55. package/dist/src/stores/onboarding.d.ts +4 -0
  56. package/dist/src/stores/recommendation.d.ts +5 -0
  57. package/dist/src/utils/dateUtil.d.ts +10 -0
  58. package/dist/src/utils/genericUtil.d.ts +3 -0
  59. package/dist/src/utils/stripoEditorApi.d.ts +4 -0
  60. package/dist/static/styles/components/recommendation-strategy.css.js +9 -0
  61. package/dist/stores/guido-email-editor.js +1 -3
  62. package/dist/stores/onboarding.js +4 -0
  63. package/dist/stores/unsubscribe.js +3 -3
  64. package/dist/utils/stripoEditorApi.js +11 -0
  65. package/package.json +2 -1
@@ -1,16 +1,16 @@
1
- var m = Object.defineProperty;
2
- var C = (g, c, t) => c in g ? m(g, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[c] = t;
3
- var i = (g, c, t) => C(g, typeof c != "symbol" ? c + "" : c, t);
4
- import { useConfig as p } from "../../../../../composables/useConfig.js";
1
+ var C = Object.defineProperty;
2
+ var p = (g, u, t) => u in g ? C(g, u, { enumerable: !0, configurable: !0, writable: !0, value: t }) : g[u] = t;
3
+ var i = (g, u, t) => p(g, typeof u != "symbol" ? u + "" : u, t);
4
+ import { useConfig as h } 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";
7
7
  import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as a } from "../../constants/defaultConfig.js";
8
8
  import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
9
- import { RecommendationConfigService as l } from "../../services/configService.js";
9
+ import { RecommendationConfigService as c } from "../../services/configService.js";
10
10
  import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
11
  import { registerNodeConfigWriter as b } from "../../utils/nodeConfigWriter.js";
12
12
  import { AlgorithmControl as T } from "./algorithm.js";
13
- import { ALGORITHM_CONTROL_ID as dt } from "./algorithm.js";
13
+ import { ALGORITHM_CONTROL_ID as ut } from "./algorithm.js";
14
14
  import { CurrencyControl as P } from "./currency.js";
15
15
  import { CURRENCY_CONTROL_ID as gt } from "./currency.js";
16
16
  import { FiltersControl as S } from "./filters.js";
@@ -29,9 +29,9 @@ 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 Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as At, regenerateMobileProductRows as Bt, updatePricesInPlace as vt, updateSingleProductContent as xt } from "./utils.js";
34
- import { useDebounceFn as h } from "../../../../../node_modules/@vueuse/shared/index.js";
32
+ import { setCurrencyAttributes as v, getBlockElement as A, isPartnerManagedBlock as B, updateProductContentInPlace as x, regenerateProductRowsWithStyles as U } from "./utils.js";
33
+ import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as vt, regenerateMobileProductRows as At, updatePricesInPlace as Bt, updateSingleProductContent as xt } from "./utils.js";
34
+ import { useDebounceFn as f } from "../../../../../node_modules/@vueuse/shared/index.js";
35
35
  const W = "ui-elements-recommendation-block";
36
36
  class at extends N {
37
37
  constructor() {
@@ -58,7 +58,7 @@ class at extends N {
58
58
  /**
59
59
  * Debounced product fetch to prevent rapid API calls during config changes
60
60
  */
61
- i(this, "_debouncedFetchProducts", h(async () => {
61
+ i(this, "_debouncedFetchProducts", f(async () => {
62
62
  try {
63
63
  await this.store.fetchRecommendationProducts();
64
64
  } finally {
@@ -76,12 +76,12 @@ class at extends N {
76
76
  * count. The store pads products to the configured size, so in-place only
77
77
  * fails when the size actually changed.
78
78
  */
79
- i(this, "_debouncedRegenerateWithProducts", h(() => {
79
+ i(this, "_debouncedRegenerateWithProducts", f(() => {
80
80
  const t = this.store.recommendationProducts;
81
81
  if (!this.currentNode || !this.api)
82
82
  return;
83
83
  const e = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(e);
84
- if (v(this.currentNode)) {
84
+ if (B(this.currentNode)) {
85
85
  o && (e.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
86
86
  return;
87
87
  }
@@ -115,7 +115,7 @@ class at extends N {
115
115
  }
116
116
  getTemplate() {
117
117
  var t;
118
- return this.rrsEnabled = p().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
118
+ return this.rrsEnabled = h().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((e) => {
119
119
  var o;
120
120
  return (o = e == null ? void 0 : e.onDestroy) == null ? void 0 : o.call(e);
121
121
  }), this.algorithmControl = new T(), this.localeControl = new L(), this.currencyControl = new P(), this.productCountControl = new E(), this.productLayoutControl = new F(), this.filtersControl = new S(), this.shuffleControl = new D(), this.pricePlacementControl = new k(), this.layoutOrientationControl = new O(), this.strategyControl = this.rrsEnabled ? new w() : null, this._subControls.forEach((e) => {
@@ -140,7 +140,7 @@ class at extends N {
140
140
  const e = (r = this.getContainer()) == null ? void 0 : r.querySelector(".recommendation-controls-container");
141
141
  if (!e)
142
142
  return;
143
- const o = this._getRecommendationIdFromNode(t) === null ? null : l.getConfig(t), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
143
+ 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;
144
144
  e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
145
145
  }
146
146
  async onRender() {
@@ -209,23 +209,30 @@ class at extends N {
209
209
  const e = this.store.blockStates[t];
210
210
  if (!e)
211
211
  return;
212
- const o = JSON.stringify(l.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
212
+ const o = JSON.stringify(c.getConfig(this.currentNode)), n = e.syncedConfigFingerprint;
213
213
  e.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
214
214
  }
215
215
  /** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
216
216
  _isPendingStrategyIdChange() {
217
217
  const t = this.pendingNodeConfigWrite;
218
- return t ? l.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
218
+ return t ? c.getConfig(this.currentNode).strategyId !== t.updates.strategyId : !1;
219
219
  }
220
220
  _capturePendingNodeConfigWrite() {
221
221
  const t = this.store.currentRecommendationId;
222
222
  if (!this.currentNode || !this.api || t === null)
223
223
  return;
224
- const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs;
224
+ const { filters: e, strategy: o, strategyId: n, size: s, nodeConfigVersion: r } = this.store.recommendationConfigs, { partnerName: l } = h();
225
225
  this.pendingNodeConfigWrite = {
226
226
  blockId: t,
227
227
  node: this.currentNode,
228
- updates: { filters: e, strategy: o, strategyId: n, size: s, configVersion: r }
228
+ updates: {
229
+ filters: e,
230
+ strategy: o,
231
+ strategyId: n,
232
+ size: s,
233
+ configVersion: r,
234
+ ...l.value ? { partnerName: l.value } : {}
235
+ }
229
236
  };
230
237
  }
231
238
  /**
@@ -240,7 +247,7 @@ class at extends N {
240
247
  */
241
248
  _stagePendingNodeConfig(t) {
242
249
  const e = this.pendingNodeConfigWrite;
243
- return !e || !this.currentNode ? !1 : (l.stageConfig(t, this.currentNode, e.updates), !0);
250
+ return !e || !this.currentNode ? !1 : (c.stageConfig(t, this.currentNode, e.updates), !0);
244
251
  }
245
252
  /**
246
253
  * Arms the guaranteed fallback write, once the product fetch has settled. The
@@ -264,12 +271,12 @@ class at extends N {
264
271
  const t = this.pendingNodeConfigWrite;
265
272
  if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
266
273
  return;
267
- const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = l.getConfig(e);
268
- JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || l.updateConfig(this.api, e, t.updates, "Update recommendation filters");
274
+ const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o = c.getConfig(e);
275
+ JSON.stringify(o.filters) === JSON.stringify(t.updates.filters) && o.strategy === t.updates.strategy && o.strategyId === t.updates.strategyId && o.size === t.updates.size || c.updateConfig(this.api, e, t.updates, "Update recommendation filters");
269
276
  }
270
277
  _syncNodeConfigToStore() {
271
278
  var n;
272
- const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
279
+ const t = c.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
273
280
  this.store.patchCurrentBlockConfig({
274
281
  strategy: t.strategy,
275
282
  strategyId: t.strategyId,
@@ -334,12 +341,12 @@ class at extends N {
334
341
  _applySmartDefaults() {
335
342
  if (!this.currentNode || !this.api)
336
343
  return;
337
- const t = l.getConfig(this.currentNode), e = {};
344
+ const t = c.getConfig(this.currentNode), e = {};
338
345
  let o = null, n = null, s = null;
339
346
  if (t.currency.code === a.currency.code) {
340
347
  const { currencyList: r } = this.store;
341
348
  r.length > 0 && (r.some(
342
- (u) => u.value === `price.${a.currency.code}`
349
+ (d) => d.value === `price.${a.currency.code}`
343
350
  ) || (o = r[0].value.replace("price.", ""), e.currency = {
344
351
  ...a.currency,
345
352
  code: o,
@@ -349,21 +356,21 @@ class at extends N {
349
356
  if (t.strategy === a.strategy) {
350
357
  const r = this.store.getActivePredictiveAlgorithms;
351
358
  r.length > 0 && (r.some(
352
- (u) => u.value === a.strategy
359
+ (d) => d.value === a.strategy
353
360
  ) || (n = r[0].value, e.strategy = n));
354
361
  }
355
362
  if (t.language === a.language) {
356
363
  const r = this.store.getLanguages;
357
364
  r.length > 0 && (r.some(
358
- (u) => u.value === a.language
365
+ (d) => d.value === a.language
359
366
  ) || (s = r[0].value, e.language = s));
360
367
  }
361
- !o && !n && !s || (l.updateConfig(
368
+ !o && !n && !s || (c.updateConfig(
362
369
  this.api,
363
370
  this.currentNode,
364
371
  e,
365
372
  "Applied smart defaults"
366
- ), o && e.currency && A({
373
+ ), o && e.currency && v({
367
374
  currentNode: this.currentNode,
368
375
  documentModifier: this.api.getDocumentModifier(),
369
376
  currency: e.currency
@@ -387,7 +394,7 @@ class at extends N {
387
394
  * Reads the recommendation-id attribute from the block element within the node
388
395
  */
389
396
  _getRecommendationIdFromNode(t) {
390
- const e = B(t);
397
+ const e = A(t);
391
398
  if (!e || !("getAttribute" in e))
392
399
  return null;
393
400
  const o = e.getAttribute(I);
@@ -420,13 +427,13 @@ class at extends N {
420
427
  }
421
428
  const r = t.$state.configVersion;
422
429
  r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
423
- const d = t.recommendationProducts, u = d !== e, f = Array.isArray(d) && d.length > 0;
424
- u && f && (e = d, this._debouncedRegenerateWithProducts());
430
+ const l = t.recommendationProducts, d = l !== e, m = Array.isArray(l) && l.length > 0;
431
+ d && m && (e = l, this._debouncedRegenerateWithProducts());
425
432
  });
426
433
  }
427
434
  }
428
435
  export {
429
- dt as ALGORITHM_CONTROL_ID,
436
+ ut as ALGORITHM_CONTROL_ID,
430
437
  T as AlgorithmControl,
431
438
  W as CONTROL_BLOCK_ID,
432
439
  gt as CURRENCY_CONTROL_ID,
@@ -450,15 +457,15 @@ export {
450
457
  w as StrategyControl,
451
458
  Et as adjustProductsToSize,
452
459
  Ft as formatProductPrice,
453
- B as getBlockElement,
460
+ A as getBlockElement,
454
461
  Dt as getCardComposition,
455
462
  wt as getCurrentLayout,
456
- At as getMainContainerTbody,
457
- v as isPartnerManagedBlock,
458
- Bt as regenerateMobileProductRows,
463
+ vt as getMainContainerTbody,
464
+ B as isPartnerManagedBlock,
465
+ At as regenerateMobileProductRows,
459
466
  U as regenerateProductRowsWithStyles,
460
- A as setCurrencyAttributes,
461
- vt as updatePricesInPlace,
467
+ v as setCurrencyAttributes,
468
+ Bt as updatePricesInPlace,
462
469
  x as updateProductContentInPlace,
463
470
  xt as updateSingleProductContent
464
471
  };
@@ -1,33 +1,35 @@
1
- var C = Object.defineProperty;
2
- var $ = (c, n, t) => n in c ? C(c, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : c[n] = t;
3
- var i = (c, n, t) => $(c, typeof n != "symbol" ? n + "" : n, t);
4
- import { useLegacyStrategyConversion as k } from "../../../../../composables/useLegacyStrategyConversion.js";
5
- import { ACADEMY_LINKS as L } from "../../../../../enums/academy.js";
6
- import { useOnboardingStore as w } from "../../../../../stores/onboarding.js";
7
- import { CommonControl as A } from "../../../common-control.js";
8
- import { RRS_CONFIG_VERSION as N } from "../../constants/defaultConfig.js";
9
- import { RecommendationConfigService as b } from "../../services/configService.js";
10
- import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
11
- const E = "recommendation-strategy-control";
12
- class M extends A {
1
+ var w = Object.defineProperty;
2
+ var N = (l, o, t) => o in l ? w(l, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[o] = t;
3
+ var i = (l, o, t) => N(l, typeof o != "symbol" ? o + "" : o, t);
4
+ import { useLegacyStrategyConversion as L } from "../../../../../composables/useLegacyStrategyConversion.js";
5
+ import { ACADEMY_LINKS as $ } from "../../../../../enums/academy.js";
6
+ import { useOnboardingStore as A } from "../../../../../stores/onboarding.js";
7
+ import { CommonControl as R } from "../../../common-control.js";
8
+ import { RRS_CONFIG_VERSION as E } from "../../constants/defaultConfig.js";
9
+ import { RecommendationConfigService as C } from "../../services/configService.js";
10
+ import { useRecommendationExtensionStore as O } from "../../store/recommendation.js";
11
+ const I = "recommendation-strategy-control";
12
+ class P extends R {
13
13
  constructor() {
14
14
  super(...arguments);
15
- i(this, "store", R());
16
- i(this, "onboardingStore", w());
17
- i(this, "legacyConversion", k());
15
+ i(this, "store", O());
16
+ i(this, "onboardingStore", A());
17
+ i(this, "legacyConversion", L());
18
18
  i(this, "storeUnsubscription", () => {
19
19
  });
20
20
  i(this, "listeners", []);
21
21
  i(this, "lastPaintedState", null);
22
22
  }
23
23
  getId() {
24
- return E;
24
+ return I;
25
25
  }
26
26
  getTemplate() {
27
27
  const t = this.api.translate(
28
28
  "You can assign a recommendation strategy by selecting an existing one or creating a new one to show specific content."
29
- ), e = this.api.translate("For more information, you can"), s = this.api.translate("visit Academy"), o = this.api.translate("Legacy Strategy"), a = this.api.translate(
29
+ ), e = this.api.translate("For more information, you can"), a = this.api.translate("visit Academy"), r = this.api.translate("Legacy Strategy"), s = this.api.translate(
30
30
  "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."
31
+ ), g = this.api.translate(
32
+ "The recommendation strategy used in the recommendation block is no longer available. You can assign a different strategy to it."
31
33
  );
32
34
  return `
33
35
  <div class="strategy-control-container">
@@ -52,9 +54,9 @@ class M extends A {
52
54
  ${t}
53
55
  ${e}
54
56
  <a
55
- href="${L.EMAIL_RECOMMENDATION_BLOCK}"
57
+ href="${$.EMAIL_RECOMMENDATION_BLOCK}"
56
58
  target="_blank"
57
- rel="noopener noreferrer">${s}</a>.
59
+ rel="noopener noreferrer">${a}</a>.
58
60
  </p>
59
61
  </div>
60
62
  <div data-strategy-empty-state style="display: none;">
@@ -71,16 +73,37 @@ class M extends A {
71
73
  id: "guido__btn-create-strategy",
72
74
  className: "strategy-control-cta primary"
73
75
  })
76
+ ], "strategy-control-cta-row")}
77
+ </div>
78
+ <div data-strategy-unavailable-state style="display: none;">
79
+ <div class="strategy-control-notice-row">
80
+ <div class="strategy-control-notice strategy-control-notice--error" role="alert">
81
+ <p class="strategy-control-notice-text">${g}</p>
82
+ </div>
83
+ </div>
84
+ ${this._GuTwoColumns([
85
+ this._GuButton({
86
+ name: "assignUnavailableStrategy",
87
+ label: this.api.translate("Assign Strategy"),
88
+ id: "guido__btn-assign-unavailable-strategy",
89
+ className: "strategy-control-cta on"
90
+ }),
91
+ this._GuButton({
92
+ name: "createUnavailableStrategy",
93
+ label: this.api.translate("Create New Strategy"),
94
+ id: "guido__btn-create-unavailable-strategy",
95
+ className: "strategy-control-cta primary"
96
+ })
74
97
  ], "strategy-control-cta-row")}
75
98
  </div>
76
99
  <div data-strategy-legacy-state style="display: none;">
77
100
  <div class="strategy-control-notice-row">
78
101
  <div class="strategy-control-notice">
79
- <p class="strategy-control-notice-text">${a}</p>
102
+ <p class="strategy-control-notice-text">${s}</p>
80
103
  </div>
81
104
  </div>
82
105
  <div class="strategy-control-name-band">
83
- <span class="strategy-control-name">${o}</span>
106
+ <span class="strategy-control-name">${r}</span>
84
107
  ${this._strategyAction({
85
108
  id: "guido__btn-update-legacy-strategy",
86
109
  label: this.api.translate("Update"),
@@ -123,12 +146,12 @@ class M extends A {
123
146
  </div>
124
147
  `;
125
148
  }
126
- _strategyAction({ id: t, label: e, modifier: s }) {
149
+ _strategyAction({ id: t, label: e, modifier: a }) {
127
150
  return `
128
151
  <button
129
152
  id="${t}"
130
153
  type="button"
131
- class="strategy-control-action strategy-control-action--${s}">
154
+ class="strategy-control-action strategy-control-action--${a}">
132
155
  <span>${e}</span>
133
156
  </button>
134
157
  `;
@@ -136,8 +159,8 @@ class M extends A {
136
159
  onRender() {
137
160
  this._teardown(), this.store.strategyPanelOpen = !0, this._setupButtonListeners(), this._renderState(), this.storeUnsubscription = this.store.$subscribe(() => {
138
161
  this._renderState();
139
- }), this.store.recommendationConfigs.strategyId && !this.store.strategiesFetched && this.store.fetchStrategies().catch(() => {
140
- });
162
+ }), this.store.recommendationConfigs.strategyId && !this.store.strategiesLoading && (this.store.invalidateStrategies(), this.store.fetchStrategies().catch(() => {
163
+ }));
141
164
  }
142
165
  /**
143
166
  * Whether the document itself says this block has no strategy.
@@ -147,10 +170,10 @@ class M extends A {
147
170
  * strategyId) for an assigned block.
148
171
  */
149
172
  _isNodeUnassigned() {
150
- if (!b.hasConfig(this.currentNode))
173
+ if (!C.hasConfig(this.currentNode))
151
174
  return !1;
152
- const t = b.getConfig(this.currentNode);
153
- return !t.strategyId && (t.configVersion ?? 0) >= N;
175
+ const t = C.getConfig(this.currentNode);
176
+ return !t.strategyId && (t.configVersion ?? 0) >= E;
154
177
  }
155
178
  onDestroy() {
156
179
  this._teardown();
@@ -163,37 +186,37 @@ class M extends A {
163
186
  const t = this.getContainer();
164
187
  if (!t)
165
188
  return;
166
- const e = (s, o) => {
167
- const a = t.querySelector(s);
168
- a && (a.addEventListener("click", o), this.listeners.push({ element: a, handler: o }));
189
+ const e = (a, r) => {
190
+ const s = t.querySelector(a);
191
+ s && (s.addEventListener("click", r), this.listeners.push({ element: s, handler: r }));
169
192
  };
170
- e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), 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", () => {
193
+ e("#guido__btn-assign-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-strategy", () => this.store.openStrategyCreation()), e("#guido__btn-assign-unavailable-strategy", () => this.store.openAssignStrategyDrawer()), e("#guido__btn-create-unavailable-strategy", () => this.store.openStrategyCreation()), 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", () => {
171
194
  this.legacyConversion.convertLegacyStrategy();
172
195
  });
173
196
  }
174
197
  _renderState() {
175
- var _;
176
- const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((_ = this.store.assignedStrategy) == null ? void 0 : _.name) ?? "" : "", s = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), o = this.store.legacyConversionLoading, a = this.store.isLegacyStrategyBlock, h = `${t}\0${e}\0${s}\0${o}\0${a}`;
177
- if (h === this.lastPaintedState)
198
+ var f;
199
+ const { strategyId: t } = this.store.recommendationConfigs, e = t ? ((f = this.store.assignedStrategy) == null ? void 0 : f.name) ?? "" : "", a = !!t && !e && (this.store.strategiesLoading || !this.store.strategiesSettled), r = !!t && !e && !a && this.store.strategiesFetched, s = this.store.legacyConversionLoading, g = this.store.isLegacyStrategyBlock, p = [t, e, a, r, s, g].join("\0");
200
+ if (p === this.lastPaintedState)
178
201
  return;
179
- const r = this.getContainer();
180
- if (!r)
202
+ const n = this.getContainer();
203
+ if (!n)
181
204
  return;
182
- const d = r.querySelector("[data-strategy-empty-state]"), y = r.querySelector("[data-strategy-assigned-state]"), g = r.querySelector("[data-strategy-legacy-state]"), p = r.querySelector("[data-strategy-loading-state]"), u = r.querySelector("[data-strategy-content]"), m = r.querySelector("[data-strategy-name]"), v = r.querySelector("[data-strategy-name-skeleton]");
183
- if (!d || !y || !g)
205
+ const y = n.querySelector("[data-strategy-empty-state]"), u = n.querySelector("[data-strategy-assigned-state]"), c = n.querySelector("[data-strategy-legacy-state]"), h = n.querySelector("[data-strategy-unavailable-state]"), v = n.querySelector("[data-strategy-loading-state]"), b = n.querySelector("[data-strategy-content]"), m = n.querySelector("[data-strategy-name]"), _ = n.querySelector("[data-strategy-name-skeleton]");
206
+ if (!y || !u || !c || !h)
184
207
  return;
185
- p && (p.style.display = "none"), u && (u.style.display = "");
186
- const f = t ? y : a ? g : d;
187
- [d, y, g].forEach((l) => {
188
- l.style.display = l === f ? "" : "none";
189
- }), g.querySelectorAll("button").forEach((l) => {
190
- l.disabled = o;
191
- }), g.classList.toggle("is-converting", o), !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding");
208
+ v && (v.style.display = "none"), b && (b.style.display = "");
209
+ const k = t ? r ? h : u : g ? c : y;
210
+ [y, u, c, h].forEach((d) => {
211
+ d.style.display = d === k ? "" : "none";
212
+ }), c.querySelectorAll("button").forEach((d) => {
213
+ d.disabled = s;
214
+ }), c.classList.toggle("is-converting", s), !t && this._isNodeUnassigned() && this.onboardingStore.startOnboarding("recommendationStrategyOnboarding");
192
215
  const S = this.store.currentRecommendationId;
193
- a && S !== null && this.store.blockStates[S] && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding"), m && (m.style.display = s ? "none" : "", t && !s && (m.textContent = e || `#${t}`)), v && (v.style.display = s ? "block" : "none"), this.lastPaintedState = h;
216
+ g && S !== null && this.store.blockStates[S] && this.onboardingStore.startOnboarding("recommendationLegacyStrategyOnboarding"), m && (m.style.display = a ? "none" : "", t && !a && (m.textContent = e || `#${t}`)), _ && (_.style.display = a ? "block" : "none"), this.lastPaintedState = p;
194
217
  }
195
218
  }
196
219
  export {
197
- E as STRATEGY_CONTROL_ID,
198
- M as StrategyControl
220
+ I as STRATEGY_CONTROL_ID,
221
+ P as StrategyControl
199
222
  };
@@ -1,13 +1,13 @@
1
- import { useToaster as D } from "../../../../composables/useToaster.js";
1
+ import { useToaster as _ } from "../../../../composables/useToaster.js";
2
2
  import { useTranslations as L } from "../../../../composables/useTranslations.js";
3
- import { getRecommendationFeedSourceMaps as F, strategyEditPath as U, URLS as E, getOperatorOptions as N, PriceAttributes as M } from "../../../../enums/extensions/recommendationBlock.js";
4
- import { ToasterTypeOptions as A } from "../../../../enums/toaster.js";
5
- import { useRecommendationApi as T } from "../../../../services/recommendationApi.js";
6
- import { useConfigStore as k } from "../../../../stores/config.js";
7
- import { defineStore as B } from "pinia";
3
+ import { getRecommendationFeedSourceMaps as F, strategyEditPath as U, strategyCreatePath as N, getOperatorOptions as M, PriceAttributes as E } from "../../../../enums/extensions/recommendationBlock.js";
4
+ import { ToasterTypeOptions as B } from "../../../../enums/toaster.js";
5
+ import { useRecommendationApi as z } from "../../../../services/recommendationApi.js";
6
+ import { useConfigStore as R } from "../../../../stores/config.js";
7
+ import { defineStore as A } from "pinia";
8
8
  import "../constants/selectors.js";
9
- import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as z } from "../constants/layout.js";
10
- import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as x, EXCLUDED_ALGORITHM_IDS as V } from "../constants/defaultConfig.js";
9
+ import { DEFAULT_MOBILE_CARDS_IN_ROW as O, DEFAULT_CARDS_IN_ROW as x } from "../constants/layout.js";
10
+ import { CURRENT_CONFIG_VERSION as C, DEFAULT_NODE_CONFIG as T, EXCLUDED_ALGORITHM_IDS as V } from "../constants/defaultConfig.js";
11
11
  import { getDefaultProducts as w } from "../templates/utils.js";
12
12
  import { generateCompleteFilterQuery as P } from "../utils/filterUtil.js";
13
13
  import { isLegacyStrategyConfig as j } from "../utils/legacyStrategyMigration.js";
@@ -15,13 +15,13 @@ import { getPartnerRecommendationParams as $ } from "../utils/partnerCustomizati
15
15
  import { sanitizeProductIds as q } from "../utils/productIds.js";
16
16
  import { isFilterValid as K } from "../validation/filterSchema.js";
17
17
  import { getInvalidFields as H, isConfigValid as J } from "../validation/requiredFields.js";
18
- const m = T();
19
- let S = null, p = null, y = null, I = "", R = null, b = 0;
18
+ const m = z();
19
+ let S = null, p = null, y = null, I = "", k = null, b = 0;
20
20
  const g = /* @__PURE__ */ new Map();
21
21
  let l = null;
22
- function _() {
22
+ function D() {
23
23
  return {
24
- cardsInRow: z,
24
+ cardsInRow: x,
25
25
  currencySettings: {
26
26
  name: "USD",
27
27
  value: "USD",
@@ -45,7 +45,7 @@ function _() {
45
45
  // that default is what reached buildCampaignUrl and baked a most-popular feed URL
46
46
  // for a block the user never configured (SD-149916). Legacy blocks still get their real
47
47
  // algorithm from the node-config sync or the save-time seed.
48
- strategy: k().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
48
+ strategy: R().isFeatureEnabled("reusableRecommendationStrategy") ? "" : "mostPopular",
49
49
  strategyId: "",
50
50
  nodeConfigVersion: C,
51
51
  textTrimming: !0,
@@ -58,7 +58,7 @@ function _() {
58
58
  }
59
59
  function G() {
60
60
  return {
61
- recommendationConfigs: _(),
61
+ recommendationConfigs: D(),
62
62
  recommendationProducts: [],
63
63
  filterStatus: !1,
64
64
  filterSelectionDrawerStatus: !1,
@@ -87,7 +87,7 @@ const Q = () => ({
87
87
  currentRecommendationId: null,
88
88
  strategyPanelOpen: !1,
89
89
  configVersion: 0
90
- }), ft = B("guidoRecommendationExtension", {
90
+ }), ft = A("guidoRecommendationExtension", {
91
91
  state: () => Q(),
92
92
  getters: {
93
93
  // ====================================================================
@@ -98,7 +98,7 @@ const Q = () => ({
98
98
  * This allows all existing code that reads `store.recommendationConfigs` to work unchanged.
99
99
  */
100
100
  recommendationConfigs(t) {
101
- return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : _();
101
+ return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].recommendationConfigs : D();
102
102
  },
103
103
  /**
104
104
  * Proxy getter: delegates to blockStates[currentRecommendationId].recommendationProducts
@@ -119,7 +119,7 @@ const Q = () => ({
119
119
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].removeStrategyModalStatus : !1;
120
120
  },
121
121
  isLegacyStrategyBlock() {
122
- return k().isFeatureEnabled("reusableRecommendationStrategy") && j(this.recommendationConfigs);
122
+ return R().isFeatureEnabled("reusableRecommendationStrategy") && j(this.recommendationConfigs);
123
123
  },
124
124
  legacyConversionLoading(t) {
125
125
  return t.currentRecommendationId !== null && t.blockStates[t.currentRecommendationId] ? t.blockStates[t.currentRecommendationId].legacyConversionLoading ?? !1 : !1;
@@ -181,7 +181,7 @@ const Q = () => ({
181
181
  getFilterList() {
182
182
  return Object.values(this.filterList).filter((t) => t.isFilterable !== 0 && t.isFilterable !== !1).map((t) => {
183
183
  let e;
184
- return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : M.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
184
+ return t.type === "productAttribute" ? e = `product_attributes.${t.attributeName}` : E.includes(t.attributeName) ? e = `${t.attributeName}.${this.recommendationConfigs.currencySettings.value}` : e = t.attributeName, {
185
185
  text: t.displayName,
186
186
  value: e,
187
187
  type: t.attributeType
@@ -234,7 +234,7 @@ const Q = () => ({
234
234
  const r = this.blockStates[t];
235
235
  if (r) {
236
236
  const o = structuredClone(r);
237
- o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && k().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
237
+ o.recommendationConfigs.id = e, o.recommendationConfigs.strategyId && R().isFeatureEnabled("reusableRecommendationStrategy") && (o.isInitialized = !1, o.syncedConfigFingerprint = null), this.blockStates = {
238
238
  ...this.blockStates,
239
239
  [e]: o
240
240
  };
@@ -314,7 +314,7 @@ const Q = () => ({
314
314
  * Creates a filter with the first available attribute and operator pre-selected.
315
315
  */
316
316
  createDefaultFilter(t, e) {
317
- const [r] = this.getFilterList, [n] = N(r == null ? void 0 : r.type);
317
+ const [r] = this.getFilterList, [n] = M(r == null ? void 0 : r.type);
318
318
  return {
319
319
  type: "standardFilter",
320
320
  attribute: (r == null ? void 0 : r.value) ?? "",
@@ -380,9 +380,9 @@ const Q = () => ({
380
380
  this.currentRecommendationId === null || !this.blockStates[this.currentRecommendationId] || (this.blockStates[this.currentRecommendationId].removeStrategyModalStatus = !1);
381
381
  },
382
382
  async fetchStrategies() {
383
- for (; R; )
383
+ for (; k; )
384
384
  try {
385
- await R;
385
+ await k;
386
386
  } catch {
387
387
  }
388
388
  if (this.strategiesFetched)
@@ -398,11 +398,11 @@ const Q = () => ({
398
398
  this.strategiesLoading = !1, t === b && (this.strategiesSettled = !0);
399
399
  }
400
400
  })();
401
- R = e;
401
+ k = e;
402
402
  try {
403
403
  await e;
404
404
  } finally {
405
- R = null;
405
+ k = null;
406
406
  }
407
407
  },
408
408
  /**
@@ -434,8 +434,8 @@ const Q = () => ({
434
434
  _armStrategyPageReturn(t) {
435
435
  const e = window.open(t, "_blank");
436
436
  if (!e)
437
- return D().showToaster({
438
- type: A.Error,
437
+ return _().showToaster({
438
+ type: B.Error,
439
439
  message: L()("discovery-strategy.error-description")
440
440
  }), !1;
441
441
  e.opener = null, l == null || l();
@@ -471,7 +471,7 @@ const Q = () => ({
471
471
  * new strategy is offered; the user picks it themselves.
472
472
  */
473
473
  openStrategyCreation() {
474
- return this._armStrategyPageReturn(E.RECOMMENDATION_STRATEGY_CREATE_PATH);
474
+ return this._armStrategyPageReturn(N());
475
475
  },
476
476
  /**
477
477
  * Opens the strategy's edit page. Every return refreshes the list so the block reflects the
@@ -503,6 +503,7 @@ const Q = () => ({
503
503
  this.blockStates[r].legacyConversionLoading = !0;
504
504
  try {
505
505
  const n = await m.migrateLegacyStrategy(t, e);
506
+ this.invalidateStrategies();
506
507
  try {
507
508
  await this.fetchStrategies();
508
509
  } catch (o) {
@@ -532,7 +533,7 @@ const Q = () => ({
532
533
  this.patchCurrentBlockConfig({
533
534
  strategyId: "",
534
535
  strategy: "",
535
- size: x.size,
536
+ size: T.size,
536
537
  nodeConfigVersion: C
537
538
  });
538
539
  },
@@ -685,7 +686,7 @@ const Q = () => ({
685
686
  },
686
687
  async _doFetchProducts() {
687
688
  var h;
688
- const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = k();
689
+ const t = this.currentRecommendationId, e = this.blockStates[t], { recommendationConfigs: r } = e, n = R();
689
690
  if (r.strategyId && n.isFeatureEnabled("reusableRecommendationStrategy")) {
690
691
  await this._doFetchStrategyProducts(t);
691
692
  return;