@cartbot/vehicle-search-beta 3.0.22 → 3.0.24

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.
@@ -1,12 +1,12 @@
1
1
  import { jsx as a, jsxs as E, Fragment as $e } from "react/jsx-runtime";
2
- import { useState as A, useEffect as B, useRef as Z, useCallback as N, useMemo as mt } from "react";
3
- import ft from "react-dom";
4
- import Ke from "js-cookie";
2
+ import { useState as A, useEffect as B, useRef as Z, useCallback as N, useMemo as ut } from "react";
3
+ import mt from "react-dom";
4
+ import ft from "js-cookie";
5
5
  import { Combobox as gt, ComboboxInput as bt, ComboboxButton as wt, ComboboxOptions as yt, ComboboxOption as xt } from "@headlessui/react";
6
6
  import kt from "fuzzysearch";
7
- import Qe from "pluralize";
7
+ import Ke from "pluralize";
8
8
  import ne from "clsx";
9
- import { MeiliSearch as We } from "meilisearch";
9
+ import { MeiliSearch as Qe } from "meilisearch";
10
10
  import Ct from "lodash/debounce.js";
11
11
  import _t from "tinycolor2";
12
12
  import Be from "posthog-js";
@@ -117,43 +117,43 @@ function X({
117
117
  label: b,
118
118
  items: v,
119
119
  selected: p,
120
- refine: F,
120
+ refine: U,
121
121
  showPopular: I,
122
122
  bgDark: R,
123
123
  sortOptions: P = !0,
124
- showLabel: T = !1,
124
+ showLabel: O = !1,
125
125
  isMobile: _ = !1,
126
126
  loading: V = !1,
127
- shouldBeActive: O = !1
127
+ shouldBeActive: T = !1
128
128
  // True when parent fields are selected and this field tried to load
129
129
  }) {
130
- const [re, u] = A(""), [y, C] = A(p || null), q = (l) => {
131
- C(l), u(""), !(l && l.value === (p == null ? void 0 : p.value)) && F(l);
132
- }, ee = (l) => {
133
- l.preventDefault(), l.stopPropagation(), u(""), C(null), F("");
130
+ const [re, u] = A(""), [y, C] = A(p || null), q = (s) => {
131
+ C(s), u(""), !(s && s.value === (p == null ? void 0 : p.value)) && U(s);
132
+ }, ee = (s) => {
133
+ s.preventDefault(), s.stopPropagation(), u(""), C(null), U("");
134
134
  };
135
135
  B(() => {
136
136
  u(""), C(p || null);
137
137
  }, [p, v]);
138
138
  let G = /* @__PURE__ */ new Set(), f = [];
139
- v && (v.forEach((l) => {
140
- String(l.value).split(/,(?![^(]*\))/).forEach((z) => {
139
+ v && (v.forEach((s) => {
140
+ String(s.value).split(/,(?![^(]*\))/).forEach((z) => {
141
141
  z = z.trim(), z && kt(re, z.toLowerCase()) && !G.has(z.toLowerCase()) && (G.add(z.toLowerCase()), f.push({
142
- ...l,
142
+ ...s,
143
143
  value: z,
144
- refinement: l.value
144
+ refinement: s.value
145
145
  }));
146
146
  });
147
147
  }), f.length === 0 && (f = v));
148
- const D = f.filter((l) => l.popularity > 0).slice(0, 11);
148
+ const D = f.filter((s) => s.popularity > 0).slice(0, 11);
149
149
  P && (f = f.filter(
150
- (l) => !D.includes(l)
150
+ (s) => !D.includes(s)
151
151
  ), f.sort(
152
- (l, U) => l.value.localeCompare(U.value, "en", { numeric: !0 })
152
+ (s, F) => s.value.localeCompare(F.value, "en", { numeric: !0 })
153
153
  ), f = D.concat(f));
154
154
  const g = !f || f.length === 0;
155
155
  return /* @__PURE__ */ E("div", { className: "vs:relative vs:flex vs:flex-col", children: [
156
- T && /* @__PURE__ */ a(
156
+ O && /* @__PURE__ */ a(
157
157
  "span",
158
158
  {
159
159
  className: `${R ? "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)`,
@@ -164,11 +164,11 @@ function X({
164
164
  /* @__PURE__ */ E(
165
165
  "select",
166
166
  {
167
- onChange: (l) => {
168
- const U = f.find(
169
- (z) => z.value.toString() === l.target.value.toString()
167
+ onChange: (s) => {
168
+ const F = f.find(
169
+ (z) => z.value.toString() === s.target.value.toString()
170
170
  );
171
- U && q(U);
171
+ F && q(F);
172
172
  },
173
173
  className: "vehicle-search-select vs:relative vs:w-full vs:cursor-default vs:overflow-hidden vs:rounded-(--partbot-button-border-radius) partbot-input-border vs:bg-white vs:py-(--partbot-padding) vs:pl-[calc(var(--partbot-padding)*1.3)] vs:pr-10 vs:text-left vs:shadow-(--partbot-input-shadow) vs:focus:border-[rgb(var(--partbot-theme))] vs:focus:outline-none vs:focus:ring-1 vs:focus:ring-[rgb(var(--partbot-theme))] vs:disabled:opacity-100! vs:disabled:text-stone-400! vs:sm:text-(length:--partbot-font-size) vs:font-(family-name:--partbot-font-family) vs:text-(length:--partbot-font-size) vs:leading-[calc(var(--partbot-font-size)*1.5)]",
174
174
  tabIndex: -1,
@@ -177,13 +177,13 @@ function X({
177
177
  children: [
178
178
  /* @__PURE__ */ a("option", { value: "", disabled: !0, children: b }),
179
179
  D.length > 0 ? /* @__PURE__ */ E($e, { children: [
180
- /* @__PURE__ */ a("optgroup", { label: `Popular ${Qe(b)}`, children: D.map((l) => /* @__PURE__ */ a("option", { value: l.refinement, children: l.value }, l.value)) }),
181
- /* @__PURE__ */ a("optgroup", { label: `All ${Qe(b)}`, children: f.filter(
182
- (l) => !D.some(
183
- (U) => U.value === l.value
180
+ /* @__PURE__ */ a("optgroup", { label: `Popular ${Ke(b)}`, children: D.map((s) => /* @__PURE__ */ a("option", { value: s.refinement, children: s.value }, s.value)) }),
181
+ /* @__PURE__ */ a("optgroup", { label: `All ${Ke(b)}`, children: f.filter(
182
+ (s) => !D.some(
183
+ (F) => F.value === s.value
184
184
  )
185
- ).map((l) => /* @__PURE__ */ a("option", { value: l.refinement, children: l.value }, l.value)) })
186
- ] }) : f.map((l) => /* @__PURE__ */ a("option", { value: l.refinement, children: l.value }, l.value))
185
+ ).map((s) => /* @__PURE__ */ a("option", { value: s.refinement, children: s.value }, s.value)) })
186
+ ] }) : f.map((s) => /* @__PURE__ */ a("option", { value: s.refinement, children: s.value }, s.value))
187
187
  ]
188
188
  }
189
189
  ),
@@ -224,10 +224,10 @@ function X({
224
224
  {
225
225
  autoComplete: "off",
226
226
  spellCheck: "false",
227
- placeholder: g && O && !V ? "N/A" : b,
227
+ placeholder: g && T && !V ? "N/A" : b,
228
228
  className: "vs:w-full vs:cursor-default vs:rounded-(--partbot-button-border-radius) partbot-input-border vs:bg-white vs:py-(--partbot-padding) vs:pl-[calc(var(--partbot-padding)*1.3)] vs:pr-10 vs:text-left vs:shadow-(--partbot-input-shadow) 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
- displayValue: (l) => (l == null ? void 0 : l.value) || "",
230
- onChange: (l) => u(l.target.value),
229
+ displayValue: (s) => (s == null ? void 0 : s.value) || "",
230
+ onChange: (s) => u(s.target.value),
231
231
  title: b
232
232
  }
233
233
  ),
@@ -272,31 +272,31 @@ function X({
272
272
  portal: !0,
273
273
  anchor: "bottom start",
274
274
  className: "vs:w-(--input-width) vs:z-99999! vs:max-h-60! vs:overflow-auto vs:rounded-[min(var(--partbot-button-border-radius),0.89rem)] vs:bg-white vs:py-1 vs:text-base vs:shadow-lg vs:ring-1 vs:ring-stone-200 vs:focus:outline-none vs:sm:text-(length:--partbot-font-size) empty:vs:invisible vs:mt-2",
275
- children: ({ option: l }) => {
276
- const U = l && D.some(
277
- (z) => z.value === l.value
275
+ children: ({ option: s }) => {
276
+ const F = s && D.some(
277
+ (z) => z.value === s.value
278
278
  );
279
279
  return /* @__PURE__ */ a(
280
280
  xt,
281
281
  {
282
- value: l,
282
+ value: s,
283
283
  className: ({ focus: z }) => ne(
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
  z ? "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
- U && "vs:font-bold!"
286
+ F && "vs:font-bold!"
287
287
  ),
288
288
  children: ({ selected: z }) => /* @__PURE__ */ E("div", { className: "vs:flex vs:w-full vs:items-center vs:justify-between", children: [
289
289
  /* @__PURE__ */ a(
290
290
  "span",
291
291
  {
292
292
  className: ne(
293
- l.value === (p == null ? void 0 : p.value) ? "vs:font-semibold" : "vs:font-normal",
293
+ s.value === (p == null ? void 0 : p.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
- children: l.value
296
+ children: s.value
297
297
  }
298
298
  ),
299
- l.value === (p == null ? void 0 : p.value) && /* @__PURE__ */ a(
299
+ s.value === (p == null ? void 0 : p.value) && /* @__PURE__ */ a(
300
300
  "span",
301
301
  {
302
302
  className: ne(
@@ -328,39 +328,39 @@ function X({
328
328
  )
329
329
  ] });
330
330
  }
331
- const $t = "3.0.22";
331
+ const $t = "3.0.24";
332
332
  console.info(
333
333
  `Vehicle Search v${$t} powered by Partbot https://mmyvs.partbot.io`
334
334
  );
335
335
  function Se(b = [], v = []) {
336
336
  const p = [];
337
- return b.forEach((F) => {
338
- const [I, ...R] = F.split(":"), P = R.join(":");
337
+ return b.forEach((U) => {
338
+ const [I, ...R] = U.split(":"), P = R.join(":");
339
339
  if (P.includes(" > ")) {
340
- const T = P.split(" > "), _ = T[T.length - 1].trim();
341
- if (I !== "make" && T.length >= 2) {
342
- const V = T[0].trim();
340
+ const O = P.split(" > "), _ = O[O.length - 1].trim();
341
+ if (I !== "make" && O.length >= 2) {
342
+ const V = O[0].trim();
343
343
  p.push(`make = "${V}"`);
344
344
  }
345
345
  p.push(`${I} = "${_}"`);
346
346
  } else
347
347
  p.push(`${I} = "${P}"`);
348
- }), v.forEach((F) => {
349
- p.push(F);
348
+ }), v.forEach((U) => {
349
+ p.push(U);
350
350
  }), p.length > 0 ? p.join(" AND ") : null;
351
351
  }
352
352
  function Mt({
353
353
  apiKey: b,
354
354
  makes: v = "",
355
355
  models: p = "",
356
- callbackUrl: F = "",
356
+ callbackUrl: U = "",
357
357
  layout: I = "row",
358
358
  fields: R,
359
359
  fieldPrefix: P = "",
360
- showBranding: T = !0,
360
+ showBranding: O = !0,
361
361
  showLabels: _ = !1,
362
362
  mobileFullWidthButton: V = !0,
363
- mobileDrawer: O = !0,
363
+ mobileDrawer: T = !0,
364
364
  modifyQueryString: re = !0,
365
365
  onChange: u,
366
366
  buttonLabel: y = "Search",
@@ -374,10 +374,10 @@ function Mt({
374
374
  // Use api.cartbot.io instead of api.partbot.io
375
375
  yearOptional: g = !1,
376
376
  // Make year selection optional, only requiring make + model
377
- mobileButtonLabel: l = "Select Vehicle"
377
+ mobileButtonLabel: s = "Select Vehicle"
378
378
  // Label for mobile drawer trigger button
379
379
  }) {
380
- const U = Z(null), z = Z(null), ie = Z(null), S = Z(null), K = Z(null), j = Z(null), Q = Z(null), w = Z(null), W = Z(null), M = Z(!1), x = f === "YMM", [le, ve] = A([]), [fe, ce] = A([]), [de, he] = A([]), [Le, ge] = A([]), [Ie, be] = A([]), [Ve, we] = A([]), [De, ye] = A([]), [Ue, xe] = A([]), Xe = Z([]), [se, ke] = A([]), [e, Y] = A({
380
+ const F = Z(null), z = Z(null), ie = Z(null), S = Z(null), K = Z(null), j = Z(null), Q = Z(null), w = Z(null), W = Z(null), M = Z(!1), x = f === "YMM", [le, ve] = A([]), [fe, ce] = A([]), [de, he] = A([]), [Le, ge] = A([]), [Ie, be] = A([]), [Ve, we] = A([]), [De, ye] = A([]), [Fe, xe] = A([]), Je = Z([]), [se, ke] = A([]), [e, Y] = A({
381
381
  make: null,
382
382
  model: null,
383
383
  year: null,
@@ -386,21 +386,21 @@ function Mt({
386
386
  variant: null,
387
387
  engine: null,
388
388
  engine_capacity: null
389
- }), [Ge, Me] = A(!1), Fe = Z([
389
+ }), [Xe, Me] = A(!1), Ue = Z([
390
390
  "body",
391
391
  "series",
392
392
  "variant",
393
393
  "engine",
394
394
  "engine_capacity"
395
395
  ]), Ce = Z(
396
- R && R.length && Fe.current ? R.split(",").filter((t) => {
396
+ R && R.length && Ue.current ? R.split(",").filter((t) => {
397
397
  var r;
398
- return (r = Fe.current) == null ? void 0 : r.includes(t);
398
+ return (r = Ue.current) == null ? void 0 : r.includes(t);
399
399
  }) : null
400
- ), [J, et] = A(!1);
400
+ ), [J, Ge] = A(!1);
401
401
  B(() => {
402
402
  const t = navigator.userAgent;
403
- et(
403
+ Ge(
404
404
  /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
405
405
  t
406
406
  )
@@ -412,7 +412,7 @@ function Mt({
412
412
  disable_session_recording: !1
413
413
  });
414
414
  }, []);
415
- const [oe, tt] = A({}), [Nt, rt] = A(""), Re = N(async () => {
415
+ const [oe, et] = A({}), [Nt, tt] = A(""), Re = N(async () => {
416
416
  if (!b)
417
417
  return;
418
418
  const r = `${D ? "https://api.cartbot.io" : "https://api.partbot.io"}/v1/vehicles/auth`;
@@ -435,7 +435,7 @@ function Mt({
435
435
  throw new Error(`Error: ${i.status} ${i.statusText}`);
436
436
  const {
437
437
  merchant: o,
438
- vehicle_makes: s,
438
+ vehicle_makes: l,
439
439
  vehicle_models: n,
440
440
  meilisearch_search_key: c,
441
441
  meilisearch_index_name: d,
@@ -449,15 +449,15 @@ function Mt({
449
449
  store_popular_models: h
450
450
  // Object mapping makes to popular models: { "TOYOTA": ["HILUX", "LANDCRUISER"], ... }
451
451
  } = await i.json();
452
- z.current = o, ie.current = (s || []).map((m) => ({
452
+ z.current = o, ie.current = (l || []).map((m) => ({
453
453
  ...m,
454
454
  refinement: m.value
455
- })), G && n ? typeof n == "object" && !Array.isArray(n) ? S.current = n : Array.isArray(n) ? S.current = n.map((m) => m && m.value ? String(m.value).trim() : "").filter(Boolean) : S.current = [] : S.current = [], K.current = Array.isArray(ae) ? ae.map((m) => String(m).trim().toUpperCase()) : null, j.current = h || null, tt({
455
+ })), G && n ? typeof n == "object" && !Array.isArray(n) ? S.current = n : Array.isArray(n) ? S.current = n.map((m) => m && m.value ? String(m.value).trim() : "").filter(Boolean) : S.current = [] : S.current = [], K.current = Array.isArray(ae) ? ae.map((m) => String(m).trim().toUpperCase()) : null, j.current = h || null, et({
456
456
  searchKey: "eeace38b64f52bf56ebb4fe8bd5837b3cd6c0ff9d7e272f76449d94b80cba86b",
457
457
  indexName: "otto_v1_vehicles_production"
458
458
  });
459
459
  } catch (i) {
460
- console.error("[VehicleSearch] Auth failed:", i), rt(i);
460
+ console.error("[VehicleSearch] Auth failed:", i), tt(i);
461
461
  }
462
462
  }, [b, ee, G, D]);
463
463
  B(() => {
@@ -465,11 +465,11 @@ function Mt({
465
465
  }, [Re]), B(() => {
466
466
  if (oe.searchKey) {
467
467
  try {
468
- Q.current = new We({
468
+ Q.current = new Qe({
469
469
  host: "https://search.partbot.io",
470
470
  apiKey: oe.searchKey
471
471
  }), w.current = Q.current.index(oe.indexName);
472
- const t = new We({
472
+ const t = new Qe({
473
473
  host: "https://partbot-meilisearch-cache.partbot.workers.dev",
474
474
  // Cloudflare Worker endpoint
475
475
  apiKey: oe.searchKey
@@ -483,7 +483,7 @@ function Mt({
483
483
  };
484
484
  }
485
485
  }, [oe.searchKey, b]);
486
- const [H, ot] = A(!1), Te = N(() => {
486
+ const [H, rt] = A(!1), Oe = N(() => {
487
487
  function t(n) {
488
488
  if (!n) return "rgba(0,0,0,1)";
489
489
  var c = r(), d = window.getComputedStyle(n).backgroundColor;
@@ -497,9 +497,9 @@ function Mt({
497
497
  }
498
498
  const i = document.querySelector("vehicle-search");
499
499
  let o;
500
- i ? o = t(i) : o = t(U.current);
501
- const s = _t(o).isDark();
502
- ot(s);
500
+ i ? o = t(i) : o = t(F.current);
501
+ const l = _t(o).isDark();
502
+ rt(l);
503
503
  }, []);
504
504
  B(() => {
505
505
  async function t() {
@@ -516,13 +516,13 @@ function Mt({
516
516
  ), e.series && r.push(`series:${e.series.refinement}`), e.engine && r.push(`engine:${e.engine.refinement}`), e.engine_capacity && r.push(
517
517
  `engine_capacity:${e.engine_capacity.refinement}`
518
518
  );
519
- let s = (await w.current.search("", {
519
+ let l = (await w.current.search("", {
520
520
  filter: Se(r, i),
521
521
  attributesToRetrieve: ["otto_id"],
522
522
  limit: 500
523
523
  // Reduced from 1000 for faster queries
524
524
  })).hits.map((d) => d.otto_id);
525
- ke(s);
525
+ ke(l);
526
526
  let c = {
527
527
  ...Object.fromEntries(
528
528
  Object.entries(e || {}).map(([d, $]) => [d, $ && $.value || null]).filter(([d, $]) => $ !== null)
@@ -533,7 +533,7 @@ function Mt({
533
533
  }
534
534
  t();
535
535
  }, [e, w, g]);
536
- const Ae = (t) => P ? `${P}${t}` : t, at = (t) => P ? t.replace(new RegExp(`^${P}`), "") : t, nt = N(() => {
536
+ const Ae = (t) => P ? `${P}${t}` : t, ot = (t) => P ? t.replace(new RegExp(`^${P}`), "") : t, at = N(() => {
537
537
  const t = new URL(window.location.href).searchParams, r = [
538
538
  "make",
539
539
  "model",
@@ -543,7 +543,7 @@ function Mt({
543
543
  "engine",
544
544
  "engine_capacity"
545
545
  ].map(Ae), i = Object.fromEntries(
546
- [...t.entries()].filter(([o]) => r.includes(o)).map(([o, s]) => [at(o), { value: s, refinement: s }])
546
+ [...t.entries()].filter(([o]) => r.includes(o)).map(([o, l]) => [ot(o), { value: l, refinement: l }])
547
547
  );
548
548
  Y(i);
549
549
  }, []), L = N(({ query: t, value: r, remove: i }) => {
@@ -552,10 +552,10 @@ function Mt({
552
552
  t = Ae(t), t && r && o.set(t, r), t && !r && o.delete(t), i && i.forEach((n) => {
553
553
  n = Ae(n), o.delete(n);
554
554
  });
555
- const s = window.location.pathname + "?" + o.toString();
556
- window.history.pushState(null, "", s);
555
+ const l = window.location.pathname + "?" + o.toString();
556
+ window.history.pushState(null, "", l);
557
557
  }
558
- }, []), it = N(() => {
558
+ }, []), nt = N(() => {
559
559
  var i;
560
560
  const t = {
561
561
  vehicle_ids: se,
@@ -568,8 +568,8 @@ function Mt({
568
568
  window.dispatchEvent(r), document.dispatchEvent(r), setTimeout(() => {
569
569
  Me(!1);
570
570
  }, 900);
571
- }, [se, q]), Oe = N(() => {
572
- var i, o, s, n, c, d, $, te, pe;
571
+ }, [se, q]), Te = N(() => {
572
+ var i, o, l, n, c, d, $, te, pe;
573
573
  const t = {
574
574
  vehicle_ids: se,
575
575
  vehicle: (i = e == null ? void 0 : e.make) != null && i.value ? e : {},
@@ -583,23 +583,23 @@ function Mt({
583
583
  if (M.current === !0) {
584
584
  localStorage.removeItem("partbot_plate_details");
585
585
  const ae = JSON.stringify({
586
- description: `${((o = e.make) == null ? void 0 : o.value) || ""} ${((s = e.model) == null ? void 0 : s.value) || ""} ${((n = e.year) == null ? void 0 : n.value) || ""} ${((c = e.body) == null ? void 0 : c.value) || ""} ${((d = e.series) == null ? void 0 : d.value) || ""} ${(($ = e.variant) == null ? void 0 : $.value) || ""} ${((te = e.engine) == null ? void 0 : te.value) || ""} ${((pe = e.engine_capacity) == null ? void 0 : pe.value) || ""}`.trim(),
586
+ description: `${((o = e.make) == null ? void 0 : o.value) || ""} ${((l = e.model) == null ? void 0 : l.value) || ""} ${((n = e.year) == null ? void 0 : n.value) || ""} ${((c = e.body) == null ? void 0 : c.value) || ""} ${((d = e.series) == null ? void 0 : d.value) || ""} ${(($ = e.variant) == null ? void 0 : $.value) || ""} ${((te = e.engine) == null ? void 0 : te.value) || ""} ${((pe = e.engine_capacity) == null ? void 0 : pe.value) || ""}`.trim(),
587
587
  vehicle_ids: se,
588
588
  vehicle: e ? Object.entries(e).reduce((h, [m, k]) => (h[m] = k != null && k.value ? k.value : {}, h), {}) : {}
589
589
  });
590
590
  localStorage.setItem(
591
591
  "partbot_selected_vehicle",
592
592
  ae
593
- ), Ke.set("partbot_selected_vehicle", ae, {
593
+ ), ft.set("partbot_selected_vehicle", ae, {
594
594
  secure: !0
595
595
  });
596
596
  }
597
- window.dispatchEvent(r), document.dispatchEvent(r), Xe.current = se, setTimeout(() => {
597
+ window.dispatchEvent(r), document.dispatchEvent(r), Je.current = se, setTimeout(() => {
598
598
  Me(!1);
599
599
  }, 900);
600
- }, [se, u]), _e = mt(
601
- () => Ct(Oe, 100),
602
- [Oe]
600
+ }, [se, u]), _e = ut(
601
+ () => Ct(Te, 100),
602
+ [Te]
603
603
  );
604
604
  B(() => {
605
605
  _e();
@@ -607,20 +607,7 @@ function Mt({
607
607
  _e.cancel();
608
608
  }, [_e]), B(() => {
609
609
  const t = () => {
610
- M.current = !1, localStorage.removeItem("partbot_selected_vehicle"), Ke.remove("partbot_selected_vehicle");
611
- const r = new URL(window.location.href), i = [
612
- "make",
613
- "model",
614
- "year",
615
- "body",
616
- "series",
617
- "variant",
618
- "engine"
619
- ];
620
- let o = !1;
621
- i.forEach((s) => {
622
- r.searchParams.has(s) && (r.searchParams.delete(s), o = !0);
623
- }), o && window.history.replaceState(null, "", r.toString()), Y({
610
+ M.current = !1, Y({
624
611
  make: null,
625
612
  model: null,
626
613
  year: null,
@@ -638,14 +625,14 @@ function Mt({
638
625
  );
639
626
  };
640
627
  }, []), B(() => {
641
- oe.searchKey && (x || vt(), nt());
628
+ oe.searchKey && (x || pt(), at());
642
629
  }, [oe.searchKey, x]), B(() => {
643
630
  x && w.current && de.length === 0 && !e.year && w.current.search("", {
644
631
  attributesToRetrieve: ["year_from", "year_to"],
645
632
  limit: 1e4
646
633
  }).then(({ hits: t }) => {
647
- const r = t.map((c) => c.year_from).filter(Boolean), i = t.map((c) => c.year_to).filter(Boolean), o = Math.min(...r), s = Math.max(...i), n = Array.from(
648
- { length: s - o + 1 },
634
+ const r = t.map((c) => c.year_from).filter(Boolean), i = t.map((c) => c.year_to).filter(Boolean), o = Math.min(...r), l = Math.max(...i), n = Array.from(
635
+ { length: l - o + 1 },
649
636
  (c, d) => ({ value: o + d, refinement: o + d })
650
637
  ).reverse();
651
638
  he(n);
@@ -653,8 +640,8 @@ function Mt({
653
640
  console.error("[VehicleSearch] Error loading year range:", t);
654
641
  });
655
642
  }, [x, oe.searchKey, de.length, e.year]), B(() => {
656
- typeof document > "u" || Te();
657
- }, [Te]);
643
+ typeof document > "u" || Oe();
644
+ }, [Oe]);
658
645
  const Ze = N(
659
646
  (t) => {
660
647
  M.current = !0, ce([]), !x && !g && he([]), ge([]), be([]), we([]), xe([]), ye([]), Y((r) => ({
@@ -738,7 +725,7 @@ function Mt({
738
725
  }), !g && (!t || t === "") && ke([]);
739
726
  },
740
727
  [L, x, g]
741
- ), st = N(
728
+ ), it = N(
742
729
  (t) => {
743
730
  M.current = !0, Y((r) => ({
744
731
  ...r,
@@ -749,7 +736,7 @@ function Mt({
749
736
  });
750
737
  },
751
738
  [L]
752
- ), lt = N(
739
+ ), st = N(
753
740
  (t) => {
754
741
  M.current = !0, Y((r) => ({
755
742
  ...r,
@@ -760,7 +747,7 @@ function Mt({
760
747
  });
761
748
  },
762
749
  [L]
763
- ), ct = N(
750
+ ), lt = N(
764
751
  (t) => {
765
752
  M.current = !0, Y((r) => ({
766
753
  ...r,
@@ -771,7 +758,7 @@ function Mt({
771
758
  });
772
759
  },
773
760
  [L]
774
- ), dt = N(
761
+ ), ct = N(
775
762
  (t) => {
776
763
  M.current = !0, Y((r) => ({
777
764
  ...r,
@@ -782,7 +769,7 @@ function Mt({
782
769
  });
783
770
  },
784
771
  [L]
785
- ), pt = N(
772
+ ), dt = N(
786
773
  (t) => {
787
774
  M.current = !0, Y((r) => ({
788
775
  ...r,
@@ -810,9 +797,9 @@ function Mt({
810
797
  });
811
798
  });
812
799
  let o = Array.from(i.values());
813
- const s = new Set(K.current || []);
814
- s.size > 0 ? o.sort((n, c) => {
815
- const d = s.has(n.value), $ = s.has(c.value);
800
+ const l = new Set(K.current || []);
801
+ l.size > 0 ? o.sort((n, c) => {
802
+ const d = l.has(n.value), $ = l.has(c.value);
816
803
  return d && !$ ? -1 : !d && $ ? 1 : d && $ ? K.current.indexOf(n.value) - K.current.indexOf(c.value) : n.value.localeCompare(c.value);
817
804
  }) : o.sort(
818
805
  (n, c) => c.popularity === n.popularity ? n.value.localeCompare(c.value) : c.popularity - n.popularity
@@ -822,7 +809,7 @@ function Mt({
822
809
  }
823
810
  })();
824
811
  }, [x, e.year]);
825
- const vt = N(() => {
812
+ const pt = N(() => {
826
813
  (async () => {
827
814
  let r = [];
828
815
  if (ie.current && ie.current.length)
@@ -833,11 +820,11 @@ function Mt({
833
820
  attributesToRetrieve: ["make", "make_popularity"],
834
821
  limit: 1e3
835
822
  }), o = /* @__PURE__ */ new Map();
836
- i.hits.forEach((s) => {
837
- s.make && !o.has(s.make) && o.set(s.make, {
838
- value: s.make.toUpperCase(),
839
- refinement: s.make.toUpperCase(),
840
- popularity: s.make_popularity || 0
823
+ i.hits.forEach((l) => {
824
+ l.make && !o.has(l.make) && o.set(l.make, {
825
+ value: l.make.toUpperCase(),
826
+ refinement: l.make.toUpperCase(),
827
+ popularity: l.make_popularity || 0
841
828
  });
842
829
  }), r = Array.from(o.values());
843
830
  } catch (i) {
@@ -851,9 +838,9 @@ function Mt({
851
838
  }
852
839
  if (K.current && K.current.length > 0) {
853
840
  const i = new Set(K.current);
854
- r.sort((o, s) => {
855
- const n = i.has(o.value), c = i.has(s.value);
856
- return n && !c ? -1 : !n && c ? 1 : n && c ? K.current.indexOf(o.value) - K.current.indexOf(s.value) : o.value.localeCompare(s.value);
841
+ r.sort((o, l) => {
842
+ const n = i.has(o.value), c = i.has(l.value);
843
+ return n && !c ? -1 : !n && c ? 1 : n && c ? K.current.indexOf(o.value) - K.current.indexOf(l.value) : o.value.localeCompare(l.value);
857
844
  });
858
845
  } else
859
846
  r.sort((i, o) => i.popularity === o.popularity ? i.value.localeCompare(o.value) : o.popularity - i.popularity);
@@ -866,26 +853,26 @@ function Mt({
866
853
  const r = e.make.refinement;
867
854
  if (G && typeof S.current == "object" && !Array.isArray(S.current) && S.current[r]) {
868
855
  const i = S.current[r].map(
869
- (s) => ({
870
- value: s,
871
- refinement: s,
856
+ (l) => ({
857
+ value: l,
858
+ refinement: l,
872
859
  popularity: 0
873
860
  // Popularity will be used from PostHog for sorting
874
861
  })
875
862
  ), o = (t = j.current) == null ? void 0 : t[r];
876
863
  if (o && Array.isArray(o)) {
877
- const s = new Map(
864
+ const l = new Map(
878
865
  o.map((n, c) => [
879
866
  n.toUpperCase(),
880
867
  o.length - c
881
868
  ])
882
869
  );
883
870
  i.sort((n, c) => {
884
- const d = s.get(n.value.toUpperCase()) || 0, $ = s.get(c.value.toUpperCase()) || 0;
871
+ const d = l.get(n.value.toUpperCase()) || 0, $ = l.get(c.value.toUpperCase()) || 0;
885
872
  return d !== $ ? $ - d : n.value.localeCompare(c.value);
886
873
  });
887
874
  } else
888
- i.sort((s, n) => s.value.localeCompare(n.value));
875
+ i.sort((l, n) => l.value.localeCompare(n.value));
889
876
  ce(i);
890
877
  return;
891
878
  }
@@ -898,9 +885,9 @@ function Mt({
898
885
  }).then((i) => {
899
886
  var pe, ae;
900
887
  const { hits: o } = i;
901
- let s = [];
902
- o.length > 0 && o[0].models && (s = o[0].models);
903
- let n = s.map((h) => ({
888
+ let l = [];
889
+ o.length > 0 && o[0].models && (l = o[0].models);
890
+ let n = l.map((h) => ({
904
891
  model: `${e.make.refinement} > ${h.name}`,
905
892
  model_popularity: h.popularity || 0
906
893
  })), c = [];
@@ -948,7 +935,7 @@ function Mt({
948
935
  if (!je && Ne) return 1;
949
936
  if (je && Ne) {
950
937
  const qe = te.map(
951
- (ut) => String(ut).trim().toUpperCase()
938
+ (ht) => String(ht).trim().toUpperCase()
952
939
  );
953
940
  return qe.indexOf(m.value) - qe.indexOf(k.value);
954
941
  }
@@ -984,7 +971,7 @@ function Mt({
984
971
  limit: 200
985
972
  // Reduced from 1000 for faster queries
986
973
  }).then(({ hits: r }) => {
987
- const i = r.map((d) => d.year_from), o = Math.min(...i), s = r.map((d) => d.year_to), n = Math.max(...s);
974
+ const i = r.map((d) => d.year_from), o = Math.min(...i), l = r.map((d) => d.year_to), n = Math.max(...l);
988
975
  let c = Array.apply(null, {
989
976
  length: n + 1 - o
990
977
  }).map(function(d, $) {
@@ -1028,13 +1015,13 @@ function Mt({
1028
1015
  }, [e.year, e.make, e.model, g]);
1029
1016
  const ue = N(({ hits: t, attribute: r, stateCallback: i }) => {
1030
1017
  let o = [
1031
- ...new Map(t.map((s) => [s[r], s])).values()
1032
- ].map((s) => ({
1033
- value: s[r].match(/[^|]*$/)[0].trim(),
1034
- refinement: s[r].match(/[^|]*$/)[0].trim()
1035
- })).filter((s) => s.refinement);
1018
+ ...new Map(t.map((l) => [l[r], l])).values()
1019
+ ].map((l) => ({
1020
+ value: l[r].match(/[^|]*$/)[0].trim(),
1021
+ refinement: l[r].match(/[^|]*$/)[0].trim()
1022
+ })).filter((l) => l.refinement);
1036
1023
  i(o);
1037
- }, []), ht = N(() => {
1024
+ }, []), vt = N(() => {
1038
1025
  const t = Ce.current ? Ce.current.length + 3 : 3, r = C ? t + 1 : t;
1039
1026
  return `vs:lg:grid-cols-${r > 8 ? 8 : r}`;
1040
1027
  }, [C]);
@@ -1099,12 +1086,12 @@ function Mt({
1099
1086
  ]);
1100
1087
  const [ze, Ee] = A(!1);
1101
1088
  return B(() => {
1102
- if (O)
1089
+ if (T)
1103
1090
  return ze ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
1104
1091
  document.body.style.overflow = "";
1105
1092
  };
1106
- }, [ze, O]), /* @__PURE__ */ E($e, { children: [
1107
- O && /* @__PURE__ */ a(
1093
+ }, [ze, T]), /* @__PURE__ */ E($e, { children: [
1094
+ T && /* @__PURE__ */ a(
1108
1095
  "button",
1109
1096
  {
1110
1097
  onClick: () => Ee(!0),
@@ -1113,10 +1100,10 @@ function Mt({
1113
1100
  "vehicle-search-btn vs:md:hidden!",
1114
1101
  V ? "vs:w-full! vs:flex! vs:shrink-0!" : "vs:w-auto! vs:inline-flex! vs:shrink!"
1115
1102
  ),
1116
- children: /* @__PURE__ */ a("span", { children: l })
1103
+ children: /* @__PURE__ */ a("span", { children: s })
1117
1104
  }
1118
1105
  ),
1119
- O && /* @__PURE__ */ a(
1106
+ T && /* @__PURE__ */ a(
1120
1107
  "div",
1121
1108
  {
1122
1109
  onClick: () => Ee(!1),
@@ -1131,11 +1118,11 @@ function Mt({
1131
1118
  {
1132
1119
  className: ne(
1133
1120
  "partbot-mmyvs-container",
1134
- O && ze && "active",
1121
+ T && ze && "active",
1135
1122
  "w-full"
1136
1123
  ),
1137
1124
  children: [
1138
- O && /* @__PURE__ */ E("div", { className: "vs:flex vs:justify-between vs:items-center vs:pb-4 vs:font-bold vs:text-white vs:md:hidden", children: [
1125
+ T && /* @__PURE__ */ E("div", { className: "vs:flex vs:justify-between vs:items-center vs:pb-4 vs:font-bold vs:text-white vs:md:hidden", children: [
1139
1126
  /* @__PURE__ */ a("span", { children: "Select Vehicle" }),
1140
1127
  /* @__PURE__ */ E(
1141
1128
  "button",
@@ -1162,10 +1149,10 @@ function Mt({
1162
1149
  /* @__PURE__ */ E(
1163
1150
  "div",
1164
1151
  {
1165
- ref: U,
1152
+ ref: F,
1166
1153
  className: ne(
1167
1154
  "vs:grid vs:gap-3",
1168
- I === "row" ? `${ht()} vs:grid-cols-1 vs:md:grid-cols-3` : "vs:grid-cols-1 vs:md:max-w-[400px] vs:md:gap-5",
1155
+ I === "row" ? `${vt()} vs:grid-cols-1 vs:md:grid-cols-3` : "vs:grid-cols-1 vs:md:max-w-[400px] vs:md:gap-5",
1169
1156
  "vs:w-full vs:transition vs:lg:mx-auto"
1170
1157
  ),
1171
1158
  children: [
@@ -1275,7 +1262,7 @@ function Mt({
1275
1262
  {
1276
1263
  label: "Body",
1277
1264
  items: Le,
1278
- refine: st,
1265
+ refine: it,
1279
1266
  selected: e.body,
1280
1267
  bgDark: H,
1281
1268
  showLabel: _,
@@ -1292,7 +1279,7 @@ function Mt({
1292
1279
  {
1293
1280
  label: "Series",
1294
1281
  items: Ie,
1295
- refine: lt,
1282
+ refine: st,
1296
1283
  selected: e.series,
1297
1284
  bgDark: H,
1298
1285
  showLabel: _,
@@ -1309,7 +1296,7 @@ function Mt({
1309
1296
  {
1310
1297
  label: "Variant",
1311
1298
  items: Ve,
1312
- refine: ct,
1299
+ refine: lt,
1313
1300
  selected: e.variant,
1314
1301
  bgDark: H,
1315
1302
  showLabel: _,
@@ -1325,13 +1312,13 @@ function Mt({
1325
1312
  X,
1326
1313
  {
1327
1314
  label: "Engine Capacity",
1328
- items: Ue,
1329
- refine: pt,
1315
+ items: Fe,
1316
+ refine: dt,
1330
1317
  selected: e.engine_capacity,
1331
1318
  bgDark: H,
1332
1319
  showLabel: _,
1333
1320
  isMobile: J,
1334
- loading: !!(e.make && e.model && e.year) && Ue.length === 0,
1321
+ loading: !!(e.make && e.model && e.year) && Fe.length === 0,
1335
1322
  shouldBeActive: !!(e.make && e.model && e.year)
1336
1323
  },
1337
1324
  "engine_capacity"
@@ -1343,7 +1330,7 @@ function Mt({
1343
1330
  {
1344
1331
  label: "Engine",
1345
1332
  items: De,
1346
- refine: dt,
1333
+ refine: ct,
1347
1334
  selected: e.engine,
1348
1335
  bgDark: H,
1349
1336
  showLabel: _,
@@ -1362,18 +1349,18 @@ function Mt({
1362
1349
  {
1363
1350
  className: "vehicle-search-btn",
1364
1351
  onClick: () => {
1365
- Me(!0), F && !q ? window.location.href = F + window.location.search : it();
1352
+ Me(!0), U && !q ? window.location.href = U + window.location.search : nt();
1366
1353
  },
1367
1354
  children: [
1368
1355
  /* @__PURE__ */ a("span", { children: y }),
1369
- Ge && /* @__PURE__ */ a(Pe, { className: "vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin" })
1356
+ Xe && /* @__PURE__ */ a(Pe, { className: "vs:w-[calc(var(--partbot-font-size)*0.9)]! vs:h-[calc(var(--partbot-font-size)*0.9)]! vs:animate-spin" })
1370
1357
  ]
1371
1358
  }
1372
1359
  ) })
1373
1360
  ]
1374
1361
  }
1375
1362
  ),
1376
- T && /* @__PURE__ */ a(
1363
+ O && /* @__PURE__ */ a(
1377
1364
  "div",
1378
1365
  {
1379
1366
  className: ne(
@@ -1402,9 +1389,9 @@ function Mt({
1402
1389
  )
1403
1390
  ] });
1404
1391
  }
1405
- let Je = !1, me = !1;
1392
+ let We = !1, me = !1;
1406
1393
  function At(b) {
1407
- var O, re;
1394
+ var T, re;
1408
1395
  const v = b.shadowRoot;
1409
1396
  if (!v) {
1410
1397
  console.error("[ShadowDOMPatch] No shadow root found");
@@ -1438,12 +1425,12 @@ function At(b) {
1438
1425
  }).observe(p, {
1439
1426
  childList: !0,
1440
1427
  subtree: !0
1441
- }), Je)
1428
+ }), We)
1442
1429
  return;
1443
- const R = (O = Object.getOwnPropertyDescriptor(
1430
+ const R = (T = Object.getOwnPropertyDescriptor(
1444
1431
  Document.prototype,
1445
1432
  "activeElement"
1446
- )) == null ? void 0 : O.get;
1433
+ )) == null ? void 0 : T.get;
1447
1434
  Object.defineProperty(Document.prototype, "activeElement", {
1448
1435
  get: function() {
1449
1436
  const u = R == null ? void 0 : R.call(this);
@@ -1460,7 +1447,7 @@ function At(b) {
1460
1447
  return u === b ? this.composedPath()[0] : u;
1461
1448
  }
1462
1449
  });
1463
- const T = (u) => {
1450
+ const O = (u) => {
1464
1451
  try {
1465
1452
  return document.body && u === document.body.style;
1466
1453
  } catch {
@@ -1468,7 +1455,7 @@ function At(b) {
1468
1455
  }
1469
1456
  }, _ = CSSStyleDeclaration.prototype.setProperty;
1470
1457
  CSSStyleDeclaration.prototype.setProperty = function(u, y, C) {
1471
- if (!(T(this) && u === "overflow" && y === "hidden" && me))
1458
+ if (!(O(this) && u === "overflow" && y === "hidden" && me))
1472
1459
  return _.call(this, u, y, C);
1473
1460
  };
1474
1461
  const V = Object.getOwnPropertyDescriptor(
@@ -1480,10 +1467,10 @@ function At(b) {
1480
1467
  return V.get.call(this);
1481
1468
  },
1482
1469
  set: function(u) {
1483
- if (!(T(this) && u === "hidden" && me))
1470
+ if (!(O(this) && u === "hidden" && me))
1484
1471
  return V.set.call(this, u);
1485
1472
  }
1486
- }), Je = !0;
1473
+ }), We = !0;
1487
1474
  }
1488
1475
  const Et = "/css/vehicle-search.css", Yt = Et;
1489
1476
  class jt extends HTMLElement {
@@ -1494,7 +1481,7 @@ class jt extends HTMLElement {
1494
1481
  }
1495
1482
  let v = document.createElement("style");
1496
1483
  v.textContent = zt;
1497
- const p = document.createElement("div"), F = this.attachShadow({ mode: "open" }), I = (j, Q, w) => {
1484
+ const p = document.createElement("div"), U = this.attachShadow({ mode: "open" }), I = (j, Q, w) => {
1498
1485
  let W;
1499
1486
  if (this.hasAttribute(Q)) {
1500
1487
  const M = this.getAttribute(Q);
@@ -1513,7 +1500,7 @@ class jt extends HTMLElement {
1513
1500
  "partbot-button-color",
1514
1501
  "data-button-color",
1515
1502
  "0 0 0"
1516
- ), T = I(
1503
+ ), O = I(
1517
1504
  "partbot-button-hover-color",
1518
1505
  "data-button-hover-color",
1519
1506
  "0 0 0"
@@ -1525,7 +1512,7 @@ class jt extends HTMLElement {
1525
1512
  "partbot-button-hover-label-color",
1526
1513
  "data-button-hover-label-color",
1527
1514
  "255 255 255"
1528
- ), O = I(
1515
+ ), T = I(
1529
1516
  "partbot-mobile-background-color",
1530
1517
  "data-mobile-background-color",
1531
1518
  "0 0 0"
@@ -1540,9 +1527,9 @@ class jt extends HTMLElement {
1540
1527
  D = `${j} ${Q} ${w}`;
1541
1528
  } else /^\d+\s+\d+\s+\d+$/.test(f) && (D = f);
1542
1529
  let g = `:host { --partbot-input-border-color: ${D}; } .partbot-mmyvs-container { --partbot-input-border-color: ${D}; }`;
1543
- const l = this.getAttribute("data-input-border-width") || "1px";
1544
- let U = `:host { --partbot-input-border-width: ${l}; } .partbot-mmyvs-container { --partbot-input-border-width: ${l}; }`;
1545
- v.textContent += R, v.textContent += P, v.textContent += T, v.textContent += _, v.textContent += V, v.textContent += O, v.textContent += re, v.textContent += u, v.textContent += y, v.textContent += C, v.textContent += G, v.textContent += g, v.textContent += U, F.appendChild(v), F.appendChild(p);
1530
+ const s = this.getAttribute("data-input-border-width") || "1px";
1531
+ let F = `:host { --partbot-input-border-width: ${s}; } .partbot-mmyvs-container { --partbot-input-border-width: ${s}; }`;
1532
+ v.textContent += R, v.textContent += P, v.textContent += O, v.textContent += _, v.textContent += V, v.textContent += T, v.textContent += re, v.textContent += u, v.textContent += y, v.textContent += C, v.textContent += G, v.textContent += g, v.textContent += F, U.appendChild(v), U.appendChild(p);
1546
1533
  const z = this.getAttribute("data-api-key");
1547
1534
  if (!z) {
1548
1535
  console.warn("Missing attributes: " + (z ? "" : "data-api-key "));
@@ -1558,7 +1545,7 @@ class jt extends HTMLElement {
1558
1545
  }
1559
1546
  At(this);
1560
1547
  const K = /* @__PURE__ */ a(Mt, { ...S });
1561
- ft.render(K, p);
1548
+ mt.render(K, p);
1562
1549
  }
1563
1550
  }
1564
1551
  customElements.define("vehicle-search", jt);