@depict-ai/ui 4.10.32 → 4.10.33

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.
@@ -4,8 +4,8 @@ var $3hooq$solidjs = require("solid-js");
4
4
  var $3hooq$depictaiutilisharedlatest = require("@depict-ai/utilishared/ES10");
5
5
  var $3hooq$solidjsstore = require("solid-js/store");
6
6
  var $3hooq$babelruntimehelpersdefineProperty = require("@babel/runtime/helpers/defineProperty");
7
- var $3hooq$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
8
7
  var $3hooq$babelruntimehelpersclassPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
8
+ var $3hooq$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
9
9
  require("../../multi_import_deduplicator.cjs").register_es_version("ui", "ES10");
10
10
  function $parcel$export(e, n, v, s) {
11
11
  Object.defineProperty(e, n, {
@@ -97,6 +97,8 @@ $parcel$export(module.exports, "styles_to_valid_css_string", () => $498967813349
97
97
  $parcel$export(module.exports, "disable_scrolling", () => $8c2e68c6d458169b$export$fe334901e8bebd57);
98
98
  $parcel$export(module.exports, "open_search_with_shift_slash", () => $f8c268e298d2d5fe$export$d0596b5cae35ad4);
99
99
  $parcel$export(module.exports, "DepictAPI", () => $e270e9f953fcbc58$export$e015ed2f2950f2e3);
100
+ $parcel$export(module.exports, "NativeDepictAPI", () => $5f20a6104f835562$export$721afe49a594bed);
101
+ $parcel$export(module.exports, "create_depict_api", () => $5f20a6104f835562$export$6d972e6af9de09f0);
100
102
  $parcel$export(module.exports, "media_query_to_accessor", () => $3e17e871e9d0911d$export$d9f36cf74e24d595);
101
103
  $parcel$export(module.exports, "setup_fast_leave", () => $27a1a8144c190980$export$689e204eadb33baf);
102
104
  $parcel$export(module.exports, "show_toast", () => $5909f8d84b7b4c30$export$5196e4c01fa56fcb);
@@ -115,7 +117,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
115
117
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
116
118
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
117
119
  /*! Depict.ai search and product listing SDK */
118
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.32";
120
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.33";
119
121
  function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
120
122
  const signal = $3hooq$solidjs.createSignal(false);
121
123
  $3hooq$solidjs.onCleanup($3hooq$depictaiutilishared.javascript_media_query(media_query, _ref => {
@@ -11409,12 +11411,845 @@ function $39cca429fb71d8ff$export$f091cbac892643a4(obj) {
11409
11411
  return Object.fromEntries(mapped_stuff); // FUCK TYPESCRIPT, WHY CAN'T YOU DO THIS CORRECTLY???
11410
11412
  }
11411
11413
 
11414
+ /** One try and at most two retries: a 503 burst from V4 shouldn't be multiplied by fetch_retry's default of 10. */
11415
+ const $8ad8c4b4b26ba277$var$NATIVE_MAX_TRIES = 3;
11416
+ function $8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, path) {
11417
+ return "".concat((0, $3hooq$depictaiutilishared.base_url), "/v4/").concat(encodeURIComponent(merchant)).concat(path);
11418
+ }
11419
+ async function $8ad8c4b4b26ba277$export$88d793e3827f3436(url) {
11420
+ return (await $8ad8c4b4b26ba277$export$f035610fd74c541a(url)).body_;
11421
+ }
11422
+ async function $8ad8c4b4b26ba277$export$f035610fd74c541a(url) {
11423
+ var _error, _error2, _error3;
11424
+ const response = await $3hooq$depictaiutilishared.fetch_retry(url, {
11425
+ method: "GET"
11426
+ }, $8ad8c4b4b26ba277$var$NATIVE_MAX_TRIES);
11427
+ if (!response) {
11428
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI] no response from", url);
11429
+ return {};
11430
+ }
11431
+ if (response.status === 200)
11432
+ // A 200 that isn't JSON (a proxy's HTML page, a cut-off body) is a failed read like any other, so callers fall
11433
+ // back instead of rejecting: get_recommendation_types then forgets the read rather than keeping it in flight.
11434
+ try {
11435
+ return {
11436
+ body_: await response.json()
11437
+ };
11438
+ } catch (e) {
11439
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI] 200 without a JSON body from", url, e);
11440
+ return {};
11441
+ }
11442
+ let error;
11443
+ try {
11444
+ error = (await response.json()).error;
11445
+ } catch {
11446
+ // not V4's error body
11447
+ }
11448
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI]", response.status, (_error = error) === null || _error === void 0 ? void 0 : _error.code, (_error2 = error) === null || _error2 === void 0 ? void 0 : _error2.message, (_error3 = error) === null || _error3 === void 0 ? void 0 : _error3.request_id, url);
11449
+ if (response.status >= 500) {
11450
+ var _error$code, _error4, _error5, _error$request_id, _error6;
11451
+ $3hooq$depictaiutilishared.report([new Error("V4 ".concat(response.status, " ").concat((_error$code = (_error4 = error) === null || _error4 === void 0 ? void 0 : _error4.code) !== null && _error$code !== void 0 ? _error$code : "")), "Native V4 request failed"], "warning", {
11452
+ url: url,
11453
+ status: response.status,
11454
+ code: (_error5 = error) === null || _error5 === void 0 ? void 0 : _error5.code,
11455
+ request_id: (_error$request_id = (_error6 = error) === null || _error6 === void 0 ? void 0 : _error6.request_id) !== null && _error$request_id !== void 0 ? _error$request_id : response.headers.get("x-depict-request-id")
11456
+ });
11457
+ }
11458
+ return {
11459
+ error_: error
11460
+ };
11461
+ }
11462
+ const $294cf81de92da757$export$8e79752841e7cdb4 = 900000;
11463
+ const $294cf81de92da757$var$storage_key = merchant => "depict_v4_recommendation_types_".concat(merchant);
11464
+ /** One read per merchant and CONTEXT_TTL_MS in this page; a failed read is forgotten so the next caller tries again. */
11465
+ const $294cf81de92da757$var$in_flight = new Map();
11466
+ function $294cf81de92da757$var$from_storage(merchant, now) {
11467
+ try {
11468
+ var _localStorage$getItem;
11469
+ const stored = JSON.parse((_localStorage$getItem = localStorage.getItem($294cf81de92da757$var$storage_key(merchant))) !== null && _localStorage$getItem !== void 0 ? _localStorage$getItem : "null");
11470
+ if (!stored || !Array.isArray(stored.types) || !(now - stored.fetched_at < $294cf81de92da757$export$8e79752841e7cdb4)) return undefined;
11471
+ return $294cf81de92da757$var$to_map(stored.types);
11472
+ } catch {
11473
+ return undefined;
11474
+ }
11475
+ }
11476
+ function $294cf81de92da757$var$to_storage(merchant, types, now) {
11477
+ try {
11478
+ localStorage.setItem($294cf81de92da757$var$storage_key(merchant), JSON.stringify({
11479
+ fetched_at: now,
11480
+ types: types
11481
+ }));
11482
+ } catch {
11483
+ // localStorage unavailable or full: read /context again on the next page.
11484
+ }
11485
+ }
11486
+ const $294cf81de92da757$var$to_map = types => new Map(types.map(_ref => {
11487
+ let {
11488
+ type: type,
11489
+ inputs: inputs
11490
+ } = _ref;
11491
+ return [type, inputs];
11492
+ }));
11493
+ function $294cf81de92da757$export$869eb14d6f85ac51(merchant) {
11494
+ let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
11495
+ const pending = $294cf81de92da757$var$in_flight.get(merchant);
11496
+ if (pending && now - pending.started_at < $294cf81de92da757$export$8e79752841e7cdb4) return pending.read;
11497
+ const stored = $294cf81de92da757$var$from_storage(merchant, now);
11498
+ if (stored) return Promise.resolve(stored);
11499
+ const read = $8ad8c4b4b26ba277$export$88d793e3827f3436($8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, "/context")).then(context => {
11500
+ var _context$recommendati;
11501
+ if (!context) {
11502
+ var _in_flight$get;
11503
+ if (((_in_flight$get = $294cf81de92da757$var$in_flight.get(merchant)) === null || _in_flight$get === void 0 ? void 0 : _in_flight$get.read) === read) $294cf81de92da757$var$in_flight.delete(merchant);
11504
+ return undefined;
11505
+ }
11506
+ const types = (_context$recommendati = context.recommendation_types) !== null && _context$recommendati !== void 0 ? _context$recommendati : [];
11507
+ $294cf81de92da757$var$to_storage(merchant, types, now);
11508
+ return $294cf81de92da757$var$to_map(types);
11509
+ });
11510
+ $294cf81de92da757$var$in_flight.set(merchant, {
11511
+ started_at: now,
11512
+ read: read
11513
+ });
11514
+ return read;
11515
+ }
11516
+ function $294cf81de92da757$export$6cde5c31239dec47() {
11517
+ $294cf81de92da757$var$in_flight.clear();
11518
+ }
11519
+
11520
+ /**
11521
+ * The shopper's recently viewed products, kept in the browser for the native V4 API's history-based recommendations.
11522
+ *
11523
+ * v3 kept this history on the server, per session. V4 content requests carry no session, so a surface that reads
11524
+ * history gets it in the request (`recent_views`), and the SDK keeps the list. It holds product ids and view times
11525
+ * only (no session, user or page data), bounded in size and age, in localStorage per merchant; when localStorage
11526
+ * can't be used (private mode, blocked, full) it lives in memory for the page load.
11527
+ *
11528
+ * A view is recorded when a native product-anchored recommendation request resolves its anchor, as v3's facade records
11529
+ * a resolved anchor as a view; the product being viewed is in the list from the next request on.
11530
+ */ /** recs-wasm reads the newest 20 views (V4 `recent_views` docs), so more would never be read. */
11531
+ const $3bfd3f1d3eb46898$export$3d684435158adda6 = 20;
11532
+ const $3bfd3f1d3eb46898$export$5eb0a366a50fa99e = 2592000000;
11533
+ /** V4's longest product id (`ProductRef`); a longer one is never a product it knows. */
11534
+ const $3bfd3f1d3eb46898$var$MAX_ID_LENGTH = 500;
11535
+ const $3bfd3f1d3eb46898$var$storage_key = merchant => "depict_v4_recent_views_".concat(merchant);
11536
+ /** The list per merchant as last written, which reads use when localStorage can't hold it. */
11537
+ const $3bfd3f1d3eb46898$var$in_memory = new Map();
11538
+ /** Merchants whose last write to localStorage failed, so localStorage holds an older list than memory. */
11539
+ const $3bfd3f1d3eb46898$var$unstored = new Set();
11540
+ /** `views` as a valid list: well-formed entries, newest first, one per id, not older than the age bound or too many. */
11541
+ function $3bfd3f1d3eb46898$var$bounded(views, now) {
11542
+ if (!Array.isArray(views)) return [];
11543
+ const seen = new Set();
11544
+ const kept = [];
11545
+ for (const item of views) {
11546
+ if (!item || typeof item !== "object") continue;
11547
+ const {
11548
+ id: id,
11549
+ at: at
11550
+ } = item;
11551
+ if (typeof id !== "string" || !id || id.length > $3bfd3f1d3eb46898$var$MAX_ID_LENGTH || typeof at !== "string") continue;
11552
+ const time = Date.parse(at);
11553
+ if (Number.isNaN(time) || now - time > $3bfd3f1d3eb46898$export$5eb0a366a50fa99e) continue;
11554
+ kept.push({
11555
+ view: {
11556
+ id: id,
11557
+ at: new Date(time).toISOString()
11558
+ },
11559
+ time: time
11560
+ });
11561
+ }
11562
+ kept.sort((a, b) => b.time - a.time);
11563
+ const newest = [];
11564
+ for (const {
11565
+ view: view
11566
+ } of kept) {
11567
+ if (seen.has(view.id)) continue;
11568
+ seen.add(view.id);
11569
+ newest.push(view);
11570
+ if (newest.length === $3bfd3f1d3eb46898$export$3d684435158adda6) break;
11571
+ }
11572
+ return newest;
11573
+ }
11574
+ function $3bfd3f1d3eb46898$var$read_stored(merchant) {
11575
+ if ($3bfd3f1d3eb46898$var$unstored.has(merchant)) return $3bfd3f1d3eb46898$var$in_memory.get(merchant);
11576
+ try {
11577
+ const stored = localStorage.getItem($3bfd3f1d3eb46898$var$storage_key(merchant));
11578
+ return stored === null ? [] : JSON.parse(stored);
11579
+ } catch {
11580
+ var _in_memory$get;
11581
+ return (_in_memory$get = $3bfd3f1d3eb46898$var$in_memory.get(merchant)) !== null && _in_memory$get !== void 0 ? _in_memory$get : [];
11582
+ }
11583
+ }
11584
+ function $3bfd3f1d3eb46898$export$2d7138f47b625a04(merchant) {
11585
+ let now = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Date.now();
11586
+ return $3bfd3f1d3eb46898$var$bounded($3bfd3f1d3eb46898$var$read_stored(merchant), now);
11587
+ }
11588
+ function $3bfd3f1d3eb46898$export$6379943de8f8af08(merchant, product_id) {
11589
+ let now = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Date.now();
11590
+ const views = $3bfd3f1d3eb46898$var$bounded([{
11591
+ id: product_id,
11592
+ at: new Date(now).toISOString()
11593
+ }, ...$3bfd3f1d3eb46898$export$2d7138f47b625a04(merchant, now)], now);
11594
+ $3bfd3f1d3eb46898$var$in_memory.set(merchant, views);
11595
+ try {
11596
+ localStorage.setItem($3bfd3f1d3eb46898$var$storage_key(merchant), JSON.stringify(views));
11597
+ $3bfd3f1d3eb46898$var$unstored.delete(merchant);
11598
+ } catch {
11599
+ // localStorage unavailable or full: the in-memory list serves this page load.
11600
+ $3bfd3f1d3eb46898$var$unstored.add(merchant);
11601
+ }
11602
+ }
11603
+
11604
+ /** V4's largest `limit`, and the most ids `cart` and `exclude` take. */
11605
+ const $e8c6cfefe84af5d7$export$f112abad09998fa8 = 100;
11606
+ const $e8c6cfefe84af5d7$var$MAX_IDS = 100;
11607
+ /** The most products V4's `recent_views` takes. */
11608
+ const $e8c6cfefe84af5d7$var$MAX_VIEWS = 50;
11609
+ /** What a v3 recommendations call names, as fetchDepictRecommendations takes it. */
11610
+ const $e8c6cfefe84af5d7$var$distinct = ids => [...new Set(ids.filter(id => typeof id === "string" && id.length > 0))];
11611
+ function $e8c6cfefe84af5d7$export$17493dc1a89b34e6(call, inputs, recent_views) {
11612
+ var _call$productIds;
11613
+ const reads = input => inputs ? inputs.includes(input) : input === "anchor";
11614
+ const product_ids = $e8c6cfefe84af5d7$var$distinct((_call$productIds = call.productIds) !== null && _call$productIds !== void 0 ? _call$productIds : []);
11615
+ const request = {
11616
+ market: call.market,
11617
+ ...(call.locale ? {
11618
+ locale: call.locale
11619
+ } : {}),
11620
+ type: call.type
11621
+ };
11622
+ if (reads("anchor")) {
11623
+ if (call.categoryId) request.anchor = {
11624
+ type: "category",
11625
+ id: call.categoryId
11626
+ };else if (call.productId) request.anchor = {
11627
+ type: "product",
11628
+ id: call.productId
11629
+ };else if (product_ids.length) {
11630
+ const [first, ...rest] = product_ids;
11631
+ request.anchor = {
11632
+ type: "product",
11633
+ id: first
11634
+ };
11635
+ if (rest.length) request.exclude = rest.slice(0, $e8c6cfefe84af5d7$var$MAX_IDS);
11636
+ }
11637
+ }
11638
+ if (reads("cart") && product_ids.length) request.cart = product_ids.slice(0, $e8c6cfefe84af5d7$var$MAX_IDS);
11639
+ if (reads("recent_views") && recent_views.length) request.recent_views = recent_views.slice(0, $e8c6cfefe84af5d7$var$MAX_VIEWS);
11640
+ if (call.limit) request.limit = Math.min(Math.max(1, Math.floor(call.limit)), $e8c6cfefe84af5d7$export$f112abad09998fa8);
11641
+ request.include = ["attributes"];
11642
+ const anchor_only = (inputs === null || inputs === void 0 ? void 0 : inputs.length) === 1 && inputs[0] === "anchor";
11643
+ if (anchor_only && !request.anchor) return undefined;
11644
+ return request;
11645
+ }
11646
+ /** `encodeURIComponent`, as V4's own encoder writes a value (`+` would mean a space). */
11647
+ const $e8c6cfefe84af5d7$var$encode = value => encodeURIComponent(value);
11648
+ function $e8c6cfefe84af5d7$export$fc756666ac777d0(request) {
11649
+ var _request$recent_views;
11650
+ const pairs = [];
11651
+ const add = (key, value) => value !== undefined && pairs.push("".concat(key, "=").concat(value));
11652
+ const list = values => values === null || values === void 0 ? void 0 : values.map($e8c6cfefe84af5d7$var$encode).join(",");
11653
+ add("market", $e8c6cfefe84af5d7$var$encode(request.market));
11654
+ add("locale", request.locale === undefined ? undefined : $e8c6cfefe84af5d7$var$encode(request.locale));
11655
+ add("type", $e8c6cfefe84af5d7$var$encode(request.type));
11656
+ add("anchor", request.anchor && "".concat($e8c6cfefe84af5d7$var$encode(request.anchor.type), ":").concat($e8c6cfefe84af5d7$var$encode(request.anchor.id)));
11657
+ add("cart", list(request.cart));
11658
+ add("recent_views", (_request$recent_views = request.recent_views) === null || _request$recent_views === void 0 ? void 0 : _request$recent_views.map(view => "".concat($e8c6cfefe84af5d7$var$encode(view.id), "@").concat($e8c6cfefe84af5d7$var$encode(view.at))).join(","));
11659
+ add("query", request.query === undefined ? undefined : $e8c6cfefe84af5d7$var$encode(request.query));
11660
+ add("exclude", list(request.exclude));
11661
+ add("limit", request.limit === undefined ? undefined : String(request.limit));
11662
+ add("include", list(request.include));
11663
+ return pairs.join("&");
11664
+ }
11665
+ const $e8c6cfefe84af5d7$export$89962366050887f7 = product => {
11666
+ var _product$variants$pro, _product$variants$pro2;
11667
+ return (_product$variants$pro = (_product$variants$pro2 = product.variants[product.selected]) === null || _product$variants$pro2 === void 0 ? void 0 : _product$variants$pro2.product_id) !== null && _product$variants$pro !== void 0 ? _product$variants$pro : product.group_id;
11668
+ };
11669
+ function $e8c6cfefe84af5d7$export$afe6aeae61a7aa58(hits, scope, type) {
11670
+ const anchors = hits.slice(0, type === "search" ? 10 : 1);
11671
+ return anchors.map((anchor, at) => {
11672
+ const exclude = hits.filter((_, index) => index !== at).map($e8c6cfefe84af5d7$export$89962366050887f7);
11673
+ return {
11674
+ market: scope.market,
11675
+ ...(scope.locale ? {
11676
+ locale: scope.locale
11677
+ } : {}),
11678
+ type: type,
11679
+ anchor: {
11680
+ type: "product",
11681
+ id: $e8c6cfefe84af5d7$export$89962366050887f7(anchor)
11682
+ },
11683
+ ...(exclude.length ? {
11684
+ exclude: exclude.slice(0, $e8c6cfefe84af5d7$var$MAX_IDS)
11685
+ } : {}),
11686
+ include: ["attributes"]
11687
+ };
11688
+ });
11689
+ }
11690
+ function $e8c6cfefe84af5d7$export$9af50be6508dcd00(lists, limit) {
11691
+ const merged = [];
11692
+ const taken = new Set();
11693
+ const depth = Math.max(0, ...lists.map(list => list.length));
11694
+ for (let index = 0; index < depth; index++) for (const list of lists) {
11695
+ const product = list[index];
11696
+ if (product === undefined || taken.has(product.group_id)) continue;
11697
+ taken.add(product.group_id);
11698
+ merged.push(product);
11699
+ if (merged.length >= limit) return merged;
11700
+ }
11701
+ return merged;
11702
+ }
11703
+
11704
+ /** Which v3 result id a card's `tracking_id` goes in; the d1 id it carries says the same (`d1.s.…`, `d1.l.…`). */ /** A bare 3/4/6/8-digit hex, as fi stores a computed `color_hex`; v3 serves it with its `#`. */
11705
+ const $7516809707c75ea7$var$BARE_HEX = /^(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
11706
+ function $7516809707c75ea7$export$7abfb7bc025aaea8(product, tracking_key) {
11707
+ var _product$attributes;
11708
+ const product_attributes = (_product$attributes = product.attributes) !== null && _product$attributes !== void 0 ? _product$attributes : {};
11709
+ return {
11710
+ variant_index: product.selected,
11711
+ variant_displays: product.variants.map(variant => {
11712
+ var _variant$price, _variant$color, _ref, _variant$attributes$m, _variant$attributes, _variant$title, _price$compare_at, _variant$slug;
11713
+ // A variant carries its own main image only when it differs from the card's; it has no gallery of its own.
11714
+ const image_urls = variant.image ? [variant.image] : [...product.images];
11715
+ const price = (_variant$price = variant.price) !== null && _variant$price !== void 0 ? _variant$price : product.price;
11716
+ const color = (_variant$color = variant.color) !== null && _variant$color !== void 0 ? _variant$color : product.color;
11717
+ const display = {
11718
+ ...product_attributes,
11719
+ // The merchant's variant attributes under their own keys (`add_to_cart_id`, `item_group_id`, …); the card
11720
+ // fields below win over a same-named attribute, as on v3.
11721
+ ...variant.attributes,
11722
+ product_id: variant.product_id,
11723
+ main_product_id: (_ref = (_variant$attributes$m = (_variant$attributes = variant.attributes) === null || _variant$attributes === void 0 ? void 0 : _variant$attributes.main_product_id) !== null && _variant$attributes$m !== void 0 ? _variant$attributes$m : variant.group_id) !== null && _ref !== void 0 ? _ref : product.group_id,
11724
+ title: (_variant$title = variant.title) !== null && _variant$title !== void 0 ? _variant$title : product.title,
11725
+ image_urls: image_urls,
11726
+ sale_price: price.amount,
11727
+ original_price: (_price$compare_at = price.compare_at) !== null && _price$compare_at !== void 0 ? _price$compare_at : price.amount,
11728
+ ...(price.lowest !== undefined ? {
11729
+ lowest_price: price.lowest
11730
+ } : {}),
11731
+ in_stock: variant.in_stock,
11732
+ ...(color ? {
11733
+ color_name: color.name
11734
+ } : {}),
11735
+ uri: (_variant$slug = variant.slug) !== null && _variant$slug !== void 0 ? _variant$slug : product.slug
11736
+ };
11737
+ const hex = display.color_hex;
11738
+ if (typeof hex === "string" && $7516809707c75ea7$var$BARE_HEX.test(hex)) display.color_hex = "#".concat(hex);
11739
+ return display;
11740
+ }),
11741
+ [tracking_key]: product.tracking_id
11742
+ };
11743
+ }
11744
+ function $744a9d695dd21ed2$var$_classPrivateFieldInitSpec(obj, privateMap, value) {
11745
+ $744a9d695dd21ed2$var$_checkPrivateRedeclaration(obj, privateMap);
11746
+ privateMap.set(obj, value);
11747
+ }
11748
+ function $744a9d695dd21ed2$var$_checkPrivateRedeclaration(obj, privateCollection) {
11749
+ if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
11750
+ }
11751
+ class $744a9d695dd21ed2$export$f5ea4d073ddb4bdb extends Error {}
11752
+ /** v3's names for V4's built-in fields, both ways. */
11753
+ const $744a9d695dd21ed2$var$V3_FIELD = {
11754
+ price: "sale_price"
11755
+ };
11756
+ const $744a9d695dd21ed2$var$V4_FIELD = {
11757
+ sale_price: "price"
11758
+ };
11759
+ const $744a9d695dd21ed2$var$V3_SORT = {
11760
+ relevance: "_relevance",
11761
+ price: "sale_price",
11762
+ newest: "product_timestamp"
11763
+ };
11764
+ const $744a9d695dd21ed2$var$V4_SORT = Object.fromEntries(Object.entries($744a9d695dd21ed2$var$V3_SORT).map(_ref => {
11765
+ let [v4, v3] = _ref;
11766
+ return [v3, v4];
11767
+ }));
11768
+ /** V4's public filter field syntax (`FilterField` in the contract). */
11769
+ const $744a9d695dd21ed2$var$PUBLIC_FIELD = /^[A-Za-z0-9_-]+(\.[A-Za-z0-9_-]+)*$/;
11770
+ /**
11771
+ * Fields that are never a lowercased group title: v3's toggles carry no group title, and `sale_price` is v3's own
11772
+ * name for V4's price. A reserved V4 field (`price`, `brand`, `category`) is not among them: iciw's category tree is
11773
+ * titled "Category", so `category` from a link may name `product_scollection_category_hierarchy`.
11774
+ */
11775
+ const $744a9d695dd21ed2$var$NEVER_A_TITLE = new Set(["in_stock", "on_sale", "sale_price"]);
11776
+ /** fi's enriched colour fields: their values are names, never a `<name>;#<hex>` composite. */
11777
+ const $744a9d695dd21ed2$var$FI_COLOUR_FIELDS = new Set(["colors", "color_details"]);
11778
+ /** The colour template's field, which indexes the composite itself. */
11779
+ const $744a9d695dd21ed2$var$V3_TEMPLATE_COLOUR = "color_with_hex_list";
11780
+ /** Legacy's colour pill composite suffix (`Green;#9ea386`). */
11781
+ const $744a9d695dd21ed2$var$HEX_SUFFIX = /;#[0-9a-fA-F]{3,8}\s*$/;
11782
+ const $744a9d695dd21ed2$var$NUMERIC = /^-?\d+(\.\d+)?$/;
11783
+ /** realtime's separator between the levels of a hierarchical facet value (`Shop # Woman`). */
11784
+ const $744a9d695dd21ed2$var$HIERARCHY_SEPARATOR = " # ";
11785
+ /** The features realtime's category tree is built on. */
11786
+ const $744a9d695dd21ed2$var$CATEGORY_TREE_FIELDS = new Set(["product_category_hierarchy", "product_scollection_category_hierarchy"]);
11787
+ /** V4's public name for the discount template's field (realtime `v4/worker/src/search/fields.ts`). */
11788
+ const $744a9d695dd21ed2$var$DISCOUNT_FIELD = "discount";
11789
+ /** The fields of V4's toggle facets (the `on_sale` and `in_stock` templates). */
11790
+ const $744a9d695dd21ed2$var$V3_TOGGLES = new Set(["on_sale", "in_stock"]);
11791
+ var $744a9d695dd21ed2$var$_by_key = /*#__PURE__*/new WeakMap();
11792
+ class $744a9d695dd21ed2$export$8d488bcc71d07ffb {
11793
+ constructor() {
11794
+ $744a9d695dd21ed2$var$_classPrivateFieldInitSpec(this, $744a9d695dd21ed2$var$_by_key, {
11795
+ writable: true,
11796
+ value: new Map()
11797
+ });
11798
+ }
11799
+ /** Adds the facets of one browse response. */
11800
+ learn_(facets) {
11801
+ for (const facet of facets !== null && facets !== void 0 ? facets : []) {
11802
+ const info = {
11803
+ field_: facet.field,
11804
+ checkbox_: facet.type === "checkbox" && !$744a9d695dd21ed2$var$is_toggle(facet),
11805
+ colour_: $744a9d695dd21ed2$var$FI_COLOUR_FIELDS.has(facet.field) || facet.type === "swatch" && facet.field !== $744a9d695dd21ed2$var$V3_TEMPLATE_COLOUR
11806
+ };
11807
+ $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).set(facet.field, info);
11808
+ const v3_field = $744a9d695dd21ed2$var$V3_FIELD[facet.field];
11809
+ if (v3_field) $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).set(v3_field, info);
11810
+ if (facet.title) $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).set(facet.title.toLowerCase(), info);
11811
+ }
11812
+ }
11813
+ /** The field a v3 filter field names, when a served facet has it as its field or its title. */
11814
+ get_(field) {
11815
+ const bare = field.replace(/#$/, "");
11816
+ const direct = $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).get(bare);
11817
+ if (direct) return direct;
11818
+ let wanted;
11819
+ try {
11820
+ wanted = decodeURIComponent(bare).toLowerCase();
11821
+ } catch {
11822
+ wanted = bare.toLowerCase();
11823
+ }
11824
+ return $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $744a9d695dd21ed2$var$_by_key).get(wanted);
11825
+ }
11826
+ }
11827
+ function $744a9d695dd21ed2$export$3b6ba2422a5e0aa0(field, index) {
11828
+ return !!index.get_(field) || $744a9d695dd21ed2$var$NEVER_A_TITLE.has(field.replace(/#$/, ""));
11829
+ }
11830
+ function $744a9d695dd21ed2$var$is_empty(data) {
11831
+ return data === undefined || data === null || data === "" || Array.isArray(data) && !data.length;
11832
+ }
11833
+ function $744a9d695dd21ed2$var$literal(value, field) {
11834
+ const text = String(value);
11835
+ if (text.includes("`")) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: a value of ".concat(field, " contains a backtick"));
11836
+ // A boolean-looking string is written bare, as realtime's filter writer does for every field.
11837
+ if (/^(true|True|false|False)$/.test(text)) return text.toLowerCase();
11838
+ if (field === "price" && $744a9d695dd21ed2$var$NUMERIC.test(text)) return text;
11839
+ return typeof value === "string" ? "`".concat(text, "`") : text;
11840
+ }
11841
+ function $744a9d695dd21ed2$var$lax_number(value) {
11842
+ if (typeof value === "number") return value;
11843
+ if (typeof value !== "string" || value.trim() === "") return undefined;
11844
+ const number = Number(value);
11845
+ return Number.isFinite(number) ? number : undefined;
11846
+ }
11847
+ function $744a9d695dd21ed2$export$c17bb5d2ead3e8f3(filter, index) {
11848
+ var _ref2, _info$field_;
11849
+ if ($744a9d695dd21ed2$var$is_empty(filter.data)) return undefined;
11850
+ const info = index.get_(filter.field);
11851
+ const bare = filter.field.replace(/#$/, "");
11852
+ const field = (_ref2 = (_info$field_ = info === null || info === void 0 ? void 0 : info.field_) !== null && _info$field_ !== void 0 ? _info$field_ : $744a9d695dd21ed2$var$V4_FIELD[bare]) !== null && _ref2 !== void 0 ? _ref2 : bare;
11853
+ if (!$744a9d695dd21ed2$var$PUBLIC_FIELD.test(field)) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("Invalid filter field `".concat(filter.field, "`"));
11854
+ const clause = text => ({
11855
+ field_: field,
11856
+ clause_: text
11857
+ });
11858
+ const colour = $744a9d695dd21ed2$var$FI_COLOUR_FIELDS.has(field) || !!(info !== null && info !== void 0 && info.colour_);
11859
+ const data = filter.data;
11860
+ const values = (Array.isArray(data) ? data : [data]).map(value => !Array.isArray(value) ? colour && typeof value === "string" ? value.replace($744a9d695dd21ed2$var$HEX_SUFFIX, "").trim() || value : value : field === "category" ? value[value.length - 1] : value.map(String).join($744a9d695dd21ed2$var$HIERARCHY_SEPARATOR));
11861
+ const list = () => "[".concat(values.map(value => $744a9d695dd21ed2$var$literal(value, field)).join(","), "]");
11862
+ // V4's discount filter (the discount template's "X% or more" radio) is a threshold, so `in` or `eq` on it means
11863
+ // "this discount or more", as on the facade since realtime#2181: a link with no operator decodes as `in`, and a
11864
+ // shop may send `in ["0.2"]` itself. Several values take the largest, as `geq` does.
11865
+ const op = (filter.op === "in" || filter.op === "eq") && field === $744a9d695dd21ed2$var$DISCOUNT_FIELD ? "geq" : filter.op;
11866
+ // A configured checkbox keeps in/nin; every other op on it becomes in.
11867
+ if (op !== "in" && op !== "nin" && info !== null && info !== void 0 && info.checkbox_) return clause("".concat(field, ":=").concat(list()));
11868
+ const one = () => {
11869
+ if (values.length !== 1) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: ".concat(op, " takes one value"));
11870
+ return $744a9d695dd21ed2$var$literal(values[0], field);
11871
+ };
11872
+ // A comparison takes a number, also one sent as a string; of several numbers `geq` takes the largest.
11873
+ const bound = () => {
11874
+ const numbers = values.map(value => typeof value === "number" || typeof value === "string" && $744a9d695dd21ed2$var$NUMERIC.test(value) ? Number(value) : undefined);
11875
+ if (numbers.length === 0 || numbers.some(number => number === undefined)) return one();
11876
+ if (numbers.length > 1 && op !== "geq") return one();
11877
+ return String(Math.max(...numbers));
11878
+ };
11879
+ switch (op) {
11880
+ case "eq":
11881
+ return clause("".concat(field, ":=").concat(one()));
11882
+ case "neq":
11883
+ return clause("".concat(field, ":!=").concat(one()));
11884
+ case "in":
11885
+ return clause("".concat(field, ":=").concat(list()));
11886
+ case "nin":
11887
+ return clause("".concat(field, ":!=").concat(list()));
11888
+ case "leq":
11889
+ return clause("".concat(field, ":<=").concat(bound()));
11890
+ case "geq":
11891
+ return clause("".concat(field, ":>=").concat(bound()));
11892
+ case "inrange":
11893
+ {
11894
+ const [min, max] = values.map($744a9d695dd21ed2$var$lax_number);
11895
+ if (min === undefined || max === undefined || values.length !== 2) throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: inrange takes [min, max]");
11896
+ return clause("".concat(field, ":[").concat(min, "..").concat(max, "]"));
11897
+ }
11898
+ default:
11899
+ throw new $744a9d695dd21ed2$export$f5ea4d073ddb4bdb("filters: unknown op ".concat(op));
11900
+ }
11901
+ }
11902
+ function $744a9d695dd21ed2$export$407f30f25da13cc7(filters, index) {
11903
+ const clauses = filters.flatMap(filter => {
11904
+ var _v3_filter_to_clause$, _v3_filter_to_clause;
11905
+ return (_v3_filter_to_clause$ = (_v3_filter_to_clause = $744a9d695dd21ed2$export$c17bb5d2ead3e8f3(filter, index)) === null || _v3_filter_to_clause === void 0 ? void 0 : _v3_filter_to_clause.clause_) !== null && _v3_filter_to_clause$ !== void 0 ? _v3_filter_to_clause$ : [];
11906
+ });
11907
+ return clauses.length ? clauses.join(" && ") : undefined;
11908
+ }
11909
+ function $744a9d695dd21ed2$export$c38de645260a41ed(error, clauses) {
11910
+ var _match, _error$message;
11911
+ if (!error || !clauses.length) return [];
11912
+ const named = (_match = ((_error$message = error.message) !== null && _error$message !== void 0 ? _error$message : "").match(/"([A-Za-z0-9_.-]+)/)) === null || _match === void 0 ? void 0 : _match[1];
11913
+ if (error.code === "unknown_filter_field") {
11914
+ if (error.allowed) {
11915
+ const allowed = new Set(error.allowed);
11916
+ return clauses.filter(clause => !allowed.has(clause.field_));
11917
+ }
11918
+ return clauses.filter(clause => clause.field_ === named);
11919
+ }
11920
+ if (error.code === "invalid_filter") {
11921
+ const on_field = clauses.filter(clause => clause.field_ === named);
11922
+ return on_field.length ? on_field : [...clauses];
11923
+ }
11924
+ return [];
11925
+ }
11926
+ function $744a9d695dd21ed2$export$78eb8e636d89ff30(sort) {
11927
+ var _V4_SORT$sort$field;
11928
+ if (!sort || sort.field === "_relevance") return undefined;
11929
+ return {
11930
+ field: (_V4_SORT$sort$field = $744a9d695dd21ed2$var$V4_SORT[sort.field]) !== null && _V4_SORT$sort$field !== void 0 ? _V4_SORT$sort$field : sort.field,
11931
+ order: sort.order
11932
+ };
11933
+ }
11934
+ function $744a9d695dd21ed2$export$cd08b64be5110ce2(sorts) {
11935
+ return sorts.map(sort => {
11936
+ var _V3_SORT$sort$field;
11937
+ return {
11938
+ field: (_V3_SORT$sort$field = $744a9d695dd21ed2$var$V3_SORT[sort.field]) !== null && _V3_SORT$sort$field !== void 0 ? _V3_SORT$sort$field : sort.field,
11939
+ order: sort.order,
11940
+ meta: {
11941
+ title: sort.title,
11942
+ values: [sort.order],
11943
+ names: [sort.title]
11944
+ }
11945
+ };
11946
+ });
11947
+ }
11948
+ const $744a9d695dd21ed2$var$V3_VALUES_TYPE = {
11949
+ checkbox: "checkbox",
11950
+ radio: "radio",
11951
+ swatch: "checkbox-color",
11952
+ hierarchy: "checkbox-hierarchical",
11953
+ grid: "checkbox-grid"
11954
+ };
11955
+ /** A toggle is a template facet's one `true` value. */
11956
+ function $744a9d695dd21ed2$var$is_toggle(facet) {
11957
+ return $744a9d695dd21ed2$var$V3_TOGGLES.has(facet.field) && facet.type === "checkbox" && facet.values.length === 1 && facet.values[0].value === "true";
11958
+ }
11959
+ function $744a9d695dd21ed2$var$category_path(value) {
11960
+ return value.split("#").map(level => level.trim()).filter(Boolean);
11961
+ }
11962
+ function $744a9d695dd21ed2$export$da9af372695714ef(facets, currency) {
11963
+ return facets.filter(facet => facet.type === "range" || facet.values.length > 0).map(facet => {
11964
+ var _V3_FIELD$facet$field, _V3_VALUES_TYPE$facet;
11965
+ const field = (_V3_FIELD$facet$field = $744a9d695dd21ed2$var$V3_FIELD[facet.field]) !== null && _V3_FIELD$facet$field !== void 0 ? _V3_FIELD$facet$field : facet.field;
11966
+ if (facet.type === "range") return {
11967
+ field: field,
11968
+ op: "inrange",
11969
+ data: [facet.min, facet.max],
11970
+ meta: {
11971
+ group_title: facet.title,
11972
+ type: "range",
11973
+ min: facet.min,
11974
+ max: facet.max,
11975
+ ...(facet.field === "price" && currency ? {
11976
+ currency: currency
11977
+ } : {})
11978
+ },
11979
+ id: "".concat(field, "1")
11980
+ };
11981
+ const hierarchy = facet.type === "hierarchy";
11982
+ const path = value => $744a9d695dd21ed2$var$CATEGORY_TREE_FIELDS.has(facet.field) ? $744a9d695dd21ed2$var$category_path(value) : value.split($744a9d695dd21ed2$var$HIERARCHY_SEPARATOR);
11983
+ if ($744a9d695dd21ed2$var$is_toggle(facet)) return {
11984
+ field: field,
11985
+ op: "eq",
11986
+ meta: {
11987
+ type: "checkbox",
11988
+ values: facet.values.map(value => value.value),
11989
+ counts: facet.values.map(value => value.count),
11990
+ names: facet.values.map(value => value.label)
11991
+ },
11992
+ id: "".concat(field, "1")
11993
+ };
11994
+ // Two spellings of one category path are one row in the tree.
11995
+ const seen = new Set();
11996
+ const values = $744a9d695dd21ed2$var$CATEGORY_TREE_FIELDS.has(facet.field) ? facet.values.filter(_ref3 => {
11997
+ let {
11998
+ value: value
11999
+ } = _ref3;
12000
+ const levels = path(value);
12001
+ const key = JSON.stringify(levels);
12002
+ if (levels.length === 0 || seen.has(key)) return false;
12003
+ seen.add(key);
12004
+ return true;
12005
+ }) : facet.values;
12006
+ return {
12007
+ field: field,
12008
+ op: facet.field === "discount" ? "geq" : "in",
12009
+ meta: {
12010
+ group_title: facet.title,
12011
+ type: (_V3_VALUES_TYPE$facet = $744a9d695dd21ed2$var$V3_VALUES_TYPE[facet.type]) !== null && _V3_VALUES_TYPE$facet !== void 0 ? _V3_VALUES_TYPE$facet : "checkbox",
12012
+ values: values.map(value => hierarchy ? path(value.value) : value.value),
12013
+ counts: values.map(value => value.count),
12014
+ names: values.map(value => hierarchy ? path(value.value).slice(-1)[0] : value.label),
12015
+ // The colour template sends swatches only with one to paint; a colour filter always sends them.
12016
+ ...(facet.type === "swatch" && (facet.field !== $744a9d695dd21ed2$var$V3_TEMPLATE_COLOUR || facet.values.some(value => value.swatch)) ? {
12017
+ swatches: facet.values.map(value => {
12018
+ var _value$swatch;
12019
+ return (_value$swatch = value.swatch) !== null && _value$swatch !== void 0 ? _value$swatch : null;
12020
+ })
12021
+ } : {})
12022
+ },
12023
+ id: "".concat(field, "1")
12024
+ };
12025
+ });
12026
+ }
12027
+ function $744a9d695dd21ed2$export$b84a41a5163c4fce(content) {
12028
+ return content.map(hit => {
12029
+ var _hit$highlights;
12030
+ return {
12031
+ type: "content_link",
12032
+ title: hit.title,
12033
+ ...(hit.description !== undefined ? {
12034
+ description: hit.description
12035
+ } : {}),
12036
+ ...(hit.image_url !== undefined ? {
12037
+ image_url: hit.image_url
12038
+ } : {}),
12039
+ page_url: hit.url,
12040
+ highlights: (_hit$highlights = hit.highlights) !== null && _hit$highlights !== void 0 ? _hit$highlights : []
12041
+ };
12042
+ });
12043
+ }
12044
+ function $14bc537adeeadca4$export$efb7dd882d411dd4(response, door, offset) {
12045
+ var _response$total, _response$sorts, _response$facets, _response$content;
12046
+ const tracking_key = door === "search" ? "search_result_id" : "product_listing_result_id";
12047
+ return {
12048
+ n_hits: (_response$total = response.total) !== null && _response$total !== void 0 ? _response$total : offset + response.products.length,
12049
+ sorts: $744a9d695dd21ed2$export$cd08b64be5110ce2((_response$sorts = response.sorts) !== null && _response$sorts !== void 0 ? _response$sorts : []),
12050
+ filters: $744a9d695dd21ed2$export$da9af372695714ef((_response$facets = response.facets) !== null && _response$facets !== void 0 ? _response$facets : [], response.currency),
12051
+ ...(door === "search" ? {
12052
+ search_request_id: response.request_id,
12053
+ content_search_links: $744a9d695dd21ed2$export$b84a41a5163c4fce((_response$content = response.content) !== null && _response$content !== void 0 ? _response$content : []),
12054
+ is_fallback: null
12055
+ } : {
12056
+ product_listing_request_id: response.request_id
12057
+ }),
12058
+ ...(response.cursor !== undefined ? {
12059
+ cursor: response.cursor
12060
+ } : {}),
12061
+ displays: response.products.map(product => $7516809707c75ea7$export$7abfb7bc025aaea8(product, tracking_key))
12062
+ };
12063
+ }
12064
+ function $14bc537adeeadca4$var$listing_ref_to_v3(ref, listing_type, show) {
12065
+ return {
12066
+ listing_id: ref.id,
12067
+ ...(ref.external_id !== undefined ? {
12068
+ external_id: ref.external_id
12069
+ } : {}),
12070
+ listing_type: listing_type,
12071
+ ...show,
12072
+ image_urls: [],
12073
+ title: ref.title,
12074
+ ...(ref.slug !== undefined ? {
12075
+ slug: ref.slug
12076
+ } : {})
12077
+ };
12078
+ }
12079
+ function $14bc537adeeadca4$export$996f2b1e66d9b5af(listing) {
12080
+ const listing_type = listing.type;
12081
+ const quick_links_are_siblings = listing.quick_links.some(link => link.id === listing.id);
12082
+ const quick_links = listing.quick_links.map(link => $14bc537adeeadca4$var$listing_ref_to_v3(link, listing_type, {
12083
+ show_in_breadcrumbs: true,
12084
+ show_in_quicklinks: true
12085
+ }));
12086
+ return {
12087
+ listing_id: listing.id,
12088
+ ...(listing.external_id !== undefined ? {
12089
+ external_id: listing.external_id
12090
+ } : {}),
12091
+ listing_type: listing_type,
12092
+ show_in_breadcrumbs: listing.show_in_breadcrumbs,
12093
+ show_in_quicklinks: true,
12094
+ image_urls: listing.images,
12095
+ title: listing.title,
12096
+ ...(listing.slug !== undefined ? {
12097
+ slug: listing.slug
12098
+ } : {}),
12099
+ ancestors: listing.breadcrumbs.map(ref => $14bc537adeeadca4$var$listing_ref_to_v3(ref, "category", {
12100
+ show_in_breadcrumbs: true,
12101
+ show_in_quicklinks: true
12102
+ })),
12103
+ siblings: quick_links_are_siblings ? quick_links : [],
12104
+ children: quick_links_are_siblings ? [] : quick_links,
12105
+ content_blocks: listing.content_blocks
12106
+ };
12107
+ }
12108
+ function $14bc537adeeadca4$export$76d96892da63b395(tree) {
12109
+ const by_id = new Map();
12110
+ const walk = (nodes, chain) => {
12111
+ for (const node of nodes) {
12112
+ if (!by_id.has(node.id)) by_id.set(node.id, chain);
12113
+ walk(node.children, [...chain, $14bc537adeeadca4$var$listing_ref_to_v3(node, node.type, {
12114
+ show_in_breadcrumbs: true,
12115
+ show_in_quicklinks: true
12116
+ })]);
12117
+ }
12118
+ };
12119
+ walk(tree, []);
12120
+ return listing_id => by_id.get(listing_id);
12121
+ }
12122
+ function $14bc537adeeadca4$export$2860125b419015f8(response, ancestors_of) {
12123
+ return {
12124
+ suggestions_request_id: response.request_id,
12125
+ suggestions: response.suggestions.map(suggestion => {
12126
+ if (suggestion.type === "query") return {
12127
+ type: "query",
12128
+ query: suggestion.query,
12129
+ suggestions_result_id: ""
12130
+ };
12131
+ const from_tree = ancestors_of === null || ancestors_of === void 0 ? void 0 : ancestors_of(suggestion.listing.id);
12132
+ const ancestors = from_tree && $14bc537adeeadca4$var$same_titles(from_tree, suggestion.path) ? from_tree : [];
12133
+ return {
12134
+ type: "listing",
12135
+ listing_id: suggestion.listing.id,
12136
+ ...(suggestion.listing.external_id !== undefined ? {
12137
+ external_id: suggestion.listing.external_id
12138
+ } : {}),
12139
+ listing_type: suggestion.listing.type,
12140
+ show_in_breadcrumbs: true,
12141
+ show_in_quicklinks: true,
12142
+ image_urls: suggestion.listing.images,
12143
+ title: suggestion.listing.title,
12144
+ ...(suggestion.listing.slug !== undefined ? {
12145
+ slug: suggestion.listing.slug
12146
+ } : {}),
12147
+ suggestions_result_id: "",
12148
+ ancestors: ancestors
12149
+ };
12150
+ })
12151
+ };
12152
+ }
12153
+ const $14bc537adeeadca4$var$same_titles = (ancestors, path) => ancestors.length === path.length && ancestors.every((ancestor, index) => ancestor.title === path[index]);
12154
+ /** `encodeURIComponent`, as V4's own encoder writes a value (`+` would mean a space). */
12155
+ const $14bc537adeeadca4$var$encode = value => encodeURIComponent(value);
12156
+ function $14bc537adeeadca4$export$7659319cdb555579(request) {
12157
+ var _request$include;
12158
+ const pairs = ["market=".concat($14bc537adeeadca4$var$encode(request.market))];
12159
+ const add = (key, value) => value !== undefined && pairs.push("".concat(key, "=").concat(value));
12160
+ add("locale", request.locale === undefined ? undefined : $14bc537adeeadca4$var$encode(request.locale));
12161
+ add("query", request.query === undefined ? undefined : $14bc537adeeadca4$var$encode(request.query));
12162
+ if (request.listing && "id" in request.listing) add("listing", $14bc537adeeadca4$var$encode(request.listing.id));else if (request.listing) add("listing_external_id", $14bc537adeeadca4$var$encode(request.listing.external_id));
12163
+ add("filter_by", request.filter_by === undefined ? undefined : $14bc537adeeadca4$var$encode(request.filter_by));
12164
+ if (request.sort) add("sort", "".concat($14bc537adeeadca4$var$encode(request.sort.field), ".").concat(request.sort.order));
12165
+ add("include", (_request$include = request.include) === null || _request$include === void 0 ? void 0 : _request$include.join(","));
12166
+ add("cursor", request.cursor);
12167
+ add("limit", request.limit === undefined ? undefined : String(request.limit));
12168
+ return pairs.join("&");
12169
+ }
12170
+ function $14bc537adeeadca4$export$fec3e4b5adfcea2c(params) {
12171
+ return params.filter(pair => pair[1] !== undefined).map(_ref => {
12172
+ let [key, value] = _ref;
12173
+ return "".concat(key, "=").concat($14bc537adeeadca4$var$encode(value));
12174
+ }).join("&");
12175
+ }
12176
+ function $14bc537adeeadca4$export$eb90c08da400512d(locale) {
12177
+ return locale ? locale.replace(/_/g, "-") : undefined;
12178
+ }
12179
+
12180
+ /** realtime's related search page: the hits related recommendations anchor on and never repeat. */
12181
+ const $2573fc0c2eb12a79$var$RELATED_SEARCH_PAGE = 100;
12182
+ const $2573fc0c2eb12a79$var$get_recommendations = (merchant, request) => $8ad8c4b4b26ba277$export$88d793e3827f3436($8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, "/recommendations") + "?" + $e8c6cfefe84af5d7$export$fc756666ac777d0(request));
12183
+ const $2573fc0c2eb12a79$var$to_displays = products => products.map(product => $7516809707c75ea7$export$7abfb7bc025aaea8(product, "recommendation_id"));
12184
+ async function $2573fc0c2eb12a79$export$656ee5c46d5d1eda(call) {
12185
+ var _response$used_inputs;
12186
+ const {
12187
+ merchant: merchant
12188
+ } = call;
12189
+ const types = await $294cf81de92da757$export$869eb14d6f85ac51(merchant);
12190
+ const inputs = types === null || types === void 0 ? void 0 : types.get(call.type);
12191
+ if (types && !inputs) {
12192
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI] V4 serves ".concat(merchant, ' no recommendation type "').concat(call.type, '"; known:'), [...types.keys()]);
12193
+ return [];
12194
+ }
12195
+ const request = $e8c6cfefe84af5d7$export$17493dc1a89b34e6({
12196
+ ...call,
12197
+ locale: $14bc537adeeadca4$export$eb90c08da400512d(call.locale)
12198
+ }, inputs, inputs !== null && inputs !== void 0 && inputs.includes("recent_views") ? $3bfd3f1d3eb46898$export$2d7138f47b625a04(merchant) : []);
12199
+ if (!request) return [];
12200
+ const response = await $2573fc0c2eb12a79$var$get_recommendations(merchant, request);
12201
+ if (!response) return [];
12202
+ const anchor = (_response$used_inputs = response.used_inputs) === null || _response$used_inputs === void 0 ? void 0 : _response$used_inputs.anchor;
12203
+ if (call.productId && (anchor === null || anchor === void 0 ? void 0 : anchor.type) === "product") $3bfd3f1d3eb46898$export$6379943de8f8af08(merchant, anchor.id);
12204
+ return $2573fc0c2eb12a79$var$to_displays(response.products);
12205
+ }
12206
+ async function $2573fc0c2eb12a79$export$bd5f8a7d3e47a43d(call) {
12207
+ var _types$get, _types$get2, _call$query;
12208
+ const {
12209
+ merchant: merchant,
12210
+ market: market
12211
+ } = call;
12212
+ const types = await $294cf81de92da757$export$869eb14d6f85ac51(merchant);
12213
+ if (!types) return undefined;
12214
+ const type = (_types$get = types.get("search")) !== null && _types$get !== void 0 && _types$get.includes("anchor") ? "search" : (_types$get2 = types.get("similar")) !== null && _types$get2 !== void 0 && _types$get2.includes("anchor") ? "similar" : undefined;
12215
+ if (!type) {
12216
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI] V4 serves ".concat(merchant, " no search or similar recommendations for related products"));
12217
+ return [];
12218
+ }
12219
+ const locale = $14bc537adeeadca4$export$eb90c08da400512d(call.locale);
12220
+ const query = ((_call$query = call.query) === null || _call$query === void 0 ? void 0 : _call$query.trim()) || undefined;
12221
+ const searched = await $8ad8c4b4b26ba277$export$88d793e3827f3436($8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, "/browse") + "?" + $14bc537adeeadca4$export$7659319cdb555579({
12222
+ market: market,
12223
+ ...(locale ? {
12224
+ locale: locale
12225
+ } : {}),
12226
+ ...(query ? {
12227
+ query: query
12228
+ } : {}),
12229
+ limit: $2573fc0c2eb12a79$var$RELATED_SEARCH_PAGE
12230
+ }));
12231
+ if (!searched) return undefined;
12232
+ const asked = $e8c6cfefe84af5d7$export$afe6aeae61a7aa58(searched.products, {
12233
+ market: market,
12234
+ ...(locale ? {
12235
+ locale: locale
12236
+ } : {})
12237
+ }, type);
12238
+ if (!asked.length) return [];
12239
+ const answers = await Promise.all(asked.map(request => $2573fc0c2eb12a79$var$get_recommendations(merchant, request)));
12240
+ const lists = answers.filter(answer => !!answer).map(answer => answer.products);
12241
+ if (!lists.length) return undefined;
12242
+ const products = lists.length > 1 ? $e8c6cfefe84af5d7$export$9af50be6508dcd00(lists, Math.max(...lists.map(list => list.length))) : lists[0];
12243
+ return $2573fc0c2eb12a79$var$to_displays(products);
12244
+ }
11412
12245
  async function $087d5425868835e3$export$58e808b1db15d3bc(options) {
12246
+ if (options.api === "v4") return await $087d5425868835e3$var$fetch_native(options);
11413
12247
  const headers = options.headers;
11414
12248
  const product_id = options.productId || options.product_id; // Second fallback here is just because there was very little missing to make this work with snake_case input and in case someone puts in snake case'd stuff already (preview browser did) we can easily not break it
11415
12249
  const cleaned_up_options = $3hooq$depictaiutilishared.snakeCasifyObject(options);
11416
12250
  delete cleaned_up_options.headers;
11417
12251
  delete cleaned_up_options.product_id;
12252
+ delete cleaned_up_options.api;
11418
12253
  cleaned_up_options.session_id || (cleaned_up_options.session_id = $3hooq$depictaiutilishared.get_session_id());
11419
12254
  if (product_id && !cleaned_up_options.product_ids) cleaned_up_options.product_ids = [product_id];
11420
12255
  const options_to_send = cleaned_up_options;
@@ -11437,6 +12272,33 @@ async function $087d5425868835e3$export$58e808b1db15d3bc(options) {
11437
12272
  return ((_decoded = decoded) === null || _decoded === void 0 ? void 0 : _decoded.displays) || [];
11438
12273
  });
11439
12274
  }
