@useinsider/guido 3.21.0-beta.9f9407d → 3.21.0-beta.a4cc621

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.
@@ -90,21 +90,21 @@ function F(t, e = {}) {
90
90
  documentModifier: o,
91
91
  products: r,
92
92
  layout: s,
93
- composition: i
93
+ composition: l
94
94
  } = t;
95
95
  if (!n || !("querySelector" in n))
96
96
  return !1;
97
- const u = s ?? T(n), l = g.getConfig(n);
98
- if (u === "list" || !l.mobileLayoutEnabled)
97
+ const u = s ?? T(n), i = g.getConfig(n);
98
+ if (u === "list" || !i.mobileLayoutEnabled)
99
99
  return ne({ currentNode: n, documentModifier: o });
100
- const c = E(), f = v(r, c.recommendationProducts), a = i ?? B(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${x(f, u, {
101
- productsPerRow: l.mobileCardsInRow,
102
- composition: a,
100
+ const c = E(), a = v(r, c.recommendationProducts), f = l ?? B(n, c.filterList), p = `<td><table class="ins-recommendation-product-container ins-recommendation-mobile-container" width="100%" cellpadding="0" cellspacing="0" border="0">${x(a, u, {
101
+ productsPerRow: i.mobileCardsInRow,
102
+ composition: f,
103
103
  filterList: c.filterList,
104
- priceInline: !l.priceMovedToNextLine,
104
+ priceInline: !i.priceMovedToNextLine,
105
105
  // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
106
- cellPadding: j(l.mobileColumnSpacing),
107
- rowSpacingPx: l.mobileRowSpacing,
106
+ cellPadding: j(i.mobileColumnSpacing),
107
+ rowSpacingPx: i.mobileRowSpacing,
108
108
  ...e
109
109
  })}</table></td>`, y = n.querySelector(k);
110
110
  return y ? (o.modifyHtml(y).setInnerHtml(p), !0) : (ie(n, o, p), !1);
@@ -118,17 +118,17 @@ function le(t, e = {}) {
118
118
  documentModifier: o,
119
119
  products: r,
120
120
  layout: s,
121
- composition: i
121
+ composition: l
122
122
  } = t;
123
123
  if (!n || !("querySelector" in n))
124
124
  return !1;
125
125
  const u = n.querySelector(w) ?? n.querySelector(Y);
126
126
  if (!u)
127
127
  return !1;
128
- const l = E(), c = v(r, l.recommendationProducts), { cardsInRow: f } = g.getConfig(n), a = i ?? B(n, l.filterList), d = s ?? T(n), p = g.getConfig(n), y = x(c, d, {
129
- productsPerRow: f,
130
- composition: a,
131
- filterList: l.filterList,
128
+ const i = E(), c = v(r, i.recommendationProducts), { cardsInRow: a } = g.getConfig(n), f = l ?? B(n, i.filterList), d = s ?? T(n), p = g.getConfig(n), y = x(c, d, {
129
+ productsPerRow: a,
130
+ composition: f,
131
+ filterList: i.filterList,
132
132
  priceInline: !p.priceMovedToNextLine,
133
133
  // Match the initial render's gutter so a regeneration never changes block height (SD-143023, #386).
134
134
  cellPadding: j(p.columnSpacing),
@@ -154,14 +154,14 @@ function ue(t, e, n) {
154
154
  const r = o.getAttribute(q);
155
155
  if (!r)
156
156
  return !1;
157
- const s = E(), i = r.split(",").filter(Boolean), u = H(i, o, s.filterList), l = [], c = u.join(",") !== i.join(",");
158
- c && l.push([q, u.join(",")]);
159
- const f = ce(
157
+ const s = E(), l = r.split(",").filter(Boolean), u = H(l, o, s.filterList), i = [], c = u.join(",") !== l.join(",");
158
+ c && i.push([q, u.join(",")]);
159
+ const a = ce(
160
160
  o.getAttribute(h)
161
- ), a = f && J(f, o, s.filterList);
162
- if (f && a && a.join(",") !== f.join(",") && l.push([h, JSON.stringify(a)]), l.length === 0)
161
+ ), f = a && J(a, o, s.filterList);
162
+ if (a && f && f.join(",") !== a.join(",") && i.push([h, JSON.stringify(f)]), i.length === 0)
163
163
  return !1;
164
- if (l.forEach(([d, p]) => {
164
+ if (i.forEach(([d, p]) => {
165
165
  e.modifyHtml(o).setAttribute(d, p);
166
166
  }), c && g.hasConfig(t)) {
167
167
  const d = {
@@ -179,21 +179,20 @@ function Re(t) {
179
179
  afterRegenerate: o,
180
180
  products: r,
181
181
  layout: s,
182
- composition: i,
183
- skipStylePreservation: u,
184
- description: l
182
+ composition: l,
183
+ skipStylePreservation: u
185
184
  } = t;
186
185
  if (!e)
187
186
  return !1;
188
- const c = u ? {} : D(e), f = {
187
+ const i = u ? {} : D(e), c = {
189
188
  currentNode: e,
190
189
  documentModifier: n,
191
190
  products: r,
192
191
  layout: s,
193
- composition: i
192
+ composition: l
194
193
  };
195
- let a = le(f, c);
196
- return a = F(f, c) || a, a && (ue(e, n, i), n.apply(new C(l ?? "Regenerate products with styles"))), o == null || o(), a;
194
+ let a = le(c, i);
195
+ return a = F(c, i) || a, a && (ue(e, n, l), n.apply(new C("Regenerate products with styles"))), o == null || o(), a;
197
196
  }
198
197
  function qe(t, e) {
199
198
  return t.length === e ? t : t.length > e ? t.slice(0, e) : [...t, ...U(e - t.length)];
@@ -217,28 +216,28 @@ function R(t, e = "price") {
217
216
  });
218
217
  }
219
218
  function se(t) {
220
- var s, i;
221
- const e = K(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((i = t.price) == null ? void 0 : i[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
219
+ var s, l;
220
+ const e = K(), n = ((s = t.original_price) == null ? void 0 : s[e.code]) ?? Object.values(t.original_price ?? {})[0] ?? 0, o = ((l = t.price) == null ? void 0 : l[e.code]) ?? Object.values(t.price ?? {})[0] ?? 0, r = n > 0 ? Math.round((n - o) / n * 100) : 0;
222
221
  return r > 0 ? `-${r}%` : "0%";
223
222
  }
224
223
  function V(t) {
225
- const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: i } = t;
224
+ const { documentModifier: e, product: n, priceEl: o, oldPriceEl: r, omnibusPriceEl: s, omnibusDiscountEl: l } = t;
226
225
  let u = !1;
227
226
  if (o && "querySelector" in o) {
228
- const l = o.querySelector("strong") ?? o.querySelector("p"), c = R(n, "price");
229
- S(e, l ?? null, c) && (u = !0);
227
+ const i = o.querySelector("strong") ?? o.querySelector("p"), c = R(n, "price");
228
+ S(e, i ?? null, c) && (u = !0);
230
229
  }
231
230
  if (r && "querySelector" in r) {
232
- const l = r.querySelector("strong") ?? r.querySelector("p"), c = R(n, "original_price");
233
- S(e, l ?? null, c) && (u = !0), A(e, r, "data-same-price", String(Z(n))) && (u = !0);
231
+ const i = r.querySelector("strong") ?? r.querySelector("p"), c = R(n, "original_price");
232
+ S(e, i ?? null, c) && (u = !0), A(e, r, "data-same-price", String(Z(n))) && (u = !0);
234
233
  }
235
234
  if (s && "querySelector" in s) {
236
- const l = s.querySelector(".omnibus-price-value") ?? null, c = R(n, "original_price");
237
- S(e, l, c) && (u = !0);
235
+ const i = s.querySelector(".omnibus-price-value") ?? null, c = R(n, "original_price");
236
+ S(e, i, c) && (u = !0);
238
237
  }
239
- if (i && "querySelector" in i) {
240
- const l = i.querySelector(".omnibus-discount-value") ?? null, c = se(n);
241
- S(e, l, c) && (u = !0);
238
+ if (l && "querySelector" in l) {
239
+ const i = l.querySelector(".omnibus-discount-value") ?? null, c = se(n);
240
+ S(e, i, c) && (u = !0);
242
241
  }
243
242
  return u;
244
243
  }
@@ -249,37 +248,37 @@ function ae(t) {
249
248
  imageEl: o,
250
249
  nameEl: r,
251
250
  priceEl: s,
252
- oldPriceEl: i,
251
+ oldPriceEl: l,
253
252
  omnibusPriceEl: u,
254
- omnibusDiscountEl: l,
253
+ omnibusDiscountEl: i,
255
254
  buttonEl: c
256
255
  } = t;
257
- let f = !1;
256
+ let a = !1;
258
257
  if (o && "querySelector" in o) {
259
- const a = o.querySelector("img");
260
- if (a) {
261
- const p = A(e, a, "src", Q(n.image_url)), y = A(e, a, "alt", n.name);
262
- f = f || p || y;
258
+ const f = o.querySelector("img");
259
+ if (f) {
260
+ const p = A(e, f, "src", Q(n.image_url)), y = A(e, f, "alt", n.name);
261
+ a = a || p || y;
263
262
  }
264
263
  const d = o.querySelector("a");
265
- d && A(e, d, "href", n.url) && (f = !0);
264
+ d && A(e, d, "href", n.url) && (a = !0);
266
265
  }
267
266
  if (r && "querySelector" in r) {
268
- const a = r.querySelector("strong") ?? r.querySelector("p");
269
- S(e, a ?? null, n.name) && (f = !0);
267
+ const f = r.querySelector("strong") ?? r.querySelector("p");
268
+ S(e, f ?? null, n.name) && (a = !0);
270
269
  }
271
270
  if (V({
272
271
  documentModifier: e,
273
272
  product: n,
274
273
  priceEl: s,
275
- oldPriceEl: i,
274
+ oldPriceEl: l,
276
275
  omnibusPriceEl: u,
277
- omnibusDiscountEl: l
278
- }) && (f = !0), c && "querySelector" in c) {
279
- const a = c.querySelector("a.es-button") || c.querySelector("a");
280
- a && A(e, a, "href", n.url) && (f = !0);
276
+ omnibusDiscountEl: i
277
+ }) && (a = !0), c && "querySelector" in c) {
278
+ const f = c.querySelector("a.es-button") || c.querySelector("a");
279
+ f && A(e, f, "href", n.url) && (a = !0);
281
280
  }
282
- return f;
281
+ return a;
283
282
  }
284
283
  function G(t) {
285
284
  return "querySelector" in t ? t.querySelector(w) ?? t : t;
@@ -303,26 +302,26 @@ function de(t, e, n) {
303
302
  if (o.length === 0)
304
303
  return !1;
305
304
  const r = /* @__PURE__ */ new Map();
306
- o.forEach((i) => {
307
- if (!("getAttribute" in i))
305
+ o.forEach((l) => {
306
+ if (!("getAttribute" in l))
308
307
  return;
309
- const u = i.getAttribute(z);
308
+ const u = l.getAttribute(z);
310
309
  if (!u)
311
310
  return;
312
- const l = r.get(u) ?? [];
313
- l.push(i), r.set(u, l);
311
+ const i = r.get(u) ?? [];
312
+ i.push(l), r.set(u, i);
314
313
  });
315
314
  let s = !1;
316
- return r.forEach((i, u) => {
317
- const l = Math.min(i.length, n.length);
318
- i.slice(0, l).forEach((c, f) => {
315
+ return r.forEach((l, u) => {
316
+ const i = Math.min(l.length, n.length);
317
+ l.slice(0, i).forEach((c, a) => {
319
318
  if (!("querySelector" in c))
320
319
  return;
321
- const a = fe(u, n[f]);
322
- if (a === null)
320
+ const f = fe(u, n[a]);
321
+ if (f === null)
323
322
  return;
324
323
  const d = c.querySelector("p") ?? null;
325
- S(e, d, a) && (s = !0);
324
+ S(e, d, f) && (s = !0);
326
325
  });
327
326
  }), s;
328
327
  }
@@ -335,55 +334,55 @@ function _(t, e, n) {
335
334
  `[esd-extension-block-id="${m.NAME}"]`
336
335
  ), s = t.querySelectorAll(
337
336
  `[esd-extension-block-id="${m.PRICE}"]`
338
- ), i = t.querySelectorAll(
337
+ ), l = t.querySelectorAll(
339
338
  `[esd-extension-block-id="${m.OLD_PRICE}"]`
340
339
  ), u = t.querySelectorAll(
341
340
  `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
342
- ), l = t.querySelectorAll(
341
+ ), i = t.querySelectorAll(
343
342
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
344
343
  ), c = t.querySelectorAll(
345
344
  `[esd-extension-block-id="${m.BUTTON}"]`
346
- ), f = Math.min(o.length, n.length);
347
- let a = !1;
348
- for (let d = 0; d < f; d++) {
345
+ ), a = Math.min(o.length, n.length);
346
+ let f = !1;
347
+ for (let d = 0; d < a; d++) {
349
348
  const p = ae({
350
349
  documentModifier: e,
351
350
  product: n[d],
352
351
  imageEl: o[d] ?? null,
353
352
  nameEl: r[d] ?? null,
354
353
  priceEl: s[d] ?? null,
355
- oldPriceEl: i[d] ?? null,
354
+ oldPriceEl: l[d] ?? null,
356
355
  omnibusPriceEl: u[d] ?? null,
357
- omnibusDiscountEl: l[d] ?? null,
356
+ omnibusDiscountEl: i[d] ?? null,
358
357
  buttonEl: c[d] ?? null
359
358
  });
360
- a = a || p;
359
+ f = f || p;
361
360
  }
362
- return de(t, e, n) && (a = !0), a;
361
+ return de(t, e, n) && (f = !0), f;
363
362
  }
364
363
  function he(t) {
365
- const { currentNode: e, documentModifier: n, products: o, onApplied: r, description: s } = t;
364
+ const { currentNode: e, documentModifier: n, products: o, onApplied: r } = t;
366
365
  if (!e || !("querySelectorAll" in e))
367
366
  return !1;
368
- const i = G(e);
369
- if (!("querySelectorAll" in i) || i.querySelectorAll(
367
+ const s = G(e);
368
+ if (!("querySelectorAll" in s) || s.querySelectorAll(
370
369
  `[esd-extension-block-id="${m.IMAGE}"]`
371
370
  ).length !== o.length)
372
371
  return !1;
373
- let l = _(i, n, o);
374
- const c = T(e), f = g.getConfig(e);
375
- if (c !== "list" && f.mobileLayoutEnabled && "querySelector" in e) {
372
+ let u = _(s, n, o);
373
+ const i = T(e), c = g.getConfig(e);
374
+ if (i !== "list" && c.mobileLayoutEnabled && "querySelector" in e) {
376
375
  const a = e.querySelector(L);
377
376
  if (a) {
378
- const d = _(
377
+ const f = _(
379
378
  a,
380
379
  n,
381
380
  o
382
381
  );
383
- l = l || d;
382
+ u = u || f;
384
383
  }
385
384
  }
386
- return l && (n.apply(new C(s ?? "Updated product content in-place")), r == null || r()), !0;
385
+ return u && (n.apply(new C("Updated product content in-place")), r == null || r()), !0;
387
386
  }
388
387
  function N(t, e, n) {
389
388
  if (!("querySelectorAll" in t))
@@ -394,10 +393,10 @@ function N(t, e, n) {
394
393
  `[esd-extension-block-id="${m.OLD_PRICE}"]`
395
394
  ), s = t.querySelectorAll(
396
395
  `[esd-extension-block-id="${m.OMNIBUS_PRICE}"]`
397
- ), i = t.querySelectorAll(
396
+ ), l = t.querySelectorAll(
398
397
  `[esd-extension-block-id="${m.OMNIBUS_DISCOUNT}"]`
399
398
  ), u = Math.min(o.length, n.length);
400
- let l = !1;
399
+ let i = !1;
401
400
  for (let c = 0; c < u; c++)
402
401
  V({
403
402
  documentModifier: e,
@@ -405,9 +404,9 @@ function N(t, e, n) {
405
404
  priceEl: o[c] ?? null,
406
405
  oldPriceEl: r[c] ?? null,
407
406
  omnibusPriceEl: s[c] ?? null,
408
- omnibusDiscountEl: i[c] ?? null
409
- }) && (l = !0);
410
- return l;
407
+ omnibusDiscountEl: l[c] ?? null
408
+ }) && (i = !0);
409
+ return i;
411
410
  }
412
411
  function Me(t) {
413
412
  const { currentNode: e, documentModifier: n } = t;
@@ -419,25 +418,25 @@ function Me(t) {
419
418
  if (r.length === 0)
420
419
  return !1;
421
420
  const s = G(e);
422
- let i = N(s, n, r);
423
- const u = T(e), l = g.getConfig(e);
424
- if (u !== "list" && l.mobileLayoutEnabled && "querySelector" in e) {
421
+ let l = N(s, n, r);
422
+ const u = T(e), i = g.getConfig(e);
423
+ if (u !== "list" && i.mobileLayoutEnabled && "querySelector" in e) {
425
424
  const c = e.querySelector(L);
426
425
  if (c) {
427
- const f = N(c, n, r);
428
- i = i || f;
426
+ const a = N(c, n, r);
427
+ l = l || a;
429
428
  }
430
429
  }
431
- return i && n.apply(new C("Updated price formatting in-place")), i;
430
+ return l && n.apply(new C("Updated price formatting in-place")), l;
432
431
  }
433
432
  function Ie(t) {
434
433
  const { currentNode: e, documentModifier: n, currency: o } = t, r = P(e);
435
434
  if (!r)
436
435
  return;
437
- const s = o.alignment === "before" ? "0" : "1", i = (u, l) => {
438
- n.modifyHtml(r).setAttribute(u, l);
436
+ const s = o.alignment === "before" ? "0" : "1", l = (u, i) => {
437
+ n.modifyHtml(r).setAttribute(u, i);
439
438
  };
440
- i(b.CURRENCY, o.code), i(b.SYMBOL, o.symbol), i(b.ALIGNMENT, s), i(b.THOUSAND_SEPARATOR, o.thousandSeparator), i(b.DECIMAL_SEPARATOR, o.decimalSeparator), i(b.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new C("Update currency attributes"));
439
+ l(b.CURRENCY, o.code), l(b.SYMBOL, o.symbol), l(b.ALIGNMENT, s), l(b.THOUSAND_SEPARATOR, o.thousandSeparator), l(b.DECIMAL_SEPARATOR, o.decimalSeparator), l(b.DECIMAL_COUNT, o.decimalCount.toString()), n.apply(new C("Update currency attributes"));
441
440
  }
442
441
  export {
443
442
  qe as adjustProductsToSize,
@@ -1,83 +1,68 @@
1
- import { ModificationDescription as d } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
- import { RECOMMENDATION_ID_ATTR as g } from "../constants/selectors.js";
3
- import { isPartnerManagedBlock as a, updateProductContentInPlace as m, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
1
+ import { ModificationDescription as g } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
2
+ import { RECOMMENDATION_ID_ATTR as l } from "../constants/selectors.js";
3
+ import { isPartnerManagedBlock as m, updateProductContentInPlace as d, regenerateProductRowsWithStyles as C } from "../controls/main/utils.js";
4
4
  import { RecommendationConfigService as c } from "../services/configService.js";
5
- import { useRecommendationExtensionStore as N } from "../store/recommendation.js";
5
+ import { useRecommendationExtensionStore as y } from "../store/recommendation.js";
6
6
  let r = null;
7
- function J(t) {
8
- r = t;
7
+ function M(n) {
8
+ r = n;
9
9
  }
10
- function l(t) {
11
- const n = r == null ? void 0 : r.getDocumentRootHtmlNode();
12
- return !n || !("querySelector" in n) ? null : n.querySelector(`[${g}="${t}"]`) ?? null;
10
+ function a(n) {
11
+ const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
12
+ return !e || !("querySelector" in e) ? null : e.querySelector(`[${l}="${n}"]`) ?? null;
13
13
  }
14
- function S(t, n) {
15
- const e = c.getConfig(t);
16
- return Object.keys(n).some((o) => JSON.stringify(e[o]) !== JSON.stringify(n[o]));
14
+ function N(n, e) {
15
+ const o = c.getConfig(n);
16
+ return Object.keys(e).some((t) => JSON.stringify(o[t]) !== JSON.stringify(e[t]));
17
17
  }
18
- function y(t, n) {
19
- const e = c.getConfig(t);
20
- return ["filters", "strategy", "strategyId", "size", "productIds"].some((o) => o in n && JSON.stringify(e[o]) !== JSON.stringify(n[o]));
18
+ function S(n, e) {
19
+ const o = c.getConfig(n);
20
+ return ["filters", "strategy", "strategyId", "size"].some((t) => t in e && JSON.stringify(o[t]) !== JSON.stringify(e[t]));
21
21
  }
22
- const p = "Updated product IDs";
23
- function I(t, n) {
24
- if (!("productIds" in n))
25
- return !1;
26
- const e = c.getConfig(t);
27
- return JSON.stringify(e.productIds) !== JSON.stringify(n.productIds);
28
- }
29
- function M(t, n, e) {
30
- const o = l(t);
31
- if (!r || !o)
32
- return !1;
33
- if (y(o, n)) {
34
- const i = I(o, n) ? p : e;
35
- c.updateConfig(r, o, n, i);
36
- }
37
- return !0;
22
+ function P(n, e, o) {
23
+ const t = a(n);
24
+ return !r || !t ? !1 : (S(t, e) && c.updateConfig(r, t, e, o), !0);
38
25
  }
39
- function O(t, n) {
40
- const e = N(), o = e.currentRecommendationId;
41
- if (o === t || !e.blockStates[t]) {
42
- n();
26
+ function p(n, e) {
27
+ const o = y(), t = o.currentRecommendationId;
28
+ if (t === n || !o.blockStates[n]) {
29
+ e();
43
30
  return;
44
31
  }
45
- e.setCurrentBlock(t);
32
+ o.setCurrentBlock(n);
46
33
  try {
47
- n();
34
+ e();
48
35
  } finally {
49
- e.$patch({ currentRecommendationId: o });
36
+ o.$patch({ currentRecommendationId: t });
50
37
  }
51
38
  }
52
- function E(t) {
53
- const n = r == null ? void 0 : r.getDocumentRootHtmlNode();
54
- return !n || !("querySelectorAll" in n) ? [] : n.querySelectorAll(`[${g}="${t}"]`).map((e) => c.getConfig(e));
39
+ function I(n) {
40
+ const e = r == null ? void 0 : r.getDocumentRootHtmlNode();
41
+ return !e || !("querySelectorAll" in e) ? [] : e.querySelectorAll(`[${l}="${n}"]`).map((o) => c.getConfig(o));
55
42
  }
56
- function T(t, n, e, o) {
57
- const i = l(t);
43
+ function $(n, e, o, t) {
44
+ const i = a(n);
58
45
  if (!r || !i)
59
46
  return !1;
60
- const f = r.getDocumentModifier(), s = S(i, n);
61
- if (c.stageConfig(f, i, n), a(i))
62
- return s && f.apply(new d(o)), !0;
47
+ const f = r.getDocumentModifier(), s = N(i, e);
48
+ if (c.stageConfig(f, i, e), m(i))
49
+ return s && f.apply(new g(t)), !0;
63
50
  let u = !1;
64
- return O(t, () => {
65
- m({
51
+ return p(n, () => {
52
+ d({
66
53
  currentNode: i,
67
54
  documentModifier: f,
68
- products: e,
55
+ products: o,
69
56
  onApplied: () => {
70
57
  u = !0;
71
58
  }
72
- }) || (u = C({ currentNode: i, documentModifier: f, products: e }));
73
- }), !u && s && f.apply(new d(o)), !0;
59
+ }) || (u = C({ currentNode: i, documentModifier: f, products: o }));
60
+ }), !u && s && f.apply(new g(t)), !0;
74
61
  }
75
62
  export {
76
- p as PRODUCT_IDS_DESCRIPTION,
77
- T as commitBlockChangeOutsidePanel,
78
- y as hasEditedConfigChange,
79
- I as isProductIdsChange,
80
- E as readBlockNodeConfigs,
81
- J as registerNodeConfigWriter,
82
- M as writeBlockConfigOutsidePanel
63
+ $ as commitBlockChangeOutsidePanel,
64
+ S as hasEditedConfigChange,
65
+ I as readBlockNodeConfigs,
66
+ M as registerNodeConfigWriter,
67
+ P as writeBlockConfigOutsidePanel
83
68
  };
@@ -1,43 +1,64 @@
1
- import { useRecommendationExtensionStore as g } from "../store/recommendation.js";
2
- import { refreshBlockOutsidePanel as y } from "./blockRefresh.js";
3
- import { toBlockUrlConfig as a } from "./blockUrlConfig.js";
4
- import { commitBlockChangeOutsidePanel as l, readBlockNodeConfigs as S } from "./nodeConfigWriter.js";
5
- function d(e, t) {
6
- const r = JSON.stringify(a(t));
7
- return S(e).find((o) => JSON.stringify(a(o)) !== r) ?? t;
1
+ import { useRecommendationExtensionStore as f } from "../store/recommendation.js";
2
+ import { refreshBlockOutsidePanel as l } from "./blockRefresh.js";
3
+ import { toBlockUrlConfig as c } from "./blockUrlConfig.js";
4
+ import { readBlockNodeConfigs as m, commitBlockChangeOutsidePanel as d } from "./nodeConfigWriter.js";
5
+ function u(n, t) {
6
+ const r = JSON.stringify(c(t));
7
+ return m(n).find((s) => JSON.stringify(c(s)) !== r) ?? t;
8
8
  }
9
- async function p(e, t, r) {
10
- const o = g(), s = [e, t];
11
- (/* @__PURE__ */ new Map([[e, d(e, r)], [t, r]])).forEach((n, i) => {
12
- var m;
13
- (!!n.strategyId || i === t) && ((m = o.blockStates[i]) == null ? void 0 : m.recommendationConfigs.strategyId) !== n.strategyId && o.seedBlockUrlConfig(i, a(n));
14
- }), o.resetArrivedBlock(t), await Promise.all(s.map(async (n) => {
15
- if (!await o.refreshStrategyBlock(n))
9
+ async function y(n, t, r = () => !0) {
10
+ const s = f();
11
+ await Promise.all(n.map(async (e) => {
12
+ if (!await s.refreshStrategyBlock(e))
16
13
  return;
17
- const { recommendationConfigs: i, recommendationProducts: f } = o.blockStates[n];
18
- l(
19
- n,
20
- { size: i.size },
21
- f,
22
- "Refresh duplicated recommendation strategy"
14
+ const { recommendationConfigs: a, recommendationProducts: o } = s.blockStates[e];
15
+ r(e, a.size) && d(
16
+ e,
17
+ { size: a.size },
18
+ o,
19
+ t
23
20
  );
24
21
  }));
25
22
  }
26
- async function k(e, t) {
27
- if (!g().blockStates[e])
23
+ async function w(n, t, r) {
24
+ const s = f(), e = [n, t];
25
+ (/* @__PURE__ */ new Map([[n, u(n, r)], [t, r]])).forEach((o, i) => {
26
+ var g;
27
+ (!!o.strategyId || i === t) && ((g = s.blockStates[i]) == null ? void 0 : g.recommendationConfigs.strategyId) !== o.strategyId && s.seedBlockUrlConfig(i, c(o));
28
+ }), s.resetArrivedBlock(t), await y(e, "Refresh duplicated recommendation strategy");
29
+ }
30
+ async function k(n) {
31
+ const t = f(), r = n.filter(({ config: e }) => !!e.strategyId);
32
+ if (!r.length)
33
+ return;
34
+ r.forEach(({ id: e, config: a }) => t.seedBlockUrlConfig(e, c(a))), t.invalidateStrategies();
35
+ const s = new Map(r.map(({ id: e, config: a }) => [e, a]));
36
+ await y(
37
+ r.map(({ id: e }) => e),
38
+ "Refresh recommendation strategy",
39
+ (e, a) => {
40
+ const o = s.get(e);
41
+ return a !== (o == null ? void 0 : o.size) && m(e).some((i) => i.strategyId === (o == null ? void 0 : o.strategyId));
42
+ }
43
+ );
44
+ }
45
+ async function O(n, t) {
46
+ if (!f().blockStates[n])
28
47
  return !1;
29
- const r = await y(e, {
30
- pickUpdates: ({ strategyId: o, strategy: s, size: c, nodeConfigVersion: n }) => ({
31
- strategyId: o,
32
- strategy: s,
33
- size: c,
34
- configVersion: n
48
+ const r = await l(n, {
49
+ pickUpdates: ({ strategyId: s, strategy: e, size: a, nodeConfigVersion: o }) => ({
50
+ strategyId: s,
51
+ strategy: e,
52
+ size: a,
53
+ configVersion: o
35
54
  }),
36
55
  description: t
37
56
  });
38
- return r || console.error("[recommendation] strategy change did not reach a node", { blockId: e }), r;
57
+ return r || console.error("[recommendation] strategy change did not reach a node", { blockId: n }), r;
39
58
  }
40
59
  export {
41
- k as commitStrategyChange,
42
- p as refreshDuplicatedStrategyBlocks
60
+ O as commitStrategyChange,
61
+ k as refreshArrivedStrategyBlocks,
62
+ w as refreshDuplicatedStrategyBlocks,
63
+ u as resolveSourceConfig
43
64
  };
@@ -19,6 +19,9 @@ export declare class RecommendationBlock extends Block {
19
19
  private _resetSourceIds;
20
20
  /** Ids handed to duplicates the document root does not show yet: a copied module renames all its blocks at once. */
21
21
  private _unsettledDuplicateIds;
22
+ private _arrivedBlocks;
23
+ /** Strategy each in-flight arrival or duplicate refresh is fetching, by block id, so a second one does not race it. */
24
+ private _refreshClaims;
22
25
  constructor();
23
26
  getId(): string;
24
27
  getIcon(): string;
@@ -44,6 +47,8 @@ export declare class RecommendationBlock extends Block {
44
47
  * @param node - The newly created block node
45
48
  */
46
49
  onCreated(node: ImmutableHtmlNode): void;
50
+ /** Refreshes every block of an opened template: Stripo restores a stored document without `onCreated`. */
51
+ onDocumentInit(): void;
47
52
  /**
48
53
  * Called when the document changes or template is loaded
49
54
  *
@@ -85,15 +90,26 @@ export declare class RecommendationBlock extends Block {
85
90
  * the renamed one depending on where the module was dropped (SD-149916).
86
91
  */
87
92
  private _scheduleArrivalReset;
93
+ /**
94
+ * Re-reads the strategy of a block that arrived with saved cards, without waiting for a click.
95
+ * Blocks of one opened template or dropped module arrive in one tick and refresh together.
96
+ */
97
+ private _queueArrivalRefresh;
98
+ private _refreshArrivedBlocks;
99
+ /**
100
+ * A new document reports each block to onCreated and onDocumentInit, not always in one batch, so a
101
+ * claimed block refreshes again only once the document shows it under another strategy (a restored version).
102
+ */
103
+ private _canClaimRefresh;
104
+ private _releaseRefreshClaim;
88
105
  /**
89
106
  * Heals a duplicate that slipped past the create-time `_detectDuplicate`
90
107
  * scan (or that was persisted by an older template before SD-142352).
91
108
  * When two blocks share a `recommendation-id`, the first occurrence in DOM
92
109
  * order is treated as the source and any later sibling is reassigned a
93
- * fresh id. The store entry and active-block focus are intentionally not
94
- * touched here: each block's persisted `esd-ext-config` carries its own
95
- * truth and the regular save-time hydration (`hydrateRecommendationStore`)
96
- * will seed the new id from that. Skipping `setCurrentBlock` avoids
110
+ * fresh id and queued for the arrival refresh, which seeds the new id's
111
+ * store entry from its persisted `esd-ext-config`. The source's store
112
+ * entry is not cloned and focus is not moved. Skipping `setCurrentBlock` avoids
97
113
  * yanking the user's current selection mid-edit when the heal fires from
98
114
  * `onDocumentChanged`.
99
115
  */
@@ -109,9 +125,9 @@ export declare class RecommendationBlock extends Block {
109
125
  *
110
126
  * Used by `_handleDuplicate` at create-time (which additionally clones the
111
127
  * store entry and focuses the new block) and by `_healLingeringDuplicate`
112
- * at document-change time (which intentionally skips store/focus side
113
- * effects so older bug-affected templates can self-repair without
114
- * disturbing the user's current selection).
128
+ * at document-change time (which skips the clone and focus change so older
129
+ * bug-affected templates can self-repair without disturbing the user's
130
+ * current selection, and queues the arrival refresh for the new id).
115
131
  */
116
132
  private _reassignDuplicateId;
117
133
  /**