@depict-ai/ui 0.0.72 → 0.0.74

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,8 +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, 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, instant_exec_on_popstate_before_ipns_update as $g9l4l$instant_exec_on_popstate_before_ipns_update} from "@depict-ai/utilishared";
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
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
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";
4
+ import {compressToBase64 as $g9l4l$compressToBase64, decompressFromBase64 as $g9l4l$decompressFromBase64} from "lz-string";
4
5
 
5
- /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.72";
6
+ /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.74";
6
7
 
7
8
 
8
9
 
@@ -56,10 +57,10 @@ function $014a147d094b0d08$var$history_state_change(signals, entries, state) {
56
57
  }
57
58
 
58
59
 
59
- function $3075a4497054bec6$export$9862539c89138352(get_default_values) {
60
- const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values());
60
+ function $3075a4497054bec6$export$9862539c89138352(get_default_values_) {
61
+ const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values_());
61
62
  const reset_state = ()=>{
62
- const new_defaults = get_default_values();
63
+ const new_defaults = get_default_values_();
63
64
  for(const key in state){
64
65
  const new_value = new_defaults[key];
65
66
  state[key][1](new_value);
@@ -777,8 +778,8 @@ function $a20b0ecfca7ab32d$export$ef6006467f04ee41({ i18n_: i18n_ , expanded_hie
777
778
  ]);
778
779
 
779
780
 
780
- /*
781
- * 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.
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.
782
783
  */ const $9679915780ee67c0$export$6c9030e511152266 = 30;
783
784
 
784
785
 
@@ -838,7 +839,7 @@ function $a406ebe9523f192f$export$b69d0d92862de18b(props) {
838
839
 
839
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);
840
841
  let $57363319986950eb$var$cached_placeholder_element;
841
- 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_ , disable_default_tracking_: disable_default_tracking_ }) {
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_ }) {
842
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
843
844
  const is_loading = (0, $g9l4l$createMemo)(()=>plp_results_.loading || query_base_.loading);
844
845
  const cleanup_old_cards = [];
@@ -877,9 +878,7 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
877
878
  post_processors: [
878
879
  ...rr_options_.post_processors || [],
879
880
  load_more_post_processor
880
- ],
881
- view_tracking: disable_default_tracking_ ? [] : undefined,
882
- click_tracking: disable_default_tracking_ ? [] : undefined
881
+ ]
883
882
  });
884
883
  // check if we still should insert or something new happened while we were rendering
885
884
  if ((0, $g9l4l$untrack)(has_no_results_or_failed) || (0, $g9l4l$untrack)(is_loading)) {
@@ -1039,8 +1038,6 @@ async function $57363319986950eb$var$insert_placeholders({ scroll_restoration_da
1039
1038
  type: "placeholder",
1040
1039
  pre_processors: [],
1041
1040
  post_processors: [],
1042
- view_tracking: [],
1043
- click_tracking: [],
1044
1041
  ...typeof rr_options_.template === "function" ? {
1045
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
1046
1043
  )
@@ -2837,156 +2834,6 @@ var $7b224b353182ce9a$export$2e2bcd8739ae039 = {
2837
2834
 
2838
2835
 
2839
2836
 
2840
- function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
2841
- let last_remote_state;
2842
- (0, $g9l4l$createComputed)(()=>{
2843
- const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
2844
- JSON.stringify([
2845
- filter.field,
2846
- filter.op,
2847
- filter?.meta?.type
2848
- ]),
2849
- filter
2850
- ]) || []);
2851
- const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
2852
- JSON.stringify([
2853
- filter.field,
2854
- filter.op,
2855
- filter?.meta?.type
2856
- ]),
2857
- filter
2858
- ]));
2859
- const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
2860
- JSON.stringify([
2861
- filter_obj.field,
2862
- filter_obj.op
2863
- ]),
2864
- filter_obj
2865
- ]));
2866
- const new_local_filter_state = [];
2867
- // we want to be as close as possible to available_filters_ in local_filters except that we want to keep values from previous available_filters_ as long as they're selected
2868
- for (const filter_id of [
2869
- ...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
2870
- ...Object.keys(remote_filters)
2871
- ]){
2872
- const local_filter = local_filters[filter_id];
2873
- const remote_filter = remote_filters[filter_id];
2874
- const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
2875
- if (!remote_filter) // check if this filter is selected, if it is just take the local one but set counts to 0 and remove non-selected options
2876
- {
2877
- if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($dd3727f29e682893$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
2878
- } else if (!local_filter) // just take the remote one
2879
- new_local_filter_state.push(remote_filter);
2880
- else {
2881
- // both exist, merge them if needed
2882
- const remote_meta = remote_filter.meta;
2883
- const local_meta = local_filter.meta;
2884
- const this_applied_filter = selected_filters[filter_id_without_meta_type];
2885
- if (!remote_meta || !local_meta || !("values" in remote_meta) || !("values" in local_meta) || !Array.isArray(this_applied_filter?.data)) // can't or shouldn't be merged due to not being selected, just take remote one
2886
- new_local_filter_state.push(remote_filter);
2887
- else {
2888
- const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
2889
- JSON.stringify(value),
2890
- {
2891
- value_: value,
2892
- count_: remote_meta.counts?.[index],
2893
- name_: remote_meta.names?.[index]
2894
- }
2895
- ]));
2896
- const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
2897
- JSON.stringify(value),
2898
- {
2899
- value_: value,
2900
- count_: 0,
2901
- name_: local_meta.names?.[index]
2902
- }
2903
- ]));
2904
- const new_data = [
2905
- ...Object.keys(data_objs_in_local).filter((key)=>{
2906
- // put data entries that are selected and don't exist in new remote state first
2907
- if (key in data_objs_in_remote) return false;
2908
- const selected_values = this_applied_filter.data;
2909
- return selected_values.some((value)=>{
2910
- const is_equal = JSON.stringify(value) === key;
2911
- if (is_equal) return true;
2912
- if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
2913
- // Very special case for hierarchical checkboxes - when a parent has all kids checked and a kid is deselected, the parent gets deselected. But since if it still has selected children we don't want to remove it from the filter state, even though it isn't selected, as the UI won't know the correct title of the parent category otherwise. This keeps it in that case.
2914
- const selected_values = data_objs_in_local[key].value_;
2915
- const values_length = value?.length;
2916
- if (values_length > 1 && values_length - 1 === selected_values.length) {
2917
- let is_parent = true;
2918
- for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
2919
- return is_parent;
2920
- }
2921
- }
2922
- return false;
2923
- });
2924
- }).map((key)=>data_objs_in_local[key]),
2925
- ...Object.values(data_objs_in_remote)
2926
- ];
2927
- const new_values = new_data.map(({ value_: value_ })=>value_);
2928
- const result = {
2929
- ...remote_filter,
2930
- meta: {
2931
- ...remote_filter.meta,
2932
- values: new_values,
2933
- names: new_data.map(({ name_: name_ })=>name_),
2934
- counts: new_data.map(({ count_: count_ })=>count_)
2935
- }
2936
- };
2937
- new_local_filter_state.push(result);
2938
- }
2939
- }
2940
- }
2941
- if (last_remote_state !== available_filters_() || // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
2942
- JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
2943
- write_local_cache(new_local_filter_state);
2944
- last_remote_state = available_filters_();
2945
- });
2946
- return read_local_cache;
2947
- }
2948
- /**
2949
- * When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
2950
- * This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
2951
- */ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
2952
- const old_meta = local_filter_object.meta;
2953
- const selected_filter_data = selected_filter.data;
2954
- const modified_filter_object = {
2955
- ...local_filter_object
2956
- };
2957
- if (old_meta) {
2958
- const new_meta = {
2959
- ...old_meta
2960
- };
2961
- modified_filter_object.meta = new_meta;
2962
- // set counts to 0
2963
- if ("counts" in new_meta) {
2964
- const counts = new_meta.counts;
2965
- if (counts) new_meta.counts = counts.map(()=>0);
2966
- }
2967
- if (Array.isArray(selected_filter_data) && "values" in new_meta) {
2968
- // we have an array of values and want to strip the ones from the available ones that aren't selected
2969
- const values = new_meta.values;
2970
- if (Array.isArray(values)) {
2971
- const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
2972
- const indexes_to_remove = new Set();
2973
- for(let i = 0; i < values.length; i++){
2974
- const value = values[i];
2975
- if (!jsond_set_values.includes(JSON.stringify(value))) // We want to remove the entry with this value from the filter object because it's not selected
2976
- indexes_to_remove.add(i);
2977
- }
2978
- new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
2979
- if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
2980
- if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
2981
- new_meta.counts.length -= indexes_to_remove.size;
2982
- }
2983
- }
2984
- }
2985
- return modified_filter_object;
2986
- }
2987
-
2988
-
2989
-
2990
2837
 
2991
2838
 
2992
2839
 
@@ -3128,11 +2975,7 @@ function $8aff437d739a524d$export$3f1a388cc0d8fed7(props) {
3128
2975
  });
3129
2976
  }
3130
2977
  function $8aff437d739a524d$var$ActualFilterBody(props) {
3131
- const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state = (0, $dd3727f29e682893$export$b288c38ae3fddb56)({
3132
- available_filters_: props.available_filters_,
3133
- selected_filters_: props.selected_filters_,
3134
- local_filter_cache_: props.local_filter_cache_
3135
- });
2978
+ const [modified_available_filters_with_selected_unexisting_ones_injected_from_local_state] = props.local_filter_cache_;
3136
2979
  const togglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>item?.meta?.group_title));
3137
2980
  const untogglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>!item?.meta?.group_title));
