@depict-ai/ui 4.7.13 → 4.7.15

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.13";
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.15";
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
  });
@@ -6271,7 +6362,7 @@ function $3bdc00a1353c1150$var$expand_until_choice(data_structure) {
6271
6362
  }
6272
6363
  });
6273
6364
  }
6274
- var $0ef1681699140f1a$var$_tmpl$ = ["<div", ' class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0">', "</div>"],
6365
+ var $0ef1681699140f1a$var$_tmpl$ = ["<div", ' class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0" aria-hidden="true">', "</div>"],
6275
6366
  $0ef1681699140f1a$var$_tmpl$2 = ["<span", ' class="count-wrapper"><span class="count">', "</span></span>"];
6276
6367
  const $0ef1681699140f1a$var$gap_px = 5;
6277
6368
  const $0ef1681699140f1a$var$max_columns = 3;
@@ -6376,7 +6467,9 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
6376
6467
  }
6377
6468
  })), "<!--/-->"], true);
6378
6469
  };
6379
- const invisible_size_button = $5vyXB$solidjsweb.createComponent(MakeButton, {});
6470
+ const invisible_size_button = $5vyXB$solidjsweb.createComponent(MakeButton, {
6471
+ tabIndex: -1
6472
+ });
6380
6473
  const smallest_possible_size = $f13855d1b951b24a$export$ebdc3711f7e02ccd(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
6381
6474
  const sizes_value = $5vyXB$solidjs.untrack(sizes_set);
6382
6475
  const shadow_children_value = $5vyXB$solidjs.untrack(shadow_children);
@@ -8127,10 +8220,13 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({
8127
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
8128
8221
  return recommendations_resource() || [];
8129
8222
  }));
8130
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
8223
+ const {
8224
+ renderedDisplays_: renderedDisplays_
8225
+ } = $67155e1aeb7073f6$export$4a14175d33d81a96({
8131
8226
  displays_by_key_: displays_by_key_,
8132
8227
  product_card_template_: product_card_template_
8133
8228
  });
8229
+ return renderedDisplays_;
8134
8230
  })();
8135
8231
  }
8136
8232
  });
@@ -8863,8 +8959,8 @@ function $4117463e2939f5f4$export$63dd0350f8559dda({
8863
8959
  function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
8864
8960
  plp_results_: plp_results_,
8865
8961
  product_card_template_: product_card_template_,
8866
- first_result_in_viewport_: [, set_first_result_in_viewport],
8867
- 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],
8868
8964
  all_products_loaded_: all_products_loaded_,
8869
8965
  min_products_to_fetch_: min_products_to_fetch_,
8870
8966
  query_base_: query_base_,
@@ -8872,36 +8968,25 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
8872
8968
  is_loading_: is_loading_,
8873
8969
  content_blocks_: content_blocks_
8874
8970
  }) {
8875
- // 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
8876
- const target_to_index_map = new Map();
8877
- const index_to_target_map_ = new Map();
8878
- const currently_intersecting = new Set();
8879
- const intersection_observer = new IntersectionObserver($5vyXB$depictaiutilishared.catchify(records => {
8880
- for (let i = 0; i < records.length; i++) {
8881
- const record = records[i];
8882
- const {
8883
- target: target,
8884
- intersectionRatio: intersectionRatio
8885
- } = record;
8886
- const index_of_target = target_to_index_map.get(target);
8887
- 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.
8888
- const is_in_set = currently_intersecting.has(index_of_target);
8889
- if (intersectionRatio > 0) {
8890
- if (!is_in_set) currently_intersecting.add(index_of_target);
8891
- } else if (is_in_set) currently_intersecting.delete(index_of_target);
8892
- }
8893
- set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
8894
- set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
8895
- }, "PLPResults IO failed"));
8896
8971
  // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
8897
8972
  const [get_extra_displays, set_extra_displays_] = $5vyXB$solidjs.createSignal([], {
8898
8973
  equals: false
8899
8974
  });
8900
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
+ });
8901
8986
  const percentage_in_view_ = $4117463e2939f5f4$export$63dd0350f8559dda({
8902
- get_last_result_in_viewport_: get_last_result_in_viewport_,
8987
+ get_last_result_in_viewport_: lastResultInViewport,
8903
8988
  displays_by_key_: displays_by_key_,
8904
- index_to_target_map_: index_to_target_map_,
8989
+ index_to_target_map_: indexToTargetMap_,
8905
8990
  is_loading_: is_loading_,
8906
8991
  get_extra_displays: get_extra_displays
8907
8992
  });
@@ -8914,30 +8999,12 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
8914
8999
  query_base_: query_base_,
8915
9000
  depict_api_: depict_api_
8916
9001
  });
