@cartbot/vehicle-search-beta 3.0.23 → 3.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/js/vehicle-search.es.js +220 -234
- package/dist/js/vehicle-search.js +16 -16
- package/package.json +1 -1
|
@@ -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
|
|
3
|
-
import
|
|
4
|
-
import
|
|
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
|
|
7
|
+
import Ke from "pluralize";
|
|
8
8
|
import ne from "clsx";
|
|
9
|
-
import { MeiliSearch as
|
|
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:
|
|
120
|
+
refine: U,
|
|
121
121
|
showPopular: I,
|
|
122
122
|
bgDark: R,
|
|
123
123
|
sortOptions: P = !0,
|
|
124
|
-
showLabel:
|
|
124
|
+
showLabel: O = !1,
|
|
125
125
|
isMobile: _ = !1,
|
|
126
126
|
loading: V = !1,
|
|
127
|
-
shouldBeActive:
|
|
127
|
+
shouldBeActive: T = !1
|
|
128
128
|
// True when parent fields are selected and this field tried to load
|
|
129
129
|
}) {
|
|
130
|
-
const [
|
|
131
|
-
C(
|
|
132
|
-
},
|
|
133
|
-
|
|
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((
|
|
140
|
-
String(
|
|
141
|
-
z = z.trim(), z && kt(
|
|
142
|
-
...
|
|
139
|
+
v && (v.forEach((s) => {
|
|
140
|
+
String(s.value).split(/,(?![^(]*\))/).forEach((z) => {
|
|
141
|
+
z = z.trim(), z && kt(re, z.toLowerCase()) && !G.has(z.toLowerCase()) && (G.add(z.toLowerCase()), f.push({
|
|
142
|
+
...s,
|
|
143
143
|
value: z,
|
|
144
|
-
refinement:
|
|
144
|
+
refinement: s.value
|
|
145
145
|
}));
|
|
146
146
|
});
|
|
147
147
|
}), f.length === 0 && (f = v));
|
|
148
|
-
const D = f.filter((
|
|
148
|
+
const D = f.filter((s) => s.popularity > 0).slice(0, 11);
|
|
149
149
|
P && (f = f.filter(
|
|
150
|
-
(
|
|
150
|
+
(s) => !D.includes(s)
|
|
151
151
|
), f.sort(
|
|
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
155
|
return /* @__PURE__ */ E("div", { className: "vs:relative vs:flex vs:flex-col", children: [
|
|
156
|
-
|
|
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: (
|
|
168
|
-
const
|
|
169
|
-
(z) => z.value.toString() ===
|
|
167
|
+
onChange: (s) => {
|
|
168
|
+
const F = f.find(
|
|
169
|
+
(z) => z.value.toString() === s.target.value.toString()
|
|
170
170
|
);
|
|
171
|
-
|
|
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 ${
|
|
181
|
-
/* @__PURE__ */ a("optgroup", { label: `All ${
|
|
182
|
-
(
|
|
183
|
-
(
|
|
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((
|
|
186
|
-
] }) : f.map((
|
|
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
|
),
|
|
@@ -191,7 +191,7 @@ function X({
|
|
|
191
191
|
!V && (y == null ? void 0 : y.value) && /* @__PURE__ */ a(
|
|
192
192
|
"button",
|
|
193
193
|
{
|
|
194
|
-
onClick:
|
|
194
|
+
onClick: ee,
|
|
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__ */ a(
|
|
@@ -224,10 +224,10 @@ function X({
|
|
|
224
224
|
{
|
|
225
225
|
autoComplete: "off",
|
|
226
226
|
spellCheck: "false",
|
|
227
|
-
placeholder: g &&
|
|
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: (
|
|
230
|
-
onChange: (
|
|
229
|
+
displayValue: (s) => (s == null ? void 0 : s.value) || "",
|
|
230
|
+
onChange: (s) => u(s.target.value),
|
|
231
231
|
title: b
|
|
232
232
|
}
|
|
233
233
|
),
|
|
@@ -235,7 +235,7 @@ function X({
|
|
|
235
235
|
(y == null ? void 0 : y.value) && /* @__PURE__ */ a(
|
|
236
236
|
"button",
|
|
237
237
|
{
|
|
238
|
-
onClick:
|
|
238
|
+
onClick: ee,
|
|
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__ */ a(
|
|
@@ -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:
|
|
276
|
-
const
|
|
277
|
-
(z) => z.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:
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
296
|
+
children: s.value
|
|
297
297
|
}
|
|
298
298
|
),
|
|
299
|
-
|
|
299
|
+
s.value === (p == null ? void 0 : p.value) && /* @__PURE__ */ a(
|
|
300
300
|
"span",
|
|
301
301
|
{
|
|
302
302
|
className: ne(
|
|
@@ -328,45 +328,45 @@ function X({
|
|
|
328
328
|
)
|
|
329
329
|
] });
|
|
330
330
|
}
|
|
331
|
-
const $t = "3.0.
|
|
331
|
+
const $t = "3.0.25";
|
|
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((
|
|
338
|
-
const [I, ...R] =
|
|
337
|
+
return b.forEach((U) => {
|
|
338
|
+
const [I, ...R] = U.split(":"), P = R.join(":");
|
|
339
339
|
if (P.includes(" > ")) {
|
|
340
|
-
const
|
|
341
|
-
if (I !== "make" &&
|
|
342
|
-
const V =
|
|
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((
|
|
349
|
-
p.push(
|
|
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:
|
|
356
|
+
callbackUrl: U = "",
|
|
357
357
|
layout: I = "row",
|
|
358
358
|
fields: R,
|
|
359
359
|
fieldPrefix: P = "",
|
|
360
|
-
showBranding:
|
|
360
|
+
showBranding: O = !0,
|
|
361
361
|
showLabels: _ = !1,
|
|
362
362
|
mobileFullWidthButton: V = !0,
|
|
363
|
-
mobileDrawer:
|
|
364
|
-
modifyQueryString:
|
|
363
|
+
mobileDrawer: T = !0,
|
|
364
|
+
modifyQueryString: re = !0,
|
|
365
365
|
onChange: u,
|
|
366
366
|
buttonLabel: y = "Search",
|
|
367
367
|
showButton: C = !0,
|
|
368
368
|
onSubmit: q,
|
|
369
|
-
store:
|
|
369
|
+
store: ee,
|
|
370
370
|
useStoreVehicles: G = !0,
|
|
371
371
|
fieldOrder: f = "MMY",
|
|
372
372
|
// "MMY" (Make→Model→Year) or "YMM" (Year→Make→Model)
|
|
@@ -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:
|
|
377
|
+
mobileButtonLabel: s = "Select Vehicle"
|
|
378
378
|
// Label for mobile drawer trigger button
|
|
379
379
|
}) {
|
|
380
|
-
const
|
|
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, he] = A([]), [ge, ce] = A([]), [de, ue] = A([]), [Le, be] = A([]), [Ie, we] = A([]), [Ve, ye] = A([]), [De, xe] = A([]), [Fe, ke] = A([]), Je = Z([]), [se, Ce] = 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
|
-
}), [
|
|
389
|
+
}), [Xe, Me] = A(!1), Ue = Z([
|
|
390
390
|
"body",
|
|
391
391
|
"series",
|
|
392
392
|
"variant",
|
|
393
393
|
"engine",
|
|
394
394
|
"engine_capacity"
|
|
395
|
-
]),
|
|
396
|
-
R && R.length &&
|
|
395
|
+
]), _e = Z(
|
|
396
|
+
R && R.length && Ue.current ? R.split(",").filter((t) => {
|
|
397
397
|
var r;
|
|
398
|
-
return (r =
|
|
398
|
+
return (r = Ue.current) == null ? void 0 : r.includes(t);
|
|
399
399
|
}) : null
|
|
400
|
-
), [J,
|
|
400
|
+
), [J, Ge] = A(!1);
|
|
401
401
|
B(() => {
|
|
402
402
|
const t = navigator.userAgent;
|
|
403
|
-
|
|
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,
|
|
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`;
|
|
@@ -427,7 +427,7 @@ function Mt({
|
|
|
427
427
|
body: JSON.stringify(
|
|
428
428
|
(() => {
|
|
429
429
|
const m = { use_store_vehicles: G };
|
|
430
|
-
return
|
|
430
|
+
return ee && (m.store = ee), m;
|
|
431
431
|
})()
|
|
432
432
|
)
|
|
433
433
|
});
|
|
@@ -435,41 +435,41 @@ function Mt({
|
|
|
435
435
|
throw new Error(`Error: ${i.status} ${i.statusText}`);
|
|
436
436
|
const {
|
|
437
437
|
merchant: o,
|
|
438
|
-
vehicle_makes:
|
|
438
|
+
vehicle_makes: l,
|
|
439
439
|
vehicle_models: n,
|
|
440
440
|
meilisearch_search_key: c,
|
|
441
441
|
meilisearch_index_name: d,
|
|
442
442
|
algolia_search_key: $,
|
|
443
443
|
// Fallback for backward compatibility
|
|
444
|
-
algolia_index_name:
|
|
444
|
+
algolia_index_name: te,
|
|
445
445
|
// Fallback for backward compatibility
|
|
446
|
-
store_index_name:
|
|
446
|
+
store_index_name: ve,
|
|
447
447
|
store_popular_makes: ae,
|
|
448
448
|
// Array of popular make values for this store (from PostHog)
|
|
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 = (
|
|
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,
|
|
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),
|
|
460
|
+
console.error("[VehicleSearch] Auth failed:", i), tt(i);
|
|
461
461
|
}
|
|
462
|
-
}, [b,
|
|
462
|
+
}, [b, ee, G, D]);
|
|
463
463
|
B(() => {
|
|
464
464
|
Re();
|
|
465
465
|
}, [Re]), B(() => {
|
|
466
466
|
if (oe.searchKey) {
|
|
467
467
|
try {
|
|
468
|
-
Q.current = new
|
|
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
|
|
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,
|
|
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(
|
|
501
|
-
const
|
|
502
|
-
|
|
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
|
|
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
|
-
|
|
525
|
+
Ce(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,
|
|
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,19 +543,19 @@ 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,
|
|
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 }) => {
|
|
550
|
-
if (
|
|
550
|
+
if (re && "URLSearchParams" in window) {
|
|
551
551
|
let o = new URLSearchParams(window.location.search);
|
|
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
|
|
556
|
-
window.history.pushState(null, "",
|
|
555
|
+
const l = window.location.pathname + "?" + o.toString();
|
|
556
|
+
window.history.pushState(null, "", l);
|
|
557
557
|
}
|
|
558
|
-
}, []),
|
|
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]),
|
|
572
|
-
var i, o,
|
|
571
|
+
}, [se, q]), Te = N(() => {
|
|
572
|
+
var i, o, l, n, c, d, $, te, ve;
|
|
573
573
|
const t = {
|
|
574
574
|
vehicle_ids: se,
|
|
575
575
|
vehicle: (i = e == null ? void 0 : e.make) != null && i.value ? e : {},
|
|
@@ -583,45 +583,31 @@ 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) || ""} ${((
|
|
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) || ""} ${((ve = e.engine_capacity) == null ? void 0 : ve.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
|
-
),
|
|
593
|
+
), ft.set("partbot_selected_vehicle", ae, {
|
|
594
594
|
secure: !0
|
|
595
595
|
});
|
|
596
596
|
}
|
|
597
|
-
window.dispatchEvent(r), document.dispatchEvent(r),
|
|
597
|
+
window.dispatchEvent(r), document.dispatchEvent(r), Je.current = se, setTimeout(() => {
|
|
598
598
|
Me(!1);
|
|
599
599
|
}, 900);
|
|
600
|
-
}, [se, u]),
|
|
601
|
-
() => Ct(
|
|
602
|
-
[
|
|
600
|
+
}, [se, u]), pe = ut(
|
|
601
|
+
() => Ct(Te, 100),
|
|
602
|
+
[Te]
|
|
603
603
|
);
|
|
604
604
|
B(() => {
|
|
605
|
-
|
|
606
|
-
}, [se,
|
|
607
|
-
|
|
608
|
-
}, [
|
|
605
|
+
pe();
|
|
606
|
+
}, [se, pe]), B(() => () => {
|
|
607
|
+
pe.cancel();
|
|
608
|
+
}, [pe]), B(() => {
|
|
609
609
|
const t = () => {
|
|
610
|
-
M.current = !1,
|
|
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());
|
|
624
|
-
}, 100), Y({
|
|
610
|
+
M.current = !1, pe.cancel(), Y({
|
|
625
611
|
make: null,
|
|
626
612
|
model: null,
|
|
627
613
|
year: null,
|
|
@@ -630,7 +616,7 @@ function Mt({
|
|
|
630
616
|
variant: null,
|
|
631
617
|
engine: null,
|
|
632
618
|
engine_capacity: null
|
|
633
|
-
}),
|
|
619
|
+
}), Ce([]);
|
|
634
620
|
};
|
|
635
621
|
return window.addEventListener("plate-search-change", t), () => {
|
|
636
622
|
window.removeEventListener(
|
|
@@ -638,27 +624,27 @@ function Mt({
|
|
|
638
624
|
t
|
|
639
625
|
);
|
|
640
626
|
};
|
|
641
|
-
}, []), B(() => {
|
|
642
|
-
oe.searchKey && (x ||
|
|
627
|
+
}, [pe]), B(() => {
|
|
628
|
+
oe.searchKey && (x || pt(), at());
|
|
643
629
|
}, [oe.searchKey, x]), B(() => {
|
|
644
630
|
x && w.current && de.length === 0 && !e.year && w.current.search("", {
|
|
645
631
|
attributesToRetrieve: ["year_from", "year_to"],
|
|
646
632
|
limit: 1e4
|
|
647
633
|
}).then(({ hits: t }) => {
|
|
648
|
-
const r = t.map((c) => c.year_from).filter(Boolean), i = t.map((c) => c.year_to).filter(Boolean), o = Math.min(...r),
|
|
649
|
-
{ length:
|
|
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 },
|
|
650
636
|
(c, d) => ({ value: o + d, refinement: o + d })
|
|
651
637
|
).reverse();
|
|
652
|
-
|
|
638
|
+
ue(n);
|
|
653
639
|
}).catch((t) => {
|
|
654
640
|
console.error("[VehicleSearch] Error loading year range:", t);
|
|
655
641
|
});
|
|
656
642
|
}, [x, oe.searchKey, de.length, e.year]), B(() => {
|
|
657
|
-
typeof document > "u" ||
|
|
658
|
-
}, [
|
|
643
|
+
typeof document > "u" || Oe();
|
|
644
|
+
}, [Oe]);
|
|
659
645
|
const Ze = N(
|
|
660
646
|
(t) => {
|
|
661
|
-
M.current = !0, ce([]), !x && !g &&
|
|
647
|
+
M.current = !0, ce([]), !x && !g && ue([]), be([]), we([]), ye([]), ke([]), xe([]), Y((r) => ({
|
|
662
648
|
make: t,
|
|
663
649
|
year: x || g ? r.year : null
|
|
664
650
|
})), L({
|
|
@@ -680,7 +666,7 @@ function Mt({
|
|
|
680
666
|
"variant",
|
|
681
667
|
"engine_capacity"
|
|
682
668
|
]
|
|
683
|
-
}), t ||
|
|
669
|
+
}), t || Ce([]);
|
|
684
670
|
},
|
|
685
671
|
[L, x, g]
|
|
686
672
|
), Ye = N(
|
|
@@ -695,7 +681,7 @@ function Mt({
|
|
|
695
681
|
variant: null,
|
|
696
682
|
engine: null,
|
|
697
683
|
engine_capacity: null
|
|
698
|
-
})), !x && !g &&
|
|
684
|
+
})), !x && !g && ue([]), be([]), we([]), ye([]), ke([]), xe([]), L({
|
|
699
685
|
query: "model",
|
|
700
686
|
value: (t == null ? void 0 : t.value) ?? "",
|
|
701
687
|
remove: x ? ["body", "series", "engine", "variant", "engine_capacity"] : g ? ["body", "series", "engine", "variant", "engine_capacity"] : [
|
|
@@ -711,9 +697,9 @@ function Mt({
|
|
|
711
697
|
[L, x, g]
|
|
712
698
|
), He = N(
|
|
713
699
|
(t) => {
|
|
714
|
-
M.current = !0, x ? (
|
|
700
|
+
M.current = !0, x ? (he([]), ce([]), Y({
|
|
715
701
|
year: t !== "" ? t : null
|
|
716
|
-
}), (!t || t === "") &&
|
|
702
|
+
}), (!t || t === "") && ue([])) : Y(g ? (r) => ({
|
|
717
703
|
...r,
|
|
718
704
|
year: t !== "" ? t : null
|
|
719
705
|
}) : (r) => ({
|
|
@@ -724,7 +710,7 @@ function Mt({
|
|
|
724
710
|
variant: null,
|
|
725
711
|
engine: null,
|
|
726
712
|
engine_capacity: null
|
|
727
|
-
})), g || (
|
|
713
|
+
})), g || (be([]), we([]), ye([]), ke([]), xe([])), L({
|
|
728
714
|
query: "year",
|
|
729
715
|
value: (t == null ? void 0 : t.value) ?? "",
|
|
730
716
|
remove: x ? [
|
|
@@ -736,10 +722,10 @@ function Mt({
|
|
|
736
722
|
"engine",
|
|
737
723
|
"engine_capacity"
|
|
738
724
|
] : g ? [] : ["body", "series", "variant", "engine", "engine_capacity"]
|
|
739
|
-
}), !g && (!t || t === "") &&
|
|
725
|
+
}), !g && (!t || t === "") && Ce([]);
|
|
740
726
|
},
|
|
741
727
|
[L, x, g]
|
|
742
|
-
),
|
|
728
|
+
), it = N(
|
|
743
729
|
(t) => {
|
|
744
730
|
M.current = !0, Y((r) => ({
|
|
745
731
|
...r,
|
|
@@ -750,7 +736,7 @@ function Mt({
|
|
|
750
736
|
});
|
|
751
737
|
},
|
|
752
738
|
[L]
|
|
753
|
-
),
|
|
739
|
+
), st = N(
|
|
754
740
|
(t) => {
|
|
755
741
|
M.current = !0, Y((r) => ({
|
|
756
742
|
...r,
|
|
@@ -761,7 +747,7 @@ function Mt({
|
|
|
761
747
|
});
|
|
762
748
|
},
|
|
763
749
|
[L]
|
|
764
|
-
),
|
|
750
|
+
), lt = N(
|
|
765
751
|
(t) => {
|
|
766
752
|
M.current = !0, Y((r) => ({
|
|
767
753
|
...r,
|
|
@@ -772,7 +758,7 @@ function Mt({
|
|
|
772
758
|
});
|
|
773
759
|
},
|
|
774
760
|
[L]
|
|
775
|
-
),
|
|
761
|
+
), ct = N(
|
|
776
762
|
(t) => {
|
|
777
763
|
M.current = !0, Y((r) => ({
|
|
778
764
|
...r,
|
|
@@ -783,7 +769,7 @@ function Mt({
|
|
|
783
769
|
});
|
|
784
770
|
},
|
|
785
771
|
[L]
|
|
786
|
-
),
|
|
772
|
+
), dt = N(
|
|
787
773
|
(t) => {
|
|
788
774
|
M.current = !0, Y((r) => ({
|
|
789
775
|
...r,
|
|
@@ -811,19 +797,19 @@ function Mt({
|
|
|
811
797
|
});
|
|
812
798
|
});
|
|
813
799
|
let o = Array.from(i.values());
|
|
814
|
-
const
|
|
815
|
-
|
|
816
|
-
const d =
|
|
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);
|
|
817
803
|
return d && !$ ? -1 : !d && $ ? 1 : d && $ ? K.current.indexOf(n.value) - K.current.indexOf(c.value) : n.value.localeCompare(c.value);
|
|
818
804
|
}) : o.sort(
|
|
819
805
|
(n, c) => c.popularity === n.popularity ? n.value.localeCompare(c.value) : c.popularity - n.popularity
|
|
820
|
-
),
|
|
806
|
+
), he(o);
|
|
821
807
|
} catch (r) {
|
|
822
808
|
console.error("[VehicleSearch] Error loading makes for year:", r);
|
|
823
809
|
}
|
|
824
810
|
})();
|
|
825
811
|
}, [x, e.year]);
|
|
826
|
-
const
|
|
812
|
+
const pt = N(() => {
|
|
827
813
|
(async () => {
|
|
828
814
|
let r = [];
|
|
829
815
|
if (ie.current && ie.current.length)
|
|
@@ -834,11 +820,11 @@ function Mt({
|
|
|
834
820
|
attributesToRetrieve: ["make", "make_popularity"],
|
|
835
821
|
limit: 1e3
|
|
836
822
|
}), o = /* @__PURE__ */ new Map();
|
|
837
|
-
i.hits.forEach((
|
|
838
|
-
|
|
839
|
-
value:
|
|
840
|
-
refinement:
|
|
841
|
-
popularity:
|
|
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
|
|
842
828
|
});
|
|
843
829
|
}), r = Array.from(o.values());
|
|
844
830
|
} catch (i) {
|
|
@@ -852,13 +838,13 @@ function Mt({
|
|
|
852
838
|
}
|
|
853
839
|
if (K.current && K.current.length > 0) {
|
|
854
840
|
const i = new Set(K.current);
|
|
855
|
-
r.sort((o,
|
|
856
|
-
const n = i.has(o.value), c = i.has(
|
|
857
|
-
return n && !c ? -1 : !n && c ? 1 : n && c ? K.current.indexOf(o.value) - K.current.indexOf(
|
|
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);
|
|
858
844
|
});
|
|
859
845
|
} else
|
|
860
846
|
r.sort((i, o) => i.popularity === o.popularity ? i.value.localeCompare(o.value) : o.popularity - i.popularity);
|
|
861
|
-
|
|
847
|
+
he(r);
|
|
862
848
|
})();
|
|
863
849
|
}, [v]);
|
|
864
850
|
B(() => {
|
|
@@ -867,26 +853,26 @@ function Mt({
|
|
|
867
853
|
const r = e.make.refinement;
|
|
868
854
|
if (G && typeof S.current == "object" && !Array.isArray(S.current) && S.current[r]) {
|
|
869
855
|
const i = S.current[r].map(
|
|
870
|
-
(
|
|
871
|
-
value:
|
|
872
|
-
refinement:
|
|
856
|
+
(l) => ({
|
|
857
|
+
value: l,
|
|
858
|
+
refinement: l,
|
|
873
859
|
popularity: 0
|
|
874
860
|
// Popularity will be used from PostHog for sorting
|
|
875
861
|
})
|
|
876
862
|
), o = (t = j.current) == null ? void 0 : t[r];
|
|
877
863
|
if (o && Array.isArray(o)) {
|
|
878
|
-
const
|
|
864
|
+
const l = new Map(
|
|
879
865
|
o.map((n, c) => [
|
|
880
866
|
n.toUpperCase(),
|
|
881
867
|
o.length - c
|
|
882
868
|
])
|
|
883
869
|
);
|
|
884
870
|
i.sort((n, c) => {
|
|
885
|
-
const d =
|
|
871
|
+
const d = l.get(n.value.toUpperCase()) || 0, $ = l.get(c.value.toUpperCase()) || 0;
|
|
886
872
|
return d !== $ ? $ - d : n.value.localeCompare(c.value);
|
|
887
873
|
});
|
|
888
874
|
} else
|
|
889
|
-
i.sort((
|
|
875
|
+
i.sort((l, n) => l.value.localeCompare(n.value));
|
|
890
876
|
ce(i);
|
|
891
877
|
return;
|
|
892
878
|
}
|
|
@@ -897,11 +883,11 @@ function Mt({
|
|
|
897
883
|
limit: 1
|
|
898
884
|
// Only one document per make
|
|
899
885
|
}).then((i) => {
|
|
900
|
-
var
|
|
886
|
+
var ve, ae;
|
|
901
887
|
const { hits: o } = i;
|
|
902
|
-
let
|
|
903
|
-
o.length > 0 && o[0].models && (
|
|
904
|
-
let n =
|
|
888
|
+
let l = [];
|
|
889
|
+
o.length > 0 && o[0].models && (l = o[0].models);
|
|
890
|
+
let n = l.map((h) => ({
|
|
905
891
|
model: `${e.make.refinement} > ${h.name}`,
|
|
906
892
|
model_popularity: h.popularity || 0
|
|
907
893
|
})), c = [];
|
|
@@ -938,18 +924,18 @@ function Mt({
|
|
|
938
924
|
refinement: h.model.match(/[^>]*$/)[0].trim(),
|
|
939
925
|
popularity: h.model_popularity
|
|
940
926
|
}));
|
|
941
|
-
const $ = (
|
|
942
|
-
if (
|
|
927
|
+
const $ = (ve = e.make) == null ? void 0 : ve.refinement, te = (ae = j.current) == null ? void 0 : ae[$];
|
|
928
|
+
if (te && Array.isArray(te) && te.length > 0) {
|
|
943
929
|
const h = new Set(
|
|
944
|
-
|
|
930
|
+
te.map((m) => String(m).trim().toUpperCase())
|
|
945
931
|
);
|
|
946
932
|
n.sort((m, k) => {
|
|
947
933
|
const je = h.has(m.value), Ne = h.has(k.value);
|
|
948
934
|
if (je && !Ne) return -1;
|
|
949
935
|
if (!je && Ne) return 1;
|
|
950
936
|
if (je && Ne) {
|
|
951
|
-
const qe =
|
|
952
|
-
(
|
|
937
|
+
const qe = te.map(
|
|
938
|
+
(ht) => String(ht).trim().toUpperCase()
|
|
953
939
|
);
|
|
954
940
|
return qe.indexOf(m.value) - qe.indexOf(k.value);
|
|
955
941
|
}
|
|
@@ -985,13 +971,13 @@ function Mt({
|
|
|
985
971
|
limit: 200
|
|
986
972
|
// Reduced from 1000 for faster queries
|
|
987
973
|
}).then(({ hits: r }) => {
|
|
988
|
-
const i = r.map((d) => d.year_from), o = Math.min(...i),
|
|
974
|
+
const i = r.map((d) => d.year_from), o = Math.min(...i), l = r.map((d) => d.year_to), n = Math.max(...l);
|
|
989
975
|
let c = Array.apply(null, {
|
|
990
976
|
length: n + 1 - o
|
|
991
977
|
}).map(function(d, $) {
|
|
992
978
|
return $ + o;
|
|
993
979
|
});
|
|
994
|
-
c = c.reverse().map((d) => ({ value: d, refinement: d })),
|
|
980
|
+
c = c.reverse().map((d) => ({ value: d, refinement: d })), ue(c);
|
|
995
981
|
}).catch((r) => {
|
|
996
982
|
console.error("[VehicleSearch] Error fetching years:", r);
|
|
997
983
|
});
|
|
@@ -1023,20 +1009,20 @@ function Mt({
|
|
|
1023
1009
|
i = [...new Map(i.map((o) => [o.body, o])).values()].map((o) => ({
|
|
1024
1010
|
value: o.body.match(/[^>]*$/)[0].trim(),
|
|
1025
1011
|
refinement: o.body.match(/[^>]*$/)[0].trim()
|
|
1026
|
-
})).filter((o) => o.value),
|
|
1012
|
+
})).filter((o) => o.value), be(i);
|
|
1027
1013
|
});
|
|
1028
1014
|
}
|
|
1029
1015
|
}, [e.year, e.make, e.model, g]);
|
|
1030
|
-
const
|
|
1016
|
+
const me = N(({ hits: t, attribute: r, stateCallback: i }) => {
|
|
1031
1017
|
let o = [
|
|
1032
|
-
...new Map(t.map((
|
|
1033
|
-
].map((
|
|
1034
|
-
value:
|
|
1035
|
-
refinement:
|
|
1036
|
-
})).filter((
|
|
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);
|
|
1037
1023
|
i(o);
|
|
1038
|
-
}, []),
|
|
1039
|
-
const t =
|
|
1024
|
+
}, []), vt = N(() => {
|
|
1025
|
+
const t = _e.current ? _e.current.length + 3 : 3, r = C ? t + 1 : t;
|
|
1040
1026
|
return `vs:lg:grid-cols-${r > 8 ? 8 : r}`;
|
|
1041
1027
|
}, [C]);
|
|
1042
1028
|
B(() => {
|
|
@@ -1067,22 +1053,22 @@ function Mt({
|
|
|
1067
1053
|
],
|
|
1068
1054
|
limit: 1e3
|
|
1069
1055
|
}).then(({ hits: o }) => {
|
|
1070
|
-
|
|
1056
|
+
me({
|
|
1071
1057
|
hits: o,
|
|
1072
1058
|
attribute: "series",
|
|
1073
|
-
stateCallback:
|
|
1074
|
-
}),
|
|
1059
|
+
stateCallback: we
|
|
1060
|
+
}), me({
|
|
1075
1061
|
hits: o,
|
|
1076
1062
|
attribute: "variant",
|
|
1077
|
-
stateCallback:
|
|
1078
|
-
}),
|
|
1063
|
+
stateCallback: ye
|
|
1064
|
+
}), me({
|
|
1079
1065
|
hits: o,
|
|
1080
1066
|
attribute: "engine",
|
|
1081
|
-
stateCallback:
|
|
1082
|
-
}),
|
|
1067
|
+
stateCallback: xe
|
|
1068
|
+
}), me({
|
|
1083
1069
|
hits: o,
|
|
1084
1070
|
attribute: "engine_capacity",
|
|
1085
|
-
stateCallback:
|
|
1071
|
+
stateCallback: ke
|
|
1086
1072
|
});
|
|
1087
1073
|
});
|
|
1088
1074
|
}
|
|
@@ -1092,7 +1078,7 @@ function Mt({
|
|
|
1092
1078
|
e.variant,
|
|
1093
1079
|
e.engine,
|
|
1094
1080
|
e.engine_capacity,
|
|
1095
|
-
|
|
1081
|
+
me,
|
|
1096
1082
|
e.make,
|
|
1097
1083
|
e.model,
|
|
1098
1084
|
e.year,
|
|
@@ -1100,12 +1086,12 @@ function Mt({
|
|
|
1100
1086
|
]);
|
|
1101
1087
|
const [ze, Ee] = A(!1);
|
|
1102
1088
|
return B(() => {
|
|
1103
|
-
if (
|
|
1089
|
+
if (T)
|
|
1104
1090
|
return ze ? document.body.style.overflow = "hidden" : document.body.style.overflow = "", () => {
|
|
1105
1091
|
document.body.style.overflow = "";
|
|
1106
1092
|
};
|
|
1107
|
-
}, [ze,
|
|
1108
|
-
|
|
1093
|
+
}, [ze, T]), /* @__PURE__ */ E($e, { children: [
|
|
1094
|
+
T && /* @__PURE__ */ a(
|
|
1109
1095
|
"button",
|
|
1110
1096
|
{
|
|
1111
1097
|
onClick: () => Ee(!0),
|
|
@@ -1114,10 +1100,10 @@ function Mt({
|
|
|
1114
1100
|
"vehicle-search-btn vs:md:hidden!",
|
|
1115
1101
|
V ? "vs:w-full! vs:flex! vs:shrink-0!" : "vs:w-auto! vs:inline-flex! vs:shrink!"
|
|
1116
1102
|
),
|
|
1117
|
-
children: /* @__PURE__ */ a("span", { children:
|
|
1103
|
+
children: /* @__PURE__ */ a("span", { children: s })
|
|
1118
1104
|
}
|
|
1119
1105
|
),
|
|
1120
|
-
|
|
1106
|
+
T && /* @__PURE__ */ a(
|
|
1121
1107
|
"div",
|
|
1122
1108
|
{
|
|
1123
1109
|
onClick: () => Ee(!1),
|
|
@@ -1132,11 +1118,11 @@ function Mt({
|
|
|
1132
1118
|
{
|
|
1133
1119
|
className: ne(
|
|
1134
1120
|
"partbot-mmyvs-container",
|
|
1135
|
-
|
|
1121
|
+
T && ze && "active",
|
|
1136
1122
|
"w-full"
|
|
1137
1123
|
),
|
|
1138
1124
|
children: [
|
|
1139
|
-
|
|
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: [
|
|
1140
1126
|
/* @__PURE__ */ a("span", { children: "Select Vehicle" }),
|
|
1141
1127
|
/* @__PURE__ */ E(
|
|
1142
1128
|
"button",
|
|
@@ -1163,10 +1149,10 @@ function Mt({
|
|
|
1163
1149
|
/* @__PURE__ */ E(
|
|
1164
1150
|
"div",
|
|
1165
1151
|
{
|
|
1166
|
-
ref:
|
|
1152
|
+
ref: F,
|
|
1167
1153
|
className: ne(
|
|
1168
1154
|
"vs:grid vs:gap-3",
|
|
1169
|
-
I === "row" ? `${
|
|
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",
|
|
1170
1156
|
"vs:w-full vs:transition vs:lg:mx-auto"
|
|
1171
1157
|
),
|
|
1172
1158
|
children: [
|
|
@@ -1206,7 +1192,7 @@ function Mt({
|
|
|
1206
1192
|
X,
|
|
1207
1193
|
{
|
|
1208
1194
|
label: "Model",
|
|
1209
|
-
items:
|
|
1195
|
+
items: ge,
|
|
1210
1196
|
refine: Ye,
|
|
1211
1197
|
selected: e.model,
|
|
1212
1198
|
showPopular: !0,
|
|
@@ -1214,7 +1200,7 @@ function Mt({
|
|
|
1214
1200
|
showLabel: _,
|
|
1215
1201
|
isMobile: J,
|
|
1216
1202
|
sortOptions: !1,
|
|
1217
|
-
loading: e.make &&
|
|
1203
|
+
loading: e.make && ge.length === 0,
|
|
1218
1204
|
shouldBeActive: !!e.make
|
|
1219
1205
|
}
|
|
1220
1206
|
)
|
|
@@ -1239,7 +1225,7 @@ function Mt({
|
|
|
1239
1225
|
X,
|
|
1240
1226
|
{
|
|
1241
1227
|
label: "Model",
|
|
1242
|
-
items:
|
|
1228
|
+
items: ge,
|
|
1243
1229
|
refine: Ye,
|
|
1244
1230
|
selected: e.model,
|
|
1245
1231
|
showPopular: !0,
|
|
@@ -1247,7 +1233,7 @@ function Mt({
|
|
|
1247
1233
|
showLabel: _,
|
|
1248
1234
|
isMobile: J,
|
|
1249
1235
|
sortOptions: !1,
|
|
1250
|
-
loading: e.make &&
|
|
1236
|
+
loading: e.make && ge.length === 0,
|
|
1251
1237
|
shouldBeActive: !!e.make
|
|
1252
1238
|
}
|
|
1253
1239
|
),
|
|
@@ -1267,7 +1253,7 @@ function Mt({
|
|
|
1267
1253
|
}
|
|
1268
1254
|
)
|
|
1269
1255
|
] }),
|
|
1270
|
-
|
|
1256
|
+
_e.current && _e.current.map((t) => {
|
|
1271
1257
|
let r = null;
|
|
1272
1258
|
switch (t) {
|
|
1273
1259
|
case "body":
|
|
@@ -1276,7 +1262,7 @@ function Mt({
|
|
|
1276
1262
|
{
|
|
1277
1263
|
label: "Body",
|
|
1278
1264
|
items: Le,
|
|
1279
|
-
refine:
|
|
1265
|
+
refine: it,
|
|
1280
1266
|
selected: e.body,
|
|
1281
1267
|
bgDark: H,
|
|
1282
1268
|
showLabel: _,
|
|
@@ -1293,7 +1279,7 @@ function Mt({
|
|
|
1293
1279
|
{
|
|
1294
1280
|
label: "Series",
|
|
1295
1281
|
items: Ie,
|
|
1296
|
-
refine:
|
|
1282
|
+
refine: st,
|
|
1297
1283
|
selected: e.series,
|
|
1298
1284
|
bgDark: H,
|
|
1299
1285
|
showLabel: _,
|
|
@@ -1310,7 +1296,7 @@ function Mt({
|
|
|
1310
1296
|
{
|
|
1311
1297
|
label: "Variant",
|
|
1312
1298
|
items: Ve,
|
|
1313
|
-
refine:
|
|
1299
|
+
refine: lt,
|
|
1314
1300
|
selected: e.variant,
|
|
1315
1301
|
bgDark: H,
|
|
1316
1302
|
showLabel: _,
|
|
@@ -1326,13 +1312,13 @@ function Mt({
|
|
|
1326
1312
|
X,
|
|
1327
1313
|
{
|
|
1328
1314
|
label: "Engine Capacity",
|
|
1329
|
-
items:
|
|
1330
|
-
refine:
|
|
1315
|
+
items: Fe,
|
|
1316
|
+
refine: dt,
|
|
1331
1317
|
selected: e.engine_capacity,
|
|
1332
1318
|
bgDark: H,
|
|
1333
1319
|
showLabel: _,
|
|
1334
1320
|
isMobile: J,
|
|
1335
|
-
loading: !!(e.make && e.model && e.year) &&
|
|
1321
|
+
loading: !!(e.make && e.model && e.year) && Fe.length === 0,
|
|
1336
1322
|
shouldBeActive: !!(e.make && e.model && e.year)
|
|
1337
1323
|
},
|
|
1338
1324
|
"engine_capacity"
|
|
@@ -1344,7 +1330,7 @@ function Mt({
|
|
|
1344
1330
|
{
|
|
1345
1331
|
label: "Engine",
|
|
1346
1332
|
items: De,
|
|
1347
|
-
refine:
|
|
1333
|
+
refine: ct,
|
|
1348
1334
|
selected: e.engine,
|
|
1349
1335
|
bgDark: H,
|
|
1350
1336
|
showLabel: _,
|
|
@@ -1363,18 +1349,18 @@ function Mt({
|
|
|
1363
1349
|
{
|
|
1364
1350
|
className: "vehicle-search-btn",
|
|
1365
1351
|
onClick: () => {
|
|
1366
|
-
Me(!0),
|
|
1352
|
+
Me(!0), U && !q ? window.location.href = U + window.location.search : nt();
|
|
1367
1353
|
},
|
|
1368
1354
|
children: [
|
|
1369
1355
|
/* @__PURE__ */ a("span", { children: y }),
|
|
1370
|
-
|
|
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" })
|
|
1371
1357
|
]
|
|
1372
1358
|
}
|
|
1373
1359
|
) })
|
|
1374
1360
|
]
|
|
1375
1361
|
}
|
|
1376
1362
|
),
|
|
1377
|
-
|
|
1363
|
+
O && /* @__PURE__ */ a(
|
|
1378
1364
|
"div",
|
|
1379
1365
|
{
|
|
1380
1366
|
className: ne(
|
|
@@ -1403,9 +1389,9 @@ function Mt({
|
|
|
1403
1389
|
)
|
|
1404
1390
|
] });
|
|
1405
1391
|
}
|
|
1406
|
-
let
|
|
1392
|
+
let We = !1, fe = !1;
|
|
1407
1393
|
function At(b) {
|
|
1408
|
-
var
|
|
1394
|
+
var T, re;
|
|
1409
1395
|
const v = b.shadowRoot;
|
|
1410
1396
|
if (!v) {
|
|
1411
1397
|
console.error("[ShadowDOMPatch] No shadow root found");
|
|
@@ -1419,13 +1405,13 @@ function At(b) {
|
|
|
1419
1405
|
if (new MutationObserver((u) => {
|
|
1420
1406
|
u.forEach((y) => {
|
|
1421
1407
|
y.addedNodes.forEach((C) => {
|
|
1422
|
-
C.nodeType === 1 && C.id === "headlessui-portal-root" && (p.appendChild(C),
|
|
1408
|
+
C.nodeType === 1 && C.id === "headlessui-portal-root" && (p.appendChild(C), fe = !0);
|
|
1423
1409
|
});
|
|
1424
1410
|
}), u.forEach((y) => {
|
|
1425
1411
|
y.removedNodes.forEach((C) => {
|
|
1426
1412
|
C.nodeType === 1 && C.id === "headlessui-portal-root" && (p.querySelector(
|
|
1427
1413
|
"#headlessui-portal-root"
|
|
1428
|
-
) || (
|
|
1414
|
+
) || (fe = !1));
|
|
1429
1415
|
});
|
|
1430
1416
|
});
|
|
1431
1417
|
}).observe(document.body, {
|
|
@@ -1433,35 +1419,35 @@ function At(b) {
|
|
|
1433
1419
|
}), new MutationObserver((u) => {
|
|
1434
1420
|
u.forEach((y) => {
|
|
1435
1421
|
y.removedNodes.forEach((C) => {
|
|
1436
|
-
C.nodeType === 1 && C.id === "headlessui-portal-root" && (
|
|
1422
|
+
C.nodeType === 1 && C.id === "headlessui-portal-root" && (fe = !1);
|
|
1437
1423
|
});
|
|
1438
1424
|
});
|
|
1439
1425
|
}).observe(p, {
|
|
1440
1426
|
childList: !0,
|
|
1441
1427
|
subtree: !0
|
|
1442
|
-
}),
|
|
1428
|
+
}), We)
|
|
1443
1429
|
return;
|
|
1444
|
-
const R = (
|
|
1430
|
+
const R = (T = Object.getOwnPropertyDescriptor(
|
|
1445
1431
|
Document.prototype,
|
|
1446
1432
|
"activeElement"
|
|
1447
|
-
)) == null ? void 0 :
|
|
1433
|
+
)) == null ? void 0 : T.get;
|
|
1448
1434
|
Object.defineProperty(Document.prototype, "activeElement", {
|
|
1449
1435
|
get: function() {
|
|
1450
1436
|
const u = R == null ? void 0 : R.call(this);
|
|
1451
1437
|
return u === b ? v.activeElement : u;
|
|
1452
1438
|
}
|
|
1453
1439
|
});
|
|
1454
|
-
const P = (
|
|
1440
|
+
const P = (re = Object.getOwnPropertyDescriptor(
|
|
1455
1441
|
Event.prototype,
|
|
1456
1442
|
"target"
|
|
1457
|
-
)) == null ? void 0 :
|
|
1443
|
+
)) == null ? void 0 : re.get;
|
|
1458
1444
|
Object.defineProperty(Event.prototype, "target", {
|
|
1459
1445
|
get: function() {
|
|
1460
1446
|
const u = P == null ? void 0 : P.call(this);
|
|
1461
1447
|
return u === b ? this.composedPath()[0] : u;
|
|
1462
1448
|
}
|
|
1463
1449
|
});
|
|
1464
|
-
const
|
|
1450
|
+
const O = (u) => {
|
|
1465
1451
|
try {
|
|
1466
1452
|
return document.body && u === document.body.style;
|
|
1467
1453
|
} catch {
|
|
@@ -1469,7 +1455,7 @@ function At(b) {
|
|
|
1469
1455
|
}
|
|
1470
1456
|
}, _ = CSSStyleDeclaration.prototype.setProperty;
|
|
1471
1457
|
CSSStyleDeclaration.prototype.setProperty = function(u, y, C) {
|
|
1472
|
-
if (!(
|
|
1458
|
+
if (!(O(this) && u === "overflow" && y === "hidden" && fe))
|
|
1473
1459
|
return _.call(this, u, y, C);
|
|
1474
1460
|
};
|
|
1475
1461
|
const V = Object.getOwnPropertyDescriptor(
|
|
@@ -1481,10 +1467,10 @@ function At(b) {
|
|
|
1481
1467
|
return V.get.call(this);
|
|
1482
1468
|
},
|
|
1483
1469
|
set: function(u) {
|
|
1484
|
-
if (!(
|
|
1470
|
+
if (!(O(this) && u === "hidden" && fe))
|
|
1485
1471
|
return V.set.call(this, u);
|
|
1486
1472
|
}
|
|
1487
|
-
}),
|
|
1473
|
+
}), We = !0;
|
|
1488
1474
|
}
|
|
1489
1475
|
const Et = "/css/vehicle-search.css", Yt = Et;
|
|
1490
1476
|
class jt extends HTMLElement {
|
|
@@ -1495,13 +1481,13 @@ class jt extends HTMLElement {
|
|
|
1495
1481
|
}
|
|
1496
1482
|
let v = document.createElement("style");
|
|
1497
1483
|
v.textContent = zt;
|
|
1498
|
-
const p = document.createElement("div"),
|
|
1484
|
+
const p = document.createElement("div"), U = this.attachShadow({ mode: "open" }), I = (j, Q, w) => {
|
|
1499
1485
|
let W;
|
|
1500
1486
|
if (this.hasAttribute(Q)) {
|
|
1501
1487
|
const M = this.getAttribute(Q);
|
|
1502
1488
|
if (/^#[0-9A-F]{6}$/i.test(M)) {
|
|
1503
|
-
const x = parseInt(M.slice(1, 3), 16), le = parseInt(M.slice(3, 5), 16),
|
|
1504
|
-
W = `${x} ${le} ${
|
|
1489
|
+
const x = parseInt(M.slice(1, 3), 16), le = parseInt(M.slice(3, 5), 16), he = parseInt(M.slice(5, 7), 16);
|
|
1490
|
+
W = `${x} ${le} ${he}`;
|
|
1505
1491
|
}
|
|
1506
1492
|
}
|
|
1507
1493
|
return W = W || w, `:host { --${j}: ${W}; } .partbot-mmyvs-container { --${j}: ${W}; }`;
|
|
@@ -1514,7 +1500,7 @@ class jt extends HTMLElement {
|
|
|
1514
1500
|
"partbot-button-color",
|
|
1515
1501
|
"data-button-color",
|
|
1516
1502
|
"0 0 0"
|
|
1517
|
-
),
|
|
1503
|
+
), O = I(
|
|
1518
1504
|
"partbot-button-hover-color",
|
|
1519
1505
|
"data-button-hover-color",
|
|
1520
1506
|
"0 0 0"
|
|
@@ -1526,13 +1512,13 @@ class jt extends HTMLElement {
|
|
|
1526
1512
|
"partbot-button-hover-label-color",
|
|
1527
1513
|
"data-button-hover-label-color",
|
|
1528
1514
|
"255 255 255"
|
|
1529
|
-
),
|
|
1515
|
+
), T = I(
|
|
1530
1516
|
"partbot-mobile-background-color",
|
|
1531
1517
|
"data-mobile-background-color",
|
|
1532
1518
|
"0 0 0"
|
|
1533
|
-
),
|
|
1534
|
-
const q = this.getAttribute("data-input-shadow"),
|
|
1535
|
-
let G = `:host { --partbot-input-shadow: ${
|
|
1519
|
+
), re = `:host { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius") || "0.375rem"}; } .partbot-mmyvs-container { --partbot-button-border-radius: ${this.getAttribute("data-button-border-radius") || "0.375rem"}; }`, u = `:host { --partbot-font-size: ${this.getAttribute("data-font-size") || "0.875rem"}; } .partbot-mmyvs-container { --partbot-font-size: ${this.getAttribute("data-font-size") || "0.875rem"}; }`, y = `:host { --partbot-font-family: ${(this.getAttribute("data-font-family") || this.getAttribute("data-font")) && (this.getAttribute("data-font-family") || this.getAttribute("data-font")).trim() !== "" ? this.getAttribute("data-font-family") || this.getAttribute("data-font") : '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}; } .partbot-mmyvs-container { --partbot-font-family: ${(this.getAttribute("data-font-family") || this.getAttribute("data-font")) && (this.getAttribute("data-font-family") || this.getAttribute("data-font")).trim() !== "" ? this.getAttribute("data-font-family") || this.getAttribute("data-font") : '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif'}; }`, C = `:host { --partbot-padding: ${this.getAttribute("data-padding") || "0.5rem"}; } .partbot-mmyvs-container { --partbot-padding: ${this.getAttribute("data-padding") || "0.5rem"}; }`;
|
|
1520
|
+
const q = this.getAttribute("data-input-shadow"), ee = q === "none" ? "none" : q || "0 1px 2px 0 rgb(0 0 0 / 0.05)";
|
|
1521
|
+
let G = `:host { --partbot-input-shadow: ${ee}; } .partbot-mmyvs-container { --partbot-input-shadow: ${ee}; }`;
|
|
1536
1522
|
const f = this.getAttribute("data-input-border-color");
|
|
1537
1523
|
let D = "229 231 235";
|
|
1538
1524
|
if (f)
|
|
@@ -1541,9 +1527,9 @@ class jt extends HTMLElement {
|
|
|
1541
1527
|
D = `${j} ${Q} ${w}`;
|
|
1542
1528
|
} else /^\d+\s+\d+\s+\d+$/.test(f) && (D = f);
|
|
1543
1529
|
let g = `:host { --partbot-input-border-color: ${D}; } .partbot-mmyvs-container { --partbot-input-border-color: ${D}; }`;
|
|
1544
|
-
const
|
|
1545
|
-
let
|
|
1546
|
-
v.textContent += R, v.textContent += P, v.textContent +=
|
|
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);
|
|
1547
1533
|
const z = this.getAttribute("data-api-key");
|
|
1548
1534
|
if (!z) {
|
|
1549
1535
|
console.warn("Missing attributes: " + (z ? "" : "data-api-key "));
|
|
@@ -1559,7 +1545,7 @@ class jt extends HTMLElement {
|
|
|
1559
1545
|
}
|
|
1560
1546
|
At(this);
|
|
1561
1547
|
const K = /* @__PURE__ */ a(Mt, { ...S });
|
|
1562
|
-
|
|
1548
|
+
mt.render(K, p);
|
|
1563
1549
|
}
|
|
1564
1550
|
}
|
|
1565
1551
|
customElements.define("vehicle-search", jt);
|