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