@depict-ai/ui 4.7.14 → 4.7.16

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.
@@ -12,6 +12,7 @@ function $parcel$export(e, n, v, s) {
12
12
  configurable: true
13
13
  });
14
14
  }
15
+ $parcel$export(module.exports, "useProductCardIsVisible", () => $67155e1aeb7073f6$export$80bb7300ce6a8be3);
15
16
  $parcel$export(module.exports, "useExpandingContainerReactive", () => $4b455f60dadde8b8$export$5bad61ecde080b1f);
16
17
  $parcel$export(module.exports, "LooksSliderOrGrid", () => $a3bbfa5fdaa39f3a$export$2c9f9bf2092486aa);
17
18
  $parcel$export(module.exports, "LookCard", () => $ad882bbe664dbd53$export$44809a8a3e867e30);
@@ -98,71 +99,18 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
98
99
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
99
100
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
100
101
  /*! Depict.ai search and product listing SDK */
101
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.14";
102
- function $4b455f60dadde8b8$export$5bad61ecde080b1f(...params) {
103
- const {
104
- collapse: collapse,
105
- expand: expand,
106
- ExpandingContainer: ExpandingContainer
107
- } = $5vyXB$depictaiutilishared.useExpandingContainer(...params);
108
- return {
109
- collapse: collapse,
110
- expand: expand,
111
- ExpandingContainer: ({
112
- children: children
113
- }) => {
114
- // get reactive signals/solid's jsx elements into `ExpandingContainer`
115
- const fake_div = document.createElement("div");
116
- const outer_expanding = $5vyXB$solidjsweb.createComponent(ExpandingContainer, {
117
- children: [fake_div]
118
- });
119
- const parent = fake_div.parentElement;
120
- fake_div.remove();
121
- $5vyXB$solidjsweb.insert(parent, children);
122
- return outer_expanding;
123
- }
124
- };
125
- }
126
- const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
127
- const cols_at_size = [];
128
- for (let i = 0; i < sorted_cols_at_size.length; i++) {
129
- const [nb_cols, width] = sorted_cols_at_size[i];
130
- const next_width = sorted_cols_at_size[i + 1]?.[1];
131
- const max_width = i === 0 ? "" : `${width}px`;
132
- const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
133
- const col_at_size = [nb_cols, min_width, max_width];
134
- cols_at_size.push(col_at_size);
135
- }
136
- return cols_at_size;
137
- };
138
- const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
139
- // Check that every element is an array
140
- const are_arrays = cols_at_size?.every?.(element => Array.isArray(element));
141
- if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
142
- // Check width duplicates
143
- const widths = cols_at_size.map(([_, width]) => width);
144
- const widths_set = new Set(widths);
145
- if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
146
- if (cols_at_size.length === 1) {
147
- const [nb_cols, width] = cols_at_size[0];
148
- const max_width = width !== undefined ? `${width}px` : "";
149
- return [[nb_cols, "", max_width]];
102
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.16";
103
+
104
+ /**
105
+ * Gets product_id (the thing we key the rendering on) from a display
106
+ */
107
+ function $a5871dacf261adf8$export$548d053aba053d79(display) {
108
+ if ("variant_index" in display) {
109
+ const actual_display = display.variant_displays[display.variant_index];
110
+ return actual_display.product_id;
150
111
  }
151
- // Sort widths in ascending order
152
- const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
153
- const [_b, width_A] = a;
154
- const [_a, width_b] = b;
155
- if (width_A === undefined) return -1;
156
- if (width_b === undefined) return 1;
157
- return width_b - width_A;
158
- });
159
- return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
160
- };
161
- function $fc23d7668ae0011d$export$a2cc176055f8f08(what = "grid") {
162
- const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
163
- return (0, $5vyXB$solidjsweb.isServer) ? {
164
- t: `<!-- ${text} -->`
165
- } : document.createComment(text);
112
+ if ("listing_id" in display) return display.listing_id;
113
+ return display.product_id;
166
114
  }
167
115
  function $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(elements) {
168
116
  // FYI this probably doesn't work on hugely deep nestings or large amount of elements
@@ -176,112 +124,6 @@ function $5f7d55c710fd1bc2$var$unwrapping_helper(elements) {
176
124
  } else if (typeof elements == "function") result.push(...$5f7d55c710fd1bc2$var$unwrapping_helper(elements()));else if (elements != undefined && typeof elements != "boolean") result.push(elements);
177
125
  return result;
178
126
  }
