@depict-ai/ui 3.0.3 → 3.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/latest/index.cjs CHANGED
@@ -77,7 +77,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
77
77
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
78
78
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
79
79
  /*! Depict.ai search and product listing SDK */
80
- const $b757f75811f3261f$export$83d89fbfd8236492 = "3.0.3";
80
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "3.0.5";
81
81
  const $0f313083912e447a$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 14 26"><path d="M2 24.656c-.078 0-.156-.016-.234-.047s-.133-.066-.187-.129c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422l10.371-10.371L1.578 2.883c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422.258-.176.422-.176.305.059.422.176l10.805 10.793a.59.59 0 0 1 .176.434c0 .172-.059.305-.176.422L2.422 24.48a.42.42 0 0 1-.199.129.54.54 0 0 1-.223.047zm0 0"fill=#0f0f0f>`);
82
82
  function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
83
83
  return (() => {
@@ -488,7 +488,7 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
488
488
  event_: event_,
489
489
  force_spa_navigation_: force_spa_navigation_,
490
490
  is_replace_: is_replace_,
491
- listing_id_: listing_id_,
491
+ listing_query_: listing_query_,
492
492
  scroll = true
493
493
  }) => {
494
494
  const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
@@ -509,10 +509,10 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
509
509
  if (force_spa_navigation_ && wants_hard_navigation) {
510
510
  // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
511
511
  const new_state = history.state;
512
- if (listing_id_) {
512
+ if (listing_query_) {
513
513
  // In JS-UI we need to know the listing_id of the current category, therefore push it into state
514
- if (!this.listing_id_state_key) $gVhhF$depictaiutilishared.report(new Error("listing_id_state_key is not set"), "error");
515
- new_state[this.listing_id_state_key] = listing_id_;
514
+ if (!this.listing_query_state_key) $gVhhF$depictaiutilishared.report(new Error("listing_query_state_key is not set"), "error");
515
+ new_state[this.listing_query_state_key] = listing_query_;
516
516
  }
517
517
  history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
518
518
  } else this.#throwing_on_navigation.call(this, {
@@ -523,8 +523,8 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
523
523
  await promise;
524
524
  })
525
525
  };
526
- constructor(on_navigation, listing_id_state_key) {
527
- this.listing_id_state_key = listing_id_state_key;
526
+ constructor(on_navigation, listing_query_state_key) {
527
+ this.listing_query_state_key = listing_query_state_key;
528
528
  this.on_navigation_ = on_navigation;
529
529
  }
530
530
  }
@@ -980,27 +980,31 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
980
980
  });
981
981
  }
982
982
  // source: https://medium.com/@pancemarko/deep-equality-in-javascript-determining-if-two-objects-are-equal-bf98cf47e934
983
+ // deeply diffs two objects
984
+ // Modified by chatGPT to not be recursive, since stiga was getting a stack overflow just due to the size of their data
985
+ // Modified futher to bias towards saying objects are equal non-primitive objects differ
983
986
  function $a73063cc642f3e5f$var$deep_equal(obj1, obj2) {
984
- if (obj1 === obj2) return true;
985
- if (Array.isArray(obj1) && Array.isArray(obj2)) {
986
- if (obj1.length !== obj2.length) return false;
987
- return obj1.every((elem, index) => {
988
- return $a73063cc642f3e5f$var$deep_equal(elem, obj2[index]);
989
- });
990
- }
991
- if (typeof obj1 === "object" && typeof obj2 === "object" && obj1 !== null && obj2 !== null) {
992
- if (Array.isArray(obj1) || Array.isArray(obj2)) return false;
993
- const keys1 = Object.keys(obj1);
994
- const keys2 = Object.keys(obj2);
995
- if (keys1.length !== keys2.length || !keys1.every(key => keys2.includes(key))) return false;
996
- for (const key in obj1) {
997
- if ($a73063cc642f3e5f$var$result_ids.includes(key)) continue; // ignore keys changing with every request
998
- const isEqual = $a73063cc642f3e5f$var$deep_equal(obj1[key], obj2[key]);
999
- if (!isEqual) return false;
1000
- }
1001
- return true;
987
+ const stack = [[obj1, obj2]];
988
+ while (stack.length > 0) {
989
+ const [currentObj1, currentObj2] = stack.pop();
990
+ if (currentObj1 === currentObj2) continue;
991
+ if (Array.isArray(currentObj1) && Array.isArray(currentObj2)) {
992
+ if (currentObj1.length !== currentObj2.length) return false;
993
+ for (let i = 0; i < currentObj1.length; i++) stack.push([currentObj1[i], currentObj2[i]]);
994
+ } else if (typeof currentObj1 === "object" && typeof currentObj2 === "object" && currentObj1 !== null && currentObj2 !== null) {
995
+ if (Array.isArray(currentObj1) || Array.isArray(currentObj2)) return false;
996
+ const keys1 = Object.keys(currentObj1);
997
+ const keys2 = Object.keys(currentObj2);
998
+ if (keys1.length !== keys2.length || !keys1.every(key => keys2.includes(key))) return false;
999
+ for (let key in currentObj1) {
1000
+ if ($a73063cc642f3e5f$var$result_ids.includes(key)) continue; // ignore comparing values for keys we know are changing with every request
1001
+ stack.push([currentObj1[key], currentObj2[key]]);
1002
+ }
1003
+ } else if (typeof currentObj1 !== "function" && typeof currentObj2 !== "function")
1004
+ // Claim that all functions are equal, since the only way a function ends up here is because someone added it in the displayTransformer and that shouldn't force us to re-render, right?
1005
+ return false;
1002
1006
  }
1003
- return false;
1007
+ return true;
1004
1008
  }
1005
1009
  const $f48d0fbb00835aaa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
1006
1010
  $f48d0fbb00835aaa$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
@@ -5492,6 +5496,11 @@ function $67dc366d96177e70$export$967e966fca9515e(api_response) {
5492
5496
  }
5493
5497
  return api_response;
5494
5498
  }