8917
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
8918
- displays_by_key_: displays_by_key_,
8919
- product_card_template_: product_card_template_,
8920
- content_blocks_: content_blocks_,
8921
- do_per_elements_: (elements, index_accessor) =>
8922
- // Adds/removes elements from the "results in viewport" intersection observer above
8923
- $5vyXB$solidjs.createEffect(() => {
8924
- const display_index = index_accessor();
8925
- // Nested createEffect because we only want to re-run this when the index changes
8926
- // 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
8927
- for (let i = 0; i < elements.length; i++) {
8928
- const element = elements[i];
8929
- target_to_index_map.set(element, display_index);
8930
- intersection_observer.observe(element);
8931
- $5vyXB$solidjs.onCleanup(() => {
8932
- intersection_observer.unobserve(element);
8933
- target_to_index_map.delete(element);
8934
- currently_intersecting.delete(display_index);
8935
- });
8936
- }
8937
- index_to_target_map_.set(display_index, elements);
8938
- $5vyXB$solidjs.onCleanup(() => index_to_target_map_.delete(display_index));
8939
- })
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);
8940
9006
  });
9007
+ return renderedDisplays_;
8941
9008
  }
8942
9009
  var $75777da1687ba3f6$var$_tmpl$ = ["<style", ' type="text/css">', "</style>"];
8943
9010
  const $75777da1687ba3f6$export$c500183c31c2b22e = "--spans-columns";
@@ -9307,11 +9374,13 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9307
9374
  cols_at_size_: modified_cols_at_size,
9308
9375
  set_top_row_shortened_by_: set_top_row_shortened_by_
9309
9376
  }));
9310
- const rendered_placeholders = $5vyXB$solidjs.createMemo(() => get_should_have_placeholders_rendered() ? $0caf87eaa19079da$export$f33414a4df0afd3f({
9311
- content_blocks_: content_blocks_,
9312
- product_card_template_: product_card_template_,
9313
- num_placeholders_: num_placeholders_
9314
- }) : undefined);
9377
+ const rendered_placeholders = $5vyXB$solidjs.createMemo(() => {
9378
+ if (get_should_have_placeholders_rendered()) return $5vyXB$solidjs.children(() => $0caf87eaa19079da$export$f33414a4df0afd3f({
9379
+ content_blocks_: content_blocks_,
9380
+ product_card_template_: product_card_template_,
9381
+ num_placeholders_: num_placeholders_
9382
+ }));
9383
+ });
9315
9384
  const layout = $5vyXB$solidjs.createMemo(() => {
9316
9385
  const incoming_layout = layout_options_().layout;
9317
9386
  if (incoming_layout === "slider-without-filters") return "slider";
@@ -9346,7 +9415,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9346
9415
  (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
9347
9416
  We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
9348
9417
  */
9349
- const product_cards_when_data = $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Suspense), {
9418
+ const product_cards_when_data = $5vyXB$solidjs.children(() => $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Suspense), {
9350
9419
  get fallback() {
9351
9420
  fallback_is_alive = true;
9352
9421
  $5vyXB$solidjs.onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
@@ -9378,17 +9447,19 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9378
9447
  return suspense_contents;
9379
9448
  })();
9380
9449
  }
9381
- });
9450
+ }));
9382
9451
  /* This Show is so that we show placeholders while query_base is loading and because it's cumbersome to ensure that everything that directly accesses the plp_results_ resource is within the <Suspense> boundary */
9383
- const listing_contents = $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
9452
+ const listing_contents = $5vyXB$solidjs.children(() => $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
9384
9453
  get when() {
9385
9454
  return !is_loading_();
9386
9455
  },
9387
9456
  get fallback() {
9388
- return rendered_placeholders();
9457
+ return rendered_placeholders()?.();
9389
9458
  },
9390
- children: product_cards_when_data
9391
- });
9459
+ get children() {
9460
+ return product_cards_when_data();
9461
+ }
9462
+ }));
9392
9463
  return [$fc23d7668ae0011d$export$a2cc176055f8f08(layout()), $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
9393
9464
  get when() {
9394
9465
  return doesnt_have_content_blocks();
@@ -9408,7 +9479,9 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9408
9479
  class: "cards css-grid"
9409
9480
  },
9410
9481
  top_row_shortened_by_: top_row_shortened_by_,
9411
- children: listing_contents
9482
+ get children() {
9483
+ return listing_contents();
9484
+ }
9412
9485
  });
9413
9486
  },
9414
9487
  get children() {
@@ -9461,7 +9534,9 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9461
9534
  $5vyXB$solidjsweb.insert(container, $5vyXB$solidjs.createMemo(() => [...non_solid_nodes, rendered_scroll_status]));
9462
9535
  }
9463
9536
  },
9464
- children: listing_contents
9537
+ get children() {
9538
+ return listing_contents();
9539
+ }
9465
9540
  });
9466
9541
  },
9467
9542
  get children() {
@@ -9482,7 +9557,9 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
9482
9557
  element_attributes: {
9483
9558
  class: "cards"
9484
9559
  },
9485
- children: listing_contents
9560
+ get children() {
9561
+ return listing_contents();
9562
+ }
9486
9563
  });
9487
9564
  }
9488
9565
  });