3138
2981
  const togglable_filters_grouped_by_collapsible = (0, $g9l4l$createMemo)(()=>{
@@ -3333,7 +3176,7 @@ function $8aff437d739a524d$var$ActualFilterBody(props) {
3333
3176
 
3334
3177
 
3335
3178
  const $c23bd3d951eee1f2$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting-attributes"></div>`, 2), $c23bd3d951eee1f2$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting-direction"></div>`, 2), $c23bd3d951eee1f2$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><div class="input-row"><input type="radio"><span class="custom-indicator"></span></div></div>`, 7), $c23bd3d951eee1f2$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><label class="input-row"><input type="radio"><span class="custom-indicator"></span></label></div>`, 7);
3336
- function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: current_sorting_ }) {
3179
+ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: [get_current_sorting, set_current_sorting] , meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_ }) {
3337
3180
  const title_radio_name = (0, $g9l4l$make_random_classname)();
3338
3181
  const order_radio_name = (0, $g9l4l$make_random_classname)();
3339
3182
  return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
@@ -3367,14 +3210,14 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
3367
3210
  },
3368
3211
  children: (item, index)=>{
3369
3212
  const is_checked = (0, $g9l4l$createMemo)(()=>{
3370
- const sort = current_sorting_[0]();
3213
+ const sort = get_current_sorting();
3371
3214
  if (!sort) // if no sortings are selected, "select" first sort
3372
3215
  return index === 0;
3373
3216
  return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
3374
3217
  });
3375
3218
  return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
3376
3219
  const _el$8 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$9 = _el$8.firstChild, _el$10 = _el$9.firstChild, _el$11 = _el$10.nextSibling;
3377
- (0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>current_sorting_[1](item())));
3220
+ (0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>set_current_sorting(item())));
3378
3221
  (0, $g9l4l$setAttribute)(_el$10, "name", title_radio_name);
3379
3222
  (0, $g9l4l$insert)(_el$9, ()=>item().meta.title, null);
3380
3223
  (0, $g9l4l$effect)(()=>_el$10.checked = is_checked());
@@ -3386,27 +3229,25 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
3386
3229
  })(),
3387
3230
  (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
3388
3231
  get when () {
3389
- return current_sorting_[0]()?.meta?.values?.length > 1;
3232
+ return meta_of_currently_selected_sorting_()?.values?.length > 1;
3390
3233
  },
3391
3234
  get children () {
3392
3235
  const _el$2 = $c23bd3d951eee1f2$var$_tmpl$2.cloneNode(true);
3393
3236
  (0, $g9l4l$insert)(_el$2, (0, $g9l4l$createComponent)((0, $g9l4l$Index), {
3394
3237
  get each () {
3395
- return current_sorting_[0]().meta.values;
3238
+ return meta_of_currently_selected_sorting_()?.values;
3396
3239
  },
3397
3240
  children: (order_value, index)=>{
3241
+ const is_checked = (0, $g9l4l$createMemo)(()=>get_current_sorting()?.order === order_value());
3398
3242
  return (()=>{
3399
3243
  const _el$12 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
3400
- (0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>current_sorting_[1]((c)=>c && {
3244
+ (0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>set_current_sorting((c)=>c && {
3401
3245
  ...c,
3402
3246
  order: order_value()
3403
3247
  })));
3404
3248
  (0, $g9l4l$setAttribute)(_el$14, "name", order_radio_name);
3405
- (0, $g9l4l$insert)(_el$13, ()=>current_sorting_[0]()?.meta?.names?.[index], null);
3406
- (0, $g9l4l$effect)(()=>_el$14.checked = (0, $g9l4l$createMemo)(()=>{
3407
- const sort = current_sorting_[0]();
3408
- return sort?.order === order_value();
3409
- })());
3249
+ (0, $g9l4l$insert)(_el$13, ()=>meta_of_currently_selected_sorting_()?.names?.[index], null);
3250
+ (0, $g9l4l$effect)(()=>_el$14.checked = is_checked());
3410
3251
  return _el$12;
3411
3252
  })();
3412
3253
  }
@@ -3751,20 +3592,177 @@ function $fd7da6fb3e08aa40$export$9bf11afa910f536e({ args_for_sorting_: args_for
3751
3592
 
3752
3593
 
3753
3594
 
3595
+
3596
+ function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
3597
+ let last_remote_state;
3598
+ (0, $g9l4l$createComputed)(()=>{
3599
+ const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
3600
+ JSON.stringify([
3601
+ filter.field,
3602
+ filter.op,
3603
+ filter?.meta?.type
3604
+ ]),
3605
+ filter
3606
+ ]) || []);
3607
+ const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
3608
+ JSON.stringify([
3609
+ filter.field,
3610
+ filter.op,
3611
+ filter?.meta?.type
3612
+ ]),
3613
+ filter
3614
+ ]));
3615
+ const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
3616
+ JSON.stringify([
3617
+ filter_obj.field,
3618
+ filter_obj.op
3619
+ ]),
3620
+ filter_obj
3621
+ ]));
3622
+ const new_local_filter_state = [];
3623
+ // we want to be as close as possible to available_filters_ in local_filters except that we want to keep values from previous available_filters_ as long as they're selected
3624
+ for (const filter_id of [
3625
+ ...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
3626
+ ...Object.keys(remote_filters)
3627
+ ]){
3628
+ const local_filter = local_filters[filter_id];
3629
+ const remote_filter = remote_filters[filter_id];
3630
+ const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
3631
+ if (!remote_filter) // check if this filter is selected, if it is just take the local one but set counts to 0 and remove non-selected options
3632
+ {
3633
+ if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($dd3727f29e682893$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
3634
+ } else if (!local_filter) // just take the remote one
3635
+ new_local_filter_state.push(remote_filter);
3636
+ else {
3637
+ // both exist, merge them if needed
3638
+ const remote_meta = remote_filter.meta;
3639
+ const local_meta = local_filter.meta;
3640
+ const this_applied_filter = selected_filters[filter_id_without_meta_type];
3641
+ if (!remote_meta || !local_meta || !("values" in remote_meta) || !("values" in local_meta) || !Array.isArray(this_applied_filter?.data)) // can't or shouldn't be merged due to not being selected, just take remote one
3642
+ new_local_filter_state.push(remote_filter);
3643
+ else {
3644
+ const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
3645
+ JSON.stringify(value),
3646
+ {
3647
+ value_: value,
3648
+ count_: remote_meta.counts?.[index],
3649
+ name_: remote_meta.names?.[index]
3650
+ }
3651
+ ]));
3652
+ const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
3653
+ JSON.stringify(value),
3654
+ {
3655
+ value_: value,
3656
+ count_: 0,
3657
+ name_: local_meta.names?.[index]
3658
+ }
3659
+ ]));
3660
+ const new_data = [
3661
+ ...Object.keys(data_objs_in_local).filter((key)=>{
3662
+ // put data entries that are selected and don't exist in new remote state first
3663
+ if (key in data_objs_in_remote) return false;
3664
+ const selected_values = this_applied_filter.data;
3665
+ return selected_values.some((value)=>{
3666
+ const is_equal = JSON.stringify(value) === key;
3667
+ if (is_equal) return true;
3668
+ if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
3669
+ // Very special case for hierarchical checkboxes - when a parent has all kids checked and a kid is deselected, the parent gets deselected. But since if it still has selected children we don't want to remove it from the filter state, even though it isn't selected, as the UI won't know the correct title of the parent category otherwise. This keeps it in that case.
3670
+ const selected_values = data_objs_in_local[key].value_;
3671
+ const values_length = value?.length;
3672
+ if (values_length > 1 && values_length - 1 === selected_values.length) {
3673
+ let is_parent = true;
3674
+ for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
3675
+ return is_parent;
3676
+ }
3677
+ }
3678
+ return false;
3679
+ });
3680
+ }).map((key)=>data_objs_in_local[key]),
3681
+ ...Object.values(data_objs_in_remote)
3682
+ ];
3683
+ const new_values = new_data.map(({ value_: value_ })=>value_);
3684
+ const result = {
3685
+ ...remote_filter,
3686
+ meta: {
3687
+ ...remote_filter.meta,
3688
+ values: new_values,
3689
+ names: new_data.map(({ name_: name_ })=>name_),
3690
+ counts: new_data.map(({ count_: count_ })=>count_)
3691
+ }
3692
+ };
3693
+ new_local_filter_state.push(result);
3694
+ }
3695
+ }
3696
+ }
3697
+ if (last_remote_state !== available_filters_() || // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
3698
+ JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
3699
+ write_local_cache(new_local_filter_state);
3700
+ last_remote_state = available_filters_();
3701
+ });
3702
+ }
3703
+ /**
3704
+ * When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
3705
+ * This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
3706
+ */ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
3707
+ const old_meta = local_filter_object.meta;
3708
+ const selected_filter_data = selected_filter.data;
3709
+ const modified_filter_object = {
3710
+ ...local_filter_object
3711
+ };
3712
+ if (old_meta) {
3713
+ const new_meta = {
3714
+ ...old_meta
3715
+ };
3716
+ modified_filter_object.meta = new_meta;
3717
+ // set counts to 0
3718
+ if ("counts" in new_meta) {
3719
+ const counts = new_meta.counts;
3720
+ if (counts) new_meta.counts = counts.map(()=>0);
3721
+ }
3722
+ if (Array.isArray(selected_filter_data) && "values" in new_meta) {
3723
+ // we have an array of values and want to strip the ones from the available ones that aren't selected
3724
+ const values = new_meta.values;
3725
+ if (Array.isArray(values)) {
3726
+ const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
3727
+ const indexes_to_remove = new Set();
3728
+ for(let i = 0; i < values.length; i++){
3729
+ const value = values[i];
3730
+ if (!jsond_set_values.includes(JSON.stringify(value))) // We want to remove the entry with this value from the filter object because it's not selected
3731
+ indexes_to_remove.add(i);
3732
+ }
3733
+ new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
3734
+ if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
3735
+ if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
3736
+ new_meta.counts.length -= indexes_to_remove.size;
3737
+ }
3738
+ }
3739
+ }
3740
+ return modified_filter_object;
3741
+ }
3742
+
3743
+
3754
3744
  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);
3755
3745
  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_ }) {
3756
3746
  return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
3757
3747
  severity_: "error",
3758
3748
  message_: "Sorting and filters failed",
3759
3749
  get children () {
3750
+ // This could technically be in SearchPage and CategoryPage and would be better suited there since it writes into local_filter_cache_ which i.e. SelectedFilters uses, but it's better suited here IMO due to DRY and being inside the correct error boundary here
3751
+ (0, $dd3727f29e682893$export$b288c38ae3fddb56)({
3752
+ available_filters_: available_filters_,
3753
+ selected_filters_: selected_filters_,
3754
+ local_filter_cache_: local_filter_cache_
3755
+ });
3760
3756
  const cleanup_promise = new Promise((r)=>(0, $g9l4l$onCleanup)(r));
3761
3757
  const [filters_open, set_filters_open] = search_filters_open_;
3762
3758
  const [sorting_open, set_sorting_open] = search_sorting_open_;
3759
+ const [get_current_sorting_] = current_sorting_;
3763
3760
  const [is_small, set_is_small] = (0, $g9l4l$createSignal)(false);
3764
3761
  const dismiss_modal_ = (0, $g9l4l$catchify)(()=>{
3765
3762
  set_filters_open(false);
3766
3763
  set_sorting_open(false);
3767
3764
  });
3765
+ const meta_of_currently_selected_sorting_ = (0, $g9l4l$createMemo)(()=>available_sortings_()?.find?.((sorting)=>sorting.field === get_current_sorting_()?.field)?.meta);
3768
3766
  const filter_options = {
3769
3767
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
3770
3768
  local_filter_cache_: local_filter_cache_,
@@ -3775,7 +3773,8 @@ function $bf7fe049e78f975a$export$d7841e452f2e59a8({ current_sorting_: current_s
3775
3773
  };
3776
3774
  const sorting_options = {
3777
3775
  current_sorting_: current_sorting_,
3778
- available_sortings_: available_sortings_
3776
+ available_sortings_: available_sortings_,
3777
+ meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_
3779
3778
  };
3780
3779
  const make_open_filters_button = (adhere_to_width = false, is_tabbable = false)=>(0, $g9l4l$createComponent)($bf7fe049e78f975a$var$OpenFiltersButton, {
3781
3780
  tabindex_: is_tabbable ? 0 : -1,
@@ -3788,11 +3787,12 @@ function $bf7fe049e78f975a$export$d7841e452f2e59a8({ current_sorting_: current_s
3788
3787
  const make_open_sorting_button = (adhere_to_width = false, is_tabbable = false)=>(0, $g9l4l$createComponent)($bf7fe049e78f975a$var$OpenSortingButton, {
3789
3788
  tabindex_: is_tabbable ? 0 : -1,
3790
3789
  i18n_: i18n_,
3791
- current_sorting_: current_sorting_,
3790
+ get_current_sorting_: get_current_sorting_,
3792
3791
  search_filters_open_: search_filters_open_,
3793
3792
  search_sorting_open_: search_sorting_open_,
3794
3793
  available_sortings_: available_sortings_,
3795
- sort_button_width_: adhere_to_width ? sort_button_width_ : undefined
3794
+ sort_button_width_: adhere_to_width ? sort_button_width_ : undefined,
3795
+ meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_
3796
3796
  });
3797
3797
  let open_modal_;
3798
3798
  let close_modal_;
@@ -3920,7 +3920,7 @@ function $bf7fe049e78f975a$var$OpenFiltersButton({ i18n_: i18n_ , search_filters
3920
3920
  return _el$8;
3921
3921
  })();
3922
3922
  }
3923
- function $bf7fe049e78f975a$var$OpenSortingButton({ i18n_: i18n_ , current_sorting_: current_sorting_ , search_filters_open_: search_filters_open_ , available_sortings_: available_sortings_ , search_sorting_open_: search_sorting_open_ , sort_button_width_: sort_button_width_ , tabindex_: tabindex_ }) {
3923
+ function $bf7fe049e78f975a$var$OpenSortingButton({ i18n_: i18n_ , get_current_sorting_: get_current_sorting_ , search_filters_open_: search_filters_open_ , available_sortings_: available_sortings_ , search_sorting_open_: search_sorting_open_ , sort_button_width_: sort_button_width_ , tabindex_: tabindex_ , meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_ }) {
3924
3924
  const sorting_closed = (0, $g9l4l$createMemo)(()=>!search_sorting_open_[0]());
3925
3925
  // We assume in embedded_num_products that this is a single HTMLElement so pls change there if you change it here
3926
3926
  return (()=>{
@@ -3936,7 +3936,7 @@ function $bf7fe049e78f975a$var$OpenSortingButton({ i18n_: i18n_ , current_sortin
3936
3936
  (0, $g9l4l$setAttribute)(_el$12, "tabindex", tabindex_);
3937
3937
  (0, $g9l4l$insert)(_el$13, (()=>{
3938
3938
  const _c$ = (0, $g9l4l$memo)(()=>!!sorting_closed());
3939
- return ()=>_c$() && (current_sorting_[0]()?.meta?.title || available_sortings_()?.[0]?.meta?.title) || i18n_.sorting_text_();
3939
+ return ()=>_c$() && (meta_of_currently_selected_sorting_()?.title || available_sortings_()?.[0]?.meta?.title) || i18n_.sorting_text_();
3940
3940
  })());
3941
3941
  (0, $g9l4l$insert)(_el$12, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
3942
3942
  get when () {
@@ -3946,7 +3946,7 @@ function $bf7fe049e78f975a$var$OpenSortingButton({ i18n_: i18n_ , current_sortin
3946
3946
  return (0, $g9l4l$createComponent)((0, $g9l4l$MinusIcon), {});
3947
3947
  },
3948
3948
  get children () {
3949
- return (0, $g9l4l$memo)(()=>current_sorting_[0]()?.order === "asc")() ? (0, $g9l4l$createComponent)((0, $g9l4l$SortIconAsc), {}) : (0, $g9l4l$createComponent)((0, $g9l4l$SortIconDesc), {});
3949
+ return (0, $g9l4l$memo)(()=>get_current_sorting_()?.order === "asc")() ? (0, $g9l4l$createComponent)((0, $g9l4l$SortIconAsc), {}) : (0, $g9l4l$createComponent)((0, $g9l4l$SortIconDesc), {});
3950
3950
  }
3951
3951
  }), null);
3952
3952
  (0, $g9l4l$effect)((_p$)=>{
@@ -4127,8 +4127,157 @@ function $4a2667e8d77eb55a$var$ActualFloatingButtons({ search_filters_open_: [ge
4127
4127
 
4128
4128
 
4129
4129
 
4130
+
4131
+
4132
+ const $73294c7089bfc7c9$var$operator_map = {
4133
+ "eq": "≡",
4134
+ "neq": "≠",
4135
+ "in": "∈",
4136
+ "nin": "∉",
4137
+ "leq": "≤",
4138
+ "geq": "≥",
4139
+ "inrange": "\uD83D\uDD22"
4140
+ };
4141
+ const $73294c7089bfc7c9$var$sorting_query_param = "sorting";
4142
+ const $73294c7089bfc7c9$var$ascending_token = "\uD83D\uDCC8";
4143
+ const $73294c7089bfc7c9$var$descending_token = "\uD83D\uDCC9";
4144
+ const $73294c7089bfc7c9$var$filter_query_param_prefix = "filter_";
4145
+ const $73294c7089bfc7c9$var$range_delimiter = "-";
4146
+ const $73294c7089bfc7c9$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
4147
+ const $73294c7089bfc7c9$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
4148
+ const $73294c7089bfc7c9$var$empty_item_replacement = "0️⃣";
4149
+ /**
4150
+ * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
4151
+ * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
4152
+ * No deep or mixed nesting levels are supported.
4153
+ */ function $73294c7089bfc7c9$var$array_is_serializable(array, is_root = true) {
4154
+ if (array.every((item)=>Array.isArray(item))) {
4155
+ if (!is_root) // Deeply nested arrays are not supported, but also don't exist as filters (yet)
4156
+ return false;
4157
+ return array.every((item)=>$73294c7089bfc7c9$var$array_is_serializable(item, false));
4158
+ }
4159
+ if (array.some((item)=>typeof item !== "string")) // Numbers are not supported, since 1 and "1" would encode to the same thing
4160
+ return false;
4161
+ // Encoding reserved characters is not supported
4162
+ return !array.some((item)=>item.includes($73294c7089bfc7c9$var$array_item_delimiter) || item.includes($73294c7089bfc7c9$var$string_item_delimiter) || item === $73294c7089bfc7c9$var$empty_item_replacement);
4163
+ }
4164
+ /**
4165
+ * Human readable string[] or string[][] serialization for URLs.
4166
+ * @param array
4167
+ * @returns
4168
+ */ function $73294c7089bfc7c9$var$encode_array(array) {
4169
+ const is_nested = array.every((item)=>Array.isArray(item));
4170
+ if (is_nested) return array.map($73294c7089bfc7c9$var$encode_array).join($73294c7089bfc7c9$var$array_item_delimiter) + $73294c7089bfc7c9$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
4171
+ return array.map((item)=>item === "" ? $73294c7089bfc7c9$var$empty_item_replacement : item).join($73294c7089bfc7c9$var$string_item_delimiter);
4172
+ }
4173
+ function $73294c7089bfc7c9$var$decode_array(encoded_array) {
4174
+ const is_nested = encoded_array.includes($73294c7089bfc7c9$var$array_item_delimiter);
4175
+ if (is_nested) return encoded_array.split($73294c7089bfc7c9$var$array_item_delimiter).filter((s)=>s !== "") // Remove empty segments, caused by trailing delimiter
4176
+ .map($73294c7089bfc7c9$var$decode_array);
4177
+ return encoded_array.split($73294c7089bfc7c9$var$string_item_delimiter).filter((s)=>s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
4178
+ .map((item)=>item === $73294c7089bfc7c9$var$empty_item_replacement ? "" : item);
4179
+ }
4180
+ function $73294c7089bfc7c9$var$encode_filter_data(op, data) {
4181
+ if (data === "true") // boolean encoding
4182
+ return "1";
4183
+ if (data === "false") // boolean encoding
4184
+ return "0";
4185
+ const data_is_array = Array.isArray(data);
4186
+ if (op === "inrange" && data_is_array && data.every((item)=>typeof item === "number")) // numeric range filter encoding
4187
+ return data.join($73294c7089bfc7c9$var$range_delimiter);
4188
+ if (data_is_array && $73294c7089bfc7c9$var$array_is_serializable(data)) {
4189
+ const encoded_data = $73294c7089bfc7c9$var$encode_array(data);
4190
+ if (!encoded_data.includes($73294c7089bfc7c9$var$array_item_delimiter) && !encoded_data.includes($73294c7089bfc7c9$var$string_item_delimiter)) // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
4191
+ // In that case we add a delimiter suffix at the end
4192
+ return encoded_data + $73294c7089bfc7c9$var$string_item_delimiter;
4193
+ return encoded_data;
4194
+ }
4195
+ // Fallback encoding
4196
+ return (0, $g9l4l$compressToBase64)(JSON.stringify(data));
4197
+ }
4198
+ function $73294c7089bfc7c9$var$decode_filter_data(op, encoded_data) {
4199
+ if (encoded_data === "1") return "true";
4200
+ if (encoded_data === "0") return "false";
4201
+ if (op === "inrange" && encoded_data.includes($73294c7089bfc7c9$var$range_delimiter)) return encoded_data.split($73294c7089bfc7c9$var$range_delimiter).map((x)=>parseFloat(x));
4202
+ if (encoded_data.includes($73294c7089bfc7c9$var$string_item_delimiter) || encoded_data.includes($73294c7089bfc7c9$var$array_item_delimiter)) return $73294c7089bfc7c9$var$decode_array(encoded_data);
4203
+ try {
4204
+ return JSON.parse((0, $g9l4l$decompressFromBase64)(encoded_data));
4205
+ } catch (e) {
4206
+ (0, $g9l4l$dlog)("Failed to fallback parse filter data", op, encoded_data, e);
4207
+ }
4208
+ return null;
4209
+ }
4210
+ function $73294c7089bfc7c9$export$58aa3f171519b6d7(filters, search_params) {
4211
+ for (const filter of filters){
4212
+ const { field: field , op: op , data: data } = filter;
4213
+ const encoded_data = $73294c7089bfc7c9$var$encode_filter_data(op, data);
4214
+ search_params.set($73294c7089bfc7c9$var$filter_query_param_prefix + field + $73294c7089bfc7c9$var$operator_map[op], encoded_data);
4215
+ }
4216
+ }
4217
+ function $73294c7089bfc7c9$export$f934fa24c3a86811(search_params) {
4218
+ const found_filters = [];
4219
+ for (const key of search_params.keys()){
4220
+ if (!key.startsWith($73294c7089bfc7c9$var$filter_query_param_prefix)) continue;
4221
+ const encoded_data = search_params.get(key);
4222
+ if (!encoded_data) continue;
4223
+ for (const op of Object.keys($73294c7089bfc7c9$var$operator_map)){
4224
+ const token = $73294c7089bfc7c9$var$operator_map[op];
4225
+ if (!key.endsWith(token)) continue;
4226
+ const data = $73294c7089bfc7c9$var$decode_filter_data(op, encoded_data);
4227
+ if (!data) continue;
4228
+ const field = key.slice($73294c7089bfc7c9$var$filter_query_param_prefix.length, -token.length);
4229
+ found_filters.push({
4230
+ field: field,
4231
+ op: op,
4232
+ data: data
4233
+ });
4234
+ }
4235
+ }
4236
+ return found_filters;
4237
+ }
4238
+ function $73294c7089bfc7c9$export$62acb285a7579555(sorting, search_params) {
4239
+ if (!sorting) return;
4240
+ const { field: field , order: order } = sorting;
4241
+ const ascending = order === "asc";
4242
+ search_params.set($73294c7089bfc7c9$var$sorting_query_param, field + (ascending ? $73294c7089bfc7c9$var$ascending_token : $73294c7089bfc7c9$var$descending_token));
4243
+ }
4244
+ function $73294c7089bfc7c9$export$766e9676e74997d3(search_params) {
4245
+ const encoded_sorting = search_params.get($73294c7089bfc7c9$var$sorting_query_param);
4246
+ if (!encoded_sorting) return;
4247
+ if (encoded_sorting.endsWith($73294c7089bfc7c9$var$ascending_token)) return {
4248
+ field: encoded_sorting.slice(0, -$73294c7089bfc7c9$var$ascending_token.length),
4249
+ order: "asc"
4250
+ };
4251
+ if (encoded_sorting.endsWith($73294c7089bfc7c9$var$descending_token)) return {
4252
+ field: encoded_sorting.slice(0, -$73294c7089bfc7c9$var$descending_token.length),
4253
+ order: "desc"
4254
+ };
4255
+ (0, $g9l4l$dlog)("Invalid sorting query param value", encoded_sorting);
4256
+ return;
4257
+ }
4258
+ function $73294c7089bfc7c9$export$af4a870a0ee262c4(search_params) {
4259
+ // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
4260
+ const keys = [
4261
+ ...search_params.keys()
4262
+ ];
4263
+ for (const key of keys)if (key.startsWith($73294c7089bfc7c9$var$filter_query_param_prefix) || key === $73294c7089bfc7c9$var$sorting_query_param) search_params.delete(key);
4264
+ }
4265
+ const $73294c7089bfc7c9$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
4266
+ function $73294c7089bfc7c9$export$43cd1e747fecd42e(to_url, set_clearing_flag, from_search_params = new URLSearchParams(location.search)) {
4267
+ if (!to_url) return to_url;
4268
+ const was_url_object = to_url instanceof URL;
4269
+ const url_object = was_url_object ? to_url : new URL(to_url);
4270
+ const { searchParams: searchParams } = url_object;
4271
+ if (set_clearing_flag) searchParams.set($73294c7089bfc7c9$export$e2cf3f19dd3f8aac, "true");
4272
+ if (from_search_params.has($73294c7089bfc7c9$var$sorting_query_param)) searchParams.set($73294c7089bfc7c9$var$sorting_query_param, from_search_params.get($73294c7089bfc7c9$var$sorting_query_param));
4273
+ for (const key of from_search_params.keys())if (key.startsWith($73294c7089bfc7c9$var$filter_query_param_prefix)) searchParams.set(key, from_search_params.get(key));
4274
+ if (was_url_object) return url_object;
4275
+ return url_object.href;
4276
+ }
4277
+
4278
+
4130
4279
  const $1b5a927e48d892a1$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<nav class="crumbs"></nav>`, 2), $1b5a927e48d892a1$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="crumb"></a>`, 2), $1b5a927e48d892a1$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="separator"></span>`, 2);