179
- let $0caf87eaa19079da$var$cached_placeholder_element;
180
- let $0caf87eaa19079da$var$rendering_cached_placeholder_element;
181
- function $0caf87eaa19079da$export$f33414a4df0afd3f({
182
- product_card_template_: product_card_template_,
183
- num_placeholders_: num_placeholders_,
184
- content_blocks_: content_blocks_
185
- }) {
186
- const [num_to_actually_show, set_num_to_actually_show] = $5vyXB$solidjs.createSignal($5vyXB$solidjs.untrack(num_placeholders_));
187
- if (0, $5vyXB$solidjsweb.isServer)
188
- // want to render simple placeholders on server, effects don't run there
189
- // FIXME when adding proper SSR: also SSR content blocks
190
- return $5vyXB$solidjs.createMemo(() => Array.from({
191
- length: num_placeholders_()
192
- }).map(() => {
193
- const template_result = product_card_template_(null, undefined);
194
- // @ts-ignore
195
- if (typeof template_result?.then !== "function") return template_result;
196
- }));
197
- $5vyXB$solidjs.createRenderEffect(() => {
198
- const existing_num = num_to_actually_show();
199
- const to_add = num_placeholders_() - existing_num;
200
- if (to_add <= 0) return;
201
- // Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
202
- // We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
203
- // The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
204
- // Above comments were from when we added elements in this createRenderEffect. Now I changed it to just increment the number and render them from an <Index> instead, so I can add content blocks better
205
- // Functionality should be the same
206
- set_num_to_actually_show(existing_num + to_add);
207
- });
208
- return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
209
- get each() {
210
- return Array.from({
211
- length: num_to_actually_show()
212
- });
213
- },
214
- children: (_item, index) => {
215
- const possible_content_block = $5vyXB$solidjs.createMemo(() => content_blocks_?.()?.()?.[index]);
216
- // Show content block before product card, so it's *at* that index
217
- return [possible_content_block, $0caf87eaa19079da$var$Placeholder({
218
- product_card_template_: product_card_template_
219
- })]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
220
- }
221
- });
222
- }
223
- /**
224
- * Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
225
- */
226
- function $0caf87eaa19079da$var$Placeholder({
227
- product_card_template_: product_card_template_
228
- }) {
229
- const get_cloned_placeholders = (element_to_clone = $0caf87eaa19079da$var$cached_placeholder_element) => Array.isArray(element_to_clone) ? element_to_clone.map(el => el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
230
- if ($0caf87eaa19079da$var$cached_placeholder_element) return get_cloned_placeholders();
231
- let dispose_original_copy;
232
- const get_unwrapped_element = $5vyXB$solidjs.createRoot(dispose => {
233
- dispose_original_copy = dispose;
234
- // if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
235
- const [resource] = $5vyXB$solidjs.createResource(() => {
236
- if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) return $0caf87eaa19079da$var$rendering_cached_placeholder_element;
237
- const return_value = product_card_template_(null, undefined);
238
- if (typeof return_value === "object" && typeof return_value?.then === "function")
239
- // Is Promise or promise-like object
240
- $0caf87eaa19079da$var$rendering_cached_placeholder_element = return_value;
241
- return return_value;
242
- });
243
- return $5vyXB$solidjs.createMemo(() => {
244
- if (resource.loading) return () => [];
245
- return $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(resource);
246
- });
247
- });
248
- $5vyXB$solidjs.onCleanup(() => {
249
- if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) {
250
- // If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
251
- const unset_current_rendering = () => {
252
- dispose_original_copy();
253
- $0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
254
- };
255
- $0caf87eaa19079da$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
256
- } else
257
- // Otherwise, just make sure we've disposed our root
258
- dispose_original_copy();
259
- });
260
- return $5vyXB$solidjs.createMemo(() => {
261
- const unwrapped_array = get_unwrapped_element()();
262
- if (!unwrapped_array?.length || !unwrapped_array.every(item => item))
263
- // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
264
- return;
265
- // placeholders have finished rendering, freeze the elements
266
- // here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
267
- $0caf87eaa19079da$var$cached_placeholder_element ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
268
- $0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
269
- dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
270
- return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
271
- });
272
- }
273
-
274
- /**
275
- * Gets product_id (the thing we key the rendering on) from a display
276
- */
277
- function $a5871dacf261adf8$export$548d053aba053d79(display) {
278
- if ("variant_index" in display) {
279
- const actual_display = display.variant_displays[display.variant_index];
280
- return actual_display.product_id;
281
- }
282
- if ("listing_id" in display) return display.listing_id;
283
- return display.product_id;
284
- }
285
127
  const $129b9b9c010039d0$var$ProductCardIndexContext = /*@__PURE__*/$5vyXB$solidjs.createContext();
