@depict-ai/ui 0.0.79 → 0.0.81

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.js CHANGED
@@ -1,9 +1,9 @@
1
- import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Tenant as $g9l4l$Tenant, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, default_rr as $g9l4l$default_rr, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, Lazyfier as $g9l4l$Lazyfier, queueMacroTask as $g9l4l$queueMacroTask, deparallelize as $g9l4l$deparallelize, Rec_Renderer as $g9l4l$Rec_Renderer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, hsl_to_rgb as $g9l4l$hsl_to_rgb, relative_luminance_from_rgb as $g9l4l$relative_luminance_from_rgb, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, instant_exec_on_suspect_history_change as $g9l4l$instant_exec_on_suspect_history_change, normal_get_product_id as $g9l4l$normal_get_product_id, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, make_placeholder_rr as $g9l4l$make_placeholder_rr, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, depict_click as $g9l4l$depict_click, impression_track_element as $g9l4l$impression_track_element, add_new_tab_listener as $g9l4l$add_new_tab_listener, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces} from "@depict-ai/utilishared";
2
- import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, memo as $g9l4l$memo, style as $g9l4l$style, mergeProps as $g9l4l$mergeProps, className as $g9l4l$className} from "solid-js/web";
3
- import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createRenderEffect as $g9l4l$createRenderEffect, runWithOwner as $g9l4l$runWithOwner, createRoot as $g9l4l$createRoot, getOwner as $g9l4l$getOwner, createReaction as $g9l4l$createReaction, on as $g9l4l$on, ErrorBoundary as $g9l4l$ErrorBoundary, Index as $g9l4l$Index, For as $g9l4l$For} from "solid-js";
1
+ import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, hsl_to_rgb as $g9l4l$hsl_to_rgb, relative_luminance_from_rgb as $g9l4l$relative_luminance_from_rgb, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, queueMacroTask as $g9l4l$queueMacroTask, instant_exec_on_suspect_history_change as $g9l4l$instant_exec_on_suspect_history_change, dwarn as $g9l4l$dwarn, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces} from "@depict-ai/utilishared";
2
+ import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, memo as $g9l4l$memo, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, style as $g9l4l$style, Dynamic as $g9l4l$Dynamic, mergeProps as $g9l4l$mergeProps, className as $g9l4l$className} from "solid-js/web";
3
+ import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createRenderEffect as $g9l4l$createRenderEffect, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createReaction as $g9l4l$createReaction, Suspense as $g9l4l$Suspense, on as $g9l4l$on, createRoot as $g9l4l$createRoot, ErrorBoundary as $g9l4l$ErrorBoundary, For as $g9l4l$For, getOwner as $g9l4l$getOwner, runWithOwner as $g9l4l$runWithOwner, Index as $g9l4l$Index} from "solid-js";
4
4
  import {compressToBase64 as $g9l4l$compressToBase64, decompressFromBase64 as $g9l4l$decompressFromBase64} from "lz-string";
5
5
 
6
- /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.79";
6
+ /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.81";
7
7
 
8
8
 
9
9
 