4131
- function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , on_crumb_click_: on_crumb_click_ , i18n_: i18n_ }) {
4280
+ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , router_: router_ , i18n_: i18n_ }) {
4132
4281
  const placeholder_crumb_data = [
4133
4282
  ,
4134
4283
  ,
@@ -4145,6 +4294,7 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4145
4294
  return crumb_data();
4146
4295
  },
4147
4296
  children: (display_accessor, index)=>{
4297
+ const href = (0, $g9l4l$createMemo)(()=>(0, $73294c7089bfc7c9$export$43cd1e747fecd42e)(display_accessor()?.page_url));
4148
4298
  return [
4149
4299
  (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
4150
4300
  get when () {
@@ -4158,9 +4308,13 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4158
4308
  },
4159
4309
  get children () {
4160
4310
  const _el$2 = $1b5a927e48d892a1$var$_tmpl$2.cloneNode(true);
4161
- (0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev, display_accessor())), true);
4311
+ (0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>router_.navigate_.go_to_({
4312
+ new_url_: href(),
4313
+ is_replace_: false,
4314
+ event_: ev
4315
+ })), true);
4162
4316
  (0, $g9l4l$insert)(_el$2, ()=>display_accessor().title);
4163
- (0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href", display_accessor().page_url));
4317
+ (0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href", href()));
4164
4318
  return _el$2;
4165
4319
  }
4166
4320
  }),
@@ -4197,8 +4351,9 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
4197
4351
 
4198
4352
 
4199
4353
 
4354
+
4200
4355
  const $6af87e1502f04aa3$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<nav class="quicklinks"></nav>`, 2), $6af87e1502f04aa3$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div>QuickLinks failed</div>`, 2), $6af87e1502f04aa3$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="quicklink"></a>`, 2);
4201
- function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklinks_data_ , on_link_click_: on_link_click_ , current_query_id_: current_query_id_ , slider_arrow_button_: slider_arrow_button_ , breadcrumb_data_: breadcrumb_data_ , i18n_: i18n_ }) {
4356
+ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklinks_data_ , router_: router_ , current_query_id_: current_query_id_ , slider_arrow_button_: slider_arrow_button_ , breadcrumb_data_: breadcrumb_data_ , i18n_: i18n_ }) {
4202
4357
  let scrolling_logic_ran_for_query_id = false;
4203
4358
  let last_scroll_position;
4204
4359
  let scroll_to_element_on_dom_insertion;
@@ -4321,18 +4476,37 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
4321
4476
  },
4322
4477
  children: (display_accessor, index)=>{
4323
4478
  const is_selected = (0, $g9l4l$createMemo)(()=>selected_index() === index);
4479
+ // Problem: if opening a sibling link in a new tab, filter clearing behavior is no longer consistent
4480
+ // Solution:
4481
+ // If id of current category is in quick links they're siblings, don't add state to the url
4482
+ // If it's not in it, it's a child of the current one, so add state
4483
+ // (This brought up the issue on what happens if someone links to a filter that no longer exists, I chose to ignore that for now)
4484
+ // Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
4485
+ // Solution: instead of not adding the state to the url, add a flag to the link if it's a sibling and then display the toast on load if the flag is set
4486
+ const is_sibling = (0, $g9l4l$createMemo)(()=>{
4487
+ const current_id = current_query_id_();
4488
+ return quicklinks_data_()?.some(({ query_id: query_id })=>query_id === current_id);
4489
+ });
4490
+ const href = (0, $g9l4l$createMemo)(()=>// We don't want these links to delete the sort and filter state by default, only if `clear_filters_when_going_sideways` explicitly clears them
4491
+ (0, $73294c7089bfc7c9$export$43cd1e747fecd42e)(display_accessor()?.page_url, is_sibling()));
4324
4492
  return (()=>{
4325
4493
  const _el$3 = $6af87e1502f04aa3$var$_tmpl$3.cloneNode(true);
4326
4494
  (0, $g9l4l$addEventListener)(_el$3, "click", (0, $g9l4l$catchify)((ev)=>{
4327
- if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button) ev.preventDefault();
4328
- else if (display_accessor()) on_link_click_(ev, display_accessor());
4495
+ const url = href();
4496
+ if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button || !url) // allow open currently selected one in new tab but otherwise prevent clicks
4497
+ ev.preventDefault();
4498
+ else if (href()) router_.navigate_.go_to_({
4499
+ new_url_: url,
4500
+ is_replace_: false,
4501
+ event_: ev
4502
+ });
4329
4503
  }), true);
4330
4504
  (0, $g9l4l$insert)(_el$3, ()=>display_accessor()?.title || (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
4331
4505
  height: "1em",
4332
4506
  width: "10ch"
4333
4507
  }));
4334
4508
  (0, $g9l4l$effect)((_p$)=>{
4335
- const _v$ = !!is_selected(), _v$2 = display_accessor()?.page_url || "javascript:void(0)";
4509
+ const _v$ = !!is_selected(), _v$2 = href();
4336
4510
  _v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
4337
4511
  _v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
4338
4512
  return _p$;
@@ -4359,7 +4533,17 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
4359
4533
 
4360
4534
 
4361
4535
 
4362
- function $2bdb723d3eb0e5b3$export$3fe6942dd2836d9d({ 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_ }) {
4536
+
4537
+ 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_ }) {
4538
+ // If we just got opened in a new tab, clear filters instantly and remove the flag
4539
+ $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
4540
+ plp_results_: plp_results_,
4541
+ local_filter_cache_: local_filter_cache_,
4542
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4543
+ selected_filters_: selected_filters_,
4544
+ i18n_: i18n_
4545
+ });
4546
+ // Code below is for when we're already open and the user navigates to a new category
4363
4547
  let previous_crumb_data = (0, $g9l4l$untrack)(crumb_data_);
4364
4548
  let query_id_when_we_got_previous_data = (0, $g9l4l$untrack)(query_id_);
4365
4549
  let allow_filter_clearing = true; // set to false when going backwards/forwards
@@ -4376,7 +4560,41 @@ function $2bdb723d3eb0e5b3$export$3fe6942dd2836d9d({ crumb_data_: crumb_data_ ,
4376
4560
  const went_downwards = previous_length < new_length;
4377
4561
  const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
4378
4562
  const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
4379
- if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) // We went sideways, not up or down. Clear filters.
4563
+ if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
4564
+ // We went sideways, not up or down. Clear filters.
4565
+ (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4566
+ user_triggered_: false,
4567
+ i18n_: i18n_,
4568
+ also_clear_sorting_: false,
4569
+ selected_filters_: selected_filters_,
4570
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4571
+ local_filter_cache_: local_filter_cache_
4572
+ });
4573
+ // Also ensure we don't have `sideways_url_params_flag` set anymore
4574
+ const url = new URL(location.href);
4575
+ const { searchParams: searchParams } = url;
4576
+ if (searchParams.has((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac))) {
4577
+ searchParams.delete((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac));
4578
+ history.replaceState(history.state, "", url.href);
4579
+ }
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_ }) {
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 url_object = new URL(location.href);
4591
+ const { searchParams: searchParams } = url_object;
4592
+ if (searchParams.get((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac)) !== "true") return;
4593
+ searchParams.delete((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac));
4594
+ history.replaceState(history.state, "", url_object.href);
4595
+ (0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
4596
+ (0, $g9l4l$queueMacroTask)(()=>{
4597
+ // Do it next task so that all the filters have time to populate
4380
4598
  (0, $af89070cc0052779$export$8895d39404bd2bb1)({
4381
4599
  user_triggered_: false,
4382
4600
  i18n_: i18n_,
@@ -4385,11 +4603,9 @@ function $2bdb723d3eb0e5b3$export$3fe6942dd2836d9d({ crumb_data_: crumb_data_ ,
4385
4603
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4386
4604
  local_filter_cache_: local_filter_cache_
4387
4605
  });
4388
- }
4389
- query_id_when_we_got_previous_data = query_id_of_new_data;
4390
- previous_crumb_data = new_crumb_data;
4391
- if (!allow_filter_clearing) allow_filter_clearing = true;
4392
- })));
4606
+ });
4607
+ });
4608
+ tracking_function_for_plp_results(plp_results_);
4393
4609
  }
4394
4610
 
4395
4611
 
@@ -4508,7 +4724,7 @@ let $01115659405f3c64$export$44dad306455dddf;
4508
4724
 
4509
4725
 
4510
4726
  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);
4511
- 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_ , on_category_link_click_: on_category_link_click_ , 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_ , disable_default_tracking_: disable_default_tracking_ = false }) {
4727
+ 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_ }) {
4512
4728
  let results_for;
4513
4729
  let only_show_filters_opener_;
4514
4730
  let middle_elements_;
@@ -4522,8 +4738,7 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4522
4738
  TENANT: (0, $g9l4l$untrack)(tenant_),
4523
4739
  MARKET: (0, $g9l4l$untrack)(market_),
4524
4740
  GA_ID: "",
4525
- get_product_id: get_product_id_,
4526
- pageview_tracking: !disable_default_tracking_
4741
+ get_product_id: get_product_id_
4527
4742
  });
4528
4743
  const [get_sorting] = current_sorting_;
4529
4744
  const number_of_rendered_selected_filters_items_ = (0, $g9l4l$createSignal)(0);
@@ -4683,13 +4898,14 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4683
4898
  selected_filters_: selected_filters_,
4684
4899
  available_filters_: available_filters_
4685
4900
  });
4686
- (0, $2bdb723d3eb0e5b3$export$3fe6942dd2836d9d)({
4901
+ (0, $cb20e79516018342$export$3945d6db2dfd3d12)({
4687
4902
  query_id_: query_id_,
4688
4903
  crumb_data_: crumb_data_,
4689
4904
  i18n_: i18n_,
4690
4905
  selected_filters_: selected_filters_,
4691
4906
  local_filter_cache_: local_filter_cache_,
4692
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
4907
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4908
+ plp_results_: plp_results_
4693
4909
  });
4694
4910
  get_breadcrumb_accessor_?.(crumb_data_);
4695
4911
  get_quicklinks_accessor_?.(quicklinks_data_);
@@ -4702,7 +4918,7 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4702
4918
  get children () {
4703
4919
  return (0, $g9l4l$createComponent)((0, $1b5a927e48d892a1$export$5646050d516e06bc), {
4704
4920
  crumb_data_: crumb_data_,
4705
- on_crumb_click_: on_category_link_click_,
4921
+ router_: router_,
4706
4922
  i18n_: i18n_
4707
4923
  });
4708
4924
  }
@@ -4713,7 +4929,7 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4713
4929
  return (0, $g9l4l$createComponent)((0, $6af87e1502f04aa3$export$466cdc317043f6cb), {
4714
4930
  quicklinks_data_: quicklinks_data_,
4715
4931
  current_query_id_: query_id_,
4716
- on_link_click_: on_category_link_click_,
4932
+ router_: router_,
4717
4933
  slider_arrow_button_: slider_arrow_button_,
4718
4934
  breadcrumb_data_: crumb_data_,
4719
4935
  i18n_: i18n_
@@ -4770,8 +4986,7 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4770
4986
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
4771
4987
  i18n_: i18n_,
4772
4988
  local_filter_cache_: local_filter_cache_
4773
- },
4774
- disable_default_tracking_: disable_default_tracking_
4989
+ }
4775
4990
  });
4776
4991
  }
4777
4992
  }), null);
@@ -4938,6 +5153,166 @@ function $c7f938ac40924f3b$export$23fca46f3143581f(component, error_message) {
4938
5153
  }
4939
5154
 
4940
5155
 
5156
+
5157
+
5158
+
5159
+ function $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7(router) {
5160
+ const current_sorting_ = (0, $g9l4l$createSignal)();
5161
+ const selected_filters_ = (0, $g9l4l$createSignal)([]);
5162
+ const [get_sorting, set_sorting] = current_sorting_;
5163
+ const [get_selected_filters, set_selected_filters] = selected_filters_;
5164
+ const [get_current_href, set_current_href] = (0, $g9l4l$createSignal)(location.href);
5165
+ const history_change_handler = ()=>set_current_href(location.href);
5166
+ const owner = (0, $g9l4l$getOwner)() || (0, $g9l4l$createRoot)(()=>(0, $g9l4l$getOwner)());
5167
+ let writer_started = false;
5168
+ (0, $g9l4l$instant_exec_on_suspect_history_change).add(history_change_handler);
5169
+ (0, $g9l4l$onCleanup)(()=>(0, $g9l4l$instant_exec_on_suspect_history_change).delete(history_change_handler));
5170
+ (0, $g9l4l$createComputed)(()=>{
5171
+ const { searchParams: searchParams } = new URL(get_current_href());
5172
+ (0, $g9l4l$batch)(()=>{
5173
+ const found_sorting = (0, $73294c7089bfc7c9$export$766e9676e74997d3)(searchParams);
5174
+ if (found_sorting) {
5175
+ const current_sorting = (0, $g9l4l$untrack)(get_sorting);
5176
+ // Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
5177
+ if (current_sorting?.field !== found_sorting.field || current_sorting?.order !== found_sorting.order) set_sorting(found_sorting);
5178
+ } else set_sorting();
5179
+ const found_filters = (0, $73294c7089bfc7c9$export$f934fa24c3a86811)(searchParams);
5180
+ const selected_filters = (0, $g9l4l$untrack)(get_selected_filters);
5181
+ const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
5182
+ JSON.stringify([
5183
+ field,
5184
+ op
5185
+ ]),
5186
+ data
5187
+ ]));
5188
+ // Sorry for this diffing algorithm lol. Looking forwards to Records and Tuples.
5189
+ if (selected_filters.length !== found_filters.length || !selected_filters.every(({ field: field , op: op , data: data })=>JSON.stringify(found_filters_map.get(JSON.stringify([
5190
+ field,
5191
+ op
5192
+ ]))) === JSON.stringify(data))) set_selected_filters(found_filters);
5193
+ if (!writer_started) {
5194
+ // 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
5195
+ (0, $g9l4l$runWithOwner)(owner, ()=>$b4291f5d2e6b2fae$var$start_href_writer(get_sorting, get_selected_filters, router));
5196
+ writer_started = true;
5197
+ }
5198
+ });
5199
+ });
5200
+ return {
5201
+ current_sorting_: current_sorting_,
5202
+ selected_filters_: selected_filters_
5203
+ };
5204
+ }
5205
+ /**
5206
+ * Writes the sorting and filters to the URL query parameters when they change.
5207
+ */ function $b4291f5d2e6b2fae$var$start_href_writer(get_sorting, get_selected_filters, router) {
5208
+ // 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)
5209
+ (0, $g9l4l$createComputed)((0, $g9l4l$on)([
5210
+ get_sorting,
5211
+ get_selected_filters
5212
+ ], ([sorting, filters])=>{
5213
+ const current_href = location.href;
5214
+ const url_object = new URL(current_href);
5215
+ const { searchParams: searchParams } = url_object;
5216
+ (0, $73294c7089bfc7c9$export$af4a870a0ee262c4)(searchParams);
5217
+ (0, $73294c7089bfc7c9$export$62acb285a7579555)(sorting, searchParams);
5218
+ (0, $73294c7089bfc7c9$export$58aa3f171519b6d7)(filters, searchParams);
5219
+ // We can't just check if the URL is equal since sometimes the order of the parameters in the URL changes (randomly?) so we need to compare them one by one
5220
+ const unmodified_search_params = [
5221
+ ...new URL(current_href).searchParams
5222
+ ];
5223
+ const new_search_params = [
5224
+ ...searchParams
5225
+ ];
5226
+ // 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
5227
+ const new_search_params_map = new Map(new_search_params);
5228
+ 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
5229
+ router.navigate_.go_to_({
5230
+ is_replace_: true,
5231
+ new_url_: url_object.href,
5232
+ force_spa_navigation_: true
5233
+ });
5234
+ }, {
5235
+ defer: true
5236
+ }));
5237
+ }
5238
+
5239
+
5240
+
5241
+ class $cfa2761d36e5714c$export$7e1297a3a19f10d8 {
5242
+ #forced_default_on_navigation({ is_replace: is_replace , new_url: new_url }) {
5243
+ history[is_replace ? "replaceState" : "pushState"](history.state, "", new_url);
5244
+ }
5245
+ /**
5246
+ * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
5247
+ */ #throwing_on_navigation(...args) {
5248
+ const { on_navigation_: on_navigation_ } = this;
5249
+ if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
5250
+ // make sure that we don't accidentally catchify if the SDK consumer has fucked up
5251
+ try {
5252
+ return on_navigation_(...args);
5253
+ } catch (e) {
5254
+ queueMicrotask(()=>{
5255
+ throw e;
5256
+ });
5257
+ }
5258
+ }
5259
+ /**
5260
+ * Checks if this tab shouldn't navigate because user wants to open in new tab
5261
+ */ #dont_attempt_navigation(ev) {
5262
+ return ev?.button || ev?.metaKey || ev?.ctrlKey;
5263
+ }
5264
+ /**
5265
+ * Vue has async router that needs to be awaited (it navigates after a microtask)
5266
+ * This standardises waiting for all kinds of routers
5267
+ */ #get_navigation_happened_promise(is_replace1) {
5268
+ return new Promise((resolve)=>{
5269
+ const handler = (what_happened)=>{
5270
+ if (what_happened === (is_replace1 ? "replaceState" : "pushState")) {
5271
+ resolve();
5272
+ (0, $g9l4l$instant_exec_on_suspect_history_change).delete(handler);
5273
+ }
5274
+ };
5275
+ (0, $g9l4l$instant_exec_on_suspect_history_change).add(handler);
5276
+ });
5277
+ }
5278
+ navigate_ = {
5279
+ /**
5280
+ * Call this if you *just* want to replace the state object in history.state
5281
+ */ replace_state_: (new_state)=>{
5282
+ // This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
5283
+ history.replaceState(new_state, "");
5284
+ },
5285
+ /**
5286
+ * Call this to change the URL
5287
+ * @param new_url_ new URL to go to
5288
+ * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
5289
+ * @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
5290
+ * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5291
+ */ go_to_: async ({ new_url_: new_url_ , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ })=>{
5292
+ const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5293
+ if (this.#dont_attempt_navigation(event_)) return;
5294
+ if (wants_hard_navigation && !force_spa_navigation_) {
5295
+ if (!event_) // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
5296
+ location.assign(new_url_);
5297
+ return;
5298
+ }
5299
+ event_?.preventDefault();
5300
+ const promise = this.#get_navigation_happened_promise(true);
5301
+ const navigation_function = // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
5302
+ force_spa_navigation_ && wants_hard_navigation ? this.#forced_default_on_navigation : this.#throwing_on_navigation;
5303
+ navigation_function.call(this, {
5304
+ is_replace: is_replace_,
5305
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_)
5306
+ });
5307
+ await promise;
5308
+ }
5309
+ };
5310
+ constructor(on_navigation){
5311
+ this.on_navigation_ = on_navigation;
5312
+ }
5313
+ }
5314
+
5315
+
4941
5316
  const $ec52ef1e6c117813$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"></div>`, 2);