286
128
  function $129b9b9c010039d0$export$11354f017ddc9790(props) {
287
129
  return $5vyXB$solidjsweb.createComponent($129b9b9c010039d0$var$ProductCardIndexContext.Provider, {
@@ -495,6 +337,249 @@ function $a73063cc642f3e5f$var$deep_equal(obj1, obj2) {
495
337
  }
496
338
  return true;
497
339
  }
340
+ const $67155e1aeb7073f6$var$CurrentlyIntersectingContext = /*@__PURE__*/$5vyXB$solidjs.createContext();
341
+ function $67155e1aeb7073f6$export$4a14175d33d81a96({
342
+ displays_by_key_: displays_by_key_,
343
+ product_card_template_: product_card_template_,
344
+ content_blocks_: content_blocks_,
345
+ alwaysObserveCards_: alwaysObserveCards_
346
+ }) {
347
+ // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator, knowing when to load more and any other consumer of the useProductCardIsVisible hook.
348
+ const targetToIndexMap_ = new Map();
349
+ const indexToTargetMap_ = new Map();
350
+ const [listenersForIntersecting, setListenersForIntersecting] = $5vyXB$solidjs.createSignal(0);
351
+ const [currentlyIntersecting, setCurrentlyIntersecting] = $5vyXB$solidjs.createSignal(new Set(), {
352
+ equals: false
353
+ });
354
+ const shouldObserve = $5vyXB$solidjs.createMemo(() => alwaysObserveCards_ || listenersForIntersecting() > 0);
355
+ const intersection_observer = new IntersectionObserver($5vyXB$depictaiutilishared.catchify(records => {
356
+ const intersectingValue = currentlyIntersecting();
357
+ for (let i = 0; i < records.length; i++) {
358
+ const record = records[i];
359
+ const {
360
+ target: target,
361
+ intersectionRatio: intersectionRatio
362
+ } = record;
363
+ const index_of_target = targetToIndexMap_.get(target);
364
+ if (index_of_target == undefined) return; // It seems like it can happen that we get IntersectionObserverEntries after the onCleanup function for a recommendation card has run, in Firefox. Probably a bug in Firefox? If I understood the bug correctly, this is a workaround.
365
+ const is_in_set = intersectingValue.has(index_of_target);
366
+ if (intersectionRatio > 0) {
367
+ if (!is_in_set) intersectingValue.add(index_of_target);
368
+ } else if (is_in_set) intersectingValue.delete(index_of_target);
369
+ }
370
+ setCurrentlyIntersecting(intersectingValue);
371
+ }, "renderDisplays IO failed"));
372
+ const renderedDisplays_ = $5vyXB$solidjsweb.createComponent($67155e1aeb7073f6$var$CurrentlyIntersectingContext.Provider, {
373
+ value: {
374
+ currentlyIntersecting_: currentlyIntersecting,
375
+ setIsListening_: setListenersForIntersecting
376
+ },
377
+ get children() {
378
+ return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
379
+ displays_by_key_: displays_by_key_,
380
+ product_card_template_: product_card_template_,
381
+ content_blocks_: content_blocks_,
382
+ do_per_elements_: (elements, index_accessor) =>
383
+ // Adds/removes elements from the "results in viewport" intersection observer above
384
+ $5vyXB$solidjs.createEffect(() => {
385
+ if (!shouldObserve()) return;
386
+ const display_index = index_accessor();
387
+ // Nested createEffect because we only want to re-run this when the index changes (or we should/shouldn't observe)
388
+ // We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
389
+ for (let i = 0; i < elements.length; i++) {
390
+ const element = elements[i];
391
+ targetToIndexMap_.set(element, display_index);
392
+ intersection_observer.observe(element);
393
+ $5vyXB$solidjs.onCleanup(() => {
394
+ intersection_observer.unobserve(element);
395
+ targetToIndexMap_.delete(element);
396
+ const intersecting = $5vyXB$solidjs.untrack(currentlyIntersecting);
397
+ const wasDeleted = intersecting.delete(display_index);
398
+ if (wasDeleted) setCurrentlyIntersecting(intersecting);
399
+ });
400
+ }
401
+ indexToTargetMap_.set(display_index, elements);
402
+ $5vyXB$solidjs.onCleanup(() => indexToTargetMap_.delete(display_index));
403
+ })
404
+ });
405
+ }
406
+ });
407
+ return {
408
+ renderedDisplays_: renderedDisplays_,
409
+ indexToTargetMap_: indexToTargetMap_,
410
+ currentlyIntersecting: currentlyIntersecting
411
+ };
412
+ }
413
+ function $67155e1aeb7073f6$export$80bb7300ce6a8be3() {
414
+ const {
415
+ setIsListening_: setIsListening_,
416
+ currentlyIntersecting_: currentlyIntersecting_
417
+ } = $5vyXB$solidjs.useContext($67155e1aeb7073f6$var$CurrentlyIntersectingContext) || {};
418
+ const getOurIndex = $129b9b9c010039d0$export$e3faf4d95300054f();
419
+ const isVisible = $5vyXB$solidjs.createMemo(() => currentlyIntersecting_?.().has(getOurIndex?.()));
420
+ setIsListening_?.(prev => prev + 1);
421
+ $5vyXB$solidjs.onCleanup(() => setIsListening_?.(prev => prev + 1));
422
+ return isVisible;
423
+ }
424
+ function $4b455f60dadde8b8$export$5bad61ecde080b1f(...params) {
425
+ const {
426
+ collapse: collapse,
427
+ expand: expand,
428
+ ExpandingContainer: ExpandingContainer
429
+ } = $5vyXB$depictaiutilishared.useExpandingContainer(...params);
430
+ return {
431
+ collapse: collapse,
432
+ expand: expand,
433
+ ExpandingContainer: ({
434
+ children: children
435
+ }) => {
436
+ // get reactive signals/solid's jsx elements into `ExpandingContainer`
437
+ const fake_div = document.createElement("div");
438
+ const outer_expanding = $5vyXB$solidjsweb.createComponent(ExpandingContainer, {
439
+ children: [fake_div]
440
+ });
441
+ const parent = fake_div.parentElement;
442
+ fake_div.remove();
443
+ $5vyXB$solidjsweb.insert(parent, children);
444
+ return outer_expanding;
445
+ }
446
+ };
447
+ }
448
+ const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
449
+ const cols_at_size = [];
450
+ for (let i = 0; i < sorted_cols_at_size.length; i++) {
451
+ const [nb_cols, width] = sorted_cols_at_size[i];
452
+ const next_width = sorted_cols_at_size[i + 1]?.[1];
453
+ const max_width = i === 0 ? "" : `${width}px`;
454
+ const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
455
+ const col_at_size = [nb_cols, min_width, max_width];
456
+ cols_at_size.push(col_at_size);
457
+ }
458
+ return cols_at_size;
459
+ };
460
+ const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
461
+ // Check that every element is an array
462
+ const are_arrays = cols_at_size?.every?.(element => Array.isArray(element));
463
+ if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
464
+ // Check width duplicates
465
+ const widths = cols_at_size.map(([_, width]) => width);
466
+ const widths_set = new Set(widths);
467
+ if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
468
+ if (cols_at_size.length === 1) {
469
+ const [nb_cols, width] = cols_at_size[0];
470
+ const max_width = width !== undefined ? `${width}px` : "";
471
+ return [[nb_cols, "", max_width]];
472
+ }
473
+ // Sort widths in ascending order
474
+ const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
475
+ const [_b, width_A] = a;
476
+ const [_a, width_b] = b;
477
+ if (width_A === undefined) return -1;
478
+ if (width_b === undefined) return 1;
479
+ return width_b - width_A;
480
+ });
481
+ return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
482
+ };
483
+ function $fc23d7668ae0011d$export$a2cc176055f8f08(what = "grid") {
484
+ const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
485
+ return (0, $5vyXB$solidjsweb.isServer) ? {
486
+ t: `<!-- ${text} -->`
487
+ } : document.createComment(text);
488
+ }
489
+ let $0caf87eaa19079da$var$cached_placeholder_element;
490
+ let $0caf87eaa19079da$var$rendering_cached_placeholder_element;
491
+ function $0caf87eaa19079da$export$f33414a4df0afd3f({
492
+ product_card_template_: product_card_template_,
493
+ num_placeholders_: num_placeholders_,
494
+ content_blocks_: content_blocks_
495
+ }) {
496
+ const [num_to_actually_show, set_num_to_actually_show] = $5vyXB$solidjs.createSignal($5vyXB$solidjs.untrack(num_placeholders_));
497
+ if (0, $5vyXB$solidjsweb.isServer)
498
+ // want to render simple placeholders on server, effects don't run there
499
+ // FIXME when adding proper SSR: also SSR content blocks
500
+ return $5vyXB$solidjs.createMemo(() => Array.from({
501
+ length: num_placeholders_()
502
+ }).map(() => {
503
+ const template_result = product_card_template_(null, undefined);
504
+ // @ts-ignore
505
+ if (typeof template_result?.then !== "function") return template_result;
506
+ }));
507
+ $5vyXB$solidjs.createRenderEffect(() => {
508
+ const existing_num = num_to_actually_show();
509
+ const to_add = num_placeholders_() - existing_num;
510
+ if (to_add <= 0) return;
511
+ // Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
512
+ // We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
513
+ // The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
514
+ // Above comments were from when we added elements in this createRenderEffect. Now I changed it to just increment the number and render them from an <Index> instead, so I can add content blocks better
515
+ // Functionality should be the same
516
+ set_num_to_actually_show(existing_num + to_add);
517
+ });
518
+ return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
519
+ get each() {
520
+ return Array.from({
521
+ length: num_to_actually_show()
522
+ });
523
+ },
524
+ children: (_item, index) => {
525
+ const possible_content_block = $5vyXB$solidjs.createMemo(() => content_blocks_?.()?.()?.[index]);
526
+ // Show content block before product card, so it's *at* that index
527
+ return [possible_content_block, $0caf87eaa19079da$var$Placeholder({
528
+ product_card_template_: product_card_template_
529
+ })]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
530
+ }
531
+ });
532
+ }
533
+ /**
534
+ * Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
535
+ */
536
+ function $0caf87eaa19079da$var$Placeholder({
537
+ product_card_template_: product_card_template_
538
+ }) {
539
+ const get_cloned_placeholders = (element_to_clone = $0caf87eaa19079da$var$cached_placeholder_element) => Array.isArray(element_to_clone) ? element_to_clone.map(el => el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
540
+ if ($0caf87eaa19079da$var$cached_placeholder_element) return get_cloned_placeholders();
541
+ let dispose_original_copy;
542
+ const get_unwrapped_element = $5vyXB$solidjs.createRoot(dispose => {
543
+ dispose_original_copy = dispose;
544
+ // if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
545
+ const [resource] = $5vyXB$solidjs.createResource(() => {
546
+ if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) return $0caf87eaa19079da$var$rendering_cached_placeholder_element;
547
+ const return_value = product_card_template_(null, undefined);
548
+ if (typeof return_value === "object" && typeof return_value?.then === "function")
549
+ // Is Promise or promise-like object
550
+ $0caf87eaa19079da$var$rendering_cached_placeholder_element = return_value;
551
+ return return_value;
552
+ });
553
+ return $5vyXB$solidjs.createMemo(() => {
554
+ if (resource.loading) return () => [];
555
+ return $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(resource);
556
+ });
557
+ });
558
+ $5vyXB$solidjs.onCleanup(() => {
559
+ if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) {
560
+ // If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
561
+ const unset_current_rendering = () => {
562
+ dispose_original_copy();
563
+ $0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
564
+ };
565
+ $0caf87eaa19079da$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
566
+ } else
567
+ // Otherwise, just make sure we've disposed our root
568
+ dispose_original_copy();
569
+ });
570
+ return $5vyXB$solidjs.createMemo(() => {
571
+ const unwrapped_array = get_unwrapped_element()();
572
+ if (!unwrapped_array?.length || !unwrapped_array.every(item => item))
573
+ // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
574
+ return;
575
+ // placeholders have finished rendering, freeze the elements
576
+ // here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
577
+ $0caf87eaa19079da$var$cached_placeholder_element ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
578
+ $0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
579
+ dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
580
+ return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
581
+ });
582
+ }
498
583
 