@@ -25,25 +25,28 @@ async function $e95f1855a5e3864f$export$58e808b1db15d3bc({ merchant: merchant ,
25
25
 
26
26
 
27
27
 
28
- function $014a147d094b0d08$export$e183a13865960371(params_to_default_value) {
28
+ function $014a147d094b0d08$export$e183a13865960371(params_to_default_value, router_) {
29
29
  const signals = {};
30
30
  const entries = Object.entries(params_to_default_value);
31
31
  const event_handler = (0, $g9l4l$catchify)(({ state: state })=>$014a147d094b0d08$var$history_state_change(signals, entries, state));
32
- for (const [param, default_value] of entries){
33
- const [read_signal] = signals[param] = (0, $g9l4l$createSignal)(history.state?.[param] ?? default_value);
34
- (0, $g9l4l$createComputed)((0, $g9l4l$catchify)(()=>{
32
+ // createRenderEffect because we need the instant execution so the signals always contain values, even before solid's render phase
33
+ (0, $g9l4l$createRenderEffect)(()=>{
34
+ let signal_changed = false;
35
+ let { state: state } = history; // cloning isn't necessary because we're calling replaceState on it anyway
36
+ if (state === null || typeof state != "object") state = {};
37
+ for (const [param, default_value] of entries){
38
+ const [read_signal] = signals[param] ||= (0, $g9l4l$createSignal)(state[param] ?? default_value);
35
39
  const new_value = read_signal();
36
- let { state: state } = history; // cloning isn't necessary because we're calling replaceState on it anyway
37
- if (new_value !== state?.[param]) {
38
- if (state === null || typeof state != "object") state = {};
40
+ if (new_value !== state[param]) {
41
+ signal_changed = true;
39
42
  state[param] = new_value;
40
- history.replaceState(state, "", location.href);
41
43
  }
42
- }));
43
- }
44
+ }
45
+ if (signal_changed) router_.navigate_.replace_state_(state);
46
+ });
44
47
  window.addEventListener("popstate", event_handler);
45
48
  (0, $g9l4l$onCleanup)((0, $g9l4l$catchify)(()=>window.removeEventListener("popstate", event_handler)));
46
- (0, $g9l4l$createEffect)((0, $g9l4l$catchify)(()=>(0, $g9l4l$untrack)((0, $g9l4l$catchify)(()=>$014a147d094b0d08$var$history_state_change(signals, entries, history.state))))); // we need this to run after the first writing
49
+ (0, $g9l4l$createEffect)((0, $g9l4l$catchify)(()=>(0, $g9l4l$untrack)((0, $g9l4l$catchify)(()=>$014a147d094b0d08$var$history_state_change(signals, entries, history.state))))); // we need this to run after reading the initial state from history.state to write the defaults to history.state
47
50
  return signals;
48
51
  }
49
52
  function $014a147d094b0d08$var$history_state_change(signals, entries, state) {
@@ -57,8 +60,8 @@ function $014a147d094b0d08$var$history_state_change(signals, entries, state) {
57
60
  }
58
61
 
59
62
 
60
- function $3075a4497054bec6$export$9862539c89138352(get_default_values_) {
61
- const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values_());
63
+ function $3075a4497054bec6$export$9862539c89138352(get_default_values_, router_) {
64
+ const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values_(), router_);
62
65
  const reset_state = ()=>{
63
66
  const new_defaults = get_default_values_();
64
67
  for(const key in state){
@@ -283,8 +286,12 @@ function $925024900e36130f$export$92f2da32c6e7e7ee({ search_results_: search_res
283
286
 
284
287
 
285
288
 
286
- function $5178263ed1e394ca$export$469c7af753d08925({ price_: price_ , price_formatting_: price_formatting_ }) {
287
- return (0, $g9l4l$createMemo)(()=>(0, $g9l4l$standard_price_format)(price_(), price_formatting_().places_after_comma_, price_formatting_().decimal_places_delimiter_, price_formatting_().thousands_delimiter_));
289
+
290
+ function $5178263ed1e394ca$export$a71e92cfbb498adc(props) {
291
+ return (0, $g9l4l$createMemo)(()=>{
292
+ const price_formatting = props.price_formatting_;
293
+ return (0, $g9l4l$standard_price_format)(props.price_, price_formatting.places_after_comma_, price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
294
+ });
288
295
  }
289
296
 
290
297
 
@@ -391,19 +398,27 @@ function $51b5c03492337d58$export$83fd5de5504a7a67({ formatted_number_of_results
391
398
  }));
392
399
  });
393
400
  return (()=>{
394
- const _el$ = $51b5c03492337d58$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$6 = _el$4.nextSibling, _el$7 = _el$6.nextSibling, _el$10 = _el$7.nextSibling, _el$8 = _el$10.nextSibling, _el$9 = _el$8.nextSibling;
401
+ const _el$ = $51b5c03492337d58$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$7 = _el$4.nextSibling, _el$8 = _el$7.nextSibling, _el$11 = _el$8.nextSibling, _el$9 = _el$11.nextSibling, _el$10 = _el$9.nextSibling;
395
402
  const _ref$ = element;
396
403
  typeof _ref$ === "function" ? (0, $g9l4l$use)(_ref$, _el$) : element = _el$;
397
- (0, $g9l4l$insert)(_el$3, (0, $5178263ed1e394ca$export$469c7af753d08925)({
398
- price_: first_to_show,
399
- price_formatting_: modified_price_formatting_
404
+ (0, $g9l4l$insert)(_el$3, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
405
+ get price_ () {
406
+ return first_to_show();
407
+ },
408
+ get price_formatting_ () {
409
+ return modified_price_formatting_();
410
+ }
400
411
  }));
401
- (0, $g9l4l$insert)(_el$6, (0, $5178263ed1e394ca$export$469c7af753d08925)({
402
- price_: last_to_show,
403
- price_formatting_: modified_price_formatting_
412
+ (0, $g9l4l$insert)(_el$7, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
413
+ get price_ () {
414
+ return last_to_show();
415
+ },
416
+ get price_formatting_ () {
417
+ return modified_price_formatting_();
418
+ }
404
419
  }));
405
- (0, $g9l4l$insert)(_el$2, of_, _el$10);
406
- (0, $g9l4l$insert)(_el$9, count_to_show);
420
+ (0, $g9l4l$insert)(_el$2, of_, _el$11);
421
+ (0, $g9l4l$insert)(_el$10, count_to_show);
407
422
  return _el$;
408
423
  })();
409
424
  }
@@ -416,134 +431,6 @@ function $51b5c03492337d58$export$83fd5de5504a7a67({ formatted_number_of_results
416
431
 
417
432
 
418
433
 
419
- /** @jsxImportSource solid-js */
420
- function $948599427c358499$export$daf1a0aef2143a61({ first_result_in_viewport_: [, set_first_result_in_viewport_] , last_result_in_viewport_: [, set_last_result_in_viewport_] }) {
421
- const intersecting = new Set();
422
- const counting_is = new IntersectionObserver((records)=>{
423
- let kids;
424
- for (const { intersectionRatio: intersectionRatio , target: target } of records){
425
- const intersects = intersectionRatio > 0;
426
- const has_target = intersecting.has(target);
427
- if (intersects && !has_target) intersecting.add(target);
428
- else if (!intersects && has_target) intersecting.delete(target);
429
- }
430
- const numbers = [
431
- ...intersecting
432
- ].map((el)=>{
433
- const index = (kids ||= [
434
- ...el.parentElement?.children || []
435
- ]).indexOf(el);
436
- if (index < 0) return undefined;
437
- return index + 1;
438
- }).filter((item)=>item != undefined);
439
- set_first_result_in_viewport_(Math.min(...numbers));
440
- set_last_result_in_viewport_(Math.max(...numbers));
441
- });
442
- (0, $g9l4l$onCleanup)(()=>counting_is.disconnect());
443
- return (els)=>{
444
- for(let i = 0; i < els?.length; i++){
445
- const el = els[i];
446
- if (el instanceof Element) counting_is.observe(el);
447
- }
448
- };
449
- }
450
-
451
-
452
- /** @jsxImportSource solid-js */
453
-
454
- function $06e28148a32abb47$export$36aef51ac7a64eae({ depict_api_: depict_api_ , min_products_to_fetch_: min_products_to_fetch_ , all_products_loaded_: all_products_loaded_ , query_base_: query_base_ , observe_for_counting_: observe_for_counting_ , start_cursor_: start_cursor_ }) {
455
- let last_loaded = +new Date();
456
- let dead = false;
457
- let current_cursor = start_cursor_;
458
- const target_to_info = new Map();
459
- const tear_down = (0, $g9l4l$catchify)((loaded_all_products)=>{
460
- intersection_observer.disconnect();
461
- target_to_info.clear();
462
- dead = true;
463
- if (loaded_all_products) all_products_loaded_?.[1]?.(true);
464
- });
465
- const deduped_load_more = (0, $g9l4l$deparallelize)(async (...args)=>{
466
- const now = +new Date();
467
- // load faster if someone is scrolling aggressively
468
- const num_to_load = now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
469
- const new_cursor = await $06e28148a32abb47$var$load_more(...args, num_to_load);
470
- if (new_cursor) current_cursor = new_cursor;
471
- last_loaded = now;
472
- });
473
- const intersection_observer = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
474
- let num_children;
475
- for(let i = 0; i < records.length; i++){
476
- // we assume they all have the same parent 👀
477
- const record = records[i];
478
- if (record.intersectionRatio <= 0) continue;
479
- const { target: target } = record;
480
- const parent = target.parentElement;
481
- if (!parent) continue; // we're not in DOM or something funky
482
- if (num_children == undefined) {
483
- const kids = parent.childElementCount;
484
- if (isNaN(kids)) continue;
485
- num_children = kids;
486
- }
487
- const info = target_to_info.get(target);
488
- if (!info) continue; // How did this happen?
489
- let actual_index_;
490
- for(let i = 0; i < num_children; i++){
491
- const child = parent.children[i];
492
- if (child === target) {
493
- actual_index_ = i;
494
- break;
495
- }
496
- }
497
- if (actual_index_ == undefined) continue;
498
- const in_range = actual_index_ / num_children * 100;
499
- const range_to_load_at = current_cursor === start_cursor_ ? 50 : 75; // if first load, load earlier
500
- if (in_range > range_to_load_at) {
501
- // load if more than 75% of elements are in view, this will make so that we load sooner and sooner which maybe (?) will adjust to people scrolling quickly :)
502
- intersection_observer.disconnect(); // no need to watch these els anymore
503
- deduped_load_more({
504
- depict_api_: depict_api_,
505
- info_: info,
506
- container_: parent,
507
- query_base_: query_base_,
508
- on_reached_end_: ()=>tear_down(true),
509
- cursor_: current_cursor
510
- });
511
- }
512
- }
513
- }));
514
- (0, $g9l4l$onCleanup)(tear_down);
515
- return (items, _display, info_)=>{
516
- observe_for_counting_(items);
517
- if (dead) return items;
518
- for(let i = 0; i < items?.length; i++){
519
- const item = items[i];
520
- if (item instanceof Element) {
521
- target_to_info.set(item, info_);
522
- intersection_observer.observe(item);
523
- }
524
- }
525
- return items;
526
- };
527
- }
528
- async function $06e28148a32abb47$var$load_more({ depict_api_: depict_api_ , query_base_: query_base_ , container_: container_ , on_reached_end_: on_reached_end_ , info_: { rendering_options: rendering_options , t: t } , cursor_: cursor_ }, num_results_to_load) {
529
- (0, $g9l4l$dlog)("SearchResults: Loading more");
530
- const base_part = (0, $g9l4l$untrack)(query_base_);
531
- const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
532
- cursor: cursor_,
533
- limit: num_results_to_load,
534
- ...base_part
535
- });
536
- const new_displays = api_response?.displays || [];
537
- const { elements: elements } = await (0, $g9l4l$Rec_Renderer)(t, {
538
- ...rendering_options,
539
- recs: new_displays || []
540
- });
541
- if (elements) container_.append(...elements);
542
- else (0, $g9l4l$dlog)("SearchResults: Got no elements, that's weird", api_response);
543
- if ("cursor" in api_response) return api_response.cursor;
544
- else if (!api_response?.failed) on_reached_end_();
545
- }
546
-
547
434
 
548
435
 
549
436
 
@@ -678,7 +565,8 @@ function $af89070cc0052779$export$8895d39404bd2bb1(props) {
678
565
  const { user_triggered_: user_triggered_ , i18n_: i18n_ , also_clear_sorting_: also_clear_sorting_ , local_filter_cache_: [get_local_filter_cache, set_local_filter_cache] , selected_filters_: [get_selected_filters, set_selected_filters] , expanded_hierarchical_filters_: [get_expanded_hierarchical_filters, set_expanded_hierarchical_filters] , delay_toast_: delay_toast_ } = props;
679
566
  const previous_selected_filters = (0, $g9l4l$untrack)(get_selected_filters);
680
567
  if (!previous_selected_filters.length) {
681
- // no filters selected, do nothing
568
+ // no filters selected, still clear sorting if applicable but don't display a toast for that since it's very minor
569
+ if (also_clear_sorting_) props.current_sorting_[1]();
682
570
  if (delay_toast_) return ()=>{};
683
571
  return;
684
572
  }
@@ -778,13 +666,8 @@ function $a20b0ecfca7ab32d$export$ef6006467f04ee41({ i18n_: i18n_ , expanded_hie
778
666
  ]);
779
667
 
780
668
 
781
- /*
782
- * Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
783
- */ const $9679915780ee67c0$export$6c9030e511152266 = 30;
784
-
785
-
786
669
  function $ed06bb0bb83a46b3$export$a2cc176055f8f08() {
787
- return document.createComment("Please try setting `colsAtSize` on `DepictProvider`/`DepictSearch` to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.");
670
+ return document.createComment("Please try setting `colsAtSize` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.");
788
671
  }
789
672
 
790
673
 
@@ -837,77 +720,347 @@ function $a406ebe9523f192f$export$b69d0d92862de18b(props) {
837
720
  }
838
721
 
839
722
 
840
- const $57363319986950eb$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="PLP-results"></div>`, 2), $57363319986950eb$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="cards"></div>`, 2);
841
- let $57363319986950eb$var$cached_placeholder_element;
842
- function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_ , depict_api_: depict_api_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , first_result_in_viewport_: first_result_in_viewport_ , last_result_in_viewport_: last_result_in_viewport_ , scroll_restoration_data_: scroll_restoration_data_ , no_results_options_: no_results_options_ , desktop_filter_elements_: desktop_filter_elements_ , sort_or_filter_open_: sort_or_filter_open_ , rr_options_: rr_options_ , layout_options_: layout_options_ , tenant_object_: tenant_object_ , type_for_tracking_: type_for_tracking_ , id_currently_querying_for_: id_currently_querying_for_ }) {
843
- // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
844
- const is_loading = (0, $g9l4l$createMemo)(()=>plp_results_.loading || query_base_.loading);
845
- const cleanup_old_cards = [];
846
- const render_and_insert_results = (0, $g9l4l$deparallelize_no_drop)(async (insert_into, owner)=>{
847
- const fallback_to_no_results = ()=>(0, $g9l4l$runWithOwner)(owner, ()=>insert_into.replaceChildren(...(0, $a20b0ecfca7ab32d$export$ef6006467f04ee41)(no_results_options_)));
848
- const observe_for_counting_ = (0, $g9l4l$runWithOwner)(owner, ()=>(0, $948599427c358499$export$daf1a0aef2143a61)({
849
- last_result_in_viewport_: last_result_in_viewport_,
850
- first_result_in_viewport_: first_result_in_viewport_
851
- }));
852
- const current_results = (0, $g9l4l$untrack)(plp_results_);
853
- const current_cursor = current_results.cursor;
854
- const load_more_post_processor = current_cursor // if we already got everything, don't make actual load more post processor.
855
- ? (0, $06e28148a32abb47$export$36aef51ac7a64eae)({
856
- depict_api_: depict_api_,
857
- min_products_to_fetch_: min_products_to_fetch_,
858
- all_products_loaded_: all_products_loaded_,
859
- query_base_: query_base_,
860
- observe_for_counting_: observe_for_counting_,
861
- start_cursor_: current_cursor
862
- }) : function(items) {
863
- observe_for_counting_(items);
864
- return items;
865
- };
866
- // create owner to run product cards with an Owner, so they know when they've gotten removed
867
- const [owner_for_cards, dispose_our_cards] = (0, $g9l4l$createRoot)((dispose)=>[
868
- (0, $g9l4l$getOwner)(),
869
- dispose
723
+
724
+
725
+ function $ccba3881414a4cec$export$2f0cbfbb4354bb52(elements) {
726
+ // FYI this probably doesn't work on hugely deep nestings or large amount of elements
727
+ return (0, $g9l4l$createMemo)(()=>$ccba3881414a4cec$var$unwrapping_helper(elements));
728
+ }
729
+ function $ccba3881414a4cec$var$unwrapping_helper(elements) {
730
+ const result = [];
731
+ if (Array.isArray(elements)) for(let i = 0; i < elements.length; i++){
732
+ const element = elements[i];
733
+ result.push(...$ccba3881414a4cec$var$unwrapping_helper(element));
734
+ }
735
+ else if (typeof elements == "function") result.push(...$ccba3881414a4cec$var$unwrapping_helper(elements()));
736
+ else if (elements != undefined && typeof elements != "boolean") result.push(elements);
737
+ return result;
738
+ }
739
+
740
+
741
+ let $dc5df79ae78a9d00$var$cached_placeholder_element;
742
+ let $dc5df79ae78a9d00$var$rendering_cached_placeholder_element;
743
+ function $dc5df79ae78a9d00$export$f33414a4df0afd3f({ product_card_template_: product_card_template_ , num_placeholders_: num_placeholders_ }) {
744
+ const [get_elements, set_elements] = (0, $g9l4l$createSignal)([]);
745
+ let existing_num = 0;
746
+ (0, $g9l4l$createRenderEffect)(()=>{
747
+ const to_add = num_placeholders_() - existing_num;
748
+ if (to_add <= 0) return;
749
+ // 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.
750
+ // 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.
751
+ // 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.
752
+ set_elements((prev)=>[
753
+ ...prev,
754
+ ...Array.from({
755
+ length: to_add
756
+ }).map(()=>$dc5df79ae78a9d00$var$Placeholder({
757
+ product_card_template_: product_card_template_
758
+ }))
870
759
  ]);
871
- const rendering_result = await (0, $g9l4l$default_rr)(tenant_object_, {
872
- type: type_for_tracking_,
873
- recs: current_results.displays,
874
- ...rr_options_,
875
- ...typeof rr_options_.template === "function" ? {
876
- template: $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, owner_for_cards)
877
- } : {},
878
- post_processors: [
879
- ...rr_options_.post_processors || [],
880
- load_more_post_processor
881
- ]
760
+ existing_num += to_add;
761
+ });
762
+ return get_elements; // https://github.com/solidjs/solid/releases/tag/v1.7.0
763
+ }
764
+ /**
765
+ * Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
766
+ */ function $dc5df79ae78a9d00$var$Placeholder({ product_card_template_: product_card_template_ }) {
767
+ const get_cloned_placeholders = (element_to_clone = $dc5df79ae78a9d00$var$cached_placeholder_element)=>Array.isArray(element_to_clone) ? element_to_clone.map((el)=>el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
768
+ if ($dc5df79ae78a9d00$var$cached_placeholder_element) return get_cloned_placeholders();
769
+ let dispose_original_copy;
770
+ const get_unwrapped_element = (0, $g9l4l$createRoot)((dispose)=>{
771
+ dispose_original_copy = dispose;
772
+ // if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
773
+ const [resource] = (0, $g9l4l$createResource)(()=>{
774
+ if ($dc5df79ae78a9d00$var$rendering_cached_placeholder_element) return $dc5df79ae78a9d00$var$rendering_cached_placeholder_element;
775
+ const return_value = product_card_template_(null, undefined);
776
+ if (typeof return_value === "object" && typeof return_value?.then === "function") // Is Promise or promise-like object
777
+ $dc5df79ae78a9d00$var$rendering_cached_placeholder_element = return_value;
778
+ return return_value;
882
779
  });
883
- // check if we still should insert or something new happened while we were rendering
884
- if ((0, $g9l4l$untrack)(has_no_results_or_failed) || (0, $g9l4l$untrack)(is_loading)) {
885
- (0, $g9l4l$dlog)("PLPResults: Not inserting rendered results because we became loading or switched to no results");
886
- return;
887
- }
888
- const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
889
- if (!elements) {
890
- fallback_to_no_results(); // rendering failed at this point but just pretend it's no results
780
+ return (0, $g9l4l$createMemo)(()=>{
781
+ if (resource.loading) return ()=>[];
782
+ return (0, $ccba3881414a4cec$export$2f0cbfbb4354bb52)(resource);
783
+ });
784
+ });
785
+ (0, $g9l4l$onCleanup)(()=>{
786
+ if ($dc5df79ae78a9d00$var$rendering_cached_placeholder_element) {
787
+ // 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
788
+ const unset_current_rendering = ()=>{
789
+ dispose_original_copy();
790
+ $dc5df79ae78a9d00$var$rendering_cached_placeholder_element = undefined;
791
+ };
792
+ $dc5df79ae78a9d00$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
793
+ } else // Otherwise, just make sure we've disposed our root
794
+ dispose_original_copy();
795
+ });
796
+ return (0, $g9l4l$createMemo)(()=>{
797
+ const unwrapped_array = get_unwrapped_element()();
798
+ if (!unwrapped_array?.length || !unwrapped_array.every((item)=>item)) // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
799
+ return;
800
+ // placeholders have finished rendering, freeze the elements
801
+ $dc5df79ae78a9d00$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
802
+ $dc5df79ae78a9d00$var$rendering_cached_placeholder_element = undefined;
803
+ dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
804
+ 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
805
+ });
806
+ }
807
+
808
+
809
+ /*
810
+ * Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
811
+ */ const $9679915780ee67c0$export$6c9030e511152266 = 30;
812
+
813
+
814
+ /** @jsxImportSource solid-js */
815
+
816
+
817
+
818
+ function $ebad9fcdd4698520$export$5e4aed86c12acdd9({ percentage_in_view_: percentage_in_view_ , set_extra_displays_: set_extra_displays_ , all_products_loaded_: all_products_loaded_ , plp_results_: plp_results_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , depict_api_: depict_api_ }) {
819
+ let last_loaded = +new Date();
820
+ let is_loading_more = false;
821
+ let is_first_load = true;
822
+ const [get_last_cursor, set_last_cursor] = (0, $g9l4l$createSignal)();
823
+ (0, $g9l4l$createComputed)((0, $g9l4l$on)(plp_results_, ()=>set_extra_displays_([]), {
824
+ defer: true
825
+ })); // empty array when a new request has completed (don't run this initially since it will already be empty)
826
+ (0, $g9l4l$createComputed)(()=>{
827
+ set_last_cursor(plp_results_()?.cursor);
828
+ last_loaded = +new Date();
829
+ is_first_load = true;
830
+ });
831
+ (0, $g9l4l$createEffect)((0, $g9l4l$catchify)(async ()=>{
832
+ const be_above_percentage = is_first_load ? 50 : 75; // if first load, load earlier
833
+ if (percentage_in_view_() < be_above_percentage || is_loading_more) return;
834
+ if (!get_last_cursor()) {
835
+ // dlog("All results loaded, can't load more");
836
+ all_products_loaded_?.[1](true); // This is unset in SearchPage as we start fetching new results
891
837
  return;
892
838
  }
893
- insert_into.replaceChildren(...elements);
894
- // Dispose the old cards just after the cards have been removed from the DOM
895
- cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
896
- cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
897
- should_stay_inserted?.then((should)=>{
898
- // If we shouldn't stay inserted for some reason, switch back to no results
899
- if (!should) fallback_to_no_results();
839
+ // dlog("More than ", be_above_percentage, "% in view, ", percentage_in_view_(), "%, loading more");
840
+ is_loading_more = true;
841
+ const base_part = (0, $g9l4l$untrack)(query_base_);
842
+ const now = +new Date();
843
+ // load faster if someone is scrolling aggressively
844
+ const number_of_results_to_load = is_first_load ? // After first load, always just load 20 since people might just be browsing the top ones still
845
+ min_products_to_fetch_ : now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
846
+ // dlog("loading ", number_of_results_to_load, "products, because it was", now - last_loaded, "ms since last load");
847
+ const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
848
+ cursor: get_last_cursor(),
849
+ limit: number_of_results_to_load,
850
+ ...base_part
851
+ });
852
+ const new_displays = api_response?.displays || [];
853
+ set_extra_displays_((old_value)=>{
854
+ // We want this to go fast. The apply method is the fastest way to add to an array, and AFAIK it's faster to add than to create a new one.
855
+ // eslint-disable-next-line prefer-spread
856
+ old_value.push.apply(old_value, new_displays);
857
+ return old_value;
900
858
  });
859
+ set_last_cursor(api_response.cursor);
860
+ is_loading_more = false;
861
+ last_loaded = +new Date();
862
+ is_first_load = false;
863
+ }));
864
+ }
865
+
866
+
867
+
868
+ function $912322b9ff19fa51$export$63dd0350f8559dda({ displays_by_key_: displays_by_key_ , get_last_result_in_viewport_: get_last_result_in_viewport_ , index_to_target_map_: index_to_target_map_ , is_loading_: is_loading_ , get_extra_displays: get_extra_displays }) {
869
+ const [get_has_rendered_toggle, set_has_rendered_toggle] = (0, $g9l4l$createSignal)(false);
870
+ (0, $g9l4l$createEffect)(()=>{
871
+ // We need this to run after the "render phase"
872
+ get_extra_displays();
873
+ set_has_rendered_toggle((old)=>!old);
874
+ });
875
+ return (0, $g9l4l$createMemo)(()=>{
876
+ const last = get_last_result_in_viewport_();
877
+ // Check if we are past the last result, in that case we want it to count as 100% for a better infinite scroll experience
878
+ past_last_result_check: {
879
+ const elements_of_last_result = index_to_target_map_.get(index_to_target_map_.size - 1);
880
+ if (elements_of_last_result) {
881
+ if ((0, $g9l4l$untrack)(is_loading_)) {
882
+ // We're loading, wait check again after we have inserted our new results
883
+ get_has_rendered_toggle();
884
+ break past_last_result_check;
885
+ }
886
+ for (const element of elements_of_last_result){
887
+ if (document.documentElement.contains(element) && element.getBoundingClientRect().top <= 0) // dlog(element, "which is of last product card is in or above viewport, probably loading more");
888
+ return 100;
889
+ }
890
+ }
891
+ }
892
+ if (isNaN(last)) return 0;
893
+ if (Math.abs(last) === Infinity) // No product card in view and not after last card, assume first card
894
+ return 0;
895
+ return last / displays_by_key_().size * 100;
896
+ });
897
+ }
898
+
899
+
900
+
901
+
902
+ /**
903
+ * Gets product_id (the thing we key the rendering on) from a display
904
+ */ function $4dd45ddfca49bd72$export$548d053aba053d79(display) {
905
+ if ("variant_index" in display) {
906
+ const actual_display = display.variant_displays[display.variant_index];
907
+ return actual_display.product_id;
908
+ }
909
+ return display.product_id;
910
+ }
911
+
912
+
913
+
914
+ function $7a5055d6c11943a0$export$7f8bd308237ab5a5(get_displays_) {
915
+ const displays_by_key_ = (0, $g9l4l$createMemo)(()=>{
916
+ const displays = get_displays_();
917
+ // We key by product_id because that's what can be used to uniquely identify products
918
+ // This way <For> can optimize the rendering
919
+ const map = new Map();
920
+ for(let i = 0; i < displays.length; i++){
921
+ const display = displays[i];
922
+ const product_id = (0, $4dd45ddfca49bd72$export$548d053aba053d79)(display);
923
+ map.set(product_id, display);
924
+ }
925
+ return map;
926
+ });
927
+ return displays_by_key_;
928
+ }
929
+ function $7a5055d6c11943a0$export$43f0fb951fcb0c54({ displays_by_key_: displays_by_key_ , merchant_: merchant_ , market_: market_ , product_card_template_: product_card_template_ , do_per_elements_: do_per_elements_ }) {
930
+ return (0, $g9l4l$createComponent)((0, $g9l4l$For), {
931
+ get each () {
932
+ return [
933
+ ...displays_by_key_().keys()
934
+ ];
935
+ },
936
+ children: (product_id, index)=>{
937
+ // We're using `untrack` here since we don't want to react in here to displays_by_key changing
938
+ // As long as our key stays the same we assume that the display hasn't changed, so we don't want to rerender
939
+ // If the key gets removed, <For> will remove us
940
+ const owner = (0, $g9l4l$getOwner)();
941
+ const display_accessor = (0, $g9l4l$createMemo)(()=>displays_by_key_().get(product_id));
942
+ const [product_card_resource] = (0, $g9l4l$createResource)((0, $g9l4l$createMemo)(()=>[
943
+ merchant_(),
944
+ market_()
945
+ ]), // re-render when merchant or market changes
946
+ ([merchant, market])=>{
947
+ // get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
948
+ const display = (0, $g9l4l$untrack)(display_accessor);
949
+ return product_card_template_(display, {
950
+ set_on_index_change: (fn)=>(0, $g9l4l$runWithOwner)(owner, ()=>(0, $g9l4l$createEffect)(()=>fn(index()))),
951
+ merchant: merchant,
952
+ market: market
953
+ });
954
+ });
955
+ const node_accessor = (0, $ccba3881414a4cec$export$2f0cbfbb4354bb52)(product_card_resource);
956
+ (0, $g9l4l$createEffect)(()=>{
957
+ const product_card_nodes = node_accessor();
958
+ const display = display_accessor();
959
+ const elements = [];
960
+ for(let i = 0; i < product_card_nodes.length; i++){
961
+ const element = product_card_nodes[i];
962
+ if (!(element instanceof Element)) continue;
963
+ elements.push(element);
964
+ // Add tracking ids
965
+ if (!(element instanceof HTMLElement)) continue; // Apparently only HTMLElements have dataset
966
+ const { dataset: dataset } = element;
967
+ const { search_result_id: search_result_id , product_listing_result_id: product_listing_result_id , recommendation_id: recommendation_id } = display;
968
+ if (search_result_id) dataset.searchResultId = search_result_id;
969
+ else if (product_listing_result_id) dataset.productListingResultId = product_listing_result_id;
970
+ else if (recommendation_id) dataset.recommendationId = recommendation_id;
971
+ }
972
+ do_per_elements_?.(elements, index);
973
+ });
974
+ return product_card_resource; // https://github.com/solidjs/solid/releases/tag/v1.7.0
975
+ }
976
+ });
977
+ }
978
+
979
+
980
+ function $9653d6d247b0b1cc$export$a1fd619a4743ca08({ plp_results_: plp_results_ , product_card_template_: product_card_template_ , first_result_in_viewport_: [, set_first_result_in_viewport] , last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport] , merchant_: merchant_ , market_: market_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , depict_api_: depict_api_ , is_loading_: is_loading_ }) {
981
+ // 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
982
+ const target_to_index_map = new Map();
983
+ const index_to_target_map_ = new Map();
984
+ const currently_intersecting = new Set();
985
+ const intersection_observer = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
986
+ for(let i = 0; i < records.length; i++){
987
+ const record = records[i];
988
+ const { target: target , intersectionRatio: intersectionRatio } = record;
989
+ const index_of_target = target_to_index_map.get(target);
990
+ const is_in_set = currently_intersecting.has(index_of_target);
991
+ if (intersectionRatio > 0) {
992
+ if (!is_in_set) currently_intersecting.add(index_of_target);
993
+ } else if (is_in_set) currently_intersecting.delete(index_of_target);
994
+ }
995
+ set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
996
+ set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
997
+ }, "PLPResults IO failed"));
998
+ // Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
999
+ const [get_extra_displays, set_extra_displays_] = (0, $g9l4l$createSignal)([], {
1000
+ equals: false
1001
+ });
1002
+ const displays_by_key_ = (0, $7a5055d6c11943a0$export$7f8bd308237ab5a5)((0, $g9l4l$createMemo)(()=>[
1003
+ ...plp_results_().displays,
1004
+ ...get_extra_displays()
1005
+ ]));
1006
+ const percentage_in_view_ = (0, $912322b9ff19fa51$export$63dd0350f8559dda)({
1007
+ get_last_result_in_viewport_: get_last_result_in_viewport_,
1008
+ displays_by_key_: displays_by_key_,
1009
+ index_to_target_map_: index_to_target_map_,
1010
+ is_loading_: is_loading_,
1011
+ get_extra_displays: get_extra_displays
1012
+ });
1013
+ (0, $ebad9fcdd4698520$export$5e4aed86c12acdd9)({
1014
+ percentage_in_view_: percentage_in_view_,
1015
+ set_extra_displays_: set_extra_displays_,
1016
+ all_products_loaded_: all_products_loaded_,
1017
+ plp_results_: plp_results_,
1018
+ min_products_to_fetch_: min_products_to_fetch_,
1019
+ query_base_: query_base_,
1020
+ depict_api_: depict_api_
1021
+ });
1022
+ return (0, $7a5055d6c11943a0$export$43f0fb951fcb0c54)({
1023
+ displays_by_key_: displays_by_key_,
1024
+ merchant_: merchant_,
1025
+ market_: market_,
1026
+ product_card_template_: product_card_template_,
1027
+ do_per_elements_: (elements, index_accessor)=>// Adds/removes elements from the "results in viewport" intersection observer above
1028
+ (0, $g9l4l$createEffect)(()=>{
1029
+ const display_index = index_accessor();
1030
+ // Nested createEffect because we only want to re-run this when the index changes
1031
+ // 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
1032
+ for(let i = 0; i < elements.length; i++){
1033
+ const element = elements[i];
1034
+ target_to_index_map.set(element, display_index);
1035
+ intersection_observer.observe(element);
1036
+ (0, $g9l4l$onCleanup)(()=>{
1037
+ intersection_observer.unobserve(element);
1038
+ target_to_index_map.delete(element);
1039
+ currently_intersecting.delete(display_index);
1040
+ });
1041
+ }
1042
+ index_to_target_map_.set(display_index, elements);
1043
+ (0, $g9l4l$onCleanup)(()=>index_to_target_map_.delete(display_index));
1044
+ })
901
1045
  });
1046
+ }
1047
+
1048
+
1049
+ const $57363319986950eb$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="PLP-results"></div>`, 2), $57363319986950eb$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="cards"></div>`, 2), $57363319986950eb$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<style></style>`, 2);
1050
+ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_ , depict_api_: depict_api_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , first_result_in_viewport_: first_result_in_viewport_ , last_result_in_viewport_: last_result_in_viewport_ , scroll_restoration_data_: [get_scroll_restoration_data] , no_results_options_: no_results_options_ , desktop_filter_elements_: desktop_filter_elements_ , sort_or_filter_open_: sort_or_filter_open_ , product_card_template_: product_card_template_ , layout_options_: layout_options_ , id_currently_querying_for_: id_currently_querying_for_ }) {
1051
+ // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
1052
+ const is_loading_ = (0, $g9l4l$createMemo)(()=>plp_results_.loading || query_base_.loading);
1053
+ const merchant_ = (0, $g9l4l$createMemo)(()=>query_base_().tenant);
1054
+ const market_ = (0, $g9l4l$createMemo)(()=>query_base_().market);
902
1055
  const has_no_results_or_failed = (0, $g9l4l$createMemo)(()=>{
903
1056
  const displays = plp_results_()?.displays;
904
- return !is_loading() && (!Array.isArray(displays) || !displays.length);
1057
+ return !is_loading_() && (!Array.isArray(displays) || !displays.length);
905
1058
  });
906
- if (all_products_loaded_) (0, $g9l4l$createComputed)(()=>{
1059
+ if (all_products_loaded_) // This is for the case that all products were loaded in the first result I think?
1060
+ (0, $g9l4l$createComputed)(()=>{
907
1061
  const is_at_end = !plp_results_()?.cursor; // or failed, but we don't wanna / it's not easy to retry
908
- if (!is_loading() && is_at_end) all_products_loaded_[1](true);
1062
+ if (!is_loading_() && is_at_end) all_products_loaded_[1](true);
909
1063
  });
910
- (0, $g9l4l$onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
911
1064
  return (()=>{
912
1065
  const _el$ = $57363319986950eb$var$_tmpl$.cloneNode(true);
913
1066
  (0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
@@ -921,7 +1074,7 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
921
1074
  return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
922
1075
  severity_: "error",
923
1076
  // More granular error handling
924
- // This _also_ fails when a product card rendering fails due to the runWithOwner with a root that was created inside the "root"/"context" of this ErrorBoundary
1077
+ // This _also_ fails when a product card rendering fails
925
1078
  on_error_: (retry)=>{
926
1079
  // re-try / reset ErrorBoundary next time we're getting product cards
927
1080
  const track = (0, $g9l4l$createReaction)(retry);
@@ -933,83 +1086,108 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
933
1086
  // So that the styling looks pretty when we've failed
934
1087
  message_: "Result rendering failed",
935
1088
  get children () {
1089
+ let suspense_contents;
1090
+ let is_just_after_plp_results_update = false;
1091
+ let fallback_is_alive = false;
936
1092
  const random_id = (0, $g9l4l$make_random_classname)();
937
- const selector_beginning = `.depict.plp #${random_id}>`;
938
- const cards = (()=>{
939
- const _el$2 = $57363319986950eb$var$_tmpl$2.cloneNode(true);
940
- (0, $g9l4l$setAttribute)(_el$2, "id", random_id);
941
- return _el$2;
942
- })();
943
- const style = document.createElement("style");
944
- (0, $g9l4l$createRenderEffect)(()=>{
945
- // Add grid styling that changes when filters get opened/closed
946
- const when_filters_closed_cols = layout_options_.cols_at_size;
947
- const cols_at_size = sort_or_filter_open_() ? when_filters_closed_cols.map((row)=>{
948
- const [num_cols_default, , , , override_cols] = row;
949
- const cloned_row = [
950
- ...row
951
- ];
952
- // @ts-ignore
953
- cloned_row[0] = num_cols_default - 1;
954
- if (override_cols) // @ts-ignore
955
- cloned_row[4] = {
956
- overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
957
- row,
958
- column - 1
959
- ]))
960
- };
961
- return cloned_row;
962
- }) : when_filters_closed_cols;
963
- const css = (0, $g9l4l$n_col_styling_with_dist)(selector_beginning, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
964
- style.replaceChildren(css);
1093
+ const selector_beginning_ = `.depict.plp #${random_id}>`;
1094
+ const [get_styling, set_styling_] = (0, $g9l4l$createSignal)("");
1095
+ const [get_should_have_placeholders_rendered, set_should_have_placeholders_rendered] = (0, $g9l4l$createSignal)(false);
1096
+ const rendered_placeholders = (0, $g9l4l$createMemo)(()=>get_should_have_placeholders_rendered() ? (0, $dc5df79ae78a9d00$export$f33414a4df0afd3f)({
1097
+ product_card_template_: product_card_template_,
1098
+ num_placeholders_: (0, $g9l4l$createMemo)(()=>{
1099
+ // Can't use the data out of request_base for the id because request_base is too late, we need the correct amount of placeholders before the browser has restored the scroll state after processing all popstate events
1100
+ return (0, $9679915780ee67c0$export$6c9030e511152266) + (get_scroll_restoration_data().find(({ for_id: for_id })=>for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
1101
+ })
1102
+ }) : undefined);
1103
+ const [get_suspense_is_blocked, set_suspense_is_blocked] = (0, $g9l4l$createSignal)(false);
1104
+ (0, $g9l4l$createComputed)(()=>{
1105
+ if (!is_loading_()) return;
1106
+ set_should_have_placeholders_rendered(true);
1107
+ set_suspense_is_blocked(false);
1108
+ is_just_after_plp_results_update = true;
965
1109
  });
966
- (0, $g9l4l$createRenderEffect)(// render placeholders / product cards
967
- (0, $g9l4l$catchify)(async ()=>{
968
- const owner_ = (0, $g9l4l$getOwner)();
969
- if (is_loading()) await $57363319986950eb$var$insert_placeholders({
970
- scroll_restoration_data_: scroll_restoration_data_,
971
- id_currently_querying_for_: id_currently_querying_for_,
972
- rr_options_: rr_options_,
973
- tenant_object_: tenant_object_,
974
- min_products_to_fetch_: min_products_to_fetch_,
975
- owner_: owner_,
976
- cards_element_: cards
977
- });
978
- else if (!has_no_results_or_failed()) {
979
- plp_results_(); // re-run render_and_insert_results when results change
980
- render_and_insert_results(cards, owner_);
981
- }
982
- }));
983
- // copied from RecommendationGrid
984
- // convoluted lazy loading that
985
- // when the elements are in the DOM starts IntersectionObserver on whole grid
986
- // when grid intersects starts Lazyfier
987
- // this is because Lazyfier is fucking stupid
988
- (0, $g9l4l$observer).wait_for_element(cards).then((0, $g9l4l$catchify)((element)=>{
989
- let start_lazy_loading;
990
- const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
991
- const lf = new (0, $g9l4l$Lazyfier)({
992
- only_load_intersecting: true,
993
- wait_for_dominsertion: lazy_loading_promise,
994
- ignore_data_urls: true,
995
- lazyfinder: {
996
- unload () {}
997
- }
998
- });
999
- lf.start_observing_for_new_children_(element);
1000
- const i_o = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
1001
- for (const record of records)if (record.intersectionRatio > 0) {
1002
- start_lazy_loading();
1003
- i_o.disconnect();
1004
- return;
1110
+ $57363319986950eb$var$results_grid_styling_generator({
1111
+ layout_options_: layout_options_,
1112
+ set_styling_: set_styling_,
1113
+ sort_or_filter_open_: sort_or_filter_open_,
1114
+ selector_beginning_: selector_beginning_
1115
+ });
1116
+ const has_at_least_one_display = (0, $g9l4l$createMemo)(()=>!!plp_results_()?.displays?.length); // Only de-construct below stuff if we get 0 displays. Important that this returns boolean so that below Suspense only gets re-created if it actually changes
1117
+ const block_suspense_if_needed = ()=>{
1118
+ if (!is_just_after_plp_results_update) return;
1119
+ is_just_after_plp_results_update = false;
1120
+ fallback_is_alive = false;
1121
+ set_suspense_is_blocked(true);
1122
+ };
1123
+ const non_placeholder_product_cards = (0, $g9l4l$createMemo)(()=>has_at_least_one_display() && // This suspense ensures that if someone has async templates, we still show placeholders until the product cards actually have finished rendering (automagically since they're createResource's)
1124
+ // We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
1125
+ // (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
1126
+ // We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
1127
+ (0, $g9l4l$createComponent)((0, $g9l4l$Suspense), {
1128
+ get fallback () {
1129
+ return (()=>{
1130
+ fallback_is_alive = true;
1131
+ (0, $g9l4l$onCleanup)(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
1132
+ return (0, $g9l4l$createMemo)(()=>{
1133
+ // We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
1134
+ // In future we could have individual suspense's for each product card, but that's too much for now
1135
+ if (get_suspense_is_blocked()) return suspense_contents;
1136
+ set_should_have_placeholders_rendered(true); // just in case
1137
+ (0, $g9l4l$onCleanup)(()=>set_should_have_placeholders_rendered(false));
1138
+ return rendered_placeholders; // I lifted the placeholders into the memo since we don't want to re-render them when switching from <Show> to <Suspense>
1139
+ });
1140
+ })();
1141
+ },
1142
+ get children () {
1143
+ return (()=>{
1144
+ suspense_contents = (0, $9653d6d247b0b1cc$export$a1fd619a4743ca08)({
1145
+ product_card_template_: product_card_template_,
1146
+ plp_results_: plp_results_,
1147
+ last_result_in_viewport_: last_result_in_viewport_,
1148
+ first_result_in_viewport_: first_result_in_viewport_,
1149
+ market_: market_,
1150
+ merchant_: merchant_,
1151
+ all_products_loaded_: all_products_loaded_,
1152
+ min_products_to_fetch_: min_products_to_fetch_,
1153
+ query_base_: query_base_,
1154
+ depict_api_: depict_api_,
1155
+ is_loading_: is_loading_
1156
+ });
1157
+ (0, $g9l4l$onCleanup)(()=>suspense_contents = undefined);
1158
+ return suspense_contents;
1159
+ })();
1005
1160
  }
1006
1161
  }));
1007
- i_o.observe(cards);
1162
+ (0, $g9l4l$createEffect)((0, $g9l4l$on)(plp_results_, ()=>{
1163
+ if (!fallback_is_alive) // if all product card rendering functions after the initial rendering are synchronous the suspense boundary will never go into the fallback, so we don't know when they have finished rendering, and we can block the suspense. Therefore, we're just doing it with this effect
1164
+ block_suspense_if_needed();
1165
+ }, {
1166
+ defer: true
1008
1167
  }));
1009
1168
  return [
1010
- (0, $ed06bb0bb83a46b3$export$a2cc176055f8f08)(),
1011
- cards,
1012
- style
1169
+ (0, $g9l4l$memo)((0, $ed06bb0bb83a46b3$export$a2cc176055f8f08)),
1170
+ (()=>{
1171
+ const _el$2 = $57363319986950eb$var$_tmpl$2.cloneNode(true);
1172
+ (0, $g9l4l$setAttribute)(_el$2, "id", random_id);
1173
+ (0, $g9l4l$insert)(_el$2, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
1174
+ get when () {
1175
+ return !is_loading_();
1176
+ },
1177
+ get fallback () {
1178
+ return rendered_placeholders();
1179
+ },
1180
+ get children () {
1181
+ return non_placeholder_product_cards();
1182
+ }
1183
+ }));
1184
+ return _el$2;
1185
+ })(),
1186
+ (()=>{
1187
+ const _el$3 = $57363319986950eb$var$_tmpl$3.cloneNode(true);
1188
+ (0, $g9l4l$insert)(_el$3, get_styling);
1189
+ return _el$3;
1190
+ })()
1013
1191
  ];
1014
1192
  }
1015
1193
  });
@@ -1020,63 +1198,32 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
1020
1198
  return _el$;
1021
1199
  })();
1022
1200
  }
1023
- async function $57363319986950eb$var$insert_placeholders({ scroll_restoration_data_: [get_scroll_restoration_data] , min_products_to_fetch_: min_products_to_fetch_ , tenant_object_: tenant_object_ , rr_options_: rr_options_ , owner_: owner_ , cards_element_: cards_element_ , id_currently_querying_for_: id_currently_querying_for_ }) {
1024
- const num_placeholders = // we don't need runWithOwner here because we haven't had an await yet, so we haven't lost the owner
1025
- (0, $g9l4l$createMemo)(()=>{
1026
- // Can't use the data out of request_base for the id because request_base is too late, we need the correct amount of placeholders before the browser has restored the scroll state after processing all popstate events
1027
- return (0, $9679915780ee67c0$export$6c9030e511152266) + (get_scroll_restoration_data().find(({ for_id: for_id })=>for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
1201
+ /**
1202
+ * Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
1203
+ * This function is special to the actual PLPResults.
1204
+ */ function $57363319986950eb$var$results_grid_styling_generator({ layout_options_: layout_options_ , sort_or_filter_open_: sort_or_filter_open_ , set_styling_: set_styling_ , selector_beginning_: selector_beginning_ }) {
1205
+ (0, $g9l4l$createRenderEffect)(()=>{
1206
+ // Add grid styling that changes when filters get opened/closed
1207
+ const when_filters_closed_cols = layout_options_.cols_at_size;
1208
+ const cols_at_size = sort_or_filter_open_() ? when_filters_closed_cols.map((row)=>{
1209
+ const [num_cols_default, , , , override_cols] = row;
1210
+ const cloned_row = [
1211
+ ...row
1212
+ ];
1213
+ // @ts-ignore
1214
+ cloned_row[0] = num_cols_default - 1;
1215
+ if (override_cols) // @ts-ignore
1216
+ cloned_row[4] = {
1217
+ overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
1218
+ row,
1219
+ column - 1
1220
+ ]))
1221
+ };
1222
+ return cloned_row;
1223
+ }) : when_filters_closed_cols;
1224
+ const css = (0, $g9l4l$n_col_styling_with_dist)(selector_beginning_, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
1225
+ set_styling_(css);
1028
1226
  });
1029
- let existing_num = 0;
1030
- let removed_old_children = false;
1031
- if (!$57363319986950eb$var$cached_placeholder_element) {
1032
- const [dispose_card, root_in_root] = (0, $g9l4l$createRoot)((dispose)=>[
1033
- dispose,
1034
- (0, $g9l4l$getOwner)()
1035
- ]);
1036
- const { elements: elements } = await (0, $g9l4l$default_rr)(tenant_object_, {
1037
- ...rr_options_,
1038
- type: "placeholder",
1039
- pre_processors: [],
1040
- post_processors: [],
1041
- ...typeof rr_options_.template === "function" ? {
1042
- template: $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, root_in_root, ()=>(0, $g9l4l$queueMacroTask)((0, $g9l4l$catchify)(dispose_card)) // we just want it cloned and dead
1043
- )
1044
- } : {},
1045
- recs: [
1046
- {
1047
- page_url: "javascript:void(0)"
1048
- }
1049
- ] // This later gets ignored and turned into `null` by the SDK functions in the @depict-ai/ui package
1050
- });
1051
- const element = elements?.find((e)=>e instanceof HTMLElement || e instanceof SVGElement);
1052
- if (!element) return [];
1053
- $57363319986950eb$var$cached_placeholder_element = element.cloneNode(true); // don't save the actual element, clone it directly so that the who provided it can't modify it later (this has caused a bug before with react)
1054
- }
1055
- (0, $g9l4l$runWithOwner)(owner_, ()=>(0, $g9l4l$createRenderEffect)(()=>{
1056
- const to_add = num_placeholders() - existing_num;
1057
- if (to_add <= 0) return;
1058
- // 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.
1059
- // 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.
1060
- cards_element_[removed_old_children ? "append" : (removed_old_children = true, "replaceChildren")](...Array.from({
1061
- length: to_add
1062
- }).map(()=>$57363319986950eb$var$cached_placeholder_element.cloneNode(true)));
1063
- existing_num += to_add;
1064
- }));
1065
- }
1066
- function $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(template, root_in_root, on_finally) {
1067
- return async (...args)=>{
1068
- try {
1069
- return await (0, $g9l4l$runWithOwner)(root_in_root, ()=>template(...args)) || [];
1070
- } catch (e) {
1071
- (0, $g9l4l$runWithOwner)(root_in_root, ()=>{
1072
- // Throw in case of promise rejection, ultimately into ErrorBoundary
1073
- throw e;
1074
- });
1075
- return [];
1076
- } finally{
1077
- on_finally?.();
1078
- }
1079
- };
1080
1227
  }
1081
1228
 
1082
1229
 
@@ -1349,16 +1496,24 @@ function $a7abb08807717ef9$export$fecbb157621501bd({ number_of_rendered_selected
1349
1496
  };
1350
1497
  (0, $g9l4l$insert)(_el$5, (0, $g9l4l$createComponent)((0, $g9l4l$CrossIcon), {}), _el$6);
1351
1498
  (0, $g9l4l$insert)(_el$6, ()=>price_formatting_().pre_, _el$7);
1352
- (0, $g9l4l$insert)(_el$6, ()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
1353
- price_: (0, $g9l4l$createMemo)(()=>filter().data[0]),
1354
- price_formatting_: price_formatting_
1355
- }), _el$7);
1499
+ (0, $g9l4l$insert)(_el$6, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
1500
+ get price_ () {
1501
+ return filter().data[0];
1502
+ },
1503
+ get price_formatting_ () {
1504
+ return price_formatting_();
1505
+ }
1506
+ }), _el$7);
1356
1507
  (0, $g9l4l$insert)(_el$6, ()=>price_formatting_().post_, _el$7);
1357
1508
  (0, $g9l4l$insert)(_el$6, ()=>price_formatting_().pre_, null);
1358
- (0, $g9l4l$insert)(_el$6, ()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
1359
- price_: (0, $g9l4l$createMemo)(()=>filter().data[1]),
1360
- price_formatting_: price_formatting_
1361
- }), null);
1509
+ (0, $g9l4l$insert)(_el$6, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
1510
+ get price_ () {
1511
+ return filter().data[1];
1512
+ },
1513
+ get price_formatting_ () {
1514
+ return price_formatting_();
1515
+ }
1516
+ }), null);
1362
1517
  (0, $g9l4l$insert)(_el$6, ()=>price_formatting_().post_, null);
1363
1518
  return _el$5;
1364
1519
  })();
