@pitvox/partner-react 0.2.1 → 0.4.0

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/index.js CHANGED
@@ -1,73 +1,74 @@
1
- import { jsx as e, jsxs as l, Fragment as Q } from "react/jsx-runtime";
2
- import { createContext as Re, useMemo as k, useContext as De, useState as j, useCallback as G } from "react";
3
- import { useQueryClient as J, QueryClient as Ie, QueryClientProvider as Me, useQuery as L, useMutation as ie } from "@tanstack/react-query";
4
- import { useSearchParams as oe } from "react-router-dom";
5
- const z = Re(null), Be = "https://cdn.pitvox.com", Ae = "https://api.pitvox.com";
6
- let W = null;
7
- function At({
8
- partnerSlug: t,
9
- apiKey: r,
10
- cdnUrl: n = Be,
11
- apiUrl: a = Ae,
12
- getSteamId: s,
13
- children: i
1
+ import { jsx as e, jsxs as l, Fragment as K } from "react/jsx-runtime";
2
+ import { createContext as fe, useMemo as C, useContext as Ne, useState as L, useCallback as q } from "react";
3
+ import { useQueryClient as H, QueryClient as be, QueryClientProvider as ye, useQuery as k, useMutation as ne } from "@tanstack/react-query";
4
+ const j = fe(null), Ce = "https://cdn.pitvox.com", we = "https://pitvox.com";
5
+ let V = null;
6
+ function or({
7
+ partnerSlug: r,
8
+ cdnUrl: t = Ce,
9
+ pitvoxUrl: n = we,
10
+ getSteamId: a,
11
+ onRegister: s,
12
+ onWithdraw: i,
13
+ children: o
14
14
  }) {
15
- const c = k(() => ({
16
- partnerSlug: t,
17
- apiKey: r,
18
- cdnUrl: n.replace(/\/$/, ""),
19
- apiUrl: a.replace(/\/$/, ""),
20
- getSteamId: s || (() => null)
21
- }), [t, r, n, a, s]);
22
- let o = !1;
15
+ const c = C(() => ({
16
+ partnerSlug: r,
17
+ cdnUrl: t.replace(/\/$/, ""),
18
+ pitvoxUrl: n.replace(/\/$/, ""),
19
+ getSteamId: a || (() => null),
20
+ onRegister: s || null,
21
+ onWithdraw: i || null
22
+ }), [r, t, n, a, s, i]);
23
+ let v = !1;
23
24
  try {
24
- J(), o = !0;
25
+ H(), v = !0;
25
26
  } catch {
26
- o = !1;
27
+ v = !1;
27
28
  }
28
- return o ? /* @__PURE__ */ e(z.Provider, { value: c, children: i }) : (W || (W = new Ie({
29
+ return v ? /* @__PURE__ */ e(j.Provider, { value: c, children: o }) : (V || (V = new be({
29
30
  defaultOptions: {
30
31
  queries: { staleTime: 6e4 }
31
32
  }
32
- })), /* @__PURE__ */ e(Me, { client: W, children: /* @__PURE__ */ e(z.Provider, { value: c, children: i }) }));
33
+ })), /* @__PURE__ */ e(ye, { client: V, children: /* @__PURE__ */ e(j.Provider, { value: c, children: o }) }));
33
34
  }
34
- function T() {
35
- const t = De(z);
36
- if (!t)
35
+ function y() {
36
+ const r = Ne(j);
37
+ if (!r)
37
38
  throw new Error("usePitVox must be used within a <PitVoxPartnerProvider>");
38
- return t;
39
+ return r;
39
40
  }
40
- async function $(t, r) {
41
- const n = await fetch(`${t}/${r}`);
41
+ async function T(r, t) {
42
+ const n = await fetch(`${r}/${t}`);
42
43
  if (!n.ok) {
43
44
  if (n.status === 404 || n.status === 403) return null;
44
45
  throw new Error(`CDN fetch failed: ${n.status}`);
45
46
  }
46
47
  return n.json();
47
48
  }
48
- function E(t) {
49
- if (!t && t !== 0) return "-";
50
- const r = Math.floor(t / 1e3), n = Math.floor(r / 60), a = r % 60, s = t % 1e3;
49
+ function B(r) {
50
+ if (!r && r !== 0) return "-";
51
+ const t = Math.floor(r / 1e3), n = Math.floor(t / 60), a = t % 60, s = r % 1e3;
51
52
  return `${n}:${String(a).padStart(2, "0")}.${String(s).padStart(3, "0")}`;
52
53
  }
53
- function P(t) {
54
- return !t && t !== 0 ? "-" : (t / 1e3).toFixed(3);
54
+ function $(r) {
55
+ return !r && r !== 0 ? "-" : (r / 1e3).toFixed(3);
55
56
  }
56
- function I(t) {
57
- if (!t) return "";
58
- let r = t;
59
- return r.startsWith("ks_") && (r = r.slice(3)), r.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
57
+ function R(r) {
58
+ if (!r) return "";
59
+ let t = r;
60
+ return t.startsWith("ks_") && (t = t.slice(3)), t.split("_").map((n) => n.charAt(0).toUpperCase() + n.slice(1)).join(" ");
60
61
  }
61
- function V(t, r, n) {
62
- const a = t.split("_").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join(" "), s = n === "acc" || !n && (r == null ? void 0 : r.toLowerCase()) === "track config";
63
- if (!r || r === "default" || s) return a;
64
- const i = r.split("_").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join(" ");
62
+ function O(r, t, n) {
63
+ const a = r.split("_").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" "), s = n === "acc" || !n && (t == null ? void 0 : t.toLowerCase()) === "track config";
64
+ if (!t || t === "default" || s) return a;
65
+ const i = t.split("_").map((o) => o.charAt(0).toUpperCase() + o.slice(1)).join(" ");
65
66
  return `${a} ${i}`;
66
67
  }
67
- function F(t) {
68
- if (!t) return "-";
68
+ function D(r) {
69
+ if (!r) return "-";
69
70
  try {
70
- return new Date(t).toLocaleDateString("en-GB", {
71
+ return new Date(r).toLocaleDateString("en-GB", {
71
72
  day: "numeric",
72
73
  month: "short",
73
74
  year: "numeric"
@@ -76,22 +77,22 @@ function F(t) {
76
77
  return "-";
77
78
  }
78
79
  }
79
- function Pt(t) {
80
- if (!t) return "";
81
- const r = Date.now() - new Date(t).getTime(), n = Math.floor(r / 1e3);
80
+ function cr(r) {
81
+ if (!r) return "";
82
+ const t = Date.now() - new Date(r).getTime(), n = Math.floor(t / 1e3);
82
83
  if (n < 60) return "Just now";
83
84
  const a = Math.floor(n / 60);
84
85
  if (a < 60) return `${a}m ago`;
85
86
  const s = Math.floor(a / 60);
86
87
  if (s < 24) return `${s}h ago`;
87
88
  const i = Math.floor(s / 24);
88
- return i < 30 ? `${i}d ago` : F(t);
89
+ return i < 30 ? `${i}d ago` : D(r);
89
90
  }
90
- function Ut(t) {
91
- return t == null ? "" : `${t >= 0 ? "+" : "-"}${(Math.abs(t) / 1e3).toFixed(3)}`;
91
+ function dr(r) {
92
+ return r == null ? "" : `${r >= 0 ? "+" : "-"}${(Math.abs(r) / 1e3).toFixed(3)}`;
92
93
  }
93
- function le(t) {
94
- return t ? {
94
+ function se(r) {
95
+ return r ? {
95
96
  E: "Eco",
96
97
  RD: "Road",
97
98
  SC: "SuperCar",
@@ -102,103 +103,103 @@ function le(t) {
102
103
  MR: "Medium Race",
103
104
  SR: "Soft Race",
104
105
  S: "Soft"
105
- }[t] || t : "Unknown";
106
+ }[r] || r : "Unknown";
106
107
  }
107
- function Pe(t = {}) {
108
- var o, m, d, g, N, x;
109
- const { cdnUrl: r, partnerSlug: n } = T(), { game: a, gameVersion: s } = t, i = L({
108
+ function pr(r = {}) {
109
+ var c, v, d, u, b, x;
110
+ const { cdnUrl: t, partnerSlug: n } = y(), { game: a, gameVersion: s } = r, i = k({
110
111
  queryKey: ["pitvox", "leaderboards", n, "index"],
111
- queryFn: () => $(r, `leaderboards/partners/${n}/index.json`),
112
+ queryFn: () => T(t, `leaderboards/partners/${n}/index.json`),
112
113
  staleTime: 3e4,
113
114
  refetchInterval: 3e4
114
- }), c = k(() => {
115
- var f;
116
- if (!((f = i.data) != null && f.tracks)) return [];
117
- let h = i.data.tracks;
118
- return a && (h = h.filter((p) => p.game === a)), s && (h = h.filter((p) => p.gameVersion === s)), h.map((p) => ({
115
+ }), o = C(() => {
116
+ var g;
117
+ if (!((g = i.data) != null && g.tracks)) return [];
118
+ let m = i.data.tracks;
119
+ return a && (m = m.filter((p) => p.game === a)), s && (m = m.filter((p) => p.gameVersion === s)), m.map((p) => ({
119
120
  id: p.trackId,
120
121
  layout: p.layout,
121
122
  game: p.game,
122
123
  gameVersion: p.gameVersion,
123
- displayName: V(p.trackId, p.layout, p.game),
124
+ displayName: O(p.trackId, p.layout, p.game),
124
125
  driverCount: p.driverCount || 0,
125
126
  carCount: p.carCount || 0,
126
127
  record: p.recordHolder ? {
127
128
  visibleId: p.recordHolder.steamId || p.recordHolder.userId,
128
129
  carId: p.recordHolder.carId,
129
- carDisplayName: I(p.recordHolder.carId),
130
+ carDisplayName: R(p.recordHolder.carId),
130
131
  lapTimeMs: p.recordHolder.lapTimeMs,
131
132
  timestamp: p.recordHolder.recordedAt
132
133
  } : null,
133
134
  recordByTag: p.recordByTag || null
134
135
  }));
135
- }, [(o = i.data) == null ? void 0 : o.tracks, a, s]);
136
+ }, [(c = i.data) == null ? void 0 : c.tracks, a, s]);
136
137
  return {
137
138
  ...i,
138
- data: c,
139
- partner: ((m = i.data) == null ? void 0 : m.partner) || null,
139
+ data: o,
140
+ partner: ((v = i.data) == null ? void 0 : v.partner) || null,
140
141
  generatedAt: (d = i.data) == null ? void 0 : d.generatedAt,
141
- totalLaps: ((g = i.data) == null ? void 0 : g.totalLaps) || 0,
142
- totalUsers: ((N = i.data) == null ? void 0 : N.totalUsers) || 0,
142
+ totalLaps: ((u = i.data) == null ? void 0 : u.totalLaps) || 0,
143
+ totalUsers: ((b = i.data) == null ? void 0 : b.totalUsers) || 0,
143
144
  versions: ((x = i.data) == null ? void 0 : x.versions) || {}
144
145
  };
145
146
  }
146
- function ce(t, r, n = {}) {
147
- const { cdnUrl: a, partnerSlug: s } = T(), { carId: i, game: c, gameVersion: o } = n, m = r || "default", d = o ? `leaderboards/partners/${s}/v/${o}/tracks/${t}/${m}.json` : `leaderboards/partners/${s}/tracks/${t}/${m}.json`, { data: g, isLoading: N, error: x } = L({
148
- queryKey: ["pitvox", "leaderboards", s, "track", t, m, o],
149
- queryFn: () => $(a, d),
150
- enabled: !!t,
147
+ function ke(r, t, n = {}) {
148
+ const { cdnUrl: a, partnerSlug: s } = y(), { carId: i, game: o, gameVersion: c } = n, v = t || "default", d = c ? `leaderboards/partners/${s}/v/${c}/tracks/${r}/${v}.json` : `leaderboards/partners/${s}/tracks/${r}/${v}.json`, { data: u, isLoading: b, error: x } = k({
149
+ queryKey: ["pitvox", "leaderboards", s, "track", r, v, c],
150
+ queryFn: () => T(a, d),
151
+ enabled: !!r,
151
152
  staleTime: 3e4,
152
153
  refetchInterval: 3e4
153
154
  });
154
- return { data: k(() => {
155
- if (!(g != null && g.entries)) return [];
156
- let f = g.entries;
157
- if (c && (f = f.filter((p) => p.game === c)), !i) {
158
- const p = /* @__PURE__ */ new Map(), v = /* @__PURE__ */ new Map();
159
- for (const u of f) {
160
- const y = u.steamId || u.userId;
161
- v.has(u.carId) || v.set(u.carId, /* @__PURE__ */ new Set()), v.get(u.carId).add(y), (!p.has(u.carId) || u.lapTimeMs < p.get(u.carId).lapTimeMs) && p.set(u.carId, u);
155
+ return { data: C(() => {
156
+ if (!(u != null && u.entries)) return [];
157
+ let g = u.entries;
158
+ if (o && (g = g.filter((p) => p.game === o)), !i) {
159
+ const p = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
160
+ for (const h of g) {
161
+ const N = h.steamId || h.userId;
162
+ f.has(h.carId) || f.set(h.carId, /* @__PURE__ */ new Set()), f.get(h.carId).add(N), (!p.has(h.carId) || h.lapTimeMs < p.get(h.carId).lapTimeMs) && p.set(h.carId, h);
162
163
  }
163
- return Array.from(p.values()).map((u) => {
164
- var y;
165
- return { ...u, driverCount: ((y = v.get(u.carId)) == null ? void 0 : y.size) || 0 };
166
- }).sort((u, y) => u.lapTimeMs - y.lapTimeMs);
164
+ return Array.from(p.values()).map((h) => {
165
+ var N;
166
+ return { ...h, driverCount: ((N = f.get(h.carId)) == null ? void 0 : N.size) || 0 };
167
+ }).sort((h, N) => h.lapTimeMs - N.lapTimeMs);
167
168
  }
168
- return f.filter((p) => p.carId === i).sort((p, v) => p.lapTimeMs - v.lapTimeMs);
169
- }, [g == null ? void 0 : g.entries, i, c]), isLoading: N, error: x };
170
- }
171
- function Ue(t, r, n, a, s = {}) {
172
- var x, h;
173
- const { cdnUrl: i, partnerSlug: c } = T(), { showInvalid: o = !1, game: m, gameVersion: d } = s, g = L({
174
- queryKey: ["pitvox", "laps", c, t],
175
- queryFn: () => $(i, `laps/partners/${c}/${t}.json`),
176
- enabled: !!t,
169
+ return g.filter((p) => p.carId === i).sort((p, f) => p.lapTimeMs - f.lapTimeMs);
170
+ }, [u == null ? void 0 : u.entries, i, o]), isLoading: b, error: x };
171
+ }
172
+ function Te(r, t, n, a, s = {}) {
173
+ var x, m;
174
+ const { cdnUrl: i, partnerSlug: o } = y(), { showInvalid: c = !1, game: v, gameVersion: d } = s, u = k({
175
+ queryKey: ["pitvox", "laps", o, r],
176
+ queryFn: () => T(i, `laps/partners/${o}/${r}.json`),
177
+ enabled: !!r,
177
178
  staleTime: 3e4,
178
179
  refetchInterval: 3e4
179
- }), N = k(() => {
180
- var f;
181
- return (f = g.data) != null && f.laps ? g.data.laps.filter((p) => {
182
- if (p.trackId !== r) return !1;
180
+ }), b = C(() => {
181
+ var g;
182
+ return (g = u.data) != null && g.laps ? u.data.laps.filter((p) => {
183
+ if (p.trackId !== t) return !1;
183
184
  if (n) {
184
185
  if (p.trackLayout !== n) return !1;
185
186
  } else if (p.trackLayout && p.trackLayout !== "default") return !1;
186
- return !(p.carId !== a || m && p.game !== m || d && p.gameVersion !== d || !o && !p.isValid);
187
- }).sort((p, v) => p.lapTimeMs - v.lapTimeMs) : [];
188
- }, [(x = g.data) == null ? void 0 : x.laps, r, n, a, m, d, o]);
187
+ return !(p.carId !== a || v && p.game !== v || d && p.gameVersion !== d || !c && !p.isValid);
188
+ }).sort((p, f) => p.lapTimeMs - f.lapTimeMs) : [];
189
+ }, [(x = u.data) == null ? void 0 : x.laps, t, n, a, v, d, c]);
189
190
  return {
190
- ...g,
191
- data: N,
192
- driverName: ((h = g.data) == null ? void 0 : h.driverName) || "Driver"
191
+ ...u,
192
+ data: b,
193
+ driverName: ((m = u.data) == null ? void 0 : m.driverName) || "Driver"
193
194
  };
194
195
  }
195
- function Ee() {
196
- const { cdnUrl: t } = T(), { data: r } = L({
196
+ function vr() {
197
+ const { cdnUrl: r } = y(), { data: t } = k({
197
198
  queryKey: ["pitvox", "users", "index"],
198
- queryFn: () => $(t, "users/index.json"),
199
+ queryFn: () => T(r, "users/index.json"),
199
200
  staleTime: 5 * 6e4,
200
201
  gcTime: 30 * 6e4
201
- }), n = (r == null ? void 0 : r.users) || {};
202
+ }), n = (t == null ? void 0 : t.users) || {};
202
203
  return (a, s) => {
203
204
  const i = n[a];
204
205
  return {
@@ -208,153 +209,145 @@ function Ee() {
208
209
  };
209
210
  };
210
211
  }
211
- function Fe() {
212
- const { cdnUrl: t } = T(), { data: r } = L({
212
+ function mr() {
213
+ const { cdnUrl: r } = y(), { data: t } = k({
213
214
  queryKey: ["pitvox", "cars", "index"],
214
- queryFn: () => $(t, "cars/index.json"),
215
+ queryFn: () => T(r, "cars/index.json"),
215
216
  staleTime: 5 * 6e4,
216
217
  gcTime: 30 * 6e4
217
218
  });
218
219
  return {
219
- tags: (r == null ? void 0 : r.tags) || [],
220
- cars: (r == null ? void 0 : r.cars) || {}
220
+ tags: (t == null ? void 0 : t.tags) || [],
221
+ cars: (t == null ? void 0 : t.cars) || {}
221
222
  };
222
223
  }
223
- function Et(t, r) {
224
- return ce(t, null, { carId: r });
224
+ function hr(r, t) {
225
+ return ke(r, null, { carId: t });
225
226
  }
226
- function _e() {
227
- const { cdnUrl: t, partnerSlug: r } = T();
228
- return L({
229
- queryKey: ["pitvox", "competitions", r],
227
+ function ur() {
228
+ const { cdnUrl: r, partnerSlug: t } = y();
229
+ return k({
230
+ queryKey: ["pitvox", "competitions", t],
230
231
  queryFn: async () => {
231
- const n = await $(t, "competitions/index.json");
232
- return n != null && n.competitions ? n.competitions.filter((a) => a.partnerSlug === r) : [];
232
+ const n = await T(r, "competitions/index.json");
233
+ return n != null && n.competitions ? n.competitions.filter((a) => a.partnerSlug === t) : [];
233
234
  },
234
235
  staleTime: 6e4
235
236
  });
236
237
  }
237
- function de(t) {
238
- const { cdnUrl: r, partnerSlug: n } = T();
239
- return L({
240
- queryKey: ["pitvox", "competition", n, t, "config"],
241
- queryFn: () => $(r, `competitions/${n}/${t}/config.json`),
242
- enabled: !!t,
238
+ function Se(r) {
239
+ const { cdnUrl: t, partnerSlug: n } = y();
240
+ return k({
241
+ queryKey: ["pitvox", "competition", n, r, "config"],
242
+ queryFn: () => T(t, `competitions/${n}/${r}/config.json`),
243
+ enabled: !!r,
243
244
  staleTime: 6e4
244
245
  });
245
246
  }
246
- function qe(t) {
247
- const { cdnUrl: r, partnerSlug: n } = T();
248
- return L({
249
- queryKey: ["pitvox", "competition", n, t, "standings"],
250
- queryFn: () => $(r, `competitions/${n}/${t}/standings.json`),
251
- enabled: !!t,
247
+ function Re(r) {
248
+ const { cdnUrl: t, partnerSlug: n } = y();
249
+ return k({
250
+ queryKey: ["pitvox", "competition", n, r, "standings"],
251
+ queryFn: () => T(t, `competitions/${n}/${r}/standings.json`),
252
+ enabled: !!r,
252
253
  staleTime: 6e4
253
254
  });
254
255
  }
255
- function je(t, r) {
256
- const { cdnUrl: n, partnerSlug: a } = T();
257
- return L({
258
- queryKey: ["pitvox", "competition", a, t, "round", r],
259
- queryFn: () => $(n, `competitions/${a}/${t}/rounds/${r}.json`),
260
- enabled: !!t && r != null,
256
+ function Le(r, t) {
257
+ const { cdnUrl: n, partnerSlug: a } = y();
258
+ return k({
259
+ queryKey: ["pitvox", "competition", a, r, "round", t],
260
+ queryFn: () => T(n, `competitions/${a}/${r}/rounds/${t}.json`),
261
+ enabled: !!r && t != null,
261
262
  staleTime: 6e4
262
263
  });
263
264
  }
264
- function Ft(t, r = []) {
265
- const { cdnUrl: n, partnerSlug: a } = T();
266
- return L({
267
- queryKey: ["pitvox", "competition", a, t, "allRounds", r],
265
+ function xr(r, t = []) {
266
+ const { cdnUrl: n, partnerSlug: a } = y();
267
+ return k({
268
+ queryKey: ["pitvox", "competition", a, r, "allRounds", t],
268
269
  queryFn: async () => (await Promise.all(
269
- r.map(
270
- (i) => $(n, `competitions/${a}/${t}/rounds/${i}.json`).catch(() => null)
270
+ t.map(
271
+ (i) => T(n, `competitions/${a}/${r}/rounds/${i}.json`).catch(() => null)
271
272
  )
272
273
  )).filter(Boolean),
273
- enabled: !!t && r.length > 0,
274
+ enabled: !!r && t.length > 0,
274
275
  staleTime: 6e4
275
276
  });
276
277
  }
277
- function Ve(t) {
278
- const { cdnUrl: r, partnerSlug: n } = T();
279
- return L({
280
- queryKey: ["pitvox", "competition", n, t, "entrylist"],
281
- queryFn: () => $(r, `competitions/${n}/${t}/entrylist.json`),
282
- enabled: !!t,
278
+ function ae(r) {
279
+ const { cdnUrl: t, partnerSlug: n } = y();
280
+ return k({
281
+ queryKey: ["pitvox", "competition", n, r, "entrylist"],
282
+ queryFn: () => T(t, `competitions/${n}/${r}/entrylist.json`),
283
+ enabled: !!r,
283
284
  staleTime: 6e4
284
285
  });
285
286
  }
286
- async function pe(t, r, n, a = {}) {
287
- const s = await fetch(`${t}${n}`, {
288
- ...a,
289
- headers: {
290
- "Content-Type": "application/json",
291
- "X-Partner-Key": r,
292
- ...a.headers
293
- }
294
- });
295
- if (!s.ok) {
296
- const i = await s.json().catch(() => ({}));
297
- throw new Error(i.detail || `API request failed: ${s.status}`);
298
- }
299
- return s.json();
300
- }
301
- function Ke(t, r, n, a) {
302
- return pe(t, r, `/api/v1/competitions/${n}/register`, {
303
- method: "POST",
304
- body: JSON.stringify(a)
305
- });
306
- }
307
- function He(t, r, n, a) {
308
- return pe(t, r, `/api/v1/competitions/${n}/register/${a}`, {
309
- method: "DELETE"
310
- });
311
- }
312
- function Oe(t) {
313
- const { cdnUrl: r, partnerSlug: n, getSteamId: a } = T(), s = a();
314
- return L({
315
- queryKey: ["pitvox", "registration", n, t, s],
287
+ function W(r) {
288
+ const { cdnUrl: t, partnerSlug: n, getSteamId: a } = y(), s = a();
289
+ return k({
290
+ queryKey: ["pitvox", "registration", n, r, s],
316
291
  queryFn: async () => {
317
- var m;
318
- const i = await fetch(`${r}/competitions/${n}/${t}/entrylist.json`);
292
+ var v;
293
+ const i = await fetch(`${t}/competitions/${n}/${r}/entrylist.json`);
319
294
  if (!i.ok) return { isRegistered: !1, entryList: null };
320
- const c = await i.json();
321
- return { isRegistered: !!s && ((m = c.drivers) == null ? void 0 : m.some((d) => d.steamId === s)), entryList: c };
295
+ const o = await i.json();
296
+ return { isRegistered: !!s && ((v = o.drivers) == null ? void 0 : v.some((d) => d.steamId === s)), entryList: o };
322
297
  },
323
- enabled: !!t,
298
+ enabled: !!r,
324
299
  staleTime: 6e4
325
300
  });
326
301
  }
327
- function We(t) {
328
- const { apiUrl: r, apiKey: n, partnerSlug: a } = T(), s = J();
329
- return ie({
330
- mutationFn: (i) => Ke(r, n, t, i),
302
+ function ie(r) {
303
+ const { onRegister: t, partnerSlug: n } = y(), a = H();
304
+ return ne({
305
+ mutationFn: (s) => {
306
+ if (!t)
307
+ throw new Error(
308
+ "No onRegister callback provided to PitVoxPartnerProvider. Provide onRegister for in-app registration, or use useRegistrationUrl() to link to pitvox.com."
309
+ );
310
+ return t(r, s);
311
+ },
331
312
  onSuccess: () => {
332
- s.invalidateQueries({
333
- queryKey: ["pitvox", "registration", a, t]
334
- }), s.invalidateQueries({
335
- queryKey: ["pitvox", "competition", a, t, "entrylist"]
313
+ a.invalidateQueries({
314
+ queryKey: ["pitvox", "registration", n, r]
315
+ }), a.invalidateQueries({
316
+ queryKey: ["pitvox", "competition", n, r, "entrylist"]
336
317
  });
337
318
  }
338
319
  });
339
320
  }
340
- function Ge(t) {
341
- const { apiUrl: r, apiKey: n, partnerSlug: a, getSteamId: s } = T(), i = J();
342
- return ie({
343
- mutationFn: (c) => {
344
- const o = c || s();
321
+ function le(r) {
322
+ const { onWithdraw: t, partnerSlug: n, getSteamId: a } = y(), s = H();
323
+ return ne({
324
+ mutationFn: (i) => {
325
+ if (!t)
326
+ throw new Error(
327
+ "No onWithdraw callback provided to PitVoxPartnerProvider. Provide onWithdraw for in-app withdrawal, or use useRegistrationUrl() to link to pitvox.com."
328
+ );
329
+ const o = i || a();
345
330
  if (!o) throw new Error("No Steam ID available");
346
- return He(r, n, t, o);
331
+ return t(r, o);
347
332
  },
348
333
  onSuccess: () => {
349
- i.invalidateQueries({
350
- queryKey: ["pitvox", "registration", a, t]
351
- }), i.invalidateQueries({
352
- queryKey: ["pitvox", "competition", a, t, "entrylist"]
334
+ s.invalidateQueries({
335
+ queryKey: ["pitvox", "registration", n, r]
336
+ }), s.invalidateQueries({
337
+ queryKey: ["pitvox", "competition", n, r, "entrylist"]
353
338
  });
354
339
  }
355
340
  });
356
341
  }
357
- const ze = {
342
+ function G() {
343
+ const { onRegister: r, onWithdraw: t } = y(), n = !!(r && t);
344
+ return { isPowerMode: n, isBasicMode: !n };
345
+ }
346
+ function z(r) {
347
+ const { pitvoxUrl: t, partnerSlug: n } = y();
348
+ return `${t}/p/${n}/competitions/${r}/register`;
349
+ }
350
+ const $e = {
358
351
  formula: "Formula",
359
352
  gt3: "GT3",
360
353
  gt2: "GT2",
@@ -374,279 +367,279 @@ const ze = {
374
367
  "2000s": "2000s",
375
368
  "2010s": "2010s",
376
369
  "2020s": "2020s"
377
- }, ue = [
370
+ }, oe = [
378
371
  { id: "class", tags: ["formula", "gt3", "gt2", "gt4", "cup", "prototype", "rally"] },
379
372
  { id: "tier", tags: ["hypercar", "supercar", "sports_car", "hot_hatch", "lightweight"] },
380
373
  { id: "era", tags: ["1960s", "1970s", "1980s", "1990s", "2000s", "2010s", "2020s"] }
381
374
  ];
382
- function Qe(t) {
383
- for (const r of ue)
384
- if (r.tags.includes(t)) return r.id;
375
+ function Me(r) {
376
+ for (const t of oe)
377
+ if (t.tags.includes(r)) return t.id;
385
378
  return "other";
386
379
  }
387
- function me(t, r) {
388
- if (r.size === 0) return !0;
380
+ function ce(r, t) {
381
+ if (t.size === 0) return !0;
389
382
  const n = {};
390
- for (const a of r) {
391
- const s = Qe(a);
383
+ for (const a of t) {
384
+ const s = Me(a);
392
385
  n[s] || (n[s] = []), n[s].push(a);
393
386
  }
394
387
  for (const a of Object.values(n))
395
- if (!a.some((s) => t.includes(s))) return !1;
388
+ if (!a.some((s) => r.includes(s))) return !1;
396
389
  return !0;
397
390
  }
398
- function he() {
399
- const [t, r] = j(/* @__PURE__ */ new Set()), n = G((s) => {
400
- r((i) => {
401
- const c = new Set(i);
402
- return c.has(s) ? c.delete(s) : c.add(s), c;
391
+ function de() {
392
+ const [r, t] = L(/* @__PURE__ */ new Set()), n = q((s) => {
393
+ t((i) => {
394
+ const o = new Set(i);
395
+ return o.has(s) ? o.delete(s) : o.add(s), o;
403
396
  });
404
- }, []), a = G(() => r(/* @__PURE__ */ new Set()), []);
405
- return { activeTags: t, toggle: n, clear: a };
397
+ }, []), a = q(() => t(/* @__PURE__ */ new Set()), []);
398
+ return { activeTags: r, toggle: n, clear: a };
406
399
  }
407
- function Z(t) {
408
- const [r, n] = j(t), a = G((s) => {
400
+ function Q(r) {
401
+ const [t, n] = L(r), a = q((s) => {
409
402
  n(
410
403
  (i) => i.key === s ? { key: s, dir: i.dir === "asc" ? "desc" : "asc" } : { key: s, dir: s.includes("timestamp") || s.includes("Date") ? "desc" : "asc" }
411
404
  );
412
405
  }, []);
413
- return [r, a];
406
+ return [t, a];
414
407
  }
415
- function X(t, r, n) {
416
- return [...t].sort((a, s) => {
417
- const i = n(a, r.key), c = n(s, r.key);
418
- if (i == null && c == null) return 0;
408
+ function Z(r, t, n) {
409
+ return [...r].sort((a, s) => {
410
+ const i = n(a, t.key), o = n(s, t.key);
411
+ if (i == null && o == null) return 0;
419
412
  if (i == null) return 1;
420
- if (c == null) return -1;
421
- const o = typeof i == "string" ? i.localeCompare(c) : i - c;
422
- return r.dir === "desc" ? -o : o;
413
+ if (o == null) return -1;
414
+ const c = typeof i == "string" ? i.localeCompare(o) : i - o;
415
+ return t.dir === "desc" ? -c : c;
423
416
  });
424
417
  }
425
- function ve(t, r = !1) {
426
- const n = r ? t == null ? void 0 : t.filter((a) => a.isValid) : t;
418
+ function pe(r, t = !1) {
419
+ const n = t ? r == null ? void 0 : r.filter((a) => a.isValid) : r;
427
420
  return n != null && n.length ? {
428
421
  s1: Math.min(...n.map((a) => a.sector1Ms).filter(Boolean)),
429
422
  s2: Math.min(...n.map((a) => a.sector2Ms).filter(Boolean)),
430
423
  s3: Math.min(...n.map((a) => a.sector3Ms).filter(Boolean))
431
424
  } : null;
432
425
  }
433
- function Je({ active: t, dir: r }) {
434
- return t ? r === "asc" ? /* @__PURE__ */ e("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) }) : /* @__PURE__ */ e("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) }) : /* @__PURE__ */ e("svg", { className: "pvx-sort-icon pvx-sort-icon--inactive", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 9l4-4 4 4M16 15l-4 4-4-4" }) });
426
+ function Pe({ active: r, dir: t }) {
427
+ return r ? t === "asc" ? /* @__PURE__ */ e("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 15.75l7.5-7.5 7.5 7.5" }) }) : /* @__PURE__ */ e("svg", { className: "pvx-sort-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M19.5 8.25l-7.5 7.5-7.5-7.5" }) }) : /* @__PURE__ */ e("svg", { className: "pvx-sort-icon pvx-sort-icon--inactive", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8 9l4-4 4 4M16 15l-4 4-4-4" }) });
435
428
  }
436
- function D({ label: t, sortKey: r, config: n, onSort: a, className: s = "" }) {
429
+ function S({ label: r, sortKey: t, config: n, onSort: a, className: s = "" }) {
437
430
  return /* @__PURE__ */ e(
438
431
  "th",
439
432
  {
440
433
  className: `pvx-th pvx-th--sortable ${s}`,
441
- onClick: () => a(r),
434
+ onClick: () => a(t),
442
435
  children: /* @__PURE__ */ l("span", { className: "pvx-th-inner", children: [
443
- t,
444
- /* @__PURE__ */ e(Je, { active: n.key === r, dir: n.dir })
436
+ r,
437
+ /* @__PURE__ */ e(Pe, { active: n.key === t, dir: n.dir })
445
438
  ] })
446
439
  }
447
440
  );
448
441
  }
449
- function Y({ userId: t, getUserDisplay: r }) {
450
- const { displayName: n, avatarUrl: a } = r(t);
442
+ function J({ userId: r, getUserDisplay: t }) {
443
+ const { displayName: n, avatarUrl: a } = t(r);
451
444
  return /* @__PURE__ */ l("span", { className: "pvx-driver", children: [
452
445
  a ? /* @__PURE__ */ e("img", { src: a, alt: "", className: "pvx-driver-avatar" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--placeholder" }),
453
446
  /* @__PURE__ */ e("span", { className: "pvx-driver-name", children: n })
454
447
  ] });
455
448
  }
456
- function xe({ rank: t, podium: r = !1 }) {
457
- return /* @__PURE__ */ e("span", { className: r ? t === 1 ? "pvx-rank pvx-rank--gold" : t === 2 ? "pvx-rank pvx-rank--silver" : t === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank" : "pvx-rank", children: t });
449
+ function ve({ rank: r, podium: t = !1 }) {
450
+ return /* @__PURE__ */ e("span", { className: t ? r === 1 ? "pvx-rank pvx-rank--gold" : r === 2 ? "pvx-rank pvx-rank--silver" : r === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank" : "pvx-rank", children: r });
458
451
  }
459
- function ge({ availableTags: t, activeTags: r, onToggle: n, onClear: a }) {
460
- if (!t || t.length < 2) return null;
461
- const s = ue.map((i) => ({ id: i.id, tags: i.tags.filter((c) => t.includes(c)) })).filter((i) => i.tags.length > 0);
452
+ function me({ availableTags: r, activeTags: t, onToggle: n, onClear: a }) {
453
+ if (!r || r.length < 2) return null;
454
+ const s = oe.map((i) => ({ id: i.id, tags: i.tags.filter((o) => r.includes(o)) })).filter((i) => i.tags.length > 0);
462
455
  return /* @__PURE__ */ l("div", { className: "pvx-tag-bar", children: [
463
456
  /* @__PURE__ */ e(
464
457
  "button",
465
458
  {
466
459
  onClick: a,
467
- className: `pvx-tag ${r.size === 0 ? "pvx-tag--active" : ""}`,
460
+ className: `pvx-tag ${t.size === 0 ? "pvx-tag--active" : ""}`,
468
461
  children: "All"
469
462
  }
470
463
  ),
471
- s.map((i, c) => /* @__PURE__ */ l("span", { className: "contents", children: [
472
- c > 0 && /* @__PURE__ */ e("span", { className: "pvx-tag-separator" }),
473
- i.tags.map((o) => /* @__PURE__ */ e(
464
+ s.map((i, o) => /* @__PURE__ */ l("span", { className: "contents", children: [
465
+ o > 0 && /* @__PURE__ */ e("span", { className: "pvx-tag-separator" }),
466
+ i.tags.map((c) => /* @__PURE__ */ e(
474
467
  "button",
475
468
  {
476
- onClick: () => n(o),
477
- className: `pvx-tag ${r.has(o) ? "pvx-tag--active" : ""}`,
478
- children: ze[o] || o
469
+ onClick: () => n(c),
470
+ className: `pvx-tag ${t.has(c) ? "pvx-tag--active" : ""}`,
471
+ children: $e[c] || c
479
472
  },
480
- o
473
+ c
481
474
  ))
482
475
  ] }, i.id))
483
476
  ] });
484
477
  }
485
- function ee({ segments: t }) {
486
- return /* @__PURE__ */ e("nav", { className: "pvx-breadcrumb", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "pvx-breadcrumb-list", children: t.map((r, n) => {
487
- const a = n === t.length - 1;
478
+ function Y({ segments: r }) {
479
+ return /* @__PURE__ */ e("nav", { className: "pvx-breadcrumb", "aria-label": "Breadcrumb", children: /* @__PURE__ */ e("ol", { className: "pvx-breadcrumb-list", children: r.map((t, n) => {
480
+ const a = n === r.length - 1;
488
481
  return /* @__PURE__ */ l("li", { className: "pvx-breadcrumb-item", children: [
489
482
  n > 0 && /* @__PURE__ */ e("svg", { className: "pvx-breadcrumb-chevron", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M8.25 4.5l7.5 7.5-7.5 7.5" }) }),
490
- !a && r.onClick ? /* @__PURE__ */ e("button", { onClick: r.onClick, className: "pvx-breadcrumb-link", children: r.label }) : /* @__PURE__ */ e("span", { className: "pvx-breadcrumb-current", children: r.label })
491
- ] }, r.key);
483
+ !a && t.onClick ? /* @__PURE__ */ e("button", { onClick: t.onClick, className: "pvx-breadcrumb-link", children: t.label }) : /* @__PURE__ */ e("span", { className: "pvx-breadcrumb-current", children: t.label })
484
+ ] }, t.key);
492
485
  }) }) });
493
486
  }
494
- function K({ message: t }) {
487
+ function I({ message: r }) {
495
488
  return /* @__PURE__ */ l("div", { className: "pvx-empty", children: [
496
489
  /* @__PURE__ */ e("svg", { className: "pvx-empty-icon", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M16.5 18.75h-9m9 0a3 3 0 013 3h-15a3 3 0 013-3m9 0v-4.5A3.375 3.375 0 0013.125 10.875h-2.25A3.375 3.375 0 007.5 14.25v4.5" }) }),
497
- /* @__PURE__ */ e("p", { children: t })
490
+ /* @__PURE__ */ e("p", { children: r })
498
491
  ] });
499
492
  }
500
- function H() {
493
+ function A() {
501
494
  return /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading..." });
502
495
  }
503
- function Ze() {
496
+ function Be() {
504
497
  return /* @__PURE__ */ e("svg", { className: "pvx-icon pvx-icon--valid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M4.5 12.75l6 6 9-13.5" }) });
505
498
  }
506
- function Xe() {
499
+ function De() {
507
500
  return /* @__PURE__ */ e("svg", { className: "pvx-icon pvx-icon--invalid", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) });
508
501
  }
509
- function Ye({ tracks: t, isLoading: r, carMetadata: n, getUserDisplay: a, onTrackSelect: s }) {
510
- const [i, c] = Z({ key: "record.timestamp", dir: "desc" }), { activeTags: o, toggle: m, clear: d } = he(), g = k(() => {
511
- var f;
512
- if (!((f = n == null ? void 0 : n.tags) != null && f.length)) return [];
513
- const h = /* @__PURE__ */ new Set();
514
- for (const p of t || [])
515
- p.recordByTag && Object.keys(p.recordByTag).forEach((v) => h.add(v));
516
- return n.tags.filter((p) => h.has(p));
517
- }, [t, n]), N = k(() => t ? o.size === 0 ? t : t.map((h) => {
518
- var v, u;
519
- if (!h.recordByTag) return null;
520
- let f = null;
502
+ function gr({ tracks: r, isLoading: t, carMetadata: n, getUserDisplay: a, onTrackSelect: s }) {
503
+ const [i, o] = Q({ key: "record.timestamp", dir: "desc" }), { activeTags: c, toggle: v, clear: d } = de(), u = C(() => {
504
+ var g;
505
+ if (!((g = n == null ? void 0 : n.tags) != null && g.length)) return [];
506
+ const m = /* @__PURE__ */ new Set();
507
+ for (const p of r || [])
508
+ p.recordByTag && Object.keys(p.recordByTag).forEach((f) => m.add(f));
509
+ return n.tags.filter((p) => m.has(p));
510
+ }, [r, n]), b = C(() => r ? c.size === 0 ? r : r.map((m) => {
511
+ var f, h;
512
+ if (!m.recordByTag) return null;
513
+ let g = null;
521
514
  const p = /* @__PURE__ */ new Set();
522
- for (const y of Object.values(h.recordByTag)) {
523
- if (p.has(y.carId)) continue;
524
- p.add(y.carId);
525
- const C = ((u = (v = n == null ? void 0 : n.cars) == null ? void 0 : v[y.carId]) == null ? void 0 : u.tags) || ["sports_car"];
526
- me(C, o) && (!f || y.lapTimeMs < f.lapTimeMs) && (f = y);
515
+ for (const N of Object.values(m.recordByTag)) {
516
+ if (p.has(N.carId)) continue;
517
+ p.add(N.carId);
518
+ const w = ((h = (f = n == null ? void 0 : n.cars) == null ? void 0 : f[N.carId]) == null ? void 0 : h.tags) || ["sports_car"];
519
+ ce(w, c) && (!g || N.lapTimeMs < g.lapTimeMs) && (g = N);
527
520
  }
528
- return f ? {
529
- ...h,
521
+ return g ? {
522
+ ...m,
530
523
  record: {
531
- visibleId: f.steamId || f.identifier,
532
- carId: f.carId,
533
- carDisplayName: I(f.carId),
534
- lapTimeMs: f.lapTimeMs,
535
- timestamp: f.recordedAt
524
+ visibleId: g.steamId || g.identifier,
525
+ carId: g.carId,
526
+ carDisplayName: R(g.carId),
527
+ lapTimeMs: g.lapTimeMs,
528
+ timestamp: g.recordedAt
536
529
  }
537
530
  } : null;
538
- }).filter(Boolean) : [], [t, o, n]), x = k(() => X(N, i, (h, f) => {
539
- var p, v;
540
- switch (f) {
531
+ }).filter(Boolean) : [], [r, c, n]), x = C(() => Z(b, i, (m, g) => {
532
+ var p, f;
533
+ switch (g) {
541
534
  case "displayName":
542
- return h.displayName;
535
+ return m.displayName;
543
536
  case "record.lapTimeMs":
544
- return (p = h.record) == null ? void 0 : p.lapTimeMs;
537
+ return (p = m.record) == null ? void 0 : p.lapTimeMs;
545
538
  case "driverCount":
546
- return h.driverCount || 0;
539
+ return m.driverCount || 0;
547
540
  case "carCount":
548
- return h.carCount || 0;
541
+ return m.carCount || 0;
549
542
  case "record.timestamp":
550
543
  default:
551
- return (v = h.record) != null && v.timestamp ? new Date(h.record.timestamp).getTime() : 0;
544
+ return (f = m.record) != null && f.timestamp ? new Date(m.record.timestamp).getTime() : 0;
552
545
  }
553
- }), [N, i]);
554
- return r ? /* @__PURE__ */ e(H, {}) : t != null && t.length ? /* @__PURE__ */ l("div", { className: "pvx-card", children: [
546
+ }), [b, i]);
547
+ return t ? /* @__PURE__ */ e(A, {}) : r != null && r.length ? /* @__PURE__ */ l("div", { className: "pvx-card", children: [
555
548
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e("h2", { className: "pvx-card-title", children: "Track Records" }) }),
556
- /* @__PURE__ */ e(ge, { availableTags: g, activeTags: o, onToggle: m, onClear: d }),
549
+ /* @__PURE__ */ e(me, { availableTags: u, activeTags: c, onToggle: v, onClear: d }),
557
550
  /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
558
551
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
559
- /* @__PURE__ */ e(D, { label: "Track", sortKey: "displayName", config: i, onSort: c }),
552
+ /* @__PURE__ */ e(S, { label: "Track", sortKey: "displayName", config: i, onSort: o }),
560
553
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Record Holder" }),
561
554
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Car" }),
562
- /* @__PURE__ */ e(D, { label: "Lap Time", sortKey: "record.lapTimeMs", config: i, onSort: c }),
563
- /* @__PURE__ */ e(D, { label: "Drivers", sortKey: "driverCount", config: i, onSort: c, className: "pvx-hidden-below-md" }),
564
- /* @__PURE__ */ e(D, { label: "Cars", sortKey: "carCount", config: i, onSort: c, className: "pvx-hidden-below-lg" }),
565
- /* @__PURE__ */ e(D, { label: "Date", sortKey: "record.timestamp", config: i, onSort: c, className: "pvx-hidden-below-xl" })
555
+ /* @__PURE__ */ e(S, { label: "Lap Time", sortKey: "record.lapTimeMs", config: i, onSort: o }),
556
+ /* @__PURE__ */ e(S, { label: "Drivers", sortKey: "driverCount", config: i, onSort: o, className: "pvx-hidden-below-md" }),
557
+ /* @__PURE__ */ e(S, { label: "Cars", sortKey: "carCount", config: i, onSort: o, className: "pvx-hidden-below-lg" }),
558
+ /* @__PURE__ */ e(S, { label: "Date", sortKey: "record.timestamp", config: i, onSort: o, className: "pvx-hidden-below-xl" })
566
559
  ] }) }),
567
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: x.map((h) => {
568
- var f, p, v;
560
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: x.map((m) => {
561
+ var g, p, f;
569
562
  return /* @__PURE__ */ l(
570
563
  "tr",
571
564
  {
572
565
  className: "pvx-row pvx-row--clickable",
573
- onClick: () => s(h.id, h.layout),
566
+ onClick: () => s(m.id, m.layout),
574
567
  children: [
575
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: h.displayName }),
576
- /* @__PURE__ */ e("td", { className: "pvx-td", children: (f = h.record) != null && f.visibleId ? /* @__PURE__ */ e(Y, { userId: h.record.visibleId, getUserDisplay: a }) : "-" }),
577
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-lg", children: ((p = h.record) == null ? void 0 : p.carDisplayName) || "-" }),
578
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: h.record ? E(h.record.lapTimeMs) : "-" }),
579
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: h.driverCount || "-" }),
580
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: h.carCount || "-" }),
581
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (v = h.record) != null && v.timestamp ? F(h.record.timestamp) : "-" })
568
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: m.displayName }),
569
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: (g = m.record) != null && g.visibleId ? /* @__PURE__ */ e(J, { userId: m.record.visibleId, getUserDisplay: a }) : "-" }),
570
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-lg", children: ((p = m.record) == null ? void 0 : p.carDisplayName) || "-" }),
571
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: m.record ? B(m.record.lapTimeMs) : "-" }),
572
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: m.driverCount || "-" }),
573
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: m.carCount || "-" }),
574
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: (f = m.record) != null && f.timestamp ? D(m.record.timestamp) : "-" })
582
575
  ]
583
576
  },
584
- `${h.id}|${h.layout || ""}`
577
+ `${m.id}|${m.layout || ""}`
585
578
  );
586
579
  }) })
587
580
  ] }) })
588
- ] }) : /* @__PURE__ */ e(K, { message: "No lap times recorded yet." });
589
- }
590
- function et({ entries: t, isLoading: r, track: n, carMetadata: a, getUserDisplay: s, onCarSelect: i, onNavigate: c }) {
591
- const [o, m] = Z({ key: "lapTimeMs", dir: "asc" }), { activeTags: d, toggle: g, clear: N } = he(), x = k(() => {
592
- var u, y, C;
593
- if (!t || !((u = a == null ? void 0 : a.tags) != null && u.length)) return [];
594
- const v = /* @__PURE__ */ new Set();
595
- for (const R of t)
596
- (((C = (y = a.cars) == null ? void 0 : y[R.carId]) == null ? void 0 : C.tags) || ["sports_car"]).forEach((S) => v.add(S));
597
- return a.tags.filter((R) => v.has(R));
598
- }, [t, a]), h = k(() => t ? d.size === 0 ? t : t.filter((v) => {
599
- var y, C;
600
- const u = ((C = (y = a == null ? void 0 : a.cars) == null ? void 0 : y[v.carId]) == null ? void 0 : C.tags) || ["sports_car"];
601
- return me(u, d);
602
- }) : [], [t, d, a]), f = k(() => X(h, o, (v, u) => {
603
- switch (u) {
581
+ ] }) : /* @__PURE__ */ e(I, { message: "No lap times recorded yet." });
582
+ }
583
+ function fr({ entries: r, isLoading: t, track: n, carMetadata: a, getUserDisplay: s, onCarSelect: i, onNavigate: o }) {
584
+ const [c, v] = Q({ key: "lapTimeMs", dir: "asc" }), { activeTags: d, toggle: u, clear: b } = de(), x = C(() => {
585
+ var h, N, w;
586
+ if (!r || !((h = a == null ? void 0 : a.tags) != null && h.length)) return [];
587
+ const f = /* @__PURE__ */ new Set();
588
+ for (const P of r)
589
+ (((w = (N = a.cars) == null ? void 0 : N[P.carId]) == null ? void 0 : w.tags) || ["sports_car"]).forEach((F) => f.add(F));
590
+ return a.tags.filter((P) => f.has(P));
591
+ }, [r, a]), m = C(() => r ? d.size === 0 ? r : r.filter((f) => {
592
+ var N, w;
593
+ const h = ((w = (N = a == null ? void 0 : a.cars) == null ? void 0 : N[f.carId]) == null ? void 0 : w.tags) || ["sports_car"];
594
+ return ce(h, d);
595
+ }) : [], [r, d, a]), g = C(() => Z(m, c, (f, h) => {
596
+ switch (h) {
604
597
  case "carId":
605
- return I(v.carId);
598
+ return R(f.carId);
606
599
  case "driverCount":
607
- return v.driverCount || 0;
600
+ return f.driverCount || 0;
608
601
  case "lapTimeMs":
609
602
  default:
610
- return v.lapTimeMs;
603
+ return f.lapTimeMs;
611
604
  }
612
- }), [h, o]), p = [
613
- { key: "tracks", label: "Tracks", onClick: () => c("tracks") },
605
+ }), [m, c]), p = [
606
+ { key: "tracks", label: "Tracks", onClick: () => o("tracks") },
614
607
  { key: "track", label: n.displayName }
615
608
  ];
616
- return r ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
617
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(ee, { segments: p }) }),
618
- /* @__PURE__ */ e(ge, { availableTags: x, activeTags: d, onToggle: g, onClear: N }),
619
- t != null && t.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
609
+ return t ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
610
+ /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(Y, { segments: p }) }),
611
+ /* @__PURE__ */ e(me, { availableTags: x, activeTags: d, onToggle: u, onClear: b }),
612
+ r != null && r.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
620
613
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
621
614
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
622
- /* @__PURE__ */ e(D, { label: "Car", sortKey: "carId", config: o, onSort: m }),
615
+ /* @__PURE__ */ e(S, { label: "Car", sortKey: "carId", config: c, onSort: v }),
623
616
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Record Holder" }),
624
- /* @__PURE__ */ e(D, { label: "Lap Time", sortKey: "lapTimeMs", config: o, onSort: m }),
625
- /* @__PURE__ */ e(D, { label: "Drivers", sortKey: "driverCount", config: o, onSort: m, className: "pvx-hidden-below-md" }),
617
+ /* @__PURE__ */ e(S, { label: "Lap Time", sortKey: "lapTimeMs", config: c, onSort: v }),
618
+ /* @__PURE__ */ e(S, { label: "Drivers", sortKey: "driverCount", config: c, onSort: v, className: "pvx-hidden-below-md" }),
626
619
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Date" })
627
620
  ] }) }),
628
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: f.map((v, u) => /* @__PURE__ */ l(
621
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: g.map((f, h) => /* @__PURE__ */ l(
629
622
  "tr",
630
623
  {
631
624
  className: "pvx-row pvx-row--clickable",
632
- onClick: () => i(v.carId),
625
+ onClick: () => i(f.carId),
633
626
  children: [
634
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(xe, { rank: u + 1, podium: !0 }) }),
635
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: I(v.carId) }),
636
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(Y, { userId: v.steamId || v.userId, getUserDisplay: s }) }),
637
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: E(v.lapTimeMs) }),
638
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: v.driverCount || "-" }),
639
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: v.recordedAt ? F(v.recordedAt) : "-" })
627
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ve, { rank: h + 1, podium: !0 }) }),
628
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: R(f.carId) }),
629
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(J, { userId: f.steamId || f.userId, getUserDisplay: s }) }),
630
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: B(f.lapTimeMs) }),
631
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-md", children: f.driverCount || "-" }),
632
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-lg", children: f.recordedAt ? D(f.recordedAt) : "-" })
640
633
  ]
641
634
  },
642
- v.carId
635
+ f.carId
643
636
  )) })
644
- ] }) }) : /* @__PURE__ */ e(K, { message: "No lap times for this track yet." })
637
+ ] }) }) : /* @__PURE__ */ e(I, { message: "No lap times for this track yet." })
645
638
  ] });
646
639
  }
647
- function tt({ entries: t, isLoading: r, track: n, carId: a, getUserDisplay: s, onDriverSelect: i, onNavigate: c }) {
648
- const [o, m] = Z({ key: "lapTimeMs", dir: "asc" }), d = k(() => ve(t), [t]), g = k(() => X(t || [], o, (x, h) => {
649
- switch (h) {
640
+ function Nr({ entries: r, isLoading: t, track: n, carId: a, getUserDisplay: s, onDriverSelect: i, onNavigate: o }) {
641
+ const [c, v] = Q({ key: "lapTimeMs", dir: "asc" }), d = C(() => pe(r), [r]), u = C(() => Z(r || [], c, (x, m) => {
642
+ switch (m) {
650
643
  case "userId":
651
644
  return s(x.steamId || x.userId).displayName;
652
645
  case "lapCount":
@@ -655,67 +648,67 @@ function tt({ entries: t, isLoading: r, track: n, carId: a, getUserDisplay: s, o
655
648
  default:
656
649
  return x.lapTimeMs;
657
650
  }
658
- }), [t, o, s]), N = [
659
- { key: "tracks", label: "Tracks", onClick: () => c("tracks") },
660
- { key: "track", label: n.displayName, onClick: () => c("track") },
661
- { key: "car", label: I(a) }
651
+ }), [r, c, s]), b = [
652
+ { key: "tracks", label: "Tracks", onClick: () => o("tracks") },
653
+ { key: "track", label: n.displayName, onClick: () => o("track") },
654
+ { key: "car", label: R(a) }
662
655
  ];
663
- return r ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
664
- /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(ee, { segments: N }) }),
665
- t != null && t.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
656
+ return t ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
657
+ /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ e(Y, { segments: b }) }),
658
+ r != null && r.length ? /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
666
659
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
667
660
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "#" }),
668
- /* @__PURE__ */ e(D, { label: "Driver", sortKey: "userId", config: o, onSort: m }),
669
- /* @__PURE__ */ e(D, { label: "Lap Time", sortKey: "lapTimeMs", config: o, onSort: m }),
661
+ /* @__PURE__ */ e(S, { label: "Driver", sortKey: "userId", config: c, onSort: v }),
662
+ /* @__PURE__ */ e(S, { label: "Lap Time", sortKey: "lapTimeMs", config: c, onSort: v }),
670
663
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S1" }),
671
664
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S2" }),
672
665
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "S3" }),
673
666
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Tyre" }),
674
667
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Fuel" }),
675
- /* @__PURE__ */ e(D, { label: "Laps", sortKey: "lapCount", config: o, onSort: m, className: "pvx-hidden-below-lg" }),
668
+ /* @__PURE__ */ e(S, { label: "Laps", sortKey: "lapCount", config: c, onSort: v, className: "pvx-hidden-below-lg" }),
676
669
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
677
670
  ] }) }),
678
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: g.map((x, h) => {
679
- const f = h + 1, p = x.steamId || x.userId, v = d && x.sector1Ms === d.s1, u = d && x.sector2Ms === d.s2, y = d && x.sector3Ms === d.s3;
671
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: u.map((x, m) => {
672
+ const g = m + 1, p = x.steamId || x.userId, f = d && x.sector1Ms === d.s1, h = d && x.sector2Ms === d.s2, N = d && x.sector3Ms === d.s3;
680
673
  return /* @__PURE__ */ l(
681
674
  "tr",
682
675
  {
683
- className: `pvx-row pvx-row--clickable ${f <= 3 ? "pvx-row--podium" : ""}`,
676
+ className: `pvx-row pvx-row--clickable ${g <= 3 ? "pvx-row--podium" : ""}`,
684
677
  onClick: () => i(p),
685
678
  children: [
686
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(xe, { rank: f, podium: !0 }) }),
687
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ e(Y, { userId: p, getUserDisplay: s }) }),
688
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: E(x.lapTimeMs) }),
689
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${v ? "pvx-td--best-sector" : ""}`, children: P(x.sector1Ms) }),
690
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${u ? "pvx-td--best-sector" : ""}`, children: P(x.sector2Ms) }),
691
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${y ? "pvx-td--best-sector" : ""}`, children: P(x.sector3Ms) }),
692
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: le(x.tyreCompound), children: x.tyreCompound || "-" }),
679
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(ve, { rank: g, podium: !0 }) }),
680
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary", children: /* @__PURE__ */ e(J, { userId: p, getUserDisplay: s }) }),
681
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: B(x.lapTimeMs) }),
682
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${f ? "pvx-td--best-sector" : ""}`, children: $(x.sector1Ms) }),
683
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${h ? "pvx-td--best-sector" : ""}`, children: $(x.sector2Ms) }),
684
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${N ? "pvx-td--best-sector" : ""}`, children: $(x.sector3Ms) }),
685
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: se(x.tyreCompound), children: x.tyreCompound || "-" }),
693
686
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-xl", children: x.startingFuelL ? `${x.startingFuelL}L` : "-" }),
694
687
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: x.lapCount || "-" }),
695
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: x.recordedAt ? F(x.recordedAt) : "-" })
688
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: x.recordedAt ? D(x.recordedAt) : "-" })
696
689
  ]
697
690
  },
698
691
  p
699
692
  );
700
693
  }) })
701
- ] }) }) : /* @__PURE__ */ e(K, { message: "No lap times for this car yet." })
694
+ ] }) }) : /* @__PURE__ */ e(I, { message: "No lap times for this car yet." })
702
695
  ] });
