@depict-ai/ui 0.0.3 → 0.0.5

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/main.js CHANGED
@@ -46,8 +46,11 @@ $parcel$export(module.exports, "swedish_category_translation", () => $7571ce64c2
46
46
  $parcel$export(module.exports, "swedish_search_translation", () => $7571ce64c2a20e28$export$596caee559c76764);
47
47
  $parcel$export(module.exports, "solid_format_price", () => $d659702496cb72ea$export$469c7af753d08925);
48
48
  $parcel$export(module.exports, "PageReplacer", () => $0a6acf31d1eae57c$export$3ccaa27d81dd8556);
49
- $parcel$export(module.exports, "Category", () => $dde172e07a8d9aee$export$3a8840c5b2ecf003);
50
- $parcel$export(module.exports, "Search", () => $d06dbfcc8cd5a5bb$export$4b85d3515bd863a5);
49
+ $parcel$export(module.exports, "Category", () => $7cb9c8285dbd453e$export$3a8840c5b2ecf003);
50
+ $parcel$export(module.exports, "DepictSearch", () => $fd2d5ef67fc09716$export$ac6237957a15b3f0);
51
+ $parcel$export(module.exports, "SearchPage", () => $fd2d5ef67fc09716$export$f2dc7e4e4aa11abb);
52
+ $parcel$export(module.exports, "SearchField", () => $fd2d5ef67fc09716$export$b94867ecbd698f21);
53
+ $parcel$export(module.exports, "get_search_query_updating_blocked_signal", () => $fd2d5ef67fc09716$export$bde3eb976dfded9);
51
54
 
52
55
 
53
56
 
@@ -162,7 +165,7 @@ const $93e94e7b0aa8ca88$export$824dde41348efed1 = /*@__PURE__*/ (()=>{
162
165
 
163
166
 
164
167
 
165
- const $e1d6c0f3d89d531c$var$v2_base_url = process.env.BASE_URL + "/v2/";
168
+ const $e1d6c0f3d89d531c$var$v2_base_url = (0, $iBTHO$depictaiutilishared.base_url) + "/v2/";
166
169
  const $e1d6c0f3d89d531c$var$search_base_url = $e1d6c0f3d89d531c$var$v2_base_url + "search/";
167
170
  const $e1d6c0f3d89d531c$var$add_ids_to_request = (input_req)=>{
168
171
  const request = {
@@ -501,7 +504,7 @@ async function $7b4bc889571cc67b$var$fetch_and_store_categories(tenant, market,
501
504
  return new_categories;
502
505
  }
503
506
  async function $7b4bc889571cc67b$var$download_categories(tenant, market) {
504
- const fetched = await (0, $iBTHO$depictaiutilishared.fetch_retry)(process.env.BASE_URL + "/v2/product-listing/queries", {
507
+ const fetched = await (0, $iBTHO$depictaiutilishared.fetch_retry)((0, $iBTHO$depictaiutilishared.base_url) + "/v2/product-listing/queries", {
505
508
  method: "POST",
506
509
  body: JSON.stringify({
507
510
  tenant: tenant,
@@ -2340,6 +2343,7 @@ let $fe76fb463cc60b89$var$cached_placeholder_element;
2340
2343
  function $fe76fb463cc60b89$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_ }) {
2341
2344
  // 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
2342
2345
  const is_loading = (0, $iBTHO$solidjs.createMemo)(()=>plp_results_.loading || query_base_.loading);
2346
+ const cleanup_old_cards = [];
2343
2347
  const render_and_insert_results = (0, $iBTHO$depictaiutilishared.deparallelize_no_drop)(async (insert_into, owner)=>{
2344
2348
  const fallback_to_no_results = ()=>(0, $iBTHO$solidjs.runWithOwner)(owner, ()=>insert_into.replaceChildren(...(0, $0d0b172488865048$export$ef6006467f04ee41)(no_results_options_)));
2345
2349
  const observe_for_counting_ = (0, $iBTHO$solidjs.runWithOwner)(owner, ()=>(0, $7f24debb0fdb7eba$export$daf1a0aef2143a61)({
@@ -2357,10 +2361,19 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({ plp_results_: plp_results_
2357
2361
  observe_for_counting_: observe_for_counting_,
2358
2362
  start_cursor_: current_cursor
2359
2363
  }) : (items)=>(observe_for_counting_(items), items);
2364
+ // create owner to run product cards with an Owner, so they know when they've gotten removed
2365
+ const [owner_for_cards, dispose_our_cards] = (0, $iBTHO$solidjs.createRoot)((dispose)=>[
2366
+ (0, $iBTHO$solidjs.getOwner)(),
2367
+ dispose
2368
+ ]);
2360
2369
  const rendering_result = await (0, $iBTHO$depictaiutilishared.default_rr)(tenant_object_, {
2361
2370
  type: type_for_tracking_,
2362
2371
  recs: current_results.displays,
2363
2372
  ...rr_options_,
2373
+ ...typeof rr_options_.template === "function" ? {
2374
+ template: (...args)=>(0, $iBTHO$solidjs.runWithOwner)(owner_for_cards, ()=>// give template the possibility to know when it gets removed from the DOM by using solid-js onCleanup
2375
+ rr_options_.template(...args))
2376
+ } : {},
2364
2377
  post_processors: [
2365
2378
  ...rr_options_.post_processors || [],
2366
2379
  load_more_post_processor
@@ -2377,6 +2390,9 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({ plp_results_: plp_results_
2377
2390
  return;
2378
2391
  }
2379
2392
  insert_into.replaceChildren(...elements);
2393
+ // Dispose the old cards just after the cards have been removed from the DOM
2394
+ cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
2395
+ cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
2380
2396
  should_stay_inserted?.then((should)=>{
2381
2397
  // If we shouldn't stay inserted for some reason, switch back to no results
2382
2398
  if (!should) fallback_to_no_results();
@@ -2390,6 +2406,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({ plp_results_: plp_results_
2390
2406
  const is_at_end = !plp_results_()?.cursor; // or failed, but we don't wanna / it's not easy to retry
2391
2407
  if (!is_loading() && is_at_end) all_products_loaded_[1](true);
2392
2408
  });
2409
+ (0, $iBTHO$solidjs.onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
2393
2410
  return (()=>{
2394
2411
  const _el$ = $fe76fb463cc60b89$var$_tmpl$.cloneNode(true);
2395
2412
  (0, $iBTHO$solidjsweb.insert)(_el$, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
@@ -2500,6 +2517,15 @@ async function $fe76fb463cc60b89$var$insert_placeholders({ scroll_restoration_da
2500
2517
  type: "placeholder",
2501
2518
  pre_processors: [],
2502
2519
  post_processors: [],
2520
+ ...typeof rr_options_.template === "function" ? {
2521
+ template: (...args)=>(0, $iBTHO$solidjs.createRoot)(async (dispose)=>{
2522
+ try {
2523
+ return await rr_options_.template(...args);
2524
+ } finally{
2525
+ (0, $iBTHO$depictaiutilishared.queueMacroTask)((0, $iBTHO$depictaiutilishared.catchify)(dispose)); // we just want it cloned and dead
2526
+ }
2527
+ })
2528
+ } : {},
2503
2529
  recs: [
2504
2530
  {
2505
2531
  page_url: "javascript:void(0)"
@@ -2508,7 +2534,7 @@ async function $fe76fb463cc60b89$var$insert_placeholders({ scroll_restoration_da
2508
2534
  });
2509
2535
  const element = elements?.find((e)=>e instanceof HTMLElement || e instanceof SVGElement);
2510
2536
  if (!element) return [];
2511
- $fe76fb463cc60b89$var$cached_placeholder_element = element;
2537
+ $fe76fb463cc60b89$var$cached_placeholder_element = element.cloneNode(true); // don't save the actual element, clone it directly so that the who provided it can't modify it later (this has caused a bug before with react)
2512
2538
  }
2513
2539
  (0, $iBTHO$solidjs.runWithOwner)(owner_, ()=>(0, $iBTHO$solidjs.createRenderEffect)(()=>{
2514
2540
  const to_add = num_placeholders() - existing_num;
@@ -2681,6 +2707,7 @@ function $235a2771a44e28e9$export$fecbb157621501bd({ number_of_rendered_selected
2681
2707
  const { collapse: collapse , expand: expand , ExpandingContainer: ExpandingContainer } = (0, $4b455f60dadde8b8$export$5bad61ecde080b1f)({
2682
2708
  duration: 200
2683
2709
  });
2710
+ const owner = (0, $iBTHO$solidjs.getOwner)();
2684
2711
  const outmost_element = (0, $iBTHO$solidjsweb.createComponent)(ExpandingContainer, {
2685
2712
  get children () {
2686
2713
  return (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
@@ -2697,14 +2724,15 @@ function $235a2771a44e28e9$export$fecbb157621501bd({ number_of_rendered_selected
2697
2724
  return [
2698
2725
  (()=>{
2699
2726
  const _el$4 = $235a2771a44e28e9$var$_tmpl$.cloneNode(true);
2700
- (0, $iBTHO$solidjsweb.addEventListener)(_el$4, "click", (0, $iBTHO$depictaiutilishared.catchify)(()=>(0, $47e2cc552c02110c$export$8895d39404bd2bb1)({
2701
- selected_filters_: selected_filters_,
2702
- i18n_: i18n_,
2703
- also_clear_sorting_: false,
2704
- user_triggered_: true,
2705
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2706
- local_filter_cache_: local_filter_cache_
2707
- })), true);
2727
+ (0, $iBTHO$solidjsweb.addEventListener)(_el$4, "click", (0, $iBTHO$depictaiutilishared.catchify)(()=>// click event handlers don't have an owner, carry it over
2728
+ (0, $iBTHO$solidjs.runWithOwner)(owner, ()=>(0, $47e2cc552c02110c$export$8895d39404bd2bb1)({
2729
+ selected_filters_: selected_filters_,
2730
+ i18n_: i18n_,
2731
+ also_clear_sorting_: false,
2732
+ user_triggered_: true,
2733
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
2734
+ local_filter_cache_: local_filter_cache_
2735
+ }))), true);
2708
2736
  (0, $iBTHO$solidjsweb.insert)(_el$4, ()=>i18n_.clear_all_from_filter_crumbs_());
2709
2737
  return _el$4;
2710
2738
  })(),
@@ -2978,8 +3006,10 @@ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_
2978
3006
  const close_modal_ = ()=>{
2979
3007
  if (dispose_and_remove) {
2980
3008
  // modal is open
2981
- dispose_and_remove();
3009
+ const dispose_fn = dispose_and_remove;
3010
+ // set dispose function to undefined in case that it triggers this dispose function itself. Not doing it leads to a bug like https://github.com/solidjs/solid/discussions/1194
2982
3011
  dispose_and_remove = undefined;
3012
+ dispose_fn();
2983
3013
  }
2984
3014
  };
2985
3015
  return {
@@ -6057,8 +6087,8 @@ function $d84fe647b84b5dc5$var$proxy_push_state(function_name, thing) {
6057
6087
  }
6058
6088
 
6059
6089
 
6060
- const $dde172e07a8d9aee$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="depict plp category"></div>`, 2);
6061
- class $dde172e07a8d9aee$export$3a8840c5b2ecf003 {
6090
+ const $7cb9c8285dbd453e$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="depict plp category"></div>`, 2);
6091
+ class $7cb9c8285dbd453e$export$3a8840c5b2ecf003 {
6062
6092
  #locale_signal = (0, $iBTHO$solidjs.createSignal)();
6063
6093
  #tenant_signal = (0, $iBTHO$solidjs.createSignal)();
6064
6094
  #market_signal = (0, $iBTHO$solidjs.createSignal)();
@@ -6070,14 +6100,14 @@ class $dde172e07a8d9aee$export$3a8840c5b2ecf003 {
6070
6100
  #booted = false;
6071
6101
  static #has_been_constructed = false;
6072
6102
  constructor(opts){
6073
- if ($dde172e07a8d9aee$export$3a8840c5b2ecf003.#has_been_constructed) throw new Error("You can only have one instance of Category due to state limitations");
6074
- $dde172e07a8d9aee$export$3a8840c5b2ecf003.#has_been_constructed = true;
6103
+ if ($7cb9c8285dbd453e$export$3a8840c5b2ecf003.#has_been_constructed) throw new Error("You can only have one instance of Category due to state limitations");
6104
+ $7cb9c8285dbd453e$export$3a8840c5b2ecf003.#has_been_constructed = true;
6075
6105
  this.#constructor_options = opts;
6076
6106
  (0, $d84fe647b84b5dc5$export$5162a71f252e6122)();
6077
6107
  }
6078
6108
  get #external_area_div() {
6079
6109
  // creates a new node every time this is accessed, doing like this for DRY purposes
6080
- return $dde172e07a8d9aee$var$_tmpl$.cloneNode(true);
6110
+ return $7cb9c8285dbd453e$var$_tmpl$.cloneNode(true);
6081
6111
  }
6082
6112
  get locale_() {
6083
6113
  // allow reactive access
@@ -6204,6 +6234,9 @@ class $dde172e07a8d9aee$export$3a8840c5b2ecf003 {
6204
6234
 
6205
6235
 
6206
6236
 
6237
+
6238
+
6239
+
6207
6240
  function $b34ce0b89e6db4e1$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_ }) {
6208
6241
  const [get_selected_filters, set_selected_filters] = selected_filters_;
6209
6242
  const clear_filters_next_submit_ = (0, $iBTHO$solidjs.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
@@ -6319,6 +6352,18 @@ function $b7d0212db218bf0b$export$2542ffb77b620b02(params_to_default_value) {
6319
6352
 
6320
6353
 
6321
6354
 
6355
+
6356
+
6357
+
6358
+
6359
+
6360
+
6361
+
6362
+
6363
+
6364
+
6365
+
6366
+
6322
6367
 
6323
6368
 
6324
6369
 
@@ -6326,7 +6371,7 @@ function $b7d0212db218bf0b$export$2542ffb77b620b02(params_to_default_value) {
6326
6371
 
6327
6372
 
6328
6373
  const $2f8c7dc07090fca9$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<button class="back" type="button"></button>`, 2), $2f8c7dc07090fca9$var$_tmpl$2 = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="query_input"><div class="field"><input class="query" tabindex="0"><button type="button" class="clear"></button></div><button class="submit major" type="button"></button></div>`, 9);
6329
- function $2f8c7dc07090fca9$export$ff21851bb5d30e15({ search_field_value_: search_field_value_ , input_field_ref_: input_field_ref_ , submit_query_: submit_query_ , override_on_enter_: override_on_enter_ , clear_filters_: clear_filters_ , disabled_: disabled_ = false , on_back_: on_back_ , i18n_: i18n_ }) {
6374
+ function $2f8c7dc07090fca9$export$ff21851bb5d30e15({ search_field_value_: search_field_value_ , input_field_ref_: input_field_ref_ , field_element_ref_: field_element_ref_ , submit_query_: submit_query_ , override_on_enter_: override_on_enter_ , clear_filters_: clear_filters_ , disabled_: disabled_ = false , on_back_: on_back_ , i18n_: i18n_ }) {
6330
6375
  let input_field;
6331
6376
  (0, $iBTHO$solidjs.createEffect)((0, $iBTHO$depictaiutilishared.catchify)(async ()=>{
6332
6377
  if (disabled_) return;
@@ -6346,6 +6391,7 @@ function $2f8c7dc07090fca9$export$ff21851bb5d30e15({ search_field_value_: search
6346
6391
  return _el$2;
6347
6392
  }
6348
6393
  }), _el$3);
6394
+ (0, $iBTHO$solidjsweb.use)((el)=>field_element_ref_?.(el), _el$3);
6349
6395
  (0, $iBTHO$solidjsweb.addEventListener)(_el$4, "select", (0, $iBTHO$depictaiutilishared.catchify)((e)=>{
6350
6396
  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
6351
6397
  {
@@ -6422,19 +6468,6 @@ function $2f8c7dc07090fca9$export$ff21851bb5d30e15({ search_field_value_: search
6422
6468
 
6423
6469
 
6424
6470
 
6425
-
6426
-
6427
-
6428
-
6429
-
6430
-
6431
-
6432
-
6433
-
6434
-
6435
-
6436
-
6437
-
6438
6471
 
6439
6472
  const $6ae556e536054e87$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="instant-results"></div>`, 2);
6440
6473
  function $6ae556e536054e87$export$62f101a8aa597bf8({ depict_api_: depict_api_ , search_field_value_: [get_search_field_value] , tenant_: tenant_ , market_: market_ , render_instant_card_: render_instant_card_ , render_instant_card_placeholder_: render_instant_card_placeholder_ , min_products_to_fetch_: min_products_to_fetch_ , has_sort_or_filters_: has_sort_or_filters_ , set_num_results_accessor_: set_num_results_accessor_ , i18n_: i18n_ }) {
@@ -7491,6 +7524,7 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
7491
7524
  })();
7492
7525
  const [get_showing_recommendation_rows] = showing_recommendation_rows_;
7493
7526
  const rows_object = view_more_button_ ? $fb29c6201c369e39$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
7527
+ const cleanup_old_cards = [];
7494
7528
  (0, $iBTHO$depictaiutilishared.Layout)({
7495
7529
  container_element: cards,
7496
7530
  layout: "grid",
@@ -7528,13 +7562,22 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
7528
7562
  }));
7529
7563
  const deparallelized_recs_fetcher = (0, $iBTHO$depictaiutilishared.deparallelize_no_drop)((0, $iBTHO$depictaiutilishared.catchify)(async (base_query)=>{
7530
7564
  const recs_promise = depict_api_.get_recommended(base_query).then((r)=>r.displays);
7565
+ // create owner to run product cards with an Owner, so they know when they've gotten removed
7566
+ const [owner_for_cards, dispose_our_cards] = (0, $iBTHO$solidjs.createRoot)((dispose)=>[
7567
+ (0, $iBTHO$solidjs.getOwner)(),
7568
+ dispose
7569
+ ]);
7531
7570
  const rendering_result = await (await (0, $iBTHO$depictaiutilishared.make_placeholder_rr)({
7532
7571
  // render the max amount of elements that there could be, to make sure scroll restoration works (placeholders can't be shorter than actual content)
7533
7572
  num_items: (0, $aec24316ed262dc0$export$6c9030e511152266) + (0, $iBTHO$solidjs.untrack)(get_showing_recommendation_rows) * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column))
7534
7573
  }))(tenant_object_, {
7535
7574
  type: "search_recs",
7536
7575
  recs: recs_promise,
7537
- ...rr_options_
7576
+ ...rr_options_,
7577
+ ...typeof rr_options_.template === "function" ? {
7578
+ template: (...args)=>(0, $iBTHO$solidjs.runWithOwner)(owner_for_cards, ()=>// give template the possibility to know when it gets removed from the DOM by using solid-js onCleanup
7579
+ rr_options_.template(...args))
7580
+ } : {}
7538
7581
  });
7539
7582
  const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
7540
7583
  let dead = false;
@@ -7545,12 +7588,16 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
7545
7588
  return;
7546
7589
  }
7547
7590
  cards.replaceChildren(...elements);
7591
+ // Dispose the old cards just after the cards have been removed from the DOM
7592
+ cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
7593
+ cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
7548
7594
  set_is_showing_something(true);
7549
7595
  should_stay_inserted?.then((should)=>{
7550
7596
  if (!should && !dead /* just in case */ ) set_is_showing_something(false);
7551
7597
  });
7552
7598
  }));
7553
7599
  (0, $iBTHO$solidjs.createRenderEffect)(()=>deparallelized_recs_fetcher(search_query_base_()));
7600
+ (0, $iBTHO$solidjs.onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
7554
7601
  return (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
7555
7602
  get when () {
7556
7603
  return is_showing_something();
@@ -7618,488 +7665,775 @@ function $65a0c4b1c2eb5d0b$export$9dd50d35b9d94fdf({ search_query_: search_query
7618
7665
 
7619
7666
  const $f1d7cb69f839a526$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $f1d7cb69f839a526$var$_tmpl$2 = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
7620
7667
  function $f1d7cb69f839a526$export$a54ec244c8863715(opts) {
7621
- const { depict_api_: depict_api_ , page_replacer_: page_replacer_ , 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;
7622
- return (0, $iBTHO$solidjs.createRoot)((dispose)=>{
7623
- return (0, $edafe91daf3091d7$export$b69d0d92862de18b)({
7624
- severity_: "error",
7625
- message_: "Whole search failed",
7626
- get children () {
7627
- page_replacer_.addEventListener("close", dispose, {
7628
- once: true
7629
- });
7630
- const tenant_object_ = new (0, $iBTHO$depictaiutilishared.Tenant)({
7631
- TENANT: (0, $iBTHO$solidjs.untrack)(tenant_),
7632
- MARKET: (0, $iBTHO$solidjs.untrack)(market_),
7633
- GA_ID: "",
7634
- get_product_id: get_product_id_
7635
- });
7636
- const [get_sorting] = current_sorting_;
7637
- const [get_search_query] = search_query_;
7638
- const all_products_loaded_ = (0, $iBTHO$solidjs.createSignal)(false);
7639
- const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
7640
- const number_of_rendered_selected_filters_items_ = (0, $iBTHO$solidjs.createSignal)(0);
7641
- const first_result_in_viewport_ = (0, $iBTHO$solidjs.createSignal)();
7642
- const last_result_in_viewport_ = (0, $iBTHO$solidjs.createSignal)();
7643
- const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = (0, $iBTHO$solidjs.createSignal)(false);
7644
- const search_query_base_ = (0, $8cd545330f2674dc$export$210f130a61ac1e8d)(()=>{
7645
- const sort_obj = get_sorting() && {
7646
- ...get_sorting()
7647
- };
7648
- delete sort_obj?.meta;
7649
- const f = selected_filters_[0]();
7650
- return {
7651
- tenant: tenant_(),
7652
- market: market_(),
7653
- query: get_search_query(),
7654
- ...f.length ? {
7655
- filters: f
7656
- } : {},
7657
- ...sort_obj ? {
7658
- sort: sort_obj
7659
- } : {}
7660
- };
7661
- });
7662
- const [search_results_] = (0, $iBTHO$solidjs.createResource)(search_query_base_, (0, $iBTHO$depictaiutilishared.catchify)(async (base_query)=>{
7663
- set_all_products_loaded(false);
7664
- // only first page of results
7665
- return await (0, $276380e4607fb9fb$export$cc42dd29bf655ab6)({
7666
- id_: (0, $iBTHO$solidjs.untrack)(get_search_query),
7668
+ 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;
7669
+ const tenant_object_ = new (0, $iBTHO$depictaiutilishared.Tenant)({
7670
+ TENANT: (0, $iBTHO$solidjs.untrack)(tenant_),
7671
+ MARKET: (0, $iBTHO$solidjs.untrack)(market_),
7672
+ GA_ID: "",
7673
+ get_product_id: get_product_id_
7674
+ });
7675
+ const [get_sorting] = current_sorting_;
7676
+ const [get_search_query] = search_query_;
7677
+ const all_products_loaded_ = (0, $iBTHO$solidjs.createSignal)(false);
7678
+ const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
7679
+ const number_of_rendered_selected_filters_items_ = (0, $iBTHO$solidjs.createSignal)(0);
7680
+ const first_result_in_viewport_ = (0, $iBTHO$solidjs.createSignal)();
7681
+ const last_result_in_viewport_ = (0, $iBTHO$solidjs.createSignal)();
7682
+ const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = (0, $iBTHO$solidjs.createSignal)(false);
7683
+ const search_query_base_ = (0, $8cd545330f2674dc$export$210f130a61ac1e8d)(()=>{
7684
+ const sort_obj = get_sorting() && {
7685
+ ...get_sorting()
7686
+ };
7687
+ delete sort_obj?.meta;
7688
+ const f = selected_filters_[0]();
7689
+ return {
7690
+ tenant: tenant_(),
7691
+ market: market_(),
7692
+ query: get_search_query(),
7693
+ ...f.length ? {
7694
+ filters: f
7695
+ } : {},
7696
+ ...sort_obj ? {
7697
+ sort: sort_obj
7698
+ } : {}
7699
+ };
7700
+ });
7701
+ const [search_results_] = (0, $iBTHO$solidjs.createResource)(search_query_base_, (0, $iBTHO$depictaiutilishared.catchify)(async (base_query)=>{
7702
+ set_all_products_loaded(false);
7703
+ // only first page of results
7704
+ return await (0, $276380e4607fb9fb$export$cc42dd29bf655ab6)({
7705
+ id_: (0, $iBTHO$solidjs.untrack)(get_search_query),
7706
+ min_products_to_fetch_: min_products_to_fetch_,
7707
+ scroll_restoration_data_: scroll_restoration_data_,
7708
+ make_request_: (limit, cursor)=>depict_api_.query({
7709
+ ...base_query,
7710
+ limit: limit,
7711
+ ...cursor ? {
7712
+ cursor: cursor
7713
+ } : {}
7714
+ })
7715
+ });
7716
+ }));
7717
+ const [suggestions] = (0, $iBTHO$solidjs.createResource)((0, $iBTHO$solidjs.createMemo)(()=>({
7718
+ query: search_query_[0](),
7719
+ tenant: tenant_(),
7720
+ market: market_()
7721
+ })), (opts)=>depict_api_.suggest(opts));
7722
+ const available_sortings_ = (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.sorts?.map((sort)=>({
7723
+ ...sort,
7724
+ order: sort.order ?? "desc"
7725
+ })));
7726
+ const available_filters_ = (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.filters);
7727
+ const modal_body_style = (0, $iBTHO$solidjs.createSignal)({});
7728
+ let input_field;
7729
+ if (include_input_field_) {
7730
+ const SafeQueryInput = (0, $iBTHO$depictaiutilishared.catchify)((0, $2f8c7dc07090fca9$export$ff21851bb5d30e15));
7731
+ input_field = (0, $iBTHO$solidjsweb.createComponent)(SafeQueryInput, {
7732
+ i18n_: i18n_,
7733
+ disabled_: true,
7734
+ search_query_: search_query_,
7735
+ search_field_value_: search_field_value_,
7736
+ submit_query_: submit_query_,
7737
+ clear_filters_: clear_filters_on_next_submit_
7738
+ });
7739
+ if (input_field) {
7740
+ opts?.modal_body_style_ref_?.(modal_body_style);
7741
+ const align_position = (0, $iBTHO$depictaiutilishared.catchify)((0, $fd463ff0edb29915$export$b3ad617e9036868))(modal_body_style, input_field, undefined, true);
7742
+ input_field.addEventListener("click", (0, $iBTHO$depictaiutilishared.catchify)((e)=>{
7743
+ const target = e.target;
7744
+ const sel = ".submit";
7745
+ if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
7746
+ return;
7747
+ align_position?.();
7748
+ open_modal_({
7749
+ style_props_: modal_body_style
7750
+ }, ()=>include_input_field_?.on_close_?.());
7751
+ include_input_field_?.on_open_?.();
7752
+ }));
7753
+ }
7754
+ }
7755
+ const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $iBTHO$solidjs.createSignal)(false);
7756
+ const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $iBTHO$solidjs.createSignal)();
7757
+ const formatted_number_of_results_ = (0, $0f400c3f7248d5f1$export$92f2da32c6e7e7ee)({
7758
+ search_results_: search_results_,
7759
+ i18n_: i18n_
7760
+ });
7761
+ const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $iBTHO$solidjs.createSignal)();
7762
+ const results_for = (0, $iBTHO$solidjsweb.createComponent)((0, $65a0c4b1c2eb5d0b$export$9dd50d35b9d94fdf), {
7763
+ search_query_: search_query_,
7764
+ i18n_: i18n_,
7765
+ formatted_number_of_results_: formatted_number_of_results_
7766
+ });
7767
+ const filters_opener = (0, $f8f64d05c525825b$export$d7841e452f2e59a8)({
7768
+ set_sort_or_filter_open_: set_sort_or_filter_open_,
7769
+ set_extra_els_in_results_container_: set_desktop_filter_elements,
7770
+ i18n_: i18n_,
7771
+ search_sorting_open_: search_sorting_open_,
7772
+ available_filters_: available_filters_,
7773
+ available_sortings_: available_sortings_,
7774
+ search_filters_open_: search_filters_open_,
7775
+ set_sort_and_filter_element_: set_sort_and_filter_element_,
7776
+ current_sorting_: current_sorting_,
7777
+ input_modal_open_: input_modal_open_,
7778
+ expanded_filters_: expanded_filters_,
7779
+ selected_filters_: selected_filters_,
7780
+ formatted_number_of_results_: formatted_number_of_results_,
7781
+ local_filter_cache_: local_filter_cache_,
7782
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7783
+ number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_
7784
+ });
7785
+ const results_filters = (0, $iBTHO$solidjs.createSignal)();
7786
+ (0, $iBTHO$solidjs.onCleanup)((0, $iBTHO$depictaiutilishared.javascript_media_query)("(max-width:600px)", async ({ matches: matches })=>{
7787
+ results_filters[1]();
7788
+ await new Promise((r)=>queueMicrotask(r));
7789
+ results_filters[1](matches ? [
7790
+ results_for,
7791
+ filters_opener
7792
+ ] : (()=>{
7793
+ const _el$ = $f1d7cb69f839a526$var$_tmpl$.cloneNode(true);
7794
+ (0, $iBTHO$solidjsweb.insert)(_el$, results_for, null);
7795
+ (0, $iBTHO$solidjsweb.insert)(_el$, filters_opener, null);
7796
+ return _el$;
7797
+ })());
7798
+ }).remove);
7799
+ (0, $iBTHO$depictaiutilishared.catchify)((0, $276380e4607fb9fb$export$6e49da55e449af7c))({
7800
+ scroll_restoration_data_: scroll_restoration_data_,
7801
+ last_result_in_viewport_: last_result_in_viewport_,
7802
+ id_: get_search_query,
7803
+ can_write_scroll_restoration_: can_write_scroll_restoration_
7804
+ });
7805
+ (0, $iBTHO$solidjs.createComputed)(()=>{
7806
+ if (search_results_.loading) set_can_write_scroll_restoration(false);
7807
+ else if (search_results_()) set_can_write_scroll_restoration(true);
7808
+ });
7809
+ (0, $6b384adf40a5f4d7$export$e702733a056c40d6)({
7810
+ selected_filters_: selected_filters_,
7811
+ available_filters_: available_filters_
7812
+ });
7813
+ // @ts-ignore
7814
+ if (process.env.GA !== "false") (0, $iBTHO$solidjs.createEffect)(()=>{
7815
+ get_search_query();
7816
+ (0, $341a019928b8b91e$export$c7e181728ad525f)(location);
7817
+ });
7818
+ (0, $iBTHO$solidjs.createComputed)(()=>{
7819
+ tenant_object_.tenant = tenant_object_.TENANT = tenant_();
7820
+ tenant_object_.market = tenant_object_.MARKET = market_();
7821
+ });
7822
+ return [
7823
+ document.createComment("Depict.ai frontend integrated search page"),
7824
+ (()=>{
7825
+ const _el$2 = $f1d7cb69f839a526$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
7826
+ (0, $iBTHO$solidjsweb.insert)(_el$3, input_field, null);
7827
+ (0, $iBTHO$solidjsweb.insert)(_el$3, make_category_suggestion_card_ ? (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7828
+ severity_: "error",
7829
+ message_: "Category suggestions failed",
7830
+ get children () {
7831
+ return (0, $iBTHO$solidjsweb.createComponent)((0, $04048c1bef16c249$export$c05a196222ba1302), {
7832
+ selected_filters_: selected_filters_,
7833
+ suggestions_: suggestions,
7834
+ slider_arrow_button_: slider_arrow_button_,
7835
+ children: make_category_suggestion_card_
7836
+ });
7837
+ }
7838
+ }) : null, null);
7839
+ (0, $iBTHO$solidjsweb.insert)(_el$3, ()=>results_filters[0](), null);
7840
+ (0, $iBTHO$solidjsweb.insert)(_el$3, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
7841
+ get when () {
7842
+ return selected_filters_[0]()?.length;
7843
+ },
7844
+ keyed: false,
7845
+ get children () {
7846
+ return (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7847
+ message_: "Selected filters failed",
7848
+ severity_: "error",
7849
+ get children () {
7850
+ return (0, $235a2771a44e28e9$export$fecbb157621501bd)({
7851
+ i18n_: i18n_,
7852
+ selected_filters_: selected_filters_,
7853
+ local_filter_cache_: local_filter_cache_,
7854
+ slider_arrow_button_: slider_arrow_button_,
7855
+ search_filters_open_: search_filters_open_,
7856
+ search_sorting_open_: search_sorting_open_,
7857
+ number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_,
7858
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_
7859
+ });
7860
+ }
7861
+ });
7862
+ }
7863
+ }), null);
7864
+ (0, $iBTHO$solidjsweb.insert)(_el$3, (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7865
+ severity_: "error",
7866
+ message_: "Search results failed",
7867
+ get children () {
7868
+ return (0, $fe76fb463cc60b89$export$3925f87b1545cfc6)({
7869
+ all_products_loaded_: all_products_loaded_,
7667
7870
  min_products_to_fetch_: min_products_to_fetch_,
7871
+ query_base_: search_query_base_,
7872
+ plp_results_: search_results_,
7873
+ depict_api_: depict_api_,
7874
+ first_result_in_viewport_: first_result_in_viewport_,
7875
+ last_result_in_viewport_: last_result_in_viewport_,
7668
7876
  scroll_restoration_data_: scroll_restoration_data_,
7669
- make_request_: (limit, cursor)=>depict_api_.query({
7670
- ...base_query,
7671
- limit: limit,
7672
- ...cursor ? {
7673
- cursor: cursor
7674
- } : {}
7675
- })
7877
+ desktop_filter_elements_: desktop_filter_elements_,
7878
+ rr_options_: rr_options_,
7879
+ layout_options_: layout_options_,
7880
+ sort_or_filter_open_: sort_or_filter_open_,
7881
+ tenant_object_: tenant_object_,
7882
+ type_for_tracking_: "search",
7883
+ id_currently_querying_for_: get_search_query,
7884
+ no_results_options_: {
7885
+ selected_filters_: selected_filters_,
7886
+ expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7887
+ local_filter_cache_: local_filter_cache_,
7888
+ i18n_: i18n_
7889
+ }
7676
7890
  });
7677
- }));
7678
- const [suggestions] = (0, $iBTHO$solidjs.createResource)((0, $iBTHO$solidjs.createMemo)(()=>({
7679
- query: search_query_[0](),
7680
- tenant: tenant_(),
7681
- market: market_()
7682
- })), (opts)=>depict_api_.suggest(opts));
7683
- const available_sortings_ = (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.sorts?.map((sort)=>({
7684
- ...sort,
7685
- order: sort.order ?? "desc"
7686
- })));
7687
- const available_filters_ = (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.filters);
7688
- const modal_body_style = (0, $iBTHO$solidjs.createSignal)({});
7689
- let input_field;
7690
- if (include_input_field_) {
7691
- const SafeQueryInput = (0, $iBTHO$depictaiutilishared.catchify)((0, $2f8c7dc07090fca9$export$ff21851bb5d30e15));
7692
- input_field = (0, $iBTHO$solidjsweb.createComponent)(SafeQueryInput, {
7891
+ }
7892
+ }), null);
7893
+ (0, $iBTHO$solidjsweb.insert)(_el$3, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
7894
+ get when () {
7895
+ return get_all_products_loaded() && !disable_search_recommendations_;
7896
+ },
7897
+ keyed: false,
7898
+ get children () {
7899
+ return (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7900
+ severity_: "error",
7901
+ message_: "Search recommendations failed",
7902
+ get children () {
7903
+ return (0, $iBTHO$solidjsweb.createComponent)((0, $fb29c6201c369e39$export$7de92c4c2205ebf3), {
7904
+ depict_api_: depict_api_,
7905
+ i18n_: i18n_,
7906
+ search_query_base_: search_query_base_,
7907
+ layout_options_: recommendations_layout_options_,
7908
+ showing_recommendation_rows_: showing_recommendation_rows_,
7909
+ rr_options_: recommendations_rr_options_,
7910
+ view_more_button_: search_recs_view_more_,
7911
+ tenant_object_: tenant_object_
7912
+ });
7913
+ }
7914
+ });
7915
+ }
7916
+ }), null);
7917
+ (0, $iBTHO$solidjsweb.insert)(_el$2, (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7918
+ message_: "Scroll status failed",
7919
+ severity_: "error",
7920
+ get children () {
7921
+ return (0, $401aee5f33dca9e2$export$83fd5de5504a7a67)({
7922
+ first_result_in_viewport_: first_result_in_viewport_,
7923
+ last_result_in_viewport_: last_result_in_viewport_,
7924
+ formatted_number_of_results_: formatted_number_of_results_,
7693
7925
  i18n_: i18n_,
7694
- disabled_: true,
7695
- search_query_: search_query_,
7696
- search_field_value_: search_field_value_,
7697
- submit_query_: submit_query_,
7698
- clear_filters_: clear_filters_on_next_submit_
7926
+ number_of_results_: (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.n_hits)
7699
7927
  });
7700
- if (input_field) {
7701
- opts?.modal_body_style_ref_?.(modal_body_style);
7702
- const align_position = (0, $iBTHO$depictaiutilishared.catchify)((0, $fd463ff0edb29915$export$b3ad617e9036868))(modal_body_style, input_field, undefined, true);
7703
- input_field.addEventListener("click", (0, $iBTHO$depictaiutilishared.catchify)((e)=>{
7704
- const target = e.target;
7705
- const sel = ".submit";
7706
- if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
7707
- return;
7708
- align_position?.();
7709
- open_modal_({
7710
- style_props_: modal_body_style
7711
- }, ()=>include_input_field_?.on_close_?.());
7712
- include_input_field_?.on_open_?.();
7713
- }));
7714
- }
7715
7928
  }
7716
- const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $iBTHO$solidjs.createSignal)(false);
7717
- const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $iBTHO$solidjs.createSignal)();
7718
- const formatted_number_of_results_ = (0, $0f400c3f7248d5f1$export$92f2da32c6e7e7ee)({
7719
- search_results_: search_results_,
7720
- i18n_: i18n_
7721
- });
7722
- const [sort_and_filter_element_, set_sort_and_filter_element_] = (0, $iBTHO$solidjs.createSignal)();
7723
- const results_for = (0, $iBTHO$solidjsweb.createComponent)((0, $65a0c4b1c2eb5d0b$export$9dd50d35b9d94fdf), {
7724
- search_query_: search_query_,
7725
- i18n_: i18n_,
7726
- formatted_number_of_results_: formatted_number_of_results_
7727
- });
7728
- const filters_opener = (0, $f8f64d05c525825b$export$d7841e452f2e59a8)({
7729
- set_sort_or_filter_open_: set_sort_or_filter_open_,
7730
- set_extra_els_in_results_container_: set_desktop_filter_elements,
7731
- i18n_: i18n_,
7732
- search_sorting_open_: search_sorting_open_,
7733
- available_filters_: available_filters_,
7734
- available_sortings_: available_sortings_,
7735
- search_filters_open_: search_filters_open_,
7736
- set_sort_and_filter_element_: set_sort_and_filter_element_,
7737
- current_sorting_: current_sorting_,
7738
- input_modal_open_: input_modal_open_,
7739
- expanded_filters_: expanded_filters_,
7740
- selected_filters_: selected_filters_,
7741
- formatted_number_of_results_: formatted_number_of_results_,
7742
- local_filter_cache_: local_filter_cache_,
7743
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7744
- number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_
7745
- });
7746
- const results_filters = (0, $iBTHO$solidjs.createSignal)();
7747
- (0, $iBTHO$solidjs.onCleanup)((0, $iBTHO$depictaiutilishared.javascript_media_query)("(max-width:600px)", async ({ matches: matches })=>{
7748
- results_filters[1]();
7749
- await new Promise((r)=>queueMicrotask(r));
7750
- results_filters[1](matches ? [
7751
- results_for,
7752
- filters_opener
7753
- ] : (()=>{
7754
- const _el$ = $f1d7cb69f839a526$var$_tmpl$.cloneNode(true);
7755
- (0, $iBTHO$solidjsweb.insert)(_el$, results_for, null);
7756
- (0, $iBTHO$solidjsweb.insert)(_el$, filters_opener, null);
7757
- return _el$;
7758
- })());
7759
- }).remove);
7760
- (0, $iBTHO$depictaiutilishared.catchify)((0, $276380e4607fb9fb$export$6e49da55e449af7c))({
7761
- scroll_restoration_data_: scroll_restoration_data_,
7762
- last_result_in_viewport_: last_result_in_viewport_,
7763
- id_: get_search_query,
7764
- can_write_scroll_restoration_: can_write_scroll_restoration_
7765
- });
7766
- (0, $iBTHO$solidjs.createComputed)(()=>{
7767
- if (search_results_.loading) set_can_write_scroll_restoration(false);
7768
- else if (search_results_()) set_can_write_scroll_restoration(true);
7769
- });
7770
- (0, $6b384adf40a5f4d7$export$e702733a056c40d6)({
7771
- selected_filters_: selected_filters_,
7772
- available_filters_: available_filters_
7773
- });
7774
- // @ts-ignore
7775
- if (process.env.GA !== "false") (0, $iBTHO$solidjs.createEffect)(()=>{
7776
- get_search_query();
7777
- (0, $341a019928b8b91e$export$c7e181728ad525f)(location);
7778
- });
7779
- (0, $iBTHO$solidjs.createComputed)(()=>{
7780
- tenant_object_.tenant = tenant_object_.TENANT = tenant_();
7781
- tenant_object_.market = tenant_object_.MARKET = market_();
7782
- });
7783
- return [
7784
- document.createComment("Depict.ai frontend integrated search page"),
7785
- (()=>{
7786
- const _el$2 = $f1d7cb69f839a526$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
7787
- (0, $iBTHO$solidjsweb.insert)(_el$3, input_field, null);
7788
- (0, $iBTHO$solidjsweb.insert)(_el$3, make_category_suggestion_card_ ? (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7789
- severity_: "error",
7790
- message_: "Category suggestions failed",
7791
- get children () {
7792
- return (0, $iBTHO$solidjsweb.createComponent)((0, $04048c1bef16c249$export$c05a196222ba1302), {
7793
- selected_filters_: selected_filters_,
7794
- suggestions_: suggestions,
7795
- slider_arrow_button_: slider_arrow_button_,
7796
- children: make_category_suggestion_card_
7797
- });
7798
- }
7799
- }) : null, null);
7800
- (0, $iBTHO$solidjsweb.insert)(_el$3, ()=>results_filters[0](), null);
7801
- (0, $iBTHO$solidjsweb.insert)(_el$3, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
7802
- get when () {
7803
- return selected_filters_[0]()?.length;
7804
- },
7805
- keyed: false,
7806
- get children () {
7807
- return (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7808
- message_: "Selected filters failed",
7809
- severity_: "error",
7810
- get children () {
7811
- return (0, $235a2771a44e28e9$export$fecbb157621501bd)({
7812
- i18n_: i18n_,
7813
- selected_filters_: selected_filters_,
7814
- local_filter_cache_: local_filter_cache_,
7815
- slider_arrow_button_: slider_arrow_button_,
7816
- search_filters_open_: search_filters_open_,
7817
- search_sorting_open_: search_sorting_open_,
7818
- number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_,
7819
- expanded_hierarchical_filters_: expanded_hierarchical_filters_
7820
- });
7821
- }
7822
- });
7823
- }
7824
- }), null);
7825
- (0, $iBTHO$solidjsweb.insert)(_el$3, (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7826
- severity_: "error",
7827
- message_: "Search results failed",
7828
- get children () {
7829
- return (0, $fe76fb463cc60b89$export$3925f87b1545cfc6)({
7830
- all_products_loaded_: all_products_loaded_,
7831
- min_products_to_fetch_: min_products_to_fetch_,
7832
- query_base_: search_query_base_,
7833
- plp_results_: search_results_,
7834
- depict_api_: depict_api_,
7835
- first_result_in_viewport_: first_result_in_viewport_,
7836
- last_result_in_viewport_: last_result_in_viewport_,
7837
- scroll_restoration_data_: scroll_restoration_data_,
7838
- desktop_filter_elements_: desktop_filter_elements_,
7839
- rr_options_: rr_options_,
7840
- layout_options_: layout_options_,
7841
- sort_or_filter_open_: sort_or_filter_open_,
7842
- tenant_object_: tenant_object_,
7843
- type_for_tracking_: "search",
7844
- id_currently_querying_for_: get_search_query,
7845
- no_results_options_: {
7846
- selected_filters_: selected_filters_,
7847
- expanded_hierarchical_filters_: expanded_hierarchical_filters_,
7848
- local_filter_cache_: local_filter_cache_,
7849
- i18n_: i18n_
7850
- }
7851
- });
7852
- }
7853
- }), null);
7854
- (0, $iBTHO$solidjsweb.insert)(_el$3, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
7855
- get when () {
7856
- return get_all_products_loaded() && !disable_search_recommendations_;
7857
- },
7858
- keyed: false,
7859
- get children () {
7860
- return (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7861
- severity_: "error",
7862
- message_: "Search recommendations failed",
7863
- get children () {
7864
- return (0, $iBTHO$solidjsweb.createComponent)((0, $fb29c6201c369e39$export$7de92c4c2205ebf3), {
7865
- depict_api_: depict_api_,
7866
- i18n_: i18n_,
7867
- search_query_base_: search_query_base_,
7868
- layout_options_: recommendations_layout_options_,
7869
- showing_recommendation_rows_: showing_recommendation_rows_,
7870
- rr_options_: recommendations_rr_options_,
7871
- view_more_button_: search_recs_view_more_,
7872
- tenant_object_: tenant_object_
7873
- });
7874
- }
7875
- });
7876
- }
7877
- }), null);
7878
- (0, $iBTHO$solidjsweb.insert)(_el$2, (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7879
- message_: "Scroll status failed",
7880
- severity_: "error",
7881
- get children () {
7882
- return (0, $401aee5f33dca9e2$export$83fd5de5504a7a67)({
7883
- first_result_in_viewport_: first_result_in_viewport_,
7884
- last_result_in_viewport_: last_result_in_viewport_,
7885
- formatted_number_of_results_: formatted_number_of_results_,
7886
- i18n_: i18n_,
7887
- number_of_results_: (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.n_hits)
7888
- });
7889
- }
7890
- }), null);
7891
- (0, $iBTHO$solidjsweb.insert)(_el$2, (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7892
- message_: "Floating buttons failed",
7893
- severity_: "error",
7894
- get children () {
7895
- return (0, $2fb324fbcc7b4a7b$export$b23abd26de154ede)({
7896
- search_filters_open_: search_filters_open_,
7897
- search_sorting_open_: search_sorting_open_,
7898
- current_sorting_: current_sorting_,
7899
- sort_and_filter_element_: sort_and_filter_element_,
7900
- i18n_: i18n_
7901
- });
7902
- }
7903
- }), null);
7904
- return _el$2;
7905
- })()
7906
- ];
7929
+ }), null);
7930
+ (0, $iBTHO$solidjsweb.insert)(_el$2, (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7931
+ message_: "Floating buttons failed",
7932
+ severity_: "error",
7933
+ get children () {
7934
+ return (0, $2fb324fbcc7b4a7b$export$b23abd26de154ede)({
7935
+ search_filters_open_: search_filters_open_,
7936
+ search_sorting_open_: search_sorting_open_,
7937
+ current_sorting_: current_sorting_,
7938
+ sort_and_filter_element_: sort_and_filter_element_,
7939
+ i18n_: i18n_
7940
+ });
7941
+ }
7942
+ }), null);
7943
+ return _el$2;
7944
+ })()
7945
+ ];
7946
+ }
7947
+
7948
+
7949
+
7950
+
7951
+
7952
+
7953
+
7954
+
7955
+
7956
+
7957
+
7958
+
7959
+
7960
+ const $ad63d2a35e827266$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<span class="orig price"></span>`, 2), $ad63d2a35e827266$var$_tmpl$2 = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<a class="instant-card"><div class="img_part"></div><div class="right_part"><div class="title_brand"><span class="brand"></span><span class="title"></span></div><div class="price_container"><span class="price"></span></div></div></a>`, 16);
7961
+ function $ad63d2a35e827266$export$3b5becc25bbaed73(display, _index, get_fake_rendering_options, i18n_) {
7962
+ const image_url = (0, $iBTHO$solidjs.createMemo)(()=>display().image_url);
7963
+ const contained_image = (0, $iBTHO$solidjs.createMemo)(()=>(0, $iBTHO$depictaiutilishared.ContainedImage)({
7964
+ aspect_ratio: 1,
7965
+ alt: "",
7966
+ // @ts-ignore
7967
+ "data-src": image_url(),
7968
+ rendering_options: (0, $iBTHO$solidjs.untrack)(()=>get_fake_rendering_options()),
7969
+ srcset_opts: {
7970
+ set_dataset: true
7971
+ },
7972
+ init_with_placeholder: true
7973
+ }));
7974
+ const is_sale = (0, $iBTHO$solidjs.createMemo)(()=>display().sale_price !== display().original_price);
7975
+ return (()=>{
7976
+ const _el$ = $ad63d2a35e827266$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
7977
+ (0, $iBTHO$solidjsweb.insert)(_el$2, contained_image);
7978
+ (0, $iBTHO$solidjsweb.insert)(_el$5, ()=>display().brand);
7979
+ (0, $iBTHO$solidjsweb.insert)(_el$6, ()=>display().title);
7980
+ (0, $iBTHO$solidjsweb.insert)(_el$7, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
7981
+ get when () {
7982
+ return is_sale();
7983
+ },
7984
+ get children () {
7985
+ const _el$8 = $ad63d2a35e827266$var$_tmpl$.cloneNode(true);
7986
+ (0, $iBTHO$solidjsweb.insert)(_el$8, ()=>i18n_.price_formatting_().pre_, null);
7987
+ (0, $iBTHO$solidjsweb.insert)(_el$8, ()=>(0, $d659702496cb72ea$export$469c7af753d08925)({
7988
+ price_: (0, $iBTHO$solidjs.createMemo)(()=>display().original_price),
7989
+ price_formatting_: i18n_.price_formatting_
7990
+ }), null);
7991
+ (0, $iBTHO$solidjsweb.insert)(_el$8, ()=>i18n_.price_formatting_().post_, null);
7992
+ return _el$8;
7907
7993
  }
7908
- })();
7909
- });
7994
+ }), _el$9);
7995
+ (0, $iBTHO$solidjsweb.insert)(_el$9, ()=>i18n_.price_formatting_().pre_, null);
7996
+ (0, $iBTHO$solidjsweb.insert)(_el$9, ()=>(0, $d659702496cb72ea$export$469c7af753d08925)({
7997
+ price_: (0, $iBTHO$solidjs.createMemo)(()=>display().sale_price),
7998
+ price_formatting_: i18n_.price_formatting_
7999
+ }), null);
8000
+ (0, $iBTHO$solidjsweb.insert)(_el$9, ()=>i18n_.price_formatting_().post_, null);
8001
+ (0, $iBTHO$solidjsweb.effect)(()=>(0, $iBTHO$solidjsweb.setAttribute)(_el$, "href", display().page_url));
8002
+ return _el$;
8003
+ })();
8004
+ }
8005
+
8006
+
8007
+
8008
+
8009
+
8010
+
8011
+
8012
+
8013
+
8014
+
8015
+
8016
+
8017
+
8018
+ const $dae23104ba8bb78c$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<span class="parent_title"></span>`, 2), $dae23104ba8bb78c$var$_tmpl$2 = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<a class="category-suggestion"><span class="title"></span></a>`, 4);
8019
+ function $dae23104ba8bb78c$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ , on_navigation_: on_navigation_ }) {
8020
+ return (()=>{
8021
+ const _el$ = $dae23104ba8bb78c$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild;
8022
+ (0, $iBTHO$solidjsweb.addEventListener)(_el$, "click", (0, $iBTHO$depictaiutilishared.catchify)((e)=>{
8023
+ if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
8024
+ return;
8025
+ return on_navigation_?.(category_suggestion_().page_url);
8026
+ }), true);
8027
+ (0, $iBTHO$solidjsweb.insert)(_el$2, ()=>category_suggestion_().title);
8028
+ (0, $iBTHO$solidjsweb.insert)(_el$, (0, $iBTHO$solidjsweb.createComponent)((0, $iBTHO$solidjs.Show), {
8029
+ get when () {
8030
+ return typeof category_suggestion_().parent_title === "string";
8031
+ },
8032
+ get children () {
8033
+ const _el$3 = $dae23104ba8bb78c$var$_tmpl$.cloneNode(true);
8034
+ (0, $iBTHO$solidjsweb.insert)(_el$3, ()=>category_suggestion_().parent_title);
8035
+ return _el$3;
8036
+ }
8037
+ }), null);
8038
+ (0, $iBTHO$solidjsweb.effect)(()=>(0, $iBTHO$solidjsweb.setAttribute)(_el$, "href", category_suggestion_().page_url));
8039
+ return _el$;
8040
+ })();
7910
8041
  }
8042
+ (0, $iBTHO$solidjsweb.delegateEvents)([
8043
+ "click"
8044
+ ]);
8045
+
7911
8046
 
8047
+ const $4e04be41243c3d80$var$transform_elements = (sorted_cols_at_size)=>{
8048
+ const cols_at_size = [];
8049
+ for(let i = 0; i < sorted_cols_at_size.length; i++){
8050
+ const [nb_cols, width] = sorted_cols_at_size[i];
8051
+ const next_width = sorted_cols_at_size[i + 1]?.[1];
8052
+ const max_width = i === 0 ? "" : `${width}px`;
8053
+ const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
8054
+ const col_at_size = [
8055
+ nb_cols,
8056
+ min_width,
8057
+ max_width
8058
+ ];
8059
+ cols_at_size.push(col_at_size);
8060
+ }
8061
+ return cols_at_size;
8062
+ };
8063
+ const $4e04be41243c3d80$export$6daf8749b65a1b77 = (cols_at_size)=>{
8064
+ // Check width duplicates
8065
+ const widths = cols_at_size.map(([_, width])=>width);
8066
+ const widths_set = new Set(widths);
8067
+ if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
8068
+ if (cols_at_size.length === 1) {
8069
+ const [nb_cols, width] = cols_at_size[0];
8070
+ const max_width = width !== undefined ? `${width}px` : "";
8071
+ return [
8072
+ [
8073
+ nb_cols,
8074
+ "",
8075
+ max_width
8076
+ ]
8077
+ ];
8078
+ }
8079
+ // Sort widths in ascending order
8080
+ const sorted_cols_at_size = cols_at_size.sort((a, b)=>{
8081
+ const [_b, width_A] = a;
8082
+ const [_a, width_b] = b;
8083
+ if (width_A === undefined) return -1;
8084
+ if (width_b === undefined) return 1;
8085
+ return width_b - width_A;
8086
+ });
8087
+ return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
8088
+ };
7912
8089
 
7913
8090
 
7914
8091
 
7915
- class $d06dbfcc8cd5a5bb$export$4b85d3515bd863a5 {
8092
+
8093
+ const $fd2d5ef67fc09716$var$_tmpl$ = /*#__PURE__*/ (0, $iBTHO$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
8094
+ /**
8095
+ * 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.
8096
+ */ const $fd2d5ef67fc09716$var$privately_shared_properties = new WeakMap();
8097
+ const $fd2d5ef67fc09716$var$min_products_to_fetch_ = 20;
8098
+ const $fd2d5ef67fc09716$export$bde3eb976dfded9 = (depict_search)=>$fd2d5ef67fc09716$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
8099
+ class $fd2d5ef67fc09716$export$ac6237957a15b3f0 {
7916
8100
  #locale_signal = (0, $iBTHO$solidjs.createSignal)();
7917
- #tenant_signal = (0, $iBTHO$solidjs.createSignal)();
8101
+ #merchant_signal = (0, $iBTHO$solidjs.createSignal)();
7918
8102
  #market_signal = (0, $iBTHO$solidjs.createSignal)();
7919
8103
  #modal_open_signal = (0, $iBTHO$solidjs.createSignal)(false);
7920
- #constructor_options;
7921
- #query_input_opts;
7922
- #booted = false;
7923
8104
  static #has_been_constructed = false;
7924
- constructor(opts){
7925
- if ($d06dbfcc8cd5a5bb$export$4b85d3515bd863a5.#has_been_constructed) throw new Error("You can only have one instance of Search due to state limitations");
7926
- $d06dbfcc8cd5a5bb$export$4b85d3515bd863a5.#has_been_constructed = true;
7927
- this.#constructor_options = opts;
8105
+ constructor({ search_query_url_param_name: search_query_url_param_name = "search_query" , url_transformer: url_transformer , on_navigation: on_navigation , enable_category_suggestions: enable_category_suggestions = true , ...props_on_class }){
8106
+ if ($fd2d5ef67fc09716$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
8107
+ Object.assign(this, props_on_class);
8108
+ const alternative_query_submitter_for_spas_ = on_navigation && ((search_param_name, new_search_query, url_transformer)=>{
8109
+ const target_url = new URL(location.href);
8110
+ url_transformer?.(target_url);
8111
+ target_url.searchParams.set(search_param_name, new_search_query);
8112
+ on_navigation(target_url.href);
8113
+ });
8114
+ const [reset_history_state_, state_] = (0, $26a56f6b44703084$export$9862539c89138352)(()=>({
8115
+ search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
8116
+ search_sorting: undefined,
8117
+ search_filters_open: false,
8118
+ search_sorting_open: false,
8119
+ search_expanded_filters: [],
8120
+ // 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
8121
+ search_selected_filters: [],
8122
+ search_local_filter_cache: [],
8123
+ search_expanded_hierarchical_filters: [],
8124
+ search_showing_recommendation_rows: (0, $fb29c6201c369e39$export$1c8c715550dc689d),
8125
+ search_scroll_restoration_data: []
8126
+ }));
8127
+ const search_query_updating_blocked_ = (0, $iBTHO$solidjs.createSignal)(false);
8128
+ const { [search_query_url_param_name]: raw_search_query_signal } = (0, $b7d0212db218bf0b$export$2542ffb77b620b02)({
8129
+ [search_query_url_param_name]: ""
8130
+ });
8131
+ const search_query_signal_ = (0, $iBTHO$solidjs.createSignal)((0, $iBTHO$solidjs.untrack)(raw_search_query_signal[0]));
8132
+ const depict_api_ = new (0, $e1d6c0f3d89d531c$export$e015ed2f2950f2e3)();
8133
+ const previous_searches = (0, $2b7a005a65221045$export$84bba84a7b837187)(search_query_signal_);
8134
+ const [, set_search_showing_recommendation_rows] = state_.search_showing_recommendation_rows;
8135
+ const after_submit_ = ()=>set_search_showing_recommendation_rows((0, $fb29c6201c369e39$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
8136
+ const configured_submit_query_ = ()=>(0, $f328bd45f8ede33c$export$e16630ecb9644a1c)({
8137
+ on_submit_with_unchanged_value_: ()=>this.modal_open = false,
8138
+ search_field_value_: state_.search_field_value,
8139
+ search_query_: search_query_signal_,
8140
+ search_param_name_: search_query_url_param_name,
8141
+ url_transformer_: url_transformer,
8142
+ on_submit_: alternative_query_submitter_for_spas_,
8143
+ after_submit_: after_submit_
8144
+ });
8145
+ const i18n_ = Object.fromEntries(Object.keys((0, $iBTHO$solidjs.untrack)(()=>this.localization)).map((key)=>[
8146
+ key,
8147
+ (0, $iBTHO$solidjs.createMemo)(()=>this.localization[key])
8148
+ ]));
8149
+ const clear_filters_on_next_submit_ = (0, $b34ce0b89e6db4e1$export$e026af0c7b64ea5f)({
8150
+ selected_filters_: state_.search_selected_filters,
8151
+ search_query_: search_query_signal_,
8152
+ current_sorting_: state_.search_sorting,
8153
+ expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
8154
+ i18n_: i18n_,
8155
+ local_filter_cache_: state_.search_local_filter_cache
8156
+ });
8157
+ (0, $iBTHO$solidjs.createComputed)(()=>{
8158
+ const [get_search_query_updating_blocked] = search_query_updating_blocked_;
8159
+ const [get_raw_search_query_signal] = raw_search_query_signal;
8160
+ const [, set_search_query_signal] = search_query_signal_; // this signal won't get written from anywhere, see url_params_to_signals JSDoc
8161
+ if (!get_search_query_updating_blocked()) set_search_query_signal(get_raw_search_query_signal());
8162
+ });
8163
+ $fd2d5ef67fc09716$var$privately_shared_properties.set(this, {
8164
+ search_query_url_param_name_: search_query_url_param_name,
8165
+ reset_history_state_: reset_history_state_,
8166
+ state_: state_,
8167
+ on_navigation_: on_navigation,
8168
+ url_transformer_: url_transformer,
8169
+ depict_api_: depict_api_,
8170
+ enable_category_suggestions_: enable_category_suggestions,
8171
+ clear_filters_on_next_submit_: clear_filters_on_next_submit_,
8172
+ configured_submit_query_: configured_submit_query_,
8173
+ search_query_signal_: search_query_signal_,
8174
+ i18n_: i18n_,
8175
+ search_query_updating_blocked_: search_query_updating_blocked_
8176
+ });
7928
8177
  (0, $d84fe647b84b5dc5$export$5162a71f252e6122)();
8178
+ (0, $iBTHO$depictaiutilishared.catchify)(async ()=>{
8179
+ const { open_modal_: open_modal_ , close_modal_: close_modal_ } = await (0, $9abb0a35d4b60ed3$export$79b1565500412d9b)((...args)=>{
8180
+ (0, $iBTHO$solidjs.onCleanup)(()=>this.modal_open = false);
8181
+ return (0, $f40a47a30a358305$export$1c593cbd6f1e10bc)(...args);
8182
+ }, {
8183
+ after_submit_: after_submit_,
8184
+ search_field_value_: state_.search_field_value,
8185
+ search_query_: search_query_signal_,
8186
+ search_page_url_param_name_: search_query_url_param_name,
8187
+ previous_searches_: previous_searches,
8188
+ depict_api_: depict_api_,
8189
+ tenant_: this.#merchant_signal[0],
8190
+ clear_filters_: clear_filters_on_next_submit_,
8191
+ market_: this.#market_signal[0],
8192
+ submit_query_: configured_submit_query_,
8193
+ alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
8194
+ url_transformer_: url_transformer,
8195
+ instant_results_options_: {
8196
+ min_products_to_fetch_: $fd2d5ef67fc09716$var$min_products_to_fetch_,
8197
+ render_instant_card_: (0, $ad63d2a35e827266$export$3b5becc25bbaed73),
8198
+ render_instant_card_placeholder_: (0, $6f604560873e4f69$export$ee1733d9a8495996),
8199
+ has_sort_or_filters_: (0, $iBTHO$solidjs.createMemo)(()=>!!(Object.keys(state_.search_selected_filters[0]())?.length || state_.search_sorting[0]()))
8200
+ },
8201
+ i18n_: i18n_,
8202
+ enable_category_suggestions_: enable_category_suggestions
8203
+ });
8204
+ // This will add some default behaviour to open_modal_ if no style_props_ are supplied
8205
+ // The default behaviour is to align the modal with the input field if possible
8206
+ (0, $iBTHO$solidjs.createComputed)(()=>{
8207
+ const open_signal_value = this.modal_open;
8208
+ const signal_value_is_options = Array.isArray(open_signal_value);
8209
+ // Close modal if signal is false
8210
+ if (!open_signal_value) {
8211
+ close_modal_();
8212
+ return;
8213
+ }
8214
+ const { search_page_aligned_modal_body_style_signal_: search_page_aligned_modal_body_style_signal_ } = $fd2d5ef67fc09716$var$privately_shared_properties.get(this);
8215
+ if (signal_value_is_options && open_signal_value[0]?.style_props_) {
8216
+ // They know what they're doing, just call the modal with the provided options
8217
+ open_modal_(...open_signal_value);
8218
+ return;
8219
+ }
8220
+ if (!open_signal_value[0]?.style_props_ && search_page_aligned_modal_body_style_signal_) {
8221
+ // Open modal aligned with search page if no alignment specified and possible to align with search page
8222
+ // TODO: nice to have: align with most visible SearchField if possible since that's always more desirable than centering
8223
+ if (!signal_value_is_options) {
8224
+ open_modal_({
8225
+ style_props_: search_page_aligned_modal_body_style_signal_
8226
+ });
8227
+ return;
8228
+ }
8229
+ const [options_arg, ...rest] = open_signal_value;
8230
+ open_modal_({
8231
+ ...options_arg,
8232
+ style_props_: search_page_aligned_modal_body_style_signal_
8233
+ }, ...rest);
8234
+ return;
8235
+ }
8236
+ // Open centered modal
8237
+ const supports_hover = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(hover: hover) and (pointer: fine)");
8238
+ const slim = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-width: 600px)");
8239
+ const desktop_short = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-height: 790px)");
8240
+ const mobile_short = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-height: 1000px)");
8241
+ const transform_x = (0, $iBTHO$solidjs.createSignal)(false);
8242
+ const transform_y = (0, $iBTHO$solidjs.createSignal)(false);
8243
+ const style_props_ = (0, $iBTHO$solidjs.createSignal)({
8244
+ position: "fixed",
8245
+ top: "50%",
8246
+ left: "50%"
8247
+ });
8248
+ (0, $iBTHO$solidjs.createComputed)(()=>transform_y[1](supports_hover() ? !desktop_short() : !mobile_short()));
8249
+ (0, $iBTHO$solidjs.createComputed)(()=>transform_x[1](transform_y[0]() || !slim()));
8250
+ (0, $iBTHO$solidjs.createComputed)(()=>style_props_[1]((old_value)=>({
8251
+ ...old_value,
8252
+ transform: transform_x[0]() && transform_y[0]() ? "translate(-50%,-50%)" : transform_x[0]() ? "translateX(-50%)" : transform_y[0]() ? "translateY(-50%)" : "unset"
8253
+ })));
8254
+ if (signal_value_is_options) {
8255
+ const [options_arg1, ...rest1] = open_signal_value;
8256
+ open_modal_({
8257
+ ...options_arg1,
8258
+ style_props_: search_page_aligned_modal_body_style_signal_
8259
+ }, ...rest1);
8260
+ return;
8261
+ }
8262
+ open_modal_({
8263
+ style_props_: style_props_
8264
+ });
8265
+ });
8266
+ })();
8267
+ $fd2d5ef67fc09716$export$ac6237957a15b3f0.#has_been_constructed = true;
7929
8268
  }
7930
- get locale_() {
8269
+ get localization() {
7931
8270
  // allow reactive access
7932
8271
  return this.#locale_signal[0]();
7933
8272
  }
7934
- set locale_(locale_obj) {
8273
+ set localization(locale_obj) {
7935
8274
  this.#locale_signal[1](locale_obj);
7936
8275
  }
7937
- get readonly_modal_open_() {
8276
+ get modal_open() {
7938
8277
  return this.#modal_open_signal[0]();
7939
8278
  }
7940
- get tenant_() {
7941
- return this.#tenant_signal[0]();
8279
+ set modal_open(new_state) {
8280
+ this.#modal_open_signal[1](new_state);
7942
8281
  }
7943
- set tenant_(tenant) {
7944
- this.#tenant_signal[1](tenant);
8282
+ get merchant() {
8283
+ return this.#merchant_signal[0]();
7945
8284
  }
7946
- get market_() {
8285
+ set merchant(tenant) {
8286
+ this.#merchant_signal[1](tenant);
8287
+ }
8288
+ get market() {
7947
8289
  return this.#market_signal[0]();
7948
8290
  }
7949
- set market_(market) {
8291
+ set market(market) {
7950
8292
  this.#market_signal[1](market);
7951
8293
  }
7952
- get boot_() {
7953
- return (0, $iBTHO$depictaiutilishared.catchify)(async ()=>{
7954
- if (!this.locale_) throw new Error("Can't start before locale is defined");
7955
- if (this.#booted) throw new Error("Already booted");
7956
- const search_query_url_param_name = this.#constructor_options.search_page_.search_query_param_name_ ?? "search_query";
7957
- let open_modal_;
7958
- let close_modal_;
7959
- const [reset_history_state, { search_field_value: search_field_value , search_sorting: search_sorting , search_filters_open: search_filters_open , search_sorting_open: search_sorting_open , search_expanded_filters: search_expanded_filters , search_local_filter_cache: search_local_filter_cache , search_selected_filters: search_selected_filters , search_expanded_hierarchical_filters: search_expanded_hierarchical_filters , search_showing_recommendation_rows: search_showing_recommendation_rows , search_scroll_restoration_data: search_scroll_restoration_data }] = (0, $26a56f6b44703084$export$9862539c89138352)(()=>({
7960
- search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
7961
- search_sorting: undefined,
7962
- search_filters_open: false,
7963
- search_sorting_open: false,
7964
- search_expanded_filters: [],
7965
- // 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
7966
- search_selected_filters: [],
7967
- search_local_filter_cache: [],
7968
- search_expanded_hierarchical_filters: [],
7969
- search_showing_recommendation_rows: (0, $fb29c6201c369e39$export$1c8c715550dc689d),
7970
- search_scroll_restoration_data: []
7971
- }));
7972
- const { [search_query_url_param_name]: search_query_signal } = (0, $b7d0212db218bf0b$export$2542ffb77b620b02)({
7973
- [search_query_url_param_name]: ""
7974
- });
7975
- const previous_searches = (0, $2b7a005a65221045$export$84bba84a7b837187)(search_query_signal);
7976
- const [, set_search_showing_recommendation_rows] = search_showing_recommendation_rows;
7977
- const after_submit_ = ()=>set_search_showing_recommendation_rows((0, $fb29c6201c369e39$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
7978
- const configured_submit_query = ()=>(0, $f328bd45f8ede33c$export$e16630ecb9644a1c)({
7979
- on_submit_with_unchanged_value_: ()=>close_modal_?.(),
7980
- search_field_value_: search_field_value,
7981
- search_query_: search_query_signal,
7982
- search_param_name_: search_query_url_param_name,
7983
- url_transformer_: this.#constructor_options.url_transformer_,
7984
- on_submit_: this.#constructor_options.alternative_query_submitter_for_spas_,
7985
- after_submit_: after_submit_
8294
+ }
8295
+ function $fd2d5ef67fc09716$var$get_shared_properties(depict_search) {
8296
+ const shared_properties = $fd2d5ef67fc09716$var$privately_shared_properties.get(depict_search);
8297
+ if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
8298
+ return shared_properties;
8299
+ }
8300
+ function $fd2d5ef67fc09716$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, $iBTHO$depictaiutilishared.normal_get_product_id) }) {
8301
+ const shared_properties = $fd2d5ef67fc09716$var$get_shared_properties(depict_search);
8302
+ return $fd2d5ef67fc09716$var$run_in_root_or_auto_cleanup(()=>{
8303
+ const { state_: state_ } = shared_properties;
8304
+ (0, $iBTHO$solidjs.onCleanup)(shared_properties.reset_history_state_);
8305
+ return (0, $f1d7cb69f839a526$export$a54ec244c8863715)({
8306
+ input_modal_open_: ()=>!!depict_search.modal_open,
8307
+ tenant_: ()=>depict_search.merchant,
8308
+ market_: ()=>depict_search.market,
8309
+ depict_api_: shared_properties.depict_api_,
8310
+ min_products_to_fetch_: $fd2d5ef67fc09716$var$min_products_to_fetch_,
8311
+ local_filter_cache_: state_.search_local_filter_cache,
8312
+ search_field_value_: state_.search_field_value,
8313
+ search_query_: shared_properties.search_query_signal_,
8314
+ clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
8315
+ open_modal_: (...args)=>depict_search.modal_open = args,
8316
+ submit_query_: shared_properties.configured_submit_query_,
8317
+ i18n_: shared_properties.i18n_,
8318
+ modal_body_style_ref_: (style)=>{
8319
+ const shared_info_right_now = $fd2d5ef67fc09716$var$privately_shared_properties.get(depict_search);
8320
+ if (!shared_info_right_now) return;
8321
+ $fd2d5ef67fc09716$var$privately_shared_properties.set(depict_search, {
8322
+ ...shared_info_right_now,
8323
+ search_page_aligned_modal_body_style_signal_: style
7986
8324
  });
7987
- const i18n_ = Object.fromEntries(Object.keys((0, $iBTHO$solidjs.untrack)(()=>this.locale_)).map((key)=>[
7988
- key,
7989
- (0, $iBTHO$solidjs.createMemo)(()=>this.locale_[key])
7990
- ]));
7991
- const min_products_to_fetch_ = 20;
7992
- const [input_modal_open, set_input_model_open] = this.#modal_open_signal;
7993
- const clear_filters_on_next_submit_ = (0, $b34ce0b89e6db4e1$export$e026af0c7b64ea5f)({
7994
- selected_filters_: search_selected_filters,
7995
- search_query_: search_query_signal,
7996
- current_sorting_: search_sorting,
7997
- expanded_hierarchical_filters_: search_expanded_hierarchical_filters,
7998
- i18n_: i18n_,
7999
- local_filter_cache_: search_local_filter_cache
8000
- });
8001
- let modal_body_style;
8002
- const search_page_options = this.#constructor_options.search_page_;
8003
- const pr = new (0, $0a6acf31d1eae57c$export$3ccaa27d81dd8556)({
8004
- is_page_: search_page_options.is_search_page_,
8005
- title_: search_page_options.page_title_,
8006
- selector_: search_page_options.selector_for_page_to_replace_,
8007
- append_instead_of_replace_: search_page_options.append_instead_of_replace_,
8008
- render_: ()=>{
8009
- const rendered_page = (0, $f1d7cb69f839a526$export$a54ec244c8863715)({
8010
- ...search_page_options,
8011
- input_modal_open_: input_modal_open,
8012
- tenant_: this.#tenant_signal[0],
8013
- market_: this.#market_signal[0],
8014
- depict_api_: this.#constructor_options.depict_api_,
8015
- page_replacer_: pr,
8016
- min_products_to_fetch_: min_products_to_fetch_,
8017
- local_filter_cache_: search_local_filter_cache,
8018
- search_field_value_: search_field_value,
8019
- search_query_: search_query_signal,
8020
- clear_filters_on_next_submit_: clear_filters_on_next_submit_,
8021
- open_modal_: (...args)=>open_modal_?.(...args),
8022
- submit_query_: configured_submit_query,
8023
- i18n_: i18n_,
8024
- modal_body_style_ref_: (style)=>modal_body_style = style,
8025
- current_sorting_: search_sorting,
8026
- search_filters_open_: search_filters_open,
8027
- search_sorting_open_: search_sorting_open,
8028
- expanded_filters_: search_expanded_filters,
8029
- make_category_suggestion_card_: this.#constructor_options.enable_category_suggestions_ ?? true ? search_page_options.make_category_suggestion_card_ : false,
8030
- expanded_hierarchical_filters_: search_expanded_hierarchical_filters,
8031
- selected_filters_: search_selected_filters,
8032
- showing_recommendation_rows_: search_showing_recommendation_rows,
8033
- scroll_restoration_data_: search_scroll_restoration_data
8325
+ (0, $iBTHO$solidjs.onCleanup)(()=>{
8326
+ const shared_info_right_now = $fd2d5ef67fc09716$var$privately_shared_properties.get(depict_search);
8327
+ if (!shared_info_right_now || shared_info_right_now.search_page_aligned_modal_body_style_signal_ !== style) return;
8328
+ $fd2d5ef67fc09716$var$privately_shared_properties.set(depict_search, {
8329
+ ...shared_info_right_now,
8330
+ search_page_aligned_modal_body_style_signal_: undefined
8034
8331
  });
8035
- return search_page_options.wrap_search_page_?.(rendered_page) || rendered_page;
8332
+ });
8333
+ },
8334
+ current_sorting_: state_.search_sorting,
8335
+ search_filters_open_: state_.search_filters_open,
8336
+ search_sorting_open_: state_.search_sorting_open,
8337
+ expanded_filters_: state_.search_expanded_filters,
8338
+ make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? (category_suggestion_)=>{
8339
+ return (0, $dae23104ba8bb78c$export$d757d54550ebfb3d)({
8340
+ category_suggestion_: category_suggestion_,
8341
+ on_navigation_: shared_properties.on_navigation_
8342
+ });
8343
+ } : false,
8344
+ expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
8345
+ selected_filters_: state_.search_selected_filters,
8346
+ showing_recommendation_rows_: state_.search_showing_recommendation_rows,
8347
+ scroll_restoration_data_: state_.search_scroll_restoration_data,
8348
+ include_input_field_: include_input_field,
8349
+ layout_options_: {
8350
+ cols_at_size: (0, $4e04be41243c3d80$export$6daf8749b65a1b77)(cols_at_size),
8351
+ ...typeof grid_spacing === "string" ? {
8352
+ grid_spacing: grid_spacing
8353
+ } : {
8354
+ override_vertical_spacing: grid_spacing.vertical,
8355
+ grid_spacing: grid_spacing.horizontal
8036
8356
  }
8037
- });
8038
- pr.addEventListener("close", (0, $iBTHO$depictaiutilishared.catchify)(reset_history_state)); // when closing search page, reset everything
8039
- this.#constructor_options.page_replacer_ref_?.(pr);
8040
- const modal_options = this.#constructor_options.modal_options_;
8041
- ({ open_modal_: open_modal_ , close_modal_: close_modal_ } = await (0, $9abb0a35d4b60ed3$export$79b1565500412d9b)((...args)=>{
8042
- set_input_model_open(true);
8043
- (0, $iBTHO$solidjs.onCleanup)(()=>set_input_model_open(false));
8044
- return (0, $f40a47a30a358305$export$1c593cbd6f1e10bc)(...args);
8045
- }, {
8046
- after_submit_: after_submit_,
8047
- search_field_value_: search_field_value,
8048
- search_query_: search_query_signal,
8049
- search_page_url_param_name_: search_query_url_param_name,
8050
- previous_searches_: previous_searches,
8051
- depict_api_: this.#constructor_options.depict_api_,
8052
- tenant_: this.#tenant_signal[0],
8053
- clear_filters_: clear_filters_on_next_submit_,
8054
- market_: this.#market_signal[0],
8055
- submit_query_: configured_submit_query,
8056
- alternative_query_submitter_for_spas_: this.#constructor_options.alternative_query_submitter_for_spas_,
8057
- url_transformer_: this.#constructor_options.url_transformer_,
8058
- instant_results_options_: {
8059
- min_products_to_fetch_: min_products_to_fetch_,
8060
- render_instant_card_: modal_options.render_instant_card_,
8061
- render_instant_card_placeholder_: modal_options.render_instant_card_placeholder_,
8062
- has_sort_or_filters_: (0, $iBTHO$solidjs.createMemo)(()=>!!(Object.keys(search_selected_filters[0]())?.length || search_sorting[0]()))
8063
- },
8064
- i18n_: i18n_,
8065
- disable_scrolling_: modal_options.disable_scrolling_,
8066
- enable_category_suggestions_: this.#constructor_options.enable_category_suggestions_,
8067
- bottom_distance_under_modal_: modal_options.bottom_distance_under_modal_
8068
- }));
8069
- this.#query_input_opts = {
8070
- search_query_: search_query_signal,
8071
- search_field_value_: search_field_value,
8072
- submit_query_: configured_submit_query,
8073
- clear_filters_: clear_filters_on_next_submit_,
8074
- i18n_: i18n_
8075
- };
8076
- this.#booted = true;
8077
- // This will add some default behaviour to open_modal_ if no style_props_ are supplied
8078
- // The default behaviour is to align the modal with the input field if possible
8079
- const wrapped_open_modal = (...args)=>{
8080
- if (!args[0].style_props_ && modal_body_style) return open_modal_({
8081
- ...args[0],
8082
- style_props_: modal_body_style
8083
- }, ...args.slice(1) // Not sure I can tell TypeScript that these are the rest of the arguments
8084
- );
8085
- else return open_modal_(...args);
8086
- };
8087
- return {
8088
- close_modal_: close_modal_,
8089
- open_modal_: wrapped_open_modal
8090
- };
8357
+ },
8358
+ slider_arrow_button_: (0, $iBTHO$depictaiutilishared.GenericSliderArrowButton)({
8359
+ height_: 12,
8360
+ width_: 6.46
8361
+ }),
8362
+ rr_options_: {
8363
+ template: product_card_template
8364
+ },
8365
+ get_product_id_: get_product_id
8091
8366
  });
8092
- }
8093
- get get_query_input() {
8094
- return (opts = {})=>{
8095
- if (!this.#booted) throw new Error("Instance not booted");
8096
- return (0, $2f8c7dc07090fca9$export$ff21851bb5d30e15)({
8097
- disabled_: true,
8098
- ...opts,
8099
- ...this.#query_input_opts
8100
- });
8101
- };
8102
- }
8367
+ }, "Entire SearchPage failed");
8368
+ }
8369
+ function $fd2d5ef67fc09716$export$b94867ecbd698f21({ depict_search: depict_search , modal_dispose_handler: modal_dispose_handler }) {
8370
+ const shared_properties = $fd2d5ef67fc09716$var$get_shared_properties(depict_search);
8371
+ return $fd2d5ef67fc09716$var$run_in_root_or_auto_cleanup(()=>{
8372
+ const input = (0, $iBTHO$solidjsweb.createComponent)((0, $2f8c7dc07090fca9$export$ff21851bb5d30e15), {
8373
+ get search_query_ () {
8374
+ return shared_properties.search_query_signal_;
8375
+ },
8376
+ get search_field_value_ () {
8377
+ return shared_properties.state_.search_field_value;
8378
+ },
8379
+ get submit_query_ () {
8380
+ return shared_properties.configured_submit_query_;
8381
+ },
8382
+ get clear_filters_ () {
8383
+ return shared_properties.clear_filters_on_next_submit_;
8384
+ },
8385
+ get i18n_ () {
8386
+ return shared_properties.i18n_;
8387
+ },
8388
+ disabled_: true,
8389
+ field_element_ref_: (field)=>{
8390
+ const handler = (0, $iBTHO$depictaiutilishared.catchify)(()=>{
8391
+ depict_search.modal_open = [
8392
+ {
8393
+ style_props_: style_props_
8394
+ },
8395
+ modal_dispose_handler
8396
+ ];
8397
+ });
8398
+ field.addEventListener("click", handler);
8399
+ (0, $iBTHO$solidjs.onCleanup)(()=>field.removeEventListener("click", handler));
8400
+ }
8401
+ });
8402
+ const style_props_ = (0, $iBTHO$solidjs.createSignal)({
8403
+ position: "fixed"
8404
+ });
8405
+ (0, $fd463ff0edb29915$export$b3ad617e9036868)(style_props_, input);
8406
+ return [
8407
+ (()=>{
8408
+ const _el$ = $fd2d5ef67fc09716$var$_tmpl$.cloneNode(true);
8409
+ (0, $iBTHO$solidjsweb.insert)(_el$, input);
8410
+ return _el$;
8411
+ })()
8412
+ ];
8413
+ }, "SearchField failed");
8414
+ }
8415
+ function $fd2d5ef67fc09716$var$run_in_root_or_auto_cleanup(component, error_message) {
8416
+ const component_in_error_boundary = (do_with_elements)=>{
8417
+ return (0, $edafe91daf3091d7$export$b69d0d92862de18b)({
8418
+ severity_: "error",
8419
+ message_: error_message,
8420
+ get children () {
8421
+ const elements = component();
8422
+ do_with_elements?.(elements);
8423
+ return elements;
8424
+ }
8425
+ })();
8426
+ };
8427
+ const owner = (0, $iBTHO$solidjs.getOwner)();
8428
+ if (owner == null) return (0, $iBTHO$solidjs.createRoot)((dispose)=>{
8429
+ // if we're not already run in a root, create a root and automatically dispose it when the first returned element is removed from the DOM
8430
+ return component_in_error_boundary((elements)=>{
8431
+ if (!elements?.length) return;
8432
+ (0, $iBTHO$depictaiutilishared.observer).onremoved(elements[0], dispose);
8433
+ });
8434
+ });
8435
+ else // we're already in a root so cleanups are handled
8436
+ return component_in_error_boundary();
8103
8437
  }
8104
8438
 
8105
8439