@cartbot/vehicle-search-beta 3.0.5 → 3.0.7

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.
@@ -5,7 +5,7 @@ import vt from "js-cookie";
5
5
  import { Combobox as pt, ComboboxInput as ht, ComboboxButton as ut, ComboboxOptions as ft, ComboboxOption as mt } from "@headlessui/react";
6
6
  import gt from "fuzzysearch";
7
7
  import Fe from "pluralize";
8
- import re from "clsx";
8
+ import te from "clsx";
9
9
  import { MeiliSearch as bt } from "meilisearch";
10
10
  import wt from "lodash/debounce";
11
11
  import yt from "tinycolor2";
@@ -113,32 +113,32 @@ function Ne({ className: g = "" }) {
113
113
  }
114
114
  );
115
115
  }
116
- function K({
116
+ function Q({
117
117
  label: g,
118
118
  items: f,
119
- selected: c,
119
+ selected: v,
120
120
  refine: D,
121
121
  showPopular: I,
122
122
  bgDark: F,
123
123
  sortOptions: A = !0,
124
- showLabel: R = !1,
124
+ showLabel: U = !1,
125
125
  isMobile: k = !1,
126
- loading: U = !1,
126
+ loading: Y = !1,
127
127
  shouldBeActive: B = !1
128
128
  // True when parent fields are selected and this field tried to load
129
129
  }) {
130
- const [X, p] = M(""), [w, y] = M(c || null), O = (i) => {
131
- y(i), p(""), !(i && i.value === (c == null ? void 0 : c.value)) && D(i);
132
- }, J = (i) => {
130
+ const [W, p] = M(""), [w, y] = M(v || null), O = (i) => {
131
+ y(i), p(""), !(i && i.value === (v == null ? void 0 : v.value)) && D(i);
132
+ }, K = (i) => {
133
133
  i.preventDefault(), i.stopPropagation(), p(""), y(null), D("");
134
134
  };
135
135
  L(() => {
136
- p(""), y(c || null);
137
- }, [c, f]);
138
- let G = /* @__PURE__ */ new Set(), x = [];
136
+ p(""), y(v || null);
137
+ }, [v, f]);
138
+ let X = /* @__PURE__ */ new Set(), x = [];
139
139
  f && (f.forEach((i) => {
140
140
  String(i.value).split(/,(?![^(]*\))/).forEach((m) => {
141
- m = m.trim(), m && gt(X, m.toLowerCase()) && !G.has(m.toLowerCase()) && (G.add(m.toLowerCase()), x.push({
141
+ m = m.trim(), m && gt(W, m.toLowerCase()) && !X.has(m.toLowerCase()) && (X.add(m.toLowerCase()), x.push({
142
142
  ...i,
143
143
  value: m,
144
144
  refinement: i.value
@@ -151,9 +151,9 @@ function K({
151
151
  ), x.sort(
152
152
  (i, z) => i.value.localeCompare(z.value, "en", { numeric: !0 })
153
153
  ), x = C.concat(x));
154
- const v = !x || x.length === 0;
154
+ const h = !x || x.length === 0;
155
155
  return /* @__PURE__ */ $("div", { className: "vs:relative vs:flex vs:flex-col", children: [
156
- R && /* @__PURE__ */ n(
156
+ U && /* @__PURE__ */ n(
157
157
  "span",
158
158
  {
159
159
  className: `${F ? "vs:text-white" : "vs:text-black"} vs:mb-1 vs:block vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)] vs:font-medium vs:font-(family-name:--partbot-font-family)`,
@@ -187,11 +187,11 @@ function K({
187
187
  ]
188
188
  }
189
189
  ),
190
- U && /* @__PURE__ */ n("div", { className: "vs:absolute vs:inset-y-0 vs:right-[calc(var(--partbot-font-size)*1.95)] vs:items-center vs:pr-(--partbot-padding) vs:text-[rgb(var(--partbot-theme))]! vs:pointer-events-none vs:flex vs:justify-center", children: /* @__PURE__ */ n(Ne, { className: "vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin vs:text-[rgb(var(--partbot-theme))]!" }) }),
191
- !U && (w == null ? void 0 : w.value) && /* @__PURE__ */ n(
190
+ Y && /* @__PURE__ */ n("div", { className: "vs:absolute vs:inset-y-0 vs:right-[calc(var(--partbot-font-size)*1.95)] vs:items-center vs:pr-(--partbot-padding) vs:text-[rgb(var(--partbot-theme))]! vs:pointer-events-none vs:flex vs:justify-center", children: /* @__PURE__ */ n(Ne, { className: "vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin vs:text-[rgb(var(--partbot-theme))]!" }) }),
191
+ !Y && (w == null ? void 0 : w.value) && /* @__PURE__ */ n(
192
192
  "button",
193
193
  {
194
- onClick: J,
194
+ onClick: K,
195
195
  tabIndex: -1,
196
196
  className: "vs:absolute vs:inset-y-0 vs:right-[calc(var(--partbot-font-size)*1.95)] vs:items-center vs:pr-(--partbot-padding) vs:text-red-300 vs:hover:text-red-500 vs:bg-transparent vs:border-none vs:outline-none vs:p-(--partbot-padding) vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)] vs:font-medium vs:transition vs:pointer-events-auto vs:flex vs:justify-center",
197
197
  children: /* @__PURE__ */ n(
@@ -215,7 +215,7 @@ function K({
215
215
  value: w || null,
216
216
  onChange: O,
217
217
  virtual: { options: x },
218
- disabled: v,
218
+ disabled: h,
219
219
  immediate: !0,
220
220
  children: [
221
221
  /* @__PURE__ */ $("div", { className: "vs:flex vs:h-full", children: [
@@ -224,7 +224,7 @@ function K({
224
224
  {
225
225
  autoComplete: "off",
226
226
  spellCheck: "false",
227
- placeholder: v && B ? "N/A" : g,
227
+ placeholder: h && B ? "N/A" : g,
228
228
  className: "vs:w-full vs:cursor-default vs:rounded-(--partbot-button-border-radius) vs:border vs:border-stone-200 vs:bg-white vs:py-(--partbot-padding) vs:pl-[calc(var(--partbot-padding)*1.3)] vs:pr-10 vs:text-left vs:shadow-sm vs:focus:border-[rgb(var(--partbot-theme))] vs:focus:outline-none vs:focus:ring-1 vs:focus:ring-[rgb(var(--partbot-theme))] vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)] vs:font-(family-name:--partbot-font-family) vs:text-stone-900 vs:placeholder:text-stone-600 vs:disabled:placeholder:text-stone-400 vs:disabled:cursor-not-allowed",
229
229
  displayValue: (i) => (i == null ? void 0 : i.value) || "",
230
230
  onChange: (i) => p(i.target.value),
@@ -235,7 +235,7 @@ function K({
235
235
  (w == null ? void 0 : w.value) && /* @__PURE__ */ n(
236
236
  "button",
237
237
  {
238
- onClick: J,
238
+ onClick: K,
239
239
  tabIndex: -1,
240
240
  className: "vs:inset-y-0 vs:pr-2 vs:text-red-300 vs:hover:text-red-500 vs:bg-transparent vs:border-none vs:outline-none vs:p-2 vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)] vs:font-medium vs:transition vs:pointer-events-auto vs:flex vs:items-center vs:justify-center vs:cursor-pointer",
241
241
  children: /* @__PURE__ */ n(
@@ -252,7 +252,7 @@ function K({
252
252
  )
253
253
  }
254
254
  ),
255
- /* @__PURE__ */ n(ut, { className: "vs:inset-y-0 vs:flex vs:items-center vs:pr-[calc(var(--partbot-padding)*1.3)] vs:pointer-events-auto vs:bg-transparent vs:border-none vs:outline-none", children: U ? /* @__PURE__ */ n(Ne, { className: "vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:text-stone-400 vs:animate-spin" }) : /* @__PURE__ */ n(
255
+ /* @__PURE__ */ n(ut, { className: "vs:inset-y-0 vs:flex vs:items-center vs:pr-[calc(var(--partbot-padding)*1.3)] vs:pointer-events-auto vs:bg-transparent vs:border-none vs:outline-none", children: Y ? /* @__PURE__ */ n(Ne, { className: "vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:text-stone-400 vs:animate-spin" }) : /* @__PURE__ */ n(
256
256
  "svg",
257
257
  {
258
258
  className: "vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:text-stone-400",
@@ -280,7 +280,7 @@ function K({
280
280
  mt,
281
281
  {
282
282
  value: i,
283
- className: ({ focus: m }) => re(
283
+ className: ({ focus: m }) => te(
284
284
  "vs:group vs:relative vs:w-full vs:cursor-default vs:py-(--partbot-padding) vs:px-[calc(var(--partbot-padding)*1.3)] vs:text-left vs:border-none",
285
285
  m ? "vs:bg-[rgb(var(--partbot-theme))] vs:text-[rgb(var(--partbot-button-label-color))]" : "vs:bg-white vs:text-stone-900 vs:hover:bg-theme vs:hover:text-button-label",
286
286
  z && "vs:font-bold!"
@@ -289,17 +289,17 @@ function K({
289
289
  /* @__PURE__ */ n(
290
290
  "span",
291
291
  {
292
- className: re(
293
- i.value === (c == null ? void 0 : c.value) ? "vs:font-semibold" : "vs:font-normal",
292
+ className: te(
293
+ i.value === (v == null ? void 0 : v.value) ? "vs:font-semibold" : "vs:font-normal",
294
294
  "vs:block vs:font-(family-name:--partbot-font-family) vs:whitespace-pre-wrap vs:text-left vs:text-(length:--partbot-font-size) vs:leading-none"
295
295
  ),
296
296
  children: i.value
297
297
  }
298
298
  ),
299
- i.value === (c == null ? void 0 : c.value) && /* @__PURE__ */ n(
299
+ i.value === (v == null ? void 0 : v.value) && /* @__PURE__ */ n(
300
300
  "span",
301
301
  {
302
- className: re(
302
+ className: te(
303
303
  "vs:text-[rgb(var(--partbot-theme))]",
304
304
  "vs:flex vs:items-center group-vs:hover:text-white"
305
305
  ),
@@ -330,49 +330,49 @@ function K({
330
330
  }
331
331
  console.info("Vehicle Search powered by Partbot https://use.partbot.io");
332
332
  function ce(g = [], f = []) {
333
- const c = [];
333
+ const v = [];
334
334
  return g.forEach((D) => {
335
335
  const [I, ...F] = D.split(":"), A = F.join(":");
336
336
  if (A.includes(" > ")) {
337
- const R = A.split(" > "), k = R[R.length - 1].trim();
338
- if (I !== "make" && R.length >= 2) {
339
- const U = R[0].trim();
340
- c.push(`make = "${U}"`);
337
+ const U = A.split(" > "), k = U[U.length - 1].trim();
338
+ if (I !== "make" && U.length >= 2) {
339
+ const Y = U[0].trim();
340
+ v.push(`make = "${Y}"`);
341
341
  }
342
- c.push(`${I} = "${k}"`);
342
+ v.push(`${I} = "${k}"`);
343
343
  } else
344
- c.push(`${I} = "${A}"`);
344
+ v.push(`${I} = "${A}"`);
345
345
  }), f.forEach((D) => {
346
- c.push(D);
347
- }), c.length > 0 ? c.join(" AND ") : null;
346
+ v.push(D);
347
+ }), v.length > 0 ? v.join(" AND ") : null;
348
348
  }
349
349
  function Ct({
350
350
  apiKey: g,
351
351
  makes: f = "",
352
- models: c = "",
352
+ models: v = "",
353
353
  callbackUrl: D = "",
354
354
  layout: I = "row",
355
355
  fields: F,
356
356
  fieldPrefix: A = "",
357
- showBranding: R = !0,
357
+ showBranding: U = !0,
358
358
  showLabels: k = !1,
359
- mobileFullWidthButton: U = !0,
359
+ mobileFullWidthButton: Y = !0,
360
360
  mobileDrawer: B = !0,
361
- modifyQueryString: X = !0,
361
+ modifyQueryString: W = !0,
362
362
  onChange: p,
363
363
  buttonLabel: w = "Search",
364
364
  showButton: y = !0,
365
365
  onSubmit: O,
366
- store: J,
367
- useStoreVehicles: G = !0,
366
+ store: K,
367
+ useStoreVehicles: X = !0,
368
368
  fieldOrder: x = "MMY",
369
369
  // "MMY" (Make→Model→Year) or "YMM" (Year→Make→Model)
370
370
  enableFeatureFlags: C = !1,
371
371
  // Use api.cartbot.io instead of api.partbot.io
372
- yearOptional: v = !1
372
+ yearOptional: h = !1
373
373
  // Make year selection optional, only requiring make + model
374
374
  }) {
375
- const i = Z(null), z = Z(null), m = Z(null), ee = Z(null), Y = Z(null), ie = Z(null), ke = Z(null), S = Z(null), W = Z(!1), _ = x === "YMM", [ve, Ce] = M([]), [pe, _e] = M([]), [ne, se] = M([]), [Ue, he] = M([]), [Ye, ue] = M([]), [Te, fe] = M([]), [Ze, me] = M([]), [Oe, ge] = M([]), He = Z([]), [oe, ze] = M([]), [e, H] = M({
375
+ const i = Z(null), z = Z(null), m = Z(null), G = Z(null), R = Z(null), ie = Z(null), ke = Z(null), S = Z(null), J = Z(!1), _ = x === "YMM", [ve, Ce] = M([]), [pe, _e] = M([]), [ae, se] = M([]), [Ye, he] = M([]), [Re, ue] = M([]), [Te, fe] = M([]), [Ze, me] = M([]), [Oe, ge] = M([]), He = Z([]), [re, ze] = M([]), [e, H] = M({
376
376
  make: null,
377
377
  model: null,
378
378
  year: null,
@@ -407,12 +407,12 @@ function Ct({
407
407
  disable_session_recording: !1
408
408
  });
409
409
  }, []);
410
- const [ae, Ke] = M({}), [Mt, Je] = M(""), Ae = j(async () => {
410
+ const [oe, Ke] = M({}), [Mt, Je] = M(""), Ae = j(async () => {
411
411
  if (!g)
412
412
  return;
413
413
  const r = `${C ? "https://api.cartbot.io" : "https://api.partbot.io"}/v1/vehicles/auth`;
414
414
  try {
415
- const o = await fetch(r, {
415
+ const a = await fetch(r, {
416
416
  method: "POST",
417
417
  headers: {
418
418
  "Content-Type": "application/json",
@@ -421,35 +421,35 @@ function Ct({
421
421
  },
422
422
  body: JSON.stringify(
423
423
  (() => {
424
- const N = { use_store_vehicles: G };
425
- return J && (N.store = J), N;
424
+ const N = { use_store_vehicles: X };
425
+ return K && (N.store = K), N;
426
426
  })()
427
427
  )
428
428
  });
429
- if (!o.ok)
430
- throw new Error(`Error: ${o.status} ${o.statusText}`);
429
+ if (!a.ok)
430
+ throw new Error(`Error: ${a.status} ${a.statusText}`);
431
431
  const {
432
- merchant: a,
433
- vehicle_makes: l,
434
- vehicle_models: s,
435
- meilisearch_search_key: d,
436
- meilisearch_index_name: h,
432
+ merchant: o,
433
+ vehicle_makes: s,
434
+ vehicle_models: l,
435
+ meilisearch_search_key: c,
436
+ meilisearch_index_name: d,
437
437
  algolia_search_key: E,
438
438
  // Fallback for backward compatibility
439
- algolia_index_name: Q,
439
+ algolia_index_name: ne,
440
440
  // Fallback for backward compatibility
441
441
  store_index_name: u,
442
442
  store_popular_makes: b,
443
443
  // Array of popular make values for this store (from PostHog)
444
444
  store_popular_models: V
445
445
  // Object mapping makes to popular models: { "TOYOTA": ["HILUX", "LANDCRUISER"], ... }
446
- } = await o.json();
447
- z.current = a, m.current = (l || []).map((N) => ({
446
+ } = await a.json();
447
+ z.current = o, m.current = (s || []).map((N) => ({
448
448
  ...N,
449
449
  refinement: N.value
450
- })), ee.current = Array.isArray(s) ? s.map((N) => N && N.value ? String(N.value).trim() : "").filter(Boolean) : [], Y.current = Array.isArray(b) ? b.map((N) => String(N).trim().toUpperCase()) : null, console.log(
450
+ })), G.current = Array.isArray(l) ? l.map((N) => N && N.value ? String(N.value).trim() : "").filter(Boolean) : [], R.current = Array.isArray(b) ? b.map((N) => String(N).trim().toUpperCase()) : null, console.log(
451
451
  "[VehicleSearch] PostHog popular makes:",
452
- Y.current
452
+ R.current
453
453
  ), ie.current = V || null, console.log(
454
454
  "[VehicleSearch] PostHog popular models:",
455
455
  ie.current
@@ -458,19 +458,19 @@ function Ct({
458
458
  indexName: "otto_v1_vehicles_production",
459
459
  storeIndexName: u || "shopify_partbot-app-test_development"
460
460
  });
461
- } catch (o) {
462
- console.error("[VehicleSearch] Auth failed:", o), Je(o);
461
+ } catch (a) {
462
+ console.error("[VehicleSearch] Auth failed:", a), Je(a);
463
463
  }
464
- }, [g, J, G, C]);
464
+ }, [g, K, X, C]);
465
465
  L(() => {
466
466
  Ae();
467
467
  }, [Ae]), L(() => {
468
- if (ae.searchKey) {
468
+ if (oe.searchKey) {
469
469
  try {
470
470
  ke.current = new bt({
471
471
  host: "https://search.partbot.io",
472
- apiKey: ae.searchKey
473
- }), S.current = ke.current.index(ae.indexName);
472
+ apiKey: oe.searchKey
473
+ }), S.current = ke.current.index(oe.indexName);
474
474
  } catch (t) {
475
475
  console.error("[VehicleSearch] Failed to initialize Meilisearch:", t);
476
476
  }
@@ -478,57 +478,57 @@ function Ct({
478
478
  ke.current = null;
479
479
  };
480
480
  }
481
- }, [ae.searchKey, g]);
481
+ }, [oe.searchKey, g]);
482
482
  const [T, We] = M(!1), Pe = j(() => {
483
- function t(s) {
484
- if (!s) return "rgba(0,0,0,1)";
485
- var d = r(), h = window.getComputedStyle(s).backgroundColor;
486
- return h !== d ? h : s.parentElement ? t(s.parentElement) : "rgba(255,255,255,1)";
483
+ function t(l) {
484
+ if (!l) return "rgba(0,0,0,1)";
485
+ var c = r(), d = window.getComputedStyle(l).backgroundColor;
486
+ return d !== c ? d : l.parentElement ? t(l.parentElement) : "rgba(255,255,255,1)";
487
487
  }
488
488
  function r() {
489
- var s = document.createElement("div");
490
- document.head.appendChild(s);
491
- var d = window.getComputedStyle(s).backgroundColor;
492
- return document.head.removeChild(s), d;
489
+ var l = document.createElement("div");
490
+ document.head.appendChild(l);
491
+ var c = window.getComputedStyle(l).backgroundColor;
492
+ return document.head.removeChild(l), c;
493
493
  }
494
- const o = document.querySelector("vehicle-search");
495
- let a;
496
- o ? a = t(o) : a = t(i.current);
497
- const l = yt(a).isDark();
498
- We(l);
494
+ const a = document.querySelector("vehicle-search");
495
+ let o;
496
+ a ? o = t(a) : o = t(i.current);
497
+ const s = yt(o).isDark();
498
+ We(s);
499
499
  }, []);
500
500
  L(() => {
501
501
  async function t() {
502
- if (!(v ? e.make && e.model : e.make) || !S.current)
502
+ if (!e.make || !S.current)
503
503
  return;
504
- let o = [], a = [];
505
- e.make && o.push(`make:${e.make.refinement}`), e.model && o.push(
504
+ let r = [], a = [];
505
+ e.make && r.push(`make:${e.make.refinement}`), e.model && r.push(
506
506
  `model:${e.make.refinement} > ${e.model.refinement}`
507
507
  ), e.year && (a = [
508
508
  `year_from <= ${e.year.value}`,
509
509
  `year_to >= ${e.year.value}`
510
- ]), e.body && o.push(
510
+ ]), e.body && r.push(
511
511
  `body:${e.make.refinement} > ${e.model.refinement} > ${e.body.refinement}`
512
- ), e.series && o.push(`series:${e.series.refinement}`), e.engine && o.push(`engine:${e.engine.refinement}`), e.engine_capacity && o.push(
512
+ ), e.series && r.push(`series:${e.series.refinement}`), e.engine && r.push(`engine:${e.engine.refinement}`), e.engine_capacity && r.push(
513
513
  `engine_capacity:${e.engine_capacity.refinement}`
514
514
  );
515
515
  let s = (await S.current.search("", {
516
- filter: ce(o, a),
517
- attributesToRetrieve: ["swd_id"],
516
+ filter: ce(r, a),
517
+ attributesToRetrieve: ["otto_id"],
518
518
  limit: 500
519
519
  // Reduced from 1000 for faster queries
520
- })).hits.map((E) => E.swd_id);
520
+ })).hits.map((d) => d.otto_id);
521
521
  ze(s);
522
- let h = {
522
+ let c = {
523
523
  ...Object.fromEntries(
524
- Object.entries(e || {}).map(([E, Q]) => [E, Q && Q.value || null]).filter(([E, Q]) => Q !== null)
524
+ Object.entries(e || {}).map(([d, E]) => [d, E && E.value || null]).filter(([d, E]) => E !== null)
525
525
  ),
526
526
  merchant: z.current
527
527
  };
528
- Ee.capture("vehicle select", h);
528
+ Ee.capture("vehicle select", c);
529
529
  }
530
530
  t();
531
- }, [e, S, v]);
531
+ }, [e, S, h]);
532
532
  const Me = (t) => A ? `${A}${t}` : t, Xe = (t) => A ? t.replace(new RegExp(`^${A}`), "") : t, Ge = j(() => {
533
533
  const t = new URL(window.location.href).searchParams, r = [
534
534
  "make",
@@ -538,24 +538,24 @@ function Ct({
538
538
  "series",
539
539
  "engine",
540
540
  "engine_capacity"
541
- ].map(Me), o = Object.fromEntries(
542
- [...t.entries()].filter(([a]) => r.includes(a)).map(([a, l]) => [Xe(a), { value: l, refinement: l }])
541
+ ].map(Me), a = Object.fromEntries(
542
+ [...t.entries()].filter(([o]) => r.includes(o)).map(([o, s]) => [Xe(o), { value: s, refinement: s }])
543
543
  );
544
- H(o);
545
- }, []), P = j(({ query: t, value: r, remove: o }) => {
546
- if (X && "URLSearchParams" in window) {
547
- let a = new URLSearchParams(window.location.search);
548
- t = Me(t), t && r && a.set(t, r), t && !r && a.delete(t), o && o.forEach((s) => {
549
- s = Me(s), a.delete(s);
544
+ H(a);
545
+ }, []), P = j(({ query: t, value: r, remove: a }) => {
546
+ if (W && "URLSearchParams" in window) {
547
+ let o = new URLSearchParams(window.location.search);
548
+ t = Me(t), t && r && o.set(t, r), t && !r && o.delete(t), a && a.forEach((l) => {
549
+ l = Me(l), o.delete(l);
550
550
  });
551
- const l = window.location.pathname + "?" + a.toString();
552
- window.history.pushState(null, "", l);
551
+ const s = window.location.pathname + "?" + o.toString();
552
+ window.history.pushState(null, "", s);
553
553
  }
554
554
  }, []), et = j(() => {
555
- var o;
555
+ var a;
556
556
  const t = {
557
- vehicle_ids: oe,
558
- vehicle: (o = e == null ? void 0 : e.make) != null && o.value ? e : {}
557
+ vehicle_ids: re,
558
+ vehicle: (a = e == null ? void 0 : e.make) != null && a.value ? e : {}
559
559
  };
560
560
  O && O(t);
561
561
  const r = new CustomEvent("vehicle-search-submit", {
@@ -564,21 +564,21 @@ function Ct({
564
564
  document.dispatchEvent(r), setTimeout(() => {
565
565
  Se(!1);
566
566
  }, 900);
567
- }, [oe, O]), Ve = j(() => {
568
- var o, a, l, s, d, h, E, Q, u;
567
+ }, [re, O]), Ve = j(() => {
568
+ var a, o, s, l, c, d, E, ne, u;
569
569
  const t = {
570
- vehicle_ids: oe,
571
- vehicle: (o = e == null ? void 0 : e.make) != null && o.value ? e : {}
570
+ vehicle_ids: re,
571
+ vehicle: (a = e == null ? void 0 : e.make) != null && a.value ? e : {}
572
572
  };
573
573
  p && p(t);
574
574
  const r = new CustomEvent("vehicle-search-change", {
575
575
  detail: t
576
576
  });
577
- if (W.current === !0 && !localStorage.getItem("partbot_plate_details")) {
577
+ if (J.current === !0 && !localStorage.getItem("partbot_plate_details")) {
578
578
  const b = JSON.stringify({
579
- description: `${((a = e.make) == null ? void 0 : a.value) || ""} ${((l = e.model) == null ? void 0 : l.value) || ""} ${((s = e.year) == null ? void 0 : s.value) || ""} ${((d = e.body) == null ? void 0 : d.value) || ""} ${((h = e.series) == null ? void 0 : h.value) || ""} ${((E = e.variant) == null ? void 0 : E.value) || ""} ${((Q = e.engine) == null ? void 0 : Q.value) || ""} ${((u = e.engine_capacity) == null ? void 0 : u.value) || ""}`.trim(),
580
- vehicle_ids: oe,
581
- vehicle: e ? Object.entries(e).reduce((V, [N, te]) => (V[N] = te != null && te.value ? te.value : {}, V), {}) : {}
579
+ description: `${((o = e.make) == null ? void 0 : o.value) || ""} ${((s = e.model) == null ? void 0 : s.value) || ""} ${((l = e.year) == null ? void 0 : l.value) || ""} ${((c = e.body) == null ? void 0 : c.value) || ""} ${((d = e.series) == null ? void 0 : d.value) || ""} ${((E = e.variant) == null ? void 0 : E.value) || ""} ${((ne = e.engine) == null ? void 0 : ne.value) || ""} ${((u = e.engine_capacity) == null ? void 0 : u.value) || ""}`.trim(),
580
+ vehicle_ids: re,
581
+ vehicle: e ? Object.entries(e).reduce((V, [N, ee]) => (V[N] = ee != null && ee.value ? ee.value : {}, V), {}) : {}
582
582
  });
583
583
  localStorage.setItem(
584
584
  "partbot_selected_vehicle",
@@ -587,21 +587,21 @@ function Ct({
587
587
  secure: !0
588
588
  });
589
589
  }
590
- document.dispatchEvent(r), He.current = oe, setTimeout(() => {
590
+ document.dispatchEvent(r), He.current = re, setTimeout(() => {
591
591
  Se(!1);
592
592
  }, 900);
593
- }, [oe, p]), we = ct(
593
+ }, [re, p]), we = ct(
594
594
  () => wt(Ve, 100),
595
595
  [Ve]
596
596
  );
597
597
  L(() => {
598
598
  we();
599
- }, [oe, we]), L(() => () => {
599
+ }, [re, we]), L(() => () => {
600
600
  we.cancel();
601
601
  }, [we]), L(() => {
602
- ae.searchKey && (_ || it(), Ge());
603
- }, [ae.searchKey, _]), L(() => {
604
- _ && S.current && ne.length === 0 && !e.year && (console.log(
602
+ oe.searchKey && (_ || it(), Ge());
603
+ }, [oe.searchKey, _]), L(() => {
604
+ _ && S.current && ae.length === 0 && !e.year && (console.log(
605
605
  "[VehicleSearch] YMM mode: Loading year range from dataset..."
606
606
  ), S.current.search("", {
607
607
  attributesToRetrieve: ["year_from", "year_to"],
@@ -612,37 +612,37 @@ function Ct({
612
612
  t.length,
613
613
  "hits for year range"
614
614
  );
615
- const r = t.map((d) => d.year_from).filter(Boolean), o = t.map((d) => d.year_to).filter(Boolean), a = Math.min(...r), l = Math.max(...o);
615
+ const r = t.map((c) => c.year_from).filter(Boolean), a = t.map((c) => c.year_to).filter(Boolean), o = Math.min(...r), s = Math.max(...a);
616
616
  console.log(
617
617
  "[VehicleSearch] YMM mode: Year range:",
618
- a,
618
+ o,
619
619
  "-",
620
- l
620
+ s
621
621
  );
622
- const s = Array.from(
623
- { length: l - a + 1 },
624
- (d, h) => ({ value: a + h, refinement: a + h })
622
+ const l = Array.from(
623
+ { length: s - o + 1 },
624
+ (c, d) => ({ value: o + d, refinement: o + d })
625
625
  ).reverse();
626
626
  console.log(
627
627
  "[VehicleSearch] YMM mode: Setting",
628
- s.length,
628
+ l.length,
629
629
  "years"
630
- ), se(s);
630
+ ), se(l);
631
631
  }).catch((t) => {
632
632
  console.error("[VehicleSearch] Error loading year range:", t);
633
633
  }));
634
- }, [_, ae.searchKey, ne.length, e.year]), L(() => {
634
+ }, [_, oe.searchKey, ae.length, e.year]), L(() => {
635
635
  typeof document > "u" || Pe();
636
636
  }, [Pe]);
637
637
  const Le = j(
638
638
  (t) => {
639
- W.current = !0, _e([]), !_ && !v && se([]), he([]), ue([]), fe([]), ge([]), me([]), H((r) => ({
639
+ J.current = !0, _e([]), !_ && !h && se([]), he([]), ue([]), fe([]), ge([]), me([]), H((r) => ({
640
640
  make: t,
641
- year: _ || v ? r.year : null
641
+ year: _ || h ? r.year : null
642
642
  })), P({
643
643
  query: "make",
644
644
  value: (t == null ? void 0 : t.value) ?? "",
645
- remove: _ ? ["model", "body", "series", "engine", "variant", "engine_capacity"] : v ? [
645
+ remove: _ ? ["model", "body", "series", "engine", "variant", "engine_capacity"] : h ? [
646
646
  "model",
647
647
  "body",
648
648
  "series",
@@ -660,23 +660,23 @@ function Ct({
660
660
  ]
661
661
  }), t || ze([]);
662
662
  },
663
- [P, _, v]
663
+ [P, _, h]
664
664
  ), Ie = j(
665
665
  (t) => {
666
- W.current = !0, H((r) => ({
666
+ J.current = !0, H((r) => ({
667
667
  ...r,
668
668
  model: t !== "" ? t : null,
669
- year: _ || v ? r.year : null,
669
+ year: _ || h ? r.year : null,
670
670
  // Preserve year in YMM mode or yearOptional mode
671
671
  body: null,
672
672
  series: null,
673
673
  variant: null,
674
674
  engine: null,
675
675
  engine_capacity: null
676
- })), !_ && !v && se([]), he([]), ue([]), fe([]), ge([]), me([]), P({
676
+ })), !_ && !h && se([]), he([]), ue([]), fe([]), ge([]), me([]), P({
677
677
  query: "model",
678
678
  value: (t == null ? void 0 : t.value) ?? "",
679
- remove: _ ? ["body", "series", "engine", "variant", "engine_capacity"] : v ? ["body", "series", "engine", "variant", "engine_capacity"] : [
679
+ remove: _ ? ["body", "series", "engine", "variant", "engine_capacity"] : h ? ["body", "series", "engine", "variant", "engine_capacity"] : [
680
680
  "year",
681
681
  "body",
682
682
  "series",
@@ -686,12 +686,12 @@ function Ct({
686
686
  ]
687
687
  });
688
688
  },
689
- [P, _, v]
689
+ [P, _, h]
690
690
  ), Be = j(
691
691
  (t) => {
692
- W.current = !0, _ ? (Ce([]), _e([]), H({
692
+ J.current = !0, _ ? (Ce([]), _e([]), H({
693
693
  year: t !== "" ? t : null
694
- }), (!t || t === "") && se([])) : H(v ? (r) => ({
694
+ }), (!t || t === "") && se([])) : H(h ? (r) => ({
695
695
  ...r,
696
696
  year: t !== "" ? t : null
697
697
  }) : (r) => ({
@@ -702,7 +702,7 @@ function Ct({
702
702
  variant: null,
703
703
  engine: null,
704
704
  engine_capacity: null
705
- })), v || (he([]), ue([]), fe([]), ge([]), me([])), P({
705
+ })), h || (he([]), ue([]), fe([]), ge([]), me([])), P({
706
706
  query: "year",
707
707
  value: (t == null ? void 0 : t.value) ?? "",
708
708
  remove: _ ? [
@@ -713,13 +713,13 @@ function Ct({
713
713
  "variant",
714
714
  "engine",
715
715
  "engine_capacity"
716
- ] : v ? [] : ["body", "series", "variant", "engine", "engine_capacity"]
717
- }), !v && (!t || t === "") && ze([]);
716
+ ] : h ? [] : ["body", "series", "variant", "engine", "engine_capacity"]
717
+ }), !h && (!t || t === "") && ze([]);
718
718
  },
719
- [P, _, v]
719
+ [P, _, h]
720
720
  ), tt = j(
721
721
  (t) => {
722
- W.current = !0, H((r) => ({
722
+ J.current = !0, H((r) => ({
723
723
  ...r,
724
724
  body: t !== "" ? t : null
725
725
  })), P({
@@ -730,7 +730,7 @@ function Ct({
730
730
  [P]
731
731
  ), rt = j(
732
732
  (t) => {
733
- W.current = !0, H((r) => ({
733
+ J.current = !0, H((r) => ({
734
734
  ...r,
735
735
  series: t !== "" ? t : null
736
736
  })), P({
@@ -741,7 +741,7 @@ function Ct({
741
741
  [P]
742
742
  ), ot = j(
743
743
  (t) => {
744
- W.current = !0, H((r) => ({
744
+ J.current = !0, H((r) => ({
745
745
  ...r,
746
746
  variant: t !== "" ? t : null
747
747
  })), P({
@@ -752,7 +752,7 @@ function Ct({
752
752
  [P]
753
753
  ), at = j(
754
754
  (t) => {
755
- W.current = !0, H((r) => ({
755
+ J.current = !0, H((r) => ({
756
756
  ...r,
757
757
  engine: t !== "" ? t : null
758
758
  })), P({
@@ -763,7 +763,7 @@ function Ct({
763
763
  [P]
764
764
  ), nt = j(
765
765
  (t) => {
766
- W.current = !0, H((r) => ({
766
+ J.current = !0, H((r) => ({
767
767
  ...r,
768
768
  engine_capacity: t !== "" ? t : null
769
769
  })), P({
@@ -780,22 +780,22 @@ function Ct({
780
780
  filter: `year_from <= ${e.year.value} AND year_to >= ${e.year.value}`,
781
781
  attributesToRetrieve: ["make", "make_popularity"],
782
782
  limit: 1e4
783
- }), o = /* @__PURE__ */ new Map();
784
- r.hits.forEach((s) => {
785
- s.make && !o.has(s.make) && o.set(s.make, {
786
- value: s.make.toUpperCase(),
787
- refinement: s.make.toUpperCase(),
788
- popularity: s.make_popularity || 0
783
+ }), a = /* @__PURE__ */ new Map();
784
+ r.hits.forEach((l) => {
785
+ l.make && !a.has(l.make) && a.set(l.make, {
786
+ value: l.make.toUpperCase(),
787
+ refinement: l.make.toUpperCase(),
788
+ popularity: l.make_popularity || 0
789
789
  });
790
790
  });
791
- let a = Array.from(o.values());
792
- const l = new Set(Y.current || []);
793
- l.size > 0 ? a.sort((s, d) => {
794
- const h = l.has(s.value), E = l.has(d.value);
795
- return h && !E ? -1 : !h && E ? 1 : h && E ? Y.current.indexOf(s.value) - Y.current.indexOf(d.value) : s.value.localeCompare(d.value);
796
- }) : a.sort(
797
- (s, d) => d.popularity === s.popularity ? s.value.localeCompare(d.value) : d.popularity - s.popularity
798
- ), Ce(a);
791
+ let o = Array.from(a.values());
792
+ const s = new Set(R.current || []);
793
+ s.size > 0 ? o.sort((l, c) => {
794
+ const d = s.has(l.value), E = s.has(c.value);
795
+ return d && !E ? -1 : !d && E ? 1 : d && E ? R.current.indexOf(l.value) - R.current.indexOf(c.value) : l.value.localeCompare(c.value);
796
+ }) : o.sort(
797
+ (l, c) => c.popularity === l.popularity ? l.value.localeCompare(c.value) : c.popularity - l.popularity
798
+ ), Ce(o);
799
799
  } catch (r) {
800
800
  console.error("[VehicleSearch] Error loading makes for year:", r);
801
801
  }
@@ -808,34 +808,34 @@ function Ct({
808
808
  r = m.current;
809
809
  else if (S.current)
810
810
  try {
811
- const o = await S.current.search("", {
811
+ const a = await S.current.search("", {
812
812
  attributesToRetrieve: ["make", "make_popularity"],
813
813
  limit: 1e3
814
- }), a = /* @__PURE__ */ new Map();
815
- o.hits.forEach((l) => {
816
- l.make && !a.has(l.make) && a.set(l.make, {
817
- value: l.make.toUpperCase(),
818
- refinement: l.make.toUpperCase(),
819
- popularity: l.make_popularity || 0
814
+ }), o = /* @__PURE__ */ new Map();
815
+ a.hits.forEach((s) => {
816
+ s.make && !o.has(s.make) && o.set(s.make, {
817
+ value: s.make.toUpperCase(),
818
+ refinement: s.make.toUpperCase(),
819
+ popularity: s.make_popularity || 0
820
820
  });
821
- }), r = Array.from(a.values());
822
- } catch (o) {
823
- console.error("[VehicleSearch] Error loading makes:", o);
821
+ }), r = Array.from(o.values());
822
+ } catch (a) {
823
+ console.error("[VehicleSearch] Error loading makes:", a);
824
824
  }
825
825
  if (f && r.length) {
826
- const o = f.trim().split(",").map((a) => a.trim().toUpperCase());
826
+ const a = f.trim().split(",").map((o) => o.trim().toUpperCase());
827
827
  r = r.filter(
828
- (a) => o.includes(a.value)
828
+ (o) => a.includes(o.value)
829
829
  );
830
830
  }
831
- if (Y.current && Y.current.length > 0) {
832
- const o = new Set(Y.current);
833
- r.sort((a, l) => {
834
- const s = o.has(a.value), d = o.has(l.value);
835
- return s && !d ? -1 : !s && d ? 1 : s && d ? Y.current.indexOf(a.value) - Y.current.indexOf(l.value) : a.value.localeCompare(l.value);
831
+ if (R.current && R.current.length > 0) {
832
+ const a = new Set(R.current);
833
+ r.sort((o, s) => {
834
+ const l = a.has(o.value), c = a.has(s.value);
835
+ return l && !c ? -1 : !l && c ? 1 : l && c ? R.current.indexOf(o.value) - R.current.indexOf(s.value) : o.value.localeCompare(s.value);
836
836
  });
837
837
  } else
838
- r.sort((o, a) => o.popularity === a.popularity ? o.value.localeCompare(a.value) : a.popularity - o.popularity);
838
+ r.sort((a, o) => a.popularity === o.popularity ? a.value.localeCompare(o.value) : o.popularity - a.popularity);
839
839
  Ce(r);
840
840
  })();
841
841
  }, [f]);
@@ -847,52 +847,52 @@ function Ct({
847
847
  `year_to >= ${e.year.value}`
848
848
  ]), S.current.search("", {
849
849
  filter: ce(t, r),
850
- attributesToRetrieve: ["model", "model_popularity", "swd_id"],
850
+ attributesToRetrieve: ["model", "model_popularity", "otto_id"],
851
851
  limit: 1e3
852
852
  // Meilisearch can handle larger limits efficiently
853
- }).then(({ hits: o }) => {
854
- var E, Q;
855
- const a = Array.isArray(ee.current) ? ee.current : typeof ee.current == "string" && ee.current.length ? ee.current.split(",").map((u) => u.trim()).filter(Boolean) : [];
856
- let l = a;
857
- if (c) {
858
- const u = c.trim().split(",").map((V) => V.trim()).filter(Boolean), b = new Set(
853
+ }).then(({ hits: a }) => {
854
+ var E, ne;
855
+ const o = Array.isArray(G.current) ? G.current : typeof G.current == "string" && G.current.length ? G.current.split(",").map((u) => u.trim()).filter(Boolean) : [];
856
+ let s = o;
857
+ if (v) {
858
+ const u = v.trim().split(",").map((V) => V.trim()).filter(Boolean), b = new Set(
859
859
  u.map((V) => V.toLowerCase())
860
860
  );
861
- l = a.length ? a.filter(
861
+ s = o.length ? o.filter(
862
862
  (V) => b.has(String(V).toLowerCase())
863
- ) : u, o = o.filter(
863
+ ) : u, a = a.filter(
864
864
  (V) => b.has(
865
865
  V.model.match(/[^>]*$/)[0].trim().toLowerCase()
866
866
  )
867
867
  );
868
868
  }
869
- if (l && l.length) {
869
+ if (s && s.length) {
870
870
  const u = new Set(
871
- l.map((b) => String(b).toLowerCase())
871
+ s.map((b) => String(b).toLowerCase())
872
872
  );
873
- o = o.filter(
873
+ a = a.filter(
874
874
  (b) => u.has(
875
875
  b.model.match(/[^>]*$/)[0].trim().toLowerCase()
876
876
  )
877
877
  );
878
878
  }
879
- let s = /* @__PURE__ */ new Set();
880
- o = o.filter((u) => u.model && u.model !== "" && !s.has(u.model) && u.model.match(/[^>]*$/)[0].trim() !== "" ? (s.add(u.model), !0) : !1), o = o.map((u) => ({
879
+ let l = /* @__PURE__ */ new Set();
880
+ a = a.filter((u) => u.model && u.model !== "" && !l.has(u.model) && u.model.match(/[^>]*$/)[0].trim() !== "" ? (l.add(u.model), !0) : !1), a = a.map((u) => ({
881
881
  value: u.model.match(/[^>]*$/)[0].trim(),
882
882
  refinement: u.model.match(/[^>]*$/)[0].trim(),
883
883
  popularity: u.model_popularity
884
884
  }));
885
- const d = (E = e.make) == null ? void 0 : E.refinement, h = (Q = ie.current) == null ? void 0 : Q[d];
886
- if (h && Array.isArray(h) && h.length > 0) {
885
+ const c = (E = e.make) == null ? void 0 : E.refinement, d = (ne = ie.current) == null ? void 0 : ne[c];
886
+ if (d && Array.isArray(d) && d.length > 0) {
887
887
  const u = new Set(
888
- h.map((b) => String(b).trim().toUpperCase())
888
+ d.map((b) => String(b).trim().toUpperCase())
889
889
  );
890
- o.sort((b, V) => {
891
- const N = u.has(b.value), te = u.has(V.value);
892
- if (N && !te) return -1;
893
- if (!N && te) return 1;
894
- if (N && te) {
895
- const De = h.map(
890
+ a.sort((b, V) => {
891
+ const N = u.has(b.value), ee = u.has(V.value);
892
+ if (N && !ee) return -1;
893
+ if (!N && ee) return 1;
894
+ if (N && ee) {
895
+ const De = d.map(
896
896
  (lt) => String(lt).trim().toUpperCase()
897
897
  );
898
898
  return De.indexOf(b.value) - De.indexOf(V.value);
@@ -900,11 +900,11 @@ function Ct({
900
900
  return b.value.localeCompare(V.value);
901
901
  });
902
902
  } else
903
- o.sort((u, b) => u.popularity === b.popularity ? u.value.localeCompare(b.value) : b.popularity - u.popularity);
904
- _e(o);
903
+ a.sort((u, b) => u.popularity === b.popularity ? u.value.localeCompare(b.value) : b.popularity - u.popularity);
904
+ _e(a);
905
905
  });
906
906
  }
907
- }, [e.make, c, g]), L(() => {
907
+ }, [e.make, v, g]), L(() => {
908
908
  if (S.current && e.make && e.model) {
909
909
  console.log(
910
910
  "[VehicleSearch] Fetching year range for:",
@@ -915,13 +915,13 @@ function Ct({
915
915
  let t = [
916
916
  `model:${e.make.refinement} > ${e.model.refinement}`
917
917
  ];
918
- v && (e.body && t.push(
918
+ h && (e.body && t.push(
919
919
  `body:${e.make.refinement} > ${e.model.refinement} > ${e.body.refinement}`
920
920
  ), e.series && t.push(`series:${e.series.refinement}`), e.engine && t.push(`engine:${e.engine.refinement}`), e.engine_capacity && t.push(
921
921
  `engine_capacity:${e.engine_capacity.refinement}`
922
922
  )), S.current.search("", {
923
923
  filter: ce(t, []),
924
- attributesToRetrieve: ["year_from", "year_to", "swd_id"],
924
+ attributesToRetrieve: ["year_from", "year_to", "otto_id"],
925
925
  limit: 200
926
926
  // Reduced from 1000 for faster queries
927
927
  }).then(({ hits: r }) => {
@@ -929,13 +929,13 @@ function Ct({
929
929
  "[VehicleSearch] Year search returned hits:",
930
930
  r.length
931
931
  );
932
- const o = r.map((h) => h.year_from), a = Math.min(...o), l = r.map((h) => h.year_to), s = Math.max(...l);
933
- let d = Array.apply(null, {
934
- length: s + 1 - a
935
- }).map(function(h, E) {
936
- return E + a;
932
+ const a = r.map((d) => d.year_from), o = Math.min(...a), s = r.map((d) => d.year_to), l = Math.max(...s);
933
+ let c = Array.apply(null, {
934
+ length: l + 1 - o
935
+ }).map(function(d, E) {
936
+ return E + o;
937
937
  });
938
- d = d.reverse().map((h) => ({ value: h, refinement: h })), se(d);
938
+ c = c.reverse().map((d) => ({ value: d, refinement: d })), se(c);
939
939
  }).catch((r) => {
940
940
  console.error("[VehicleSearch] Error fetching years:", r);
941
941
  });
@@ -944,13 +944,13 @@ function Ct({
944
944
  e.model,
945
945
  e.make,
946
946
  _,
947
- v,
947
+ h,
948
948
  e.body,
949
949
  e.series,
950
950
  e.engine,
951
951
  e.engine_capacity
952
952
  ]), L(() => {
953
- const t = v ? e.make && e.model : e.year && e.make && e.model;
953
+ const t = h ? e.make && e.model : e.year && e.make && e.model;
954
954
  if (S.current && t) {
955
955
  const r = e.year ? [
956
956
  `year_from <= ${e.year.value}`,
@@ -961,30 +961,30 @@ function Ct({
961
961
  [`model:${e.make.refinement} > ${e.model.refinement}`],
962
962
  r
963
963
  ),
964
- attributesToRetrieve: ["body", "swd_id"],
964
+ attributesToRetrieve: ["body", "otto_id"],
965
965
  limit: 1e3
966
- }).then(({ hits: o }) => {
967
- o = [...new Map(o.map((a) => [a.body, a])).values()].map((a) => ({
968
- value: a.body.match(/[^>]*$/)[0].trim(),
969
- refinement: a.body.match(/[^>]*$/)[0].trim()
970
- })).filter((a) => a.value), he(o);
966
+ }).then(({ hits: a }) => {
967
+ a = [...new Map(a.map((o) => [o.body, o])).values()].map((o) => ({
968
+ value: o.body.match(/[^>]*$/)[0].trim(),
969
+ refinement: o.body.match(/[^>]*$/)[0].trim()
970
+ })).filter((o) => o.value), he(a);
971
971
  });
972
972
  }
973
- }, [e.year, e.make, e.model, v]);
974
- const le = j(({ hits: t, attribute: r, stateCallback: o }) => {
975
- let a = [
976
- ...new Map(t.map((l) => [l[r], l])).values()
977
- ].map((l) => ({
978
- value: l[r].match(/[^|]*$/)[0].trim(),
979
- refinement: l[r].match(/[^|]*$/)[0].trim()
980
- })).filter((l) => l.refinement);
981
- o(a);
973
+ }, [e.year, e.make, e.model, h]);
974
+ const le = j(({ hits: t, attribute: r, stateCallback: a }) => {
975
+ let o = [
976
+ ...new Map(t.map((s) => [s[r], s])).values()
977
+ ].map((s) => ({
978
+ value: s[r].match(/[^|]*$/)[0].trim(),
979
+ refinement: s[r].match(/[^|]*$/)[0].trim()
980
+ })).filter((s) => s.refinement);
981
+ a(o);
982
982
  }, []), st = j(() => {
983
983
  const t = be.current ? be.current.length + 3 : 3, r = y ? t + 1 : t;
984
984
  return `vs:lg:grid-cols-${r > 8 ? 8 : r}`;
985
985
  }, [y]);
986
986
  L(() => {
987
- const t = v ? e.make && e.model : e.make && e.model && e.year;
987
+ const t = h ? e.make && e.model : e.make && e.model && e.year;
988
988
  if (S.current && t) {
989
989
  let r = [
990
990
  `make:${e.make.refinement}`,
@@ -994,37 +994,37 @@ function Ct({
994
994
  e.variant ? `variant:${e.variant.refinement}` : "",
995
995
  e.engine ? `engine:${e.engine.refinement}` : "",
996
996
  e.engine_capacity ? `engine_capacity:${e.engine_capacity.refinement}` : ""
997
- ].filter((a) => a);
998
- const o = e.year ? [
997
+ ].filter((o) => o);
998
+ const a = e.year ? [
999
999
  `year_from <= ${e.year.value}`,
1000
1000
  `year_to >= ${e.year.value}`
1001
1001
  ] : [];
1002
1002
  S.current.search("", {
1003
- filter: ce(r, o),
1003
+ filter: ce(r, a),
1004
1004
  attributesToRetrieve: [
1005
1005
  "series",
1006
1006
  "engine_capacity",
1007
1007
  "engine",
1008
1008
  "cylinders",
1009
1009
  "variant",
1010
- "swd_id"
1010
+ "otto_id"
1011
1011
  ],
1012
1012
  limit: 1e3
1013
- }).then(({ hits: a }) => {
1013
+ }).then(({ hits: o }) => {
1014
1014
  le({
1015
- hits: a,
1015
+ hits: o,
1016
1016
  attribute: "series",
1017
1017
  stateCallback: ue
1018
1018
  }), le({
1019
- hits: a,
1019
+ hits: o,
1020
1020
  attribute: "variant",
1021
1021
  stateCallback: fe
1022
1022
  }), le({
1023
- hits: a,
1023
+ hits: o,
1024
1024
  attribute: "engine",
1025
1025
  stateCallback: me
1026
1026
  }), le({
1027
- hits: a,
1027
+ hits: o,
1028
1028
  attribute: "engine_capacity",
1029
1029
  stateCallback: ge
1030
1030
  });
@@ -1040,7 +1040,7 @@ function Ct({
1040
1040
  e.make,
1041
1041
  e.model,
1042
1042
  e.year,
1043
- v
1043
+ h
1044
1044
  ]);
1045
1045
  const [ye, $e] = M(!1);
1046
1046
  return L(() => {
@@ -1054,9 +1054,9 @@ function Ct({
1054
1054
  {
1055
1055
  onClick: () => $e(!0),
1056
1056
  type: "button",
1057
- className: re(
1057
+ className: te(
1058
1058
  "vehicle-search-btn vs:md:hidden!",
1059
- U ? "vs:w-full! vs:flex! vs:shrink-0!" : "vs:w-auto! vs:inline-flex! vs:shrink!"
1059
+ Y ? "vs:w-full! vs:flex! vs:shrink-0!" : "vs:w-auto! vs:inline-flex! vs:shrink!"
1060
1060
  ),
1061
1061
  children: /* @__PURE__ */ n("span", { children: "Select Vehicle" })
1062
1062
  }
@@ -1065,7 +1065,7 @@ function Ct({
1065
1065
  "div",
1066
1066
  {
1067
1067
  onClick: () => $e(!1),
1068
- className: re(
1068
+ className: te(
1069
1069
  "vs:z-10 vs:fixed vs:inset-0 vs:bg-stone-900 vs:transition-all vs:duration-300",
1070
1070
  ye ? "vs:opacity-75" : "vs:pointer-events-none vs:opacity-0"
1071
1071
  )
@@ -1074,7 +1074,7 @@ function Ct({
1074
1074
  /* @__PURE__ */ $(
1075
1075
  "div",
1076
1076
  {
1077
- className: re(
1077
+ className: te(
1078
1078
  B && "partbot-mmyvs-container",
1079
1079
  B && ye && "active",
1080
1080
  "w-full"
@@ -1108,7 +1108,7 @@ function Ct({
1108
1108
  "div",
1109
1109
  {
1110
1110
  ref: i,
1111
- className: re(
1111
+ className: te(
1112
1112
  "vs:grid vs:gap-3",
1113
1113
  I === "row" ? `${st()} vs:grid-cols-1 vs:md:grid-cols-3` : "vs:grid-cols-1 vs:md:max-w-[400px] vs:md:gap-5",
1114
1114
  "vs:w-full vs:transition vs:lg:mx-auto"
@@ -1116,21 +1116,21 @@ function Ct({
1116
1116
  children: [
1117
1117
  _ ? /* @__PURE__ */ $(xe, { children: [
1118
1118
  /* @__PURE__ */ n(
1119
- K,
1119
+ Q,
1120
1120
  {
1121
1121
  label: "Year",
1122
- items: ne,
1122
+ items: ae,
1123
1123
  refine: Be,
1124
1124
  selected: e.year,
1125
1125
  bgDark: T,
1126
1126
  showLabel: k,
1127
1127
  isMobile: q,
1128
1128
  sortOptions: !1,
1129
- loading: ne.length === 0
1129
+ loading: ae.length === 0
1130
1130
  }
1131
1131
  ),
1132
1132
  /* @__PURE__ */ n(
1133
- K,
1133
+ Q,
1134
1134
  {
1135
1135
  label: "Make",
1136
1136
  items: ve,
@@ -1145,7 +1145,7 @@ function Ct({
1145
1145
  }
1146
1146
  ),
1147
1147
  /* @__PURE__ */ n(
1148
- K,
1148
+ Q,
1149
1149
  {
1150
1150
  label: "Model",
1151
1151
  items: pe,
@@ -1161,7 +1161,7 @@ function Ct({
1161
1161
  )
1162
1162
  ] }) : /* @__PURE__ */ $(xe, { children: [
1163
1163
  /* @__PURE__ */ n(
1164
- K,
1164
+ Q,
1165
1165
  {
1166
1166
  label: "Make",
1167
1167
  items: ve,
@@ -1176,7 +1176,7 @@ function Ct({
1176
1176
  }
1177
1177
  ),
1178
1178
  /* @__PURE__ */ n(
1179
- K,
1179
+ Q,
1180
1180
  {
1181
1181
  label: "Model",
1182
1182
  items: pe,
@@ -1191,17 +1191,17 @@ function Ct({
1191
1191
  }
1192
1192
  ),
1193
1193
  /* @__PURE__ */ n(
1194
- K,
1194
+ Q,
1195
1195
  {
1196
1196
  label: "Year",
1197
- items: ne,
1197
+ items: ae,
1198
1198
  refine: Be,
1199
1199
  selected: e.year,
1200
1200
  bgDark: T,
1201
1201
  showLabel: k,
1202
1202
  isMobile: q,
1203
1203
  sortOptions: !1,
1204
- loading: e.model && ne.length === 0
1204
+ loading: e.model && ae.length === 0
1205
1205
  }
1206
1206
  )
1207
1207
  ] }),
@@ -1210,10 +1210,10 @@ function Ct({
1210
1210
  switch (t) {
1211
1211
  case "body":
1212
1212
  r = /* @__PURE__ */ n(
1213
- K,
1213
+ Q,
1214
1214
  {
1215
1215
  label: "Body",
1216
- items: Ue,
1216
+ items: Ye,
1217
1217
  refine: tt,
1218
1218
  selected: e.body,
1219
1219
  bgDark: T,
@@ -1227,10 +1227,10 @@ function Ct({
1227
1227
  break;
1228
1228
  case "series":
1229
1229
  r = /* @__PURE__ */ n(
1230
- K,
1230
+ Q,
1231
1231
  {
1232
1232
  label: "Series",
1233
- items: Ye,
1233
+ items: Re,
1234
1234
  refine: rt,
1235
1235
  selected: e.series,
1236
1236
  bgDark: T,
@@ -1244,7 +1244,7 @@ function Ct({
1244
1244
  break;
1245
1245
  case "variant":
1246
1246
  r = /* @__PURE__ */ n(
1247
- K,
1247
+ Q,
1248
1248
  {
1249
1249
  label: "Variant",
1250
1250
  items: Te,
@@ -1261,7 +1261,7 @@ function Ct({
1261
1261
  break;
1262
1262
  case "engine_capacity":
1263
1263
  r = /* @__PURE__ */ n(
1264
- K,
1264
+ Q,
1265
1265
  {
1266
1266
  label: "Engine Capacity",
1267
1267
  items: Oe,
@@ -1278,7 +1278,7 @@ function Ct({
1278
1278
  break;
1279
1279
  case "engine":
1280
1280
  r = /* @__PURE__ */ n(
1281
- K,
1281
+ Q,
1282
1282
  {
1283
1283
  label: "Engine",
1284
1284
  items: Ze,
@@ -1312,10 +1312,10 @@ function Ct({
1312
1312
  ]
1313
1313
  }
1314
1314
  ),
1315
- R && /* @__PURE__ */ n(
1315
+ U && /* @__PURE__ */ n(
1316
1316
  "div",
1317
1317
  {
1318
- className: re(
1318
+ className: te(
1319
1319
  "vs:flex vs:w-full vs:justify-center vs:items-center",
1320
1320
  I === "row" ? "vs:md:items-end vs:md:justify-end" : "vs:md:justify-center",
1321
1321
  "vs:mt-4 vs:md:mt-3 vs:md:pr-1.5"
@@ -1341,27 +1341,27 @@ function Ct({
1341
1341
  )
1342
1342
  ] });
1343
1343
  }
1344
- let Re = !1, de = !1;
1344
+ let Ue = !1, de = !1;
1345
1345
  function _t(g) {
1346
- var B, X;
1346
+ var B, W;
1347
1347
  const f = g.shadowRoot;
1348
1348
  if (!f) {
1349
1349
  console.error("[ShadowDOMPatch] No shadow root found");
1350
1350
  return;
1351
1351
  }
1352
- const c = f.children[1];
1353
- if (!c) {
1352
+ const v = f.children[1];
1353
+ if (!v) {
1354
1354
  console.error("[ShadowDOMPatch] No mount point found in shadow root");
1355
1355
  return;
1356
1356
  }
1357
1357
  if (new MutationObserver((p) => {
1358
1358
  p.forEach((w) => {
1359
1359
  w.addedNodes.forEach((y) => {
1360
- y.nodeType === 1 && y.id === "headlessui-portal-root" && (c.appendChild(y), de = !0);
1360
+ y.nodeType === 1 && y.id === "headlessui-portal-root" && (v.appendChild(y), de = !0);
1361
1361
  });
1362
1362
  }), p.forEach((w) => {
1363
1363
  w.removedNodes.forEach((y) => {
1364
- y.nodeType === 1 && y.id === "headlessui-portal-root" && (c.querySelector(
1364
+ y.nodeType === 1 && y.id === "headlessui-portal-root" && (v.querySelector(
1365
1365
  "#headlessui-portal-root"
1366
1366
  ) || (de = !1));
1367
1367
  });
@@ -1374,10 +1374,10 @@ function _t(g) {
1374
1374
  y.nodeType === 1 && y.id === "headlessui-portal-root" && (de = !1);
1375
1375
  });
1376
1376
  });
1377
- }).observe(c, {
1377
+ }).observe(v, {
1378
1378
  childList: !0,
1379
1379
  subtree: !0
1380
- }), Re)
1380
+ }), Ue)
1381
1381
  return;
1382
1382
  const F = (B = Object.getOwnPropertyDescriptor(
1383
1383
  Document.prototype,
@@ -1389,17 +1389,17 @@ function _t(g) {
1389
1389
  return p === g ? f.activeElement : p;
1390
1390
  }
1391
1391
  });
1392
- const A = (X = Object.getOwnPropertyDescriptor(
1392
+ const A = (W = Object.getOwnPropertyDescriptor(
1393
1393
  Event.prototype,
1394
1394
  "target"
1395
- )) == null ? void 0 : X.get;
1395
+ )) == null ? void 0 : W.get;
1396
1396
  Object.defineProperty(Event.prototype, "target", {
1397
1397
  get: function() {
1398
1398
  const p = A == null ? void 0 : A.call(this);
1399
1399
  return p === g ? this.composedPath()[0] : p;
1400
1400
  }
1401
1401
  });
1402
- const R = (p) => {
1402
+ const U = (p) => {
1403
1403
  try {
1404
1404
  return document.body && p === document.body.style;
1405
1405
  } catch {
@@ -1407,24 +1407,24 @@ function _t(g) {
1407
1407
  }
1408
1408
  }, k = CSSStyleDeclaration.prototype.setProperty;
1409
1409
  CSSStyleDeclaration.prototype.setProperty = function(p, w, y) {
1410
- if (!(R(this) && p === "overflow" && w === "hidden" && de))
1410
+ if (!(U(this) && p === "overflow" && w === "hidden" && de))
1411
1411
  return k.call(this, p, w, y);
1412
1412
  };
1413
- const U = Object.getOwnPropertyDescriptor(
1413
+ const Y = Object.getOwnPropertyDescriptor(
1414
1414
  CSSStyleDeclaration.prototype,
1415
1415
  "overflow"
1416
1416
  );
1417
- U && Object.defineProperty(CSSStyleDeclaration.prototype, "overflow", {
1417
+ Y && Object.defineProperty(CSSStyleDeclaration.prototype, "overflow", {
1418
1418
  get: function() {
1419
- return U.get.call(this);
1419
+ return Y.get.call(this);
1420
1420
  },
1421
1421
  set: function(p) {
1422
- if (!(R(this) && p === "hidden" && de))
1423
- return U.set.call(this, p);
1422
+ if (!(U(this) && p === "hidden" && de))
1423
+ return Y.set.call(this, p);
1424
1424
  }
1425
- }), Re = !0;
1425
+ }), Ue = !0;
1426
1426
  }
1427
- const zt = "/css/vehicle-search.css", Rt = zt;
1427
+ const zt = "/css/vehicle-search.css", Ut = zt;
1428
1428
  class St extends HTMLElement {
1429
1429
  connectedCallback() {
1430
1430
  if (!document.getElementById("vehicle-search-inter-font")) {
@@ -1433,13 +1433,13 @@ class St extends HTMLElement {
1433
1433
  }
1434
1434
  let f = document.createElement("style");
1435
1435
  f.textContent = xt;
1436
- const c = document.createElement("div"), D = this.attachShadow({ mode: "open" }), I = (C, v, i) => {
1436
+ const v = document.createElement("div"), D = this.attachShadow({ mode: "open" }), I = (C, h, i) => {
1437
1437
  let z;
1438
- if (this.hasAttribute(v)) {
1439
- const m = this.getAttribute(v);
1438
+ if (this.hasAttribute(h)) {
1439
+ const m = this.getAttribute(h);
1440
1440
  if (/^#[0-9A-F]{6}$/i.test(m)) {
1441
- const ee = parseInt(m.slice(1, 3), 16), Y = parseInt(m.slice(3, 5), 16), ie = parseInt(m.slice(5, 7), 16);
1442
- z = `${ee} ${Y} ${ie}`;
1441
+ const G = parseInt(m.slice(1, 3), 16), R = parseInt(m.slice(3, 5), 16), ie = parseInt(m.slice(5, 7), 16);
1442
+ z = `${G} ${R} ${ie}`;
1443
1443
  }
1444
1444
  }
1445
1445
  return z = z || i, `:host { --${C}: ${z}; }`;
@@ -1452,7 +1452,7 @@ class St extends HTMLElement {
1452
1452
  "partbot-button-color",
1453
1453
  "data-button-color",
1454
1454
  "99 102 241"
1455
- ), R = I(
1455
+ ), U = I(
1456
1456
  "partbot-button-hover-color",
1457
1457
  "data-button-hover-color",
1458
1458
  "79 70 229"
@@ -1460,7 +1460,7 @@ class St extends HTMLElement {
1460
1460
  "partbot-button-label-color",
1461
1461
  "data-button-label-color",
1462
1462
  "255 255 255"
1463
- ), U = I(
1463
+ ), Y = I(
1464
1464
  "partbot-button-hover-label-color",
1465
1465
  "data-button-hover-label-color",
1466
1466
  "255 255 255"
@@ -1468,29 +1468,29 @@ class St extends HTMLElement {
1468
1468
  "partbot-mobile-background-color",
1469
1469
  "data-mobile-background-color",
1470
1470
  "12 24 39"
1471
- ), X = `:host { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius") || "0.375rem"}}`, p = `:host { --partbot-font-size: ${this.getAttribute("data-font-size") || "0.875rem"}}`, w = `:host { --partbot-font-family: ${this.getAttribute("data-font") && this.getAttribute("data-font").trim() !== "" ? this.getAttribute("data-font") : '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}}`, y = `:host { --partbot-padding: ${this.getAttribute("data-padding") || "0.5rem"}}`;
1472
- f.textContent += F, f.textContent += A, f.textContent += R, f.textContent += k, f.textContent += U, f.textContent += B, f.textContent += X, f.textContent += p, f.textContent += w, f.textContent += y, D.appendChild(f), D.appendChild(c);
1471
+ ), W = `:host { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius") || "0.375rem"}}`, p = `:host { --partbot-font-size: ${this.getAttribute("data-font-size") || "0.875rem"}}`, w = `:host { --partbot-font-family: ${this.getAttribute("data-font") && this.getAttribute("data-font").trim() !== "" ? this.getAttribute("data-font") : '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}}`, y = `:host { --partbot-padding: ${this.getAttribute("data-padding") || "0.5rem"}}`;
1472
+ f.textContent += F, f.textContent += A, f.textContent += U, f.textContent += k, f.textContent += Y, f.textContent += B, f.textContent += W, f.textContent += p, f.textContent += w, f.textContent += y, D.appendChild(f), D.appendChild(v);
1473
1473
  const O = this.getAttribute("data-api-key");
1474
1474
  if (!O) {
1475
1475
  console.warn("Missing attributes: " + (O ? "" : "data-api-key "));
1476
1476
  return;
1477
1477
  }
1478
- const J = this.attributes, G = {};
1479
- for (let C = 0; C < J.length; C++) {
1480
- const { name: v, value: i } = J[C];
1481
- if (v.startsWith("data-")) {
1482
- const z = v.slice(5).replace(/-([a-z])/g, (m) => m[1].toUpperCase());
1483
- G[z] = i === "true" ? !0 : i === "false" ? !1 : i;
1478
+ const K = this.attributes, X = {};
1479
+ for (let C = 0; C < K.length; C++) {
1480
+ const { name: h, value: i } = K[C];
1481
+ if (h.startsWith("data-")) {
1482
+ const z = h.slice(5).replace(/-([a-z])/g, (m) => m[1].toUpperCase());
1483
+ X[z] = i === "true" ? !0 : i === "false" ? !1 : i;
1484
1484
  }
1485
1485
  }
1486
1486
  _t(this);
1487
- const x = /* @__PURE__ */ n(Ct, { ...G });
1488
- dt.render(x, c);
1487
+ const x = /* @__PURE__ */ n(Ct, { ...X });
1488
+ dt.render(x, v);
1489
1489
  }
1490
1490
  }
1491
1491
  customElements.define("vehicle-search", St);
1492
1492
  export {
1493
1493
  Ct as VehicleSearch,
1494
1494
  Ct as default,
1495
- Rt as vehicleSearchCssUrl
1495
+ Ut as vehicleSearchCssUrl
1496
1496
  };