703
696
  }
704
- function nt({ userId: t, track: r, carId: n, game: a, gameVersion: s, showInvalid: i, getUserDisplay: c, onToggleInvalid: o, onNavigate: m }) {
705
- const { data: d, driverName: g, isLoading: N } = Ue(t, r.id, r.layout, n, { showInvalid: i, game: a, gameVersion: s }), { displayName: x, avatarUrl: h } = c(t, g), f = k(() => ve(d, !0), [d]), p = k(() => {
706
- const u = (d == null ? void 0 : d.filter((y) => y.isValid)) || [];
707
- return u.length ? Math.min(...u.map((y) => y.lapTimeMs)) : null;
708
- }, [d]), v = [
709
- { key: "tracks", label: "Tracks", onClick: () => m("tracks") },
710
- { key: "track", label: r.displayName, onClick: () => m("track") },
711
- { key: "car", label: I(n), onClick: () => m("car") },
697
+ function br({ userId: r, track: t, carId: n, game: a, gameVersion: s, showInvalid: i, getUserDisplay: o, onToggleInvalid: c, onNavigate: v }) {
698
+ const { data: d, driverName: u, isLoading: b } = Te(r, t.id, t.layout, n, { showInvalid: i, game: a, gameVersion: s }), { displayName: x, avatarUrl: m } = o(r, u), g = C(() => pe(d, !0), [d]), p = C(() => {
699
+ const h = (d == null ? void 0 : d.filter((N) => N.isValid)) || [];
700
+ return h.length ? Math.min(...h.map((N) => N.lapTimeMs)) : null;
701
+ }, [d]), f = [
702
+ { key: "tracks", label: "Tracks", onClick: () => v("tracks") },
703
+ { key: "track", label: t.displayName, onClick: () => v("track") },
704
+ { key: "car", label: R(n), onClick: () => v("car") },
712
705
  { key: "driver", label: x }
713
706
  ];
714
- return N ? /* @__PURE__ */ e(H, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
707
+ return b ? /* @__PURE__ */ e(A, {}) : /* @__PURE__ */ l("div", { className: "pvx-card", children: [
715
708
  /* @__PURE__ */ l("div", { className: "pvx-card-header pvx-card-header--split", children: [
716
709
  /* @__PURE__ */ l("div", { className: "pvx-card-header-left", children: [
717
- /* @__PURE__ */ e(ee, { segments: v }),
718
- h ? /* @__PURE__ */ e("img", { src: h, alt: "", className: "pvx-driver-avatar pvx-driver-avatar--lg" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder" })
710
+ /* @__PURE__ */ e(Y, { segments: f }),
711
+ m ? /* @__PURE__ */ e("img", { src: m, alt: "", className: "pvx-driver-avatar pvx-driver-avatar--lg" }) : /* @__PURE__ */ e("span", { className: "pvx-driver-avatar pvx-driver-avatar--lg pvx-driver-avatar--placeholder" })
719
712
  ] }),
720
713
  /* @__PURE__ */ l("label", { className: "pvx-checkbox-label", children: [
721
714
  /* @__PURE__ */ e(
@@ -723,7 +716,7 @@ function nt({ userId: t, track: r, carId: n, game: a, gameVersion: s, showInvali
723
716
  {
724
717
  type: "checkbox",
725
718
  checked: i,
726
- onChange: o,
719
+ onChange: c,
727
720
  className: "pvx-checkbox"
728
721
  }
729
722
  ),
@@ -743,164 +736,26 @@ function nt({ userId: t, track: r, carId: n, game: a, gameVersion: s, showInvali
743
736
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-lg", children: "Fuel" }),
744
737
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-xl", children: "Date" })
745
738
  ] }) }),
746
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: d.map((u, y) => {
747
- const C = u.isValid && u.lapTimeMs === p, R = f && u.isValid && u.sector1Ms === f.s1, q = f && u.isValid && u.sector2Ms === f.s2, S = f && u.isValid && u.sector3Ms === f.s3;
748
- let A = "pvx-row";
749
- return u.isValid || (A += " pvx-row--invalid"), C && (A += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: A, children: [
750
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e("span", { className: `pvx-rank ${C ? "pvx-rank--gold" : ""}`, children: y + 1 }) }),
751
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: u.lapNumber || "-" }),
752
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: E(u.lapTimeMs) }),
753
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${R ? "pvx-td--best-sector" : ""}`, children: P(u.sector1Ms) }),
754
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${q ? "pvx-td--best-sector" : ""}`, children: P(u.sector2Ms) }),
755
- /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${S ? "pvx-td--best-sector" : ""}`, children: P(u.sector3Ms) }),
756
- /* @__PURE__ */ e("td", { className: "pvx-td", title: u.isValid ? void 0 : u.invalidReason || "Invalid", children: u.isValid ? /* @__PURE__ */ e(Ze, {}) : /* @__PURE__ */ e(Xe, {}) }),
757
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: le(u.tyreCompound), children: u.tyreCompound || "-" }),
758
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: u.startingFuelL ? `${u.startingFuelL}L` : "-" }),
759
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: F(u.timestamp) })
760
- ] }, u.id);
739
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: d.map((h, N) => {
740
+ const w = h.isValid && h.lapTimeMs === p, P = g && h.isValid && h.sector1Ms === g.s1, X = g && h.isValid && h.sector2Ms === g.s2, F = g && h.isValid && h.sector3Ms === g.s3;
741
+ let _ = "pvx-row";
742
+ return h.isValid || (_ += " pvx-row--invalid"), w && (_ += " pvx-row--personal-best"), /* @__PURE__ */ l("tr", { className: _, children: [
743
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e("span", { className: `pvx-rank ${w ? "pvx-rank--gold" : ""}`, children: N + 1 }) }),
744
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-md", children: h.lapNumber || "-" }),
745
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--primary pvx-td--mono", children: B(h.lapTimeMs) }),
746
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${P ? "pvx-td--best-sector" : ""}`, children: $(h.sector1Ms) }),
747
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${X ? "pvx-td--best-sector" : ""}`, children: $(h.sector2Ms) }),
748
+ /* @__PURE__ */ e("td", { className: `pvx-td pvx-td--mono pvx-td--sector pvx-hidden-below-sm ${F ? "pvx-td--best-sector" : ""}`, children: $(h.sector3Ms) }),
749
+ /* @__PURE__ */ e("td", { className: "pvx-td", title: h.isValid ? void 0 : h.invalidReason || "Invalid", children: h.isValid ? /* @__PURE__ */ e(Be, {}) : /* @__PURE__ */ e(De, {}) }),
750
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", title: se(h.tyreCompound), children: h.tyreCompound || "-" }),
751
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-lg", children: h.startingFuelL ? `${h.startingFuelL}L` : "-" }),
752
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--muted pvx-hidden-below-xl", children: D(h.timestamp) })
753
+ ] }, h.id);
761
754
  }) })
762
- ] }) }) : /* @__PURE__ */ e(K, { message: i ? "No laps recorded for this combination." : 'No valid laps. Try enabling "Show invalid laps".' })
755
+ ] }) }) : /* @__PURE__ */ e(I, { message: i ? "No laps recorded for this combination." : 'No valid laps. Try enabling "Show invalid laps".' })
763
756
  ] });
764
757
  }
765
- function _t({ className: t, defaultGame: r = "evo", title: n = "Leaderboards" }) {
766
- const [a, s] = oe(), i = Ee(), c = Fe(), o = a.get("game") || r, m = a.get("version"), d = a.get("track"), g = a.get("car"), N = a.get("driver"), x = a.get("invalid") === "true", {
767
- data: h,
768
- isLoading: f,
769
- generatedAt: p,
770
- totalLaps: v,
771
- totalUsers: u,
772
- versions: y
773
- } = Pe({ game: o }), C = y == null ? void 0 : y[o], R = m || (C == null ? void 0 : C.default) || null, q = k(() => !h || !R ? h || [] : h.filter((b) => b.gameVersion === R), [h, R]), S = k(() => {
774
- if (!d) return null;
775
- const [b, w] = d.split("|");
776
- return { id: b, layout: w || null, displayName: V(b, w, o) };
777
- }, [d, o]), { data: A, isLoading: te } = ce(
778
- S == null ? void 0 : S.id,
779
- S == null ? void 0 : S.layout,
780
- { carId: g, game: o, gameVersion: R }
781
- );
782
- function B(b) {
783
- s(b);
784
- }
785
- function Ce(b) {
786
- B({ game: b });
787
- }
788
- function we(b) {
789
- const w = { game: o };
790
- b && b !== (C == null ? void 0 : C.default) && (w.version = b), B(w);
791
- }
792
- function ke(b, w) {
793
- const ne = { game: o, track: w ? `${b}|${w}` : b };
794
- m && (ne.version = m), B(ne);
795
- }
796
- function Te(b) {
797
- const w = { game: o, track: d };
798
- m && (w.version = m), b && (w.car = b), B(w);
799
- }
800
- function Se(b) {
801
- const w = { game: o, track: d, car: g, driver: b };
802
- m && (w.version = m), B(w);
803
- }
804
- function O(b) {
805
- const w = { game: o };
806
- m && (w.version = m), (b === "track" || b === "car") && (w.track = d), b === "car" && (w.car = g), B(w);
807
- }
808
- function Le() {
809
- const b = { game: o, track: d, car: g, driver: N };
810
- m && (b.version = m), x || (b.invalid = "true"), B(b);
811
- }
812
- const $e = () => S && g && N ? /* @__PURE__ */ e(
813
- nt,
814
- {
815
- userId: N,
816
- track: S,
817
- carId: g,
818
- game: o,
819
- gameVersion: R,
820
- showInvalid: x,
821
- getUserDisplay: i,
822
- onToggleInvalid: Le,
823
- onNavigate: O
824
- }
825
- ) : S && g ? /* @__PURE__ */ e(
826
- tt,
827
- {
828
- entries: A || [],
829
- isLoading: te,
830
- track: S,
831
- carId: g,
832
- getUserDisplay: i,
833
- onDriverSelect: Se,
834
- onNavigate: O
835
- }
836
- ) : S ? /* @__PURE__ */ e(
837
- et,
838
- {
839
- entries: A || [],
840
- isLoading: te,
841
- track: S,
842
- carMetadata: c,
843
- getUserDisplay: i,
844
- onCarSelect: Te,
845
- onNavigate: O
846
- }
847
- ) : /* @__PURE__ */ e(
848
- Ye,
849
- {
850
- tracks: q,
851
- isLoading: f,
852
- carMetadata: c,
853
- getUserDisplay: i,
854
- onTrackSelect: ke
855
- }
856
- );
857
- return /* @__PURE__ */ l("div", { className: `pvx-leaderboard-explorer ${t || ""}`, children: [
858
- /* @__PURE__ */ l("div", { className: "pvx-explorer-header", children: [
859
- /* @__PURE__ */ e("h1", { className: "pvx-explorer-title", children: n }),
860
- /* @__PURE__ */ l("div", { className: "pvx-explorer-stats", children: [
861
- v > 0 && /* @__PURE__ */ l("span", { children: [
862
- v.toLocaleString(),
863
- " laps"
864
- ] }),
865
- v > 0 && u > 0 && /* @__PURE__ */ e("span", { className: "pvx-explorer-stats-sep", children: "|" }),
866
- u > 0 && /* @__PURE__ */ l("span", { children: [
867
- u.toLocaleString(),
868
- " drivers"
869
- ] })
870
- ] })
871
- ] }),
872
- /* @__PURE__ */ l("div", { className: "pvx-explorer-controls", children: [
873
- /* @__PURE__ */ e("div", { className: "pvx-game-tabs", children: ["evo", "acc"].map((b) => /* @__PURE__ */ e(
874
- "button",
875
- {
876
- onClick: () => Ce(b),
877
- className: `pvx-game-tab ${o === b ? "pvx-game-tab--active" : ""}`,
878
- children: b === "evo" ? "AC EVO" : "ACC"
879
- },
880
- b
881
- )) }),
882
- C && /* @__PURE__ */ e(
883
- "select",
884
- {
885
- value: R || "",
886
- onChange: (b) => we(b.target.value),
887
- className: "pvx-version-select",
888
- children: C.available.slice().reverse().map((b) => /* @__PURE__ */ l("option", { value: b, children: [
889
- "v",
890
- b,
891
- b === C.default ? " (Latest)" : ""
892
- ] }, b))
893
- }
894
- )
895
- ] }),
896
- $e(),
897
- p && /* @__PURE__ */ l("p", { className: "pvx-data-timestamp", children: [
898
- "Data updated: ",
899
- new Date(p).toLocaleString()
900
- ] })
901
- ] });
902
- }
903
- const rt = {
758
+ const Ue = {
904
759
  GBR: "🇬🇧",
905
760
  DEU: "🇩🇪",
906
761
  NLD: "🇳🇱",
@@ -931,125 +786,168 @@ const rt = {
931
786
  RUS: "🇷🇺",
932
787
  TUR: "🇹🇷",
933
788
  KOR: "🇰🇷"
934
- }, at = {
789
+ }, Ie = ["🥇", "🥈", "🥉"], Ae = {
935
790
  championship: "Championship",
936
791
  series: "Series",
937
792
  event: "Event"
938
- }, re = ["PRACTICE", "QUALIFYING", "RACE"];
939
- function fe({ position: t }) {
940
- return /* @__PURE__ */ e("span", { className: t === 1 ? "pvx-rank pvx-rank--gold" : t === 2 ? "pvx-rank pvx-rank--silver" : t === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank", children: t });
941
- }
942
- function Ne({ nation: t }) {
943
- const r = t && rt[t];
944
- return r ? /* @__PURE__ */ e("span", { className: "pvx-nation-flag", title: t, children: r }) : null;
945
- }
946
- function st({ sessions: t, activeSession: r, onSelect: n }) {
947
- if (!t || t.length <= 1) return null;
948
- const a = [...t].sort(
949
- (s, i) => re.indexOf(s.type) - re.indexOf(i.type)
793
+ }, ee = ["PRACTICE", "QUALIFYING", "RACE"];
794
+ function he({ position: r }) {
795
+ return /* @__PURE__ */ e("span", { className: r === 1 ? "pvx-rank pvx-rank--gold" : r === 2 ? "pvx-rank pvx-rank--silver" : r === 3 ? "pvx-rank pvx-rank--bronze" : "pvx-rank", children: r });
796
+ }
797
+ function ue({ nation: r }) {
798
+ const t = r && Ue[r];
799
+ return t ? /* @__PURE__ */ e("span", { className: "pvx-nation-flag", title: r, children: t }) : null;
800
+ }
801
+ function Fe({ sessions: r, activeSession: t, onSelect: n }) {
802
+ if (!r || r.length <= 1) return null;
803
+ const a = [...r].sort(
804
+ (s, i) => ee.indexOf(s.type) - ee.indexOf(i.type)
950
805
  );
951
806
  return /* @__PURE__ */ e("div", { className: "pvx-session-tabs", children: a.map((s) => /* @__PURE__ */ e(
952
807
  "button",
953
808
  {
954
809
  onClick: () => n(s.type),
955
- className: `pvx-session-tab ${r === s.type ? "pvx-session-tab--active" : ""}`,
810
+ className: `pvx-session-tab ${t === s.type ? "pvx-session-tab--active" : ""}`,
956
811
  children: s.type
957
812
  },
958
813
  s.type
959
814
  )) });
960
815
  }
961
- function be({ type: t }) {
962
- return /* @__PURE__ */ e("span", { className: `pvx-comp-badge pvx-comp-badge--${t}`, children: at[t] || t });
816
+ function _e({ type: r }) {
817
+ return /* @__PURE__ */ e("span", { className: `pvx-comp-badge pvx-comp-badge--${r}`, children: Ae[r] || r });
963
818
  }
964
- function U({ children: t, variant: r = "default" }) {
965
- return /* @__PURE__ */ e("span", { className: `pvx-info-pill ${r !== "default" ? `pvx-info-pill--${r}` : ""}`, children: t });
819
+ function E({ children: r, variant: t = "default" }) {
820
+ return /* @__PURE__ */ e("span", { className: `pvx-info-pill ${t !== "default" ? `pvx-info-pill--${t}` : ""}`, children: r });
966
821
  }
967
- function ye(t) {
968
- if (!t) return "TBD";
969
- const r = new Date(t);
970
- if (isNaN(r)) return "TBD";
971
- const n = r.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short" }), a = r.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
822
+ function Ve(r) {
823
+ if (!r) return "TBD";
824
+ const t = new Date(r);
825
+ if (isNaN(t)) return "TBD";
826
+ const n = t.toLocaleDateString("en-GB", { weekday: "short", day: "numeric", month: "short" }), a = t.toLocaleTimeString("en-GB", { hour: "2-digit", minute: "2-digit" });
972
827
  return `${n} • ${a}`;
973
828
  }
974
- function it(t) {
975
- return t.reduce((r, n) => {
829
+ function Ee(r) {
830
+ return r.reduce((t, n) => {
976
831
  var a;
977
- return (a = n.splits) != null && a.length ? r ? r.map((s, i) => {
978
- const c = n.splits[i];
979
- return c && c < s ? c : s;
980
- }) : [...n.splits] : r;
832
+ return (a = n.splits) != null && a.length ? t ? t.map((s, i) => {
833
+ const o = n.splits[i];
834
+ return o && o < s ? o : s;
835
+ }) : [...n.splits] : t;
981
836
  }, null);
982
837
  }
983
- function _({ message: t = "Loading..." }) {
984
- return /* @__PURE__ */ e("div", { className: "pvx-loading", children: t });
838
+ function U({ message: r = "Loading..." }) {
839
+ return /* @__PURE__ */ e("div", { className: "pvx-loading", children: r });
985
840
  }
986
- function M({ message: t = "No data available." }) {
987
- return /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: t }) });
841
+ function M({ message: r = "No data available." }) {
842
+ return /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: r }) });
988
843
  }
989
- function ot({ competitions: t, isLoading: r, onSelect: n, className: a }) {
990
- return r ? /* @__PURE__ */ e(_, { message: "Loading competitions..." }) : t != null && t.length ? /* @__PURE__ */ e("div", { className: `pvx-comp-grid ${a || ""}`, children: t.map((s) => /* @__PURE__ */ e(lt, { comp: s, onSelect: n }, s.id)) }) : /* @__PURE__ */ e(M, { message: "No competitions available." });
844
+ function yr({ competitions: r, isLoading: t, onSelect: n, onRegister: a, className: s }) {
845
+ return t ? /* @__PURE__ */ e(U, { message: "Loading competitions..." }) : r != null && r.length ? /* @__PURE__ */ e("div", { className: `pvx-comp-grid ${s || ""}`, children: r.map((i) => /* @__PURE__ */ e(qe, { comp: i, onSelect: n, onRegister: a || n }, i.id)) }) : /* @__PURE__ */ e(M, { message: "No competitions available." });
991
846
  }
992
- function lt({ comp: t, onSelect: r }) {
993
- var f, p, v;
994
- const { cdnUrl: n } = T(), a = t.posterCdnPath ? `${n}/${t.posterCdnPath}` : null, s = t.registration, i = (s == null ? void 0 : s.currentCount) || 0, c = s == null ? void 0 : s.maxParticipants, o = c && i >= c, m = (s == null ? void 0 : s.deadline) && new Date(s.deadline) < /* @__PURE__ */ new Date(), d = (s == null ? void 0 : s.isOpen) && !m && !o, g = /* @__PURE__ */ new Date(), N = (f = t.rounds) == null ? void 0 : f.find((u) => u.startTime && new Date(u.startTime) >= g), x = ((p = t.rounds) == null ? void 0 : p.length) || 0, h = ((v = t.rounds) == null ? void 0 : v.filter((u) => u.isFinalized).length) || 0;
847
+ function qe({ comp: r, onSelect: t, onRegister: n }) {
848
+ var p, f, h;
849
+ const { cdnUrl: a } = y(), s = r.posterCdnPath ? `${a}/${r.posterCdnPath}` : null, i = r.registration, o = (i == null ? void 0 : i.currentCount) || 0, c = i == null ? void 0 : i.maxParticipants, v = c && o >= c, d = (i == null ? void 0 : i.deadline) && new Date(i.deadline) < /* @__PURE__ */ new Date(), u = (i == null ? void 0 : i.isOpen) && !d && !v, b = /* @__PURE__ */ new Date(), x = (p = r.rounds) == null ? void 0 : p.find((N) => N.startTime && new Date(N.startTime) >= b), m = ((f = r.rounds) == null ? void 0 : f.length) || 0, g = ((h = r.rounds) == null ? void 0 : h.filter((N) => N.isFinalized).length) || 0;
995
850
  return /* @__PURE__ */ l(
996
851
  "div",
997
852
  {
998
853
  className: "pvx-comp-card",
999
- onClick: () => r(t.id),
854
+ onClick: () => t(r.id),
1000
855
  role: "button",
1001
856
  tabIndex: 0,
1002
- onKeyDown: (u) => {
1003
- (u.key === "Enter" || u.key === " ") && (u.preventDefault(), r(t.id));
857
+ onKeyDown: (N) => {
858
+ (N.key === "Enter" || N.key === " ") && (N.preventDefault(), t(r.id));
1004
859
  },
1005
860
  children: [
1006
- /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster", children: a ? /* @__PURE__ */ e("img", { src: a, alt: t.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ e(ct, {}) }) }),
861
+ /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster", children: s ? /* @__PURE__ */ e("img", { src: s, alt: r.name, className: "pvx-comp-card-poster-img" }) : /* @__PURE__ */ e("div", { className: "pvx-comp-card-poster-placeholder", children: /* @__PURE__ */ e(Ke, {}) }) }),
1007
862
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-body", children: [
1008
- /* @__PURE__ */ e("h3", { className: "pvx-comp-card-title", children: t.name }),
1009
- t.description && /* @__PURE__ */ e("p", { className: "pvx-comp-card-desc", children: t.description }),
863
+ /* @__PURE__ */ e("h3", { className: "pvx-comp-card-title", children: r.name }),
864
+ r.description && /* @__PURE__ */ e("p", { className: "pvx-comp-card-desc", children: r.description }),
1010
865
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-pills", children: [
1011
- /* @__PURE__ */ e(be, { type: t.type }),
1012
- t.game && /* @__PURE__ */ e(U, { children: t.game.toUpperCase() }),
1013
- t.formatDescription && t.formatDescription.split(", ").map((u, y) => /* @__PURE__ */ e(U, { variant: "format", children: u }, y))
866
+ /* @__PURE__ */ e(_e, { type: r.type }),
867
+ r.game && /* @__PURE__ */ e(E, { children: r.game.toUpperCase() }),
868
+ r.formatDescription && r.formatDescription.split(", ").map((N, w) => /* @__PURE__ */ e(E, { variant: "format", children: N }, w))
1014
869
  ] }),
1015
- t.carsDescription && /* @__PURE__ */ e("div", { className: "pvx-comp-card-pills", children: t.carsDescription.split(", ").map((u, y) => /* @__PURE__ */ e(U, { children: u }, y)) }),
870
+ r.carsDescription && /* @__PURE__ */ e("div", { className: "pvx-comp-card-pills", children: r.carsDescription.split(", ").map((N, w) => /* @__PURE__ */ e(E, { children: N }, w)) }),
1016
871
  /* @__PURE__ */ l("div", { className: "pvx-comp-card-schedule", children: [
1017
- N ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
872
+ x ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1018
873
  /* @__PURE__ */ e("span", { className: "pvx-comp-card-schedule-label", children: "Next:" }),
1019
874
  " ",
1020
875
  "R",
1021
- N.roundNumber,
876
+ x.roundNumber,
1022
877
  " ",
1023
- N.track || "TBD",
878
+ x.track || "TBD",
1024
879
  " — ",
1025
- ye(N.startTime)
1026
- ] }) : x > 0 ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
1027
- h,
880
+ Ve(x.startTime)
881
+ ] }) : m > 0 ? /* @__PURE__ */ l("span", { className: "pvx-comp-card-schedule-next", children: [
882
+ g,
1028
883
  "/",
1029
- x,
884
+ m,
1030
885
  " rounds completed"
1031
886
  ] }) : null,
1032
- x > 0 && /* @__PURE__ */ l("span", { className: "pvx-comp-card-round-count", children: [
1033
- x,
887
+ m > 0 && /* @__PURE__ */ l("span", { className: "pvx-comp-card-round-count", children: [
888
+ m,
1034
889
  " round",
1035
- x !== 1 ? "s" : ""
890
+ m !== 1 ? "s" : ""
1036
891
  ] })
1037
892
  ] }),
1038
- s && /* @__PURE__ */ l("div", { className: "pvx-comp-card-reg", children: [
1039
- /* @__PURE__ */ e("span", { className: `pvx-comp-reg-badge ${d ? "pvx-comp-reg-badge--open" : o ? "pvx-comp-reg-badge--full" : "pvx-comp-reg-badge--closed"}`, children: d ? "Registration Open" : o ? "Full" : "Registration Closed" }),
1040
- /* @__PURE__ */ l("span", { className: "pvx-comp-reg-count", children: [
1041
- i,
1042
- "/",
1043
- c || "∞",
1044
- " drivers"
1045
- ] })
1046
- ] })
893
+ i && /* @__PURE__ */ e(
894
+ je,
895
+ {
896
+ competitionId: r.id,
897
+ regOpen: u,
898
+ isFull: v,
899
+ deadlinePassed: d,
900
+ regCount: o,
901
+ regMax: c,
902
+ onRegister: n
903
+ }
904
+ )
1047
905
  ] })
1048
906
  ]
1049
907
  }
1050
908
  );
1051
909
  }
1052
- function ct() {
910
+ function je({ competitionId: r, regOpen: t, isFull: n, deadlinePassed: a, regCount: s, regMax: i, onRegister: o }) {
911
+ const { isPowerMode: c } = G(), v = z(r), { data: d } = W(r), u = (d == null ? void 0 : d.isRegistered) || !1, b = i ? s / i * 100 : 0, x = b >= 100 ? "full" : b >= 75 ? "warning" : "ok";
912
+ return /* @__PURE__ */ l("div", { className: "pvx-comp-card-reg", children: [
913
+ /* @__PURE__ */ e("div", { className: "pvx-comp-card-reg-info", children: /* @__PURE__ */ l("span", { className: `pvx-reg-capacity pvx-reg-capacity--${x}`, children: [
914
+ s,
915
+ "/",
916
+ i || "∞",
917
+ " drivers"
918
+ ] }) }),
919
+ /* @__PURE__ */ e("div", { className: "pvx-comp-card-reg-action", children: u ? /* @__PURE__ */ e(
920
+ "button",
921
+ {
922
+ className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--registered",
923
+ onClick: (m) => {
924
+ m.stopPropagation(), o(r);
925
+ },
926
+ children: "✓ Registered"
927
+ }
928
+ ) : t ? c ? /* @__PURE__ */ e(
929
+ "button",
930
+ {
931
+ className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",
932
+ onClick: (m) => {
933
+ m.stopPropagation(), o(r);
934
+ },
935
+ children: "Register"
936
+ }
937
+ ) : /* @__PURE__ */ e(
938
+ "a",
939
+ {
940
+ href: v,
941
+ target: "_blank",
942
+ rel: "noopener noreferrer",
943
+ className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--open",
944
+ onClick: (m) => m.stopPropagation(),
945
+ children: "Register"
946
+ }
947
+ ) : /* @__PURE__ */ e("span", { className: "pvx-comp-card-reg-btn pvx-comp-card-reg-btn--closed", children: n ? "Full" : "Closed" }) })
948
+ ] });
949
+ }
950
+ function Ke() {
1053
951
  return /* @__PURE__ */ l("svg", { className: "pvx-comp-trophy-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
1054
952
  /* @__PURE__ */ e("path", { d: "M6 9H4.5a2.5 2.5 0 0 1 0-5H6" }),
1055
953
  /* @__PURE__ */ e("path", { d: "M18 9h1.5a2.5 2.5 0 0 0 0-5H18" }),
@@ -1059,15 +957,15 @@ function ct() {
1059
957
  /* @__PURE__ */ e("path", { d: "M18 2H6v7a6 6 0 0 0 12 0V2Z" })
1060
958
  ] });
1061
959
  }
1062
- function dt({ competitionId: t, className: r }) {
1063
- var o, m;
1064
- const { data: n, isLoading: a } = qe(t), { data: s, isLoading: i } = de(t);
960
+ function Cr({ competitionId: r, className: t }) {
961
+ var c, v;
962
+ const { data: n, isLoading: a } = Re(r), { data: s, isLoading: i } = Se(r);
1065
963
  if (a || i)
1066
- return /* @__PURE__ */ e(_, { message: "Loading standings..." });
1067
- if (!((o = n == null ? void 0 : n.standings) != null && o.length))
964
+ return /* @__PURE__ */ e(U, { message: "Loading standings..." });
965
+ if (!((c = n == null ? void 0 : n.standings) != null && c.length))
1068
966
  return /* @__PURE__ */ e(M, { message: "No standings data yet. Results will appear once rounds are finalised." });
1069
- const c = ((m = s == null ? void 0 : s.rounds) == null ? void 0 : m.filter((d) => d.isFinalized)) || [];
1070
- return /* @__PURE__ */ l("div", { className: `pvx-card ${r || ""}`, children: [
967
+ const o = ((v = s == null ? void 0 : s.rounds) == null ? void 0 : v.filter((d) => d.isFinalized)) || [];
968
+ return /* @__PURE__ */ l("div", { className: `pvx-card ${t || ""}`, children: [
1071
969
  /* @__PURE__ */ e("div", { className: "pvx-card-header--split", children: /* @__PURE__ */ l("div", { className: "pvx-card-header-left", children: [
1072
970
  /* @__PURE__ */ e("h3", { className: "pvx-card-title", children: "Championship Standings" }),
1073
971
  /* @__PURE__ */ l("span", { className: "pvx-standings-subtitle", children: [
@@ -1085,7 +983,7 @@ function dt({ competitionId: t, className: r }) {
1085
983
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center pvx-hidden-below-sm", children: "W" }),
1086
984
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center pvx-hidden-below-sm", children: "Pod" }),
1087
985
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center", children: "Points" }),
1088
- c.map((d) => /* @__PURE__ */ l(
986
+ o.map((d) => /* @__PURE__ */ l(
1089
987
  "th",
1090
988
  {
1091
989
  className: "pvx-th pvx-th--center pvx-hidden-below-md",
@@ -1099,42 +997,42 @@ function dt({ competitionId: t, className: r }) {
1099
997
  ))
1100
998
  ] }) }),
1101
999
  /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: n.standings.map((d) => /* @__PURE__ */ e(
1102
- pt,
1000
+ He,
1103
1001
  {
1104
1002
  driver: d,
1105
- finalizedRounds: c
1003
+ finalizedRounds: o
1106
1004
  },
1107
1005
  d.driverId || d.driverName
1108
1006
  )) })
1109
1007
  ] }) })
1110
1008
  ] });
1111
1009
  }
1112
- function pt({ driver: t, finalizedRounds: r }) {
1113
- var c, o, m;
1114
- const n = t.position <= 3, a = new Map(
1115
- ((c = t.roundResults) == null ? void 0 : c.map((d) => [d.roundNumber, d])) || []
1116
- ), s = ((o = t.roundResults) == null ? void 0 : o.filter((d) => d.position === 1).length) || 0, i = ((m = t.roundResults) == null ? void 0 : m.filter((d) => d.position <= 3).length) || 0;
1010
+ function He({ driver: r, finalizedRounds: t }) {
1011
+ var o, c, v;
1012
+ const n = r.position <= 3, a = new Map(
1013
+ ((o = r.roundResults) == null ? void 0 : o.map((d) => [d.roundNumber, d])) || []
1014
+ ), s = ((c = r.roundResults) == null ? void 0 : c.filter((d) => d.position === 1).length) || 0, i = ((v = r.roundResults) == null ? void 0 : v.filter((d) => d.position <= 3).length) || 0;
1117
1015
  return /* @__PURE__ */ l("tr", { className: `pvx-row ${n ? "pvx-row--podium" : ""}`, children: [
1118
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(fe, { position: t.position }) }),
1016
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(he, { position: r.position }) }),
1119
1017
  /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--primary", children: [
1120
- /* @__PURE__ */ e(Ne, { nation: t.nation }),
1121
- t.driverName
1018
+ /* @__PURE__ */ e(ue, { nation: r.nation }),
1019
+ r.driverName
1122
1020
  ] }),
1123
1021
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: s || "-" }),
1124
1022
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-hidden-below-sm", children: i || "-" }),
1125
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-standings-total", children: t.totalPoints }),
1126
- r.map((d) => {
1127
- const g = a.get(d.roundNumber), N = g == null ? void 0 : g.dropped;
1023
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--center pvx-standings-total", children: r.totalPoints }),
1024
+ t.map((d) => {
1025
+ const u = a.get(d.roundNumber), b = u == null ? void 0 : u.dropped;
1128
1026
  return /* @__PURE__ */ e(
1129
1027
  "td",
1130
1028
  {
1131
- className: `pvx-td pvx-td--center pvx-hidden-below-md ${!N && (g == null ? void 0 : g.position) <= 3 ? "pvx-standings-cell--podium" : ""}`,
1132
- children: g ? /* @__PURE__ */ l("div", { className: `pvx-standings-round-cell ${N ? "pvx-standings-round-cell--dropped" : ""}`, children: [
1029
+ className: `pvx-td pvx-td--center pvx-hidden-below-md ${!b && (u == null ? void 0 : u.position) <= 3 ? "pvx-standings-cell--podium" : ""}`,
1030
+ children: u ? /* @__PURE__ */ l("div", { className: `pvx-standings-round-cell ${b ? "pvx-standings-round-cell--dropped" : ""}`, children: [
1133
1031
  /* @__PURE__ */ l("span", { className: "pvx-standings-round-pos", children: [
1134
1032
  "P",
1135
- g.position
1033
+ u.position
1136
1034
  ] }),
1137
- /* @__PURE__ */ e("span", { className: "pvx-standings-round-pts", children: g.points })
1035
+ /* @__PURE__ */ e("span", { className: "pvx-standings-round-pts", children: u.points })
1138
1036
  ] }) : /* @__PURE__ */ e("span", { className: "pvx-td--muted", children: "-" })
1139
1037
  },
1140
1038
  d.roundNumber
@@ -1142,17 +1040,14 @@ function pt({ driver: t, finalizedRounds: r }) {
1142
1040
  })
1143
1041
  ] });
1144
1042
  }
1145
- function ut({ competitionId: t, roundNumber: r, className: n }) {
1146
- var g, N;
1147
- const { data: a, isLoading: s } = je(t, r), [i, c] = j(null);
1043
+ function wr({ competitionId: r, roundNumber: t, className: n }) {
1044
+ var v;
1045
+ const { data: a, isLoading: s } = Le(r, t);
1148
1046
  if (s)
1149
- return /* @__PURE__ */ e(_, { message: "Loading results..." });
1047
+ return /* @__PURE__ */ e(U, { message: "Loading results..." });
1150
1048
  if (!a)
1151
1049
  return /* @__PURE__ */ e(M, { message: "No results for this round." });
1152
- const o = a.sessions || [];
1153
- if (!o.length)
1154
- return /* @__PURE__ */ e(M, { message: "No session data for this round." });
1155
- const m = i || ((g = o.find((x) => x.type === "RACE")) == null ? void 0 : g.type) || ((N = o[0]) == null ? void 0 : N.type), d = o.find((x) => x.type === m) || o[0];
1050
+ const o = (a.sessions || []).find((d) => d.type === "RACE"), c = (v = o == null ? void 0 : o.results) == null ? void 0 : v.filter((d) => d.position <= 3).sort((d, u) => d.position - u.position);
1156
1051
  return /* @__PURE__ */ l("div", { className: `pvx-round-results ${n || ""}`, children: [
1157
1052
  /* @__PURE__ */ l("div", { className: "pvx-round-results-header", children: [
1158
1053
  /* @__PURE__ */ l("div", { children: [
@@ -1167,52 +1062,55 @@ function ut({ competitionId: t, roundNumber: r, className: n }) {
1167
1062
  year: "numeric"
1168
1063
  }) })
1169
1064
  ] }),
1170
- /* @__PURE__ */ e(mt, { sessions: o })
1065
+ (c == null ? void 0 : c.length) > 0 && /* @__PURE__ */ e("div", { className: "pvx-round-podium-summary", children: c.map((d) => /* @__PURE__ */ l("span", { className: "pvx-round-podium-item", children: [
1066
+ /* @__PURE__ */ e("span", { children: Ie[d.position - 1] }),
1067
+ /* @__PURE__ */ e("span", { children: d.driverName })
1068
+ ] }, d.driverId)) })
1171
1069
  ] }),
1070
+ /* @__PURE__ */ e(Oe, { round: a })
1071
+ ] });
1072
+ }
1073
+ function Oe({ round: r, className: t }) {
1074
+ var c, v;
1075
+ const [n, a] = L(null), s = (r == null ? void 0 : r.sessions) || [];
1076
+ if (!s.length)
1077
+ return /* @__PURE__ */ e(M, { message: "No session data for this round." });
1078
+ const i = n || ((c = s.find((d) => d.type === "RACE")) == null ? void 0 : c.type) || ((v = s[0]) == null ? void 0 : v.type), o = s.find((d) => d.type === i) || s[0];
1079
+ return /* @__PURE__ */ l("div", { className: t || "", children: [
1172
1080
  /* @__PURE__ */ e(
1173
- st,
1081
+ Fe,
1174
1082
  {
1175
- sessions: o,
1176
- activeSession: m,
1177
- onSelect: c
1083
+ sessions: s,
1084
+ activeSession: i,
1085
+ onSelect: a
1178
1086
  }
1179
1087
  ),
1180
- /* @__PURE__ */ e(ht, { session: d })
1088
+ /* @__PURE__ */ e(We, { session: o })
1181
1089
  ] });
1182
1090
  }
1183
- function mt({ sessions: t }) {
1184
- var s;
1185
- const r = t.find((i) => i.type === "RACE"), n = (s = r == null ? void 0 : r.results) == null ? void 0 : s.filter((i) => i.position <= 3).sort((i, c) => i.position - c.position);
1186
- if (!(n != null && n.length)) return null;
1187
- const a = ["🥇", "🥈", "🥉"];
1188
- return /* @__PURE__ */ e("div", { className: "pvx-round-podium-summary", children: n.map((i) => /* @__PURE__ */ l("span", { className: "pvx-round-podium-item", children: [
1189
- /* @__PURE__ */ e("span", { children: a[i.position - 1] }),
1190
- /* @__PURE__ */ e("span", { children: i.driverName })
1191
- ] }, i.driverId)) });
1192
- }
1193
- function ht({ session: t }) {
1091
+ function We({ session: r }) {
1194
1092
  var a;
1195
- const r = t.type === "RACE";
1196
- if (!((a = t.results) != null && a.length))
1197
- return /* @__PURE__ */ e(M, { message: `No results for ${t.type}.` });
1198
- const n = it(t.results);
1093
+ const t = r.type === "RACE";
1094
+ if (!((a = r.results) != null && a.length))
1095
+ return /* @__PURE__ */ e(M, { message: `No results for ${r.type}.` });
1096
+ const n = Ee(r.results);
1199
1097
  return /* @__PURE__ */ e("div", { className: "pvx-table-scroll", children: /* @__PURE__ */ l("table", { className: "pvx-table", children: [
1200
1098
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ l("tr", { className: "pvx-thead-row", children: [
1201
1099
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--narrow", children: "Pos" }),
1202
1100
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Driver" }),
1203
1101
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Car" }),
1204
1102
  /* @__PURE__ */ e("th", { className: "pvx-th", children: "Best Lap" }),
1205
- r && /* @__PURE__ */ l(Q, { children: [
1103
+ t && /* @__PURE__ */ l(K, { children: [
1206
1104
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Laps" }),
1207
1105
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-hidden-below-sm", children: "Time / Gap" }),
1208
1106
  /* @__PURE__ */ e("th", { className: "pvx-th pvx-th--center", children: "Points" })
1209
1107
  ] })
1210
1108
  ] }) }),
1211
- /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: t.results.map((s, i) => /* @__PURE__ */ e(
1212
- vt,
1109
+ /* @__PURE__ */ e("tbody", { className: "pvx-tbody", children: r.results.map((s, i) => /* @__PURE__ */ e(
1110
+ Ge,
1213
1111
  {
1214
1112
  result: s,
1215
- isRace: r,
1113
+ isRace: t,
1216
1114
  fastestSplits: n,
1217
1115
  rowIndex: i
1218
1116
  },
@@ -1220,265 +1118,296 @@ function ht({ session: t }) {
1220
1118
  )) })
1221
1119
  ] }) });
1222
1120
  }
1223
- function vt({ result: t, isRace: r, fastestSplits: n, rowIndex: a }) {
1224
- const s = t.position <= 3;
1121
+ function Ge({ result: r, isRace: t, fastestSplits: n, rowIndex: a }) {
1122
+ const s = r.position <= 3;
1225
1123
  return /* @__PURE__ */ l("tr", { className: `pvx-row ${s ? "pvx-row--podium" : ""}`, children: [
1226
- /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(fe, { position: t.position }) }),
1124
+ /* @__PURE__ */ e("td", { className: "pvx-td", children: /* @__PURE__ */ e(he, { position: r.position }) }),
1227
1125
  /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--primary", children: [
1228
- /* @__PURE__ */ e(Ne, { nation: t.nation }),
1229
- t.driverName,
1230
- t.carNumber != null && /* @__PURE__ */ l("span", { className: "pvx-car-number", children: [
1126
+ /* @__PURE__ */ e(ue, { nation: r.nation }),
1127
+ r.driverName,
1128
+ r.carNumber != null && /* @__PURE__ */ l("span", { className: "pvx-car-number", children: [
1231
1129
  "#",
1232
- t.carNumber
1130
+ r.carNumber
1233
1131
  ] }),
1234
- t.penalty && /* @__PURE__ */ e("span", { className: "pvx-penalty", children: t.penalty })
1132
+ r.penalty && /* @__PURE__ */ e("span", { className: "pvx-penalty", children: r.penalty })
1235
1133
  ] }),
1236
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: I(t.carId) }),
1134
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: R(r.carId) }),
1237
1135
  /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono", children: /* @__PURE__ */ e(
1238
- xt,
1136
+ ze,
1239
1137
  {
1240
- bestLap: t.bestLapFormatted,
1241
- hasBestLap: t.hasBestLap,
1242
- splits: t.splits,
1138
+ bestLap: r.bestLapFormatted,
1139
+ hasBestLap: r.hasBestLap,
1140
+ splits: r.splits,
1243
1141
  fastestSplits: n,
1244
1142
  showAbove: a <= 1
1245
1143
  }
1246
1144
  ) }),
1247
- r && /* @__PURE__ */ l(Q, { children: [
1248
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: t.lapsCompleted }),
1249
- /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm", children: t.position === 1 ? t.totalTime || "-" : t.gap || "-" }),
1145
+ t && /* @__PURE__ */ l(K, { children: [
1146
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-hidden-below-sm", children: r.lapsCompleted }),
1147
+ /* @__PURE__ */ e("td", { className: "pvx-td pvx-td--mono pvx-td--muted pvx-hidden-below-sm", children: r.position === 1 ? r.totalTime || "-" : r.gap || "-" }),
1250
1148
  /* @__PURE__ */ l("td", { className: "pvx-td pvx-td--center", children: [
1251
- /* @__PURE__ */ e("span", { className: "pvx-session-points", children: t.points }),
1252
- t.pointsOverride !== 0 && t.pointsOverride && /* @__PURE__ */ l("span", { className: "pvx-points-override", children: [
1149
+ /* @__PURE__ */ e("span", { className: "pvx-session-points", children: r.points }),
1150
+ r.pointsOverride !== 0 && r.pointsOverride && /* @__PURE__ */ l("span", { className: "pvx-points-override", children: [
1253
1151
  "(",
1254
- t.pointsOverride > 0 ? "+" : "",
1255
- t.pointsOverride,
1152
+ r.pointsOverride > 0 ? "+" : "",
1153
+ r.pointsOverride,
1256
1154
  ")"
1257
1155
  ] })
1258
1156
  ] })
1259
1157
  ] })
1260
1158
  ] });
1261
1159
  }
1262
- function xt({ bestLap: t, hasBestLap: r, splits: n, fastestSplits: a, showAbove: s }) {
1263
- return t ? /* @__PURE__ */ l("span", { className: `pvx-best-lap-cell ${r ? "pvx-best-lap-cell--fastest" : ""}`, children: [
1264
- /* @__PURE__ */ e("span", { className: "pvx-best-lap-time", children: t }),
1265
- (n == null ? void 0 : n.length) > 0 && /* @__PURE__ */ e("span", { className: "pvx-splits-tooltip-anchor", children: /* @__PURE__ */ e("span", { className: `pvx-splits-tooltip ${s ? "" : "pvx-splits-tooltip--above"}`, children: n.map((i, c) => {
1266
- const o = a && i === a[c];
1160
+ function ze({ bestLap: r, hasBestLap: t, splits: n, fastestSplits: a, showAbove: s }) {
1161
+ return r ? /* @__PURE__ */ l("span", { className: `pvx-best-lap-cell ${t ? "pvx-best-lap-cell--fastest" : ""}`, children: [
1162
+ /* @__PURE__ */ e("span", { className: "pvx-best-lap-time", children: r }),
1163
+ (n == null ? void 0 : n.length) > 0 && /* @__PURE__ */ e("span", { className: "pvx-splits-tooltip-anchor", children: /* @__PURE__ */ e("span", { className: `pvx-splits-tooltip ${s ? "" : "pvx-splits-tooltip--above"}`, children: n.map((i, o) => {
1164
+ const c = a && i === a[o];
1267
1165
  return /* @__PURE__ */ l("span", { className: "pvx-splits-tooltip-row", children: [
1268
1166
  /* @__PURE__ */ l("span", { className: "pvx-splits-tooltip-label", children: [
1269
1167
  "S",
1270
- c + 1
1168
+ o + 1
1271
1169
  ] }),
1272
- /* @__PURE__ */ e("span", { className: o ? "pvx-splits-tooltip-best" : "", children: i })
1273
- ] }, c);
1170
+ /* @__PURE__ */ e("span", { className: c ? "pvx-splits-tooltip-best" : "", children: i })
1171
+ ] }, o);
1274
1172
  }) }) })
1275
1173
  ] }) : /* @__PURE__ */ e("span", { className: "pvx-td--muted", children: "-" });
1276
1174
  }
1277
- function gt({ competitionId: t, className: r }) {
1278
- const { data: n, isLoading: a } = Ve(t);
1279
- if (a)
1280
- return /* @__PURE__ */ e(_, { message: "Loading drivers..." });
1281
- const s = (n == null ? void 0 : n.drivers) || (n == null ? void 0 : n.entries) || [];
1282
- return s.length ? /* @__PURE__ */ e("div", { className: `pvx-entry-grid ${r || ""}`, children: s.map((i) => {
1283
- var c, o;
1284
- return /* @__PURE__ */ l("div", { className: "pvx-entry-card", children: [
1285
- i.avatarUrl ? /* @__PURE__ */ e(
1175
+ function kr({ competitionId: r, className: t }) {
1176
+ const { getSteamId: n } = y(), { data: a, isLoading: s } = ae(r), i = n();
1177
+ if (s)
1178
+ return /* @__PURE__ */ e(U, { message: "Loading drivers..." });
1179
+ const o = (a == null ? void 0 : a.drivers) || (a == null ? void 0 : a.entries) || [];
1180
+ return o.length ? /* @__PURE__ */ e("div", { className: `pvx-entry-grid ${t || ""}`, children: o.map((c) => {
1181
+ var d, u;
1182
+ const v = i && c.steamId === i;
1183
+ return /* @__PURE__ */ l("div", { className: `pvx-entry-card ${v ? "pvx-entry-card--you" : ""}`, children: [
1184
+ c.avatarUrl ? /* @__PURE__ */ e(
1286
1185
  "img",
1287
1186
  {
1288
- src: i.avatarUrl,
1187
+ src: c.avatarUrl,
1289
1188
  alt: "",
1290
1189
  className: "pvx-entry-avatar"
1291
1190
  }
1292
- ) : /* @__PURE__ */ e("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((o = (c = i.displayName) == null ? void 0 : c.charAt(0)) == null ? void 0 : o.toUpperCase()) || "?" }),
1293
- /* @__PURE__ */ e("span", { className: "pvx-entry-name", children: i.displayName })
1294
- ] }, i.steamId || i.driverId);
1191
+ ) : /* @__PURE__ */ e("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((u = (d = c.displayName) == null ? void 0 : d.charAt(0)) == null ? void 0 : u.toUpperCase()) || "?" }),
1192
+ /* @__PURE__ */ l("span", { className: "pvx-entry-name", children: [
1193
+ c.displayName,
1194
+ v && /* @__PURE__ */ e("span", { className: "pvx-entry-you", children: " (you)" })
1195
+ ] })
1196
+ ] }, c.steamId || c.driverId);
1295
1197
  }) }) : /* @__PURE__ */ e(M, { message: "No drivers registered yet." });
1296
1198
  }
1297
- const ft = [
1298
- { id: "standings", label: "Standings" },
1299
- { id: "rounds", label: "Rounds" },
1300
- { id: "drivers", label: "Drivers" }
1301
- ];
1302
- function qt({ className: t, title: r = "Competitions" }) {
1303
- const [n, a] = oe(), s = n.get("competition"), i = n.get("tab") || "standings", c = n.get("round") ? Number(n.get("round")) : null, { data: o, isLoading: m } = _e();
1304
- function d(f) {
1305
- a({ competition: f });
1306
- }
1307
- function g() {
1308
- a({});
1309
- }
1310
- function N(f) {
1311
- a({ competition: s, tab: f });
1312
- }
1313
- function x(f) {
1314
- a({ competition: s, tab: "rounds", round: String(f) });
1315
- }
1316
- function h() {
1317
- a({ competition: s, tab: "rounds" });
1318
- }
1319
- return s ? /* @__PURE__ */ e("div", { className: `pvx-comp-explorer ${t || ""}`, children: /* @__PURE__ */ e(
1320
- Nt,
1199
+ function Tr({
1200
+ competitionId: r,
1201
+ driverData: t,
1202
+ className: n,
1203
+ children: a
1204
+ }) {
1205
+ const { data: s, isLoading: i } = W(r), { isPowerMode: o } = G(), c = z(r), v = ie(r), d = le(r), u = (s == null ? void 0 : s.isRegistered) || !1, b = i || v.isPending || d.isPending, x = v.error || d.error || null, m = () => {
1206
+ o && v.mutate(t || {});
1207
+ }, g = () => {
1208
+ o && d.mutate();
1209
+ };
1210
+ return typeof a == "function" ? a({ isRegistered: u, isLoading: b, register: m, withdraw: g, error: x, isPowerMode: o, registrationUrl: c }) : o ? /* @__PURE__ */ e(
1211
+ "button",
1212
+ {
1213
+ className: `pvx-comp-register-btn ${n || ""}`,
1214
+ onClick: u ? g : m,
1215
+ disabled: b,
1216
+ children: b ? "Loading..." : u ? "Withdraw" : "Register"
1217
+ }
1218
+ ) : /* @__PURE__ */ e(
1219
+ "a",
1220
+ {
1221
+ href: c,
1222
+ target: "_blank",
1223
+ rel: "noopener noreferrer",
1224
+ className: `pvx-comp-register-link ${n || ""}`,
1225
+ children: u ? "View Registration" : "Register on PitVox"
1226
+ }
1227
+ );
1228
+ }
1229
+ function Sr({ competitionId: r, registration: t, className: n }) {
1230
+ const { getSteamId: a } = y(), { isPowerMode: s } = G(), i = z(r), { data: o, isLoading: c } = W(r), { data: v, isLoading: d } = ae(r), u = ie(r), b = le(r), x = a(), m = (o == null ? void 0 : o.isRegistered) || !1, g = (v == null ? void 0 : v.drivers) || (v == null ? void 0 : v.entries) || [], p = t || {}, f = p.maxParticipants && (p.currentCount || 0) >= p.maxParticipants, h = p.deadline && new Date(p.deadline) < /* @__PURE__ */ new Date(), N = p.isOpen && !h && !f;
1231
+ return c || d ? /* @__PURE__ */ e(U, { message: "Loading registration..." }) : m ? /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: /* @__PURE__ */ e(
1232
+ Ze,
1233
+ {
1234
+ competitionId: r,
1235
+ drivers: g,
1236
+ steamId: x,
1237
+ isPowerMode: s,
1238
+ registrationUrl: i,
1239
+ withdrawMutation: b,
1240
+ registration: p
1241
+ }
1242
+ ) }) : N ? x ? s ? /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: /* @__PURE__ */ e(
1243
+ Qe,
1321
1244
  {
1322
- competitionId: s,
1323
- activeTab: i,
1324
- selectedRound: c,
1325
- onBack: g,
1326
- onTabChange: N,
1327
- onSelectRound: x,
1328
- onDeselectRound: h
1245
+ competitionId: r,
1246
+ registerMutation: u,
1247
+ registration: p
1329
1248
  }
1330
- ) }) : /* @__PURE__ */ l("div", { className: `pvx-comp-explorer ${t || ""}`, children: [
1331
- /* @__PURE__ */ l("div", { className: "pvx-explorer-header", children: [
1332
- /* @__PURE__ */ e("h2", { className: "pvx-explorer-title", children: r }),
1333
- !m && (o == null ? void 0 : o.length) > 0 && /* @__PURE__ */ e("div", { className: "pvx-explorer-stats", children: /* @__PURE__ */ l("span", { children: [
1334
- o.length,
1335
- " competition",
1336
- o.length !== 1 ? "s" : ""
1337
- ] }) })
1249
+ ) }) : /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: /* @__PURE__ */ e("a", { href: i, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) : /* @__PURE__ */ e("div", { className: `pvx-reg-panel ${n || ""}`, children: s ? /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: "Sign in to register for this competition." }) : /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: /* @__PURE__ */ e("a", { href: i, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Register on PitVox" }) }) }) : /* @__PURE__ */ l("div", { className: `pvx-reg-panel ${n || ""}`, children: [
1250
+ /* @__PURE__ */ e("div", { className: "pvx-reg-status-msg", children: f ? "Registration is full." : h ? "Registration deadline has passed." : "Registration is closed." }),
1251
+ g.length > 0 && /* @__PURE__ */ e(xe, { drivers: g, steamId: x })
1252
+ ] });
1253
+ }
1254
+ function Qe({ competitionId: r, registerMutation: t, registration: n }) {
1255
+ const [a, s] = L(""), [i, o] = L("intermediate"), [c, v] = L(""), d = (m) => {
1256
+ m.preventDefault(), t.mutate({
1257
+ discordUsername: a || void 0,
1258
+ experience: i,
1259
+ comments: c || void 0
1260
+ });
1261
+ }, u = n || {}, b = u.currentCount || 0, x = u.maxParticipants;
1262
+ return /* @__PURE__ */ l("form", { className: "pvx-reg-form", onSubmit: d, children: [
1263
+ /* @__PURE__ */ l("div", { className: "pvx-reg-form-header", children: [
1264
+ /* @__PURE__ */ e("h3", { className: "pvx-reg-form-title", children: "Register" }),
1265
+ x && /* @__PURE__ */ e(ge, { count: b, max: x })
1338
1266
  ] }),
1339
- /* @__PURE__ */ e(
1340
- ot,
1267
+ t.error && /* @__PURE__ */ e("div", { className: "pvx-reg-error", children: t.error.message || "Registration failed" }),
1268
+ /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
1269
+ /* @__PURE__ */ l("label", { className: "pvx-reg-label", htmlFor: `pvx-discord-${r}`, children: [
1270
+ "Discord Username ",
1271
+ /* @__PURE__ */ e("span", { className: "pvx-reg-optional", children: "(optional)" })
1272
+ ] }),
1273
+ /* @__PURE__ */ e(
1274
+ "input",
1275
+ {
1276
+ id: `pvx-discord-${r}`,
1277
+ type: "text",
1278
+ className: "pvx-reg-input",
1279
+ placeholder: "e.g. username",
1280
+ value: a,
1281
+ onChange: (m) => s(m.target.value)
1282
+ }
1283
+ )
1284
+ ] }),
1285
+ /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
1286
+ /* @__PURE__ */ e("label", { className: "pvx-reg-label", htmlFor: `pvx-exp-${r}`, children: "Experience Level" }),
1287
+ /* @__PURE__ */ l(
1288
+ "select",
1289
+ {
1290
+ id: `pvx-exp-${r}`,
1291
+ className: "pvx-reg-select",
1292
+ value: i,
1293
+ onChange: (m) => o(m.target.value),
1294
+ children: [
1295
+ /* @__PURE__ */ e("option", { value: "beginner", children: "Beginner" }),
1296
+ /* @__PURE__ */ e("option", { value: "intermediate", children: "Intermediate" }),
1297
+ /* @__PURE__ */ e("option", { value: "advanced", children: "Advanced" })
1298
+ ]
1299
+ }
1300
+ )
1301
+ ] }),
1302
+ /* @__PURE__ */ l("div", { className: "pvx-reg-field", children: [
1303
+ /* @__PURE__ */ l("label", { className: "pvx-reg-label", htmlFor: `pvx-comments-${r}`, children: [
1304
+ "Comments ",
1305
+ /* @__PURE__ */ e("span", { className: "pvx-reg-optional", children: "(optional)" })
1306
+ ] }),
1307
+ /* @__PURE__ */ e(
1308
+ "textarea",
1309
+ {
1310
+ id: `pvx-comments-${r}`,
1311
+ className: "pvx-reg-textarea",
1312
+ rows: 3,
1313
+ placeholder: "Anything the organisers should know?",
1314
+ value: c,
1315
+ onChange: (m) => v(m.target.value)
1316
+ }
1317
+ )
1318
+ ] }),
1319
+ /* @__PURE__ */ e("div", { className: "pvx-reg-actions", children: /* @__PURE__ */ e(
1320
+ "button",
1341
1321
  {
1342
- competitions: o,
1343
- isLoading: m,
1344
- onSelect: d
1322
+ type: "submit",
1323
+ className: "pvx-comp-register-btn",
1324
+ disabled: t.isPending,
1325
+ children: t.isPending ? "Registering..." : "Register"
1345
1326
  }
1346
- )
1327
+ ) })
1347
1328
  ] });
1348
1329
  }
1349
- function Nt({
1350
- competitionId: t,
1351
- activeTab: r,
1352
- selectedRound: n,
1353
- onBack: a,
1354
- onTabChange: s,
1355
- onSelectRound: i,
1356
- onDeselectRound: c
1357
- }) {
1358
- var f, p;
1359
- const { data: o, isLoading: m } = de(t);
1360
- if (m)
1361
- return /* @__PURE__ */ e(_, { message: "Loading competition..." });
1362
- if (!o)
1363
- return /* @__PURE__ */ l("div", { children: [
1364
- /* @__PURE__ */ e(M, { message: "Competition not found." }),
1365
- /* @__PURE__ */ e("div", { className: "pvx-comp-back-link-wrap", children: /* @__PURE__ */ e("button", { onClick: a, className: "pvx-comp-back-link", children: "← Back to competitions" }) })
1366
- ] });
1367
- const d = o.type === "championship", g = ((f = o.rounds) == null ? void 0 : f.filter((v) => v.isFinalized)) || [], N = o.rounds || [], x = ft.filter((v) => !(v.id === "standings" && !d || v.id === "rounds" && g.length === 0)), h = x.find((v) => v.id === r) ? r : ((p = x[0]) == null ? void 0 : p.id) || "standings";
1368
- return /* @__PURE__ */ l(Q, { children: [
1369
- /* @__PURE__ */ e("button", { onClick: a, className: "pvx-comp-back-link", children: "← Competitions" }),
1370
- /* @__PURE__ */ l("div", { className: "pvx-comp-detail-header", children: [
1371
- /* @__PURE__ */ e("h2", { className: "pvx-explorer-title", children: o.name }),
1372
- o.description && /* @__PURE__ */ e("p", { className: "pvx-comp-detail-desc", children: o.description }),
1373
- /* @__PURE__ */ l("div", { className: "pvx-comp-detail-meta", children: [
1374
- /* @__PURE__ */ e(be, { type: o.type }),
1375
- o.game && /* @__PURE__ */ e(U, { children: o.game.toUpperCase() }),
1376
- o.countingRounds > 0 && /* @__PURE__ */ l(U, { variant: "format", children: [
1377
- "Best ",
1378
- o.countingRounds,
1379
- " of ",
1380
- N.length,
1381
- " rounds count"
1382
- ] }),
1383
- N.length > 0 && /* @__PURE__ */ l(U, { children: [
1384
- N.length,
1385
- " round",
1386
- N.length !== 1 ? "s" : ""
1387
- ] })
1388
- ] })
1330
+ function Ze({ competitionId: r, drivers: t, steamId: n, isPowerMode: a, registrationUrl: s, withdrawMutation: i, registration: o }) {
1331
+ const [c, v] = L(!1), d = () => {
1332
+ i.mutate(void 0, {
1333
+ onSuccess: () => v(!1)
1334
+ });
1335
+ }, u = o || {}, b = t.length || u.currentCount || 0, x = u.maxParticipants;
1336
+ return /* @__PURE__ */ l(K, { children: [
1337
+ /* @__PURE__ */ l("div", { className: "pvx-reg-form-header", children: [
1338
+ /* @__PURE__ */ e("h3", { className: "pvx-reg-form-title", children: "Registered Drivers" }),
1339
+ x && /* @__PURE__ */ e(ge, { count: b, max: x })
1389
1340
  ] }),
1390
- N.length > 0 && /* @__PURE__ */ e(bt, { rounds: N }),
1391
- x.length > 1 && /* @__PURE__ */ e("div", { className: "pvx-comp-tabs", children: x.map((v) => /* @__PURE__ */ e(
1341
+ /* @__PURE__ */ e(xe, { drivers: t, steamId: n }),
1342
+ i.error && /* @__PURE__ */ e("div", { className: "pvx-reg-error", children: i.error.message || "Withdrawal failed" }),
1343
+ a ? /* @__PURE__ */ e("div", { className: "pvx-reg-actions", children: c ? /* @__PURE__ */ l("div", { className: "pvx-reg-confirm", children: [
1344
+ /* @__PURE__ */ e("p", { className: "pvx-reg-confirm-text", children: "Are you sure you want to unregister?" }),
1345
+ /* @__PURE__ */ l("div", { className: "pvx-reg-confirm-actions", children: [
1346
+ /* @__PURE__ */ e(
1347
+ "button",
1348
+ {
1349
+ type: "button",
1350
+ className: "pvx-reg-cancel-btn",
1351
+ onClick: () => v(!1),
1352
+ children: "Cancel"
1353
+ }
1354
+ ),
1355
+ /* @__PURE__ */ e(
1356
+ "button",
1357
+ {
1358
+ type: "button",
1359
+ className: "pvx-reg-danger-btn",
1360
+ onClick: d,
1361
+ disabled: i.isPending,
1362
+ children: i.isPending ? "Unregistering..." : "Yes, Unregister"
1363
+ }
1364
+ )
1365
+ ] })
1366
+ ] }) : /* @__PURE__ */ e(
1392
1367
  "button",
1393
1368
  {
1394
- onClick: () => s(v.id),
1395
- className: `pvx-comp-tab ${h === v.id ? "pvx-comp-tab--active" : ""}`,
1396
- children: v.label
1397
- },
1398
- v.id
1399
- )) }),
1400
- h === "standings" && /* @__PURE__ */ e(dt, { competitionId: t }),
1401
- h === "rounds" && /* @__PURE__ */ e(
1402
- yt,
1403
- {
1404
- competitionId: t,
1405
- finalizedRounds: g,
1406
- selectedRound: n,
1407
- onSelectRound: i,
1408
- onDeselectRound: c
1369
+ type: "button",
1370
+ className: "pvx-reg-unregister-btn",
1371
+ onClick: () => v(!0),
1372
+ children: "Unregister"
1409
1373
  }
1410
- ),
1411
- h === "drivers" && /* @__PURE__ */ e(gt, { competitionId: t })
1374
+ ) }) : /* @__PURE__ */ e("div", { className: "pvx-reg-actions", children: /* @__PURE__ */ e("a", { href: s, target: "_blank", rel: "noopener noreferrer", className: "pvx-comp-register-link", children: "Manage on PitVox" }) })
1412
1375
  ] });
1413
1376
  }
1414
- function bt({ rounds: t }) {
1415
- const r = /* @__PURE__ */ new Date(), n = t.find((a) => a.startTime && new Date(a.startTime) >= r);
1416
- return /* @__PURE__ */ e("div", { className: "pvx-comp-schedule", children: /* @__PURE__ */ e("div", { className: "pvx-comp-schedule-list", children: t.map((a) => {
1417
- const s = a === n, i = a.startTime && new Date(a.startTime) < r;
1377
+ function xe({ drivers: r, steamId: t }) {
1378
+ return r.length ? /* @__PURE__ */ e("div", { className: "pvx-reg-driver-list", children: r.map((n) => {
1379
+ var s, i;
1380
+ const a = t && n.steamId === t;
1418
1381
  return /* @__PURE__ */ l(
1419
1382
  "div",
1420
1383
  {
1421
- className: `pvx-comp-schedule-item ${s ? "pvx-comp-schedule-item--next" : ""} ${i ? "pvx-comp-schedule-item--past" : ""}`,
1384
+ className: `pvx-entry-card ${a ? "pvx-entry-card--you" : ""}`,
1422
1385
  children: [
1423
- /* @__PURE__ */ l("span", { className: "pvx-comp-schedule-round", children: [
1424
- "R",
1425
- a.roundNumber
1426
- ] }),
1427
- /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-track", children: a.track || "TBD" }),
1428
- /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-date", children: ye(a.startTime) }),
1429
- a.isFinalized && /* @__PURE__ */ e("span", { className: "pvx-comp-schedule-badge", children: "Results" })
1386
+ n.avatarUrl ? /* @__PURE__ */ e("img", { src: n.avatarUrl, alt: "", className: "pvx-entry-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-entry-avatar pvx-entry-avatar--placeholder", children: ((i = (s = n.displayName) == null ? void 0 : s.charAt(0)) == null ? void 0 : i.toUpperCase()) || "?" }),
1387
+ /* @__PURE__ */ l("span", { className: "pvx-entry-name", children: [
1388
+ n.displayName,
1389
+ a && /* @__PURE__ */ e("span", { className: "pvx-entry-you", children: " (you)" })
1390
+ ] })
1430
1391
  ]
1431
1392
  },
1432
- a.roundNumber
1393
+ n.steamId || n.driverId
1433
1394
  );
1434
- }) }) });
1435
- }
1436
- function yt({ competitionId: t, finalizedRounds: r, selectedRound: n, onSelectRound: a, onDeselectRound: s }) {
1437
- return r.length ? /* @__PURE__ */ l("div", { className: "pvx-comp-rounds", children: [
1438
- /* @__PURE__ */ e("div", { className: "pvx-comp-round-pills", children: r.map((i) => /* @__PURE__ */ l(
1439
- "button",
1440
- {
1441
- onClick: () => n === i.roundNumber ? s() : a(i.roundNumber),
1442
- className: `pvx-comp-round-pill ${n === i.roundNumber ? "pvx-comp-round-pill--active" : ""}`,
1443
- children: [
1444
- /* @__PURE__ */ l("span", { className: "pvx-comp-round-pill-num", children: [
1445
- "R",
1446
- i.roundNumber
1447
- ] }),
1448
- i.track && /* @__PURE__ */ e("span", { className: "pvx-comp-round-pill-track", children: i.track })
1449
- ]
1450
- },
1451
- i.roundNumber
1452
- )) }),
1453
- n ? /* @__PURE__ */ e(ut, { competitionId: t, roundNumber: n }) : /* @__PURE__ */ e("div", { className: "pvx-empty", children: /* @__PURE__ */ e("p", { children: "Select a round to view results." }) })
1454
- ] }) : /* @__PURE__ */ e(M, { message: "No finalised rounds yet." });
1455
- }
1456
- function jt({
1457
- competitionId: t,
1458
- driverData: r,
1459
- className: n,
1460
- children: a
1461
- }) {
1462
- const { data: s, isLoading: i } = Oe(t), c = We(t), o = Ge(t), m = (s == null ? void 0 : s.isRegistered) || !1, d = i || c.isPending || o.isPending, g = c.error || o.error || null, N = () => {
1463
- r && c.mutate(r);
1464
- }, x = () => {
1465
- o.mutate();
1466
- };
1467
- return typeof a == "function" ? a({ isRegistered: m, isLoading: d, register: N, withdraw: x, error: g }) : /* @__PURE__ */ e(
1468
- "button",
1469
- {
1470
- className: n,
1471
- onClick: m ? x : N,
1472
- disabled: d,
1473
- children: d ? "Loading..." : m ? "Withdraw" : "Register"
1474
- }
1475
- );
1395
+ }) }) : /* @__PURE__ */ e("div", { className: "pvx-reg-no-drivers", children: "No drivers registered yet." });
1396
+ }
1397
+ function ge({ count: r, max: t }) {
1398
+ const n = t ? r / t * 100 : 0, a = n >= 100 ? "full" : n >= 75 ? "warning" : "ok";
1399
+ return /* @__PURE__ */ l("span", { className: `pvx-reg-capacity pvx-reg-capacity--${a}`, children: [
1400
+ r,
1401
+ "/",
1402
+ t,
1403
+ " drivers"
1404
+ ] });
1476
1405
  }
1477
- function Ct(t) {
1478
- const { cdnUrl: r, partnerSlug: n } = T(), a = L({
1479
- queryKey: ["pitvox", "laps", n, t],
1480
- queryFn: () => $(r, `laps/partners/${n}/${t}.json`),
1481
- enabled: !!t,
1406
+ function Je(r) {
1407
+ const { cdnUrl: t, partnerSlug: n } = y(), a = k({
1408
+ queryKey: ["pitvox", "laps", n, r],
1409
+ queryFn: () => T(t, `laps/partners/${n}/${r}.json`),
1410
+ enabled: !!r,
1482
1411
  staleTime: 3e4,
1483
1412
  refetchInterval: 3e4
1484
1413
  }), s = a.data;
@@ -1500,19 +1429,19 @@ function Ct(t) {
1500
1429
  } : null
1501
1430
  };
1502
1431
  }
1503
- function wt(t) {
1432
+ function Ye(r) {
1504
1433
  var i;
1505
- const { cdnUrl: r, partnerSlug: n } = T(), a = L({
1434
+ const { cdnUrl: t, partnerSlug: n } = y(), a = k({
1506
1435
  queryKey: ["pitvox", "ratings", n],
1507
- queryFn: () => $(r, `leaderboards/partners/${n}/ratings.json`),
1436
+ queryFn: () => T(t, `leaderboards/partners/${n}/ratings.json`),
1508
1437
  staleTime: 6e4,
1509
1438
  refetchInterval: 6e4
1510
- }), s = k(() => {
1511
- var c;
1512
- return !((c = a.data) != null && c.drivers) || !t ? null : a.data.drivers.find(
1513
- (o) => o.identifier === t
1439
+ }), s = C(() => {
1440
+ var o;
1441
+ return !((o = a.data) != null && o.drivers) || !r ? null : a.data.drivers.find(
1442
+ (c) => c.identifier === r
1514
1443
  ) || null;
1515
- }, [(i = a.data) == null ? void 0 : i.drivers, t]);
1444
+ }, [(i = a.data) == null ? void 0 : i.drivers, r]);
1516
1445
  return {
1517
1446
  isLoading: a.isLoading,
1518
1447
  error: a.error,
@@ -1526,12 +1455,12 @@ function wt(t) {
1526
1455
  } : null
1527
1456
  };
1528
1457
  }
1529
- function kt({ driverName: t, avatarUrl: r, memberSince: n, className: a = "" }) {
1458
+ function Xe({ driverName: r, avatarUrl: t, memberSince: n, className: a = "" }) {
1530
1459
  const s = n ? new Date(n).toLocaleDateString("en-GB", { day: "2-digit", month: "2-digit", year: "numeric" }) : null;
1531
1460
  return /* @__PURE__ */ l("div", { className: `pvx-card pvx-dash-profile ${a}`, children: [
1532
- r ? /* @__PURE__ */ e("img", { src: r, alt: "", className: "pvx-dash-profile-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder", children: (t || "?")[0].toUpperCase() }),
1461
+ t ? /* @__PURE__ */ e("img", { src: t, alt: "", className: "pvx-dash-profile-avatar" }) : /* @__PURE__ */ e("div", { className: "pvx-dash-profile-avatar pvx-dash-profile-avatar--placeholder", children: (r || "?")[0].toUpperCase() }),
1533
1462
  /* @__PURE__ */ l("div", { className: "pvx-dash-profile-info", children: [
1534
- /* @__PURE__ */ e("h2", { className: "pvx-dash-profile-name", children: t }),
1463
+ /* @__PURE__ */ e("h2", { className: "pvx-dash-profile-name", children: r }),
1535
1464
  s && /* @__PURE__ */ l("p", { className: "pvx-dash-profile-since", children: [
1536
1465
  "Racing since ",
1537
1466
  s
@@ -1539,7 +1468,7 @@ function kt({ driverName: t, avatarUrl: r, memberSince: n, className: a = "" })
1539
1468
  ] })
1540
1469
  ] });
1541
1470
  }
1542
- function Tt() {
1471
+ function er() {
1543
1472
  return /* @__PURE__ */ l("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1544
1473
  /* @__PURE__ */ e("line", { x1: "4", y1: "9", x2: "20", y2: "9" }),
1545
1474
  /* @__PURE__ */ e("line", { x1: "4", y1: "15", x2: "20", y2: "15" }),
@@ -1547,7 +1476,7 @@ function Tt() {
1547
1476
  /* @__PURE__ */ e("line", { x1: "16", y1: "3", x2: "14", y2: "21" })
1548
1477
  ] });
1549
1478
  }
1550
- function St() {
1479
+ function rr() {
1551
1480
  return /* @__PURE__ */ l("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1552
1481
  /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10" }),
1553
1482
  /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "2" }),
@@ -1556,74 +1485,74 @@ function St() {
1556
1485
  /* @__PURE__ */ e("path", { d: "M13.5 12.5l4 2.5" })
1557
1486
  ] });
1558
1487
  }
1559
- function Lt() {
1488
+ function tr() {
1560
1489
  return /* @__PURE__ */ e("svg", { className: "pvx-dash-stat-icon", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" }) });
1561
1490
  }
1562
- function ae({ items: t, labelKey: r, countKey: n }) {
1563
- if (!(t != null && t.length)) return null;
1564
- const a = t.slice().sort((s, i) => i[n] - s[n]).slice(0, 10);
1491
+ function re({ items: r, labelKey: t, countKey: n }) {
1492
+ if (!(r != null && r.length)) return null;
1493
+ const a = r.slice().sort((s, i) => i[n] - s[n]).slice(0, 10);
1565
1494
  return /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip", children: [
1566
1495
  a.map((s, i) => /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row", children: [
1567
- /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-label", children: s[r] }),
1496
+ /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-label", children: s[t] }),
1568
1497
  /* @__PURE__ */ e("span", { className: "pvx-dash-tooltip-value", children: s[n] })
1569
1498
  ] }, i)),
1570
- t.length > 10 && /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row pvx-dash-tooltip-more", children: [
1499
+ r.length > 10 && /* @__PURE__ */ l("div", { className: "pvx-dash-tooltip-row pvx-dash-tooltip-more", children: [
1571
1500
  "+",
1572
- t.length - 10,
1501
+ r.length - 10,
1573
1502
  " more"
1574
1503
  ] })
1575
1504
  ] });
1576
1505
  }
1577
- function $t({ stats: t, rating: r, className: n = "" }) {
1578
- if (!t) return null;
1579
- const a = t.trackBreakdown.map((i) => ({
1580
- name: V(i.trackId, i.layout),
1506
+ function nr({ stats: r, rating: t, className: n = "" }) {
1507
+ if (!r) return null;
1508
+ const a = r.trackBreakdown.map((i) => ({
1509
+ name: O(i.trackId, i.layout),
1581
1510
  lapCount: i.lapCount
1582
- })), s = t.carBreakdown.map((i) => ({
1583
- name: I(i.carId),
1511
+ })), s = r.carBreakdown.map((i) => ({
1512
+ name: R(i.carId),
1584
1513
  lapCount: i.lapCount
1585
1514
  }));
1586
1515
  return /* @__PURE__ */ l("div", { className: `pvx-dash-stats ${n}`, children: [
1587
1516
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1588
- /* @__PURE__ */ e(Tt, {}),
1517
+ /* @__PURE__ */ e(er, {}),
1589
1518
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1590
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: t.lapCount.toLocaleString() }),
1519
+ /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: r.lapCount.toLocaleString() }),
1591
1520
  /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Total Laps" })
1592
1521
  ] }),
1593
- /* @__PURE__ */ e(ae, { items: a, labelKey: "name", countKey: "lapCount" })
1522
+ /* @__PURE__ */ e(re, { items: a, labelKey: "name", countKey: "lapCount" })
1594
1523
  ] }),
1595
1524
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--has-tooltip", children: [
1596
- /* @__PURE__ */ e(St, {}),
1525
+ /* @__PURE__ */ e(rr, {}),
1597
1526
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1598
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: t.carBreakdown.length }),
1527
+ /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: r.carBreakdown.length }),
1599
1528
  /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Cars Used" })
1600
1529
  ] }),
1601
- /* @__PURE__ */ e(ae, { items: s, labelKey: "name", countKey: "lapCount" })
1530
+ /* @__PURE__ */ e(re, { items: s, labelKey: "name", countKey: "lapCount" })
1602
1531
  ] }),
1603
- r && /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--rating", children: [
1604
- /* @__PURE__ */ e(Lt, {}),
1532
+ t && /* @__PURE__ */ l("div", { className: "pvx-dash-stat-card pvx-dash-stat-card--rating", children: [
1533
+ /* @__PURE__ */ e(tr, {}),
1605
1534
  /* @__PURE__ */ l("div", { className: "pvx-dash-stat-content", children: [
1606
- /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: r.rating.toFixed(1) }),
1535
+ /* @__PURE__ */ e("span", { className: "pvx-dash-stat-value", children: t.rating.toFixed(1) }),
1607
1536
  /* @__PURE__ */ e("span", { className: "pvx-dash-stat-label", children: "Driver Rating" }),
1608
1537
  /* @__PURE__ */ l("span", { className: "pvx-dash-stat-sub", children: [
1609
1538
  "#",
1610
- r.rank,
1539
+ t.rank,
1611
1540
  " of ",
1612
- r.totalDrivers
1541
+ t.totalDrivers
1613
1542
  ] })
1614
1543
  ] })
1615
1544
  ] })
1616
1545
  ] });
1617
1546
  }
1618
- const se = 10;
1619
- function Rt({ records: t, className: r = "" }) {
1620
- const [n, a] = j(!1), s = k(() => t != null && t.length ? t.slice().sort((o, m) => {
1621
- const d = o.recordedAt ? new Date(o.recordedAt).getTime() : 0;
1622
- return (m.recordedAt ? new Date(m.recordedAt).getTime() : 0) - d;
1623
- }) : [], [t]);
1547
+ const te = 10;
1548
+ function sr({ records: r, className: t = "" }) {
1549
+ const [n, a] = L(!1), s = C(() => r != null && r.length ? r.slice().sort((c, v) => {
1550
+ const d = c.recordedAt ? new Date(c.recordedAt).getTime() : 0;
1551
+ return (v.recordedAt ? new Date(v.recordedAt).getTime() : 0) - d;
1552
+ }) : [], [r]);
1624
1553
  if (!s.length) return null;
1625
- const i = n ? s : s.slice(0, se), c = s.length > se;
1626
- return /* @__PURE__ */ l("div", { className: `pvx-card ${r}`, children: [
1554
+ const i = n ? s : s.slice(0, te), o = s.length > te;
1555
+ return /* @__PURE__ */ l("div", { className: `pvx-card ${t}`, children: [
1627
1556
  /* @__PURE__ */ e("div", { className: "pvx-card-header", children: /* @__PURE__ */ l("h3", { className: "pvx-card-title", children: [
1628
1557
  /* @__PURE__ */ e("span", { className: "pvx-dash-records-icon", children: /* @__PURE__ */ l("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1629
1558
  /* @__PURE__ */ e("path", { d: "M6 9H4.5a2.5 2.5 0 010-5H6" }),
@@ -1640,20 +1569,20 @@ function Rt({ records: t, className: r = "" }) {
1640
1569
  ")"
1641
1570
  ] })
1642
1571
  ] }) }),
1643
- /* @__PURE__ */ e("div", { className: "pvx-dash-records-list", children: i.map((o, m) => /* @__PURE__ */ l("div", { className: "pvx-dash-record-row", children: [
1572
+ /* @__PURE__ */ e("div", { className: "pvx-dash-records-list", children: i.map((c, v) => /* @__PURE__ */ l("div", { className: "pvx-dash-record-row", children: [
1644
1573
  /* @__PURE__ */ l("div", { className: "pvx-dash-record-info", children: [
1645
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-track", children: V(o.trackId, o.layout, o.game) }),
1646
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-car", children: I(o.carId) })
1574
+ /* @__PURE__ */ e("span", { className: "pvx-dash-record-track", children: O(c.trackId, c.layout, c.game) }),
1575
+ /* @__PURE__ */ e("span", { className: "pvx-dash-record-car", children: R(c.carId) })
1647
1576
  ] }),
1648
1577
  /* @__PURE__ */ l("div", { className: "pvx-dash-record-time", children: [
1649
- /* @__PURE__ */ e("span", { className: "pvx-dash-record-lap", children: E(o.lapTimeMs) }),
1650
- /* @__PURE__ */ l("span", { className: `pvx-dash-game-badge pvx-dash-game-badge--${o.game || "evo"}`, children: [
1651
- (o.game || "evo").toUpperCase(),
1652
- o.gameVersion ? ` ${o.gameVersion}` : ""
1578
+ /* @__PURE__ */ e("span", { className: "pvx-dash-record-lap", children: B(c.lapTimeMs) }),
1579
+ /* @__PURE__ */ l("span", { className: `pvx-dash-game-badge pvx-dash-game-badge--${c.game || "evo"}`, children: [
1580
+ (c.game || "evo").toUpperCase(),
1581
+ c.gameVersion ? ` ${c.gameVersion}` : ""
1653
1582
  ] })
1654
1583
  ] })
1655
- ] }, m)) }),
1656
- c && /* @__PURE__ */ e(
1584
+ ] }, v)) }),
1585
+ o && /* @__PURE__ */ e(
1657
1586
  "button",
1658
1587
  {
1659
1588
  className: "pvx-dash-records-toggle",
@@ -1663,62 +1592,69 @@ function Rt({ records: t, className: r = "" }) {
1663
1592
  )
1664
1593
  ] });
1665
1594
  }
1666
- function Vt({ steamId: t, avatarUrl: r, memberSince: n, className: a = "" }) {
1667
- const { data: s, isLoading: i, error: c } = Ct(t), { data: o, isLoading: m } = wt(t);
1668
- return i || m ? /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading dashboard..." }) : c ? /* @__PURE__ */ e("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : s ? /* @__PURE__ */ l("div", { className: `pvx-dash ${a}`, children: [
1595
+ function Rr({ steamId: r, avatarUrl: t, memberSince: n, className: a = "" }) {
1596
+ const { data: s, isLoading: i, error: o } = Je(r), { data: c, isLoading: v } = Ye(r);
1597
+ return i || v ? /* @__PURE__ */ e("div", { className: "pvx-loading", children: "Loading dashboard..." }) : o ? /* @__PURE__ */ e("div", { className: "pvx-empty", children: "Failed to load dashboard data." }) : s ? /* @__PURE__ */ l("div", { className: `pvx-dash ${a}`, children: [
1669
1598
  /* @__PURE__ */ e(
1670
- kt,
1599
+ Xe,
1671
1600
  {
1672
1601
  driverName: s.driverName,
1673
- avatarUrl: r,
1602
+ avatarUrl: t,
1674
1603
  memberSince: n
1675
1604
  }
1676
1605
  ),
1677
- /* @__PURE__ */ e($t, { stats: s, rating: o }),
1678
- /* @__PURE__ */ e(Rt, { records: s.currentRecords })
1606
+ /* @__PURE__ */ e(nr, { stats: s, rating: c }),
1607
+ /* @__PURE__ */ e(sr, { records: s.currentRecords })
1679
1608
  ] }) : /* @__PURE__ */ e("div", { className: "pvx-empty", children: "No data available yet. Start driving to see your stats!" });
1680
1609
  }
1681
1610
  export {
1682
- et as CarsTable,
1683
- ot as CompetitionCards,
1684
- qt as CompetitionExplorer,
1685
- Vt as DriverDashboard,
1686
- kt as DriverProfile,
1687
- tt as DriversTable,
1688
- gt as EntryList,
1689
- nt as LapHistoryTable,
1690
- _t as LeaderboardExplorer,
1691
- At as PitVoxPartnerProvider,
1692
- Rt as RecordsTable,
1693
- jt as RegisterButton,
1694
- ut as RoundResults,
1695
- dt as StandingsTable,
1696
- $t as StatsCards,
1697
- Ye as TracksTable,
1698
- I as formatCarName,
1699
- F as formatDate,
1700
- Ut as formatDelta,
1701
- E as formatLapTime,
1702
- Pt as formatRelativeTime,
1703
- P as formatSectorTime,
1704
- V as formatTrackName,
1705
- le as formatTyreCompound,
1706
- Et as useCarLeaderboard,
1707
- Fe as useCarMetadata,
1708
- Ft as useCompetitionAllRounds,
1709
- de as useCompetitionConfig,
1710
- Ve as useCompetitionEntryList,
1711
- je as useCompetitionRound,
1712
- qe as useCompetitionStandings,
1713
- _e as useCompetitions,
1714
- Ue as useDriverLaps,
1715
- wt as useDriverRating,
1716
- Ct as useDriverStats,
1717
- Pe as useLeaderboardIndex,
1718
- T as usePitVox,
1719
- We as useRegister,
1720
- Oe as useRegistrationStatus,
1721
- ce as useTrackLeaderboard,
1722
- Ee as useUserLookup,
1723
- Ge as useWithdraw
1611
+ fr as CarsTable,
1612
+ M as CompEmptyState,
1613
+ U as CompLoadingState,
1614
+ yr as CompetitionCards,
1615
+ Rr as DriverDashboard,
1616
+ Xe as DriverProfile,
1617
+ Nr as DriversTable,
1618
+ kr as EntryList,
1619
+ E as InfoPill,
1620
+ br as LapHistoryTable,
1621
+ Ie as PODIUM_MEDALS,
1622
+ or as PitVoxPartnerProvider,
1623
+ sr as RecordsTable,
1624
+ Tr as RegisterButton,
1625
+ Sr as RegistrationPanel,
1626
+ wr as RoundResults,
1627
+ Oe as RoundSessionResults,
1628
+ Cr as StandingsTable,
1629
+ nr as StatsCards,
1630
+ gr as TracksTable,
1631
+ _e as TypeBadge,
1632
+ R as formatCarName,
1633
+ D as formatDate,
1634
+ dr as formatDelta,
1635
+ B as formatLapTime,
1636
+ cr as formatRelativeTime,
1637
+ $ as formatSectorTime,
1638
+ O as formatTrackName,
1639
+ se as formatTyreCompound,
1640
+ hr as useCarLeaderboard,
1641
+ mr as useCarMetadata,
1642
+ xr as useCompetitionAllRounds,
1643
+ Se as useCompetitionConfig,
1644
+ ae as useCompetitionEntryList,
1645
+ Le as useCompetitionRound,
1646
+ Re as useCompetitionStandings,
1647
+ ur as useCompetitions,
1648
+ Te as useDriverLaps,
1649
+ Ye as useDriverRating,
1650
+ Je as useDriverStats,
1651
+ pr as useLeaderboardIndex,
1652
+ y as usePitVox,
1653
+ ie as useRegister,
1654
+ G as useRegistrationMode,
1655
+ W as useRegistrationStatus,
1656
+ z as useRegistrationUrl,
1657
+ ke as useTrackLeaderboard,
1658
+ vr as useUserLookup,
1659
+ le as useWithdraw
1724
1660
  };