12275
+ async function $087d5425868835e3$var$fetch_native(options) {
12276
+ const {
12277
+ merchant: merchant,
12278
+ market: market,
12279
+ locale: locale,
12280
+ type: type,
12281
+ headers: headers,
12282
+ categoryId: categoryId,
12283
+ productIds: productIds
12284
+ } = options;
12285
+ if (headers) $3hooq$depictaiutilishared.dwarn("fetchDepictRecommendations: headers aren't sent to the native V4 API", headers);
12286
+ try {
12287
+ return await $2573fc0c2eb12a79$export$656ee5c46d5d1eda({
12288
+ merchant: merchant,
12289
+ market: market,
12290
+ locale: locale,
12291
+ type: type,
12292
+ categoryId: categoryId,
12293
+ productId: options.productId || options.product_id,
12294
+ productIds: productIds,
12295
+ limit: options.limit
12296
+ });
12297
+ } catch (e) {
12298
+ $3hooq$depictaiutilishared.dlog("fetch_native_recommendations threw", e);
12299
+ return [];
12300
+ }
12301
+ }
11440
12302
  var $0c91ea7c14692db9$var$_tmpl$ = ["<div", ' class="sort-and-filter-buttons fake" aria-hidden="true" style="position:absolute;z-index:-1;pointer-events:none;opacity:0"><div class="outer"><div class="inner"><!--$-->', "<!--/--><!--$-->", "<!--/--><!--$-->", "<!--/--></div></div></div>"];