@@ -1657,7 +1812,7 @@ function $9e6544e509214c47$export$ca21a16d65b3dd8({ show_extras_: [get_show_extr
1657
1812
  const $5be19bd31e1c92fe$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<form class="checkboxes"></form>`, 2);
1658
1813
  const $5be19bd31e1c92fe$var$max_visible_without_collapsing = 7;
1659
1814
  const $5be19bd31e1c92fe$var$show_non_collapsible_when_collapsed = 4;
1660
- function $5be19bd31e1c92fe$export$dd948f91abc3a1c4({ filter_: filter_ , selected_filters_: [get_selected_filters, set_selected_filters] , i18n_: i18n_ , view_more_button_below_group_: [_get_view_more_button_below_group_, set_view_more_button_below_group_] }) {
1815
+ function $5be19bd31e1c92fe$export$dd948f91abc3a1c4({ filter_: filter_ , selected_filters_: [get_selected_filters, set_selected_filters] , i18n_: i18n_ , view_more_button_below_group_: [, set_view_more_button_below_group_] }) {
1661
1816
  const existing_filter = (0, $g9l4l$createMemo)(()=>{
1662
1817
  const { field: field , op: op } = filter_();
1663
1818
  return get_selected_filters().find(({ field: checking_field , op: checking_op })=>checking_field === field && checking_op === op);
@@ -1738,7 +1893,7 @@ function $5be19bd31e1c92fe$export$dd948f91abc3a1c4({ filter_: filter_ , selected
1738
1893
  ...base_object,
1739
1894
  data: [
1740
1895
  ...new FormData(form)
1741
- ].filter(([_key, value])=>value === "on").map(([key])=>key)
1896
+ ].filter(([, value])=>value === "on").map(([key])=>key)
1742
1897
  };
1743
1898
  const selected_filters = [
1744
1899
  ...get_selected_filters()
@@ -1929,16 +2084,24 @@ function $66f3de62e88607b0$var$RangeSelector({ max_: max_ , min_: min_ , current
1929
2084
  i18n_: i18n_
1930
2085
  }), _el$8);
1931
2086
  (0, $g9l4l$insert)(_el$9, pre_price, null);
1932
- (0, $g9l4l$insert)(_el$9, ()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
1933
- price_: min_,
1934
- price_formatting_: price_formatting_
1935
- }), null);
2087
+ (0, $g9l4l$insert)(_el$9, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
2088
+ get price_ () {
2089
+ return min_();
2090
+ },
2091
+ get price_formatting_ () {
2092
+ return price_formatting_();
2093
+ }
2094
+ }), null);
1936
2095
  (0, $g9l4l$insert)(_el$9, post_price, null);
1937
2096
  (0, $g9l4l$insert)(_el$10, pre_price, null);
1938
- (0, $g9l4l$insert)(_el$10, ()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
1939
- price_: max_,
1940
- price_formatting_: price_formatting_
1941
- }), null);
2097
+ (0, $g9l4l$insert)(_el$10, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
2098
+ get price_ () {
2099
+ return max_();
2100
+ },
2101
+ get price_formatting_ () {
2102
+ return price_formatting_();
2103
+ }
2104
+ }), null);
1942
2105
  (0, $g9l4l$insert)(_el$10, post_price, null);
1943
2106
  (0, $g9l4l$effect)((_p$)=>{
1944
2107
  const _v$ = i18n_.range_filter_low_point_aria_label_(), _v$2 = min_(), _v$3 = max_(), _v$4 = i18n_.range_filter_high_point_aria_label_(), _v$5 = min_(), _v$6 = max_();
@@ -2843,48 +3006,57 @@ var $7b224b353182ce9a$export$2e2bcd8739ae039 = {
2843
3006
  const $7c4a8499f0ad6e11$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="show-selected" aria-hidden="true"><span></span></span>`, 4);
2844
3007
  function $7c4a8499f0ad6e11$export$53c59af873b303c9({ selected_filters_in_group_: selected_filters_in_group_ , i18n_: { price_formatting_: price_formatting_ } }) {
2845
3008
  const [show_tick_icon, set_show_tick_icon] = (0, $g9l4l$createSignal)(false);
2846
- return (()=>{
2847
- const _el$ = $7c4a8499f0ad6e11$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
2848
- (0, $g9l4l$insert)(_el$2, ()=>(0, $g9l4l$createMemo)(()=>(0, $g9l4l$batch)(()=>{
2849
- set_show_tick_icon(false);
2850
- let { size: size } = selected_filters_in_group_();
2851
- try_specific: {
2852
- if (size > 1) break try_specific;
2853
- for (const [selected_filter, filter_data] of selected_filters_in_group_()){
2854
- // we're intentionally not looping in this statement since we always just want to show the first thing in the filter group
2855
- const { meta: meta } = filter_data;
2856
- const { type: type } = meta;
2857
- if (type === "range") return [
2858
- (0, $g9l4l$memo)(()=>price_formatting_().pre_),
2859
- (0, $g9l4l$memo)(()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
2860
- price_: (0, $g9l4l$createMemo)(()=>selected_filter.data[0]),
2861
- price_formatting_: price_formatting_
2862
- })),
2863
- (0, $g9l4l$memo)(()=>price_formatting_().post_),
2864
- " – ",
2865
- (0, $g9l4l$memo)(()=>price_formatting_().pre_),
2866
- (0, $g9l4l$memo)(()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
2867
- price_: (0, $g9l4l$createMemo)(()=>selected_filter.data[1]),
2868
- price_formatting_: price_formatting_
2869
- })),
2870
- (0, $g9l4l$memo)(()=>price_formatting_().post_)
2871
- ];
2872
- else {
2873
- const { data: data } = selected_filter;
2874
- const data_is_array = Array.isArray(data);
2875
- if (data_is_array && data.length !== 1) {
2876
- size = data.length;
2877
- break try_specific;
2878
- }
2879
- const needle = data_is_array ? data[0] : data;
2880
- const index_in_meta = meta.values.findIndex((value)=>needle === value || Array.isArray(needle) && Array.isArray(value) && needle.length === value.length && value.every((item, index)=>needle[index] === item));
2881
- return meta.names?.[index_in_meta] || meta.values?.[index_in_meta];
3009
+ const text = (0, $g9l4l$createMemo)(()=>(0, $g9l4l$batch)(()=>{
3010
+ set_show_tick_icon(false);
3011
+ let { size: size } = selected_filters_in_group_();
3012
+ try_specific: {
3013
+ if (size > 1) break try_specific;
3014
+ for (const [selected_filter, filter_data] of selected_filters_in_group_()){
3015
+ // we're intentionally not looping in this statement since we always just want to show the first thing in the filter group
3016
+ const { meta: meta } = filter_data;
3017
+ const { type: type } = meta;
3018
+ if (type === "range") return [
3019
+ (0, $g9l4l$memo)(()=>price_formatting_().pre_),
3020
+ (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
3021
+ get price_ () {
3022
+ return selected_filter.data[0];
3023
+ },
3024
+ get price_formatting_ () {
3025
+ return price_formatting_();
3026
+ }
3027
+ }),
3028
+ (0, $g9l4l$memo)(()=>price_formatting_().post_),
3029
+ " – ",
3030
+ (0, $g9l4l$memo)(()=>price_formatting_().pre_),
3031
+ (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
3032
+ get price_ () {
3033
+ return selected_filter.data[1];
3034
+ },
3035
+ get price_formatting_ () {
3036
+ return price_formatting_();
2882
3037
  }
3038
+ }),
3039
+ (0, $g9l4l$memo)(()=>price_formatting_().post_)
3040
+ ];
3041
+ else {
3042
+ const { data: data } = selected_filter;
3043
+ const data_is_array = Array.isArray(data);
3044
+ if (data_is_array && data.length !== 1) {
3045
+ size = data.length;
3046
+ break try_specific;
2883
3047
  }
3048
+ const needle = data_is_array ? data[0] : data;
3049
+ const index_in_meta = meta.values.findIndex((value)=>needle === value || Array.isArray(needle) && Array.isArray(value) && needle.length === value.length && value.every((item, index)=>needle[index] === item));
3050
+ return meta.names?.[index_in_meta] || meta.values?.[index_in_meta];
2884
3051
  }
2885
- set_show_tick_icon(true);
2886
- return size + "";
2887
- })));
3052
+ }
3053
+ }
3054
+ set_show_tick_icon(true);
3055
+ return size + "";
3056
+ }));
3057
+ return (()=>{
3058
+ const _el$ = $7c4a8499f0ad6e11$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
3059
+ (0, $g9l4l$insert)(_el$2, text);
2888
3060
  (0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
2889
3061
  get when () {
2890
3062
  return show_tick_icon();
@@ -2950,6 +3122,7 @@ function $a2432c33d88ec427$export$ab34afce88557c0e(props) {
2950
3122
 
2951
3123
 
2952
3124
 
3125
+
2953
3126
  const $8aff437d739a524d$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-collapsible"></div>`, 2), $8aff437d739a524d$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="clear-group"><span></span></button>`, 4), $8aff437d739a524d$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="view-more-clear"></div>`, 2), $8aff437d739a524d$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-collapsible-body"><div class="filter-part"></div></div>`, 4), $8aff437d739a524d$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<details class="filter-collapsible"></details>`, 2), $8aff437d739a524d$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<summary class="filter-group-summary"><div class="summary"><span></span><div class="selected-w-sign"></div></div></summary>`, 8), $8aff437d739a524d$var$_tmpl$7 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="ungrouped"></div>`, 2), $8aff437d739a524d$var$_tmpl$8 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="clear-all-filters major"></button>`, 2);
2954
3127
  function $8aff437d739a524d$export$3f1a388cc0d8fed7(props) {
2955
3128
  // Split like this to make placeholder wrapping more visible & this component is exported and used in MobileModal
@@ -3061,13 +3234,22 @@ function $8aff437d739a524d$var$ActualFilterBody(props) {
3061
3234
  return "Filter group " + JSON.stringify(section_) + " failed";
3062
3235
  },
3063
3236
  get children () {
3064
- return (0, $g9l4l$createMemo)(()=>(0, $g9l4l$createMemo)(()=>(0, $7b224b353182ce9a$export$2e2bcd8739ae039)[filter()?.meta?.type])()?.({
3065
- filter_: filter,
3066
- expanded_hierarchical_filters_: props.expanded_hierarchical_filters_,
3067
- selected_filters_: props.selected_filters_,
3068
- i18n_: props.i18n_,
3069
- view_more_button_below_group_: view_more_button_below_group
3070
- }));
3237
+ return (0, $g9l4l$createComponent)((0, $g9l4l$Dynamic), {
3238
+ get component () {
3239
+ return (0, $7b224b353182ce9a$export$2e2bcd8739ae039)[filter()?.meta?.type];
3240
+ },
3241
+ filter_: filter,
3242
+ get expanded_hierarchical_filters_ () {
3243
+ return props.expanded_hierarchical_filters_;
3244
+ },
3245
+ get selected_filters_ () {
3246
+ return props.selected_filters_;
3247
+ },
3248
+ get i18n_ () {
3249
+ return props.i18n_;
3250
+ },
3251
+ view_more_button_below_group_: view_more_button_below_group
3252
+ });
3071
3253
  }
3072
3254
  })
3073
3255
  }));
@@ -3123,19 +3305,27 @@ function $8aff437d739a524d$var$ActualFilterBody(props) {
3123
3305
  get each () {
3124
3306
  return untogglable_filters();
3125
3307
  },
3126
- children: (filter)=>// create memo to diff the function with next function
3127
- {
3308
+ children: (filter)=>{
3128
3309
  const view_more_button_below_group = (0, $g9l4l$createSignal)();
3129
- const filter_element_memo = (0, $g9l4l$createMemo)(()=>(0, $g9l4l$createMemo)(()=>(0, $7b224b353182ce9a$export$2e2bcd8739ae039)[filter()?.meta?.type])()?.({
3310
+ const [get_view_more_button_below_group] = view_more_button_below_group;
3311
+ return [
3312
+ (0, $g9l4l$createComponent)((0, $g9l4l$Dynamic), {
3313
+ get component () {
3314
+ return (0, $7b224b353182ce9a$export$2e2bcd8739ae039)[filter()?.meta?.type];
3315
+ },
3130
3316
  filter_: filter,
3131
- expanded_hierarchical_filters_: props.expanded_hierarchical_filters_,
3132
- selected_filters_: props.selected_filters_,
3133
- i18n_: props.i18n_,
3317
+ get expanded_hierarchical_filters_ () {
3318
+ return props.expanded_hierarchical_filters_;
3319
+ },
3320
+ get selected_filters_ () {
3321
+ return props.selected_filters_;
3322
+ },
3323
+ get i18n_ () {
3324
+ return props.i18n_;
3325
+ },
3134
3326
  view_more_button_below_group_: view_more_button_below_group
3135
- }));
3136
- return [
3137
- filter_element_memo,
3138
- view_more_button_below_group[0]
3327
+ }),
3328
+ (0, $g9l4l$memo)(get_view_more_button_below_group)
3139
3329
  ];
3140
3330
  }
3141
3331
  }));
@@ -3743,6 +3933,7 @@ function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: availab
3743
3933
 
3744
3934
  const $bf7fe049e78f975a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filters"><div class="body"></div></div>`, 4), $bf7fe049e78f975a$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting"><div class="body"></div></div>`, 4), $bf7fe049e78f975a$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sort-and-filter-buttons"><div class="outer"><div class="inner"></div></div></div>`, 6), $bf7fe049e78f975a$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="num-filters"></span>`, 2), $bf7fe049e78f975a$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="open-filters-button-container"><button class="filter toggle-button major-minor-transition" type="button"><span></span></button></div>`, 6), $bf7fe049e78f975a$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="toggle-button for-sorting major-minor-transition"><span></span></button>`, 4);
3745
3935
  function $bf7fe049e78f975a$export$d7841e452f2e59a8({ current_sorting_: current_sorting_ , set_extra_els_in_results_container_: set_extra_els_in_results_container_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , set_sort_or_filter_open_: set_sort_or_filter_open_ , i18n_: i18n_ , available_sortings_: available_sortings_ , available_filters_: available_filters_ , expanded_filters_: expanded_filters_ , middle_elements_: middle_elements_ , input_modal_open_: input_modal_open_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_ , set_sort_and_filter_element_: set_sort_and_filter_element_ , formatted_number_of_results_: formatted_number_of_results_ , filter_button_width_: filter_button_width_ , sort_button_width_: sort_button_width_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , get_extra_filters_button_: get_extra_filters_button_ , get_extra_sorting_button_: get_extra_sorting_button_ }) {
3936
+ // @ts-ignore
3746
3937
  return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
3747
3938
  severity_: "error",
3748
3939
  message_: "Sorting and filters failed",
@@ -4536,90 +4727,6 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
4536
4727
 
4537
4728
 
4538
4729
 
4539
-
4540
-
4541
- function $cb20e79516018342$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ , router_: router_ }) {
4542
- // If we just got opened in a new tab, clear filters instantly and remove the flag
4543
- $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
4544
- plp_results_: plp_results_,
4545
- local_filter_cache_: local_filter_cache_,
4546
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4547
- selected_filters_: selected_filters_,
4548
- i18n_: i18n_,
4549
- router_: router_
4550
- });
4551
- // Code below is for when we're already open and the user navigates to a new category
4552
- let previous_crumb_data = (0, $g9l4l$untrack)(crumb_data_);
4553
- let query_id_when_we_got_previous_data = (0, $g9l4l$untrack)(query_id_);
4554
- let allow_filter_clearing = true; // set to false when going backwards/forwards
4555
- // temporarily disable filter clearing when going backwards/forwards
4556
- const handler = ()=>allow_filter_clearing = false;
4557
- window.addEventListener("popstate", handler); // popstate only gets called when using back/forwards button of browser or the history navigate to achieve the same, but not on pushState or replaceState
4558
- (0, $g9l4l$onCleanup)(()=>window.removeEventListener("popstate", handler));
4559
- (0, $g9l4l$createEffect)((0, $g9l4l$on)(crumb_data_, (0, $g9l4l$catchify)((new_crumb_data)=>{
4560
- const query_id_of_new_data = query_id_();
4561
- if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
4562
- const previous_length = previous_crumb_data.length;
4563
- const new_length = new_crumb_data.length;
4564
- const went_upwards = new_length < previous_length;
4565
- const went_downwards = previous_length < new_length;
4566
- const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
4567
- const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
4568
- if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
4569
- // We went sideways, not up or down. Clear filters.
4570
- (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4571
- user_triggered_: false,
4572
- i18n_: i18n_,
4573
- also_clear_sorting_: false,
4574
- selected_filters_: selected_filters_,
4575
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4576
- local_filter_cache_: local_filter_cache_
4577
- });
4578
- // Also ensure we don't have `sideways_url_params_flag` set anymore
4579
- $cb20e79516018342$var$delete_sideways_param_flag(router_);
4580
- }
4581
- }
4582
- query_id_when_we_got_previous_data = query_id_of_new_data;
4583
- previous_crumb_data = new_crumb_data;
4584
- if (!allow_filter_clearing) allow_filter_clearing = true;
4585
- })));
4586
- }
4587
- function $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , router_: router_ }) {
4588
- const tracking_function_for_plp_results = (0, $g9l4l$createReaction)(()=>{
4589
- // On first rendering of the CategoryPage (after we have results), check if we got to this URL by going sideways in QuickLinks and clear filters with toast if so
4590
- const had_flag = $cb20e79516018342$var$delete_sideways_param_flag(router_);
4591
- if (!had_flag) return;
4592
- (0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
4593
- (0, $g9l4l$queueMacroTask)(()=>{
4594
- // Do it next task so that all the filters have time to populate
4595
- (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4596
- user_triggered_: false,
4597
- i18n_: i18n_,
4598
- also_clear_sorting_: false,
4599
- selected_filters_: selected_filters_,
4600
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4601
- local_filter_cache_: local_filter_cache_
4602
- });
4603
- });
4604
- });
4605
- tracking_function_for_plp_results(plp_results_);
4606
- }
4607
- function $cb20e79516018342$var$delete_sideways_param_flag(router) {
4608
- const url_object = new URL(location.href);
4609
- const { searchParams: searchParams } = url_object;
4610
- if (searchParams.get((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac)) !== "true") return false;
4611
- searchParams.delete((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac));
4612
- router.navigate_.go_to_({
4613
- new_url_: url_object,
4614
- is_replace_: true,
4615
- force_spa_navigation_: true
4616
- });
4617
- return true;
4618
- }
4619
-
4620
-
4621
-
4622
-
4623
4730
  const $f4d7f67154f032af$var$max_history_change_frequency = 300;