5499
+
5500
+ // Minifiable and tree-shakable enum
5501
+ // Why not use const enum? See https://gitlab.com/depict-ai/depict.ai/-/merge_requests/9223#note_1675965260
5502
+ const $779741d0f266ea8c$export$74ee7529ce0f8a00 = "listingId";
5503
+ const $779741d0f266ea8c$export$5aae649db1b959fc = "externalId";
5495
5504
  const $e1d6c0f3d89d531c$var$v3_base_url = (0, $gVhhF$depictaiutilishared.base_url) + "/v3/";
5496
5505
  const $e1d6c0f3d89d531c$var$search_base_url = $e1d6c0f3d89d531c$var$v3_base_url + "search/";
5497
5506
  class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
@@ -5521,7 +5530,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
5521
5530
  const category_transformer = this.display_transformers?.categories;
5522
5531
  if (!category_transformer) return response;
5523
5532
  // find category suggestions, run thing with them, and then replace them
5524
- const category_suggestions = response.suggestions.filter(suggestion => suggestion.type === "category");
5533
+ const category_suggestions = response.suggestions.filter(suggestion => suggestion.type === "listing");
5525
5534
  const transformed_category_suggestions = await category_transformer({
5526
5535
  market: market,
5527
5536
  merchant: merchant,
@@ -5571,8 +5580,7 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
5571
5580
  endpoint_: endpoint_,
5572
5581
  input_req_: input_req_,
5573
5582
  fallback_response_: fallback_response_,
5574
- method_ = "POST",
5575
- delete_key_before_sending_: delete_key_before_sending_ // only supported for GET requests
5583
+ method_ = "POST"
5576
5584
  }) {
5577
5585
  const cache_obj = this.#get_cache_obj_for_endpoint(endpoint_);
5578
5586
  const with_ids = this.#add_ids_to_request(input_req_);
@@ -5590,7 +5598,6 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
5590
5598
  cache_obj.in_progress_[body] = new Promise(r => resolve_in_progress = r);
5591
5599
  try {
5592
5600
  const is_post = method_ === "POST";
5593
- if (!is_post && delete_key_before_sending_) delete sorted_request[delete_key_before_sending_];
5594
5601
  const url_to_request = is_post ? endpoint_ : $gVhhF$depictaiutilishared.make_url_with_query_params(endpoint_, sorted_request);
5595
5602
  const api_response = await $gVhhF$depictaiutilishared.fetch_retry($gVhhF$depictaiutilishared.add_version_query_params(url_to_request), {
5596
5603
  method: method_,
@@ -5678,9 +5685,13 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
5678
5685
  })
5679
5686
  });
5680
5687
  }
5681
- async get_listing(input_req) {
5688
+ async get_listing({
5689
+ id_type_: id_type_,
5690
+ id_to_query_for_: id_to_query_for_,
5691
+ ...input_req
5692
+ }) {
5682
5693
  return await this.#cached_request({
5683
- endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + encodeURIComponent(input_req.listing_id),
5694
+ endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + (id_type_ === $779741d0f266ea8c$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_),
5684
5695
  input_req_: input_req,
5685
5696
  fallback_response_: () => ({
5686
5697
  listing_id: "",
@@ -5694,20 +5705,17 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
5694
5705
  "quick_links": [],
5695
5706
  failed: true
5696
5707
  }),
5697
- method_: "GET",
5698
- delete_key_before_sending_: "listing_id" // this goes into the path, but we still need to have it in the request object until the last second as we want to include it as a key when caching requests
5708
+ method_: "GET"
5699
5709
  });
5700
5710
  }
