@useinsider/guido 3.20.0-beta.6e5144c → 3.20.0-beta.af394f2
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.
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +188 -229
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +155 -170
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +6 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +6 -19
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +1 -7
- package/package.json +1 -1
|
@@ -1,77 +1,74 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var p = (h, u, e) => u in h ? C(h, u, { enumerable: !0, configurable: !0, writable: !0, value: e }) : h[u] = e;
|
|
3
|
+
var r = (h, u, e) => p(h, typeof u != "symbol" ? u + "" : u, e);
|
|
4
4
|
import { useConfig as f } from "../../../../../composables/useConfig.js";
|
|
5
|
-
import { ModificationDescription as
|
|
6
|
-
import { CommonControl as
|
|
7
|
-
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as
|
|
8
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
9
|
-
import { RecommendationConfigService as
|
|
5
|
+
import { ModificationDescription as y } from "../../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
|
+
import { CommonControl as N } from "../../../common-control.js";
|
|
7
|
+
import { RRS_CONFIG_VERSION as _, DEFAULT_NODE_CONFIG as c } from "../../constants/defaultConfig.js";
|
|
8
|
+
import { RECOMMENDATION_ID_ATTR as I } from "../../constants/selectors.js";
|
|
9
|
+
import { RecommendationConfigService as d } from "../../services/configService.js";
|
|
10
10
|
import { useRecommendationExtensionStore as R } from "../../store/recommendation.js";
|
|
11
|
-
import { registerNodeConfigWriter as
|
|
11
|
+
import { registerNodeConfigWriter as b, commitBlockChangeOutsidePanel as P } from "../../utils/nodeConfigWriter.js";
|
|
12
12
|
import { AlgorithmControl as S } from "./algorithm.js";
|
|
13
|
-
import { ALGORITHM_CONTROL_ID as
|
|
14
|
-
import { CurrencyControl as
|
|
15
|
-
import { CURRENCY_CONTROL_ID as
|
|
16
|
-
import { FiltersControl as
|
|
17
|
-
import { FILTERS_CONTROL_ID as
|
|
18
|
-
import { LayoutOrientationControl as
|
|
19
|
-
import { LAYOUT_ORIENTATION_CONTROL_ID as
|
|
20
|
-
import { LocaleControl as
|
|
21
|
-
import { LOCALE_CONTROL_ID as
|
|
22
|
-
import { PricePlacementControl as
|
|
23
|
-
import { PRICE_PLACEMENT_CONTROL_ID as
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as ue } from "./algorithm.js";
|
|
14
|
+
import { CurrencyControl as T } from "./currency.js";
|
|
15
|
+
import { CURRENCY_CONTROL_ID as ge } from "./currency.js";
|
|
16
|
+
import { FiltersControl as O } from "./filters.js";
|
|
17
|
+
import { FILTERS_CONTROL_ID as me } from "./filters.js";
|
|
18
|
+
import { LayoutOrientationControl as k } from "./layoutOrientation.js";
|
|
19
|
+
import { LAYOUT_ORIENTATION_CONTROL_ID as pe } from "./layoutOrientation.js";
|
|
20
|
+
import { LocaleControl as L } from "./locale.js";
|
|
21
|
+
import { LOCALE_CONTROL_ID as Ne } from "./locale.js";
|
|
22
|
+
import { PricePlacementControl as E } from "./pricePlacement.js";
|
|
23
|
+
import { PRICE_PLACEMENT_CONTROL_ID as Ie } from "./pricePlacement.js";
|
|
24
24
|
import { ProductCountControl as F } from "./productCount.js";
|
|
25
|
-
import { PRODUCT_COUNT_CONTROL_ID as
|
|
26
|
-
import { ProductLayoutControl as
|
|
25
|
+
import { PRODUCT_COUNT_CONTROL_ID as be } from "./productCount.js";
|
|
26
|
+
import { ProductLayoutControl as D } from "./productLayout.js";
|
|
27
27
|
import { PRODUCT_LAYOUT_CONTROL_ID as Se } from "./productLayout.js";
|
|
28
|
-
import { ShuffleControl as
|
|
29
|
-
import { SHUFFLE_CONTROL_ID as
|
|
30
|
-
import { StrategyControl as
|
|
31
|
-
import { STRATEGY_CONTROL_ID as
|
|
32
|
-
import { setCurrencyAttributes as
|
|
33
|
-
import { adjustProductsToSize as Fe, formatProductPrice as
|
|
34
|
-
import { useDebounceFn as
|
|
28
|
+
import { ShuffleControl as w } from "./shuffle.js";
|
|
29
|
+
import { SHUFFLE_CONTROL_ID as Oe } from "./shuffle.js";
|
|
30
|
+
import { StrategyControl as B } from "./strategy.js";
|
|
31
|
+
import { STRATEGY_CONTROL_ID as Le } from "./strategy.js";
|
|
32
|
+
import { setCurrencyAttributes as U, getBlockElement as v, isPartnerManagedBlock as A, updateProductContentInPlace as x, regenerateProductRowsWithStyles as V } from "./utils.js";
|
|
33
|
+
import { adjustProductsToSize as Fe, formatProductPrice as De, getCardComposition as we, getCurrentLayout as Be, getMainContainerTbody as Ue, regenerateMobileProductRows as ve, updatePricesInPlace as Ae, updateSingleProductContent as xe } from "./utils.js";
|
|
34
|
+
import { useDebounceFn as m } from "../../../../../node_modules/@vueuse/shared/index.js";
|
|
35
35
|
const W = "ui-elements-recommendation-block";
|
|
36
|
-
class
|
|
36
|
+
class ce extends N {
|
|
37
37
|
constructor() {
|
|
38
38
|
super(...arguments);
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
r(this, "store", R());
|
|
40
|
+
r(this, "storeUnsubscription", () => {
|
|
41
41
|
});
|
|
42
42
|
// A config change waiting to reach the node config. Deferred so it can ride the
|
|
43
43
|
// re-render's single apply() — one user action must cost one undo press.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
//
|
|
47
|
-
//
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
s(this, "isDestroyed", !1);
|
|
44
|
+
r(this, "pendingNodeConfigWrite", null);
|
|
45
|
+
r(this, "pendingConfigFlushTimer", null);
|
|
46
|
+
// Last configVersion the subscription handled, and whether its products still
|
|
47
|
+
// have to reach the canvas — both read on destroy to finish that work.
|
|
48
|
+
r(this, "seenConfigVersion", 0);
|
|
49
|
+
r(this, "fetchedConfigVersion", 0);
|
|
50
|
+
r(this, "hasUnappliedConfigChange", !1);
|
|
52
51
|
// Sub-control instances for lifecycle management
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
52
|
+
r(this, "algorithmControl", null);
|
|
53
|
+
r(this, "localeControl", null);
|
|
54
|
+
r(this, "currencyControl", null);
|
|
55
|
+
r(this, "productCountControl", null);
|
|
56
|
+
r(this, "productLayoutControl", null);
|
|
57
|
+
r(this, "filtersControl", null);
|
|
58
|
+
r(this, "shuffleControl", null);
|
|
59
|
+
r(this, "pricePlacementControl", null);
|
|
60
|
+
r(this, "layoutOrientationControl", null);
|
|
61
|
+
r(this, "strategyControl", null);
|
|
62
|
+
r(this, "rrsEnabled", !1);
|
|
64
63
|
/**
|
|
65
64
|
* Debounced product fetch to prevent rapid API calls during config changes
|
|
66
65
|
*/
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return;
|
|
70
|
-
const t = this._getBlockConfigVersion(e);
|
|
66
|
+
r(this, "_debouncedFetchProducts", m(async () => {
|
|
67
|
+
const { configVersion: e } = this.store.$state;
|
|
71
68
|
try {
|
|
72
|
-
await this.store.fetchRecommendationProducts(),
|
|
69
|
+
await this.store.fetchRecommendationProducts(), this.fetchedConfigVersion = e;
|
|
73
70
|
} finally {
|
|
74
|
-
|
|
71
|
+
this._scheduleConfigFlush();
|
|
75
72
|
}
|
|
76
73
|
}, 500));
|
|
77
74
|
/**
|
|
@@ -85,21 +82,21 @@ class ae extends y {
|
|
|
85
82
|
* count. The store pads products to the configured size, so in-place only
|
|
86
83
|
* fails when the size actually changed.
|
|
87
84
|
*/
|
|
88
|
-
|
|
85
|
+
r(this, "_debouncedRegenerateWithProducts", m(() => {
|
|
89
86
|
const e = this.store.recommendationProducts;
|
|
90
|
-
if (
|
|
87
|
+
if (!this.currentNode || !this.api)
|
|
91
88
|
return;
|
|
92
|
-
this.
|
|
89
|
+
this.fetchedConfigVersion === this.seenConfigVersion && (this.hasUnappliedConfigChange = !1);
|
|
93
90
|
const t = this.api.getDocumentModifier(), o = this._stagePendingNodeConfig(t);
|
|
94
|
-
if (
|
|
95
|
-
o && (t.apply(new
|
|
91
|
+
if (A(this.currentNode)) {
|
|
92
|
+
o && (t.apply(new y("Update recommendation configuration")), this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
96
93
|
return;
|
|
97
94
|
}
|
|
98
|
-
|
|
95
|
+
x({
|
|
99
96
|
currentNode: this.currentNode,
|
|
100
97
|
documentModifier: t,
|
|
101
98
|
products: e
|
|
102
|
-
}) ||
|
|
99
|
+
}) || V({
|
|
103
100
|
currentNode: this.currentNode,
|
|
104
101
|
documentModifier: t,
|
|
105
102
|
products: e
|
|
@@ -128,7 +125,7 @@ class ae extends y {
|
|
|
128
125
|
return this.rrsEnabled = f().isFeatureEnabled("reusableRecommendationStrategy"), this._subControls.forEach((t) => {
|
|
129
126
|
var o;
|
|
130
127
|
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
131
|
-
}), this.algorithmControl = new S(), this.localeControl = new
|
|
128
|
+
}), this.algorithmControl = new S(), this.localeControl = new L(), this.currencyControl = new T(), this.productCountControl = new F(), this.productLayoutControl = new D(), this.filtersControl = new O(), this.shuffleControl = new w(), this.pricePlacementControl = new E(), this.layoutOrientationControl = new k(), this.strategyControl = this.rrsEnabled ? new B() : null, this._subControls.forEach((t) => {
|
|
132
129
|
t && (t.api = this.api);
|
|
133
130
|
}), `
|
|
134
131
|
<div class="recommendation-controls-container">
|
|
@@ -146,16 +143,16 @@ class ae extends y {
|
|
|
146
143
|
`;
|
|
147
144
|
}
|
|
148
145
|
_showControlsForBlock(e) {
|
|
149
|
-
var
|
|
150
|
-
const t = (
|
|
146
|
+
var i;
|
|
147
|
+
const t = (i = this.getContainer()) == null ? void 0 : i.querySelector(".recommendation-controls-container");
|
|
151
148
|
if (!t)
|
|
152
149
|
return;
|
|
153
|
-
const o = this._getRecommendationIdFromNode(e) === null ? null :
|
|
154
|
-
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block",
|
|
150
|
+
const o = this._getRecommendationIdFromNode(e) === null ? null : d.getConfig(e), n = this.rrsEnabled && !!o && (!!(o != null && o.strategyId) || ((o == null ? void 0 : o.configVersion) ?? 0) >= _), s = this.rrsEnabled && !!o && !n;
|
|
151
|
+
t.classList.toggle("strategy-block", n), t.classList.toggle("legacy-strategy-block", s);
|
|
155
152
|
}
|
|
156
153
|
async onRender() {
|
|
157
154
|
var o;
|
|
158
|
-
|
|
155
|
+
b(this.api);
|
|
159
156
|
const e = this._getRecommendationIdFromNode(this.currentNode), t = e ?? this.store.currentRecommendationId;
|
|
160
157
|
if (t !== null && this.store.setCurrentBlock(t), e !== null && this._syncNodeConfigIfChanged(e), this._listenStateUpdates(), this._showControlsForBlock(this.currentNode), e !== null && this.strategyControl && (this.strategyControl.api = this.api, this.strategyControl.currentNode = this.currentNode, this.strategyControl.onRender()), t !== null && ((o = this.store.blockStates[t]) != null && o.isInitialized)) {
|
|
161
158
|
this._initializeSubControls();
|
|
@@ -167,17 +164,18 @@ class ae extends y {
|
|
|
167
164
|
var o;
|
|
168
165
|
super.onTemplateNodeUpdated(e);
|
|
169
166
|
const t = this._getRecommendationIdFromNode(e);
|
|
170
|
-
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t
|
|
167
|
+
t !== null && t !== this.store.currentRecommendationId && this.store.setCurrentBlock(t), t !== null && this._syncNodeConfigIfChanged(t), this._showControlsForBlock(e), t !== null && !((o = this.store.blockStates[t]) != null && o.isInitialized) && this._fetchBlockData(t).then(() => {
|
|
171
168
|
this._initializeSubControls();
|
|
172
169
|
}), this._subControls.forEach((n) => {
|
|
173
|
-
var
|
|
174
|
-
n != null && n.api && (n.currentNode = e, (
|
|
170
|
+
var s;
|
|
171
|
+
n != null && n.api && (n.currentNode = e, (s = n.onTemplateNodeUpdated) == null || s.call(n, e));
|
|
175
172
|
});
|
|
176
173
|
}
|
|
177
174
|
onDestroy() {
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
175
|
+
const e = this.hasUnappliedConfigChange || this.store.$state.configVersion !== this.seenConfigVersion;
|
|
176
|
+
this.storeUnsubscription(), e ? this._refreshProductsOutsidePanel() : this._flushPendingNodeConfig(), this._subControls.forEach((t) => {
|
|
177
|
+
var o;
|
|
178
|
+
return (o = t == null ? void 0 : t.onDestroy) == null ? void 0 : o.call(t);
|
|
181
179
|
});
|
|
182
180
|
}
|
|
183
181
|
/**
|
|
@@ -214,38 +212,35 @@ class ae extends y {
|
|
|
214
212
|
* that state and made a re-dropped saved module keep the defaults its wiped
|
|
215
213
|
* state was rebuilt with (SD-150347).
|
|
216
214
|
*/
|
|
217
|
-
_syncNodeConfigIfChanged(e
|
|
218
|
-
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
const i = this.store.blockStates[e];
|
|
222
|
-
if (!i)
|
|
215
|
+
_syncNodeConfigIfChanged(e) {
|
|
216
|
+
this.pendingNodeConfigWrite && this.pendingNodeConfigWrite.blockId !== e && this._flushPendingNodeConfig();
|
|
217
|
+
const t = this.store.blockStates[e];
|
|
218
|
+
if (!t)
|
|
223
219
|
return;
|
|
224
|
-
const
|
|
225
|
-
|
|
220
|
+
const o = JSON.stringify(d.getConfig(this.currentNode)), n = t.syncedConfigFingerprint;
|
|
221
|
+
t.syncedConfigFingerprint = o, n !== o && (this.pendingNodeConfigWrite || this._syncNodeConfigToStore());
|
|
226
222
|
}
|
|
227
223
|
/** Whether the deferred write would move the node's strategyId — see the caller (SD-149916). */
|
|
228
224
|
_isPendingStrategyIdChange() {
|
|
229
225
|
const e = this.pendingNodeConfigWrite;
|
|
230
|
-
return e ?
|
|
226
|
+
return e ? d.getConfig(this.currentNode).strategyId !== e.updates.strategyId : !1;
|
|
231
227
|
}
|
|
232
228
|
_capturePendingNodeConfigWrite(e = this.store.currentRecommendationId) {
|
|
233
229
|
const t = e === null ? void 0 : this.store.blockStates[e];
|
|
234
|
-
!this.currentNode || !this.api || e === null || !t
|
|
230
|
+
if (!this.currentNode || !this.api || e === null || !t)
|
|
231
|
+
return;
|
|
232
|
+
const { filters: o, strategy: n, strategyId: s, size: i, nodeConfigVersion: l } = t.recommendationConfigs, { partnerName: a } = f();
|
|
233
|
+
this.pendingNodeConfigWrite = {
|
|
235
234
|
blockId: e,
|
|
236
235
|
node: this.currentNode,
|
|
237
|
-
updates:
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
strategyId: n,
|
|
246
|
-
size: i,
|
|
247
|
-
configVersion: r,
|
|
248
|
-
...c.value ? { partnerName: c.value } : {}
|
|
236
|
+
updates: {
|
|
237
|
+
filters: o,
|
|
238
|
+
strategy: n,
|
|
239
|
+
strategyId: s,
|
|
240
|
+
size: i,
|
|
241
|
+
configVersion: l,
|
|
242
|
+
...a.value ? { partnerName: a.value } : {}
|
|
243
|
+
}
|
|
249
244
|
};
|
|
250
245
|
}
|
|
251
246
|
/**
|
|
@@ -260,7 +255,7 @@ class ae extends y {
|
|
|
260
255
|
*/
|
|
261
256
|
_stagePendingNodeConfig(e) {
|
|
262
257
|
const t = this.pendingNodeConfigWrite;
|
|
263
|
-
return !t || !this.currentNode ? !1 : (
|
|
258
|
+
return !t || !this.currentNode ? !1 : (d.stageConfig(e, this.currentNode, t.updates), !0);
|
|
264
259
|
}
|
|
265
260
|
/**
|
|
266
261
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -282,17 +277,14 @@ class ae extends y {
|
|
|
282
277
|
*/
|
|
283
278
|
_flushPendingNodeConfig() {
|
|
284
279
|
const e = this.pendingNodeConfigWrite;
|
|
285
|
-
this.pendingNodeConfigWrite = null, this._clearConfigFlush(), this.
|
|
286
|
-
}
|
|
287
|
-
_writeNodeConfig(e) {
|
|
288
|
-
if (!e || !this.api)
|
|
280
|
+
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !e || !this.api)
|
|
289
281
|
return;
|
|
290
|
-
const t = e.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : e.node, o =
|
|
291
|
-
JSON.stringify(o.filters) === JSON.stringify(e.updates.filters) && o.strategy === e.updates.strategy && o.strategyId === e.updates.strategyId && o.size === e.updates.size ||
|
|
282
|
+
const t = e.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : e.node, o = d.getConfig(t);
|
|
283
|
+
JSON.stringify(o.filters) === JSON.stringify(e.updates.filters) && o.strategy === e.updates.strategy && o.strategyId === e.updates.strategyId && o.size === e.updates.size || d.updateConfig(this.api, t, e.updates, "Update recommendation filters");
|
|
292
284
|
}
|
|
293
285
|
_syncNodeConfigToStore() {
|
|
294
286
|
var n;
|
|
295
|
-
const e =
|
|
287
|
+
const e = d.getConfig(this.currentNode), t = this.store.currentRecommendationId, o = t !== null && ((n = this.store.blockStates[t]) == null ? void 0 : n.isInitialized);
|
|
296
288
|
this.store.patchCurrentBlockConfig({
|
|
297
289
|
strategy: e.strategy,
|
|
298
290
|
strategyId: e.strategyId,
|
|
@@ -357,36 +349,36 @@ class ae extends y {
|
|
|
357
349
|
_applySmartDefaults() {
|
|
358
350
|
if (!this.currentNode || !this.api)
|
|
359
351
|
return;
|
|
360
|
-
const e =
|
|
361
|
-
let o = null, n = null,
|
|
362
|
-
if (e.currency.code ===
|
|
363
|
-
const { currencyList:
|
|
364
|
-
|
|
365
|
-
(a) => a.value === `price.${
|
|
366
|
-
) || (o =
|
|
367
|
-
...
|
|
352
|
+
const e = d.getConfig(this.currentNode), t = {};
|
|
353
|
+
let o = null, n = null, s = null;
|
|
354
|
+
if (e.currency.code === c.currency.code) {
|
|
355
|
+
const { currencyList: i } = this.store;
|
|
356
|
+
i.length > 0 && (i.some(
|
|
357
|
+
(a) => a.value === `price.${c.currency.code}`
|
|
358
|
+
) || (o = i[0].value.replace("price.", ""), t.currency = {
|
|
359
|
+
...c.currency,
|
|
368
360
|
code: o,
|
|
369
361
|
symbol: o
|
|
370
362
|
}));
|
|
371
363
|
}
|
|
372
|
-
if (e.strategy ===
|
|
373
|
-
const
|
|
374
|
-
|
|
375
|
-
(a) => a.value ===
|
|
376
|
-
) || (n =
|
|
364
|
+
if (e.strategy === c.strategy) {
|
|
365
|
+
const i = this.store.getActivePredictiveAlgorithms;
|
|
366
|
+
i.length > 0 && (i.some(
|
|
367
|
+
(a) => a.value === c.strategy
|
|
368
|
+
) || (n = i[0].value, t.strategy = n));
|
|
377
369
|
}
|
|
378
|
-
if (e.language ===
|
|
379
|
-
const
|
|
380
|
-
|
|
381
|
-
(a) => a.value ===
|
|
382
|
-
) || (
|
|
370
|
+
if (e.language === c.language) {
|
|
371
|
+
const i = this.store.getLanguages;
|
|
372
|
+
i.length > 0 && (i.some(
|
|
373
|
+
(a) => a.value === c.language
|
|
374
|
+
) || (s = i[0].value, t.language = s));
|
|
383
375
|
}
|
|
384
|
-
!o && !n && !
|
|
376
|
+
!o && !n && !s || (d.updateConfig(
|
|
385
377
|
this.api,
|
|
386
378
|
this.currentNode,
|
|
387
379
|
t,
|
|
388
380
|
"Applied smart defaults"
|
|
389
|
-
), o && t.currency &&
|
|
381
|
+
), o && t.currency && U({
|
|
390
382
|
currentNode: this.currentNode,
|
|
391
383
|
documentModifier: this.api.getDocumentModifier(),
|
|
392
384
|
currency: t.currency
|
|
@@ -396,101 +388,68 @@ class ae extends y {
|
|
|
396
388
|
name: o,
|
|
397
389
|
value: o,
|
|
398
390
|
symbol: o,
|
|
399
|
-
alignment:
|
|
400
|
-
decimalCount:
|
|
401
|
-
decimalSeparator:
|
|
402
|
-
thousandSeparator:
|
|
391
|
+
alignment: c.currency.alignment === "before" ? "0" : "1",
|
|
392
|
+
decimalCount: c.currency.decimalCount.toString(),
|
|
393
|
+
decimalSeparator: c.currency.decimalSeparator,
|
|
394
|
+
thousandSeparator: c.currency.thousandSeparator
|
|
403
395
|
}
|
|
404
396
|
} : {},
|
|
405
397
|
...n ? { strategy: n } : {},
|
|
406
|
-
...
|
|
398
|
+
...s ? { language: s } : {}
|
|
407
399
|
}, { triggerRefetch: !1 }));
|
|
408
400
|
}
|
|
409
401
|
/**
|
|
410
402
|
* Reads the recommendation-id attribute from the block element within the node
|
|
411
403
|
*/
|
|
412
404
|
_getRecommendationIdFromNode(e) {
|
|
413
|
-
const t =
|
|
405
|
+
const t = v(e);
|
|
414
406
|
if (!t || !("getAttribute" in t))
|
|
415
407
|
return null;
|
|
416
|
-
const o = t.getAttribute(
|
|
408
|
+
const o = t.getAttribute(I);
|
|
417
409
|
if (!o)
|
|
418
410
|
return null;
|
|
419
411
|
const n = parseInt(o);
|
|
420
412
|
return Number.isNaN(n) ? null : n;
|
|
421
413
|
}
|
|
422
414
|
/**
|
|
423
|
-
*
|
|
424
|
-
*
|
|
425
|
-
* @returns whether a refresh was started
|
|
415
|
+
* Fetches and renders the block's products without the panel, carrying the
|
|
416
|
+
* deferred config write so both still land as one undo entry.
|
|
426
417
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
}
|
|
434
|
-
/** A removed block counts as unrendered so its pending write still gets flushed. */
|
|
435
|
-
_hasUnrenderedChange(e) {
|
|
436
|
-
if (e !== this.trackedBlockId)
|
|
437
|
-
return !1;
|
|
438
|
-
const t = this.store.blockStates[e];
|
|
439
|
-
return !t || this.renderedConfigVersion !== t.configVersion;
|
|
440
|
-
}
|
|
441
|
-
_hasPendingWriteFor(e) {
|
|
442
|
-
var t;
|
|
443
|
-
return ((t = this.pendingNodeConfigWrite) == null ? void 0 : t.blockId) === e;
|
|
444
|
-
}
|
|
445
|
-
_getBlockConfigVersion(e) {
|
|
446
|
-
var t;
|
|
447
|
-
return e === null ? 0 : ((t = this.store.blockStates[e]) == null ? void 0 : t.configVersion) ?? 0;
|
|
448
|
-
}
|
|
449
|
-
/**
|
|
450
|
-
* Fetches and renders one block's products without the panel, carrying its config
|
|
451
|
-
* write so both still land as one undo entry.
|
|
452
|
-
*/
|
|
453
|
-
async _refreshBlockOutsidePanel(e, t) {
|
|
454
|
-
var c;
|
|
455
|
-
if (((c = this.pendingNodeConfigWrite) == null ? void 0 : c.blockId) !== e && this._flushPendingNodeConfig(), !this.store.blockStates[e]) {
|
|
418
|
+
async _refreshProductsOutsidePanel() {
|
|
419
|
+
var a;
|
|
420
|
+
const e = this.store.currentRecommendationId, t = this._getRecommendationIdFromNode(this.currentNode), o = t !== null && t !== e ? t : e;
|
|
421
|
+
if (((a = this.pendingNodeConfigWrite) == null ? void 0 : a.blockId) !== o && this._flushPendingNodeConfig(), o === null)
|
|
422
|
+
return;
|
|
423
|
+
if (this._capturePendingNodeConfigWrite(o), o !== e) {
|
|
456
424
|
this._flushPendingNodeConfig();
|
|
457
425
|
return;
|
|
458
426
|
}
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
try {
|
|
465
|
-
await this.store.fetchRecommendationProductsForBlock(e);
|
|
466
|
-
} catch (a) {
|
|
467
|
-
console.warn("Recommendation block: fetchRecommendationProductsForBlock failed", a);
|
|
468
|
-
}
|
|
469
|
-
const i = this.store.blockStates[e];
|
|
470
|
-
if (i && i.configVersion !== n) {
|
|
471
|
-
if (o && !this._hasPendingWriteFor(e)) {
|
|
472
|
-
const a = this._getNodeConfigUpdates(i.recommendationConfigs);
|
|
473
|
-
this._writeNodeConfig({ ...o, updates: a });
|
|
474
|
-
}
|
|
475
|
-
return;
|
|
427
|
+
const n = this.pendingNodeConfigWrite;
|
|
428
|
+
try {
|
|
429
|
+
await this.store.fetchRecommendationProducts();
|
|
430
|
+
} catch (g) {
|
|
431
|
+
console.warn("Recommendation block: fetchRecommendationProducts failed", g);
|
|
476
432
|
}
|
|
477
|
-
|
|
433
|
+
const s = this.pendingNodeConfigWrite === n, i = s ? (n == null ? void 0 : n.updates) ?? {} : {}, l = this.store.blockStates[e];
|
|
478
434
|
try {
|
|
479
|
-
|
|
435
|
+
if (l && P(
|
|
480
436
|
e,
|
|
481
|
-
|
|
482
|
-
|
|
437
|
+
i,
|
|
438
|
+
l.recommendationProducts,
|
|
483
439
|
"Update recommendation configuration"
|
|
484
|
-
)
|
|
485
|
-
|
|
486
|
-
|
|
440
|
+
)) {
|
|
441
|
+
s && (this.pendingNodeConfigWrite = null, this._clearConfigFlush());
|
|
442
|
+
return;
|
|
443
|
+
}
|
|
444
|
+
s && this._flushPendingNodeConfig();
|
|
445
|
+
} catch (g) {
|
|
446
|
+
console.error("Recommendation block: refresh outside the panel failed", g);
|
|
487
447
|
}
|
|
488
|
-
r || this._writeNodeConfig(o);
|
|
489
448
|
}
|
|
490
449
|
/**
|
|
491
450
|
* Listen to store changes that require product refresh or regeneration.
|
|
492
451
|
*
|
|
493
|
-
* Uses
|
|
452
|
+
* Uses configVersion counter (incremented only by patchCurrentBlockConfig)
|
|
494
453
|
* to distinguish user-initiated config changes from internal mutations
|
|
495
454
|
* (e.g., fetchRecommendationCreateData setting preferred currency).
|
|
496
455
|
*
|
|
@@ -502,54 +461,54 @@ class ae extends y {
|
|
|
502
461
|
*/
|
|
503
462
|
_listenStateUpdates() {
|
|
504
463
|
const { store: e } = this;
|
|
505
|
-
let t = e.recommendationProducts, o =
|
|
506
|
-
this.
|
|
464
|
+
let t = e.recommendationProducts, o = e.currentRecommendationId;
|
|
465
|
+
this.seenConfigVersion = e.$state.configVersion, this.hasUnappliedConfigChange = !1, this.storeUnsubscription = e.$subscribe(() => {
|
|
507
466
|
const n = e.currentRecommendationId;
|
|
508
|
-
if (n !==
|
|
509
|
-
|
|
467
|
+
if (n !== o) {
|
|
468
|
+
o = n, t = e.recommendationProducts, this.seenConfigVersion = e.$state.configVersion, this.hasUnappliedConfigChange = !1;
|
|
510
469
|
return;
|
|
511
470
|
}
|
|
512
|
-
const
|
|
513
|
-
|
|
514
|
-
const
|
|
515
|
-
|
|
471
|
+
const s = e.$state.configVersion;
|
|
472
|
+
s !== this.seenConfigVersion && (this.seenConfigVersion = s, this.hasUnappliedConfigChange = !0, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
473
|
+
const i = e.recommendationProducts, l = i !== t, a = Array.isArray(i) && i.length > 0;
|
|
474
|
+
l && a && (t = i, this._debouncedRegenerateWithProducts());
|
|
516
475
|
});
|
|
517
476
|
}
|
|
518
477
|
}
|
|
519
478
|
export {
|
|
520
|
-
|
|
479
|
+
ue as ALGORITHM_CONTROL_ID,
|
|
521
480
|
S as AlgorithmControl,
|
|
522
481
|
W as CONTROL_BLOCK_ID,
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
482
|
+
ge as CURRENCY_CONTROL_ID,
|
|
483
|
+
T as CurrencyControl,
|
|
484
|
+
me as FILTERS_CONTROL_ID,
|
|
485
|
+
O as FiltersControl,
|
|
486
|
+
pe as LAYOUT_ORIENTATION_CONTROL_ID,
|
|
487
|
+
Ne as LOCALE_CONTROL_ID,
|
|
488
|
+
k as LayoutOrientationControl,
|
|
489
|
+
L as LocaleControl,
|
|
490
|
+
Ie as PRICE_PLACEMENT_CONTROL_ID,
|
|
491
|
+
be as PRODUCT_COUNT_CONTROL_ID,
|
|
533
492
|
Se as PRODUCT_LAYOUT_CONTROL_ID,
|
|
534
|
-
|
|
493
|
+
E as PricePlacementControl,
|
|
535
494
|
F as ProductCountControl,
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
495
|
+
D as ProductLayoutControl,
|
|
496
|
+
ce as RecommendationBlockControl,
|
|
497
|
+
Oe as SHUFFLE_CONTROL_ID,
|
|
498
|
+
Le as STRATEGY_CONTROL_ID,
|
|
499
|
+
w as ShuffleControl,
|
|
500
|
+
B as StrategyControl,
|
|
542
501
|
Fe as adjustProductsToSize,
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
502
|
+
De as formatProductPrice,
|
|
503
|
+
v as getBlockElement,
|
|
504
|
+
we as getCardComposition,
|
|
505
|
+
Be as getCurrentLayout,
|
|
506
|
+
Ue as getMainContainerTbody,
|
|
507
|
+
A as isPartnerManagedBlock,
|
|
508
|
+
ve as regenerateMobileProductRows,
|
|
509
|
+
V as regenerateProductRowsWithStyles,
|
|
510
|
+
U as setCurrencyAttributes,
|
|
511
|
+
Ae as updatePricesInPlace,
|
|
512
|
+
x as updateProductContentInPlace,
|
|
513
|
+
xe as updateSingleProductContent
|
|
555
514
|
};
|