499
584
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
500
585
  class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
@@ -769,10 +854,13 @@ function $363ce4d1d71041aa$export$d41d19e89346fa2({
769
854
  return (() => {
770
855
  // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
771
856
  const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($5vyXB$solidjs.createMemo(() => recommendations_resource_() || []));
772
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
857
+ const {
858
+ renderedDisplays_: renderedDisplays_
859
+ } = $67155e1aeb7073f6$export$4a14175d33d81a96({
773
860
  displays_by_key_: displays_by_key_,
774
861
  product_card_template_: product_card_template_
775
862
  });
863
+ return renderedDisplays_;
776
864
  })();
777
865
  }
778
866
  });
@@ -1757,10 +1845,13 @@ function $b8e79813f4f7ebe4$export$7da560f849543dff({
1757
1845
  return (() => {
1758
1846
  // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
1759
1847
  const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($5vyXB$solidjs.createMemo(() => recommendations_resource_() || []));
1760
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
1848
+ const {
1849
+ renderedDisplays_: renderedDisplays_
1850
+ } = $67155e1aeb7073f6$export$4a14175d33d81a96({
1761
1851
  displays_by_key_: displays_by_key_,
1762
1852
  product_card_template_: product_card_template_
1763
1853
  });
1854
+ return renderedDisplays_;
1764
1855
  })();
1765
1856
  }
1766
1857
  });