5701
-
5702
- async get_listing_products(input_req) {
5703
- const listing_id = input_req.listing_id; // listing_id goes into the path
5704
- const cloned_request = {
5705
- ...input_req
5706
- };
5707
- delete cloned_request["listing_id"];
5711
+ async get_listing_products({
5712
+ id_to_query_for_: id_to_query_for_,
5713
+ id_type_: id_type_,
5714
+ ...input_req_
5715
+ }) {
5708
5716
  return await this.#cached_request({
5709
- endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + encodeURIComponent(listing_id) + "/products",
5710
- input_req_: input_req,
5717
+ endpoint_: $e1d6c0f3d89d531c$var$v3_base_url + "listings/" + (id_type_ === $779741d0f266ea8c$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
5718
+ input_req_: input_req_,
5711
5719
  fallback_response_: () => ({
5712
5720
  "n_hits": 0,
5713
5721
  "displays": [],
@@ -6046,7 +6054,7 @@ function $3f08fe2992a2a8ca$export$5e4aed86c12acdd9({
6046
6054
  // After first load, always just load 20 since people might just be browsing the top ones still
6047
6055
  min_products_to_fetch_ : now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
6048
6056
  // dlog("loading ", number_of_results_to_load, "products, because it was", now - last_loaded, "ms since last load");
6049
- const api_response = await depict_api_["listing_id" in base_part ? "get_listing_products" : "query"]({
6057
+ const api_response = await depict_api_["query" in base_part ? "query" : "get_listing_products"]({
6050
6058
  cursor: get_last_cursor(),
6051
6059
  limit: number_of_results_to_load,
6052
6060
  ...base_part
@@ -7688,7 +7696,10 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
7688
7696
  is_replace_: false,
7689
7697
  event_: ev,
7690
7698
  force_spa_navigation_: true,
7691
- listing_id_: display_accessor()?.listing_id
7699
+ listing_query_: {
7700
+ id: display_accessor().listing_id,
7701
+ type: $779741d0f266ea8c$export$74ee7529ce0f8a00
7702
+ }
7692
7703
  })), true);
7693
7704
  $gVhhF$solidjsweb.insert(_el$2, () => display_accessor().title);
7694
7705
  $gVhhF$solidjsweb.effect(() => $gVhhF$solidjsweb.setAttribute(_el$2, "href", href()));
@@ -7719,11 +7730,12 @@ const $8cceb1d3a967f369$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<n
7719
7730
  function $8cceb1d3a967f369$export$466cdc317043f6cb({
7720
7731
  quicklinks_data_: quicklinks_data_,
7721
7732
  router_: router_,
7722
- current_listing_id_: current_listing_id_,
7733
+ id_to_query_for_: id_to_query_for_,
7723
7734
  breadcrumb_data_: breadcrumb_data_,
7724
7735
  i18n_: i18n_,
7725
7736
  sorting_query_param_: sorting_query_param_,
7726
- filter_query_param_prefix_: filter_query_param_prefix_
7737
+ filter_query_param_prefix_: filter_query_param_prefix_,
7738
+ id_type_: id_type_
7727
7739
  }) {
7728
7740
  let scrolling_logic_ran_for_listing_id = false;
7729
7741
  let last_scroll_position;
@@ -7731,11 +7743,11 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7731
7743
  let last_was_placeholder = false;
7732
7744
  let sliding_element;
7733
7745
  $gVhhF$solidjs.createComputed(() => {
7734
- current_listing_id_();
7746
+ id_to_query_for_();
7735
7747
  scrolling_logic_ran_for_listing_id = false;
7736
7748
  });
7737
7749
  const place_holdey_quicklinks_data = $gVhhF$solidjs.createMemo(() => quicklinks_data_() || [,,,]);
7738
- const selected_index = $gVhhF$solidjs.createMemo(() => quicklinks_data_()?.findIndex(item => item.listing_id === current_listing_id_())); // this will be -1 when viewing child categories
7750
+ const selected_index = $gVhhF$solidjs.createMemo(() => quicklinks_data_()?.findIndex(item => item[id_type_() === $779741d0f266ea8c$export$5aae649db1b959fc ? "external_id" : "listing_id"] === id_to_query_for_())); // this will be -1 when viewing child categories
7739
7751
  const scrollpos_per_listing_id = {};
7740
7752
  const mutation_plugins = [function () {
7741
7753
  if (!scrolling_logic_ran_for_listing_id) return;
@@ -7744,7 +7756,7 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7744
7756
  } = this.insert_here;
7745
7757
  if (scrollLeft > 0) {
7746
7758
  last_scroll_position = scrollLeft;
7747
- const current_id = $gVhhF$solidjs.untrack(current_listing_id_);
7759
+ const current_id = $gVhhF$solidjs.untrack(id_to_query_for_);
7748
7760
  // make sure to not save position where selected item isn't in viewport
7749
7761
  const current_selected_index = $gVhhF$solidjs.untrack(selected_index);
7750
7762
  const intersecting_thing = this.intersecting_items_object[current_selected_index];
@@ -7807,7 +7819,7 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7807
7819
  equals: false
7808
7820
  }), new_data => {
7809
7821
  const quicklinks_data = quicklinks_data_(); // this signal should have updated by now since this is a createEffect
7810
- const current_id = current_listing_id_();
7822
+ const current_id = id_to_query_for_();
7811
7823
  if (!new_data || !quicklinks_data || !current_id) return;
7812
7824
  const owner = $gVhhF$solidjs.getOwner();
7813
7825
  queueMicrotask(() => {
@@ -7855,10 +7867,9 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7855
7867
  // Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
7856
7868
  // 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
7857
7869
  const is_sibling = $gVhhF$solidjs.createMemo(() => {
7858
- const current_id = current_listing_id_();
7859
- return quicklinks_data_()?.some(({
7860
- listing_id: listing_id
7861
- }) => listing_id === current_id);
7870
+ const current_id = id_to_query_for_();
7871
+ const lookForId = id_type_() === $779741d0f266ea8c$export$5aae649db1b959fc ? "external_id" : "listing_id";
7872
+ return quicklinks_data_()?.some(quickLink => quickLink[lookForId] === current_id);
7862
7873
  });
7863
7874
  const href = $gVhhF$solidjs.createMemo(() =>
7864
7875
  // 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
@@ -7879,7 +7890,10 @@ function $8cceb1d3a967f369$export$466cdc317043f6cb({
7879
7890
  is_replace_: false,
7880
7891
  event_: ev,
7881
7892
  force_spa_navigation_: true,
7882
- listing_id_: display_accessor()?.listing_id
7893
+ listing_query_: {
7894
+ id: display_accessor().listing_id,
7895
+ type: $779741d0f266ea8c$export$74ee7529ce0f8a00
7896
+ }
7883
7897
  });
7884
7898
  }), true);
7885
7899
  $gVhhF$solidjsweb.insert(_el$3, () => display_accessor()?.title || $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
@@ -8036,13 +8050,14 @@ let $0b6e2070a98de347$export$44dad306455dddf;
8036
8050
  })($0b6e2070a98de347$export$44dad306455dddf || ($0b6e2070a98de347$export$44dad306455dddf = {}));
8037
8051
  function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
8038
8052
  crumb_data_: crumb_data_,
8039
- listing_id_: listing_id_,
8053
+ id_to_query_for_: id_to_query_for_,
8040
8054
  i18n_: i18n_,
8041
8055
  selected_filters_: selected_filters_,
8042
8056
  local_filter_cache_: local_filter_cache_,
8043
8057
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
8044
8058
  plp_results_: plp_results_,
8045
- sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
8059
+ sideways_filter_clearing_flag_: sideways_filter_clearing_flag_,
8060
+ id_type_: id_type_
8046
8061
  }) {
8047
8062
  // If we just got opened in a new tab, clear filters instantly and remove the flag
8048
8063
  $ef972f5c10b1c5b4$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
@@ -8053,17 +8068,21 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
8053
8068
  i18n_: i18n_,
8054
8069
  sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
8055
8070
  });
8056
- // Code below is for when we're already open and the user navigates to a new category
8071
+ // The code below is for when we're already open and the user navigates to a new category
8057
8072
  let previous_crumb_data = $gVhhF$solidjs.untrack(crumb_data_);
8058
- let listing_id_when_we_got_previous_data = $gVhhF$solidjs.untrack(listing_id_);
8073
+ let id_when_we_got_previous_data = {
8074
+ id_: $gVhhF$solidjs.untrack(id_to_query_for_),
8075
+ type_: $gVhhF$solidjs.untrack(id_type_)
8076
+ };
8059
8077
  let allow_filter_clearing = true; // set to false when going backwards/forwards
8060
8078
  // temporarily disable filter clearing when going backwards/forwards
8061
8079
  const handler = () => allow_filter_clearing = false;
8062
8080
  window.addEventListener("popstate", handler); // popstate only gets called when using back/forwards button of browser or the history navigate to achieve the same, but not on pushState or replaceState
8063
8081
  $gVhhF$solidjs.onCleanup(() => window.removeEventListener("popstate", handler));
8064
8082
  $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(crumb_data_, $gVhhF$depictaiutilishared.catchify(new_crumb_data => {
8065
- const listing_id_of_new_data = listing_id_();
8066
- if (allow_filter_clearing && previous_crumb_data && new_crumb_data && listing_id_of_new_data !== listing_id_when_we_got_previous_data) {
8083
+ const id_of_new_data = id_to_query_for_();
8084
+ const type_of_id_of_new_data = id_type_();
8085
+ if (allow_filter_clearing && previous_crumb_data && new_crumb_data && (id_of_new_data !== id_when_we_got_previous_data.id_ || type_of_id_of_new_data !== id_when_we_got_previous_data.type_)) {
8067
8086
  const previous_length = previous_crumb_data.length;
8068
8087
  const new_length = new_crumb_data.length;
8069
8088
  const went_upwards = new_length < previous_length;
@@ -8086,7 +8105,10 @@ function $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
8086
8105
  sideways_filter_clearing_flag_[1](false);
8087
8106
  }
8088
8107
  }
8089
- listing_id_when_we_got_previous_data = listing_id_of_new_data;
8108
+ id_when_we_got_previous_data = {
8109
+ id_: id_of_new_data,
8110
+ type_: type_of_id_of_new_data
8111
+ };
8090
8112
  previous_crumb_data = new_crumb_data;
8091
8113
  if (!allow_filter_clearing) allow_filter_clearing = true;
8092
8114
  })));
@@ -8118,7 +8140,7 @@ function $ef972f5c10b1c5b4$var$clear_if_opened_new_tab_with_sideways_url_params_
8118
8140
  });
8119
8141
  tracking_function_for_plp_results(plp_results_);
8120
8142
  }
8121
- const $bb9760b7a8acdc18$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=statement style=white-space:pre-wrap>No listingId specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a listingId.`),
8143
+ const $bb9760b7a8acdc18$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=statement style=white-space:pre-wrap>No \`id\` specified in \`listingQuery\`, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a listingQuery.`),
8122
8144
  $bb9760b7a8acdc18$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=buttons><button class="ok major">`);
8123
8145
  function $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id, i18n_) {
8124
8146
  if (!(0, $gVhhF$depictaiutilishared.is_debug)) return; // Just to make sure we don't show this in production
@@ -8128,7 +8150,7 @@ function $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id, i18n_) {
8128
8150
  }) => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => {
8129
8151
  if (!document.documentElement.contains(element)) return;
8130
8152
  if (!listing_id()) {
8131
- const warning = "No listingId specified, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a listingId.";
8153
+ const warning = "No `id` specified in `listingQuery`, this is probably unintentional. Make sure to create (and insert) the CategoryPage *after* you have specified a listingQuery.";
8132
8154
  $gVhhF$depictaiutilishared.dwarn(warning);
8133
8155
  const {
8134
8156
  close_toast_: close_toast_
@@ -8183,8 +8205,8 @@ const $840d88a04b2d22a7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<d
8183
8205
  $840d88a04b2d22a7$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict plp category"><div class=listing-page><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/><!$><!/></div><!$><!/><!$><!/>`);