4624
4731
  const $f4d7f67154f032af$var$api_max_products_per_request = 100;
4625
4732
  function $f4d7f67154f032af$export$6e49da55e449af7c({ scroll_restoration_data_: [, set_scroll_restoration_data] , last_result_in_viewport_: [get_last_result_in_viewport_] , id_: id_ , can_write_scroll_restoration_: can_write_scroll_restoration_ }) {
@@ -4732,8 +4839,92 @@ let $01115659405f3c64$export$44dad306455dddf;
4732
4839
  })($01115659405f3c64$export$44dad306455dddf || ($01115659405f3c64$export$44dad306455dddf = {}));
4733
4840
 
4734
4841
 
4842
+
4843
+
4844
+
4845
+
4846
+ function $cb20e79516018342$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ , router_: router_ }) {
4847
+ // If we just got opened in a new tab, clear filters instantly and remove the flag
4848
+ $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
4849
+ plp_results_: plp_results_,
4850
+ local_filter_cache_: local_filter_cache_,
4851
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4852
+ selected_filters_: selected_filters_,
4853
+ i18n_: i18n_,
4854
+ router_: router_
4855
+ });
4856
+ // Code below is for when we're already open and the user navigates to a new category
4857
+ let previous_crumb_data = (0, $g9l4l$untrack)(crumb_data_);
4858
+ let query_id_when_we_got_previous_data = (0, $g9l4l$untrack)(query_id_);
4859
+ let allow_filter_clearing = true; // set to false when going backwards/forwards
4860
+ // temporarily disable filter clearing when going backwards/forwards
4861
+ const handler = ()=>allow_filter_clearing = false;
4862
+ window.addEventListener("popstate", handler); // popstate only gets called when using back/forwards button of browser or the history navigate to achieve the same, but not on pushState or replaceState
4863
+ (0, $g9l4l$onCleanup)(()=>window.removeEventListener("popstate", handler));
4864
+ (0, $g9l4l$createEffect)((0, $g9l4l$on)(crumb_data_, (0, $g9l4l$catchify)((new_crumb_data)=>{
4865
+ const query_id_of_new_data = query_id_();
4866
+ if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
4867
+ const previous_length = previous_crumb_data.length;
4868
+ const new_length = new_crumb_data.length;
4869
+ const went_upwards = new_length < previous_length;
4870
+ const went_downwards = previous_length < new_length;
4871
+ const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
4872
+ const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
4873
+ if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
4874
+ // We went sideways, not up or down. Clear filters.
4875
+ (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4876
+ user_triggered_: false,
4877
+ i18n_: i18n_,
4878
+ also_clear_sorting_: false,
4879
+ selected_filters_: selected_filters_,
4880
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4881
+ local_filter_cache_: local_filter_cache_
4882
+ });
4883
+ // Also ensure we don't have `sideways_url_params_flag` set anymore
4884
+ $cb20e79516018342$var$delete_sideways_param_flag(router_);
4885
+ }
4886
+ }
4887
+ query_id_when_we_got_previous_data = query_id_of_new_data;
4888
+ previous_crumb_data = new_crumb_data;
4889
+ if (!allow_filter_clearing) allow_filter_clearing = true;
4890
+ })));
4891
+ }
4892
+ function $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , router_: router_ }) {
4893
+ const tracking_function_for_plp_results = (0, $g9l4l$createReaction)(()=>{
4894
+ // On first rendering of the CategoryPage (after we have results), check if we got to this URL by going sideways in QuickLinks and clear filters with toast if so
4895
+ const had_flag = $cb20e79516018342$var$delete_sideways_param_flag(router_);
4896
+ if (!had_flag) return;
4897
+ (0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
4898
+ (0, $g9l4l$queueMacroTask)(()=>{
4899
+ // Do it next task so that all the filters have time to populate
4900
+ (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4901
+ user_triggered_: false,
4902
+ i18n_: i18n_,
4903
+ also_clear_sorting_: false,
4904
+ selected_filters_: selected_filters_,
4905
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4906
+ local_filter_cache_: local_filter_cache_
4907
+ });
4908
+ });
4909
+ });
4910
+ tracking_function_for_plp_results(plp_results_);
4911
+ }
4912
+ function $cb20e79516018342$var$delete_sideways_param_flag(router) {
4913
+ const url_object = new URL(location.href);
4914
+ const { searchParams: searchParams } = url_object;
4915
+ if (searchParams.get((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac)) !== "true") return false;
4916
+ searchParams.delete((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac));
4917
+ router.navigate_.go_to_({
4918
+ new_url_: url_object,
4919
+ is_replace_: true,
4920
+ force_spa_navigation_: true
4921
+ });
4922
+ return true;
4923
+ }
4924
+
4925
+
4735
4926
  const $1ae892b13d7746ab$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="product-count"> </div>`, 2), $1ae892b13d7746ab$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div></div>`, 2), $1ae892b13d7746ab$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-results-for-one-row"></div>`, 2), $1ae892b13d7746ab$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