4942
5317
  const $ec52ef1e6c117813$var$min_products_to_fetch_ = 20;
4943
5318
  const $ec52ef1e6c117813$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
@@ -4948,6 +5323,7 @@ const $ec52ef1e6c117813$var$InExternalAreaDiv = ({ children: children })=>(()=>
4948
5323
  return _el$;
4949
5324
  })();
4950
5325
  class $ec52ef1e6c117813$export$f34314aa9505732e {
5326
+ #router = new (0, $cfa2761d36e5714c$export$7e1297a3a19f10d8)("hard_navigation");
4951
5327
  #locale_signal = (0, $g9l4l$createSignal)();
4952
5328
  #merchant_signal = (0, $g9l4l$createSignal)();
4953
5329
  #market_signal = (0, $g9l4l$createSignal)();
@@ -4978,38 +5354,30 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
4978
5354
  set market(market) {
4979
5355
  this.#market_signal[1](market);
4980
5356
  }
5357
+ get on_navigation() {
5358
+ // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
5359
+ return this.#router.on_navigation_;
5360
+ }
5361
+ set on_navigation(new_function) {
5362
+ this.#router.on_navigation_ = new_function;
5363
+ }
4981
5364
  constructor({ api: api , on_navigation: on_navigation , ...props_on_class }){
4982
5365
  if ($ec52ef1e6c117813$export$f34314aa9505732e.#has_been_constructed) throw new Error("You can only have one instance of DepictCategory due to state limitations");
4983
5366
  $ec52ef1e6c117813$export$f34314aa9505732e.#has_been_constructed = true;
4984
5367
  Object.assign(this, props_on_class); // set initial signal values
4985
5368
  (0, $2864fd26f57ff474$export$5162a71f252e6122)();
5369
+ if (on_navigation) this.#router.on_navigation_ = on_navigation;
5370
+ const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7)(this.#router);
4986
5371
  const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
4987
- category_sorting: undefined,
4988
5372
  category_filters_open: false,
4989
5373
  category_sorting_open: false,
4990
5374
  category_expanded_filters: [],
4991
- // WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters and we'll end up with too few filters in search_local_filter_cache in some cases
4992
- category_selected_filters: [],
5375
+ // Please make sure that the signal created by below line always updates AFTER selected_filters_ updates on a "popstate" event. If the filter cache is popped before the selected filters are the code in create_modified_filters() is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters, and we'll end up with too few filters in search_local_filter_cache in some cases
4993
5376
  category_local_filter_cache: [],
4994
5377
  category_expanded_hierarchical_filters: [],
4995
5378
  category_scroll_restoration_data: []
4996
5379
  }));
4997
5380
  const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
4998
- const on_category_link_click_ = (e, d)=>{
4999
- if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
5000
- return;
5001
- try {
5002
- const url_object = new URL(d.page_url);
5003
- const relative_url = url_object.pathname + url_object.search + url_object.hash;
5004
- on_navigation(relative_url, e, d);
5005
- e.preventDefault();
5006
- } catch (e) {
5007
- queueMicrotask(()=>{
5008
- // make sure to throw into the global scope if on_navigation throws
5009
- throw e;
5010
- });
5011
- }
5012
- };
5013
5381
  $ec52ef1e6c117813$var$privately_shared_properties.set(this, {
5014
5382
  state_: state_,
5015
5383
  breadcrumb_signal_: (0, $g9l4l$createSignal)(),
@@ -5017,7 +5385,9 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5017
5385
  i18n_: i18n_,
5018
5386
  reset_history_state_: reset_history_state_,
5019
5387
  depict_api_: api ?? new (0, $3846bb34098c738f$export$e015ed2f2950f2e3)(),
5020
- on_category_link_click_: on_category_link_click_,
5388
+ router_: this.#router,
5389
+ selected_filters_: selected_filters_,
5390
+ current_sorting_: current_sorting_,
5021
5391
  slider_arrow_button_: (0, $g9l4l$GenericSliderArrowButton)({
5022
5392
  height_: 12,
5023
5393
  width_: 6.46
@@ -5025,7 +5395,7 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
5025
5395
  });
5026
5396
  }
5027
5397
  }