@@ -8129,10 +8220,13 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({
8129
8220
  if (!should_show() && prev) return prev; // When we're invisible, don't update what we're rendering to be possibly undefined to preserve the same products if possible
8130
8221
  return recommendations_resource() || [];
8131
8222
  }));
8132
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
8223
+ const {
8224
+ renderedDisplays_: renderedDisplays_
8225
+ } = $67155e1aeb7073f6$export$4a14175d33d81a96({
8133
8226
  displays_by_key_: displays_by_key_,
8134
8227
  product_card_template_: product_card_template_
8135
8228
  });
8229
+ return renderedDisplays_;
8136
8230
  })();
8137
8231
  }
8138
8232
  });
@@ -8865,8 +8959,8 @@ function $4117463e2939f5f4$export$63dd0350f8559dda({
8865
8959
  function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
8866
8960
  plp_results_: plp_results_,
8867
8961
  product_card_template_: product_card_template_,
8868
- first_result_in_viewport_: [, set_first_result_in_viewport],
8869
- last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport],
8962
+ first_result_in_viewport_: [, setFirstResultInViewport],
8963
+ last_result_in_viewport_: [lastResultInViewport, setLastResultsInViewport],
8870
8964
  all_products_loaded_: all_products_loaded_,
8871
8965
  min_products_to_fetch_: min_products_to_fetch_,
8872
8966
  query_base_: query_base_,
@@ -8874,36 +8968,25 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
8874
8968
  is_loading_: is_loading_,
8875
8969
  content_blocks_: content_blocks_
8876
8970
  }) {
8877
- // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
8878
- const target_to_index_map = new Map();
8879
- const index_to_target_map_ = new Map();
8880
- const currently_intersecting = new Set();
8881
- const intersection_observer = new IntersectionObserver($5vyXB$depictaiutilishared.catchify(records => {
8882
- for (let i = 0; i < records.length; i++) {
8883
- const record = records[i];
8884
- const {
8885
- target: target,
8886
- intersectionRatio: intersectionRatio
8887
- } = record;
8888
- const index_of_target = target_to_index_map.get(target);
8889
- if (index_of_target == undefined) return; // It seems like it can happen that we get IntersectionObserverEntries after the onCleanup function for a recommendation card has run, in Firefox. Probably a bug in Firefox? If I understood the bug correctly, this is a workaround.
8890
- const is_in_set = currently_intersecting.has(index_of_target);
8891
- if (intersectionRatio > 0) {
8892
- if (!is_in_set) currently_intersecting.add(index_of_target);
8893
- } else if (is_in_set) currently_intersecting.delete(index_of_target);
8894
- }
8895
- set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
8896
- set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
8897
- }, "PLPResults IO failed"));
8898
8971
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
8899
8972
  const [get_extra_displays, set_extra_displays_] = $5vyXB$solidjs.createSignal([], {
8900
8973
  equals: false
8901
8974
  });
8902
8975
  const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($5vyXB$solidjs.createMemo(() => [...(plp_results_()?.displays || []), ...get_extra_displays()]));
8976
+ const {
8977
+ indexToTargetMap_: indexToTargetMap_,
8978
+ renderedDisplays_: renderedDisplays_,
8979
+ currentlyIntersecting: currentlyIntersecting
8980
+ } = $67155e1aeb7073f6$export$4a14175d33d81a96({
8981
+ displays_by_key_: displays_by_key_,
8982
+ product_card_template_: product_card_template_,
8983
+ content_blocks_: content_blocks_,
8984
+ alwaysObserveCards_: true
8985
+ });
8903
8986
  const percentage_in_view_ = $4117463e2939f5f4$export$63dd0350f8559dda({
8904
- get_last_result_in_viewport_: get_last_result_in_viewport_,
8987
+ get_last_result_in_viewport_: lastResultInViewport,
8905
8988
  displays_by_key_: displays_by_key_,
8906
- index_to_target_map_: index_to_target_map_,
8989
+ index_to_target_map_: indexToTargetMap_,
8907
8990
  is_loading_: is_loading_,
8908
8991
  get_extra_displays: get_extra_displays
8909
8992
  });
@@ -8916,30 +8999,12 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
8916
8999
  query_base_: query_base_,
8917
9000
  depict_api_: depict_api_
8918
9001
  });