4736
- function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , rr_options_: rr_options_ , get_product_id_: get_product_id_ }) {
4927
+ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ }) {
4737
4928
  let results_for;
4738
4929
  let only_show_filters_opener_;
4739
4930
  let middle_elements_;
@@ -4743,12 +4934,6 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4743
4934
  show_n_results_: incoming_i18n.show_n_products_,
4744
4935
  no_results_text_: incoming_i18n.no_products_text_
4745
4936
  };
4746
- const tenant_object_ = new (0, $g9l4l$Tenant)({
4747
- TENANT: (0, $g9l4l$untrack)(tenant_),
4748
- MARKET: (0, $g9l4l$untrack)(market_),
4749
- GA_ID: "",
4750
- get_product_id: get_product_id_
4751
- });
4752
4937
  const [get_sorting] = current_sorting_;
4753
4938
  const number_of_rendered_selected_filters_items_ = (0, $g9l4l$createSignal)(0);
4754
4939
  const first_result_in_viewport_ = (0, $g9l4l$createSignal)();
@@ -4985,11 +5170,9 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4985
5170
  last_result_in_viewport_: last_result_in_viewport_,
4986
5171
  scroll_restoration_data_: scroll_restoration_data_,
4987
5172
  layout_options_: layout_options_,
4988
- rr_options_: rr_options_,
5173
+ product_card_template_: product_card_template_,
4989
5174
  sort_or_filter_open_: sort_or_filter_open_,
4990
5175
  desktop_filter_elements_: desktop_filter_elements_,
4991
- tenant_object_: tenant_object_,
4992
- type_for_tracking_: "category",
4993
5176
  id_currently_querying_for_: query_id_,
