@useinsider/guido 3.19.0-beta.cac604e → 3.19.0-beta.dcea8c0
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/@types/config/schemas.js +91 -104
- package/dist/composables/useLegacyStrategyConversion.js +23 -19
- package/dist/extensions/Blocks/Recommendation/block.js +53 -88
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +38 -45
- package/dist/extensions/Blocks/Recommendation/controls/main/strategy.js +49 -72
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +22 -41
- package/dist/src/@types/config/schemas.d.ts +0 -16
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +0 -6
- package/dist/src/stores/config.d.ts +0 -20
- package/dist/static/styles/components/recommendation-strategy.css.js +0 -9
- package/package.json +1 -2
- package/dist/extensions/Blocks/Recommendation/utils/partnerScope.js +0 -26
- package/dist/src/extensions/Blocks/Recommendation/utils/partnerScope.d.ts +0 -27
|
@@ -1,41 +1,39 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useConfig as
|
|
5
|
-
import { BlockId as
|
|
6
|
-
import { getMigrationBannerHtml as
|
|
7
|
-
import { Block as
|
|
8
|
-
import { CURRENT_CONFIG_VERSION as
|
|
9
|
-
import { RECOMMENDATION_ID_ATTR as
|
|
10
|
-
import { regenerateMobileProductRows as
|
|
11
|
-
import { ensureMobileCssRulesExist as
|
|
1
|
+
var y = Object.defineProperty;
|
|
2
|
+
var A = (l, c, t) => c in l ? y(l, c, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[c] = t;
|
|
3
|
+
var g = (l, c, t) => A(l, typeof c != "symbol" ? c + "" : c, t);
|
|
4
|
+
import { useConfig as h } from "../../../composables/useConfig.js";
|
|
5
|
+
import { BlockId as D } from "../../../enums/block.js";
|
|
6
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
7
|
+
import { Block as E, BlockCompositionType as S, ModificationDescription as p } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
8
|
+
import { CURRENT_CONFIG_VERSION as N, PRE_RRS_CONFIG_VERSION as O } from "./constants/defaultConfig.js";
|
|
9
|
+
import { RECOMMENDATION_ID_ATTR as m } from "./constants/selectors.js";
|
|
10
|
+
import { regenerateMobileProductRows as M } from "./controls/main/utils.js";
|
|
11
|
+
import { ensureMobileCssRulesExist as I, setMobileLayoutOptOut as R, hasMobileLayoutOptOut as w } from "./controls/mobileLayout/cssRules.js";
|
|
12
12
|
import { RecommendationConfigService as s } from "./services/configService.js";
|
|
13
|
-
import { useRecommendationExtensionStore as
|
|
14
|
-
import { getDefaultTemplate as
|
|
15
|
-
import { useRecommendationBlockWarning as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
let E = !1;
|
|
20
|
-
class at extends O {
|
|
13
|
+
import { useRecommendationExtensionStore as d } from "./store/recommendation.js";
|
|
14
|
+
import { getDefaultTemplate as T } from "./templates/grid/template.js";
|
|
15
|
+
import { useRecommendationBlockWarning as x } from "./useRecommendationBlockWarning.js";
|
|
16
|
+
const k = D.Recommendation, u = "recommendation-block-v2", B = "hide-price";
|
|
17
|
+
let b = !1;
|
|
18
|
+
class j extends E {
|
|
21
19
|
constructor() {
|
|
22
20
|
super();
|
|
23
21
|
/**
|
|
24
22
|
* Stores the ID generated in getTemplate() so onCreated() can reuse it.
|
|
25
23
|
* This avoids generating a new (different) ID in onCreated().
|
|
26
24
|
*/
|
|
27
|
-
|
|
25
|
+
g(this, "_pendingBlockId", null);
|
|
28
26
|
/** Ids already reset under their new name, so the deferred pass skips their stale snapshot. */
|
|
29
|
-
|
|
27
|
+
g(this, "_resetSourceIds", /* @__PURE__ */ new Set());
|
|
30
28
|
}
|
|
31
29
|
getId() {
|
|
32
|
-
return
|
|
30
|
+
return k;
|
|
33
31
|
}
|
|
34
32
|
getIcon() {
|
|
35
33
|
return "recommendation-icon";
|
|
36
34
|
}
|
|
37
35
|
getBlockCompositionType() {
|
|
38
|
-
return
|
|
36
|
+
return S.CONTAINER;
|
|
39
37
|
}
|
|
40
38
|
getName() {
|
|
41
39
|
return this.api.translate("Recommendation Block");
|
|
@@ -46,8 +44,8 @@ class at extends O {
|
|
|
46
44
|
);
|
|
47
45
|
}
|
|
48
46
|
getSettingsPanelTitleHtml() {
|
|
49
|
-
return
|
|
50
|
-
|
|
47
|
+
return C(
|
|
48
|
+
k,
|
|
51
49
|
this.api.translate("Recommendation Block"),
|
|
52
50
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Recommendation block and test your message to ensure it works properly.")
|
|
53
51
|
);
|
|
@@ -70,7 +68,7 @@ class at extends O {
|
|
|
70
68
|
*/
|
|
71
69
|
getTemplate() {
|
|
72
70
|
const t = this._generateNextId();
|
|
73
|
-
return this._pendingBlockId = t,
|
|
71
|
+
return this._pendingBlockId = t, T(t);
|
|
74
72
|
}
|
|
75
73
|
/**
|
|
76
74
|
* Called when a new block is dropped into the template
|
|
@@ -93,28 +91,27 @@ class at extends O {
|
|
|
93
91
|
}
|
|
94
92
|
const i = this._pendingBlockId ?? this._generateNextId();
|
|
95
93
|
this._pendingBlockId = null, this._assignRecommendationId(t, i);
|
|
96
|
-
const n =
|
|
94
|
+
const n = h().isFeatureEnabled("reusableRecommendationStrategy"), o = n && !s.hasConfig(t), { config: r, wasFreshDrop: a } = s.initializeConfig(
|
|
97
95
|
this.api,
|
|
98
96
|
t,
|
|
99
97
|
{
|
|
100
98
|
recommendationId: i,
|
|
101
|
-
configVersion: n ?
|
|
102
|
-
...o ? { partnerName: g().partnerName.value } : {},
|
|
99
|
+
configVersion: n ? N : O,
|
|
103
100
|
// An RRS block picks a strategy, not an algorithm, and its algorithm control is
|
|
104
101
|
// hidden. Keeping the `mostPopular` default would bake a most-popular feed URL
|
|
105
102
|
// at save for a block the user never configured.
|
|
106
103
|
...o ? { strategy: "" } : {}
|
|
107
104
|
}
|
|
108
|
-
),
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
|
|
105
|
+
), f = d();
|
|
106
|
+
if (f.setCurrentBlock(i), this._stampHidePrice(t, r.priceHideIfSameAsDiscounted), a) {
|
|
107
|
+
I(this.api);
|
|
108
|
+
const _ = this._getBlockElement(t);
|
|
109
|
+
_ && (R(this.api, _, !0), M({
|
|
113
110
|
currentNode: t,
|
|
114
111
|
documentModifier: this.api.getDocumentModifier()
|
|
115
112
|
}));
|
|
116
113
|
}
|
|
117
|
-
|
|
114
|
+
f.patchCurrentBlockConfig({ language: r.language }, { triggerRefetch: !1 }), this._warnIfMultipleBlocks();
|
|
118
115
|
}
|
|
119
116
|
/**
|
|
120
117
|
* Called when the document changes or template is loaded
|
|
@@ -134,13 +131,13 @@ class at extends O {
|
|
|
134
131
|
"Assign recommendation ID to legacy block"
|
|
135
132
|
);
|
|
136
133
|
}
|
|
137
|
-
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t)
|
|
134
|
+
this._healLingeringDuplicate(t), s.needsMigration(t) && this._migrateFromLegacy(t), this._healHidePriceAttr(t);
|
|
138
135
|
try {
|
|
139
|
-
|
|
136
|
+
b || (I(this.api), b = !0);
|
|
140
137
|
const e = s.getConfig(t), i = this._getBlockElement(t);
|
|
141
138
|
if (i) {
|
|
142
139
|
const n = !e.mobileLayoutEnabled;
|
|
143
|
-
|
|
140
|
+
w(i) !== n && R(this.api, i, n);
|
|
144
141
|
}
|
|
145
142
|
} catch {
|
|
146
143
|
}
|
|
@@ -154,7 +151,7 @@ class at extends O {
|
|
|
154
151
|
*/
|
|
155
152
|
onDelete(t) {
|
|
156
153
|
const e = this._getRecommendationId(t);
|
|
157
|
-
e &&
|
|
154
|
+
e && d().removeBlockState(e);
|
|
158
155
|
}
|
|
159
156
|
/**
|
|
160
157
|
* Warns (dark advisory toaster) when the design holds more than one live
|
|
@@ -170,7 +167,7 @@ class at extends O {
|
|
|
170
167
|
*/
|
|
171
168
|
_warnIfMultipleBlocks() {
|
|
172
169
|
try {
|
|
173
|
-
|
|
170
|
+
x().warnIfMultipleBlocks(this.api.getDocumentRootHtmlNode());
|
|
174
171
|
} catch {
|
|
175
172
|
}
|
|
176
173
|
}
|
|
@@ -182,9 +179,9 @@ class at extends O {
|
|
|
182
179
|
let t = 0;
|
|
183
180
|
try {
|
|
184
181
|
const e = this.api.getDocumentRoot();
|
|
185
|
-
e && "querySelectorAll" in e && e.querySelectorAll(`.${
|
|
182
|
+
e && "querySelectorAll" in e && e.querySelectorAll(`.${u}`).forEach((n) => {
|
|
186
183
|
if ("getAttribute" in n) {
|
|
187
|
-
const o = n.getAttribute(
|
|
184
|
+
const o = n.getAttribute(m), r = o ? parseInt(o) : 0;
|
|
188
185
|
r > t && (t = r);
|
|
189
186
|
}
|
|
190
187
|
});
|
|
@@ -200,9 +197,9 @@ class at extends O {
|
|
|
200
197
|
* the renamed one depending on where the module was dropped (SD-149916).
|
|
201
198
|
*/
|
|
202
199
|
_scheduleArrivalReset(t) {
|
|
203
|
-
|
|
200
|
+
h().isFeatureEnabled("reusableRecommendationStrategy") && setTimeout(() => {
|
|
204
201
|
const e = this._getRecommendationId(t);
|
|
205
|
-
e !== null && e > 0 && !this._resetSourceIds.delete(e) &&
|
|
202
|
+
e !== null && e > 0 && !this._resetSourceIds.delete(e) && d().resetArrivedBlock(e);
|
|
206
203
|
}, 0);
|
|
207
204
|
}
|
|
208
205
|
/**
|
|
@@ -225,7 +222,7 @@ class at extends O {
|
|
|
225
222
|
if (!i || !("querySelectorAll" in i))
|
|
226
223
|
return;
|
|
227
224
|
const n = i.querySelectorAll(
|
|
228
|
-
`.${
|
|
225
|
+
`.${u}[${m}="${e}"]`
|
|
229
226
|
);
|
|
230
227
|
if (n.length <= 1)
|
|
231
228
|
return;
|
|
@@ -250,7 +247,7 @@ class at extends O {
|
|
|
250
247
|
const e = this.api.getDocumentRoot();
|
|
251
248
|
if (e && "querySelectorAll" in e)
|
|
252
249
|
return e.querySelectorAll(
|
|
253
|
-
`.${
|
|
250
|
+
`.${u}[${m}="${t}"]`
|
|
254
251
|
).length > 1;
|
|
255
252
|
} catch {
|
|
256
253
|
}
|
|
@@ -258,8 +255,8 @@ class at extends O {
|
|
|
258
255
|
}
|
|
259
256
|
/** Assigns a fresh id to a duplicated block and syncs DOM, node config and store. */
|
|
260
257
|
_handleDuplicate(t, e) {
|
|
261
|
-
const i = this._reassignDuplicateId(t, e), n =
|
|
262
|
-
n.cloneBlockState(e, i), n.setCurrentBlock(i),
|
|
258
|
+
const i = this._reassignDuplicateId(t, e), n = d();
|
|
259
|
+
n.cloneBlockState(e, i), n.setCurrentBlock(i), h().isFeatureEnabled("reusableRecommendationStrategy") && (this._resetSourceIds.add(e), n.resetArrivedBlock(i)), this._warnIfMultipleBlocks();
|
|
263
260
|
}
|
|
264
261
|
/**
|
|
265
262
|
* Core id-reassignment for a duplicated block: rewrites the DOM
|
|
@@ -292,7 +289,7 @@ class at extends O {
|
|
|
292
289
|
if (!("getAttribute" in t))
|
|
293
290
|
return;
|
|
294
291
|
const n = `ins-recommendation-v3-block-${e}`, o = `ins-recommendation-v3-block-${i}`, r = this.api.getDocumentModifier();
|
|
295
|
-
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new
|
|
292
|
+
r.modifyHtml(t).removeClass(n).setClass(o), r.apply(new p(
|
|
296
293
|
`Reassign recommendation instance class ${n} -> ${o}`
|
|
297
294
|
));
|
|
298
295
|
}
|
|
@@ -307,7 +304,7 @@ class at extends O {
|
|
|
307
304
|
if (!i)
|
|
308
305
|
return;
|
|
309
306
|
const n = this.api.getDocumentModifier();
|
|
310
|
-
n.modifyHtml(i).setAttribute(
|
|
307
|
+
n.modifyHtml(i).setAttribute(m, e.toString()), n.apply(new p(`Assign recommendation ID ${e}`));
|
|
311
308
|
}
|
|
312
309
|
/**
|
|
313
310
|
* Stamps the `hide-price` attribute (read by email-service at send time) on
|
|
@@ -315,7 +312,7 @@ class at extends O {
|
|
|
315
312
|
*/
|
|
316
313
|
_stampHidePrice(t, e) {
|
|
317
314
|
const i = this._getBlockElement(t);
|
|
318
|
-
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new
|
|
315
|
+
i && this.api.getDocumentModifier().modifyHtml(i).setAttribute(B, String(e)).apply(new p("Stamp hide-price"));
|
|
319
316
|
}
|
|
320
317
|
/**
|
|
321
318
|
* Stamps `hide-price` from config only when the block lacks the attribute —
|
|
@@ -328,38 +325,6 @@ class at extends O {
|
|
|
328
325
|
const { priceHideIfSameAsDiscounted: i } = s.getConfig(t);
|
|
329
326
|
this._stampHidePrice(t, i);
|
|
330
327
|
}
|
|
331
|
-
/**
|
|
332
|
-
* Empties a block copied in from another account: its strategy and attribute types
|
|
333
|
-
* are account-scoped and would not resolve here (SD-151945). Layout, locale and
|
|
334
|
-
* currency stay. The write stamps the current account, so the next pass is a no-op.
|
|
335
|
-
*/
|
|
336
|
-
_resetForeignPartnerConfig(t) {
|
|
337
|
-
var I, R;
|
|
338
|
-
const e = this._getRecommendationId(t), i = this._getBlockElement(t);
|
|
339
|
-
if (e === null || !i || !s.hasConfig(t))
|
|
340
|
-
return;
|
|
341
|
-
const { partnerName: n, template: o } = g(), r = s.getConfig(t);
|
|
342
|
-
if (!W({
|
|
343
|
-
config: r,
|
|
344
|
-
blockId: e,
|
|
345
|
-
partnerName: n.value,
|
|
346
|
-
campaignUrls: (I = o.value) == null ? void 0 : I.recommendationCampaignUrls,
|
|
347
|
-
loadedIds: K(((R = o.value) == null ? void 0 : R.html) ?? "")
|
|
348
|
-
}))
|
|
349
|
-
return;
|
|
350
|
-
const u = z(r.composition), l = this.api.getDocumentModifier();
|
|
351
|
-
i.querySelectorAll(F).forEach((k) => {
|
|
352
|
-
var A;
|
|
353
|
-
(A = V(k)) != null && A.startsWith(H) && l.modifyHtml(k).delete();
|
|
354
|
-
}), l.modifyHtml(i).setAttribute(P, u.join(",")).setAttribute(x, "[]"), s.stageConfig(l, t, {
|
|
355
|
-
strategyId: "",
|
|
356
|
-
strategy: "",
|
|
357
|
-
filters: [],
|
|
358
|
-
productIds: [],
|
|
359
|
-
composition: u,
|
|
360
|
-
partnerName: n.value
|
|
361
|
-
}), l.apply(new h("Reset recommendation block copied from another account")), p().resetPartnerScopedConfig(e);
|
|
362
|
-
}
|
|
363
328
|
/**
|
|
364
329
|
* Gets the recommendation-id from a block node
|
|
365
330
|
*/
|
|
@@ -367,7 +332,7 @@ class at extends O {
|
|
|
367
332
|
const e = this._getBlockElement(t);
|
|
368
333
|
if (!e || !("getAttribute" in e))
|
|
369
334
|
return null;
|
|
370
|
-
const i = e.getAttribute(
|
|
335
|
+
const i = e.getAttribute(m);
|
|
371
336
|
if (!i)
|
|
372
337
|
return null;
|
|
373
338
|
const n = parseInt(i);
|
|
@@ -379,10 +344,10 @@ class at extends O {
|
|
|
379
344
|
_getBlockElement(t) {
|
|
380
345
|
if ("getAttribute" in t) {
|
|
381
346
|
const e = t.getAttribute("class");
|
|
382
|
-
if (e && e.includes(
|
|
347
|
+
if (e && e.includes(u))
|
|
383
348
|
return t;
|
|
384
349
|
}
|
|
385
|
-
return "querySelector" in t ? t.querySelector(`.${
|
|
350
|
+
return "querySelector" in t ? t.querySelector(`.${u}`) ?? null : null;
|
|
386
351
|
}
|
|
387
352
|
/**
|
|
388
353
|
* Migrate configuration from legacy format
|
|
@@ -392,6 +357,6 @@ class at extends O {
|
|
|
392
357
|
}
|
|
393
358
|
}
|
|
394
359
|
export {
|
|
395
|
-
|
|
396
|
-
|
|
360
|
+
k as BLOCK_ID,
|
|
361
|
+
j as RecommendationBlock
|
|
397
362
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (g,
|
|
4
|
-
import { useConfig as
|
|
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";
|
|
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
|
|
9
|
+
import { RecommendationConfigService as l } 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
|
|
13
|
+
import { ALGORITHM_CONTROL_ID as dt } 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
|
|
33
|
-
import { adjustProductsToSize as Et, formatProductPrice as Ft, getCardComposition as Dt, getCurrentLayout as wt, getMainContainerTbody as
|
|
34
|
-
import { useDebounceFn as
|
|
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";
|
|
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",
|
|
61
|
+
i(this, "_debouncedFetchProducts", h(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",
|
|
79
|
+
i(this, "_debouncedRegenerateWithProducts", h(() => {
|
|
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 (
|
|
84
|
+
if (v(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 =
|
|
118
|
+
return this.rrsEnabled = p().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 :
|
|
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;
|
|
144
144
|
e.classList.toggle("strategy-block", n), e.classList.toggle("legacy-strategy-block", s);
|
|
145
145
|
}
|
|
146
146
|
async onRender() {
|
|
@@ -209,30 +209,23 @@ class at extends N {
|
|
|
209
209
|
const e = this.store.blockStates[t];
|
|
210
210
|
if (!e)
|
|
211
211
|
return;
|
|
212
|
-
const o = JSON.stringify(
|
|
212
|
+
const o = JSON.stringify(l.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 ?
|
|
218
|
+
return t ? l.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;
|
|
225
225
|
this.pendingNodeConfigWrite = {
|
|
226
226
|
blockId: t,
|
|
227
227
|
node: this.currentNode,
|
|
228
|
-
updates: {
|
|
229
|
-
filters: e,
|
|
230
|
-
strategy: o,
|
|
231
|
-
strategyId: n,
|
|
232
|
-
size: s,
|
|
233
|
-
configVersion: r,
|
|
234
|
-
...l.value ? { partnerName: l.value } : {}
|
|
235
|
-
}
|
|
228
|
+
updates: { filters: e, strategy: o, strategyId: n, size: s, configVersion: r }
|
|
236
229
|
};
|
|
237
230
|
}
|
|
238
231
|
/**
|
|
@@ -247,7 +240,7 @@ class at extends N {
|
|
|
247
240
|
*/
|
|
248
241
|
_stagePendingNodeConfig(t) {
|
|
249
242
|
const e = this.pendingNodeConfigWrite;
|
|
250
|
-
return !e || !this.currentNode ? !1 : (
|
|
243
|
+
return !e || !this.currentNode ? !1 : (l.stageConfig(t, this.currentNode, e.updates), !0);
|
|
251
244
|
}
|
|
252
245
|
/**
|
|
253
246
|
* Arms the guaranteed fallback write, once the product fetch has settled. The
|
|
@@ -271,12 +264,12 @@ class at extends N {
|
|
|
271
264
|
const t = this.pendingNodeConfigWrite;
|
|
272
265
|
if (this.pendingNodeConfigWrite = null, this._clearConfigFlush(), !t || !this.api)
|
|
273
266
|
return;
|
|
274
|
-
const e = t.blockId === this.store.currentRecommendationId && this.currentNode ? this.currentNode : t.node, o =
|
|
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 ||
|
|
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");
|
|
276
269
|
}
|
|
277
270
|
_syncNodeConfigToStore() {
|
|
278
271
|
var n;
|
|
279
|
-
const t =
|
|
272
|
+
const t = l.getConfig(this.currentNode), e = this.store.currentRecommendationId, o = e !== null && ((n = this.store.blockStates[e]) == null ? void 0 : n.isInitialized);
|
|
280
273
|
this.store.patchCurrentBlockConfig({
|
|
281
274
|
strategy: t.strategy,
|
|
282
275
|
strategyId: t.strategyId,
|
|
@@ -341,12 +334,12 @@ class at extends N {
|
|
|
341
334
|
_applySmartDefaults() {
|
|
342
335
|
if (!this.currentNode || !this.api)
|
|
343
336
|
return;
|
|
344
|
-
const t =
|
|
337
|
+
const t = l.getConfig(this.currentNode), e = {};
|
|
345
338
|
let o = null, n = null, s = null;
|
|
346
339
|
if (t.currency.code === a.currency.code) {
|
|
347
340
|
const { currencyList: r } = this.store;
|
|
348
341
|
r.length > 0 && (r.some(
|
|
349
|
-
(
|
|
342
|
+
(u) => u.value === `price.${a.currency.code}`
|
|
350
343
|
) || (o = r[0].value.replace("price.", ""), e.currency = {
|
|
351
344
|
...a.currency,
|
|
352
345
|
code: o,
|
|
@@ -356,21 +349,21 @@ class at extends N {
|
|
|
356
349
|
if (t.strategy === a.strategy) {
|
|
357
350
|
const r = this.store.getActivePredictiveAlgorithms;
|
|
358
351
|
r.length > 0 && (r.some(
|
|
359
|
-
(
|
|
352
|
+
(u) => u.value === a.strategy
|
|
360
353
|
) || (n = r[0].value, e.strategy = n));
|
|
361
354
|
}
|
|
362
355
|
if (t.language === a.language) {
|
|
363
356
|
const r = this.store.getLanguages;
|
|
364
357
|
r.length > 0 && (r.some(
|
|
365
|
-
(
|
|
358
|
+
(u) => u.value === a.language
|
|
366
359
|
) || (s = r[0].value, e.language = s));
|
|
367
360
|
}
|
|
368
|
-
!o && !n && !s || (
|
|
361
|
+
!o && !n && !s || (l.updateConfig(
|
|
369
362
|
this.api,
|
|
370
363
|
this.currentNode,
|
|
371
364
|
e,
|
|
372
365
|
"Applied smart defaults"
|
|
373
|
-
), o && e.currency &&
|
|
366
|
+
), o && e.currency && A({
|
|
374
367
|
currentNode: this.currentNode,
|
|
375
368
|
documentModifier: this.api.getDocumentModifier(),
|
|
376
369
|
currency: e.currency
|
|
@@ -394,7 +387,7 @@ class at extends N {
|
|
|
394
387
|
* Reads the recommendation-id attribute from the block element within the node
|
|
395
388
|
*/
|
|
396
389
|
_getRecommendationIdFromNode(t) {
|
|
397
|
-
const e =
|
|
390
|
+
const e = B(t);
|
|
398
391
|
if (!e || !("getAttribute" in e))
|
|
399
392
|
return null;
|
|
400
393
|
const o = e.getAttribute(I);
|
|
@@ -427,13 +420,13 @@ class at extends N {
|
|
|
427
420
|
}
|
|
428
421
|
const r = t.$state.configVersion;
|
|
429
422
|
r !== o && (o = r, this._capturePendingNodeConfigWrite(), this._isPendingStrategyIdChange() && this._flushPendingNodeConfig(), this._debouncedFetchProducts());
|
|
430
|
-
const
|
|
431
|
-
|
|
423
|
+
const d = t.recommendationProducts, u = d !== e, f = Array.isArray(d) && d.length > 0;
|
|
424
|
+
u && f && (e = d, this._debouncedRegenerateWithProducts());
|
|
432
425
|
});
|
|
433
426
|
}
|
|
434
427
|
}
|
|
435
428
|
export {
|
|
436
|
-
|
|
429
|
+
dt as ALGORITHM_CONTROL_ID,
|
|
437
430
|
T as AlgorithmControl,
|
|
438
431
|
W as CONTROL_BLOCK_ID,
|
|
439
432
|
gt as CURRENCY_CONTROL_ID,
|
|
@@ -457,15 +450,15 @@ export {
|
|
|
457
450
|
w as StrategyControl,
|
|
458
451
|
Et as adjustProductsToSize,
|
|
459
452
|
Ft as formatProductPrice,
|
|
460
|
-
|
|
453
|
+
B as getBlockElement,
|
|
461
454
|
Dt as getCardComposition,
|
|
462
455
|
wt as getCurrentLayout,
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
456
|
+
At as getMainContainerTbody,
|
|
457
|
+
v as isPartnerManagedBlock,
|
|
458
|
+
Bt as regenerateMobileProductRows,
|
|
466
459
|
U as regenerateProductRowsWithStyles,
|
|
467
|
-
|
|
468
|
-
|
|
460
|
+
A as setCurrencyAttributes,
|
|
461
|
+
vt as updatePricesInPlace,
|
|
469
462
|
x as updateProductContentInPlace,
|
|
470
463
|
xt as updateSingleProductContent
|
|
471
464
|
};
|