astrogators-shared-ui 0.17.3 → 0.17.4
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/THIRD-PARTY-LICENSES.md +107 -0
- package/dist/index.css +1 -1
- package/dist/index.js +295 -271
- package/dist/src/services/safeStorage.d.ts +21 -0
- package/package.json +4 -2
package/dist/index.js
CHANGED
|
@@ -128,51 +128,75 @@ var _ = [
|
|
|
128
128
|
href: "/nightwatcher/"
|
|
129
129
|
}]
|
|
130
130
|
}
|
|
131
|
-
], v =
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
131
|
+
], v = /* @__PURE__ */ new Map(), y = {
|
|
132
|
+
getItem(e) {
|
|
133
|
+
let t = v.get(e);
|
|
134
|
+
if (t !== void 0) return t;
|
|
135
|
+
try {
|
|
136
|
+
return localStorage.getItem(e);
|
|
137
|
+
} catch {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
setItem(e, t) {
|
|
142
|
+
try {
|
|
143
|
+
localStorage.setItem(e, t), v.delete(e);
|
|
144
|
+
} catch {
|
|
145
|
+
v.set(e, t);
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
removeItem(e) {
|
|
149
|
+
v.delete(e);
|
|
150
|
+
try {
|
|
151
|
+
localStorage.removeItem(e);
|
|
152
|
+
} catch {}
|
|
153
|
+
}
|
|
154
|
+
}, b = "astrogators_access_token", x = "astrogators_refresh_token", S = () => y.getItem(b), C = (e) => {
|
|
155
|
+
y.setItem(b, e);
|
|
156
|
+
}, w = () => {
|
|
157
|
+
y.removeItem(b);
|
|
158
|
+
}, T = () => y.getItem(x), E = (e) => {
|
|
159
|
+
y.setItem(x, e);
|
|
141
160
|
}, D = () => {
|
|
142
|
-
|
|
143
|
-
}, O = (
|
|
144
|
-
|
|
145
|
-
},
|
|
146
|
-
|
|
161
|
+
y.removeItem(x);
|
|
162
|
+
}, O = (e, t) => {
|
|
163
|
+
C(e), E(t);
|
|
164
|
+
}, k = () => {
|
|
165
|
+
w(), D();
|
|
166
|
+
}, ee = () => !!S(), te = "", A, j = null, ne = (e) => {
|
|
167
|
+
te = e.baseURL, A = e.onUnauthorized;
|
|
168
|
+
}, M = () => j || (j = (async () => {
|
|
169
|
+
let e = T();
|
|
147
170
|
if (!e) throw Error("No refresh token available");
|
|
148
|
-
let t = await fetch(`${
|
|
171
|
+
let t = await fetch(`${te}/api/v1/auth/refresh`, {
|
|
149
172
|
method: "POST",
|
|
150
173
|
headers: { "Content-Type": "application/json" },
|
|
151
174
|
body: JSON.stringify({ refresh_token: e })
|
|
152
175
|
});
|
|
153
|
-
if (!t.ok) throw
|
|
176
|
+
if (!t.ok) throw k(), A?.(), Error("Token refresh failed");
|
|
154
177
|
let n = await t.json();
|
|
155
|
-
return
|
|
178
|
+
return O(n.access_token, n.refresh_token), n.access_token;
|
|
156
179
|
})().finally(() => {
|
|
157
|
-
|
|
158
|
-
}),
|
|
180
|
+
j = null;
|
|
181
|
+
}), j), N = 30, P = [700, 1500], F = /* @__PURE__ */ new Set([
|
|
159
182
|
502,
|
|
160
183
|
503,
|
|
161
184
|
504
|
|
162
|
-
]),
|
|
185
|
+
]), re = (e) => {
|
|
163
186
|
let t = (e ?? "GET").toUpperCase();
|
|
164
187
|
return t === "GET" || t === "HEAD" || t === "OPTIONS";
|
|
165
|
-
},
|
|
166
|
-
let n =
|
|
167
|
-
for (let a = 0; a <=
|
|
168
|
-
a > 0 && await
|
|
169
|
-
let o = a <
|
|
188
|
+
}, I = (e) => e == null || typeof e == "string", ie = (e) => new Promise((t) => setTimeout(t, e)), ae = async (e, t) => {
|
|
189
|
+
let n = re(t.method) && I(t.body), r = I(t.body), i;
|
|
190
|
+
for (let a = 0; a <= P.length; a++) {
|
|
191
|
+
if (a > 0 && (await ie(P[a - 1]), t.signal?.aborted)) throw t.signal.reason;
|
|
192
|
+
let o = a < P.length;
|
|
170
193
|
try {
|
|
171
194
|
let r = await fetch(e, t);
|
|
172
|
-
if (o && n &&
|
|
195
|
+
if (o && n && F.has(r.status)) continue;
|
|
173
196
|
return r;
|
|
174
197
|
} catch (e) {
|
|
175
|
-
if (i = e,
|
|
198
|
+
if (i = e, t.signal?.aborted) throw e;
|
|
199
|
+
if (o && r) continue;
|
|
176
200
|
throw e;
|
|
177
201
|
}
|
|
178
202
|
}
|
|
@@ -180,26 +204,26 @@ var _ = [
|
|
|
180
204
|
}, oe = (e) => {
|
|
181
205
|
try {
|
|
182
206
|
let t = e.split(".")[1].replace(/-/g, "+").replace(/_/g, "/"), { exp: n } = JSON.parse(atob(t));
|
|
183
|
-
return typeof n == "number" && Date.now() / 1e3 >= n -
|
|
207
|
+
return typeof n == "number" && Date.now() / 1e3 >= n - N;
|
|
184
208
|
} catch {
|
|
185
209
|
return !1;
|
|
186
210
|
}
|
|
187
211
|
}, se = async (e, t = {}) => {
|
|
188
|
-
let n =
|
|
212
|
+
let n = S();
|
|
189
213
|
if (n && oe(n)) try {
|
|
190
|
-
n = await
|
|
214
|
+
n = await M();
|
|
191
215
|
} catch {
|
|
192
|
-
n =
|
|
216
|
+
n = S();
|
|
193
217
|
}
|
|
194
218
|
let r = { ...t.headers };
|
|
195
219
|
n && (r.Authorization = `Bearer ${n}`);
|
|
196
|
-
let i = await
|
|
220
|
+
let i = await ae(e, {
|
|
197
221
|
...t,
|
|
198
222
|
headers: r
|
|
199
223
|
});
|
|
200
224
|
if (i.status !== 401 || !n) return i;
|
|
201
225
|
try {
|
|
202
|
-
return r.Authorization = `Bearer ${await
|
|
226
|
+
return r.Authorization = `Bearer ${await M()}`, await ae(e, {
|
|
203
227
|
...t,
|
|
204
228
|
headers: r
|
|
205
229
|
});
|
|
@@ -268,66 +292,66 @@ var _ = [
|
|
|
268
292
|
method: "DELETE"
|
|
269
293
|
});
|
|
270
294
|
}
|
|
271
|
-
},
|
|
272
|
-
|
|
295
|
+
}, L, le = (e) => {
|
|
296
|
+
L = new ce(e);
|
|
273
297
|
}, ue = async (e) => {
|
|
274
|
-
let t = await
|
|
275
|
-
return t.tokens &&
|
|
276
|
-
}, de = async () => (await
|
|
298
|
+
let t = await L.patch("/api/v1/users/me", e);
|
|
299
|
+
return t.tokens && O(t.tokens.access_token, t.tokens.refresh_token), t;
|
|
300
|
+
}, de = async () => (await L.post("/api/v1/auth/logout-all")).message, R = "astrogators_ally_codes", fe = "astrogators_selected_ally_code", pe = "astrogators_migration_prompt_dismissed", z = () => {
|
|
277
301
|
try {
|
|
278
|
-
let e =
|
|
302
|
+
let e = y.getItem(R);
|
|
279
303
|
return e ? JSON.parse(e) : [];
|
|
280
304
|
} catch (e) {
|
|
281
305
|
return console.error("Failed to read ally codes from localStorage:", e), [];
|
|
282
306
|
}
|
|
283
|
-
},
|
|
307
|
+
}, me = (e) => {
|
|
284
308
|
try {
|
|
285
|
-
let t =
|
|
309
|
+
let t = z();
|
|
286
310
|
if (t.some((t) => t.ally_code === e.ally_code)) return;
|
|
287
|
-
t.push(e),
|
|
311
|
+
t.push(e), y.setItem(R, JSON.stringify(t));
|
|
288
312
|
} catch (e) {
|
|
289
313
|
console.error("Failed to save ally code to localStorage:", e);
|
|
290
314
|
}
|
|
291
|
-
},
|
|
315
|
+
}, he = (e) => {
|
|
292
316
|
try {
|
|
293
|
-
let t =
|
|
294
|
-
|
|
317
|
+
let t = z().filter((t) => t.ally_code !== e);
|
|
318
|
+
y.setItem(R, JSON.stringify(t));
|
|
295
319
|
} catch (e) {
|
|
296
320
|
console.error("Failed to remove ally code from localStorage:", e);
|
|
297
321
|
}
|
|
298
|
-
},
|
|
322
|
+
}, ge = (e) => {
|
|
299
323
|
try {
|
|
300
|
-
let t =
|
|
324
|
+
let t = z().map((t) => t.ally_code === e ? {
|
|
301
325
|
...t,
|
|
302
326
|
last_used_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
303
327
|
} : t);
|
|
304
|
-
|
|
328
|
+
y.setItem(R, JSON.stringify(t));
|
|
305
329
|
} catch (e) {
|
|
306
330
|
console.error("Failed to update ally code last used:", e);
|
|
307
331
|
}
|
|
308
|
-
},
|
|
309
|
-
e ?
|
|
310
|
-
}, _e = () => {
|
|
311
|
-
localStorage.removeItem(I), localStorage.removeItem(L);
|
|
332
|
+
}, _e = () => y.getItem(fe), B = (e) => {
|
|
333
|
+
e ? y.setItem(fe, e) : y.removeItem(fe);
|
|
312
334
|
}, ve = () => {
|
|
335
|
+
y.removeItem(R), y.removeItem(fe);
|
|
336
|
+
}, ye = () => {
|
|
313
337
|
try {
|
|
314
|
-
return sessionStorage.getItem(
|
|
338
|
+
return sessionStorage.getItem(pe) === "1";
|
|
315
339
|
} catch (e) {
|
|
316
340
|
return console.error("Failed to read migration prompt dismissal from sessionStorage:", e), !1;
|
|
317
341
|
}
|
|
318
|
-
},
|
|
342
|
+
}, be = () => {
|
|
319
343
|
try {
|
|
320
|
-
sessionStorage.setItem(
|
|
344
|
+
sessionStorage.setItem(pe, "1");
|
|
321
345
|
} catch (e) {
|
|
322
346
|
console.error("Failed to persist migration prompt dismissal to sessionStorage:", e);
|
|
323
347
|
}
|
|
324
|
-
},
|
|
348
|
+
}, xe = () => {
|
|
325
349
|
try {
|
|
326
|
-
sessionStorage.removeItem(
|
|
350
|
+
sessionStorage.removeItem(pe);
|
|
327
351
|
} catch (e) {
|
|
328
352
|
console.error("Failed to clear migration prompt dismissal from sessionStorage:", e);
|
|
329
353
|
}
|
|
330
|
-
},
|
|
354
|
+
}, Se = t(void 0), Ce = ({ children: e, apiBaseUrl: t }) => {
|
|
331
355
|
let [n, i] = s(null), [o, c] = s(!0), [u, d] = s(!0), [f, p] = s(!0), [m, h] = s([]), [g, _] = s(null), [v, y] = s(!1), [b, x] = s({
|
|
332
356
|
show: !1,
|
|
333
357
|
localStorageCodes: []
|
|
@@ -335,7 +359,7 @@ var _ = [
|
|
|
335
359
|
le({ baseURL: t }), a(() => {
|
|
336
360
|
(async () => {
|
|
337
361
|
try {
|
|
338
|
-
let e = await
|
|
362
|
+
let e = await L.get("/api/v1/config/features");
|
|
339
363
|
d(e.auth_enabled);
|
|
340
364
|
} catch (e) {
|
|
341
365
|
console.error("Failed to fetch features:", e), d(!0);
|
|
@@ -345,15 +369,15 @@ var _ = [
|
|
|
345
369
|
})();
|
|
346
370
|
}, [t]);
|
|
347
371
|
let S = r(async () => {
|
|
348
|
-
if (!
|
|
372
|
+
if (!ee()) {
|
|
349
373
|
i(null), c(!1);
|
|
350
374
|
return;
|
|
351
375
|
}
|
|
352
376
|
try {
|
|
353
|
-
let e = await
|
|
377
|
+
let e = await L.get("/api/v1/users/me");
|
|
354
378
|
i(e);
|
|
355
379
|
} catch (e) {
|
|
356
|
-
console.error("Failed to fetch user:", e), i(null),
|
|
380
|
+
console.error("Failed to fetch user:", e), i(null), k();
|
|
357
381
|
} finally {
|
|
358
382
|
c(!1);
|
|
359
383
|
}
|
|
@@ -363,172 +387,172 @@ var _ = [
|
|
|
363
387
|
}, [S]);
|
|
364
388
|
let C = async (e) => {
|
|
365
389
|
try {
|
|
366
|
-
let t = await
|
|
367
|
-
|
|
368
|
-
let n = await
|
|
390
|
+
let t = await L.post("/api/v1/auth/login", e);
|
|
391
|
+
O(t.access_token, t.refresh_token);
|
|
392
|
+
let n = await L.get("/api/v1/users/me");
|
|
369
393
|
i(n);
|
|
370
394
|
} catch (e) {
|
|
371
395
|
throw console.error("Login failed:", e), e;
|
|
372
396
|
}
|
|
373
397
|
}, w = async (e) => {
|
|
374
398
|
try {
|
|
375
|
-
await
|
|
399
|
+
await L.post("/api/v1/auth/register", e);
|
|
376
400
|
} catch (e) {
|
|
377
401
|
throw console.error("Registration failed:", e), e;
|
|
378
402
|
}
|
|
379
403
|
}, T = () => {
|
|
380
|
-
|
|
404
|
+
k(), i(null), h([]), _(null), B(null), x({
|
|
381
405
|
show: !1,
|
|
382
406
|
localStorageCodes: []
|
|
383
|
-
}),
|
|
384
|
-
},
|
|
407
|
+
}), xe();
|
|
408
|
+
}, E = async () => {
|
|
385
409
|
await S();
|
|
386
|
-
},
|
|
410
|
+
}, D = async () => {
|
|
387
411
|
try {
|
|
388
412
|
await de();
|
|
389
413
|
} finally {
|
|
390
414
|
T();
|
|
391
415
|
}
|
|
392
|
-
},
|
|
416
|
+
}, te = async (e) => {
|
|
393
417
|
let t = await ue(e);
|
|
394
418
|
return i(t), t;
|
|
395
|
-
},
|
|
419
|
+
}, A = async (e) => {
|
|
396
420
|
try {
|
|
397
|
-
return (await
|
|
421
|
+
return (await L.post("/api/v1/auth/forgot-password", e)).message;
|
|
398
422
|
} catch (e) {
|
|
399
423
|
throw console.error("Forgot password failed:", e), e;
|
|
400
424
|
}
|
|
401
|
-
},
|
|
425
|
+
}, j = async (e) => {
|
|
402
426
|
try {
|
|
403
|
-
return (await
|
|
427
|
+
return (await L.post("/api/v1/auth/reset-password", e)).message;
|
|
404
428
|
} catch (e) {
|
|
405
429
|
throw console.error("Reset password failed:", e), e;
|
|
406
430
|
}
|
|
407
|
-
},
|
|
431
|
+
}, ne = async (e) => {
|
|
408
432
|
try {
|
|
409
|
-
return (await
|
|
433
|
+
return (await L.post("/api/v1/auth/resend-verification", e)).message;
|
|
410
434
|
} catch (e) {
|
|
411
435
|
throw console.error("Resend verification failed:", e), e;
|
|
412
436
|
}
|
|
413
|
-
},
|
|
437
|
+
}, M = r(async () => {
|
|
414
438
|
y(!0);
|
|
415
439
|
try {
|
|
416
440
|
let e = [];
|
|
417
441
|
if (n) {
|
|
418
|
-
let t = await
|
|
442
|
+
let t = await L.get("/api/v1/users/me/ally-codes");
|
|
419
443
|
h(t.ally_codes), e = t.ally_codes.map((e) => e.ally_code);
|
|
420
|
-
let n =
|
|
421
|
-
n.length > 0 && !
|
|
444
|
+
let n = z();
|
|
445
|
+
n.length > 0 && !ye() && x({
|
|
422
446
|
show: !0,
|
|
423
447
|
localStorageCodes: n.map((e) => e.ally_code)
|
|
424
448
|
});
|
|
425
449
|
} else {
|
|
426
|
-
let t =
|
|
450
|
+
let t = z();
|
|
427
451
|
h(t), e = t.map((e) => e.ally_code);
|
|
428
452
|
}
|
|
429
|
-
let t =
|
|
430
|
-
_(r), r !== t &&
|
|
453
|
+
let t = _e(), r = t && e.includes(t) ? t : null;
|
|
454
|
+
_(r), r !== t && B(r);
|
|
431
455
|
} catch (e) {
|
|
432
456
|
console.error("Failed to fetch ally codes:", e), h([]);
|
|
433
457
|
} finally {
|
|
434
458
|
y(!1);
|
|
435
459
|
}
|
|
436
|
-
}, [n]),
|
|
437
|
-
n && typeof e == "number" ? (await
|
|
438
|
-
}, [n,
|
|
439
|
-
if (_(e),
|
|
460
|
+
}, [n]), N = r(async (e) => {
|
|
461
|
+
n && typeof e == "number" ? (await L.put(`/api/v1/users/me/ally-codes/${e}/use`, {}), await M()) : !n && typeof e == "string" && (ge(e), h(z()));
|
|
462
|
+
}, [n, M]), P = r((e) => {
|
|
463
|
+
if (_(e), B(e), e && n) {
|
|
440
464
|
let t = m.find((t) => "ally_code" in t && t.ally_code === e);
|
|
441
|
-
t && "id" in t &&
|
|
442
|
-
} else e && !n &&
|
|
465
|
+
t && "id" in t && N(t.id);
|
|
466
|
+
} else e && !n && ge(e);
|
|
443
467
|
}, [
|
|
444
468
|
n,
|
|
445
469
|
m,
|
|
446
|
-
|
|
447
|
-
]),
|
|
470
|
+
N
|
|
471
|
+
]), F = r(async (e) => {
|
|
448
472
|
if (!/^\d{9}$/.test(e)) throw Error("Ally code must be exactly 9 digits");
|
|
449
473
|
if (n) {
|
|
450
|
-
let t = await
|
|
451
|
-
h((e) => [t, ...e]), m.length === 0 &&
|
|
474
|
+
let t = await L.post("/api/v1/users/me/ally-codes", { ally_code: e });
|
|
475
|
+
h((e) => [t, ...e]), m.length === 0 && P(e);
|
|
452
476
|
} else {
|
|
453
|
-
let t = await
|
|
477
|
+
let t = await L.get(`/api/v1/player-data/player/${e}`);
|
|
454
478
|
if (!t) throw Error("Invalid ally code - player not found");
|
|
455
|
-
|
|
479
|
+
me({
|
|
456
480
|
ally_code: e,
|
|
457
481
|
player_name: t.data?.name ?? null,
|
|
458
482
|
last_used_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
459
|
-
}), h(
|
|
483
|
+
}), h(z()), m.length === 0 && P(e);
|
|
460
484
|
}
|
|
461
485
|
}, [
|
|
462
486
|
n,
|
|
463
487
|
m.length,
|
|
464
|
-
|
|
465
|
-
]),
|
|
466
|
-
n && typeof e == "number" ? (await
|
|
488
|
+
P
|
|
489
|
+
]), re = r(async (e) => {
|
|
490
|
+
n && typeof e == "number" ? (await L.delete(`/api/v1/users/me/ally-codes/${e}`), h((t) => t.filter((t) => "id" in t && t.id !== e))) : !n && typeof e == "string" && (he(e), h(z()), g === e && P(null));
|
|
467
491
|
}, [
|
|
468
492
|
n,
|
|
469
493
|
g,
|
|
470
|
-
|
|
471
|
-
]),
|
|
494
|
+
P
|
|
495
|
+
]), I = r(() => {
|
|
472
496
|
x({
|
|
473
497
|
show: !1,
|
|
474
498
|
localStorageCodes: []
|
|
475
|
-
}),
|
|
476
|
-
}, []),
|
|
499
|
+
}), be();
|
|
500
|
+
}, []), ie = r(async () => {
|
|
477
501
|
if (!n) return;
|
|
478
|
-
let e =
|
|
502
|
+
let e = z();
|
|
479
503
|
for (let t of e) try {
|
|
480
|
-
await
|
|
504
|
+
await F(t.ally_code);
|
|
481
505
|
} catch (e) {
|
|
482
506
|
console.error(`Failed to migrate ally code ${t.ally_code}:`, e);
|
|
483
507
|
}
|
|
484
|
-
|
|
508
|
+
ve(), I();
|
|
485
509
|
}, [
|
|
486
510
|
n,
|
|
487
|
-
|
|
488
|
-
|
|
511
|
+
F,
|
|
512
|
+
I
|
|
489
513
|
]);
|
|
490
514
|
a(() => {
|
|
491
|
-
|
|
492
|
-
}, [
|
|
493
|
-
let
|
|
515
|
+
M();
|
|
516
|
+
}, [M]);
|
|
517
|
+
let ae = {
|
|
494
518
|
user: n,
|
|
495
519
|
isAuthenticated: !!n,
|
|
496
520
|
isLoading: o,
|
|
497
521
|
login: C,
|
|
498
522
|
register: w,
|
|
499
523
|
logout: T,
|
|
500
|
-
logoutAll:
|
|
501
|
-
refreshUser:
|
|
502
|
-
forgotPassword:
|
|
503
|
-
resetPassword:
|
|
504
|
-
resendVerification:
|
|
505
|
-
updateAccount:
|
|
524
|
+
logoutAll: D,
|
|
525
|
+
refreshUser: E,
|
|
526
|
+
forgotPassword: A,
|
|
527
|
+
resetPassword: j,
|
|
528
|
+
resendVerification: ne,
|
|
529
|
+
updateAccount: te,
|
|
506
530
|
authEnabled: u,
|
|
507
531
|
isLoadingFeatures: f,
|
|
508
532
|
allyCodes: m,
|
|
509
533
|
selectedAllyCode: g,
|
|
510
534
|
isLoadingAllyCodes: v,
|
|
511
|
-
fetchAllyCodes:
|
|
512
|
-
addAllyCode:
|
|
513
|
-
removeAllyCode:
|
|
514
|
-
selectAllyCode:
|
|
515
|
-
updateAllyCodeLastUsed:
|
|
535
|
+
fetchAllyCodes: M,
|
|
536
|
+
addAllyCode: F,
|
|
537
|
+
removeAllyCode: re,
|
|
538
|
+
selectAllyCode: P,
|
|
539
|
+
updateAllyCodeLastUsed: N,
|
|
516
540
|
migrationPrompt: b,
|
|
517
|
-
dismissMigrationPrompt:
|
|
518
|
-
migrateLocalStorageCodes:
|
|
541
|
+
dismissMigrationPrompt: I,
|
|
542
|
+
migrateLocalStorageCodes: ie
|
|
519
543
|
};
|
|
520
|
-
return /* @__PURE__ */ l(
|
|
521
|
-
value:
|
|
544
|
+
return /* @__PURE__ */ l(Se.Provider, {
|
|
545
|
+
value: ae,
|
|
522
546
|
children: e
|
|
523
547
|
});
|
|
524
|
-
},
|
|
525
|
-
let e = i(
|
|
548
|
+
}, V = () => {
|
|
549
|
+
let e = i(Se);
|
|
526
550
|
if (e === void 0) throw Error("useAuth must be used within an AuthProvider");
|
|
527
551
|
return e;
|
|
528
552
|
};
|
|
529
553
|
//#endregion
|
|
530
554
|
//#region src/hooks/useDismissableMenu.ts
|
|
531
|
-
function
|
|
555
|
+
function we({ isOpen: e, onClose: t, triggerRef: n, panelRef: r }) {
|
|
532
556
|
a(() => {
|
|
533
557
|
if (!e) return;
|
|
534
558
|
let i = (e) => {
|
|
@@ -547,7 +571,7 @@ function Ce({ isOpen: e, onClose: t, triggerRef: n, panelRef: r }) {
|
|
|
547
571
|
r
|
|
548
572
|
]);
|
|
549
573
|
}
|
|
550
|
-
var
|
|
574
|
+
var H = {
|
|
551
575
|
navMenu: "_navMenu_vspnm_1",
|
|
552
576
|
trigger: "_trigger_vspnm_8",
|
|
553
577
|
tabActive: "_tabActive_vspnm_29",
|
|
@@ -560,9 +584,9 @@ var V = {
|
|
|
560
584
|
groupLabel: "_groupLabel_vspnm_92",
|
|
561
585
|
groupItems: "_groupItems_vspnm_97",
|
|
562
586
|
groupItem: "_groupItem_vspnm_97"
|
|
563
|
-
},
|
|
564
|
-
let { isAuthenticated: s, user: c } =
|
|
565
|
-
|
|
587
|
+
}, Te = ({ app: e, isCurrentApp: t, activeSectionId: n, isOpen: r, onOpenChange: i, onSectionClick: a }) => {
|
|
588
|
+
let { isAuthenticated: s, user: c } = V(), d = o(null), f = o(null), p = `navmenu-panel-${e.id}`;
|
|
589
|
+
we({
|
|
566
590
|
isOpen: r,
|
|
567
591
|
onClose: () => i(!1),
|
|
568
592
|
triggerRef: d,
|
|
@@ -578,24 +602,24 @@ var V = {
|
|
|
578
602
|
let i = t && n === e.id;
|
|
579
603
|
return /* @__PURE__ */ l("a", {
|
|
580
604
|
href: e.href,
|
|
581
|
-
className: `${
|
|
605
|
+
className: `${H.sectionLink} ${r ?? ""} ${i ? H.sectionActive : ""}`,
|
|
582
606
|
"aria-current": i ? "page" : void 0,
|
|
583
607
|
onClick: h(e),
|
|
584
608
|
children: e.label
|
|
585
609
|
}, e.id);
|
|
586
610
|
};
|
|
587
611
|
return /* @__PURE__ */ u("div", {
|
|
588
|
-
className:
|
|
612
|
+
className: H.navMenu,
|
|
589
613
|
children: [/* @__PURE__ */ u("button", {
|
|
590
614
|
type: "button",
|
|
591
615
|
ref: d,
|
|
592
|
-
className: `${
|
|
616
|
+
className: `${H.trigger} ${t ? H.tabActive : ""}`,
|
|
593
617
|
"aria-expanded": r,
|
|
594
618
|
"aria-controls": p,
|
|
595
619
|
"aria-haspopup": "true",
|
|
596
620
|
onClick: () => i(!r),
|
|
597
621
|
children: [e.label, /* @__PURE__ */ l("svg", {
|
|
598
|
-
className:
|
|
622
|
+
className: H.chevron,
|
|
599
623
|
width: "10",
|
|
600
624
|
height: "6",
|
|
601
625
|
viewBox: "0 0 10 6",
|
|
@@ -612,9 +636,9 @@ var V = {
|
|
|
612
636
|
}), r && /* @__PURE__ */ l("div", {
|
|
613
637
|
id: p,
|
|
614
638
|
ref: f,
|
|
615
|
-
className:
|
|
639
|
+
className: H.panel,
|
|
616
640
|
children: e.status === "coming-soon" ? /* @__PURE__ */ l("div", {
|
|
617
|
-
className:
|
|
641
|
+
className: H.comingSoon,
|
|
618
642
|
children: "Coming soon"
|
|
619
643
|
}) : /* @__PURE__ */ l("nav", {
|
|
620
644
|
"aria-label": `${e.label} sections`,
|
|
@@ -623,20 +647,20 @@ var V = {
|
|
|
623
647
|
if (!g(e)) return m(e) ? v(e) : null;
|
|
624
648
|
let t = e.items.filter(m);
|
|
625
649
|
return /* @__PURE__ */ u("div", {
|
|
626
|
-
className:
|
|
627
|
-
children: [v(e,
|
|
628
|
-
className:
|
|
629
|
-
children: t.map((e) => v(e,
|
|
650
|
+
className: H.group,
|
|
651
|
+
children: [v(e, H.groupLabel), /* @__PURE__ */ l("div", {
|
|
652
|
+
className: H.groupItems,
|
|
653
|
+
children: t.map((e) => v(e, H.groupItem))
|
|
630
654
|
})]
|
|
631
655
|
}, e.id);
|
|
632
656
|
})
|
|
633
657
|
})
|
|
634
658
|
})]
|
|
635
659
|
});
|
|
636
|
-
},
|
|
660
|
+
}, Ee = { burger: "_burger_javjr_1" }, De = n(({ isOpen: e, onClick: t, controlsId: n }, r) => /* @__PURE__ */ l("button", {
|
|
637
661
|
ref: r,
|
|
638
662
|
type: "button",
|
|
639
|
-
className:
|
|
663
|
+
className: Ee.burger,
|
|
640
664
|
onClick: t,
|
|
641
665
|
"aria-expanded": e,
|
|
642
666
|
"aria-controls": n,
|
|
@@ -665,8 +689,8 @@ var V = {
|
|
|
665
689
|
})
|
|
666
690
|
})
|
|
667
691
|
}));
|
|
668
|
-
|
|
669
|
-
var
|
|
692
|
+
De.displayName = "NavBurger";
|
|
693
|
+
var U = {
|
|
670
694
|
selectWrapper: "_selectWrapper_ir4bq_1",
|
|
671
695
|
fullWidth: "_fullWidth_ir4bq_7",
|
|
672
696
|
label: "_label_ir4bq_11",
|
|
@@ -677,25 +701,25 @@ var H = {
|
|
|
677
701
|
arrow: "_arrow_ir4bq_71",
|
|
678
702
|
errorText: "_errorText_ir4bq_81",
|
|
679
703
|
helperText: "_helperText_ir4bq_86"
|
|
680
|
-
},
|
|
704
|
+
}, Oe = e.forwardRef(({ label: e, error: t, helperText: n, options: r, placeholder: i, fullWidth: a = !1, className: o = "", id: s, ...c }, d) => {
|
|
681
705
|
let f = s || `select-${Math.random().toString(36).substr(2, 9)}`, p = !!t;
|
|
682
706
|
return /* @__PURE__ */ u("div", {
|
|
683
|
-
className: `${
|
|
707
|
+
className: `${U.selectWrapper} ${a ? U.fullWidth : ""} ${o}`,
|
|
684
708
|
children: [
|
|
685
709
|
e && /* @__PURE__ */ u("label", {
|
|
686
710
|
htmlFor: f,
|
|
687
|
-
className:
|
|
711
|
+
className: U.label,
|
|
688
712
|
children: [e, c.required && /* @__PURE__ */ l("span", {
|
|
689
|
-
className:
|
|
713
|
+
className: U.required,
|
|
690
714
|
children: "*"
|
|
691
715
|
})]
|
|
692
716
|
}),
|
|
693
717
|
/* @__PURE__ */ u("div", {
|
|
694
|
-
className:
|
|
718
|
+
className: U.selectContainer,
|
|
695
719
|
children: [/* @__PURE__ */ u("select", {
|
|
696
720
|
ref: d,
|
|
697
721
|
id: f,
|
|
698
|
-
className: `${
|
|
722
|
+
className: `${U.select} ${p ? U.error : ""}`,
|
|
699
723
|
...c,
|
|
700
724
|
children: [
|
|
701
725
|
i && /* @__PURE__ */ l("option", {
|
|
@@ -711,23 +735,23 @@ var H = {
|
|
|
711
735
|
!r && c.children
|
|
712
736
|
]
|
|
713
737
|
}), /* @__PURE__ */ l("span", {
|
|
714
|
-
className:
|
|
738
|
+
className: U.arrow,
|
|
715
739
|
children: "▼"
|
|
716
740
|
})]
|
|
717
741
|
}),
|
|
718
742
|
t && /* @__PURE__ */ l("span", {
|
|
719
|
-
className:
|
|
743
|
+
className: U.errorText,
|
|
720
744
|
children: t
|
|
721
745
|
}),
|
|
722
746
|
n && !t && /* @__PURE__ */ l("span", {
|
|
723
|
-
className:
|
|
747
|
+
className: U.helperText,
|
|
724
748
|
children: n
|
|
725
749
|
})
|
|
726
750
|
]
|
|
727
751
|
});
|
|
728
752
|
});
|
|
729
|
-
|
|
730
|
-
var
|
|
753
|
+
Oe.displayName = "Select";
|
|
754
|
+
var W = {
|
|
731
755
|
button: "_button_159ms_1",
|
|
732
756
|
sm: "_sm_159ms_22",
|
|
733
757
|
md: "_md_159ms_28",
|
|
@@ -743,18 +767,18 @@ var U = {
|
|
|
743
767
|
spinner: "_spinner_159ms_116",
|
|
744
768
|
spin: "_spin_159ms_116",
|
|
745
769
|
loadingText: "_loadingText_159ms_131"
|
|
746
|
-
},
|
|
747
|
-
className: `${
|
|
770
|
+
}, G = ({ children: e, variant: t = "primary", size: n = "md", fullWidth: r = !1, loading: i = !1, disabled: a = !1, className: o = "", ...s }) => /* @__PURE__ */ l("button", {
|
|
771
|
+
className: `${W.button} ${W[t]} ${W[n]} ${r ? W.fullWidth : ""} ${i ? W.loading : ""} ${o}`,
|
|
748
772
|
disabled: a || i,
|
|
749
773
|
...s,
|
|
750
774
|
children: i ? /* @__PURE__ */ u("span", {
|
|
751
|
-
className:
|
|
752
|
-
children: [/* @__PURE__ */ l("span", { className:
|
|
753
|
-
className:
|
|
775
|
+
className: W.loadingSpinner,
|
|
776
|
+
children: [/* @__PURE__ */ l("span", { className: W.spinner }), /* @__PURE__ */ l("span", {
|
|
777
|
+
className: W.loadingText,
|
|
754
778
|
children: e
|
|
755
779
|
})]
|
|
756
780
|
}) : e
|
|
757
|
-
}),
|
|
781
|
+
}), K = {
|
|
758
782
|
inputWrapper: "_inputWrapper_15t4g_1",
|
|
759
783
|
fullWidth: "_fullWidth_15t4g_7",
|
|
760
784
|
label: "_label_15t4g_11",
|
|
@@ -763,40 +787,40 @@ var U = {
|
|
|
763
787
|
error: "_error_15t4g_55",
|
|
764
788
|
errorText: "_errorText_15t4g_63",
|
|
765
789
|
helperText: "_helperText_15t4g_68"
|
|
766
|
-
},
|
|
790
|
+
}, ke = e.forwardRef(({ label: e, error: t, helperText: n, fullWidth: r = !1, className: i = "", id: a, ...o }, s) => {
|
|
767
791
|
let c = a || `input-${Math.random().toString(36).substr(2, 9)}`, d = !!t;
|
|
768
792
|
return /* @__PURE__ */ u("div", {
|
|
769
|
-
className: `${
|
|
793
|
+
className: `${K.inputWrapper} ${r ? K.fullWidth : ""} ${i}`,
|
|
770
794
|
children: [
|
|
771
795
|
e && /* @__PURE__ */ u("label", {
|
|
772
796
|
htmlFor: c,
|
|
773
|
-
className:
|
|
797
|
+
className: K.label,
|
|
774
798
|
children: [e, o.required && /* @__PURE__ */ l("span", {
|
|
775
|
-
className:
|
|
799
|
+
className: K.required,
|
|
776
800
|
children: "*"
|
|
777
801
|
})]
|
|
778
802
|
}),
|
|
779
803
|
/* @__PURE__ */ l("input", {
|
|
780
804
|
ref: s,
|
|
781
805
|
id: c,
|
|
782
|
-
className: `${
|
|
806
|
+
className: `${K.input} ${d ? K.error : ""}`,
|
|
783
807
|
...o
|
|
784
808
|
}),
|
|
785
809
|
t && /* @__PURE__ */ l("span", {
|
|
786
|
-
className:
|
|
810
|
+
className: K.errorText,
|
|
787
811
|
children: t
|
|
788
812
|
}),
|
|
789
813
|
n && !t && /* @__PURE__ */ l("span", {
|
|
790
|
-
className:
|
|
814
|
+
className: K.helperText,
|
|
791
815
|
children: n
|
|
792
816
|
})
|
|
793
817
|
]
|
|
794
818
|
});
|
|
795
819
|
});
|
|
796
|
-
|
|
820
|
+
ke.displayName = "Input";
|
|
797
821
|
//#endregion
|
|
798
822
|
//#region src/utils/formatAllyCode.ts
|
|
799
|
-
var
|
|
823
|
+
var q = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e.slice(6, 9)}`, Ae = (e) => e.replace(/-/g, ""), J = {
|
|
800
824
|
allyCodeDropdown: "_allyCodeDropdown_1pawi_1",
|
|
801
825
|
select: "_select_1pawi_8",
|
|
802
826
|
manageButton: "_manageButton_1pawi_12",
|
|
@@ -809,29 +833,29 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
809
833
|
codeItem: "_codeItem_1pawi_71",
|
|
810
834
|
doneButton: "_doneButton_1pawi_88",
|
|
811
835
|
inline: "_inline_1pawi_107"
|
|
812
|
-
},
|
|
813
|
-
let { allyCodes: a, selectedAllyCode: c, selectAllyCode: d, removeAllyCode: f, addAllyCode: p, isLoadingAllyCodes: m } =
|
|
836
|
+
}, je = ({ onAllyCodeSelected: e, className: t = "", isOpen: n, onOpenChange: r, variant: i = "floating" }) => {
|
|
837
|
+
let { allyCodes: a, selectedAllyCode: c, selectAllyCode: d, removeAllyCode: f, addAllyCode: p, isLoadingAllyCodes: m } = V(), [h, g] = s(!1), _ = n ?? h, v = (e) => {
|
|
814
838
|
g(e), r?.(e);
|
|
815
839
|
}, [y, b] = s(""), [x, S] = s(""), [C, w] = s(""), [T, E] = s(!1), D = o(null), O = o(null);
|
|
816
|
-
|
|
840
|
+
we({
|
|
817
841
|
isOpen: _ && i === "floating",
|
|
818
842
|
onClose: () => v(!1),
|
|
819
843
|
triggerRef: D,
|
|
820
844
|
panelRef: O
|
|
821
845
|
});
|
|
822
|
-
let
|
|
846
|
+
let k = a.map((e) => ({
|
|
823
847
|
value: e.ally_code,
|
|
824
|
-
label: e.player_name ? `${e.player_name} (${
|
|
825
|
-
})),
|
|
848
|
+
label: e.player_name ? `${e.player_name} (${q(e.ally_code)})` : q(e.ally_code)
|
|
849
|
+
})), ee = (t) => {
|
|
826
850
|
let n = t.target.value || null;
|
|
827
851
|
d(n), e?.(n);
|
|
828
|
-
},
|
|
852
|
+
}, te = async (e) => {
|
|
829
853
|
let t = a.find((t) => t.ally_code === e);
|
|
830
854
|
if (t) {
|
|
831
855
|
let e = "id" in t ? t.id : t.ally_code;
|
|
832
856
|
await f(e);
|
|
833
857
|
}
|
|
834
|
-
},
|
|
858
|
+
}, A = async () => {
|
|
835
859
|
if (S(""), w(""), !/^\d{9}$/.test(y)) {
|
|
836
860
|
S("Ally code must be exactly 9 digits");
|
|
837
861
|
return;
|
|
@@ -844,110 +868,110 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
844
868
|
} finally {
|
|
845
869
|
E(!1);
|
|
846
870
|
}
|
|
847
|
-
},
|
|
871
|
+
}, j = a.length > 0;
|
|
848
872
|
return /* @__PURE__ */ u("div", {
|
|
849
|
-
className: `${
|
|
873
|
+
className: `${J.allyCodeDropdown} ${i === "inline" ? J.inline : ""} ${t}`,
|
|
850
874
|
children: [
|
|
851
|
-
|
|
852
|
-
options:
|
|
875
|
+
j && /* @__PURE__ */ l(Oe, {
|
|
876
|
+
options: k,
|
|
853
877
|
value: c || "",
|
|
854
|
-
onChange:
|
|
878
|
+
onChange: ee,
|
|
855
879
|
placeholder: "Select ally code",
|
|
856
880
|
disabled: m,
|
|
857
|
-
className:
|
|
881
|
+
className: J.select
|
|
858
882
|
}),
|
|
859
883
|
_ && /* @__PURE__ */ u("div", {
|
|
860
|
-
className:
|
|
884
|
+
className: J.managePanel,
|
|
861
885
|
ref: O,
|
|
862
886
|
id: "ally-code-manage-panel",
|
|
863
887
|
children: [
|
|
864
888
|
/* @__PURE__ */ l("h4", { children: "Manage Ally Codes" }),
|
|
865
889
|
/* @__PURE__ */ u("div", {
|
|
866
|
-
className:
|
|
890
|
+
className: J.addSection,
|
|
867
891
|
children: [
|
|
868
892
|
/* @__PURE__ */ u("div", {
|
|
869
|
-
className:
|
|
870
|
-
children: [/* @__PURE__ */ l(
|
|
893
|
+
className: J.addInputGroup,
|
|
894
|
+
children: [/* @__PURE__ */ l(ke, {
|
|
871
895
|
type: "text",
|
|
872
896
|
placeholder: "9-digit ally code",
|
|
873
897
|
value: y,
|
|
874
898
|
onChange: (e) => b(e.target.value.replace(/\D/g, "").slice(0, 9)),
|
|
875
899
|
disabled: T
|
|
876
|
-
}), /* @__PURE__ */ l(
|
|
900
|
+
}), /* @__PURE__ */ l(G, {
|
|
877
901
|
variant: "primary",
|
|
878
902
|
size: "sm",
|
|
879
|
-
onClick:
|
|
903
|
+
onClick: A,
|
|
880
904
|
loading: T,
|
|
881
905
|
disabled: y.length !== 9,
|
|
882
906
|
children: "Add"
|
|
883
907
|
})]
|
|
884
908
|
}),
|
|
885
909
|
x && /* @__PURE__ */ l("div", {
|
|
886
|
-
className:
|
|
910
|
+
className: J.error,
|
|
887
911
|
children: x
|
|
888
912
|
}),
|
|
889
913
|
C && /* @__PURE__ */ l("div", {
|
|
890
|
-
className:
|
|
914
|
+
className: J.success,
|
|
891
915
|
children: C
|
|
892
916
|
})
|
|
893
917
|
]
|
|
894
918
|
}),
|
|
895
919
|
/* @__PURE__ */ l("div", {
|
|
896
|
-
className:
|
|
920
|
+
className: J.codesList,
|
|
897
921
|
children: a.map((e) => /* @__PURE__ */ u("div", {
|
|
898
|
-
className:
|
|
899
|
-
children: [/* @__PURE__ */ l("span", { children: e.player_name ? `${e.player_name} (${
|
|
922
|
+
className: J.codeItem,
|
|
923
|
+
children: [/* @__PURE__ */ l("span", { children: e.player_name ? `${e.player_name} (${q(e.ally_code)})` : q(e.ally_code) }), /* @__PURE__ */ l(G, {
|
|
900
924
|
variant: "ghost",
|
|
901
925
|
size: "sm",
|
|
902
|
-
onClick: () =>
|
|
926
|
+
onClick: () => te(e.ally_code),
|
|
903
927
|
children: "Remove"
|
|
904
928
|
})]
|
|
905
929
|
}, e.ally_code))
|
|
906
930
|
}),
|
|
907
|
-
/* @__PURE__ */ l(
|
|
931
|
+
/* @__PURE__ */ l(G, {
|
|
908
932
|
variant: "secondary",
|
|
909
933
|
size: "sm",
|
|
910
934
|
onClick: () => v(!1),
|
|
911
|
-
className:
|
|
935
|
+
className: J.doneButton,
|
|
912
936
|
children: "Done"
|
|
913
937
|
})
|
|
914
938
|
]
|
|
915
939
|
}),
|
|
916
940
|
/* @__PURE__ */ l("span", {
|
|
917
941
|
ref: D,
|
|
918
|
-
children: /* @__PURE__ */ l(
|
|
942
|
+
children: /* @__PURE__ */ l(G, {
|
|
919
943
|
variant: "ghost",
|
|
920
944
|
size: "sm",
|
|
921
945
|
onClick: () => v(!_),
|
|
922
|
-
className:
|
|
946
|
+
className: J.manageButton,
|
|
923
947
|
"aria-expanded": _,
|
|
924
948
|
"aria-controls": "ally-code-manage-panel",
|
|
925
949
|
"aria-haspopup": "true",
|
|
926
|
-
children:
|
|
950
|
+
children: j ? "Manage" : "+ Add ally code"
|
|
927
951
|
})
|
|
928
952
|
})
|
|
929
953
|
]
|
|
930
954
|
});
|
|
931
|
-
},
|
|
955
|
+
}, Me = {
|
|
932
956
|
authCluster: "_authCluster_17o10_1",
|
|
933
957
|
userLink: "_userLink_17o10_7",
|
|
934
958
|
adminLink: "_adminLink_17o10_16"
|
|
935
|
-
},
|
|
936
|
-
let { user: t, isAuthenticated: n, logout: r, authEnabled: i } =
|
|
959
|
+
}, Ne = ({ showAuth: e = !0 }) => {
|
|
960
|
+
let { user: t, isAuthenticated: n, logout: r, authEnabled: i } = V();
|
|
937
961
|
return e ? n ? /* @__PURE__ */ u("div", {
|
|
938
|
-
className:
|
|
962
|
+
className: Me.authCluster,
|
|
939
963
|
children: [
|
|
940
964
|
t?.role === "admin" && /* @__PURE__ */ l("a", {
|
|
941
965
|
href: "/admin/users",
|
|
942
|
-
className:
|
|
966
|
+
className: Me.adminLink,
|
|
943
967
|
children: "Admin"
|
|
944
968
|
}),
|
|
945
969
|
/* @__PURE__ */ l("a", {
|
|
946
970
|
href: "/profile",
|
|
947
|
-
className:
|
|
971
|
+
className: Me.userLink,
|
|
948
972
|
children: t?.username
|
|
949
973
|
}),
|
|
950
|
-
/* @__PURE__ */ l(
|
|
974
|
+
/* @__PURE__ */ l(G, {
|
|
951
975
|
variant: "ghost",
|
|
952
976
|
size: "sm",
|
|
953
977
|
onClick: () => {
|
|
@@ -957,24 +981,24 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
957
981
|
})
|
|
958
982
|
]
|
|
959
983
|
}) : i ? /* @__PURE__ */ u("div", {
|
|
960
|
-
className:
|
|
984
|
+
className: Me.authCluster,
|
|
961
985
|
children: [/* @__PURE__ */ l("a", {
|
|
962
986
|
href: "/login",
|
|
963
|
-
children: /* @__PURE__ */ l(
|
|
987
|
+
children: /* @__PURE__ */ l(G, {
|
|
964
988
|
variant: "ghost",
|
|
965
989
|
size: "sm",
|
|
966
990
|
children: "Login"
|
|
967
991
|
})
|
|
968
992
|
}), /* @__PURE__ */ l("a", {
|
|
969
993
|
href: "/register",
|
|
970
|
-
children: /* @__PURE__ */ l(
|
|
994
|
+
children: /* @__PURE__ */ l(G, {
|
|
971
995
|
variant: "primary",
|
|
972
996
|
size: "sm",
|
|
973
997
|
children: "Sign Up"
|
|
974
998
|
})
|
|
975
999
|
})]
|
|
976
1000
|
}) : null : null;
|
|
977
|
-
},
|
|
1001
|
+
}, Y = {
|
|
978
1002
|
backdrop: "_backdrop_3ax21_1",
|
|
979
1003
|
panel: "_panel_3ax21_11",
|
|
980
1004
|
accordion: "_accordion_3ax21_24",
|
|
@@ -994,8 +1018,8 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
994
1018
|
allySection: "_allySection_3ax21_112",
|
|
995
1019
|
extrasSection: "_extrasSection_3ax21_113",
|
|
996
1020
|
accountSection: "_accountSection_3ax21_114"
|
|
997
|
-
},
|
|
998
|
-
let { isAuthenticated: h, user: v } =
|
|
1021
|
+
}, Pe = "a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex=\"-1\"])", Fe = ({ isOpen: e, onClose: t, currentApp: n, activeSectionId: r, onSectionClick: i, rightExtras: c, showAuth: f, panelId: p, returnFocusRef: m }) => {
|
|
1022
|
+
let { isAuthenticated: h, user: v } = V(), [y, b] = s(n === "hub" ? null : n), x = o(null);
|
|
999
1023
|
if (a(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
|
|
1000
1024
|
document.body.style.overflow = "unset";
|
|
1001
1025
|
}), [e]), a(() => {
|
|
@@ -1006,7 +1030,7 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1006
1030
|
return;
|
|
1007
1031
|
}
|
|
1008
1032
|
if (e.key === "Tab") {
|
|
1009
|
-
let t = x.current?.querySelectorAll(
|
|
1033
|
+
let t = x.current?.querySelectorAll(Pe);
|
|
1010
1034
|
if (!t || t.length === 0) return;
|
|
1011
1035
|
let n = t[0], r = t[t.length - 1], i = document.activeElement, a = i === x.current || !x.current?.contains(i);
|
|
1012
1036
|
e.shiftKey && (i === n || a) ? (e.preventDefault(), r.focus()) : !e.shiftKey && (i === r || a) && (e.preventDefault(), n.focus());
|
|
@@ -1018,7 +1042,7 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1018
1042
|
e === n && i?.(r, a), t();
|
|
1019
1043
|
};
|
|
1020
1044
|
return d(/* @__PURE__ */ l("div", {
|
|
1021
|
-
className:
|
|
1045
|
+
className: Y.backdrop,
|
|
1022
1046
|
onClick: t,
|
|
1023
1047
|
children: /* @__PURE__ */ u("div", {
|
|
1024
1048
|
ref: x,
|
|
@@ -1027,32 +1051,32 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1027
1051
|
"aria-modal": "true",
|
|
1028
1052
|
"aria-label": "Navigation menu",
|
|
1029
1053
|
tabIndex: -1,
|
|
1030
|
-
className:
|
|
1054
|
+
className: Y.panel,
|
|
1031
1055
|
onClick: (e) => e.stopPropagation(),
|
|
1032
1056
|
children: [
|
|
1033
1057
|
/* @__PURE__ */ l("div", {
|
|
1034
|
-
className:
|
|
1058
|
+
className: Y.accordion,
|
|
1035
1059
|
children: _.map((e) => {
|
|
1036
1060
|
let t = y === e.id, i = n === e.id, a = (e) => !(e.requiresAuth && !h || e.roles && (!v || !e.roles.includes(v.role))), o = `mobile-accordion-${e.id}`, s = (t, n) => {
|
|
1037
1061
|
let a = i && r === t.id;
|
|
1038
1062
|
return /* @__PURE__ */ l("a", {
|
|
1039
1063
|
href: t.href,
|
|
1040
|
-
className: `${
|
|
1064
|
+
className: `${Y.sectionLink} ${n ?? ""} ${a ? Y.sectionActive : ""}`,
|
|
1041
1065
|
"aria-current": a ? "page" : void 0,
|
|
1042
1066
|
onClick: S(e.id, t),
|
|
1043
1067
|
children: t.label
|
|
1044
1068
|
}, t.id);
|
|
1045
1069
|
};
|
|
1046
1070
|
return /* @__PURE__ */ u("div", {
|
|
1047
|
-
className:
|
|
1071
|
+
className: Y.accordionItem,
|
|
1048
1072
|
children: [/* @__PURE__ */ u("button", {
|
|
1049
1073
|
type: "button",
|
|
1050
|
-
className: `${
|
|
1074
|
+
className: `${Y.accordionHeader} ${i ? Y.currentApp : ""}`,
|
|
1051
1075
|
"aria-expanded": t,
|
|
1052
1076
|
"aria-controls": o,
|
|
1053
1077
|
onClick: () => b(t ? null : e.id),
|
|
1054
1078
|
children: [e.label, /* @__PURE__ */ l("svg", {
|
|
1055
|
-
className: `${
|
|
1079
|
+
className: `${Y.chevron} ${t ? Y.chevronOpen : ""}`,
|
|
1056
1080
|
width: "10",
|
|
1057
1081
|
height: "6",
|
|
1058
1082
|
viewBox: "0 0 10 6",
|
|
@@ -1068,18 +1092,18 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1068
1092
|
})]
|
|
1069
1093
|
}), t && /* @__PURE__ */ l("div", {
|
|
1070
1094
|
id: o,
|
|
1071
|
-
className:
|
|
1095
|
+
className: Y.accordionPanel,
|
|
1072
1096
|
children: e.status === "coming-soon" ? /* @__PURE__ */ l("div", {
|
|
1073
|
-
className:
|
|
1097
|
+
className: Y.comingSoon,
|
|
1074
1098
|
children: "Coming soon"
|
|
1075
1099
|
}) : e.sections.map((e) => {
|
|
1076
1100
|
if (!g(e)) return a(e) ? s(e) : null;
|
|
1077
1101
|
let t = e.items.filter(a);
|
|
1078
1102
|
return /* @__PURE__ */ u("div", {
|
|
1079
|
-
className:
|
|
1080
|
-
children: [s(e,
|
|
1081
|
-
className:
|
|
1082
|
-
children: t.map((e) => s(e,
|
|
1103
|
+
className: Y.group,
|
|
1104
|
+
children: [s(e, Y.groupLabel), /* @__PURE__ */ l("div", {
|
|
1105
|
+
className: Y.groupItems,
|
|
1106
|
+
children: t.map((e) => s(e, Y.groupItem))
|
|
1083
1107
|
})]
|
|
1084
1108
|
}, e.id);
|
|
1085
1109
|
})
|
|
@@ -1088,26 +1112,26 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1088
1112
|
})
|
|
1089
1113
|
}),
|
|
1090
1114
|
/* @__PURE__ */ l("div", {
|
|
1091
|
-
className:
|
|
1092
|
-
children: /* @__PURE__ */ l(
|
|
1115
|
+
className: Y.allySection,
|
|
1116
|
+
children: /* @__PURE__ */ l(je, { variant: "inline" })
|
|
1093
1117
|
}),
|
|
1094
1118
|
c && /* @__PURE__ */ l("div", {
|
|
1095
|
-
className:
|
|
1119
|
+
className: Y.extrasSection,
|
|
1096
1120
|
children: c
|
|
1097
1121
|
}),
|
|
1098
1122
|
/* @__PURE__ */ l("div", {
|
|
1099
|
-
className:
|
|
1100
|
-
children: /* @__PURE__ */ l(
|
|
1123
|
+
className: Y.accountSection,
|
|
1124
|
+
children: /* @__PURE__ */ l(Ne, { showAuth: f })
|
|
1101
1125
|
})
|
|
1102
1126
|
]
|
|
1103
1127
|
})
|
|
1104
1128
|
}), document.body);
|
|
1105
|
-
},
|
|
1129
|
+
}, Ie = {
|
|
1106
1130
|
logoLink: "_logoLink_12f5f_3",
|
|
1107
1131
|
appMenus: "_appMenus_12f5f_10",
|
|
1108
1132
|
desktopRight: "_desktopRight_12f5f_19",
|
|
1109
1133
|
extrasGroup: "_extrasGroup_12f5f_25"
|
|
1110
|
-
},
|
|
1134
|
+
}, Le = ({ currentApp: e, activeSectionId: t, onNavigate: n, rightExtras: r, showAuth: i = !0, className: d }) => {
|
|
1111
1135
|
let [f, p] = s(null), [m, g] = s(!1), v = o(null), y = "suite-mobile-nav-panel";
|
|
1112
1136
|
return a(() => {
|
|
1113
1137
|
let e = window.matchMedia("(max-width: 768px)"), t = () => {
|
|
@@ -1118,12 +1142,12 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1118
1142
|
className: d,
|
|
1119
1143
|
logo: /* @__PURE__ */ l("a", {
|
|
1120
1144
|
href: "/",
|
|
1121
|
-
className:
|
|
1145
|
+
className: Ie.logoLink,
|
|
1122
1146
|
children: "The Astrogator's Table"
|
|
1123
1147
|
}),
|
|
1124
1148
|
leftContent: /* @__PURE__ */ l("nav", {
|
|
1125
|
-
className:
|
|
1126
|
-
children: _.map((r) => /* @__PURE__ */ l(
|
|
1149
|
+
className: Ie.appMenus,
|
|
1150
|
+
children: _.map((r) => /* @__PURE__ */ l(Te, {
|
|
1127
1151
|
app: r,
|
|
1128
1152
|
isCurrentApp: e === r.id,
|
|
1129
1153
|
activeSectionId: t,
|
|
@@ -1133,19 +1157,19 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1133
1157
|
}, r.id))
|
|
1134
1158
|
}),
|
|
1135
1159
|
rightContent: /* @__PURE__ */ u(c, { children: [/* @__PURE__ */ u("div", {
|
|
1136
|
-
className:
|
|
1160
|
+
className: Ie.desktopRight,
|
|
1137
1161
|
children: [
|
|
1138
1162
|
r && /* @__PURE__ */ l("div", {
|
|
1139
|
-
className:
|
|
1163
|
+
className: Ie.extrasGroup,
|
|
1140
1164
|
children: r
|
|
1141
1165
|
}),
|
|
1142
|
-
/* @__PURE__ */ l(
|
|
1166
|
+
/* @__PURE__ */ l(je, {
|
|
1143
1167
|
isOpen: f === "ally",
|
|
1144
1168
|
onOpenChange: (e) => p(e ? "ally" : null)
|
|
1145
1169
|
}),
|
|
1146
|
-
/* @__PURE__ */ l(
|
|
1170
|
+
/* @__PURE__ */ l(Ne, { showAuth: i })
|
|
1147
1171
|
]
|
|
1148
|
-
}), /* @__PURE__ */ l(
|
|
1172
|
+
}), /* @__PURE__ */ l(De, {
|
|
1149
1173
|
ref: v,
|
|
1150
1174
|
isOpen: m,
|
|
1151
1175
|
onClick: () => {
|
|
@@ -1153,7 +1177,7 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1153
1177
|
},
|
|
1154
1178
|
controlsId: y
|
|
1155
1179
|
})] })
|
|
1156
|
-
}), /* @__PURE__ */ l(
|
|
1180
|
+
}), /* @__PURE__ */ l(Fe, {
|
|
1157
1181
|
isOpen: m,
|
|
1158
1182
|
onClose: () => g(!1),
|
|
1159
1183
|
currentApp: e,
|
|
@@ -1170,7 +1194,7 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1170
1194
|
defaultContent: "_defaultContent_zjuj8_13",
|
|
1171
1195
|
copyright: "_copyright_zjuj8_21",
|
|
1172
1196
|
disclaimer: "_disclaimer_zjuj8_26"
|
|
1173
|
-
},
|
|
1197
|
+
}, Re = ({ children: e, className: t = "" }) => /* @__PURE__ */ l("footer", {
|
|
1174
1198
|
className: `${X.footer} ${t}`,
|
|
1175
1199
|
children: /* @__PURE__ */ l("div", {
|
|
1176
1200
|
className: X.content,
|
|
@@ -1192,11 +1216,11 @@ var K = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e
|
|
|
1192
1216
|
});
|
|
1193
1217
|
//#endregion
|
|
1194
1218
|
//#region src/utils/formatTime.ts
|
|
1195
|
-
function
|
|
1219
|
+
function ze(e) {
|
|
1196
1220
|
let t = /([zZ]|[+-]\d{2}:?\d{2})$/.test(e);
|
|
1197
1221
|
return new Date(t ? e : `${e}Z`);
|
|
1198
1222
|
}
|
|
1199
|
-
function
|
|
1223
|
+
function Be(e, t) {
|
|
1200
1224
|
let n = Math.max(0, Math.floor((t - e.getTime()) / 1e3));
|
|
1201
1225
|
if (n < 60) return `${n}s ago`;
|
|
1202
1226
|
let r = Math.floor(n / 60);
|
|
@@ -1204,38 +1228,38 @@ function Re(e, t) {
|
|
|
1204
1228
|
let i = Math.floor(r / 60);
|
|
1205
1229
|
return i < 24 ? `${i}h ago` : `${Math.floor(i / 24)}d ago`;
|
|
1206
1230
|
}
|
|
1207
|
-
function
|
|
1231
|
+
function Ve(e) {
|
|
1208
1232
|
return `${Math.floor(e / 60)}:${(e % 60).toString().padStart(2, "0")}`;
|
|
1209
1233
|
}
|
|
1210
|
-
var
|
|
1234
|
+
var He = {
|
|
1211
1235
|
rosterRefresh: "_rosterRefresh_1rbul_3",
|
|
1212
1236
|
updatedLabel: "_updatedLabel_1rbul_11",
|
|
1213
1237
|
refreshButton: "_refreshButton_1rbul_19",
|
|
1214
1238
|
spin: "_spin_1rbul_31"
|
|
1215
|
-
},
|
|
1239
|
+
}, Ue = ({ onRefresh: e, isRefreshing: t, cachedAt: n = null, refreshAvailableAt: r = null, labelPrefix: i = "Updated", className: o = "" }) => {
|
|
1216
1240
|
let [c, d] = s(() => Date.now()), f = !!n || r != null && r > c;
|
|
1217
1241
|
a(() => {
|
|
1218
1242
|
if (!f) return;
|
|
1219
1243
|
let e = setInterval(() => d(Date.now()), 1e3);
|
|
1220
1244
|
return () => clearInterval(e);
|
|
1221
1245
|
}, [f]);
|
|
1222
|
-
let p = r ? Math.max(0, Math.ceil((r - c) / 1e3)) : 0, m = n ?
|
|
1246
|
+
let p = r ? Math.max(0, Math.ceil((r - c) / 1e3)) : 0, m = n ? Be(ze(n), c) : null, h = t || p > 0, g = p > 0 ? `Fresh data available in ${Ve(p)}` : "Refresh roster";
|
|
1223
1247
|
return /* @__PURE__ */ u("div", {
|
|
1224
|
-
className: `${
|
|
1248
|
+
className: `${He.rosterRefresh} ${o}`,
|
|
1225
1249
|
children: [m && /* @__PURE__ */ l("span", {
|
|
1226
|
-
className:
|
|
1250
|
+
className: He.updatedLabel,
|
|
1227
1251
|
title: g,
|
|
1228
|
-
children: p > 0 ? `${i} ${m} · fresh in ${
|
|
1229
|
-
}), /* @__PURE__ */ l(
|
|
1252
|
+
children: p > 0 ? `${i} ${m} · fresh in ${Ve(p)}` : `${i} ${m}`
|
|
1253
|
+
}), /* @__PURE__ */ l(G, {
|
|
1230
1254
|
variant: "outline",
|
|
1231
1255
|
size: "sm",
|
|
1232
1256
|
onClick: e,
|
|
1233
1257
|
disabled: h,
|
|
1234
1258
|
title: g,
|
|
1235
1259
|
"aria-label": "Refresh roster",
|
|
1236
|
-
className:
|
|
1260
|
+
className: He.refreshButton,
|
|
1237
1261
|
children: /* @__PURE__ */ l("span", {
|
|
1238
|
-
className: t ?
|
|
1262
|
+
className: t ? He.spin : void 0,
|
|
1239
1263
|
children: "⟳"
|
|
1240
1264
|
})
|
|
1241
1265
|
})]
|
|
@@ -1251,7 +1275,7 @@ var Be = {
|
|
|
1251
1275
|
"padding-md": "_padding-md_1vw8g_43",
|
|
1252
1276
|
"padding-lg": "_padding-lg_1vw8g_47",
|
|
1253
1277
|
hoverable: "_hoverable_1vw8g_52"
|
|
1254
|
-
},
|
|
1278
|
+
}, We = ({ children: e, variant: t = "default", chamfered: n = !1, chamferSize: r = "md", padding: i = "md", hoverable: a = !1, showDiagonalBorders: o = !0, edgeColor: s, className: d = "", onClick: f, style: p }) => {
|
|
1255
1279
|
let m = n ? r === "asymmetric" ? "chamfered-box-asymmetric" : r === "sm" ? "chamfered-box-sm" : r === "lg" ? "chamfered-box-lg" : "chamfered-box" : "", h = s ?? (n ? "var(--color-border)" : void 0), g = h ? { color: h } : void 0, _ = h ? {
|
|
1256
1280
|
...p,
|
|
1257
1281
|
"--card-edge-color": h
|
|
@@ -1281,7 +1305,7 @@ var Be = {
|
|
|
1281
1305
|
})
|
|
1282
1306
|
] }), e]
|
|
1283
1307
|
});
|
|
1284
|
-
},
|
|
1308
|
+
}, Ge = {
|
|
1285
1309
|
badge: "_badge_rk7t5_1",
|
|
1286
1310
|
sm: "_sm_rk7t5_11",
|
|
1287
1311
|
md: "_md_rk7t5_16",
|
|
@@ -1293,8 +1317,8 @@ var Be = {
|
|
|
1293
1317
|
warning: "_warning_rk7t5_47",
|
|
1294
1318
|
error: "_error_rk7t5_52",
|
|
1295
1319
|
info: "_info_rk7t5_57"
|
|
1296
|
-
},
|
|
1297
|
-
className: `${
|
|
1320
|
+
}, Ke = ({ children: e, variant: t = "default", size: n = "md", className: r = "" }) => /* @__PURE__ */ l("span", {
|
|
1321
|
+
className: `${Ge.badge} ${Ge[t]} ${Ge[n]} ${r}`,
|
|
1298
1322
|
children: e
|
|
1299
1323
|
}), Q = {
|
|
1300
1324
|
overlay: "_overlay_1b3yt_1",
|
|
@@ -1309,7 +1333,7 @@ var Be = {
|
|
|
1309
1333
|
title: "_title_1b3yt_53",
|
|
1310
1334
|
closeButton: "_closeButton_1b3yt_60",
|
|
1311
1335
|
content: "_content_1b3yt_78"
|
|
1312
|
-
},
|
|
1336
|
+
}, qe = ({ isOpen: e, onClose: t, title: n, children: r, size: i = "md", closeOnOverlayClick: o = !0, className: s = "" }) => (a(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
|
|
1313
1337
|
document.body.style.overflow = "unset";
|
|
1314
1338
|
}), [e]), a(() => {
|
|
1315
1339
|
let n = (n) => {
|
|
@@ -1351,7 +1375,7 @@ var Be = {
|
|
|
1351
1375
|
dot: "_dot_1uhnh_34",
|
|
1352
1376
|
bounce: "_bounce_1uhnh_1",
|
|
1353
1377
|
visuallyHidden: "_visuallyHidden_1uhnh_91"
|
|
1354
|
-
},
|
|
1378
|
+
}, Je = ({ size: e = "md", variant: t = "spinner", className: n = "" }) => t === "dots" ? /* @__PURE__ */ u("div", {
|
|
1355
1379
|
className: `${$.dots} ${$[e]} ${n}`,
|
|
1356
1380
|
children: [
|
|
1357
1381
|
/* @__PURE__ */ l("span", { className: $.dot }),
|
|
@@ -1365,10 +1389,10 @@ var Be = {
|
|
|
1365
1389
|
className: $.visuallyHidden,
|
|
1366
1390
|
children: "Loading..."
|
|
1367
1391
|
})
|
|
1368
|
-
}),
|
|
1392
|
+
}), Ye = async (e) => {
|
|
1369
1393
|
if (e.length === 0) return {};
|
|
1370
|
-
let t = [...new Set(e)], n = await
|
|
1394
|
+
let t = [...new Set(e)], n = await L.get(`/api/v1/users/lookup?ids=${t.join(",")}`);
|
|
1371
1395
|
return Object.fromEntries(n.users.map((e) => [e.id, e.username]));
|
|
1372
1396
|
};
|
|
1373
1397
|
//#endregion
|
|
1374
|
-
export {
|
|
1398
|
+
export { je as AllyCodeDropdown, ce as ApiClient, Ce as AuthProvider, Ke as Badge, G as Button, We as Card, p as Container, Re as Footer, ke as Input, Je as Loader, qe as Modal, Le as NavBar, Ue as RosterRefresh, _ as SUITE_NAV, Oe as Select, h as TopBar, L as apiClient, se as authedFetch, ve as clearAllyCodes, k as clearTokens, ne as configureAuthRefresh, Ye as fetchUsernames, q as formatAllyCode, Ve as formatCountdown, Be as formatRelativeTime, S as getAccessToken, z as getAllyCodesFromStorage, T as getRefreshToken, _e as getSelectedAllyCode, le as initializeApiClient, ee as isAuthenticated, g as isSuiteNavGroup, ze as parseBackendTimestamp, M as refreshAccessToken, w as removeAccessToken, he as removeAllyCodeFromStorage, D as removeRefreshToken, me as saveAllyCodeToStorage, C as setAccessToken, E as setRefreshToken, B as setSelectedAllyCode, O as setTokens, Ae as unformatAllyCode, ge as updateAllyCodeLastUsed, V as useAuth };
|