4994
5177
  no_results_options_: {
4995
5178
  selected_filters_: selected_filters_,
@@ -5140,6 +5323,7 @@ function $0466953901b38f18$export$f091cbac892643a4(obj) {
5140
5323
 
5141
5324
  function $c7f938ac40924f3b$export$23fca46f3143581f(component, error_message) {
5142
5325
  const component_in_error_boundary = (do_with_elements)=>{
5326
+ // @ts-ignore
5143
5327
  return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
5144
5328
  severity_: "error",
5145
5329
  message_: error_message,
@@ -5166,13 +5350,16 @@ function $c7f938ac40924f3b$export$23fca46f3143581f(component, error_message) {
5166
5350
 
5167
5351
 
5168
5352
 
5169
- function $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7(router) {
5353
+ function $f01b3a0b9fbf6519$export$477caf01aecaeb2a({ search_query_url_param_name_: search_query_url_param_name_ , router_: router_ }) {
5354
+ const search_query_ = search_query_url_param_name_ ? (0, $g9l4l$createSignal)("") : undefined;
5355
+ const get_search_query_ = search_query_?.[0];
5356
+ const set_search_query = search_query_?.[1];
5170
5357
  const current_sorting_ = (0, $g9l4l$createSignal)();
5171
5358
  const selected_filters_ = (0, $g9l4l$createSignal)([]);
5172
- const [get_sorting, set_sorting] = current_sorting_;
5173
- const [get_selected_filters, set_selected_filters] = selected_filters_;
5359
+ const [get_sorting_, set_sorting] = current_sorting_;
5360
+ const [get_selected_filters_, set_selected_filters] = selected_filters_;
5174
5361
  const [get_current_href, set_current_href] = (0, $g9l4l$createSignal)(location.href);
5175
- const history_change_handler = ()=>set_current_href(location.href);
5362
+ const history_change_handler = (0, $g9l4l$catchify)(()=>set_current_href(location.href));
5176
5363
  const owner = (0, $g9l4l$getOwner)() || (0, $g9l4l$createRoot)(()=>(0, $g9l4l$getOwner)());
5177
5364
  let writer_started = false;
5178
5365
  (0, $g9l4l$instant_exec_on_suspect_history_change).add(history_change_handler);
@@ -5182,12 +5369,12 @@ function $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7(router) {
5182
5369
  (0, $g9l4l$batch)(()=>{
5183
5370
  const found_sorting = (0, $73294c7089bfc7c9$export$766e9676e74997d3)(searchParams);
5184
5371
  if (found_sorting) {
5185
- const current_sorting = (0, $g9l4l$untrack)(get_sorting);
5372
+ const current_sorting = (0, $g9l4l$untrack)(get_sorting_);
5186
5373
  // Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
5187
5374
  if (current_sorting?.field !== found_sorting.field || current_sorting?.order !== found_sorting.order) set_sorting(found_sorting);
5188
5375
  } else set_sorting();
5189
5376
  const found_filters = (0, $73294c7089bfc7c9$export$f934fa24c3a86811)(searchParams);
5190
- const selected_filters = (0, $g9l4l$untrack)(get_selected_filters);
5377
+ const selected_filters = (0, $g9l4l$untrack)(get_selected_filters_);
5191
5378
  const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
5192
5379
  JSON.stringify([
5193
5380
  field,
@@ -5200,25 +5387,36 @@ function $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7(router) {
5200
5387
  field,
5201
5388
  op
5202
5389
  ]))) === JSON.stringify(data))) set_selected_filters(found_filters);
5390
+ if (search_query_url_param_name_) {
5391
+ const found_query = searchParams.get(search_query_url_param_name_);
5392
+ set_search_query(found_query || "");
5393
+ }
5203
5394
  if (!writer_started) {
5204
5395
  // The owner here is the createComputed which gets disposed the next time the computation runs - but we actually just want to delay the start of the href_writer until our signals contain the current value of the URL, therefore the runWithOwner
5205
- (0, $g9l4l$runWithOwner)(owner, ()=>$b4291f5d2e6b2fae$var$start_href_writer(get_sorting, get_selected_filters, router));
5396
+ (0, $g9l4l$runWithOwner)(owner, ()=>$f01b3a0b9fbf6519$var$start_href_writer({
5397
+ get_sorting_: get_sorting_,
5398
+ get_selected_filters_: get_selected_filters_,
5399
+ router_: router_
5400
+ }));
5206
5401
  writer_started = true;
5207
5402
  }
5208
5403
  });
5209
5404
  });
5405
+ // @ts-ignore
5210
5406
  return {
5211
5407
  current_sorting_: current_sorting_,
5212
- selected_filters_: selected_filters_
5408
+ selected_filters_: selected_filters_,
5409
+ ...typeof search_query_url_param_name_ === "string" ? {
5410
+ search_query_accessor_: get_search_query_
5411
+ } : {}
5213
5412
  };
5214
5413
  }
5215
5414
  /**
5216
5415
  * Writes the sorting and filters to the URL query parameters when they change.
5217
- */ function $b4291f5d2e6b2fae$var$start_href_writer(get_sorting, get_selected_filters, router) {
5218
- // This has to be a createComputed because there can be some kind of URL query bouncing back and forwards otherwise (observed when clearing filters by making a new search)
5219
- (0, $g9l4l$createComputed)((0, $g9l4l$on)([
5220
- get_sorting,
5221
- get_selected_filters
5416
+ */ function $f01b3a0b9fbf6519$var$start_href_writer({ get_sorting_: get_sorting_ , get_selected_filters_: get_selected_filters_ , router_: router_ }) {
5417
+ (0, $g9l4l$createEffect)((0, $g9l4l$on)([
5418
+ get_sorting_,
5419
+ get_selected_filters_
5222
5420
  ], ([sorting, filters])=>{
5223
5421
  const current_href = location.href;
5224
5422
  const url_object = new URL(current_href);
@@ -5236,7 +5434,7 @@ function $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7(router) {
5236
5434
  // Having the array middle step because if we'd check the "size" property of the map the algorithm could be fooled if there were two query parameters with the same key
5237
5435
  const new_search_params_map = new Map(new_search_params);
5238
5436
  if (unmodified_search_params.length !== new_search_params.length || !unmodified_search_params.every(([key, value])=>new_search_params_map.get(key) === value)) // Only update URL if it actually changed
5239
- router.navigate_.go_to_({
5437
+ router_.navigate_.go_to_({
5240
5438
  is_replace_: true,
5241
5439
  new_url_: url_object.href,
5242
5440
  force_spa_navigation_: true
@@ -5296,10 +5494,14 @@ class $cfa2761d36e5714c$export$7e1297a3a19f10d8 {
5296
5494
  * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
5297
5495
  * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5298
5496
  * @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
5299
- */ go_to_: async ({ new_url_: new_url_ , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5497
+ */ go_to_: (0, $g9l4l$catchify)(async ({ new_url_: raw_new_url , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5498
+ const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
5300
5499
  const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5301
5500
  if (this.#dont_attempt_navigation(event_)) return;
5302
- if (wants_hard_navigation && !force_spa_navigation_) {
5501
+ const different_origin = new_url_.origin !== location.origin;
5502
+ if (wants_hard_navigation && (!force_spa_navigation_ || different_origin)) {
5503
+ if (force_spa_navigation_ && different_origin) // If we call history.pushState on a different origin, it will throw an error, so fallback to hard navigations
5504
+ (0, $g9l4l$dwarn)("Can't single page navigate to", new_url_.href, "due to different origin, this MIGHT mean you should fix the URLs");
5303
5505
  if (!event_) // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
5304
5506
  location.assign(new_url_);
5305
5507
  return;
@@ -5317,7 +5519,7 @@ class $cfa2761d36e5714c$export$7e1297a3a19f10d8 {
5317
5519
  new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin)
5318
5520
  });
5319
5521
  await promise;
5320
- }
5522
+ })
5321
5523
  };
5322
5524
  constructor(on_navigation){
5323
5525
  this.on_navigation_ = on_navigation;
@@ -5379,7 +5581,9 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5379
5581
  Object.assign(this, props_on_class); // set initial signal values
5380
5582
  (0, $2864fd26f57ff474$export$5162a71f252e6122)();
5381
5583
  if (on_navigation) this.#router.on_navigation_ = on_navigation;
5382
- const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7)(this.#router);
5584
+ const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $f01b3a0b9fbf6519$export$477caf01aecaeb2a)({
5585
+ router_: this.#router
5586
+ });
5383
5587
  const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
5384
5588
  category_filters_open: false,
5385
5589
  category_sorting_open: false,
@@ -5388,7 +5592,7 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5388
5592
  category_local_filter_cache: [],
5389
5593
  category_expanded_hierarchical_filters: [],
5390
5594
  category_scroll_restoration_data: []
5391
- }));
5595
+ }), this.#router);
5392
5596
  const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
5393
5597
  $ec52ef1e6c117813$var$privately_shared_properties.set(this, {
5394
5598
  state_: state_,
@@ -5407,7 +5611,7 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5407
5611
  });
5408
5612
  }
5409
5613
  }
5410
- function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title }) {
5614
+ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title }) {
5411
5615
  const shared_properties = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
5412
5616
  const grid_spacing_override = typeof grid_spacing === "string" ? {
5413
5617
  grid_spacing: grid_spacing
@@ -5440,17 +5644,11 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
5440
5644
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
5441
5645
  selected_filters_: selected_filters_,
5442
5646
  scroll_restoration_data_: scroll_restoration_data_,
5443
- get_product_id_: get_product_id,
5444
5647
  layout_options_: {
5445
5648
  cols_at_size: (0, $b4e6a093ae83373b$export$6daf8749b65a1b77)(cols_at_size),
5446
5649
  ...grid_spacing_override
5447
5650
  },
5448
- rr_options_: {
5449
- template: (display, info)=>{
5450
- const is_placeholder = info.rendering_options.type === "placeholder";
5451
- return product_card_template(is_placeholder ? null : display, info);
5452
- }
5453
- }
5651
+ product_card_template_: product_card_template
5454
5652
  });
5455
5653
  }, "Entire CategoryPage failed");
5456
5654
  }
@@ -5856,22 +6054,48 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
5856
6054
 
5857
6055
 
5858
6056
 
6057
+
6058
+
5859
6059
  const $aee0c68312d971f4$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="cards"></div>`, 2), $aee0c68312d971f4$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="search-recs"><h3 class="search-recs-title"></h3></div>`, 4), $aee0c68312d971f4$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="show-more major" type="button"></button>`, 2);
5860
6060
  const $aee0c68312d971f4$export$1c8c715550dc689d = 2;
5861
- function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , tenant_object_: tenant_object_ , search_query_base_: search_query_base_ , rr_options_: rr_options_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_ }) {
5862
- const [is_showing_something, set_is_showing_something] = (0, $g9l4l$createSignal)(false);
5863
- const cards = $aee0c68312d971f4$var$_tmpl$.cloneNode(true);
5864
- const on_next_render = [];
5865
- const main_element = (()=>{
6061
+ function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , search_query_base_: search_query_base_ , product_card_template_: product_card_template_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_ }) {
6062
+ const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
6063
+ const rows_object = view_more_button_ ? $aee0c68312d971f4$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
6064
+ const [recommendations_resource] = (0, $g9l4l$createResource)(search_query_base_, (query)=>depict_api_.get_recommended(query).then((r)=>r.displays));
6065
+ const is_showing_something = (0, $g9l4l$createMemo)(()=>recommendations_resource.loading || recommendations_resource()?.length);
6066
+ const num_placeholders_ = (0, $g9l4l$createMemo)(()=>(0, $9679915780ee67c0$export$6c9030e511152266) + get_showing_recommendation_rows() * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column)));
6067
+ const cards = (()=>{
6068
+ const _el$ = $aee0c68312d971f4$var$_tmpl$.cloneNode(true);
6069
+ (0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Suspense), {
6070
+ get fallback () {
6071
+ return (0, $dc5df79ae78a9d00$export$f33414a4df0afd3f)({
6072
+ num_placeholders_: num_placeholders_,
6073
+ product_card_template_: product_card_template_
6074
+ });
6075
+ },
6076
+ get children () {
6077
+ return (()=>{
6078
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
6079
+ const displays_by_key_ = (0, $7a5055d6c11943a0$export$7f8bd308237ab5a5)((0, $g9l4l$createMemo)(()=>recommendations_resource() || []));
6080
+ return (0, $7a5055d6c11943a0$export$43f0fb951fcb0c54)({
6081
+ displays_by_key_: displays_by_key_,
6082
+ merchant_: (0, $g9l4l$createMemo)(()=>search_query_base_().tenant),
6083
+ market_: (0, $g9l4l$createMemo)(()=>search_query_base_().market),
6084
+ product_card_template_: product_card_template_
6085
+ });
6086
+ })();
6087
+ }
6088
+ }));
6089
+ return _el$;
6090
+ })();
6091
+ const search_recs_elements = (()=>{
5866
6092
  const _el$2 = $aee0c68312d971f4$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
5867
6093
  (0, $g9l4l$insert)(_el$3, ()=>i18n_.search_recs_title_());
5868
6094
  (0, $g9l4l$insert)(_el$2, (0, $ed06bb0bb83a46b3$export$a2cc176055f8f08), null);
5869
6095
  (0, $g9l4l$insert)(_el$2, cards, null);
5870
6096
  return _el$2;
5871
6097
  })();
5872
- const [get_showing_recommendation_rows] = showing_recommendation_rows_;
5873
- const rows_object = view_more_button_ ? $aee0c68312d971f4$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
5874
- const cleanup_old_cards = [];
6098
+ // the cards element must have a parent for Layout to work, therefore we're inserting it into a div above
5875
6099
  (0, $g9l4l$Layout)({
5876
6100
  container_element: cards,
5877
6101
  layout: "grid",
@@ -5881,77 +6105,11 @@ function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
5881
6105
  e,
5882
6106
  "Layout failed"
5883
6107
  ], "error"));
5884
- // copied from RecommendationGrid
5885
- // convoluted lazy loading that
5886
- // when the elements are in the DOM starts IntersectionObserver on whole grid
5887
- // when grid intersects starts Lazyfier
5888
- // this is because Lazyfier is fucking stupid
5889
- (0, $g9l4l$observer).wait_for_element(cards).then((0, $g9l4l$catchify)((element)=>{
5890
- let start_lazy_loading;
5891
- const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
5892
- const lf = new (0, $g9l4l$Lazyfier)({
5893
- only_load_intersecting: true,
5894
- wait_for_dominsertion: lazy_loading_promise,
5895
- ignore_data_urls: true,
5896
- lazyfinder: {
5897
- unload () {}
5898
- }
5899
- });
5900
- lf.start_observing_for_new_children_(element);
5901
- const i_o = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
5902
- for (const record of records)if (record.intersectionRatio > 0) {
5903
- start_lazy_loading();
5904
- i_o.disconnect();
5905
- return;
5906
- }
5907
- }));
5908
- i_o.observe(cards);
5909
- }));
5910
- const deparallelized_recs_fetcher = (0, $g9l4l$deparallelize_no_drop)((0, $g9l4l$catchify)(async (base_query)=>{
5911
- const recs_promise = depict_api_.get_recommended(base_query).then((r)=>r.displays);
5912
- // create owner to run product cards with an Owner, so they know when they've gotten removed
5913
- const [owner_for_cards, dispose_our_cards] = (0, $g9l4l$createRoot)((dispose)=>[
5914
- (0, $g9l4l$getOwner)(),
5915
- dispose
5916
- ]);
5917
- const rendering_result = await (await (0, $g9l4l$make_placeholder_rr)({
5918
- // render the max amount of elements that there could be, to make sure scroll restoration works (placeholders can't be shorter than actual content)
5919
- num_items: (0, $9679915780ee67c0$export$6c9030e511152266) + (0, $g9l4l$untrack)(get_showing_recommendation_rows) * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column))
5920
- }))(tenant_object_, // @ts-ignore - make_placeholder_rr types is a touchy subject
5921
- {
5922
- type: "search_recs",
5923
- recs: recs_promise,
5924
- ...rr_options_,
5925
- ...typeof rr_options_.template === "function" ? {
5926
- template: (...args)=>(0, $g9l4l$runWithOwner)(owner_for_cards, ()=>// give template the possibility to know when it gets removed from the DOM by using solid-js onCleanup
5927
- // @ts-ignore
5928
- rr_options_.template(...args))
5929
- } : {}
5930
- });
5931
- const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
5932
- let dead = false;
5933
- while(on_next_render.length)on_next_render.pop()();
5934
- on_next_render.push(()=>dead = true);
5935
- if (!elements) {
5936
- set_is_showing_something(false);
5937
- return;
5938
- }
5939
- cards.replaceChildren(...elements);
5940
- // Dispose the old cards just after the cards have been removed from the DOM
5941
- cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
5942
- cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
5943
- set_is_showing_something(true);
5944
- should_stay_inserted?.then((should)=>{
5945
- if (!should && !dead /* just in case */ ) set_is_showing_something(false);
5946
- });
5947
- }));
5948
- (0, $g9l4l$createRenderEffect)(()=>deparallelized_recs_fetcher(search_query_base_()));
5949
- (0, $g9l4l$onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
5950
6108
  return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
5951
6109
  get when () {
5952
6110
  return is_showing_something();
5953
6111
  },
5954
- children: main_element
6112
+ children: search_recs_elements
5955
6113
  });
5956
6114
  }
5957
6115
  function $aee0c68312d971f4$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
@@ -6033,7 +6191,7 @@ function $079defea521d5e2a$export$b3ad617e9036868(modal_body_style, input_field,
6033
6191
 
6034
6192
 
6035
6193
 
6036
- function $a0d89ff25220eb8d$export$e026af0c7b64ea5f({ selected_filters_: selected_filters_ , search_query_: [get_search_query] , current_sorting_: current_sorting_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , local_filter_cache_: local_filter_cache_ }) {
6194
+ function $a0d89ff25220eb8d$export$e026af0c7b64ea5f({ selected_filters_: selected_filters_ , get_search_query_: get_search_query_ , current_sorting_: current_sorting_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , local_filter_cache_: local_filter_cache_ }) {
6037
6195
  const [get_selected_filters] = selected_filters_;
6038
6196
  // Possible values:
6039
6197
  // 0 - we should not clear next submit
@@ -6048,7 +6206,7 @@ function $a0d89ff25220eb8d$export$e026af0c7b64ea5f({ selected_filters_: selected
6048
6206
  }, {
6049
6207
  defer: true
6050
6208
  }));
6051
- (0, $g9l4l$createComputed)((0, $g9l4l$on)(get_search_query, (0, $g9l4l$catchify)(()=>{
6209
+ (0, $g9l4l$createComputed)((0, $g9l4l$on)(get_search_query_, (0, $g9l4l$catchify)(()=>{
6052
6210
  // when a query was submitted, clear filters if clear was pressed before
6053
6211
  const clear_value = (0, $g9l4l$untrack)(get_clear_filters_next_submit);
6054
6212
  if (clear_value) {
@@ -6073,12 +6231,11 @@ function $a0d89ff25220eb8d$export$e026af0c7b64ea5f({ selected_filters_: selected
6073
6231
 
6074
6232
 
6075
6233
 
6076
- function $4d62f5daa51642fe$export$84bba84a7b837187(search_query) {
6234
+ function $4d62f5daa51642fe$export$84bba84a7b837187(read_search_query) {
6077
6235
  const ls = localStorage;
6078
6236
  const key = "depict_searches";
6079
6237
  const previous_searches = (0, $g9l4l$createSignal)(JSON.parse(ls[key] || "[]"));
6080
6238
  const [read_previous_searches, write_previous_searches] = previous_searches;
6081
- const [read_search_query] = search_query;
6082
6239
  (0, $g9l4l$createEffect)((0, $g9l4l$catchify)(()=>{
6083
6240
  const json_encoded = JSON.stringify(read_previous_searches());
6084
6241
  if (ls[key] !== json_encoded) ls[key] = json_encoded;
@@ -6099,9 +6256,9 @@ function $4d62f5daa51642fe$export$84bba84a7b837187(search_query) {
6099
6256
 
6100
6257
 
6101
6258
 
6102
- async function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , set_search_field_value_: set_search_field_value_ , search_query_: [read_search_query] , url_transformer_: url_transformer_ , router_: router_ , after_submit_: after_submit_ , get_new_query: get_new_query }) {
6259
+ async function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , set_search_field_value_: set_search_field_value_ , get_search_query_: get_search_query_ , url_transformer_: url_transformer_ , router_: router_ , after_submit_: after_submit_ , get_new_query: get_new_query }) {
6103
6260
  const new_search_query = get_new_query();
6104
- const previous_query = (0, $g9l4l$untrack)(read_search_query);
6261
+ const previous_query = (0, $g9l4l$untrack)(get_search_query_);
6105
6262
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
6106
6263
  // don't push a history entry / re-search if someone submits a search again
6107
6264
  // do close the modal though
@@ -6125,32 +6282,6 @@ async function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchan
6125
6282
 
6126
6283
 
6127
6284
 
6128
- function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
6129
- // TODO: remove this abstraction, put it in same place as filters
6130
- // TODO: make it only return an accessor
6131
- const signals = {};
6132
- const entries = Object.entries(params_to_default_value);
6133
- for (const [param, default_value] of entries)signals[param] = (0, $g9l4l$createSignal)(default_value ?? "");
6134
- const [exit_iterable, exitable_iterable] = (0, $g9l4l$make_asyncIterable_exiter)((0, $g9l4l$href_change_ipns));
6135
- (0, $g9l4l$onCleanup)((0, $g9l4l$catchify)(exit_iterable));
6136
- (0, $g9l4l$catchify)(async ()=>{
6137
- for await (const href of exitable_iterable){
6138
- const { searchParams: searchParams } = new URL(href);
6139
- for (const [param, default_value] of entries){
6140
- const [_get, set] = signals[param];
6141
- if (searchParams.has(param)) {
6142
- const new_val = searchParams.get(param) ?? default_value ?? "";
6143
- set(new_val);
6144
- } else set(default_value ?? "");
6145
- }
6146
- }
6147
- })();
6148
- return signals;
6149
- }
6150
-
6151
-
6152
-
6153
-
6154
6285
 
6155
6286
 
6156
6287
 
@@ -6190,7 +6321,8 @@ function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
6190
6321
 
6191
6322
 
6192
6323
  const $d3c0043bb23a833f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="orig price"></span>`, 2), $d3c0043bb23a833f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $d3c0043bb23a833f$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="tagline"></div>`, 2);
6193
- const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market }, router_)=>{
6324
+ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n }, router_)=>{
6325
+ const search_result_id = (0, $g9l4l$createMemo)(()=>display_or_variant_container().search_result_id);
6194
6326
  const display = (0, $g9l4l$createMemo)(()=>{
6195
6327
  const display = display_or_variant_container();
6196
6328
  // Support for backend's new display format
@@ -6208,19 +6340,19 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
6208
6340
  });
6209
6341
  const image_url = (0, $g9l4l$createMemo)(()=>display().image_url);
6210
6342
  const contained_image = (0, $g9l4l$createMemo)(()=>(0, $g9l4l$ContainedImage)({
6343
+ loading: "lazy",
6211
6344
  aspect_ratio: 1,
6212
6345
  alt: "",
6213
6346
  rendering_options: {},
6214
- // @ts-ignore
6215
- "data-src": image_url(),
6347
+ "src": image_url(),
6216
6348
  srcset_opts: {
6217
- set_dataset: true
6349
+ set_dataset: false
6218
6350
  },
6219
- init_with_placeholder: true
6351
+ sizes: "0px"
6220
6352
  }));
6221
6353
  const is_sale = (0, $g9l4l$createMemo)(()=>display().sale_price !== display().original_price);
6222
6354
  const href = (0, $g9l4l$createMemo)(()=>display().page_url);
6223
- const returnVal = (()=>{
6355
+ return (()=>{
6224
6356
  const _el$ = $d3c0043bb23a833f$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
6225
6357
  (0, $g9l4l$addEventListener)(_el$, "click", (0, $g9l4l$catchify)((event_)=>router_.navigate_.go_to_({
6226
6358
  new_url_: href(),
@@ -6248,33 +6380,41 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
6248
6380
  get children () {
6249
6381
  const _el$8 = $d3c0043bb23a833f$var$_tmpl$.cloneNode(true);
6250
6382
  (0, $g9l4l$insert)(_el$8, ()=>i18n.price_formatting_().pre_, null);
6251
- (0, $g9l4l$insert)(_el$8, ()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
6252
- price_: (0, $g9l4l$createMemo)(()=>display().original_price),
6253
- price_formatting_: i18n.price_formatting_
6254
- }), null);
6383
+ (0, $g9l4l$insert)(_el$8, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
6384
+ get price_ () {
6385
+ return display().original_price;
6386
+ },
6387
+ get price_formatting_ () {
6388
+ return i18n.price_formatting_();
6389
+ }
6390
+ }), null);
6255
6391
  (0, $g9l4l$insert)(_el$8, ()=>i18n.price_formatting_().post_, null);
6256
6392
  return _el$8;
6257
6393
  }
6258
6394
  }), _el$9);
6259
6395
  (0, $g9l4l$insert)(_el$9, ()=>i18n.price_formatting_().pre_, null);
6260
- (0, $g9l4l$insert)(_el$9, ()=>(0, $5178263ed1e394ca$export$469c7af753d08925)({
6261
- price_: (0, $g9l4l$createMemo)(()=>display().sale_price),
6262
- price_formatting_: i18n.price_formatting_
6263
- }), null);
6396
+ (0, $g9l4l$insert)(_el$9, (0, $g9l4l$createComponent)((0, $5178263ed1e394ca$export$a71e92cfbb498adc), {
6397
+ get price_ () {
6398
+ return display().sale_price;
6399
+ },
6400
+ get price_formatting_ () {
6401
+ return i18n.price_formatting_();
6402
+ }
6403
+ }), null);
6264
6404
  (0, $g9l4l$insert)(_el$9, ()=>i18n.price_formatting_().post_, null);
6265
6405
  (0, $g9l4l$effect)((_p$)=>{
6266
- const _v$ = href(), _v$2 = !!is_sale();
6406
+ const _v$ = href(), _v$2 = search_result_id(), _v$3 = !!is_sale();
6267
6407
  _v$ !== _p$._v$ && (0, $g9l4l$setAttribute)(_el$, "href", _p$._v$ = _v$);
6268
- _v$2 !== _p$._v$2 && _el$9.classList.toggle("sales-price", _p$._v$2 = _v$2);
6408
+ _v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$, "data-search-result-id", _p$._v$2 = _v$2);
6409
+ _v$3 !== _p$._v$3 && _el$9.classList.toggle("sales-price", _p$._v$3 = _v$3);
6269
6410
  return _p$;
6270
6411
  }, {
6271
6412
  _v$: undefined,
6272
- _v$2: undefined
6413
+ _v$2: undefined,
6414
+ _v$3: undefined
6273
6415
  });
6274
6416
  return _el$;
6275
6417
  })();
6276
- // This solves a JSX type issue where the return value does not match with the explicit JSX.Element type for some reason
6277
- return returnVal;
6278
6418
  };
6279
6419
  (0, $g9l4l$delegateEvents)([
6280
6420
  "click"
@@ -6311,7 +6451,7 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6311
6451
  }));
6312
6452
  const sliced_displays = (0, $g9l4l$createMemo)(()=>search_results()?.displays?.slice(0, max_cards));
6313
6453
  let placeholder;
6314
- const container = (()=>{
6454
+ return (()=>{
6315
6455
  const _el$ = $d811ce622b5b7626$var$_tmpl$.cloneNode(true);
6316
6456
  (0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
6317
6457
  get when () {
@@ -6329,8 +6469,8 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6329
6469
  get each () {
6330
6470
  return sliced_displays();
6331
6471
  },
6332
- children: (d, i)=>$d811ce622b5b7626$var$track_elements(d, i, // Custom instant card requires a re-render on every display or i18n update
6333
- render_instant_card_ ? (0, $g9l4l$createMemo)(()=>render_instant_card_(d(), {
6472
+ children: (d, i)=>{
6473
+ const card = render_instant_card_ ? (0, $g9l4l$createMemo)(()=>render_instant_card_(d(), {
6334
6474
  index: i,
6335
6475
  i18n: (0, $589fd8dc82a78e48$export$27b710c08412a7ad)(i18n_),
6336
6476
  merchant: tenant_(),
@@ -6340,79 +6480,14 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6340
6480
  i18n: i18n_,
6341
6481
  merchant: tenant_(),
6342
6482
  market: market_()
6343
- }, router_), tenant_, market_)
6483
+ }, router_);
6484
+ return card;
6485
+ }
6344
6486
  });
6345
6487
  }
6346
6488
  }));
6347
6489
  return _el$;
6348
6490
  })();
6349
- new (0, $g9l4l$Lazyfier)({
6350
- container: container,
6351
- lazyfinder: {
6352
- unload () {}
6353
- },
6354
- ignore_data_urls: true
6355
- });
6356
- return container;
6357
- }
6358
- function $d811ce622b5b7626$var$track_elements(display, index, elements, tenant, market) {
6359
- const type = "instant_result";
6360
- const unwrapped_elements = $d811ce622b5b7626$var$unwrap_solid_jsx_element(elements);
6361
- const disconnectors = [];
6362
- (0, $g9l4l$createComputed)(()=>{
6363
- let stop = false;
6364
- const modern_or_legacy_d = display(); // For every display
6365
- const d = "variant_index" in modern_or_legacy_d ? modern_or_legacy_d.variant_displays[modern_or_legacy_d.variant_index] : modern_or_legacy_d;
6366
- const t = tenant(); // and tenant
6367
- const m = market(); // / market combination
6368
- const click_handler = ()=>{
6369
- (0, $g9l4l$depict_click)({
6370
- tenant: (0, $g9l4l$untrack)(tenant),
6371
- market: (0, $g9l4l$untrack)(market),
6372
- ...d,
6373
- click_location: type + "_" + (index + 1),
6374
- recommendation_type: type
6375
- });
6376
- localStorage.setItem(`depict_attribution_${d.product_id}`, d.search_result_id);
6377
- };
6378
- while(disconnectors.length)// disconnect stuff from old display
6379
- disconnectors.pop()();
6380
- disconnectors.push(()=>stop = true);
6381
- (0, $g9l4l$createComputed)(()=>{
6382
- if (stop) return;
6383
- const filtered_els = unwrapped_elements().filter((el)=>el instanceof Element);
6384
- for (const element of filtered_els){
6385
- element.addEventListener("click", click_handler);
6386
- disconnectors.push((0, $g9l4l$impression_track_element)({
6387
- element: element,
6388
- data: {
6389
- tenant: t,
6390
- market: m,
6391
- recommendation_type: type,
6392
- recommendation_id: d.recommendation_id,
6393
- product_id: d.product_id,
6394
- entity_price: d.entity_price
6395
- }
6396
- }), ()=>element.removeEventListener("click", click_handler));
6397
- }
6398
- (0, $g9l4l$add_new_tab_listener)(filtered_els, d, 1, (disconnector)=>disconnectors.push(disconnector));
6399
- });
6400
- });
6401
- return elements;
6402
- }
6403
- function $d811ce622b5b7626$var$unwrap_solid_jsx_element(elements) {
6404
- // FYI this probably doesn't work on hugely deep nestings or large amount of elements
6405
- return (0, $g9l4l$createMemo)(()=>$d811ce622b5b7626$var$unwrapping_helper(elements));
6406
- }
6407
- function $d811ce622b5b7626$var$unwrapping_helper(elements) {
6408
- const result = [];
6409
- if (Array.isArray(elements)) for(let i = 0; i < elements.length; i++){
6410
- const element = elements[i];
6411
- result.push(...$d811ce622b5b7626$var$unwrapping_helper(element));
6412
- }
6413
- else if (typeof elements == "function") result.push(...$d811ce622b5b7626$var$unwrapping_helper(elements()));
6414
- else if (elements != undefined && typeof elements != "boolean") result.push(elements);
6415
- return result;
6416
6491
  }
6417
6492
 
6418
6493
 
@@ -6646,14 +6721,14 @@ function $54eb3ff8b0c7c7b8$export$ba17c5b7e6dda39f({ whole_text_to_display_: who
6646
6721
 
6647
6722
 
6648
6723
  const $f19e81a7eecb0aac$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="suggestion"></a>`, 2), $f19e81a7eecb0aac$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="search-icon"></div>`, 2), $f19e81a7eecb0aac$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="type"></span>`, 2), $f19e81a7eecb0aac$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><span class="value"></span></div>`, 4), $f19e81a7eecb0aac$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<h2 class="text"></h2>`, 2), $f19e81a7eecb0aac$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="suggestion-container query"></div>`, 2), $f19e81a7eecb0aac$var$_tmpl$7 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="suggestion-container page"></div>`, 2), $f19e81a7eecb0aac$var$_tmpl$8 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="suggestions"></div>`, 2);
6649
- function $f19e81a7eecb0aac$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ , search_page_url_param_name_: search_page_url_param_name_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , filtered_previous_searches_: filtered_previous_searches_ , currently_showing_suggestions_: currently_showing_suggestions_ , on_previous_searches_page_: on_previous_searches_page_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , searching_for_value_: searching_for_value_ , router_: router_ , submit_query_: submit_query_ }) {
6724
+ function $f19e81a7eecb0aac$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ , search_query_url_param_name_: search_query_url_param_name_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , filtered_previous_searches_: filtered_previous_searches_ , currently_showing_suggestions_: currently_showing_suggestions_ , on_previous_searches_page_: on_previous_searches_page_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , searching_for_value_: searching_for_value_ , router_: router_ , submit_query_: submit_query_ }) {
6650
6725
  const queries_memo = (0, $g9l4l$createMemo)(()=>suggestion_memo_().filter(({ type: type , title: title })=>type === (0, $c7bc9269d29d4bdc$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
6651
6726
  ));
6652
6727
  const not_queries_memo = (0, $g9l4l$createMemo)(()=>suggestion_memo_().filter(({ type: type })=>type !== (0, $c7bc9269d29d4bdc$export$3cf9497e790da491)));
6653
6728
  const render_entry = (input_obj, autocomplete_data_index, index, is_history = false)=>{
6654
6729
  const is_query = (0, $g9l4l$createMemo)(()=>input_obj().type === (0, $c7bc9269d29d4bdc$export$3cf9497e790da491));
6655
6730
  const href_with_changed_params_accessor = (0, $g9l4l$createMemo)(()=>is_query() ? (0, $8fee64e5ff6fd014$export$91c3b6774e8be0f5)({
6656
- param_: search_page_url_param_name_,
6731
+ param_: search_query_url_param_name_,
6657
6732
  value_: (0, $g9l4l$createMemo)(()=>input_obj().title),
6658
6733
  url_transformer_: url_transformer_
6659
6734
  }) : undefined);
@@ -6989,7 +7064,7 @@ function $a817d06dc1c5911c$var$open_link_on_cmd_pressed(e, href) {
6989
7064
 
6990
7065
 
6991
7066
  const $c7bc9269d29d4bdc$export$3cf9497e790da491 = "query";
6992
- function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search_field_value_ , search_query_: [get_search_query_] , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: unfiltered_previous_searches , previous_searches_text_: previous_searches_text_ , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , input_field_: input_field_ , url_transformer_: url_transformer_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , selected_index_: selected_index_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , submit_query_: submit_query_ , router_: router_ }) {
7067
+ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , search_query_url_param_name_: search_query_url_param_name_ , previous_searches_: unfiltered_previous_searches , previous_searches_text_: previous_searches_text_ , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , input_field_: input_field_ , url_transformer_: url_transformer_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , selected_index_: selected_index_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , submit_query_: submit_query_ , router_: router_ }) {
6993
7068
  const [searching_for_value, set_searching_for_value] = (0, $g9l4l$createSignal)();
6994
7069
  const [read_search_field_value] = search_field_value_;
6995
7070
  const updating_blocked = (0, $g9l4l$createSignal)(false);
@@ -7030,7 +7105,7 @@ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search
7030
7105
  updating_blocked_: updating_blocked,
7031
7106
  currently_showing_suggestions_: currently_showing_suggestions_,
7032
7107
  set_override_on_enter_fn_: set_override_on_enter_fn_,
7033
- search_query_param_name_: search_page_url_param_name_,
7108
+ search_query_param_name_: search_query_url_param_name_,
7034
7109
  url_transformer_: url_transformer_,
7035
7110
  router_: router_
7036
7111
  });
@@ -7045,7 +7120,7 @@ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search
7045
7120
  get set_unfiltered_previous_searches_ () {
7046
7121
  return unfiltered_previous_searches[1];
7047
7122
  },
7048
- search_query_param_name_: search_page_url_param_name_,
7123
+ search_query_param_name_: search_query_url_param_name_,
7049
7124
  text_: previous_searches_text_,
7050
7125
  get previous_searches_ () {
7051
7126
  return (0, $g9l4l$createMemo)(()=>filtered_previous_searches().slice(0, 5));
@@ -7072,7 +7147,7 @@ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search
7072
7147
  i18n_: i18n_,
7073
7148
  url_transformer_: url_transformer_,
7074
7149
  searching_for_value_: searching_for_value,
7075
- search_page_url_param_name_: search_page_url_param_name_,
7150
+ search_query_url_param_name_: search_query_url_param_name_,
7076
7151
  selected_index_: selected_index_,
7077
7152
  suggestion_memo_: read_suggestion_signal,
7078
7153
  currently_showing_suggestions_: currently_showing_suggestions_,
@@ -7107,13 +7182,13 @@ function $b760a1a8108897d0$export$c7e181728ad525f(url) {
7107
7182
  }
7108
7183
 
7109
7184
 
7110
- function $e495e86fcf483c73$export$3340fdd8259bd4fd({ get_search_field_value_: get_search_field_value_ , search_page_url_param_name_: search_page_url_param_name_ , url_transformer_: url_transformer_ , get_search_query_: get_search_query_ }) {
7185
+ function $e495e86fcf483c73$export$3340fdd8259bd4fd({ get_search_field_value_: get_search_field_value_ , search_query_url_param_name_: search_query_url_param_name_ , url_transformer_: url_transformer_ , get_search_query_: get_search_query_ }) {
7111
7186
  let debounce_timeout;
7112
7187
  const stop_timeout = ()=>clearTimeout(debounce_timeout);
7113
7188
  const send_to_ga = (0, $g9l4l$catchify)(()=>{
7114
7189
  const fake_url = new URL(location.href);
7115
7190
  const { searchParams: searchParams } = fake_url;
7116
- searchParams.set(search_page_url_param_name_, (0, $g9l4l$untrack)(get_search_field_value_));
7191
+ searchParams.set(search_query_url_param_name_, (0, $g9l4l$untrack)(get_search_field_value_));
7117
7192
  searchParams.set("instant_result", "true");
7118
7193
  url_transformer_?.(fake_url);
7119
7194
  (0, $b760a1a8108897d0$export$c7e181728ad525f)(fake_url);
@@ -7164,7 +7239,7 @@ function $b24f16c875c2baa6$export$f021bdedd3ec901a(props) {
7164
7239
 
7165
7240
 
7166
7241
  const $a9f6faeac82c322b$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="discover-more"><button class="major" type="button"></button></div>`, 4), $a9f6faeac82c322b$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<b></b>`, 2), $a9f6faeac82c322b$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict-search-modal"><div class="body"><div class="padded"></div></div></div>`, 6), $a9f6faeac82c322b$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"><div class="depict-search-modal-backdrop"></div></div>`, 4);