8184
8206
  function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8185
8207
  depict_api_: depict_api_,
8186
- listing_id_: listing_id_,
8187
- meta_title_suffix_: meta_title_suffix_,
8208
+ id_to_query_for_: id_to_query_for_,
8209
+ id_type_: id_type_,
8188
8210
  current_sorting_: current_sorting_,
8189
8211
  min_products_to_fetch_: min_products_to_fetch_,
8190
8212
  category_filters_open_: category_filters_open_,
@@ -8237,7 +8259,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8237
8259
  merchant: merchant_(),
8238
8260
  market: market_(),
8239
8261
  locale: backend_locale_(),
8240
- listing_id: listing_id_(),
8262
+ id_to_query_for_: id_to_query_for_(),
8263
+ id_type_: id_type_(),
8241
8264
  ...(f.length ? {
8242
8265
  filters: f
8243
8266
  } : {}),
@@ -8249,8 +8272,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8249
8272
  // Make "Get products in listing" request to get products in listing
8250
8273
  const [plp_products_] = $gVhhF$solidjs.createResource(products_query_base_,
8251
8274
  // only first page of results, unless the history state says we should load more (can't do that in load more thing, I tested, they need to be added at once for the browser to not give up scroll restoration)
8252
- $gVhhF$depictaiutilishared.catchify(base_query => $276380e4607fb9fb$export$cc42dd29bf655ab6({
8253
- id_: $gVhhF$solidjs.untrack(listing_id_),
8275
+ $gVhhF$depictaiutilisharedlatest.catchify(base_query => $276380e4607fb9fb$export$cc42dd29bf655ab6({
8276
+ id_: $gVhhF$solidjs.untrack(id_to_query_for_),
8254
8277
  scroll_restoration_data_: scroll_restoration_data_,
8255
8278
  min_products_to_fetch_: min_products_to_fetch_,
8256
8279
  make_request_: (limit, cursor) => depict_api_.get_listing_products({
@@ -8265,10 +8288,11 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8265
8288
  merchant: merchant_(),
8266
8289
  market: market_(),
8267
8290
  locale: backend_locale_(),
8268
- listing_id: listing_id_()
8291
+ id_to_query_for_: id_to_query_for_(),
8292
+ id_type_: id_type_()
8269
8293
  }));
8270
8294
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
8271
- const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilishared.catchify(query => depict_api_.get_listing(query)));
8295
+ const [plp_meta] = $gVhhF$solidjs.createResource(meta_query_base, $gVhhF$depictaiutilisharedlatest.catchify(query => depict_api_.get_listing(query)));
8272
8296
  const available_sortings_ = $gVhhF$solidjs.createMemo(() => plp_products_()?.sorts?.map(sort => ({
8273
8297
  ...sort,
8274
8298
  order: sort.order ?? "desc"
@@ -8277,13 +8301,6 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8277
8301
  const title = $gVhhF$solidjs.createMemo(() => plp_meta()?.title);
8278
8302
  const crumb_data_ = $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title);
8279
8303
  const quicklinks_data_ = $gVhhF$solidjs.createMemo(() => plp_meta()?.quick_links);
8280
- const meta_tag_data_ = $gVhhF$solidjs.createMemo(() => {
8281
- if (plp_meta()?.replace_meta_tags) return {
8282
- title: plp_meta()?.title + (meta_title_suffix_() || ""),
8283
- description: plp_meta()?.description
8284
- };
8285
- });
8286
- $gVhhF$depictaiutilishared.edit_current_page_meta_tags(meta_tag_data_);
8287
8304
  const [sort_or_filter_open_, set_sort_or_filter_open_] = $gVhhF$solidjs.createSignal(false);
8288
8305
  const [desktop_filter_elements_, set_desktop_filter_elements] = $gVhhF$solidjs.createSignal();
8289
8306
  const formatted_number_of_results_ = $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
@@ -8353,7 +8370,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8353
8370
  }));
8354
8371
  results_for = make_product_count_();
8355
8372
  } else {
8356
- $gVhhF$depictaiutilishared.report(new Error("Unrecognised category_title_type, UI will look messed up"), "error");
8373
+ $gVhhF$depictaiutilisharedlatest.report(new Error("Unrecognised category_title_type, UI will look messed up"), "error");
8357
8374
  results_for = $gVhhF$solidjsweb.getNextElement($840d88a04b2d22a7$var$_tmpl$2);
8358
8375
  }
8359
8376
  const filters_opener = $f8f64d05c525825b$export$d7841e452f2e59a8({
@@ -8375,17 +8392,17 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8375
8392
  number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_,
8376
8393
  ...extra_sort_and_filter_args_
8377
8394
  });
8378
- $gVhhF$depictaiutilishared.catchify((0, $276380e4607fb9fb$export$6e49da55e449af7c))({
8395
+ $gVhhF$depictaiutilisharedlatest.catchify((0, $276380e4607fb9fb$export$6e49da55e449af7c))({
8379
8396
  scroll_restoration_data_: scroll_restoration_data_,
8380
8397
  last_result_in_viewport_: last_result_in_viewport_,
8381
- id_: listing_id_,
8398
+ id_: id_to_query_for_,
8382
8399
  can_write_scroll_restoration_: can_write_scroll_restoration_
8383
8400
  });
8384
8401
  on_filters_constructed_?.();
8385
8402
  $gVhhF$solidjs.createComputed(() => {
8386
8403
  if (plp_products_.loading) set_can_write_scroll_restoration(false);else if (plp_products_()) set_can_write_scroll_restoration(true);
8387
8404
  });
8388
- $gVhhF$solidjs.createRenderEffect($gVhhF$depictaiutilishared.catchify(async () => {
8405
+ $gVhhF$solidjs.createRenderEffect($gVhhF$depictaiutilisharedlatest.catchify(async () => {
8389
8406
  const slim = is_slim_();
8390
8407
  const only_show_filters_opener = only_show_filters_opener_?.();
8391
8408
  const owner = $gVhhF$solidjs.getOwner();
@@ -8407,14 +8424,15 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8407
8424
  available_filters_: available_filters_
8408
8425
  });
8409
8426
  $ef972f5c10b1c5b4$export$3945d6db2dfd3d12({
8410
- listing_id_: listing_id_,
8427
+ id_to_query_for_: id_to_query_for_,
8411
8428
  crumb_data_: crumb_data_,
8412
8429
  i18n_: i18n_,
8413
8430
  selected_filters_: selected_filters_,
8414
8431
  local_filter_cache_: local_filter_cache_,
8415
8432
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
8416
8433
  plp_results_: plp_products_,
8417
- sideways_filter_clearing_flag_: sideways_filter_clearing_flag_
8434
+ sideways_filter_clearing_flag_: sideways_filter_clearing_flag_,
8435
+ id_type_: id_type_
8418
8436
  });
8419
8437
  get_breadcrumb_accessor_?.(crumb_data_);
8420
8438
  get_quicklinks_accessor_?.(quicklinks_data_);
@@ -8437,7 +8455,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8437
8455
  [_el$28, _co$11] = $gVhhF$solidjsweb.getNextMarker(_el$27.nextSibling),
8438
8456
  _el$29 = _el$28.nextSibling,
8439
8457
  [_el$30, _co$12] = $gVhhF$solidjsweb.getNextMarker(_el$29.nextSibling);
8440
- $gVhhF$solidjsweb.use(el => process.env.NODE_ENV === "development" && $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, listing_id_, i18n_), _el$13);
8458
+ $gVhhF$solidjsweb.use(el => process.env.NODE_ENV === "development" && $bb9760b7a8acdc18$export$7af06a63c5a976c9(el, id_to_query_for_, i18n_), _el$13);
8441
8459
  $gVhhF$solidjsweb.insert(_el$14, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
8442
8460
  get when() {
8443
8461
  return show_breadcrumbs_();
@@ -8459,7 +8477,8 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8459
8477
  get children() {
8460
8478
  return $gVhhF$solidjsweb.createComponent((0, $8cceb1d3a967f369$export$466cdc317043f6cb), {
8461
8479
  quicklinks_data_: quicklinks_data_,
8462
- current_listing_id_: listing_id_,
8480
+ id_to_query_for_: id_to_query_for_,
8481
+ id_type_: id_type_,
8463
8482
  router_: router_,
8464
8483
  breadcrumb_data_: crumb_data_,
8465
8484
  i18n_: i18n_,
@@ -8513,7 +8532,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8513
8532
  sort_or_filter_open_: sort_or_filter_open_,
8514
8533
  desktop_filter_elements_: desktop_filter_elements_,
8515
8534
  content_blocks_by_row_: content_blocks_by_row_,
8516
- id_currently_querying_for_: listing_id_,
8535
+ id_currently_querying_for_: id_to_query_for_,
8517
8536
  no_results_options_: {
8518
8537
  selected_filters_: selected_filters_,
8519
8538
  expanded_hierarchical_filters_: expanded_hierarchical_filters_,
@@ -8559,7 +8578,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
8559
8578
  * Adds the current page as last breadcrumb to the breadcrumb trail
8560
8579
  */
8561
8580
  function $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title) {
8562
- const href_accessor = $gVhhF$depictaiutilishared.use_href_accessor();
8581
+ const href_accessor = $gVhhF$depictaiutilisharedlatest.use_href_accessor();
8563
8582
  return $gVhhF$solidjs.createMemo(() => {
8564
8583
  const api_value = plp_meta()?.breadcrumbs;
8565
8584
  if (!api_value) return api_value;
@@ -8575,6 +8594,12 @@ function $840d88a04b2d22a7$var$add_us_to_crumbs(plp_meta, title) {
8575
8594
  },
8576
8595
  get slug() {
8577
8596
  return plp_meta().slug;
8597
+ },
8598
+ get listing_type() {
8599
+ return plp_meta().listing_type;
8600
+ },
8601
+ get external_id() {
8602
+ return plp_meta().external_id;
8578
8603
  }
8579
8604
  }];
8580
8605
  });
@@ -8747,8 +8772,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8747
8772
  #localization_signal = $gVhhF$solidjs.createSignal();
8748
8773
  #merchant_signal = $gVhhF$solidjs.createSignal();
8749
8774
  #market_signal = $gVhhF$solidjs.createSignal();
8750
- #listing_id_signal = $gVhhF$solidjs.createSignal("");
8751
- #meta_title_suffix_ = $gVhhF$solidjs.createSignal();
8775
+ #listing_query_signal = $gVhhF$solidjs.createSignal({});
8752
8776
  #disable_override_listing_id = $gVhhF$solidjs.createSignal();
8753
8777
  static #keys_constructed_with = /*@__PURE__*/new Set();
8754
8778
  get localization() {
@@ -8758,11 +8782,11 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8758
8782
  set localization(locale_obj) {
8759
8783
  this.#localization_signal[1](locale_obj);
8760
8784
  }
8761
- get listing_id() {
8762
- return this.#listing_id_signal[0]();
8785
+ get listing_query() {
8786
+ return this.#listing_query_signal[0]();
8763
8787
  }
8764
- set listing_id(id) {
8765
- this.#listing_id_signal[1](id);
8788
+ set listing_query(query) {
8789
+ this.#listing_query_signal[1](query);
8766
8790
  }
8767
8791
  get merchant() {
8768
8792
  return this.#merchant_signal[0]();
@@ -8776,12 +8800,6 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8776
8800
  set market(market) {
8777
8801
  this.#market_signal[1](market);
8778
8802
  }
8779
- get meta_title_suffix() {
8780
- return this.#meta_title_suffix_[0]();
8781
- }
8782
- set meta_title_suffix(new_suffix) {
8783
- this.#meta_title_suffix_[1](new_suffix);
8784
- }
8785
8803
  get disable_override_listing_id() {
8786
8804
  return this.#disable_override_listing_id[0]();
8787
8805
  }
@@ -8800,7 +8818,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8800
8818
  on_navigation: on_navigation,
8801
8819
  display_transformers: display_transformers,
8802
8820
  unique_instance_key_for_state = "",
8803
- listing_id_state_key: listing_id_state_key,
8821
+ listing_query_state_key: listing_query_state_key,
8804
8822
  ...props_on_class
8805
8823
  }) {
8806
8824
  const owner = $gVhhF$solidjs.getOwner() || $gVhhF$solidjs.createRoot(() => $gVhhF$solidjs.getOwner()); // we might have an owner, if so, pass it on. Otherwise, create one so solid doesn't print warnings to the console
@@ -8810,7 +8828,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
8810
8828
  throw new Error("You can only have one instance of DepictCategory with the same uniqueInstanceKeyForState");
8811
8829
  Object.assign(this, props_on_class); // set initial signal values
8812
8830
  $d84fe647b84b5dc5$export$5162a71f252e6122();
8813
- this.#router = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)("hard_navigation", listing_id_state_key);
8831
+ this.#router = new (0, $e96dd13889871fc0$export$7e1297a3a19f10d8)("hard_navigation", listing_query_state_key);
8814
8832
  if (on_navigation) this.#router.on_navigation_ = on_navigation;
8815
8833
  const override_listing_id_query_param_names_ = ["listing_id_" + unique_instance_key_for_state, "listing_id"]; // If you're wondering why this is an array https://gitlab.com/depict-ai/depict.ai/-/merge_requests/7958#note_1511700842
8816
8834
  const sorting_query_param_ = "sorting" + unique_instance_key_for_state;
@@ -8870,14 +8888,16 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8870
8888
  category_title: category_title
8871
8889
  } = props;
8872
8890
  const shared_properties = $48567ac5b39bac56$var$get_shared_properties(depict_category);
8891
+ const diffableListingQuery = $gVhhF$solidjs.createMemo(() => Object.values(depict_category.listing_query || {}).join(""));
8873
8892
  return $95837413165cc2df$export$23fca46f3143581f(() => {
8874
8893
  $gVhhF$solidjs.createEffect(prev => {
8875
8894
  // this is here (and not on DepictCategory) so that people also know when PageReplacer removes the page, it's intended to help people replace their own content when a depict page is navigated, see https://depictaiworkspace.slack.com/archives/C04M8MGCF3K/p1691670636155369
8876
- const id = depict_category.listing_id; // <- this is a reactive getter
8877
- $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_id_change)(id, prev);
8878
- return id;
8895
+ diffableListingQuery(); // Only re-run this effect when the listing query *actually* changes (not just the object reference)
8896
+ const newId = $gVhhF$solidjs.untrack(() => depict_category.listing_query);
8897
+ $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_query_change)(newId, prev);
8898
+ return newId;
8879
8899
  });
8880
- $gVhhF$solidjs.onCleanup(() => $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_id_change)());
8900
+ $gVhhF$solidjs.onCleanup(() => $deaaf04362a1bc71$export$f50b88e2a00918b5(props.on_listing_query_change)());
8881
8901
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
8882
8902
  const {
8883
8903
  grid_spacing: grid_spacing
@@ -8918,8 +8938,11 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
8918
8938
  depict_api_: depict_api_,
8919
8939
  min_products_to_fetch_: $48567ac5b39bac56$var$min_products_to_fetch_,
8920
8940
  local_filter_cache_: local_filter_cache_,
8921
- listing_id_: $gVhhF$solidjs.createMemo(() => !depict_category.disable_override_listing_id && override_listing_id_accessor_() || depict_category.listing_id),
8922
- meta_title_suffix_: () => depict_category.meta_title_suffix,
8941
+ id_to_query_for_: $gVhhF$solidjs.createMemo(() => !depict_category.disable_override_listing_id && override_listing_id_accessor_() || depict_category.listing_query.id),
8942
+ id_type_: $gVhhF$solidjs.createMemo(() => {
8943
+ if (!depict_category.disable_override_listing_id && override_listing_id_accessor_()) return $779741d0f266ea8c$export$74ee7529ce0f8a00;
8944
+ return depict_category.listing_query.type;
8945
+ }),
8923
8946
  i18n_: i18n_,
8924
8947
  show_quicklinks_: $gVhhF$solidjs.createMemo(() => props.show_quicklinks ?? true),
8925
8948
  category_title_: category_title,
@@ -8979,13 +9002,16 @@ function $48567ac5b39bac56$export$de035477d6fef996({
8979
9002
  sorting_query_param_: sorting_query_param_,
8980
9003
  filter_query_param_prefix_: filter_query_param_prefix_
8981
9004
  } = $48567ac5b39bac56$var$get_shared_properties(depict_category);
9005
+ const id_to_query_for_ = $gVhhF$solidjs.createMemo(() => depict_category.listing_query.id);
9006
+ const id_type_ = $gVhhF$solidjs.createMemo(() => depict_category.listing_query.type);
8982
9007
  return $gVhhF$solidjsweb.createComponent($48567ac5b39bac56$var$InExternalAreaDiv, {
8983
9008
  get children() {
8984
9009
  return $8cceb1d3a967f369$export$466cdc317043f6cb({
8985
9010
  i18n_: i18n_,
8986
9011
  quicklinks_data_: quicklinks_data_,
8987
9012
  router_: router_,
8988
- current_listing_id_: () => depict_category.listing_id,
9013
+ id_type_: id_type_,
9014
+ id_to_query_for_: id_to_query_for_,
8989
9015
  breadcrumb_data_: breadcrumb_data_,
8990
9016
  sorting_query_param_: sorting_query_param_,
8991
9017
  filter_query_param_prefix_: filter_query_param_prefix_
@@ -10117,7 +10143,7 @@ function $6b65ba8af12c5a26$export$e872e2339fb04a7f({
10117
10143
  const _el$3 = $gVhhF$solidjsweb.getNextElement($6b65ba8af12c5a26$var$_tmpl$3);
10118
10144
  $gVhhF$solidjsweb.insert(_el$3, $gVhhF$solidjs.createMemo(() => {
10119
10145
  if (input_obj().type === "content") return i18n_.content_();
10120
- if (input_obj().category_type === "brand") return i18n_.brand_();
10146
+ if (input_obj().listing_type === "brand") return i18n_.brand_();
10121
10147
  return i18n_.category_();
10122
10148
  }));
10123
10149
  return _el$3;
@@ -10377,7 +10403,7 @@ function $6a374b16bfe947d0$var$actual_navigation_working_on_fake_data({
10377
10403
  url.searchParams.set(search_query_param_name_, title);
10378
10404
  return $b8700779b3e745de$export$1efe1013da60d0e4(e, url.href);
10379
10405
  }));
10380
- } else if (selected_entry?.type == "category" || selected_entry?.type === "content") $gVhhF$solidjs.runWithOwner(owner, () => override_on_enter_for_this_entry(e => {
10406
+ } else if (selected_entry?.type == "listing" || selected_entry?.type === "content") $gVhhF$solidjs.runWithOwner(owner, () => override_on_enter_for_this_entry(e => {
10381
10407
  const {
10382
10408
  page_url: page_url
10383
10409
  } = selected_entry;
@@ -10902,7 +10928,7 @@ function $04048c1bef16c249$export$c05a196222ba1302({
10902
10928
  suggestions_: suggestions_,
10903
10929
  children: children
10904
10930
  }) {
10905
- const category_suggestions_ = $gVhhF$solidjs.createMemo(() => suggestions_()?.suggestions.filter(s => s.type === "category"));
10931
+ const category_suggestions_ = $gVhhF$solidjs.createMemo(() => suggestions_()?.suggestions.filter(s => s.type === "listing"));
10906
10932
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
10907
10933
  get when() {
10908
10934
  return category_suggestions_()?.length || suggestions_.loading;