8919
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
8920
- displays_by_key_: displays_by_key_,
8921
- product_card_template_: product_card_template_,
8922
- content_blocks_: content_blocks_,
8923
- do_per_elements_: (elements, index_accessor) =>
8924
- // Adds/removes elements from the "results in viewport" intersection observer above
8925
- $5vyXB$solidjs.createEffect(() => {
8926
- const display_index = index_accessor();
8927
- // Nested createEffect because we only want to re-run this when the index changes
8928
- // We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
8929
- for (let i = 0; i < elements.length; i++) {
8930
- const element = elements[i];
8931
- target_to_index_map.set(element, display_index);
8932
- intersection_observer.observe(element);
8933
- $5vyXB$solidjs.onCleanup(() => {
8934
- intersection_observer.unobserve(element);
8935
- target_to_index_map.delete(element);
8936
- currently_intersecting.delete(display_index);
8937
- });
8938
- }
8939
- index_to_target_map_.set(display_index, elements);
8940
- $5vyXB$solidjs.onCleanup(() => index_to_target_map_.delete(display_index));
8941
- })
9002
+ $5vyXB$solidjs.createEffect(() => {
9003
+ const intersecting = currentlyIntersecting();
9004
+ setFirstResultInViewport(Math.min(...intersecting) + 1); // +1 because we want to start counting at 1
9005
+ setLastResultsInViewport(Math.max(...intersecting) + 1);
8942
9006
  });