7167
- function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_search_field_value , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $g9l4l$createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false , router_: router_ }) {
7242
+ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_search_field_value , get_search_query_: get_search_query_ , search_query_url_param_name_: search_query_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $g9l4l$createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false , router_: router_ }) {
7168
7243
  let on_enter_in_search_field_function;
7169
7244
  // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
7170
7245
  // This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
@@ -7191,7 +7266,7 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
7191
7266
  equals: false
7192
7267
  });
7193
7268
  if (disable_scrolling_) (0, $a1123c5ed9b0ee29$export$fe334901e8bebd57)();
7194
- $a9f6faeac82c322b$var$close_modal_when_navigating_away(close_modal_, search_page_url_param_name_);
7269
+ $a9f6faeac82c322b$var$close_modal_when_navigating_away(close_modal_, search_query_url_param_name_);
7195
7270
  window.addEventListener("keydown", close_on_escape_handler);
7196
7271
  (0, $g9l4l$onCleanup)((0, $g9l4l$catchify)(()=>window.removeEventListener("keydown", close_on_escape_handler)));
7197
7272
  const owner = (0, $g9l4l$getOwner)();
@@ -7216,8 +7291,8 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
7216
7291
  (0, $e495e86fcf483c73$export$3340fdd8259bd4fd)({
7217
7292
  get_search_field_value_: get_search_field_value_,
7218
7293
  url_transformer_: url_transformer_,
7219
- search_page_url_param_name_: search_page_url_param_name_,
7220
- get_search_query_: search_query_[0]
7294
+ search_query_url_param_name_: search_query_url_param_name_,
7295
+ get_search_query_: get_search_query_
7221
7296
  });
7222
7297
  const random_classname = (0, $g9l4l$make_random_classname)();
7223
7298
  const body_style = (0, $g9l4l$createMemo)(()=>{
@@ -7234,7 +7309,6 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
7234
7309
  input_field_ref_: (element)=>set_input_field(element),
7235
7310
  override_on_enter_: (e)=>on_enter_in_search_field_function?.(e),
7236
7311
  on_back_: close_modal_,
7237
- search_query_: search_query_,
7238
7312
  search_field_value_: search_field_value_,
7239
7313
  submit_query_: submit_query_,
7240
7314
  clear_filters_: clear_filters_,
@@ -7266,9 +7340,9 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
7266
7340
  get previous_searches_text_ () {
7267
7341
  return i18n_.previous_searches_text_;
7268
7342
  },
7269
- search_query_: search_query_,
7343
+ get_search_query_: get_search_query_,
7270
7344
  previous_searches_: previous_searches_,
7271
- search_page_url_param_name_: search_page_url_param_name_,
7345
+ search_query_url_param_name_: search_query_url_param_name_,
7272
7346
  market_: market_,
7273
7347
  tenant_: tenant_,
7274
7348
  selected_index_: selected_index,
@@ -7326,7 +7400,7 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
7326
7400
  })()
7327
7401
  ];
7328
7402
  }