5028
- 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 , disable_default_tracking: disable_default_tracking = false }) {
5398
+ 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 }) {
5029
5399
  const shared_properties = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
5030
5400
  const grid_spacing_override = typeof grid_spacing === "string" ? {
5031
5401
  grid_spacing: grid_spacing
@@ -5034,7 +5404,7 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
5034
5404
  grid_spacing: grid_spacing.horizontal
5035
5405
  };
5036
5406
  return (0, $c7f938ac40924f3b$export$23fca46f3143581f)(()=>{
5037
- const { state_: { category_local_filter_cache: local_filter_cache_ , category_sorting: current_sorting_ , category_filters_open: category_filters_open_ , category_sorting_open: category_sorting_open_ , category_expanded_filters: expanded_filters_ , category_expanded_hierarchical_filters: expanded_hierarchical_filters_ , category_selected_filters: selected_filters_ , category_scroll_restoration_data: scroll_restoration_data_ } , reset_history_state_: reset_history_state_ , depict_api_: depict_api_ , i18n_: i18n_ , on_category_link_click_: on_category_link_click_ , breadcrumb_signal_: breadcrumb_signal_ , quicklinks_signal_: quicklinks_signal_ , slider_arrow_button_: slider_arrow_button_ } = shared_properties;
5407
+ const { state_: { category_local_filter_cache: local_filter_cache_ , category_filters_open: category_filters_open_ , category_sorting_open: category_sorting_open_ , category_expanded_filters: expanded_filters_ , category_expanded_hierarchical_filters: expanded_hierarchical_filters_ , category_scroll_restoration_data: scroll_restoration_data_ } , current_sorting_: current_sorting_ , selected_filters_: selected_filters_ , reset_history_state_: reset_history_state_ , depict_api_: depict_api_ , i18n_: i18n_ , router_: router_ , breadcrumb_signal_: breadcrumb_signal_ , quicklinks_signal_: quicklinks_signal_ , slider_arrow_button_: slider_arrow_button_ } = shared_properties;
5038
5408
  (0, $g9l4l$onCleanup)(reset_history_state_);
5039
5409
  return (0, $1ae892b13d7746ab$export$f7d2f673fc2f091d)({
5040
5410
  tenant_: ()=>depict_category.merchant,
@@ -5048,7 +5418,7 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
5048
5418
  category_title_: category_title,
5049
5419
  show_breadcrumbs_: show_breadcrumbs,
5050
5420
  current_sorting_: current_sorting_,
5051
- on_category_link_click_: on_category_link_click_,
5421
+ router_: router_,
5052
5422
  get_breadcrumb_accessor_: (accessor)=>(0, $g9l4l$createComputed)(()=>breadcrumb_signal_[1](accessor())),
5053
5423
  get_quicklinks_accessor_: (accessor)=>(0, $g9l4l$createComputed)(()=>quicklinks_signal_[1](accessor())),
5054
5424
  category_filters_open_: category_filters_open_,
@@ -5068,31 +5438,30 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
5068
5438
  const is_placeholder = info.rendering_options.type === "placeholder";
5069
5439
  return product_card_template(is_placeholder ? null : display, info);
5070
5440
  }
5071
- },
5072
- disable_default_tracking_: disable_default_tracking
5441
+ }
5073
5442
  });
5074
5443
  }, "Entire CategoryPage failed");
5075
5444
  }
5076
5445
  function $ec52ef1e6c117813$export$5b7c3ce0ebe51f86({ depict_category: depict_category }) {
5077
- const { i18n_: i18n_ , breadcrumb_signal_: [crumb_data_] , on_category_link_click_: on_crumb_click_ } = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
5446
+ const { i18n_: i18n_ , breadcrumb_signal_: [crumb_data_] , router_: router_ } = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
5078
5447
  return (0, $g9l4l$createComponent)($ec52ef1e6c117813$var$InExternalAreaDiv, {
5079
5448
  get children () {
5080
5449
  return (0, $1b5a927e48d892a1$export$5646050d516e06bc)({
5081
5450
  i18n_: i18n_,
5082
5451
  crumb_data_: crumb_data_,
5083
- on_crumb_click_: on_crumb_click_
5452
+ router_: router_
5084
5453
  });
5085
5454
  }
5086
5455
  });
5087
5456
  }
