@cartbot/vehicle-search-beta 3.0.20 → 3.0.21

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,5 +1,5 @@
1
- import { jsx as a, jsxs as A, Fragment as $e } from "react/jsx-runtime";
2
- import { useState as M, useEffect as B, useRef as Z, useCallback as N, useMemo as ut } from "react";
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 ut } from "react";
3
3
  import mt from "react-dom";
4
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";
@@ -23,7 +23,7 @@ function St({ className: b }) {
23
23
  width: "auto",
24
24
  height: "100%"
25
25
  },
26
- children: /* @__PURE__ */ A("g", { children: [
26
+ children: /* @__PURE__ */ E("g", { children: [
27
27
  /* @__PURE__ */ a(
28
28
  "rect",
29
29
  {
@@ -127,7 +127,7 @@ function X({
127
127
  shouldBeActive: T = !1
128
128
  // True when parent fields are selected and this field tried to load
129
129
  }) {
130
- const [re, u] = M(""), [y, C] = M(p || null), q = (s) => {
130
+ const [re, u] = A(""), [y, C] = A(p || null), q = (s) => {
131
131
  C(s), u(""), !(s && s.value === (p == null ? void 0 : p.value)) && U(s);
132
132
  }, ee = (s) => {
133
133
  s.preventDefault(), s.stopPropagation(), u(""), C(null), U("");
@@ -152,7 +152,7 @@ function X({
152
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
- return /* @__PURE__ */ A("div", { className: "vs:relative vs:flex vs:flex-col", children: [
155
+ return /* @__PURE__ */ E("div", { className: "vs:relative vs:flex vs:flex-col", children: [
156
156
  O && /* @__PURE__ */ a(
157
157
  "span",
158
158
  {
@@ -160,8 +160,8 @@ function X({
160
160
  children: b
161
161
  }
162
162
  ),
163
- _ && /* @__PURE__ */ A("div", { className: "vs:relative vs:flex vs:flex-col", children: [
164
- /* @__PURE__ */ A(
163
+ _ && /* @__PURE__ */ E("div", { className: "vs:relative vs:flex vs:flex-col", children: [
164
+ /* @__PURE__ */ E(
165
165
  "select",
166
166
  {
167
167
  onChange: (s) => {
@@ -176,7 +176,7 @@ function X({
176
176
  value: y ? y.value : "",
177
177
  children: [
178
178
  /* @__PURE__ */ a("option", { value: "", disabled: !0, children: b }),
179
- D.length > 0 ? /* @__PURE__ */ A($e, { children: [
179
+ D.length > 0 ? /* @__PURE__ */ E($e, { children: [
180
180
  /* @__PURE__ */ a("optgroup", { label: `Popular ${Ke(b)}`, children: D.map((s) => /* @__PURE__ */ a("option", { value: s.refinement, children: s.value }, s.value)) }),
181
181
  /* @__PURE__ */ a("optgroup", { label: `All ${Ke(b)}`, children: f.filter(
182
182
  (s) => !D.some(
@@ -209,7 +209,7 @@ function X({
209
209
  }
210
210
  )
211
211
  ] }),
212
- !_ && /* @__PURE__ */ A(
212
+ !_ && /* @__PURE__ */ E(
213
213
  gt,
214
214
  {
215
215
  value: y || null,
@@ -218,7 +218,7 @@ function X({
218
218
  disabled: g,
219
219
  immediate: !0,
220
220
  children: [
221
- /* @__PURE__ */ A("div", { className: "vs:flex vs:h-full", children: [
221
+ /* @__PURE__ */ E("div", { className: "vs:flex vs:h-full", children: [
222
222
  /* @__PURE__ */ a(
223
223
  bt,
224
224
  {
@@ -231,7 +231,7 @@ function X({
231
231
  title: b
232
232
  }
233
233
  ),
234
- /* @__PURE__ */ A("div", { className: "vs:absolute vs:pointer-events-none vs:h-full vs:right-0 vs:flex vs:space-x-[calc(var(--partbot-padding)*0.25)] vs:items-center", children: [
234
+ /* @__PURE__ */ E("div", { className: "vs:absolute vs:pointer-events-none vs:h-full vs:right-0 vs:flex vs:space-x-[calc(var(--partbot-padding)*0.25)] vs:items-center", children: [
235
235
  (y == null ? void 0 : y.value) && /* @__PURE__ */ a(
236
236
  "button",
237
237
  {
@@ -285,7 +285,7 @@ function X({
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
286
  F && "vs:font-bold!"
287
287
  ),
288
- children: ({ selected: z }) => /* @__PURE__ */ A("div", { className: "vs:flex vs:w-full vs:items-center vs:justify-between", children: [
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
  {
@@ -328,7 +328,7 @@ function X({
328
328
  )
329
329
  ] });
330
330
  }
331
- const $t = "3.0.20";
331
+ const $t = "3.0.21";
332
332
  console.info(
333
333
  `Vehicle Search v${$t} powered by Partbot https://mmyvs.partbot.io`
334
334
  );
@@ -377,7 +377,7 @@ function Mt({
377
377
  mobileButtonLabel: s = "Select Vehicle"
378
378
  // Label for mobile drawer trigger button
379
379
  }) {
380
- const F = Z(null), z = Z(null), ie = Z(null), S = Z(null), K = Z(null), E = Z(null), Q = Z(null), w = Z(null), W = Z(null), j = Z(!1), x = f === "YMM", [le, ve] = M([]), [fe, ce] = M([]), [de, he] = M([]), [Le, ge] = M([]), [Ie, be] = M([]), [Ve, we] = M([]), [De, ye] = M([]), [Fe, xe] = M([]), Je = Z([]), [se, ke] = M([]), [e, Y] = M({
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,7 +386,7 @@ function Mt({
386
386
  variant: null,
387
387
  engine: null,
388
388
  engine_capacity: null
389
- }), [Xe, Me] = M(!1), Ue = Z([
389
+ }), [Xe, Me] = A(!1), Ue = Z([
390
390
  "body",
391
391
  "series",
392
392
  "variant",
@@ -397,7 +397,7 @@ function Mt({
397
397
  var r;
398
398
  return (r = Ue.current) == null ? void 0 : r.includes(t);
399
399
  }) : null
400
- ), [J, Ge] = M(!1);
400
+ ), [J, Ge] = A(!1);
401
401
  B(() => {
402
402
  const t = navigator.userAgent;
403
403
  Ge(
@@ -412,7 +412,7 @@ function Mt({
412
412
  disable_session_recording: !1
413
413
  });
414
414
  }, []);
415
- const [oe, et] = M({}), [Nt, tt] = M(""), 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`;
@@ -452,7 +452,7 @@ function Mt({
452
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, E.current = h || null, et({
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
  });
@@ -483,7 +483,7 @@ function Mt({
483
483
  };
484
484
  }
485
485
  }, [oe.searchKey, b]);
486
- const [H, rt] = M(!1), Oe = 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;
@@ -573,14 +573,14 @@ function Mt({
573
573
  const t = {
574
574
  vehicle_ids: se,
575
575
  vehicle: (i = e == null ? void 0 : e.make) != null && i.value ? e : {},
576
- userSelected: j.current
576
+ userSelected: M.current
577
577
  // Flag to indicate if user actively selected
578
578
  };
579
579
  u && u(t);
580
580
  const r = new CustomEvent("vehicle-search-change", {
581
581
  detail: t
582
582
  });
583
- if (j.current === !0) {
583
+ if (M.current === !0) {
584
584
  localStorage.removeItem("partbot_plate_details");
585
585
  const ae = JSON.stringify({
586
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(),
@@ -607,7 +607,7 @@ function Mt({
607
607
  _e.cancel();
608
608
  }, [_e]), B(() => {
609
609
  const t = () => {
610
- Y({
610
+ M.current = !1, Y({
611
611
  make: null,
612
612
  model: null,
613
613
  year: null,
@@ -644,7 +644,7 @@ function Mt({
644
644
  }, [Oe]);
645
645
  const Ze = N(
646
646
  (t) => {
647
- j.current = !0, ce([]), !x && !g && he([]), ge([]), be([]), we([]), xe([]), ye([]), Y((r) => ({
647
+ M.current = !0, ce([]), !x && !g && he([]), ge([]), be([]), we([]), xe([]), ye([]), Y((r) => ({
648
648
  make: t,
649
649
  year: x || g ? r.year : null
650
650
  })), L({
@@ -671,7 +671,7 @@ function Mt({
671
671
  [L, x, g]
672
672
  ), Ye = N(
673
673
  (t) => {
674
- j.current = !0, Y((r) => ({
674
+ M.current = !0, Y((r) => ({
675
675
  ...r,
676
676
  model: t !== "" ? t : null,
677
677
  year: x || g ? r.year : null,
@@ -697,7 +697,7 @@ function Mt({
697
697
  [L, x, g]
698
698
  ), He = N(
699
699
  (t) => {
700
- j.current = !0, x ? (ve([]), ce([]), Y({
700
+ M.current = !0, x ? (ve([]), ce([]), Y({
701
701
  year: t !== "" ? t : null
702
702
  }), (!t || t === "") && he([])) : Y(g ? (r) => ({
703
703
  ...r,
@@ -727,7 +727,7 @@ function Mt({
727
727
  [L, x, g]
728
728
  ), it = N(
729
729
  (t) => {
730
- j.current = !0, Y((r) => ({
730
+ M.current = !0, Y((r) => ({
731
731
  ...r,
732
732
  body: t !== "" ? t : null
733
733
  })), L({
@@ -738,7 +738,7 @@ function Mt({
738
738
  [L]
739
739
  ), st = N(
740
740
  (t) => {
741
- j.current = !0, Y((r) => ({
741
+ M.current = !0, Y((r) => ({
742
742
  ...r,
743
743
  series: t !== "" ? t : null
744
744
  })), L({
@@ -749,7 +749,7 @@ function Mt({
749
749
  [L]
750
750
  ), lt = N(
751
751
  (t) => {
752
- j.current = !0, Y((r) => ({
752
+ M.current = !0, Y((r) => ({
753
753
  ...r,
754
754
  variant: t !== "" ? t : null
755
755
  })), L({
@@ -760,7 +760,7 @@ function Mt({
760
760
  [L]
761
761
  ), ct = N(
762
762
  (t) => {
763
- j.current = !0, Y((r) => ({
763
+ M.current = !0, Y((r) => ({
764
764
  ...r,
765
765
  engine: t !== "" ? t : null
766
766
  })), L({
@@ -771,7 +771,7 @@ function Mt({
771
771
  [L]
772
772
  ), dt = N(
773
773
  (t) => {
774
- j.current = !0, Y((r) => ({
774
+ M.current = !0, Y((r) => ({
775
775
  ...r,
776
776
  engine_capacity: t !== "" ? t : null
777
777
  })), L({
@@ -859,7 +859,7 @@ function Mt({
859
859
  popularity: 0
860
860
  // Popularity will be used from PostHog for sorting
861
861
  })
862
- ), o = (t = E.current) == null ? void 0 : t[r];
862
+ ), o = (t = j.current) == null ? void 0 : t[r];
863
863
  if (o && Array.isArray(o)) {
864
864
  const l = new Map(
865
865
  o.map((n, c) => [
@@ -924,7 +924,7 @@ function Mt({
924
924
  refinement: h.model.match(/[^>]*$/)[0].trim(),
925
925
  popularity: h.model_popularity
926
926
  }));
927
- const $ = (pe = e.make) == null ? void 0 : pe.refinement, te = (ae = E.current) == null ? void 0 : ae[$];
927
+ const $ = (pe = e.make) == null ? void 0 : pe.refinement, te = (ae = j.current) == null ? void 0 : ae[$];
928
928
  if (te && Array.isArray(te) && te.length > 0) {
929
929
  const h = new Set(
930
930
  te.map((m) => String(m).trim().toUpperCase())
@@ -1084,13 +1084,13 @@ function Mt({
1084
1084
  e.year,
1085
1085
  g
1086
1086
  ]);
1087
- const [ze, Ee] = M(!1);
1087
+ const [ze, Ee] = A(!1);
1088
1088
  return B(() => {
1089
1089
  if (T)
1090
1090
  return ze ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
1091
1091
  document.body.style.overflow = "";
1092
1092
  };
1093
- }, [ze, T]), /* @__PURE__ */ A($e, { children: [
1093
+ }, [ze, T]), /* @__PURE__ */ E($e, { children: [
1094
1094
  T && /* @__PURE__ */ a(
1095
1095
  "button",
1096
1096
  {
@@ -1113,7 +1113,7 @@ function Mt({
1113
1113
  )
1114
1114
  }
1115
1115
  ),
1116
- /* @__PURE__ */ A(
1116
+ /* @__PURE__ */ E(
1117
1117
  "div",
1118
1118
  {
1119
1119
  className: ne(
@@ -1122,9 +1122,9 @@ function Mt({
1122
1122
  "w-full"
1123
1123
  ),
1124
1124
  children: [
1125
- T && /* @__PURE__ */ A("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: [
1126
1126
  /* @__PURE__ */ a("span", { children: "Select Vehicle" }),
1127
- /* @__PURE__ */ A(
1127
+ /* @__PURE__ */ E(
1128
1128
  "button",
1129
1129
  {
1130
1130
  onClick: () => Ee(!1),
@@ -1146,7 +1146,7 @@ function Mt({
1146
1146
  }
1147
1147
  )
1148
1148
  ] }),
1149
- /* @__PURE__ */ A(
1149
+ /* @__PURE__ */ E(
1150
1150
  "div",
1151
1151
  {
1152
1152
  ref: F,
@@ -1156,7 +1156,7 @@ function Mt({
1156
1156
  "vs:w-full vs:transition vs:lg:mx-auto"
1157
1157
  ),
1158
1158
  children: [
1159
- x ? /* @__PURE__ */ A($e, { children: [
1159
+ x ? /* @__PURE__ */ E($e, { children: [
1160
1160
  /* @__PURE__ */ a(
1161
1161
  X,
1162
1162
  {
@@ -1204,7 +1204,7 @@ function Mt({
1204
1204
  shouldBeActive: !!e.make
1205
1205
  }
1206
1206
  )
1207
- ] }) : /* @__PURE__ */ A($e, { children: [
1207
+ ] }) : /* @__PURE__ */ E($e, { children: [
1208
1208
  /* @__PURE__ */ a(
1209
1209
  X,
1210
1210
  {
@@ -1344,7 +1344,7 @@ function Mt({
1344
1344
  }
1345
1345
  return r;
1346
1346
  }),
1347
- C && /* @__PURE__ */ a("div", { className: "vs:flex vs:h-full vs:flex-col vs:justify-end vs:md:col-span-3 vs:lg:col-span-1", children: /* @__PURE__ */ A(
1347
+ C && /* @__PURE__ */ a("div", { className: "vs:flex vs:h-full vs:flex-col vs:justify-end vs:md:col-span-3 vs:lg:col-span-1", children: /* @__PURE__ */ E(
1348
1348
  "button",
1349
1349
  {
1350
1350
  className: "vehicle-search-btn",
@@ -1368,7 +1368,7 @@ function Mt({
1368
1368
  I === "row" ? "vs:md:items-end vs:md:justify-end" : "vs:md:justify-center",
1369
1369
  "vs:mt-4 vs:md:mt-3 vs:md:pr-1.5"
1370
1370
  ),
1371
- children: /* @__PURE__ */ A(
1371
+ children: /* @__PURE__ */ E(
1372
1372
  "a",
1373
1373
  {
1374
1374
  href: `https://use.partbot.io/?ref=${// append referrer to url, just the top level domain
@@ -1476,21 +1476,21 @@ const Et = "/css/vehicle-search.css", Yt = Et;
1476
1476
  class jt extends HTMLElement {
1477
1477
  connectedCallback() {
1478
1478
  if (!document.getElementById("vehicle-search-inter-font")) {
1479
- const E = document.createElement("link");
1480
- E.id = "vehicle-search-inter-font", E.rel = "stylesheet", E.href = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap", document.head.appendChild(E);
1479
+ const j = document.createElement("link");
1480
+ j.id = "vehicle-search-inter-font", j.rel = "stylesheet", j.href = "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap", document.head.appendChild(j);
1481
1481
  }
1482
1482
  let v = document.createElement("style");
1483
1483
  v.textContent = zt;
1484
- const p = document.createElement("div"), U = this.attachShadow({ mode: "open" }), I = (E, Q, w) => {
1484
+ const p = document.createElement("div"), U = this.attachShadow({ mode: "open" }), I = (j, Q, w) => {
1485
1485
  let W;
1486
1486
  if (this.hasAttribute(Q)) {
1487
- const j = this.getAttribute(Q);
1488
- if (/^#[0-9A-F]{6}$/i.test(j)) {
1489
- const x = parseInt(j.slice(1, 3), 16), le = parseInt(j.slice(3, 5), 16), ve = parseInt(j.slice(5, 7), 16);
1487
+ const M = this.getAttribute(Q);
1488
+ if (/^#[0-9A-F]{6}$/i.test(M)) {
1489
+ const x = parseInt(M.slice(1, 3), 16), le = parseInt(M.slice(3, 5), 16), ve = parseInt(M.slice(5, 7), 16);
1490
1490
  W = `${x} ${le} ${ve}`;
1491
1491
  }
1492
1492
  }
1493
- return W = W || w, `:host { --${E}: ${W}; } .partbot-mmyvs-container { --${E}: ${W}; }`;
1493
+ return W = W || w, `:host { --${j}: ${W}; } .partbot-mmyvs-container { --${j}: ${W}; }`;
1494
1494
  };
1495
1495
  let R = I(
1496
1496
  "partbot-theme",
@@ -1523,8 +1523,8 @@ class jt extends HTMLElement {
1523
1523
  let D = "229 231 235";
1524
1524
  if (f)
1525
1525
  if (/^#[0-9A-F]{6}$/i.test(f)) {
1526
- const E = parseInt(f.slice(1, 3), 16), Q = parseInt(f.slice(3, 5), 16), w = parseInt(f.slice(5, 7), 16);
1527
- D = `${E} ${Q} ${w}`;
1526
+ const j = parseInt(f.slice(1, 3), 16), Q = parseInt(f.slice(3, 5), 16), w = parseInt(f.slice(5, 7), 16);
1527
+ D = `${j} ${Q} ${w}`;
1528
1528
  } else /^\d+\s+\d+\s+\d+$/.test(f) && (D = f);
1529
1529
  let g = `:host { --partbot-input-border-color: ${D}; } .partbot-mmyvs-container { --partbot-input-border-color: ${D}; }`;
1530
1530
  const s = this.getAttribute("data-input-border-width") || "1px";
@@ -1536,10 +1536,10 @@ class jt extends HTMLElement {
1536
1536
  return;
1537
1537
  }
1538
1538
  const ie = this.attributes, S = {};
1539
- for (let E = 0; E < ie.length; E++) {
1540
- const { name: Q, value: w } = ie[E];
1539
+ for (let j = 0; j < ie.length; j++) {
1540
+ const { name: Q, value: w } = ie[j];
1541
1541
  if (Q.startsWith("data-")) {
1542
- const W = Q.slice(5).replace(/-([a-z])/g, (j) => j[1].toUpperCase());
1542
+ const W = Q.slice(5).replace(/-([a-z])/g, (M) => M[1].toUpperCase());
1543
1543
  S[W] = w === "true" ? !0 : w === "false" ? !1 : w;
1544
1544
  }
1545
1545
  }