7329
- function $a9f6faeac82c322b$var$close_modal_when_navigating_away(close_modal, search_page_url_param_name_) {
7403
+ function $a9f6faeac82c322b$var$close_modal_when_navigating_away(close_modal, search_query_url_param_name_) {
7330
7404
  const [exit_iterable, exitable_iterable] = (0, $g9l4l$make_asyncIterable_exiter)((0, $g9l4l$href_change_ipns));
7331
7405
  let set_initial_values = false;
7332
7406
  let old_pathname;
@@ -7336,7 +7410,7 @@ function $a9f6faeac82c322b$var$close_modal_when_navigating_away(close_modal, sea
7336
7410
  for await (const href of exitable_iterable){
7337
7411
  const u_o = new URL(href);
7338
7412
  const new_pathname = u_o.pathname;
7339
- const new_param_value = u_o.searchParams.get(search_page_url_param_name_);
7413
+ const new_param_value = u_o.searchParams.get(search_query_url_param_name_);
7340
7414
  if (set_initial_values) {
7341
7415
  if (new_param_value !== old_param_value || new_pathname !== old_pathname) {
7342
7416
  // close modal when pathname or query changes
@@ -7425,9 +7499,9 @@ function $71cf2f71a46bffea$export$c05a196222ba1302({ suggestions_: suggestions_
7425
7499
 
7426
7500
 
7427
7501
  const $57ec75eac12fe1fc$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<b></b>`, 2), $57ec75eac12fe1fc$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="results-for"></div>`, 2);
7428
- function $57ec75eac12fe1fc$export$9dd50d35b9d94fdf({ search_query_: search_query_ , i18n_: i18n_ , formatted_number_of_results_: formatted_number_of_results_ }) {
7502
+ function $57ec75eac12fe1fc$export$9dd50d35b9d94fdf({ get_search_query_: get_search_query_ , i18n_: i18n_ , formatted_number_of_results_: formatted_number_of_results_ }) {
7429
7503
  const contents = (0, $g9l4l$createMemo)((0, $g9l4l$catchify)(()=>{
7430
- const q = search_query_[0]();
7504
+ const q = get_search_query_();
7431
7505
  return i18n_.get_showing_results_for_()((()=>{
7432
7506
  const _el$ = $57ec75eac12fe1fc$var$_tmpl$.cloneNode(true);
7433
7507
  (0, $g9l4l$insert)(_el$, q);
@@ -7454,15 +7528,8 @@ function $57ec75eac12fe1fc$export$9dd50d35b9d94fdf({ search_query_: search_query
7454
7528
 
7455
7529
  const $b76e8f62b1f313ef$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-results-for-one-row"></div>`, 2), $b76e8f62b1f313ef$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
7456
7530
  function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7457
- const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , search_query_: search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , rr_options_: rr_options_ , recommendations_rr_options_: recommendations_rr_options_ = rr_options_ , search_recs_view_more_: search_recs_view_more_ , get_product_id_: get_product_id_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ } = opts;
7458
- const tenant_object_ = new (0, $g9l4l$Tenant)({
7459
- TENANT: (0, $g9l4l$untrack)(tenant_),
7460
- MARKET: (0, $g9l4l$untrack)(market_),
7461
- GA_ID: "",
7462
- get_product_id: get_product_id_
7463
- });
7531
+ const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , search_recs_view_more_: search_recs_view_more_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ } = opts;
7464
7532
  const [get_sorting] = current_sorting_;
7465
- const [get_search_query] = search_query_;
7466
7533
  const all_products_loaded_ = (0, $g9l4l$createSignal)(false);
7467
7534
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
7468
7535
  const number_of_rendered_selected_filters_items_ = (0, $g9l4l$createSignal)(0);
@@ -7478,7 +7545,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7478
7545
  return {
7479
7546
  tenant: tenant_(),
7480
7547
  market: market_(),
7481
- query: get_search_query(),
7548
+ query: get_search_query_(),
7482
7549
  ...f.length ? {
7483
7550
  filters: f
7484
7551
  } : {},
@@ -7491,7 +7558,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7491
7558
  set_all_products_loaded(false);
7492
7559
  // only first page of results
7493
7560
  return await (0, $f4d7f67154f032af$export$cc42dd29bf655ab6)({
7494
- id_: (0, $g9l4l$untrack)(get_search_query),
7561
+ id_: (0, $g9l4l$untrack)(get_search_query_),
7495
7562
  min_products_to_fetch_: min_products_to_fetch_,
7496
7563
  scroll_restoration_data_: scroll_restoration_data_,
7497
7564
  make_request_: (limit, cursor)=>depict_api_.query({
@@ -7504,7 +7571,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7504
7571
  });
7505
7572
  }));
7506
7573
  const [suggestions] = (0, $g9l4l$createResource)((0, $g9l4l$createMemo)(()=>({
7507
- query: search_query_[0](),
7574
+ query: get_search_query_(),
7508
7575
  tenant: tenant_(),
7509
7576
  market: market_()
7510
7577
  })), (opts)=>depict_api_.suggest(opts));
@@ -7521,7 +7588,6 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7521
7588
  let div_with_field_class;
7522
7589
  search_field = SafeSearchField({
7523
7590
  i18n_: i18n_,
7524
- search_query_: search_query_,
7525
7591
  search_field_value_: search_field_value_,
7526
7592
  submit_query_: submit_query_,
7527
7593
  clear_filters_: clear_filters_on_next_submit_,
@@ -7559,7 +7625,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7559
7625
  });
7560
7626
  const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $g9l4l$createSignal)();
7561
7627
  const results_for = (0, $g9l4l$createComponent)((0, $57ec75eac12fe1fc$export$9dd50d35b9d94fdf), {
7562
- search_query_: search_query_,
7628
+ get_search_query_: get_search_query_,
7563
7629
  i18n_: i18n_,
7564
7630
  formatted_number_of_results_: formatted_number_of_results_
7565
7631
  });
@@ -7598,7 +7664,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7598
7664
  (0, $g9l4l$catchify)((0, $f4d7f67154f032af$export$6e49da55e449af7c))({
7599
7665
  scroll_restoration_data_: scroll_restoration_data_,
7600
7666
  last_result_in_viewport_: last_result_in_viewport_,
7601
- id_: get_search_query,
7667
+ id_: get_search_query_,
7602
7668
  can_write_scroll_restoration_: can_write_scroll_restoration_
7603
7669
  });
7604
7670
  (0, $g9l4l$createComputed)(()=>{
@@ -7610,13 +7676,9 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7610
7676
  available_filters_: available_filters_
7611
7677
  });
7612
7678
  (0, $g9l4l$createEffect)(()=>{
7613
- get_search_query();
7679
+ get_search_query_();
7614
7680
  (0, $b760a1a8108897d0$export$c7e181728ad525f)(location);
7615
7681
  });
7616
- (0, $g9l4l$createComputed)(()=>{
7617
- tenant_object_.tenant = tenant_object_.TENANT = tenant_();
7618
- tenant_object_.market = tenant_object_.MARKET = market_();
7619
- });
7620
7682
  return [
7621
7683
  document.createComment("Search page based on Depict SDK"),
7622
7684
  (()=>{
@@ -7672,12 +7734,10 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7672
7734
  last_result_in_viewport_: last_result_in_viewport_,
7673
7735
  scroll_restoration_data_: scroll_restoration_data_,
7674
7736
  desktop_filter_elements_: desktop_filter_elements_,
7675
- rr_options_: rr_options_,
7737
+ product_card_template_: product_card_template_,
7676
7738
  layout_options_: layout_options_,
7677
7739
  sort_or_filter_open_: sort_or_filter_open_,
7678
- tenant_object_: tenant_object_,
7679
- type_for_tracking_: "search",
7680
- id_currently_querying_for_: get_search_query,
7740
+ id_currently_querying_for_: get_search_query_,
7681
7741
  no_results_options_: {
7682
7742
  selected_filters_: selected_filters_,
7683
7743
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -7703,9 +7763,8 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7703
7763
  search_query_base_: search_query_base_,
7704
7764
  layout_options_: recommendations_layout_options_,
7705
7765
  showing_recommendation_rows_: showing_recommendation_rows_,
7706
- rr_options_: recommendations_rr_options_,
7707
7766
  view_more_button_: search_recs_view_more_,
7708
- tenant_object_: tenant_object_
7767
+ product_card_template_: product_card_template_
7709
7768
  });
7710
7769
  }
7711
7770
  });
@@ -7790,13 +7849,17 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7790
7849
  #modal_open_signal = (0, $g9l4l$createSignal)(false);
7791
7850
  static #has_been_constructed = false;
7792
7851
  #router = new (0, $cfa2761d36e5714c$export$7e1297a3a19f10d8)("hard_navigation");
7793
- constructor({ search_query_url_param_name: search_query_url_param_name = "query" , url_transformer: url_transformer , on_navigation: on_navigation , enable_category_suggestions: enable_category_suggestions = true , disable_scrolling_during_modal: // Stuff needed for non-standard customer deployments that we shouldn't actually expose
7794
- disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
7852
+ constructor({ search_query_url_param_name: search_query_url_param_name_ = "query" , url_transformer: url_transformer , on_navigation: on_navigation , enable_category_suggestions: enable_category_suggestions = true , disable_scrolling_during_modal: // Stuff needed for non-standard customer deployments that we shouldn't actually expose
7853
+ disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal: bottom_distance_under_modal , render_instant_card: render_instant_card , ...props_on_class }){
7795
7854
  if ($540e930c58500cbe$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
7796
7855
  Object.assign(this, props_on_class);
7797
- const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7)(this.#router);
7856
+ if (on_navigation) this.#router.on_navigation_ = on_navigation;
7857
+ const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ , search_query_accessor_: raw_search_query_accessor } = (0, $f01b3a0b9fbf6519$export$477caf01aecaeb2a)({
7858
+ search_query_url_param_name_: search_query_url_param_name_,
7859
+ router_: this.#router
7860
+ });
7798
7861
  const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
7799
- search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7862
+ search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name_) ?? "",
7800
7863
  search_filters_open: false,
7801
7864
  search_sorting_open: false,
7802
7865
  search_expanded_filters: [],
@@ -7805,14 +7868,15 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7805
7868
  search_expanded_hierarchical_filters: [],
7806
7869
  search_showing_recommendation_rows: (0, $aee0c68312d971f4$export$1c8c715550dc689d),
7807
7870
  search_scroll_restoration_data: []
7808
- }));
7871
+ }), this.#router);
7809
7872
  const search_query_updating_blocked_ = (0, $g9l4l$createSignal)(false);
7810
- const { [search_query_url_param_name]: raw_search_query_signal } = (0, $4ad18a8b237ff7f6$export$2542ffb77b620b02)({
7811
- [search_query_url_param_name]: ""
7873
+ const [get_search_query_updating_blocked] = search_query_updating_blocked_;
7874
+ const get_search_query_ = (0, $g9l4l$createMemo)((previous_value)=>{
7875
+ if (get_search_query_updating_blocked()) return previous_value;
7876
+ else return raw_search_query_accessor();
7812
7877
  });
7813
- const search_query_signal_ = (0, $g9l4l$createSignal)((0, $g9l4l$untrack)(raw_search_query_signal[0]));
7814
7878
  const depict_api_ = api ?? new (0, $3846bb34098c738f$export$e015ed2f2950f2e3)();
7815
- const previous_searches = (0, $4d62f5daa51642fe$export$84bba84a7b837187)(search_query_signal_);
7879
+ const previous_searches = (0, $4d62f5daa51642fe$export$84bba84a7b837187)(get_search_query_);
7816
7880
  const [, set_search_showing_recommendation_rows] = state_.search_showing_recommendation_rows;
7817
7881
  const after_submit_ = ()=>set_search_showing_recommendation_rows((0, $aee0c68312d971f4$export$1c8c715550dc689d)); // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
7818
7882
  const on_submit_with_unchanged_value_ = ()=>this.modal_open = false;
@@ -7820,31 +7884,24 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7820
7884
  const configured_submit_query_ = (new_query)=>(0, $7f6ddd9a7e868c4d$export$e16630ecb9644a1c)({
7821
7885
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
7822
7886
  set_search_field_value_: set_search_field_value_,
7823
- search_query_: search_query_signal_,
7824
- search_param_name_: search_query_url_param_name,
7825
- url_transformer_: url_transformer,
7887
+ get_search_query_: get_search_query_,
7888
+ search_param_name_: search_query_url_param_name_,
7826
7889
  after_submit_: after_submit_,
7827
7890
  get_new_query: ()=>new_query || (0, $g9l4l$untrack)(get_search_field_value_),
7891
+ url_transformer_: url_transformer,
7828
7892
  router_: this.#router
7829
7893
  });
7830
7894
  const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
7831
7895
  const clear_filters_on_next_submit_ = (0, $a0d89ff25220eb8d$export$e026af0c7b64ea5f)({
7832
7896
  selected_filters_: selected_filters_,
7833
- search_query_: search_query_signal_,
7897
+ get_search_query_: get_search_query_,
7834
7898
  current_sorting_: current_sorting_,
7835
7899
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7836
7900
  i18n_: i18n_,
7837
7901
  local_filter_cache_: state_.search_local_filter_cache
7838
7902
  });
7839
- if (on_navigation) this.#router.on_navigation_ = on_navigation;
7840
- (0, $g9l4l$createComputed)(()=>{
7841
- const [get_search_query_updating_blocked] = search_query_updating_blocked_;
7842
- const [get_raw_search_query_signal] = raw_search_query_signal;
7843
- const [, set_search_query_signal] = search_query_signal_; // this signal won't get written from anywhere, see url_params_to_signals JSDoc
7844
- if (!get_search_query_updating_blocked()) set_search_query_signal(get_raw_search_query_signal());
7845
- });
7846
7903
  $540e930c58500cbe$var$privately_shared_properties.set(this, {
7847
- search_query_url_param_name_: search_query_url_param_name,
7904
+ search_query_url_param_name_: search_query_url_param_name_,
7848
7905
  reset_history_state_: reset_history_state_,
7849
7906
  state_: state_,
7850
7907
  router_: this.#router,
@@ -7853,7 +7910,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7853
7910
  enable_category_suggestions_: enable_category_suggestions,
7854
7911
  clear_filters_on_next_submit_: clear_filters_on_next_submit_,
7855
7912
  configured_submit_query_: configured_submit_query_,
7856
- search_query_signal_: search_query_signal_,
7913
+ get_search_query_: get_search_query_,
7857
7914
  i18n_: i18n_,
7858
7915
  search_query_updating_blocked_: search_query_updating_blocked_,
7859
7916
  current_sorting_: current_sorting_,
@@ -7867,8 +7924,8 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7867
7924
  return (0, $a9f6faeac82c322b$export$1c593cbd6f1e10bc)(...args);
7868
7925
  }, {
7869
7926
  search_field_value_: state_.search_field_value,
7870
- search_query_: search_query_signal_,
7871
- search_page_url_param_name_: search_query_url_param_name,
7927
+ get_search_query_: get_search_query_,
7928
+ search_query_url_param_name_: search_query_url_param_name_,
7872
7929
  previous_searches_: previous_searches,
7873
7930
  depict_api_: depict_api_,
7874
7931
  tenant_: this.#merchant_signal[0],
@@ -7886,7 +7943,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7886
7943
  i18n_: i18n_,
7887
7944
  enable_category_suggestions_: enable_category_suggestions,
7888
7945
  disable_scrolling_: disable_scrolling_during_modal,
7889
- bottom_distance_under_modal_: bottom_distance_under_modal_
7946
+ bottom_distance_under_modal_: bottom_distance_under_modal
7890
7947
  });
7891
7948
  // This will add some default behaviour to open_modal_ if no style_props_ are supplied
7892
7949
  // The default behaviour is to align the modal with the input field if possible
@@ -7997,7 +8054,7 @@ function $540e930c58500cbe$var$get_shared_properties(depict_search) {
7997
8054
  if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
7998
8055
  return shared_properties;
7999
8056
  }
8000
- function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id = (0, $g9l4l$normal_get_product_id) , extra_depict_options: extra_depict_options }) {
8057
+ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , extra_depict_options: extra_depict_options }) {
8001
8058
  const shared_properties = $540e930c58500cbe$var$get_shared_properties(depict_search);
8002
8059
  const grid_spacing_override = typeof grid_spacing === "string" ? {
8003
8060
  grid_spacing: grid_spacing
@@ -8016,7 +8073,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
8016
8073
  min_products_to_fetch_: $540e930c58500cbe$var$min_products_to_fetch_,
8017
8074
  local_filter_cache_: state_.search_local_filter_cache,
8018
8075
  search_field_value_: state_.search_field_value,
8019
- search_query_: shared_properties.search_query_signal_,
8076
+ get_search_query_: shared_properties.get_search_query_,
8020
8077
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
8021
8078
  open_modal_: (...args)=>depict_search.modal_open = args,
8022
8079
  submit_query_: shared_properties.configured_submit_query_,
@@ -8064,15 +8121,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
8064
8121
  height_: 12,
8065
8122
  width_: 6.46
8066
8123
  }),
8067
- rr_options_: {
8068
- template: (display, info)=>{
8069
- const is_placeholder = info.rendering_options.type === "placeholder";
8070
- return product_card_template(is_placeholder ? null : display, info);
8071
- },
8072
- pre_processors: extra_depict_options?.pre_processors,
8073
- post_processors: extra_depict_options?.post_processors
8074
- },
8075
- get_product_id_: get_product_id
8124
+ product_card_template_: product_card_template
8076
8125
  });
8077
8126
  }, "Entire SearchPage failed");
8078
8127
  }
@@ -8081,9 +8130,6 @@ function $540e930c58500cbe$export$316f6f283ae64765({ depict_search: depict_searc
8081
8130
  return (0, $c7f938ac40924f3b$export$23fca46f3143581f)(()=>{
8082
8131
  let input_element;
8083
8132
  const search_field = (0, $g9l4l$createComponent)((0, $6ded59a142c93078$export$b94867ecbd698f21), {
8084
- get search_query_ () {
8085
- return shared_properties.search_query_signal_;
8086
- },
8087
8133
  get search_field_value_ () {
8088
8134
  return shared_properties.state_.search_field_value;
8089
8135
  },
@@ -8427,4 +8473,4 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
8427
8473
  (0, $g9l4l$add_to_version_info)("ui", (0, $18bf1d29fb889cca$export$83d89fbfd8236492));
8428
8474
 
8429
8475
 
8430
- export {$e95f1855a5e3864f$export$58e808b1db15d3bc as fetchDepictRecommendations, $ec52ef1e6c117813$export$de035477d6fef996 as QuickLinks, $ec52ef1e6c117813$export$5b7c3ce0ebe51f86 as BreadCrumbs, $6340962f8bafd049$export$b91cec6bdc6b32a1 as CategoryTitle, $9b693ea3ff420de6$export$824dde41348efed1 as embedded_num_products, $80a49d3809ecb080$export$643598a327b5833e as get_categories, $ec52ef1e6c117813$export$f34314aa9505732e as DepictCategory, $ec52ef1e6c117813$export$e2bf8ce7779e827e as CategoryPage, $540e930c58500cbe$export$ac6237957a15b3f0 as DepictSearch, $540e930c58500cbe$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $540e930c58500cbe$export$f2dc7e4e4aa11abb as SearchPage, $540e930c58500cbe$export$316f6f283ae64765 as SearchField, $22d7fd594100c3d0$export$aa14a9f43128f61f as ProductCardError, $7cbfd6122dbaf087$export$d86a33413558014e as open_modal_with_alignment, $aaacfac0064e97d9$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $079defea521d5e2a$export$b3ad617e9036868 as align_field, $b4e6a093ae83373b$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $246aa49a8f85c7f3$export$1233ca167bf71f9a as styles_to_valid_css_string, $a1123c5ed9b0ee29$export$fe334901e8bebd57 as disable_scrolling, $a3e81b85527bc866$export$d0596b5cae35ad4 as open_search_with_shift_slash, $3846bb34098c738f$export$e015ed2f2950f2e3 as DepictAPI, $fefe7683325039b3$export$d9f36cf74e24d595 as media_query_to_accessor, $36316d7b4c897a03$export$689e204eadb33baf as setup_fast_leave, $886fa987db4f3805$export$5196e4c01fa56fcb as show_toast, $5178263ed1e394ca$export$469c7af753d08925 as solid_format_price, $a79ffb1cbfbd2a09$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $ba6c9609228edf6b$export$3ccaa27d81dd8556 as PageReplacer, $18bf1d29fb889cca$export$83d89fbfd8236492 as version};
8476
+ export {$e95f1855a5e3864f$export$58e808b1db15d3bc as fetchDepictRecommendations, $ec52ef1e6c117813$export$de035477d6fef996 as QuickLinks, $ec52ef1e6c117813$export$5b7c3ce0ebe51f86 as BreadCrumbs, $6340962f8bafd049$export$b91cec6bdc6b32a1 as CategoryTitle, $9b693ea3ff420de6$export$824dde41348efed1 as embedded_num_products, $80a49d3809ecb080$export$643598a327b5833e as get_categories, $ec52ef1e6c117813$export$f34314aa9505732e as DepictCategory, $ec52ef1e6c117813$export$e2bf8ce7779e827e as CategoryPage, $540e930c58500cbe$export$ac6237957a15b3f0 as DepictSearch, $540e930c58500cbe$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $540e930c58500cbe$export$f2dc7e4e4aa11abb as SearchPage, $540e930c58500cbe$export$316f6f283ae64765 as SearchField, $22d7fd594100c3d0$export$aa14a9f43128f61f as ProductCardError, $7cbfd6122dbaf087$export$d86a33413558014e as open_modal_with_alignment, $aaacfac0064e97d9$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $079defea521d5e2a$export$b3ad617e9036868 as align_field, $b4e6a093ae83373b$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $246aa49a8f85c7f3$export$1233ca167bf71f9a as styles_to_valid_css_string, $a1123c5ed9b0ee29$export$fe334901e8bebd57 as disable_scrolling, $a3e81b85527bc866$export$d0596b5cae35ad4 as open_search_with_shift_slash, $3846bb34098c738f$export$e015ed2f2950f2e3 as DepictAPI, $fefe7683325039b3$export$d9f36cf74e24d595 as media_query_to_accessor, $36316d7b4c897a03$export$689e204eadb33baf as setup_fast_leave, $886fa987db4f3805$export$5196e4c01fa56fcb as show_toast, $5178263ed1e394ca$export$a71e92cfbb498adc as SolidFormatPrice, $a79ffb1cbfbd2a09$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $ba6c9609228edf6b$export$3ccaa27d81dd8556 as PageReplacer, $18bf1d29fb889cca$export$83d89fbfd8236492 as version};