9007
+ return renderedDisplays_;
8943
9008
  }
8944
9009
  var $75777da1687ba3f6$var$_tmpl$ = ["<style", ' type="text/css">', "</style>"];
8945
9010
  const $75777da1687ba3f6$export$c500183c31c2b22e = "--spans-columns";
@@ -9309,11 +9374,13 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9309
9374
  cols_at_size_: modified_cols_at_size,
9310
9375
  set_top_row_shortened_by_: set_top_row_shortened_by_
9311
9376
  }));
9312
- const rendered_placeholders = $5vyXB$solidjs.createMemo(() => get_should_have_placeholders_rendered() ? $0caf87eaa19079da$export$f33414a4df0afd3f({
9313
- content_blocks_: content_blocks_,
9314
- product_card_template_: product_card_template_,
9315
- num_placeholders_: num_placeholders_
9316
- }) : undefined);
9377
+ const rendered_placeholders = $5vyXB$solidjs.createMemo(() => {
9378
+ if (get_should_have_placeholders_rendered()) return $0caf87eaa19079da$export$f33414a4df0afd3f({
9379
+ content_blocks_: content_blocks_,
9380
+ product_card_template_: product_card_template_,
9381
+ num_placeholders_: num_placeholders_
9382
+ });
9383
+ });
9317
9384
  const layout = $5vyXB$solidjs.createMemo(() => {
9318
9385
  const incoming_layout = layout_options_().layout;
9319
9386
  if (incoming_layout === "slider-without-filters") return "slider";