11441
12303
  const $0c91ea7c14692db9$export$824dde41348efed1 = /*@__PURE__*/(() => {
11442
12304
  const actual_function = _ref => {
@@ -11731,6 +12593,11 @@ function $e270e9f953fcbc58$var$_classPrivateMethodGet(receiver, privateSet, fn)
11731
12593
  }
11732
12594
  const $e270e9f953fcbc58$var$v3_base_url = (0, $3hooq$depictaiutilishared.base_url) + "/v3/";
11733
12595
  const $e270e9f953fcbc58$var$search_base_url = $e270e9f953fcbc58$var$v3_base_url + "search/";
12596
+ /**
12597
+ * One read DepictAPI makes, as the transport sees it. `request_` is the v3 request as DepictAPI would send it (with
12598
+ * session_id and metadata added), `body_` its JSON. A transport answers with the v3-shaped JSON response, or undefined
12599
+ * when the request failed (DepictAPI then serves its fallback response).
12600
+ */
11734
12601
  var $e270e9f953fcbc58$var$_supports_finalization_registry = /*#__PURE__*/new WeakMap();
11735
12602
  var $e270e9f953fcbc58$var$_cache_objs = /*#__PURE__*/new WeakMap();
11736
12603
  var $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint = /*#__PURE__*/new WeakSet();
@@ -11745,7 +12612,29 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
11745
12612
  * Runs the displayTransformer for the suggest endpoints results
11746
12613
  */ /**
11747
12614
  * rest = everything except query suggestions
11748
- */
12615
+ */ /**
12616
+ * The network step of every read: sends `call` to the v3 API and returns the decoded JSON, or undefined when the
12617
+ * request failed. NativeDepictAPI overrides this to read the native V4 API instead and map its answers to v3 shapes,
12618
+ * so caching, display transformers and fallbacks stay the same for both.
12619
+ */ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12620
+ async request_raw_(call) {
12621
+ const {
12622
+ endpoint_: endpoint_,
12623
+ method_: method_,
12624
+ request_: request_,
12625
+ body_: body_
12626
+ } = call;
12627
+ const is_post = method_ === "POST";
12628
+ const url_to_request = is_post ? endpoint_ : $3hooq$depictaiutilishared.make_url_with_query_params(endpoint_, request_);
12629
+ const api_response = await $3hooq$depictaiutilishared.fetch_retry($3hooq$depictaiutilishared.add_version_query_params(url_to_request), {
12630
+ method: method_,
12631
+ ...(is_post ? {
12632
+ body: body_
12633
+ } : {})
12634
+ });
12635
+ if (!api_response || call.kind_ !== "suggest" && api_response.status !== 200) return undefined;
12636
+ return await api_response.json();
12637
+ }
11749
12638
  constructor(options) {
11750
12639
  $e270e9f953fcbc58$var$_classPrivateMethodInitSpec(this, $e270e9f953fcbc58$var$_cached_request);
11751
12640
  $e270e9f953fcbc58$var$_classPrivateMethodInitSpec(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest);
@@ -11795,11 +12684,13 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
11795
12684
  const request = metaData ? Object.assign(with_ids, {
11796
12685
  metadata: JSON.stringify(metaData)
11797
12686
  }) : with_ids;
11798
- const url = $3hooq$depictaiutilishared.make_url_with_query_params($e270e9f953fcbc58$var$search_base_url + "suggestions", request);
11799
- const results = await $3hooq$depictaiutilishared.fetch_retry($3hooq$depictaiutilishared.add_version_query_params(url));
11800
12687
  attempt_to_return_api_response: {
11801
- if (!results) break attempt_to_return_api_response;
11802
- const decoded_json = await results.json();
12688
+ const decoded_json = await this.request_raw_({
12689
+ kind_: "suggest",
12690
+ endpoint_: $e270e9f953fcbc58$var$search_base_url + "suggestions",
12691
+ method_: "GET",
12692
+ request_: request
12693
+ });
11803
12694
  if (!Array.isArray(decoded_json === null || decoded_json === void 0 ? void 0 : decoded_json.suggestions)) break attempt_to_return_api_response;
11804
12695
  try {
11805
12696
  return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_url_creator_for_suggest, $e270e9f953fcbc58$var$_run_url_creator_for_suggest2).call(this, input_req.merchant, input_req.market, input_req.locale, decoded_json);
@@ -11816,6 +12707,7 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
11816
12707
  async query(input_req) {
11817
12708
  return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
11818
12709
  endpoint_: $e270e9f953fcbc58$var$search_base_url + "results",
12710
+ kind_: "search",
11819
12711
  input_req_: input_req,
11820
12712
  fallback_response_: () => ({
11821
12713
  "n_hits": 0,
@@ -11836,6 +12728,9 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
11836
12728
  return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
11837
12729
  endpoint_: $e270e9f953fcbc58$var$v3_base_url + "listings/" + (id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_),
11838
12730
  input_req_: input_req,
12731
+ kind_: "listing",
12732
+ id_to_query_for_: id_to_query_for_,
12733
+ id_type_: id_type_,
11839
12734
  fallback_response_: () => ({
11840
12735
  listing_id: "",
11841
12736
  listing_type: "category",
@@ -11863,6 +12758,9 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
11863
12758
  endpoint_: $e270e9f953fcbc58$var$v3_base_url + "listings/" + (id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
11864
12759
  input_req_: input_req_,
11865
12760
  currentListingForTransformer_: currentListingForTransformer_,
12761
+ kind_: "listing_products",
12762
+ id_to_query_for_: id_to_query_for_,
12763
+ id_type_: id_type_,
11866
12764
  fallback_response_: () => ({
11867
12765
  "n_hits": 0,
11868
12766
  "displays": [],
@@ -11876,6 +12774,7 @@ class $e270e9f953fcbc58$export$e015ed2f2950f2e3 {
11876
12774
  async get_recommended(input_req) {
11877
12775
  return await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_cached_request, $e270e9f953fcbc58$var$_cached_request2).call(this, {
11878
12776
  endpoint_: $e270e9f953fcbc58$var$search_base_url + "related",
12777
+ kind_: "related",
11879
12778
  input_req_: input_req,
11880
12779
  fallback_response_: () => ({
11881
12780
  displays: []
@@ -11990,7 +12889,10 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
11990
12889
  input_req_: input_req_,
11991
12890
  fallback_response_: fallback_response_,
11992
12891
  method_ = "POST",
11993
- currentListingForTransformer_: currentListingForTransformer_
12892
+ currentListingForTransformer_: currentListingForTransformer_,
12893
+ kind_: kind_,
12894
+ id_to_query_for_: id_to_query_for_,
12895
+ id_type_: id_type_
11994
12896
  } = _ref4;
11995
12897
  const cache_obj = $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint, $e270e9f953fcbc58$var$_get_cache_obj_for_endpoint2).call(this, endpoint_);
11996
12898
  const with_ids = $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $e270e9f953fcbc58$var$_add_ids_to_request).call(this, input_req_);
@@ -12007,19 +12909,19 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
12007
12909
  let resolve_in_progress;
12008
12910
  cache_obj.in_progress_[body] = new Promise(r => resolve_in_progress = r);
12009
12911
  try {
12010
- const is_post = method_ === "POST";
12011
- const url_to_request = is_post ? endpoint_ : $3hooq$depictaiutilishared.make_url_with_query_params(endpoint_, sorted_request);
12012
- const api_response = await $3hooq$depictaiutilishared.fetch_retry($3hooq$depictaiutilishared.add_version_query_params(url_to_request), {
12013
- method: method_,
12014
- ...(is_post ? {
12015
- body: body
12016
- } : {})
12017
- });
12018
12912
  return_successfully: {
12019
- if (!api_response || api_response.status !== 200) break return_successfully;
12020
12913
  let result;
12021
12914
  try {
12022
- const unmodified_result = await api_response.json();
12915
+ const unmodified_result = await this.request_raw_({
12916
+ kind_: kind_,
12917
+ endpoint_: endpoint_,
12918
+ method_: method_,
12919
+ request_: sorted_request,
12920
+ body_: body,
12921
+ id_to_query_for_: id_to_query_for_,
12922
+ id_type_: id_type_
12923
+ });
12924
+ if (unmodified_result === undefined) break return_successfully;
12023
12925
  result = await $e270e9f953fcbc58$var$_classPrivateMethodGet(this, $e270e9f953fcbc58$var$_run_display_transformers_for_rest, $e270e9f953fcbc58$var$_run_display_transformers_for_rest2).call(this, input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result, currentListingForTransformer_);
12024
12926
  } catch (e) {
12025
12927
  $3hooq$depictaiutilishared.dwarn("displayTransformer or json decoding failed", e);
@@ -12047,6 +12949,283 @@ async function $e270e9f953fcbc58$var$_cached_request2(_ref4) {
12047
12949
  delete cache_obj.in_progress_[body];
12048
12950
  }
12049
12951
  }
12952
+ function $5f20a6104f835562$var$_classPrivateMethodInitSpec(obj, privateSet) {
12953
+ $5f20a6104f835562$var$_checkPrivateRedeclaration(obj, privateSet);
12954
+ privateSet.add(obj);
12955
+ }
12956
+ function $5f20a6104f835562$var$_classPrivateFieldInitSpec(obj, privateMap, value) {
12957
+ $5f20a6104f835562$var$_checkPrivateRedeclaration(obj, privateMap);
12958
+ privateMap.set(obj, value);
12959
+ }
12960
+ function $5f20a6104f835562$var$_checkPrivateRedeclaration(obj, privateCollection) {
12961
+ if (privateCollection.has(obj)) throw new TypeError("Cannot initialize the same private elements twice on an object");
12962
+ }
12963
+ function $5f20a6104f835562$var$_classPrivateMethodGet(receiver, privateSet, fn) {
12964
+ if (!privateSet.has(receiver)) throw new TypeError("attempted to get private field on non-instance");
12965
+ return fn;
12966
+ }
12967
+ /** V4 browse's largest page; a bigger v3 page is V4's pages chained by their cursors, as the facade does. */
12968
+ const $5f20a6104f835562$var$BROWSE_MAX_LIMIT = 100;
12969
+ /** V4 browse's page size without a limit, and v3's. */
12970
+ const $5f20a6104f835562$var$DEFAULT_LIMIT = 24;
12971
+ /** A query with no letter or digit browses the catalogue instead of returning an empty grid, as on v3. */
12972
+ const $5f20a6104f835562$var$HAS_LETTER_OR_DIGIT = /[0-9A-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0560-\u0588\u05D0-\u05EA\u05EF-\u05F2\u0620-\u064A\u0660-\u0669\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07C0-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u0870-\u0887\u0889-\u088E\u08A0-\u08C9\u0904-\u0939\u093D\u0950\u0958-\u0961\u0966-\u096F\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09E6-\u09F1\u09F4-\u09F9\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AE6-\u0AEF\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F\u0B71-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0BE6-\u0BF2\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C5D\u0C60\u0C61\u0C66-\u0C6F\u0C78-\u0C7E\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDD\u0CDE\u0CE0\u0CE1\u0CE6-\u0CEF\u0CF1\u0CF2\u0D04-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D58-\u0D61\u0D66-\u0D78\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DE6-\u0DEF\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F20-\u0F33\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F-\u1049\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u1090-\u1099\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u1711\u171F-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1820-\u1878\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A16\u1A20-\u1A54\u1A80-\u1A89\u1A90-\u1A99\u1AA7\u1B05-\u1B33\u1B45-\u1B4C\u1B50-\u1B59\u1B83-\u1BA0\u1BAE-\u1BE5\u1C00-\u1C23\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CE9-\u1CEC\u1CEE-\u1CF3\u1CF5\u1CF6\u1CFA\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7CA\uA7D0\uA7D1\uA7D3\uA7D5-\uA7D9\uA7F2-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA830-\uA835\uA840-\uA873\uA882-\uA8B3\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8FB\uA8FD\uA8FE\uA900-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF-\uA9D9\uA9E0-\uA9E4\uA9E6-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA50-\uAA59\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABE2\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC\u{10000}-\u{1000B}\u{1000D}-\u{10026}\u{10028}-\u{1003A}\u{1003C}\u{1003D}\u{1003F}-\u{1004D}\u{10050}-\u{1005D}\u{10080}-\u{100FA}\u{10107}-\u{10133}\u{10140}-\u{10178}\u{1018A}\u{1018B}\u{10280}-\u{1029C}\u{102A0}-\u{102D0}\u{102E1}-\u{102FB}\u{10300}-\u{10323}\u{1032D}-\u{1034A}\u{10350}-\u{10375}\u{10380}-\u{1039D}\u{103A0}-\u{103C3}\u{103C8}-\u{103CF}\u{103D1}-\u{103D5}\u{10400}-\u{1049D}\u{104A0}-\u{104A9}\u{104B0}-\u{104D3}\u{104D8}-\u{104FB}\u{10500}-\u{10527}\u{10530}-\u{10563}\u{10570}-\u{1057A}\u{1057C}-\u{1058A}\u{1058C}-\u{10592}\u{10594}\u{10595}\u{10597}-\u{105A1}\u{105A3}-\u{105B1}\u{105B3}-\u{105B9}\u{105BB}\u{105BC}\u{10600}-\u{10736}\u{10740}-\u{10755}\u{10760}-\u{10767}\u{10780}-\u{10785}\u{10787}-\u{107B0}\u{107B2}-\u{107BA}\u{10800}-\u{10805}\u{10808}\u{1080A}-\u{10835}\u{10837}\u{10838}\u{1083C}\u{1083F}-\u{10855}\u{10858}-\u{10876}\u{10879}-\u{1089E}\u{108A7}-\u{108AF}\u{108E0}-\u{108F2}\u{108F4}\u{108F5}\u{108FB}-\u{1091B}\u{10920}-\u{10939}\u{10980}-\u{109B7}\u{109BC}-\u{109CF}\u{109D2}-\u{10A00}\u{10A10}-\u{10A13}\u{10A15}-\u{10A17}\u{10A19}-\u{10A35}\u{10A40}-\u{10A48}\u{10A60}-\u{10A7E}\u{10A80}-\u{10A9F}\u{10AC0}-\u{10AC7}\u{10AC9}-\u{10AE4}\u{10AEB}-\u{10AEF}\u{10B00}-\u{10B35}\u{10B40}-\u{10B55}\u{10B58}-\u{10B72}\u{10B78}-\u{10B91}\u{10BA9}-\u{10BAF}\u{10C00}-\u{10C48}\u{10C80}-\u{10CB2}\u{10CC0}-\u{10CF2}\u{10CFA}-\u{10D23}\u{10D30}-\u{10D39}\u{10E60}-\u{10E7E}\u{10E80}-\u{10EA9}\u{10EB0}\u{10EB1}\u{10F00}-\u{10F27}\u{10F30}-\u{10F45}\u{10F51}-\u{10F54}\u{10F70}-\u{10F81}\u{10FB0}-\u{10FCB}\u{10FE0}-\u{10FF6}\u{11003}-\u{11037}\u{11052}-\u{1106F}\u{11071}\u{11072}\u{11075}\u{11083}-\u{110AF}\u{110D0}-\u{110E8}\u{110F0}-\u{110F9}\u{11103}-\u{11126}\u{11136}-\u{1113F}\u{11144}\u{11147}\u{11150}-\u{11172}\u{11176}\u{11183}-\u{111B2}\u{111C1}-\u{111C4}\u{111D0}-\u{111DA}\u{111DC}\u{111E1}-\u{111F4}\u{11200}-\u{11211}\u{11213}-\u{1122B}\u{1123F}\u{11240}\u{11280}-\u{11286}\u{11288}\u{1128A}-\u{1128D}\u{1128F}-\u{1129D}\u{1129F}-\u{112A8}\u{112B0}-\u{112DE}\u{112F0}-\u{112F9}\u{11305}-\u{1130C}\u{1130F}\u{11310}\u{11313}-\u{11328}\u{1132A}-\u{11330}\u{11332}\u{11333}\u{11335}-\u{11339}\u{1133D}\u{11350}\u{1135D}-\u{11361}\u{11400}-\u{11434}\u{11447}-\u{1144A}\u{11450}-\u{11459}\u{1145F}-\u{11461}\u{11480}-\u{114AF}\u{114C4}\u{114C5}\u{114C7}\u{114D0}-\u{114D9}\u{11580}-\u{115AE}\u{115D8}-\u{115DB}\u{11600}-\u{1162F}\u{11644}\u{11650}-\u{11659}\u{11680}-\u{116AA}\u{116B8}\u{116C0}-\u{116C9}\u{11700}-\u{1171A}\u{11730}-\u{1173B}\u{11740}-\u{11746}\u{11800}-\u{1182B}\u{118A0}-\u{118F2}\u{118FF}-\u{11906}\u{11909}\u{1190C}-\u{11913}\u{11915}\u{11916}\u{11918}-\u{1192F}\u{1193F}\u{11941}\u{11950}-\u{11959}\u{119A0}-\u{119A7}\u{119AA}-\u{119D0}\u{119E1}\u{119E3}\u{11A00}\u{11A0B}-\u{11A32}\u{11A3A}\u{11A50}\u{11A5C}-\u{11A89}\u{11A9D}\u{11AB0}-\u{11AF8}\u{11C00}-\u{11C08}\u{11C0A}-\u{11C2E}\u{11C40}\u{11C50}-\u{11C6C}\u{11C72}-\u{11C8F}\u{11D00}-\u{11D06}\u{11D08}\u{11D09}\u{11D0B}-\u{11D30}\u{11D46}\u{11D50}-\u{11D59}\u{11D60}-\u{11D65}\u{11D67}\u{11D68}\u{11D6A}-\u{11D89}\u{11D98}\u{11DA0}-\u{11DA9}\u{11EE0}-\u{11EF2}\u{11F02}\u{11F04}-\u{11F10}\u{11F12}-\u{11F33}\u{11F50}-\u{11F59}\u{11FB0}\u{11FC0}-\u{11FD4}\u{12000}-\u{12399}\u{12400}-\u{1246E}\u{12480}-\u{12543}\u{12F90}-\u{12FF0}\u{13000}-\u{1342F}\u{13441}-\u{13446}\u{14400}-\u{14646}\u{16800}-\u{16A38}\u{16A40}-\u{16A5E}\u{16A60}-\u{16A69}\u{16A70}-\u{16ABE}\u{16AC0}-\u{16AC9}\u{16AD0}-\u{16AED}\u{16B00}-\u{16B2F}\u{16B40}-\u{16B43}\u{16B50}-\u{16B59}\u{16B5B}-\u{16B61}\u{16B63}-\u{16B77}\u{16B7D}-\u{16B8F}\u{16E40}-\u{16E96}\u{16F00}-\u{16F4A}\u{16F50}\u{16F93}-\u{16F9F}\u{16FE0}\u{16FE1}\u{16FE3}\u{17000}-\u{187F7}\u{18800}-\u{18CD5}\u{18D00}-\u{18D08}\u{1AFF0}-\u{1AFF3}\u{1AFF5}-\u{1AFFB}\u{1AFFD}\u{1AFFE}\u{1B000}-\u{1B122}\u{1B132}\u{1B150}-\u{1B152}\u{1B155}\u{1B164}-\u{1B167}\u{1B170}-\u{1B2FB}\u{1BC00}-\u{1BC6A}\u{1BC70}-\u{1BC7C}\u{1BC80}-\u{1BC88}\u{1BC90}-\u{1BC99}\u{1D2C0}-\u{1D2D3}\u{1D2E0}-\u{1D2F3}\u{1D360}-\u{1D378}\u{1D400}-\u{1D454}\u{1D456}-\u{1D49C}\u{1D49E}\u{1D49F}\u{1D4A2}\u{1D4A5}\u{1D4A6}\u{1D4A9}-\u{1D4AC}\u{1D4AE}-\u{1D4B9}\u{1D4BB}\u{1D4BD}-\u{1D4C3}\u{1D4C5}-\u{1D505}\u{1D507}-\u{1D50A}\u{1D50D}-\u{1D514}\u{1D516}-\u{1D51C}\u{1D51E}-\u{1D539}\u{1D53B}-\u{1D53E}\u{1D540}-\u{1D544}\u{1D546}\u{1D54A}-\u{1D550}\u{1D552}-\u{1D6A5}\u{1D6A8}-\u{1D6C0}\u{1D6C2}-\u{1D6DA}\u{1D6DC}-\u{1D6FA}\u{1D6FC}-\u{1D714}\u{1D716}-\u{1D734}\u{1D736}-\u{1D74E}\u{1D750}-\u{1D76E}\u{1D770}-\u{1D788}\u{1D78A}-\u{1D7A8}\u{1D7AA}-\u{1D7C2}\u{1D7C4}-\u{1D7CB}\u{1D7CE}-\u{1D7FF}\u{1DF00}-\u{1DF1E}\u{1DF25}-\u{1DF2A}\u{1E030}-\u{1E06D}\u{1E100}-\u{1E12C}\u{1E137}-\u{1E13D}\u{1E140}-\u{1E149}\u{1E14E}\u{1E290}-\u{1E2AD}\u{1E2C0}-\u{1E2EB}\u{1E2F0}-\u{1E2F9}\u{1E4D0}-\u{1E4EB}\u{1E4F0}-\u{1E4F9}\u{1E7E0}-\u{1E7E6}\u{1E7E8}-\u{1E7EB}\u{1E7ED}\u{1E7EE}\u{1E7F0}-\u{1E7FE}\u{1E800}-\u{1E8C4}\u{1E8C7}-\u{1E8CF}\u{1E900}-\u{1E943}\u{1E94B}\u{1E950}-\u{1E959}\u{1EC71}-\u{1ECAB}\u{1ECAD}-\u{1ECAF}\u{1ECB1}-\u{1ECB4}\u{1ED01}-\u{1ED2D}\u{1ED2F}-\u{1ED3D}\u{1EE00}-\u{1EE03}\u{1EE05}-\u{1EE1F}\u{1EE21}\u{1EE22}\u{1EE24}\u{1EE27}\u{1EE29}-\u{1EE32}\u{1EE34}-\u{1EE37}\u{1EE39}\u{1EE3B}\u{1EE42}\u{1EE47}\u{1EE49}\u{1EE4B}\u{1EE4D}-\u{1EE4F}\u{1EE51}\u{1EE52}\u{1EE54}\u{1EE57}\u{1EE59}\u{1EE5B}\u{1EE5D}\u{1EE5F}\u{1EE61}\u{1EE62}\u{1EE64}\u{1EE67}-\u{1EE6A}\u{1EE6C}-\u{1EE72}\u{1EE74}-\u{1EE77}\u{1EE79}-\u{1EE7C}\u{1EE7E}\u{1EE80}-\u{1EE89}\u{1EE8B}-\u{1EE9B}\u{1EEA1}-\u{1EEA3}\u{1EEA5}-\u{1EEA9}\u{1EEAB}-\u{1EEBB}\u{1F100}-\u{1F10C}\u{1FBF0}-\u{1FBF9}\u{20000}-\u{2A6DF}\u{2A700}-\u{2B739}\u{2B740}-\u{2B81D}\u{2B820}-\u{2CEA1}\u{2CEB0}-\u{2EBE0}\u{2F800}-\u{2FA1D}\u{30000}-\u{3134A}\u{31350}-\u{323AF}]/u;
12973
+ /** Which API an SDK reads: `v3` (the default) or the native V4 API (`https://api.depict.ai/v4/{merchant}/…`). */
12974
+ var $5f20a6104f835562$var$_facet_indices = /*#__PURE__*/new WeakMap();
12975
+ var $5f20a6104f835562$var$_learned = /*#__PURE__*/new WeakMap();
12976
+ var $5f20a6104f835562$var$_cursor_offsets = /*#__PURE__*/new WeakMap();
12977
+ var $5f20a6104f835562$var$_ancestor_lookups = /*#__PURE__*/new WeakMap();
12978
+ var $5f20a6104f835562$var$_rejected = /*#__PURE__*/new WeakMap();
12979
+ var $5f20a6104f835562$var$_merchant_url = /*#__PURE__*/new WeakSet();
12980
+ var $5f20a6104f835562$var$_get_json = /*#__PURE__*/new WeakSet();
12981
+ var $5f20a6104f835562$var$_get_answer = /*#__PURE__*/new WeakSet();
12982
+ var $5f20a6104f835562$var$_facet_index = /*#__PURE__*/new WeakSet();
12983
+ var $5f20a6104f835562$var$_browse_page = /*#__PURE__*/new WeakSet();
12984
+ var $5f20a6104f835562$var$_browse_answer = /*#__PURE__*/new WeakSet();
12985
+ var $5f20a6104f835562$var$_rejected_clauses = /*#__PURE__*/new WeakSet();
12986
+ var $5f20a6104f835562$var$_browse = /*#__PURE__*/new WeakSet();
12987
+ var $5f20a6104f835562$var$_listing = /*#__PURE__*/new WeakSet();
12988
+ var $5f20a6104f835562$var$_suggest = /*#__PURE__*/new WeakSet();
12989
+ var $5f20a6104f835562$var$_ancestors = /*#__PURE__*/new WeakSet();
12990
+ class $5f20a6104f835562$export$721afe49a594bed extends (0, $e270e9f953fcbc58$export$e015ed2f2950f2e3) {
12991
+ /** Facets served so far, per merchant, market and locale, to resolve v3 filter fields (group titles) to V4 fields. */ /** Browses whose facets were read only to resolve filter fields, so each is read at most once. */ /** How many products came before each cursor V4 handed out, for the lower-bound count when `total` is absent. */ /** Each listing's ancestors from the listing tree, per merchant, market and locale, read once a page load. */ /** Filter clauses V4 refused (`unknown_filter_field`, `invalid_filter`), per merchant, market and locale. */constructor(options) {
12992
+ super(options);
12993
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_ancestors);
12994
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_suggest);
12995
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_listing);
12996
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_browse);
12997
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_rejected_clauses);
12998
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_browse_answer);
12999
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_browse_page);
13000
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_facet_index);
13001
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_get_answer);
13002
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_get_json);
13003
+ $5f20a6104f835562$var$_classPrivateMethodInitSpec(this, $5f20a6104f835562$var$_merchant_url);
13004
+ $5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_facet_indices, {
13005
+ writable: true,
13006
+ value: new Map()
13007
+ });
13008
+ $5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_learned, {
13009
+ writable: true,
13010
+ value: new Set()
13011
+ });
13012
+ $5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_cursor_offsets, {
13013
+ writable: true,
13014
+ value: new Map()
13015
+ });
13016
+ $5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_ancestor_lookups, {
13017
+ writable: true,
13018
+ value: new Map()
13019
+ });
13020
+ $5f20a6104f835562$var$_classPrivateFieldInitSpec(this, $5f20a6104f835562$var$_rejected, {
13021
+ writable: true,
13022
+ value: new Map()
13023
+ });
13024
+ $3hooq$depictaiutilishared.set_event_api("v4");
13025
+ }
13026
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13027
+ async request_raw_(call) {
13028
+ switch (call.kind_) {
13029
+ case "search":
13030
+ return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse, $5f20a6104f835562$var$_browse2).call(this, "search", call.request_);
13031
+ case "listing_products":
13032
+ return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse, $5f20a6104f835562$var$_browse2).call(this, "listing", call.request_, {
13033
+ [call.id_type_ === $c3739e86187f2054$export$5aae649db1b959fc ? "external_id" : "id"]: call.id_to_query_for_
13034
+ });
13035
+ case "listing":
13036
+ return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_listing, $5f20a6104f835562$var$_listing2).call(this, call);
13037
+ case "suggest":
13038
+ return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_suggest, $5f20a6104f835562$var$_suggest2).call(this, call.request_);
13039
+ case "related":
13040
+ {
13041
+ const {
13042
+ merchant: merchant,
13043
+ market: market,
13044
+ locale: locale,
13045
+ query: query
13046
+ } = call.request_;
13047
+ const displays = await $2573fc0c2eb12a79$export$bd5f8a7d3e47a43d({
13048
+ merchant: merchant,
13049
+ market: market,
13050
+ locale: locale,
13051
+ query: query
13052
+ });
13053
+ return displays && {
13054
+ displays: displays
13055
+ };
13056
+ }
13057
+ }
13058
+ }
13059
+ }
13060
+ /** The v3 search or listing-products request DepictAPI hands its transport. */
13061
+ function $5f20a6104f835562$var$_merchant_url2(merchant, path) {
13062
+ return $8ad8c4b4b26ba277$export$b6dad15503f66988(merchant, path);
13063
+ }
13064
+ async function $5f20a6104f835562$var$_get_json2(url) {
13065
+ return (await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_answer, $5f20a6104f835562$var$_get_answer2).call(this, url)).body_;
13066
+ }
13067
+ async function $5f20a6104f835562$var$_get_answer2(url) {
13068
+ return await $8ad8c4b4b26ba277$export$f035610fd74c541a(url);
13069
+ }
13070
+ function $5f20a6104f835562$var$_facet_index2(merchant, market, locale) {
13071
+ const key = JSON.stringify([merchant, market, locale]);
13072
+ let index = $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_facet_indices).get(key);
13073
+ if (!index) $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_facet_indices).set(key, index = new (0, $744a9d695dd21ed2$export$8d488bcc71d07ffb)());
13074
+ return index;
13075
+ }
13076
+ async function $5f20a6104f835562$var$_browse_page2(merchant, request) {
13077
+ return (await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_answer, $5f20a6104f835562$var$_browse_answer2).call(this, merchant, request)).body_;
13078
+ }
13079
+ async function $5f20a6104f835562$var$_browse_answer2(merchant, request) {
13080
+ return await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_answer, $5f20a6104f835562$var$_get_answer2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, "/browse") + "?" + $14bc537adeeadca4$export$7659319cdb555579(request));
13081
+ }
13082
+ function $5f20a6104f835562$var$_rejected_clauses2(merchant, market, locale) {
13083
+ const key = JSON.stringify([merchant, market, locale]);
13084
+ let rejected = $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_rejected).get(key);
13085
+ if (!rejected) $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_rejected).set(key, rejected = new Set());
13086
+ return rejected;
13087
+ }
13088
+ async function $5f20a6104f835562$var$_browse2(door, v3_request, listing) {
13089
+ var _v3_request$filters, _v3_request$limit;
13090
+ const {
13091
+ merchant: merchant,
13092
+ market: market
13093
+ } = v3_request;
13094
+ const locale = $14bc537adeeadca4$export$eb90c08da400512d(v3_request.locale);
13095
+ const query = door === "search" && v3_request.query && $5f20a6104f835562$var$HAS_LETTER_OR_DIGIT.test(v3_request.query) ? v3_request.query : undefined;
13096
+ const base = {
13097
+ market: market,
13098
+ ...(locale ? {
13099
+ locale: locale
13100
+ } : {}),
13101
+ ...(query ? {
13102
+ query: query
13103
+ } : {}),
13104
+ ...(listing ? {
13105
+ listing: listing
13106
+ } : {})
13107
+ };
13108
+ const index = $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_facet_index, $5f20a6104f835562$var$_facet_index2).call(this, merchant, market, locale);
13109
+ const filters = (_v3_request$filters = v3_request.filters) !== null && _v3_request$filters !== void 0 ? _v3_request$filters : [];
13110
+ // depict-ui sends a filter's lowercased group title as its field. A page opened from a link with filters in it
13111
+ // comes before any facets, so read this browse's facets once to learn which field each title names.
13112
+ const learn_key = JSON.stringify([merchant, base]);
13113
+ if (filters.some(filter => filter.data != null && !$744a9d695dd21ed2$export$3b6ba2422a5e0aa0(filter.field, index)) && !$parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_learned).has(learn_key)) {
13114
+ var _await$_classPrivateM;
13115
+ $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_learned).add(learn_key);
13116
+ index.learn_((_await$_classPrivateM = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_page, $5f20a6104f835562$var$_browse_page2).call(this, merchant, {
13117
+ ...base,
13118
+ include: ["facets"],
13119
+ limit: 1
13120
+ })) === null || _await$_classPrivateM === void 0 ? void 0 : _await$_classPrivateM.facets);
13121
+ }
13122
+ // A filter V4 can't take must not cost the shopper the page: a link can outlive its filter (one removed from the
13123
+ // store, a hand-written value). One the adapter can't write is left out here; one V4 rejects is left out and the
13124
+ // page asked again, and remembered for this page load so later pages don't ask with it.
13125
+ const rejected = $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_rejected_clauses, $5f20a6104f835562$var$_rejected_clauses2).call(this, merchant, market, locale);
13126
+ let clauses = [];
13127
+ for (const filter of filters) try {
13128
+ const clause = $744a9d695dd21ed2$export$c17bb5d2ead3e8f3(filter, index);
13129
+ if (clause) clauses.push(clause);
13130
+ } catch (e) {
13131
+ if (!(e instanceof (0, $744a9d695dd21ed2$export$f5ea4d073ddb4bdb))) throw e;
13132
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI] leaving out a filter V4 can't take:", e.message, filter);
13133
+ }
13134
+ clauses = clauses.filter(clause => !rejected.has(clause.clause_));
13135
+ const sort = $744a9d695dd21ed2$export$78eb8e636d89ff30(v3_request.sort);
13136
+ const include = door === "search" ? ["facets", "sorts", "content", "attributes"] : ["facets", "sorts", "attributes"];
13137
+ const want = (_v3_request$limit = v3_request.limit) !== null && _v3_request$limit !== void 0 ? _v3_request$limit : $5f20a6104f835562$var$DEFAULT_LIMIT;
13138
+ const offset = v3_request.cursor && $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_cursor_offsets).get(v3_request.cursor) || 0;
13139
+ const request_with = sent => ({
13140
+ ...base,
13141
+ ...(sent.length ? {
13142
+ filter_by: sent.map(clause => clause.clause_).join(" && ")
13143
+ } : {}),
13144
+ ...(sort ? {
13145
+ sort: sort
13146
+ } : {}),
13147
+ ...(v3_request.cursor ? {
13148
+ cursor: v3_request.cursor
13149
+ } : {}),
13150
+ include: include,
13151
+ ...(want !== $5f20a6104f835562$var$DEFAULT_LIMIT ? {
13152
+ limit: Math.min(want, $5f20a6104f835562$var$BROWSE_MAX_LIMIT)
13153
+ } : {})
13154
+ });
13155
+ let request = request_with(clauses);
13156
+ let answer = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_answer, $5f20a6104f835562$var$_browse_answer2).call(this, merchant, request);
13157
+ // Each retry leaves out at least one more clause, so this ends.
13158
+ while (!answer.body_) {
13159
+ var _answer$error_;
13160
+ const refused = $744a9d695dd21ed2$export$c38de645260a41ed(answer.error_, clauses);
13161
+ if (!refused.length) return undefined;
13162
+ $3hooq$depictaiutilishared.dwarn("[NativeDepictAPI] leaving out filters V4 refused:", refused.map(clause => clause.clause_), (_answer$error_ = answer.error_) === null || _answer$error_ === void 0 ? void 0 : _answer$error_.message);
13163
+ for (const clause of refused) rejected.add(clause.clause_);
13164
+ clauses = clauses.filter(clause => !refused.includes(clause));
13165
+ request = request_with(clauses);
13166
+ answer = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_answer, $5f20a6104f835562$var$_browse_answer2).call(this, merchant, request);
13167
+ }
13168
+ let response = answer.body_;
13169
+ // A page over V4's largest is its pages chained by their cursors; later pages ask for products alone.
13170
+ while (want > $5f20a6104f835562$var$BROWSE_MAX_LIMIT && response.products.length < want && response.cursor !== undefined) {
13171
+ const page = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_browse_page, $5f20a6104f835562$var$_browse_page2).call(this, merchant, {
13172
+ ...request,
13173
+ cursor: response.cursor,
13174
+ limit: Math.min(want - response.products.length, $5f20a6104f835562$var$BROWSE_MAX_LIMIT),
13175
+ include: ["attributes"]
13176
+ });
13177
+ if (!page) return undefined;
13178
+ if (!page.products.length) break;
13179
+ response = {
13180
+ ...response,
13181
+ products: [...response.products, ...page.products],
13182
+ ...(page.cursor !== undefined ? {
13183
+ cursor: page.cursor
13184
+ } : {
13185
+ cursor: undefined
13186
+ })
13187
+ };
13188
+ }
13189
+ if (response.cursor === undefined) delete response.cursor;
13190
+ index.learn_(response.facets);
13191
+ if (response.cursor !== undefined) $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_cursor_offsets).set(response.cursor, offset + response.products.length);
13192
+ return $14bc537adeeadca4$export$efb7dd882d411dd4(response, door, offset);
13193
+ }
13194
+ async function $5f20a6104f835562$var$_listing2(call) {
13195
+ const {
13196
+ merchant: merchant,
13197
+ market: market
13198
+ } = call.request_;
13199
+ const locale = $14bc537adeeadca4$export$eb90c08da400512d(call.request_.locale);
13200
+ const by_external_id = call.id_type_ === $c3739e86187f2054$export$5aae649db1b959fc;
13201
+ const path = by_external_id ? "/listings" : "/listings/" + encodeURIComponent(call.id_to_query_for_);
13202
+ const response = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_json, $5f20a6104f835562$var$_get_json2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, path) + "?" + $14bc537adeeadca4$export$fec3e4b5adfcea2c([["market", market], ["locale", locale], ["external_id", by_external_id ? call.id_to_query_for_ : undefined]]));
13203
+ return response && $14bc537adeeadca4$export$996f2b1e66d9b5af(response.listing);
13204
+ }
13205
+ async function $5f20a6104f835562$var$_suggest2(v3_request) {
13206
+ var _v3_request$query;
13207
+ const {
13208
+ merchant: merchant,
13209
+ market: market
13210
+ } = v3_request;
13211
+ const locale = $14bc537adeeadca4$export$eb90c08da400512d(v3_request.locale);
13212
+ const response = await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_json, $5f20a6104f835562$var$_get_json2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, "/suggest") + "?" + $14bc537adeeadca4$export$fec3e4b5adfcea2c([["market", market], ["locale", locale], ["query", (_v3_request$query = v3_request.query) !== null && _v3_request$query !== void 0 ? _v3_request$query : ""]]));
13213
+ if (!response) return undefined;
13214
+ const needs_ancestors = response.suggestions.some(suggestion => suggestion.type === "listing" && suggestion.path.length > 0);
13215
+ return $14bc537adeeadca4$export$2860125b419015f8(response, needs_ancestors ? await $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_ancestors, $5f20a6104f835562$var$_ancestors2).call(this, merchant, market, locale) : undefined);
13216
+ }
13217
+ function $5f20a6104f835562$var$_ancestors2(merchant, market, locale) {
13218
+ const key = JSON.stringify([merchant, market, locale]);
13219
+ let lookup = $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_ancestor_lookups).get(key);
13220
+ if (!lookup) {
13221
+ lookup = $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_get_json, $5f20a6104f835562$var$_get_json2).call(this, $5f20a6104f835562$var$_classPrivateMethodGet(this, $5f20a6104f835562$var$_merchant_url, $5f20a6104f835562$var$_merchant_url2).call(this, merchant, "/listings") + "?" + $14bc537adeeadca4$export$fec3e4b5adfcea2c([["market", market], ["locale", locale]])).then(tree => tree && $14bc537adeeadca4$export$76d96892da63b395(tree.listings));
13222
+ $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $5f20a6104f835562$var$_ancestor_lookups).set(key, lookup);
13223
+ }
13224
+ return lookup;
13225
+ }
13226
+ function $5f20a6104f835562$export$6d972e6af9de09f0(version, options) {
13227
+ return version === "v4" ? new $5f20a6104f835562$export$721afe49a594bed(options) : new (0, $e270e9f953fcbc58$export$e015ed2f2950f2e3)(options);
13228
+ }
12050
13229
  function $5dd9d0d3ea82e2dd$export$477caf01aecaeb2a(options) {
12051
13230
  var _globalThis$location$, _globalThis$location;
12052
13231
  const router_ = options.router_;
@@ -12356,8 +13535,9 @@ class $9cbefc32b9dab36d$export$f34314aa9505732e {
12356
13535
  quicklinks_signal_: $3hooq$solidjs.createSignal(),
12357
13536
  i18n_: i18n_,
12358
13537
  reset_history_state_: reset_history_state_,
13538
+ depict_api_: typeof api === "object" && api ? api :
12359
13539
  // @ts-ignore
12360
- depict_api_: api !== null && api !== void 0 ? api : new (0, $e270e9f953fcbc58$export$e015ed2f2950f2e3)({
13540
+ $5f20a6104f835562$export$6d972e6af9de09f0(api, {
12361
13541
  display_transformers: display_transformers
12362
13542
  }),
12363
13543
  router_: $parcel$interopDefault($3hooq$babelruntimehelpersclassPrivateFieldGet)(this, $9cbefc32b9dab36d$var$_router),
@@ -13904,8 +15084,9 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
13904
15084
  const get_search_query_ = $3hooq$solidjs.createMemo(previous_value => {
13905
15085
  if (get_search_query_updating_blocked()) return previous_value;else return raw_search_query_accessor();
13906
15086
  });
15087
+ const depict_api_ = typeof api === "object" && api ? api :
13907
15088
  // @ts-ignore
13908
- const depict_api_ = api !== null && api !== void 0 ? api : new (0, $e270e9f953fcbc58$export$e015ed2f2950f2e3)({
15089
+ $5f20a6104f835562$export$6d972e6af9de09f0(api, {
13909
15090
  display_transformers: display_transformers
13910
15091
  });
13911
15092
  const previous_searches = $cfeb65948dbdcaab$export$84bba84a7b837187(get_search_query_);