5088
5457
  function $ec52ef1e6c117813$export$de035477d6fef996({ depict_category: depict_category }) {
5089
- const { i18n_: i18n_ , quicklinks_signal_: [quicklinks_data_] , breadcrumb_signal_: [breadcrumb_data_] , on_category_link_click_: on_link_click_ , slider_arrow_button_: slider_arrow_button_ } = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
5458
+ const { i18n_: i18n_ , quicklinks_signal_: [quicklinks_data_] , breadcrumb_signal_: [breadcrumb_data_] , router_: router_ , slider_arrow_button_: slider_arrow_button_ } = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
5090
5459
  return (0, $g9l4l$createComponent)($ec52ef1e6c117813$var$InExternalAreaDiv, {
5091
5460
  get children () {
5092
5461
  return (0, $6af87e1502f04aa3$export$466cdc317043f6cb)({
5093
5462
  i18n_: i18n_,
5094
5463
  quicklinks_data_: quicklinks_data_,
5095
- on_link_click_: on_link_click_,
5464
+ router_: router_,
5096
5465
  current_query_id_: ()=>depict_category.category_id,
5097
5466
  slider_arrow_button_: slider_arrow_button_,
5098
5467
  breadcrumb_data_: breadcrumb_data_
@@ -5321,17 +5690,14 @@ function $aaacfac0064e97d9$export$ee1733d9a8495996() {
5321
5690
 
5322
5691
 
5323
5692
  const $7a7079d66c12b788$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="parent-title"></span>`, 2), $7a7079d66c12b788$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="category-suggestion"><span class="title"></span></a>`, 4);
5324
- function $7a7079d66c12b788$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ , on_navigation_: on_navigation_ }) {
5693
+ function $7a7079d66c12b788$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ , router_: router_ }) {
5325
5694
  return (()=>{
5326
5695
  const _el$ = $7a7079d66c12b788$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild;
5327
- (0, $g9l4l$addEventListener)(_el$, "click", (0, $g9l4l$catchify)((e)=>{
5328
- if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
5329
- return;
5330
- if (on_navigation_) {
5331
- e.preventDefault();
5332
- return on_navigation_(category_suggestion_().page_url);
5333
- }
5334
- }), true);
5696
+ (0, $g9l4l$addEventListener)(_el$, "click", (0, $g9l4l$catchify)((e)=>router_.navigate_.go_to_({
5697
+ new_url_: category_suggestion_().page_url,
5698
+ is_replace_: false,
5699
+ event_: e
5700
+ })), true);
5335
5701
  (0, $g9l4l$insert)(_el$2, ()=>category_suggestion_().title);
5336
5702
  (0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
5337
5703
  get when () {
@@ -5409,13 +5775,14 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
5409
5775
  if (disabled_) // just in case. The field not actually being disabled when being disabled_ is so that you can focus it and open the modal. We don't want any of the other input-field-interaction features to work
5410
5776
  return;
5411
5777
  if (input_element.selectionStart === 0 && input_element.selectionEnd === input_element.value.length) // everything was selected, clear filters on next submit on next input
5412
- input_element.addEventListener("input", (0, $g9l4l$catchify)(clear_filters_), {
5778
+ input_element.addEventListener("input", (0, $g9l4l$catchify)(()=>clear_filters_(false)), // We don't count this as user triggered since it wasn't explicit
5779
+ {
5413
5780
  once: true
5414
5781
  });
5415
5782
  }));
5416
5783
  (0, $g9l4l$addEventListener)(_el$4, "input", (0, $g9l4l$catchify)(()=>{
5417
5784
  const { value: value } = input_element;
5418
- if (!disabled_ && !value.length) clear_filters_(); // if the user clears the whole field, reset filters on next submit
5785
+ if (!disabled_ && !value.length) clear_filters_(false); // if the user clears the whole field, reset filters on next submit
5419
5786
  search_field_value_[1](value);
5420
5787
  }), true);
5421
5788
  (0, $g9l4l$addEventListener)(_el$4, "keydown", (0, $g9l4l$catchify)((e)=>{
@@ -5435,7 +5802,7 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
5435
5802
  _el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
5436
5803
  (0, $g9l4l$addEventListener)(_el$5, "click", (0, $g9l4l$catchify)(()=>{
5437
5804
  search_field_value_[1]("");
5438
- clear_filters_();
5805
+ clear_filters_(true);
5439
5806
  if (!disabled_) input_element.focus();
5440
5807
  }), true);
5441
5808
  (0, $g9l4l$insert)(_el$5, (0, $g9l4l$createComponent)((0, $g9l4l$CrossIcon), {}));
@@ -5477,7 +5844,7 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
5477
5844
 
5478
5845
  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);
5479
5846
  const $aee0c68312d971f4$export$1c8c715550dc689d = 2;
5480
- 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_ , disable_default_tracking_: disable_default_tracking_ }) {
5847
+ 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_ }) {
5481
5848
  const [is_showing_something, set_is_showing_something] = (0, $g9l4l$createSignal)(false);
5482
5849
  const cards = $aee0c68312d971f4$var$_tmpl$.cloneNode(true);
5483
5850
  const on_next_render = [];
@@ -5545,9 +5912,7 @@ function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
5545
5912
  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
5546
5913
  // @ts-ignore
5547
5914
  rr_options_.template(...args))
5548
- } : {},
5549
- view_tracking: disable_default_tracking_ ? [] : undefined,
5550
- click_tracking: disable_default_tracking_ ? [] : undefined
5915
+ } : {}
5551
5916
  });
5552
5917
  const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
5553
5918
  let dead = false;
@@ -5655,27 +6020,27 @@ function $079defea521d5e2a$export$b3ad617e9036868(modal_body_style, input_field,
5655
6020
 
5656
6021
 
5657
6022
  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_ }) {
5658
- const [get_selected_filters, set_selected_filters] = selected_filters_;
5659
- const clear_filters_next_submit_ = (0, $g9l4l$createSignal)(false); // we store this here (and not in history.state) (maybe there's a better place) because it's a very temporary thing. I.e. as soon as anything breaks the "flow of intent" to make a new search we want this reset
6023
+ const [get_selected_filters] = selected_filters_;
6024
+ // Possible values:
6025
+ // 0 - we should not clear next submit
6026
+ // 1 - we should clear next submit due to internal heuristics
6027
+ // 2 - we should clear next submit due to EXPLICIT user action (i.e. clear button pressed)
6028
+ const clear_filters_next_submit_ = (0, $g9l4l$createSignal)(0); // we store this here (and not in history.state) (maybe there's a better place) because it's a very temporary thing. I.e. as soon as anything breaks the "flow of intent" to make a new search we want this reset
5660
6029
  const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
5661
- const clear_filters = ()=>set_clear_filters_next_submit(true);
6030
+ const clear_filters = (user_triggered)=>set_clear_filters_next_submit(user_triggered ? 2 : 1);
5662
6031
  (0, $g9l4l$createComputed)((0, $g9l4l$on)(get_selected_filters, ()=>{
5663
6032
  // if the selected filters update, clear the clearing signal
5664
- set_clear_filters_next_submit(false);
6033
+ set_clear_filters_next_submit(0);
5665
6034
  }, {
5666
6035
  defer: true
5667
6036
  }));
5668
6037
  (0, $g9l4l$createComputed)((0, $g9l4l$on)(get_search_query, (0, $g9l4l$catchify)(()=>{
5669
6038
  // when a query was submitted, clear filters if clear was pressed before
5670
- if ((0, $g9l4l$untrack)(get_clear_filters_next_submit)) {
5671
- set_clear_filters_next_submit(false);
5672
- set_selected_filters([]);
5673
- // also collapse expanded filters in hierarchical filter tree again
5674
- expanded_hierarchical_filters_[1]([]);
5675
- // also clear sorting
5676
- current_sorting_[1](undefined);
6039
+ const clear_value = (0, $g9l4l$untrack)(get_clear_filters_next_submit);
6040
+ if (clear_value) {
6041
+ set_clear_filters_next_submit(0);
5677
6042
  (0, $af89070cc0052779$export$8895d39404bd2bb1)({
5678
- user_triggered_: true,
6043
+ user_triggered_: clear_value === 2,
5679
6044
  selected_filters_: selected_filters_,
5680
6045
  i18n_: i18n_,
5681
6046
  also_clear_sorting_: true,
@@ -5720,26 +6085,8 @@ function $4d62f5daa51642fe$export$84bba84a7b837187(search_query) {
5720
6085
 
5721
6086
 
5722
6087
 
5723
- /**
5724
- * Calls history.pushState wiht the current url BUT the query parameter with name url_param_name has been set to value (or deleted if no value is provided) and url_transformer has been executed on the URL object that we're pushing
5725
- */ function $972ebf2641490830$export$26df08e242fe83a3(url_param_name, value, url_transformer) {
5726
- $972ebf2641490830$var$set_param(false, url_param_name, value, url_transformer);
5727
- }
5728
- function $972ebf2641490830$export$7a053411c76081d8(url_param_name, value, url_transformer) {
5729
- $972ebf2641490830$var$set_param(true, url_param_name, value, url_transformer);
5730
- }
5731
- function $972ebf2641490830$var$set_param(replace, url_param_name, value, url_transformer) {
5732
- const u_o = new URL(location.href);
5733
- url_transformer?.(u_o);
5734
- const { searchParams: searchParams } = u_o;
5735
- if (value !== undefined) searchParams.set(url_param_name, value);
5736
- else searchParams.delete(url_param_name);
5737
- history[replace ? "replaceState" : "pushState"](history.state, "", u_o.href);
5738
- }
5739
-
5740
-
5741
- function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , search_field_value_: [read_field_value, write_field_value] , search_query_: [read_search_query] , url_transformer_: url_transformer_ , on_submit_: on_submit_ = (0, $972ebf2641490830$export$26df08e242fe83a3) , after_submit_: after_submit_ }) {
5742
- const new_search_query = (0, $g9l4l$untrack)(read_field_value);
6088
+ 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 }) {
6089
+ const new_search_query = get_new_query();
5743
6090
  const previous_query = (0, $g9l4l$untrack)(read_search_query);
5744
6091
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
5745
6092
  // don't push a history entry / re-search if someone submits a search again
@@ -5747,9 +6094,16 @@ function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchanged_va
5747
6094
  on_submit_with_unchanged_value_?.();
5748
6095
  return;
5749
6096
  }
5750
- write_field_value(previous_query); // restore the value to the previous query since this one goes to the new history entry
5751
- on_submit_(search_param_name_, new_search_query, url_transformer_);
5752
- write_field_value(new_search_query);
6097
+ set_search_field_value_(previous_query); // restore the value to the previous query since this one goes to the new history entry
6098
+ const target_url = new URL(location.href);
6099
+ url_transformer_?.(target_url);
6100
+ target_url.searchParams.set(search_param_name_, new_search_query);
6101
+ await router_.navigate_.go_to_({
6102
+ new_url_: target_url,
6103
+ is_replace_: false,
6104
+ force_spa_navigation_: true
6105
+ });
6106
+ set_search_field_value_(new_search_query);
5753
6107
  scrollTo(0, 0);
5754
6108
  after_submit_?.();
5755
6109
  }
@@ -5758,6 +6112,8 @@ function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchanged_va
5758
6112
 
5759
6113
 
5760
6114
  function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
6115
+ // TODO: remove this abstraction, put it in same place as filters
6116
+ // TODO: make it only return an accessor
5761
6117
  const signals = {};
5762
6118
  const entries = Object.entries(params_to_default_value);
5763
6119
  for (const [param, default_value] of entries)signals[param] = (0, $g9l4l$createSignal)(default_value ?? "");
@@ -5797,8 +6153,8 @@ function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
5797
6153
 
5798
6154
 
5799
6155
 
5800
- /**
5801
- * Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
6156
+ /**
6157
+ * Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
5802
6158
  */ const $589fd8dc82a78e48$export$27b710c08412a7ad = (obj)=>{
5803
6159
  return Object.fromEntries(Object.keys(obj).map((key)=>[
5804
6160
  key,
@@ -5997,6 +6353,7 @@ function $d811ce622b5b7626$var$track_elements(display, index, elements, tenant,
5997
6353
  click_location: type + "_" + (index + 1),
5998
6354
  recommendation_type: type
5999
6355
  });
6356
+ localStorage.setItem(`depict_attribution_${d.product_id}`, d.search_result_id);
6000
6357
  };
6001
6358
  while(disconnectors.length)// disconnect stuff from old display
6002
6359
  disconnectors.pop()();
@@ -6087,47 +6444,26 @@ function $ced3551536e52fa1$export$50b90be27d8502d9(el, [get_style_props, set_sty
6087
6444
 
6088
6445
 
6089
6446
 
6090
- function $8fee64e5ff6fd014$export$91c3b6774e8be0f5({ param_: param_ , value_: value_ , url_transformer_: url_transformer_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , set_search_field_value_: set_search_field_value_ , get_search_query_: get_search_query_ , after_submit_: after_submit_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ }) {
6091
- const [read_link, write_link] = (0, $g9l4l$createSignal)();
6447
+ function $8fee64e5ff6fd014$export$91c3b6774e8be0f5({ param_: param_ , value_: value_ , url_transformer_: url_transformer_ }) {
6448
+ const [get_current_href, set_current_href] = (0, $g9l4l$createSignal)(location.href);
6092
6449
  const [exit_iterable, exitable_iterable] = (0, $g9l4l$make_asyncIterable_exiter)((0, $g9l4l$href_change_ipns));
6093
6450
  (0, $g9l4l$onCleanup)(exit_iterable);
6094
6451
  (0, $g9l4l$catchify)(async ()=>{
6095
- for await (const href of exitable_iterable){
6096
- // use native links so ppl can cmdclick/right click and open in new tab and see target URL
6097
- const u_o = new URL(href);
6098
- url_transformer_?.(u_o);
6099
- u_o.searchParams.set(param_, value_);
6100
- write_link(u_o.href);
6101
- }
6452
+ for await (const href of exitable_iterable)// use native links so ppl can cmdclick/right click and open in new tab and see target URL
6453
+ set_current_href(href);
6102
6454
  })();
6103
- const on_click_handler_ = (e)=>{
6104
- if (e.button || e.metaKey || e.ctrlKey) // not button 0 or cmd/ctrl click
6105
- return;
6106
- e.preventDefault();
6107
- if (new URLSearchParams(location.search).get(param_) === value_) {
6108
- // don't do anything if we're already searching for this
6109
- on_submit_with_unchanged_value_?.();
6110
- return;
6111
- }
6112
- set_search_field_value_((0, $g9l4l$untrack)(get_search_query_)); // fill in old query in previous history entry before making new one, like we do in submit_query
6113
- if (typeof alternative_query_submitter_for_spas_ === "function") alternative_query_submitter_for_spas_(param_, value_, url_transformer_);
6114
- else {
6115
- history.pushState(history.state, "", (0, $g9l4l$untrack)((0, $g9l4l$catchify)(()=>read_link())));
6116
- scrollTo(0, 0);
6117
- }
6118
- set_search_field_value_(value_);
6119
- after_submit_?.();
6120
- };
6121
- return {
6122
- read_link_: read_link,
6123
- on_click_handler_: on_click_handler_
6124
- };
6455
+ return (0, $g9l4l$createMemo)(()=>{
6456
+ const u_o = new URL(get_current_href());
6457
+ url_transformer_?.(u_o);
6458
+ u_o.searchParams.set(param_, value_());
6459
+ return u_o.href;
6460
+ });
6125
6461
  }
6126
6462
 
6127
6463
 
6128
6464
 
6129
6465
  const $dd44dd5f5011ac6f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="previous-searches"><h2 class="text"></h2><div class="list"></div></div>`, 6), $dd44dd5f5011ac6f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="item"><div class="left"><span></span></div><button class="delete"></button></a>`, 8);
6130
- function $dd44dd5f5011ac6f$export$a146ac6fa8346a25({ text_: text_ , previous_searches_: previous_searches_ , search_query_param_name_: search_query_param_name_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_unfiltered_previous_searches_: set_unfiltered_previous_searches_ , search_field_value_: search_field_value_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , i18n_: i18n_ , get_search_query_: get_search_query_ , after_submit_: after_submit_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ }) {
6466
+ function $dd44dd5f5011ac6f$export$a146ac6fa8346a25({ text_: text_ , previous_searches_: previous_searches_ , search_query_param_name_: search_query_param_name_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_unfiltered_previous_searches_: set_unfiltered_previous_searches_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , i18n_: i18n_ , submit_query_: submit_query_ }) {
6131
6467
  const has_entries = (0, $g9l4l$createMemo)(()=>previous_searches_().length >= 1);
6132
6468
  currently_showing_suggestions_[1]((value)=>{
6133
6469
  value[0] = (0, $g9l4l$createMemo)(()=>previous_searches_().map((result)=>({
@@ -6153,20 +6489,20 @@ function $dd44dd5f5011ac6f$export$a146ac6fa8346a25({ text_: text_ , previous_sea
6153
6489
  return previous_searches_();
6154
6490
  },
6155
6491
  children: (item, index)=>{
6156
- const param_change_obj = (0, $g9l4l$createMemo)(()=>(0, $8fee64e5ff6fd014$export$91c3b6774e8be0f5)({
6157
- param_: search_query_param_name_,
6158
- value_: item(),
6159
- url_transformer_: url_transformer_,
6160
- alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
6161
- set_search_field_value_: search_field_value_[1],
6162
- get_search_query_: get_search_query_,
6163
- after_submit_: after_submit_,
6164
- on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
6165
- }));
6492
+ const href = (0, $8fee64e5ff6fd014$export$91c3b6774e8be0f5)({
6493
+ param_: search_query_param_name_,
6494
+ value_: item,
6495
+ url_transformer_: url_transformer_
6496
+ });
6166
6497
  return (()=>{
6167
6498
  const _el$4 = $dd44dd5f5011ac6f$var$_tmpl$2.cloneNode(true), _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$7 = _el$5.nextSibling;
6168
6499
  (0, $g9l4l$use)((element)=>element.addEventListener(// Viskan's Oscar Jacobson site requires us to add the event listener normally here. They do too much when this element is clicked. We work around it by blocking the event and just dispatching it non-bubbling on this element.
6169
- "click", (0, $g9l4l$catchify)((e)=>param_change_obj().on_click_handler_(e))), _el$4);
6500
+ "click", (0, $g9l4l$catchify)((ev)=>{
6501
+ if (ev.button || ev.metaKey || ev.ctrlKey) // not button 0 or cmd/ctrl click
6502
+ return;
6503
+ ev.preventDefault();
6504
+ submit_query_(item());
6505
+ })), _el$4);
6170
6506
  (0, $g9l4l$addEventListener)(_el$4, "mouseleave", (0, $g9l4l$catchify)(()=>write_selected_index_(undefined)));
6171
6507
  (0, $g9l4l$addEventListener)(_el$4, "mouseenter", (0, $g9l4l$catchify)(()=>write_selected_index_([
6172
6508
  0,
@@ -6191,7 +6527,7 @@ function $dd44dd5f5011ac6f$export$a146ac6fa8346a25({ text_: text_ , previous_sea
6191
6527
  })), _el$7);
6192
6528
  (0, $g9l4l$insert)(_el$7, (0, $g9l4l$createComponent)((0, $g9l4l$CrossIcon), {}));
6193
6529
  (0, $g9l4l$effect)((_p$)=>{
6194
- const _v$ = !!(0, $g9l4l$createMemo)(()=>read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)(), _v$2 = param_change_obj().read_link_(), _v$3 = i18n_.previous_searches_delete_entry_from_history_();
6530
+ const _v$ = !!(0, $g9l4l$createMemo)(()=>read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)(), _v$2 = href(), _v$3 = i18n_.previous_searches_delete_entry_from_history_();
6195
6531
  _v$ !== _p$._v$ && _el$4.classList.toggle("selected", _p$._v$ = _v$);
6196
6532
  _v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$4, "href", _p$._v$2 = _v$2);
6197
6533
  _v$3 !== _p$._v$3 && (0, $g9l4l$setAttribute)(_el$7, "title", _p$._v$3 = _v$3);
@@ -6290,41 +6626,34 @@ function $54eb3ff8b0c7c7b8$export$ba17c5b7e6dda39f({ whole_text_to_display_: who
6290
6626
 
6291
6627
 
6292
6628
  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);
6293
- function $f19e81a7eecb0aac$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ , search_field_value_: search_field_value_ , 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_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , searching_for_value_: searching_for_value_ , get_search_query_: get_search_query_ , after_submit_: after_submit_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ }) {
6629
+ 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_ }) {
6294
6630
  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
6295
6631
  ));
6296
6632
  const not_queries_memo = (0, $g9l4l$createMemo)(()=>suggestion_memo_().filter(({ type: type })=>type !== (0, $c7bc9269d29d4bdc$export$3cf9497e790da491)));
6297
6633
  const render_entry = (input_obj, autocomplete_data_index, index, is_history = false)=>{
6298
6634
  const is_query = (0, $g9l4l$createMemo)(()=>input_obj().type === (0, $c7bc9269d29d4bdc$export$3cf9497e790da491));
6299
- const param_change_obj = (0, $g9l4l$createMemo)(()=>is_query() ? (0, $8fee64e5ff6fd014$export$91c3b6774e8be0f5)({
6635
+ const href_with_changed_params_accessor = (0, $g9l4l$createMemo)(()=>is_query() ? (0, $8fee64e5ff6fd014$export$91c3b6774e8be0f5)({
6300
6636
  param_: search_page_url_param_name_,
6301
- value_: input_obj().title,
6302
- url_transformer_: url_transformer_,
6303
- alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
6304
- get_search_query_: get_search_query_,
6305
- set_search_field_value_: search_field_value_[1],
6306
- after_submit_: after_submit_,
6307
- on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
6637
+ value_: (0, $g9l4l$createMemo)(()=>input_obj().title),
6638
+ url_transformer_: url_transformer_
6308
6639
  }) : undefined);
6309
- const [href, set_href] = (0, $g9l4l$createSignal)();
6310
- (0, $g9l4l$createComputed)(()=>{
6311
- const new_href = is_query() ? param_change_obj().read_link_() : input_obj().page_url;
6312
- // href will first show up in a tick from input_obj() updating, we don't want to assign undefined in the meantime
6313
- if (new_href) set_href(new_href);
6314
- });
6640
+ const href = (0, $g9l4l$createMemo)(()=>is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
6315
6641
  return (()=>{
6316
6642
  const _el$ = $f19e81a7eecb0aac$var$_tmpl$.cloneNode(true);
6317
6643
  (0, $g9l4l$use)((element)=>element.addEventListener("click", (0, $g9l4l$catchify)((ev)=>{
6318
6644
  // Viskan's Oscar Jacobson site requires us to add the event listener normally here. They do too much when this element is clicked. We work around it by blocking the event and just dispatching it non-bubbling on this element.
6319
- if (is_query()) return param_change_obj().on_click_handler_(ev);
6320
- else if (navigate_page_to_href_) {
6321
- // single page navigate to category suggestions if enabled
6322
- // object should have a href where we want to go
6645
+ if (is_query()) {
6323
6646
  if (ev.button || ev.metaKey || ev.ctrlKey) // not button 0 or cmd/ctrl click
6324
6647
  return;
6325
6648
  ev.preventDefault();
6326
- navigate_page_to_href_(input_obj().page_url);
6649
+ submit_query_(input_obj().title);
6650
+ return;
6327
6651
  }
6652
+ router_.navigate_.go_to_({
6653
+ new_url_: input_obj().page_url,
6654
+ is_replace_: false,
6655
+ event_: ev
6656
+ });
6328
6657
  })), _el$);
6329
6658
  (0, $g9l4l$addEventListener)(_el$, "mouseleave", (0, $g9l4l$catchify)(()=>write_selected_index_(undefined)));
6330
6659
  (0, $g9l4l$addEventListener)(_el$, "mouseenter", (0, $g9l4l$catchify)(()=>write_selected_index_([
@@ -6549,6 +6878,7 @@ function $a817d06dc1c5911c$export$217899a935ef803b({ selected_index_: [read_sele
6549
6878
  }
6550
6879
  };
6551
6880
  // TODO: if selected item stops existing, remove it
6881
+ // Is above actually not done???
6552
6882
  $a817d06dc1c5911c$var$actual_navigation_working_on_fake_data({
6553
6883
  ...rest_of_props,
6554
6884
  last_suggestion_index_: last_suggestion_index_,
@@ -6556,7 +6886,7 @@ function $a817d06dc1c5911c$export$217899a935ef803b({ selected_index_: [read_sele
6556
6886
  write_selected_fake_index_: write_selected_fake_index_
6557
6887
  });
6558
6888
  }
6559
- function $a817d06dc1c5911c$var$actual_navigation_working_on_fake_data({ element_: element_ , search_field_value_: [get_search_field_value, set_search_field_value] , updating_blocked_: [read_updating_blocked, write_updating_blocked] , last_suggestion_index_: last_suggestion_index_ , read_selected_fake_index_: read_selected_fake_index_ , write_selected_fake_index_: write_selected_fake_index_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , navigate_page_to_href_: navigate_page_to_href_ , url_transformer_: url_transformer_ , search_query_param_name_: search_query_param_name_ }) {
6889
+ function $a817d06dc1c5911c$var$actual_navigation_working_on_fake_data({ element_: element_ , search_field_value_: [get_search_field_value, set_search_field_value] , updating_blocked_: [read_updating_blocked, write_updating_blocked] , last_suggestion_index_: last_suggestion_index_ , read_selected_fake_index_: read_selected_fake_index_ , write_selected_fake_index_: write_selected_fake_index_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , url_transformer_: url_transformer_ , search_query_param_name_: search_query_param_name_ , router_: router_ }) {
6560
6890
  let previous_value;
6561
6891
  (0, $g9l4l$createEffect)(()=>{
6562
6892
  const sfv = get_search_field_value();
@@ -6594,6 +6924,7 @@ function $a817d06dc1c5911c$var$actual_navigation_working_on_fake_data({ element_
6594
6924
  set_search_field_value(title);
6595
6925
  override_on_enter_for_this_entry((e)=>{
6596
6926
  // Open search query in new tab on cmd+enter
6927
+ // If it's not cmd+enter, pressing enter will just submit the value that was put into the field while selecting with the arrow keys ;)
6597
6928
  const url = new URL(location);
6598
6929
  url_transformer_?.(url);
6599
6930
  url.searchParams.set(search_query_param_name_, title);
@@ -6601,11 +6932,11 @@ function $a817d06dc1c5911c$var$actual_navigation_working_on_fake_data({ element_
6601
6932
  });
6602
6933
  } else if (selected_entry?.type == "category") override_on_enter_for_this_entry((e)=>{
6603
6934
  const { page_url: page_url } = selected_entry;
6604
- if (!$a817d06dc1c5911c$var$open_link_on_cmd_pressed(e, page_url)) {
6605
- // Above fn will return true if it opened a new tab, and we won't make these checks anymore
6606
- if (navigate_page_to_href_) navigate_page_to_href_(page_url);
6607
- else location.href = page_url;
6608
- }
6935
+ if (!$a817d06dc1c5911c$var$open_link_on_cmd_pressed(e, page_url)) // Above fn will return true if it opened a new tab, and we won't make these checks anymore
6936
+ router_.navigate_.go_to_({
6937
+ new_url_: page_url,
6938
+ is_replace_: false
6939
+ });
6609
6940
  return true;
6610
6941
  });
6611
6942
  else if (!selected_entry) {
@@ -6638,7 +6969,7 @@ function $a817d06dc1c5911c$var$open_link_on_cmd_pressed(e, href) {
6638
6969
 
6639
6970
 
6640
6971
  const $c7bc9269d29d4bdc$export$3cf9497e790da491 = "query";
6641
- 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_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , after_submit_: after_submit_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ }) {
6972
+ 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_ }) {
6642
6973
  const [searching_for_value, set_searching_for_value] = (0, $g9l4l$createSignal)();
6643
6974
  const [read_search_field_value] = search_field_value_;
6644
6975
  const updating_blocked = (0, $g9l4l$createSignal)(false);
@@ -6681,7 +7012,7 @@ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search
6681
7012
  set_override_on_enter_fn_: set_override_on_enter_fn_,
6682
7013
  search_query_param_name_: search_page_url_param_name_,
6683
7014
  url_transformer_: url_transformer_,
6684
- navigate_page_to_href_: navigate_page_to_href_
7015
+ router_: router_
6685
7016
  });
6686
7017
  return [
6687
7018
  (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
@@ -6699,14 +7030,10 @@ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search
6699
7030
  get previous_searches_ () {
6700
7031
  return (0, $g9l4l$createMemo)(()=>filtered_previous_searches().slice(0, 5));
6701
7032
  },
6702
- search_field_value_: search_field_value_,
6703
7033
  selected_index_: selected_index_,
6704
7034
  currently_showing_suggestions_: currently_showing_suggestions_,
6705
7035
  url_transformer_: url_transformer_,
6706
- get_search_query_: get_search_query_,
6707
- alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
6708
- after_submit_: after_submit_,
6709
- on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
7036
+ submit_query_: submit_query_
6710
7037
  });
6711
7038
  }
6712
7039
  }),
@@ -6724,18 +7051,14 @@ function $c7bc9269d29d4bdc$export$2f2b9559550c7bbc({ search_field_value_: search
6724
7051
  on_previous_searches_page_: show_previous_searches_component,
6725
7052
  i18n_: i18n_,
6726
7053
  url_transformer_: url_transformer_,
6727
- search_field_value_: search_field_value_,
6728
7054
  searching_for_value_: searching_for_value,
6729
7055
  search_page_url_param_name_: search_page_url_param_name_,
6730
- alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
6731
7056
  selected_index_: selected_index_,
6732
7057
  suggestion_memo_: read_suggestion_signal,
6733
7058
  currently_showing_suggestions_: currently_showing_suggestions_,
6734
- get_search_query_: get_search_query_,
6735
7059
  include_category_suggestions_: include_category_suggestions_,
6736
- after_submit_: after_submit_,
6737
- navigate_page_to_href_: navigate_page_to_href_,
6738
- on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
7060
+ router_: router_,
7061
+ submit_query_: submit_query_
6739
7062
  })
6740
7063
  ];
6741
7064
  }
@@ -6821,7 +7144,7 @@ function $b24f16c875c2baa6$export$f021bdedd3ec901a(props) {
6821
7144
 
6822
7145
 
6823
7146
  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);
6824
- 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_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: props_after_submit , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false }) {
7147
+ 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_ }) {
6825
7148
  let on_enter_in_search_field_function;
6826
7149
  // 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.
6827
7150
  // 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
@@ -6835,12 +7158,6 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
6835
7158
  propagate_search_field_value_back?.();
6836
7159
  return props_submit_query(...args);
6837
7160
  };
6838
- const after_submit_ = props_after_submit && ((...args)=>{
6839
- // This will be called by link_to_param_change when clicking on a suggestion
6840
- // the logic in link_to_param_change doesn't need to read the search field value before submitting, so we can just propagate the changes after submitting
6841
- propagate_search_field_value_back?.();
6842
- return props_after_submit(...args);
6843
- });
6844
7161
  const [input_field, set_input_field] = (0, $g9l4l$createSignal)();
6845
7162
  const [get_search_field_value_] = search_field_value_;
6846
7163
  const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $g9l4l$createSignal)();
@@ -6863,7 +7180,7 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
6863
7180
  (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
6864
7181
  (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
6865
7182
  const _el$ = $a9f6faeac82c322b$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
6866
- _el$2.$$click = submit_query_;
7183
+ (0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)(()=>submit_query_()), true);
6867
7184
  (0, $g9l4l$insert)(_el$2, (()=>{
6868
7185
  const _c$ = (0, $g9l4l$memo)(()=>!!get_search_field_value_());
6869
7186
  return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
@@ -6937,13 +7254,11 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
6937
7254
  selected_index_: selected_index,
6938
7255
  currently_showing_suggestions_: currently_showing_suggestions_,
6939
7256
  depict_api_: depict_api_,
6940
- alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
6941
7257
  url_transformer_: url_transformer_,
6942
7258
  i18n_: i18n_,
6943
7259
  include_category_suggestions_: enable_category_suggestions_ ?? true,
6944
- after_submit_: after_submit_,
6945
- navigate_page_to_href_: navigate_page_to_href_,
6946
- on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
7260
+ router_: router_,
7261
+ submit_query_: submit_query_
6947
7262
  });
6948
7263
  }
6949
7264
  }), null);
@@ -7035,7 +7350,7 @@ function $a9f6faeac82c322b$var$close_modal_when_navigating_away(close_modal, sea
7035
7350
 
7036
7351
 
7037
7352
  const $71cf2f71a46bffea$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="category-suggestions"></div>`, 2), $71cf2f71a46bffea$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="category-suggestion"></div>`, 2);
7038
- function $71cf2f71a46bffea$export$c05a196222ba1302({ suggestions_: suggestions_ , children: children , selected_filters_: selected_filters_ , slider_arrow_button_: slider_arrow_button_ }) {
7353
+ function $71cf2f71a46bffea$export$c05a196222ba1302({ suggestions_: suggestions_ , children: children , slider_arrow_button_: slider_arrow_button_ }) {
7039
7354
  const category_suggestions_ = (0, $g9l4l$createMemo)(()=>suggestions_()?.suggestions.filter((s)=>s.type === "category"));
7040
7355
  return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
7041
7356
  get when () {
@@ -7066,7 +7381,7 @@ function $71cf2f71a46bffea$export$c05a196222ba1302({ suggestions_: suggestions_
7066
7381
  get each () {
7067
7382
  return category_suggestions_();
7068
7383
  },
7069
- children: (suggestion, index)=>children(suggestion, index, selected_filters_)
7384
+ children: (suggestion, index)=>children(suggestion, index)
7070
7385
  });
7071
7386
  }
7072
7387
  });
@@ -7118,13 +7433,12 @@ function $57ec75eac12fe1fc$export$9dd50d35b9d94fdf({ search_query_: search_query
7118
7433
 
7119
7434
  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);
7120
7435
  function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7121
- 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_ , disable_default_tracking_: disable_default_tracking_ = false } = opts;
7436
+ 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;
7122
7437
  const tenant_object_ = new (0, $g9l4l$Tenant)({
7123
7438
  TENANT: (0, $g9l4l$untrack)(tenant_),
7124
7439
  MARKET: (0, $g9l4l$untrack)(market_),
7125
7440
  GA_ID: "",
7126
- get_product_id: get_product_id_,
7127
- pageview_tracking: !disable_default_tracking_
7441
+ get_product_id: get_product_id_
7128
7442
  });
7129
7443
  const [get_sorting] = current_sorting_;
7130
7444
  const [get_search_query] = search_query_;
@@ -7292,7 +7606,6 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7292
7606
  message_: "Category suggestions failed",
7293
7607
  get children () {
7294
7608
  return (0, $g9l4l$createComponent)((0, $71cf2f71a46bffea$export$c05a196222ba1302), {
7295
- selected_filters_: selected_filters_,
7296
7609
  suggestions_: suggestions,
7297
7610
  slider_arrow_button_: slider_arrow_button_,
7298
7611
  children: make_category_suggestion_card_
@@ -7349,8 +7662,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7349
7662
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7350
7663
  local_filter_cache_: local_filter_cache_,
7351
7664
  i18n_: i18n_
7352
- },
7353
- disable_default_tracking_: disable_default_tracking_
7665
+ }
7354
7666
  });
7355
7667
  }
7356
7668
  }), null);
@@ -7372,8 +7684,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
7372
7684
  showing_recommendation_rows_: showing_recommendation_rows_,
7373
7685
  rr_options_: recommendations_rr_options_,
7374
7686
  view_more_button_: search_recs_view_more_,
7375
- tenant_object_: tenant_object_,
7376
- disable_default_tracking_: disable_default_tracking_
7687
+ tenant_object_: tenant_object_
7377
7688
  });
7378
7689
  }
7379
7690
  });
@@ -7443,9 +7754,11 @@ function $a79ffb1cbfbd2a09$export$828dcdd425fd3231(aligner) {
7443
7754
  }
7444
7755
 
7445
7756
 
7757
+
7758
+
7446
7759
  const $540e930c58500cbe$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"></div>`, 2);
7447
- /**
7448
- * Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
7760
+ /**
7761
+ * Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
7449
7762
  */ const $540e930c58500cbe$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
7450
7763
  const $540e930c58500cbe$var$min_products_to_fetch_ = 20;
7451
7764
  const $540e930c58500cbe$export$bde3eb976dfded9 = (depict_search)=>$540e930c58500cbe$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
@@ -7455,36 +7768,18 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7455
7768
  #market_signal = (0, $g9l4l$createSignal)();
7456
7769
  #modal_open_signal = (0, $g9l4l$createSignal)(false);
7457
7770
  static #has_been_constructed = false;
7458
- constructor({ search_query_url_param_name: search_query_url_param_name = "search_query" , url_transformer: url_transformer , on_navigation: raw_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
7771
+ #router = new (0, $cfa2761d36e5714c$export$7e1297a3a19f10d8)("hard_navigation");
7772
+ 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
7459
7773
  disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
7460
7774
  if ($540e930c58500cbe$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
7461
7775
  Object.assign(this, props_on_class);
7462
- const on_navigation = raw_on_navigation && ((absolute_href)=>{
7463
- const u_o = new URL(absolute_href);
7464
- const relative_href = u_o.pathname + u_o.search + u_o.hash;
7465
- // make sure that we don't accidentally catchify if the SDK consumer has fucked up
7466
- try {
7467
- return raw_on_navigation(relative_href);
7468
- } catch (e) {
7469
- queueMicrotask(()=>{
7470
- throw e;
7471
- });
7472
- }
7473
- });
7474
- const alternative_query_submitter_for_spas_ = on_navigation && ((search_param_name, new_search_query, url_transformer)=>{
7475
- const target_url = new URL(location.href);
7476
- url_transformer?.(target_url);
7477
- target_url.searchParams.set(search_param_name, new_search_query);
7478
- on_navigation(target_url.href);
7479
- });
7776
+ const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $b4291f5d2e6b2fae$export$7bcff1eb3eca57d7)(this.#router);
7480
7777
  const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
7481
7778
  search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7482
- search_sorting: undefined,
7483
7779
  search_filters_open: false,
7484
7780
  search_sorting_open: false,
7485
7781
  search_expanded_filters: [],
7486
- // WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters, and we'll end up with too few filters in search_local_filter_cache in some cases
7487
- search_selected_filters: [],
7782
+ // Please make sure that the signal created by below line always updates AFTER selected_filters_ updates on a "popstate" event. If the filter cache is popped before the selected filters are the code in create_modified_filters() is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters, and we'll end up with too few filters in search_local_filter_cache in some cases
7488
7783
  search_local_filter_cache: [],
7489
7784
  search_expanded_hierarchical_filters: [],
7490
7785
  search_showing_recommendation_rows: (0, $aee0c68312d971f4$export$1c8c715550dc689d),
@@ -7500,24 +7795,27 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7500
7795
  const [, set_search_showing_recommendation_rows] = state_.search_showing_recommendation_rows;
7501
7796
  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
7502
7797
  const on_submit_with_unchanged_value_ = ()=>this.modal_open = false;
7503
- const configured_submit_query_ = ()=>(0, $7f6ddd9a7e868c4d$export$e16630ecb9644a1c)({
7798
+ const [get_search_field_value_, set_search_field_value_] = state_.search_field_value;
7799
+ const configured_submit_query_ = (new_query)=>(0, $7f6ddd9a7e868c4d$export$e16630ecb9644a1c)({
7504
7800
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
7505
- search_field_value_: state_.search_field_value,
7801
+ set_search_field_value_: set_search_field_value_,
7506
7802
  search_query_: search_query_signal_,
7507
7803
  search_param_name_: search_query_url_param_name,
7508
7804
  url_transformer_: url_transformer,
7509
- on_submit_: alternative_query_submitter_for_spas_,
7510
- after_submit_: after_submit_
7805
+ after_submit_: after_submit_,
7806
+ get_new_query: ()=>new_query || (0, $g9l4l$untrack)(get_search_field_value_),
7807
+ router_: this.#router
7511
7808
  });
7512
7809
  const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
7513
7810
  const clear_filters_on_next_submit_ = (0, $a0d89ff25220eb8d$export$e026af0c7b64ea5f)({
7514
- selected_filters_: state_.search_selected_filters,
7811
+ selected_filters_: selected_filters_,
7515
7812
  search_query_: search_query_signal_,
7516
- current_sorting_: state_.search_sorting,
7813
+ current_sorting_: current_sorting_,
7517
7814
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7518
7815
  i18n_: i18n_,
7519
7816
  local_filter_cache_: state_.search_local_filter_cache
7520
7817
  });
7818
+ if (on_navigation) this.#router.on_navigation_ = on_navigation;
7521
7819
  (0, $g9l4l$createComputed)(()=>{
7522
7820
  const [get_search_query_updating_blocked] = search_query_updating_blocked_;
7523
7821
  const [get_raw_search_query_signal] = raw_search_query_signal;
@@ -7528,7 +7826,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7528
7826
  search_query_url_param_name_: search_query_url_param_name,
7529
7827
  reset_history_state_: reset_history_state_,
7530
7828
  state_: state_,
7531
- on_navigation_: on_navigation,
7829
+ router_: this.#router,
7532
7830
  url_transformer_: url_transformer,
7533
7831
  depict_api_: depict_api_,
7534
7832
  enable_category_suggestions_: enable_category_suggestions,
@@ -7536,16 +7834,17 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7536
7834
  configured_submit_query_: configured_submit_query_,
7537
7835
  search_query_signal_: search_query_signal_,
7538
7836
  i18n_: i18n_,
7539
- search_query_updating_blocked_: search_query_updating_blocked_
7837
+ search_query_updating_blocked_: search_query_updating_blocked_,
7838
+ current_sorting_: current_sorting_,
7839
+ selected_filters_: selected_filters_
7540
7840
  });
7541
7841
  (0, $2864fd26f57ff474$export$5162a71f252e6122)();
7542
7842
  (0, $g9l4l$catchify)(async ()=>{
7543
- const owner = (0, $g9l4l$getOwner)(); // we might have an owner, if so, pass it on
7843
+ const owner = (0, $g9l4l$getOwner)() || (0, $g9l4l$createRoot)(()=>(0, $g9l4l$getOwner)()); // we might have an owner, if so, pass it on. Otherwise, create one so solid doesn't print warnings to the console
7544
7844
  const { open_modal_: open_modal_ , close_modal_: close_modal_ } = await (0, $3786428a06ed81c4$export$79b1565500412d9b)((...args)=>{
7545
7845
  (0, $g9l4l$onCleanup)(()=>this.modal_open = false);
7546
7846
  return (0, $a9f6faeac82c322b$export$1c593cbd6f1e10bc)(...args);
7547
7847
  }, {
7548
- after_submit_: after_submit_,
7549
7848
  search_field_value_: state_.search_field_value,
7550
7849
  search_query_: search_query_signal_,
7551
7850
  search_page_url_param_name_: search_query_url_param_name,
@@ -7555,15 +7854,13 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7555
7854
  clear_filters_: clear_filters_on_next_submit_,
7556
7855
  market_: this.#market_signal[0],
7557
7856
  submit_query_: configured_submit_query_,
7558
- alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
7559
7857
  url_transformer_: url_transformer,
7560
- navigate_page_to_href_: on_navigation,
7561
- on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
7858
+ router_: this.#router,
7562
7859
  instant_results_options_: {
7563
7860
  min_products_to_fetch_: $540e930c58500cbe$var$min_products_to_fetch_,
7564
7861
  render_instant_card_: render_instant_card,
7565
7862
  render_instant_card_placeholder_: (0, $aaacfac0064e97d9$export$ee1733d9a8495996),
7566
- has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(state_.search_selected_filters[0]())?.length || state_.search_sorting[0]()))
7863
+ has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(selected_filters_[0]())?.length || current_sorting_[0]()))
7567
7864
  },
7568
7865
  i18n_: i18n_,
7569
7866
  enable_category_suggestions_: enable_category_suggestions,
@@ -7572,7 +7869,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7572
7869
  });
7573
7870
  // This will add some default behaviour to open_modal_ if no style_props_ are supplied
7574
7871
  // The default behaviour is to align the modal with the input field if possible
7575
- const computation = ()=>{
7872
+ const modal_opening_effect = ()=>{
7576
7873
  const open_signal_value = this.modal_open;
7577
7874
  const signal_value_is_options = Array.isArray(open_signal_value);
7578
7875
  // Close modal if signal is false
@@ -7626,11 +7923,17 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7626
7923
  style_props_: style_props_
7627
7924
  });
7628
7925
  };
7629
- if (owner != null) (0, $g9l4l$runWithOwner)(owner, ()=>(0, $g9l4l$createComputed)(computation));
7630
- else (0, $g9l4l$createComputed)(computation);
7926
+ (0, $g9l4l$runWithOwner)(owner, ()=>(0, $g9l4l$createEffect)(modal_opening_effect));
7631
7927
  })();
7632
7928
  $540e930c58500cbe$export$ac6237957a15b3f0.#has_been_constructed = true;
7633
7929
  }
7930
+ get on_navigation() {
7931
+ // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
7932
+ return this.#router.on_navigation_;
7933
+ }
7934
+ set on_navigation(new_function) {
7935
+ this.#router.on_navigation_ = new_function;
7936
+ }
7634
7937
  get localization() {
7635
7938
  // allow reactive access
7636
7939
  return this.#locale_signal[0]();
@@ -7673,7 +7976,7 @@ function $540e930c58500cbe$var$get_shared_properties(depict_search) {
7673
7976
  if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
7674
7977
  return shared_properties;
7675
7978
  }
7676
- 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 , disable_default_tracking: disable_default_tracking }) {
7979
+ 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 }) {
7677
7980
  const shared_properties = $540e930c58500cbe$var$get_shared_properties(depict_search);
7678
7981
  const grid_spacing_override = typeof grid_spacing === "string" ? {
7679
7982
  grid_spacing: grid_spacing
@@ -7713,18 +8016,18 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
7713
8016
  });
7714
8017
  });
7715
8018
  },
7716
- current_sorting_: state_.search_sorting,
8019
+ current_sorting_: shared_properties.current_sorting_,
7717
8020
  search_filters_open_: state_.search_filters_open,
7718
8021
  search_sorting_open_: state_.search_sorting_open,
7719
8022
  expanded_filters_: state_.search_expanded_filters,
7720
8023
  make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? (category_suggestion_)=>{
7721
8024
  return (0, $7a7079d66c12b788$export$d757d54550ebfb3d)({
7722
8025
  category_suggestion_: category_suggestion_,
7723
- on_navigation_: shared_properties.on_navigation_
8026
+ router_: shared_properties.router_
7724
8027
  });
7725
8028
  } : false,
7726
8029
  expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
7727
- selected_filters_: state_.search_selected_filters,
8030
+ selected_filters_: shared_properties.selected_filters_,
7728
8031
  showing_recommendation_rows_: state_.search_showing_recommendation_rows,
7729
8032
  scroll_restoration_data_: state_.search_scroll_restoration_data,
7730
8033
  include_input_field_: include_input_field,
@@ -7748,8 +8051,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
7748
8051
  pre_processors: extra_depict_options?.pre_processors,
7749
8052
  post_processors: extra_depict_options?.post_processors
7750
8053
  },
7751
- get_product_id_: get_product_id,
7752
- disable_default_tracking_: disable_default_tracking
8054
+ get_product_id_: get_product_id
7753
8055
  });
7754
8056
  }, "Entire SearchPage failed");
7755
8057
  }
@@ -7863,8 +8165,8 @@ const $7cbfd6122dbaf087$export$d86a33413558014e = (openModalParams)=>{
7863
8165
  }
7864
8166
  const { cleanup: cleanup } = (0, $a79ffb1cbfbd2a09$export$828dcdd425fd3231)(openModalParams.element);
7865
8167
  let dispose_aligner;
7866
- /**
7867
- * Setting position to fixed is important to make the modal work with align_field.
8168
+ /**
8169
+ * Setting position to fixed is important to make the modal work with align_field.
7868
8170
  */ const style_props_ = (0, $g9l4l$createSignal)({
7869
8171
  position: "fixed"
7870
8172
  });
@@ -7908,7 +8210,6 @@ function $a3e81b85527bc866$export$d0596b5cae35ad4(open_search) {
7908
8210
 
7909
8211
 
7910
8212
 
7911
-
7912
8213
  function $36316d7b4c897a03$export$689e204eadb33baf(pr) {
7913
8214
  let old_url;
7914
8215
  let disconnect_link_observer;
@@ -7961,8 +8262,8 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
7961
8262
  })();
7962
8263
  return new Set();
7963
8264
  })();
7964
- /**
7965
- * Returns if the "replacement page" is currently open
8265
+ /**
8266
+ * Returns if the "replacement page" is currently open
7966
8267
  */ get open_() {
7967
8268
  // make this "readonly" from the outside, the only way to open is by making the url change so that is_page_ returns true
7968
8269
  return this.#is_open;
@@ -8043,39 +8344,40 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
8043
8344
  }, "failed to open page");
8044
8345
  #empty_page_bugfix() {
8045
8346
  // Called when a "page" is "opened" using PageReplacer
8046
- const on_popstate = ()=>{
8347
+ const on_maybe_popstate = (what_happened)=>{
8348
+ if (what_happened !== "popstate") return;
8047
8349
  const cleaned_current_url = $ba6c9609228edf6b$var$clean_url(location.href);
8048
8350
  if (!$ba6c9609228edf6b$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
8049
- /*
8050
- What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
8051
- The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
8052
- The reproduction is this:
8053
- Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
8054
- 1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
8055
- 2. Make a search
8056
- We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
8057
- 3. Try going back just for fun
8058
- Everything works as expected
8059
- 4. Go forwards again (just for fun, skip this if you skipped 3)
8060
- Now the trouble comes when we introduce "hard" navigation.
8061
- 5. Click on a search result. The browser will now "hard" navigate to a new page.
8062
- 6. Click "back"
8063
- What happens now, is that the browser hard-navigates to /start/search.
8064
- 7. Click "back" again
8065
- What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
8066
- PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
8067
- The fix: is to remember all pages that we have visited since the creation of `window` (we do that by having a static property on PageReplacer since we assume the PageReplacer source code will only exist once on the page and will be loaded at page load, the latter assumption might be wrong, but I hope not). If we get a "popstate" event (meaning back or forwards button, not new page being pushed) to an unknown page we reload.
8068
- */ (0, $g9l4l$dlog)("PageReplacer: ", cleaned_current_url, " hasn't been visited since document was created, reloading since we won't be able to show this page otherwise");
8351
+ /*
8352
+ What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
8353
+ The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
8354
+ The reproduction is this:
8355
+ Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
8356
+ 1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
8357
+ 2. Make a search
8358
+ We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
8359
+ 3. Try going back just for fun
8360
+ Everything works as expected
8361
+ 4. Go forwards again (just for fun, skip this if you skipped 3)
8362
+ Now the trouble comes when we introduce "hard" navigation.
8363
+ 5. Click on a search result. The browser will now "hard" navigate to a new page.
8364
+ 6. Click "back"
8365
+ What happens now, is that the browser hard-navigates to /start/search.
8366
+ 7. Click "back" again
8367
+ What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
8368
+ PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
8369
+ The fix: is to remember all pages that we have visited since the creation of `window` (we do that by having a static property on PageReplacer since we assume the PageReplacer source code will only exist once on the page and will be loaded at page load, the latter assumption might be wrong, but I hope not). If we get a "popstate" event (meaning back or forwards button, not new page being pushed) to an unknown page we reload.
8370
+ */ (0, $g9l4l$dlog)("PageReplacer: ", cleaned_current_url, " hasn't been visited since document was created, reloading since we won't be able to show this page otherwise");
8069
8371
  location.reload();
8070
8372
  $ba6c9609228edf6b$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
8071
8373
  this.#unload(); // Call unload to "kill" the solid-js stuff quicker so that it stops updating - the user is expecting the next thing that happens to be a navigation to the actual page the URL says they're on.
8072
8374
  }
8073
8375
  };
8074
- (0, $g9l4l$instant_exec_on_popstate_before_ipns_update).add(on_popstate);
8075
- this.#revert_fns.push(()=>(0, $g9l4l$instant_exec_on_popstate_before_ipns_update).delete(on_popstate)); // Don't run the bugfixer if there isn't a PageReplacer page open since I assume the bug only happens when going back from a PageReplace'd page
8376
+ (0, $g9l4l$instant_exec_on_suspect_history_change).add(on_maybe_popstate);
8377
+ this.#revert_fns.push(()=>(0, $g9l4l$instant_exec_on_suspect_history_change).delete(on_maybe_popstate)); // Don't run the bugfixer if there isn't a PageReplacer page open since I assume the bug only happens when going back from a PageReplace'd page
8076
8378
  }
8077
- /**
8078
- * Stops listening to URL changes and closes the page (if it is currently open)
8379
+ /**
8380
+ * Stops listening to URL changes and closes the page (if it is currently open)
8079
8381
  */ destroy_() {
8080
8382
  this.#unload();
8081
8383
  this.#stop_listening?.();
@@ -8090,8 +8392,8 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
8090
8392
  if (!is_spa_) (0, $36316d7b4c897a03$export$689e204eadb33baf)(this); // Make so that clicking on links to the previous page work instantly
8091
8393
  }
8092
8394
  }
8093
- /**
8094
- * Remove hash from URL
8395
+ /**
8396
+ * Remove hash from URL
8095
8397
  */ function $ba6c9609228edf6b$var$clean_url(url) {
8096
8398
  // Would want to have this a static private function on PageReplacer, but that's not supported in MobileSafari yet
8097
8399
  // remove hash, all other params *could* trigger a re-request
@@ -8104,4 +8406,4 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
8104
8406
  (0, $g9l4l$add_to_version_info)("ui", (0, $18bf1d29fb889cca$export$83d89fbfd8236492));
8105
8407
 
8106
8408
 
8107
- 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, $972ebf2641490830$export$26df08e242fe83a3 as push_state_with_query_param_value, $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};
8409
+ 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};