astrogators-shared-ui 0.4.3 → 0.4.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/dist/index.js ADDED
@@ -0,0 +1,791 @@
1
+ var ue = Object.defineProperty;
2
+ var he = (e, s, t) => s in e ? ue(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
3
+ var R = (e, s, t) => he(e, typeof s != "symbol" ? s + "" : s, t);
4
+ import { jsx as r, jsxs as m, Fragment as ge } from "react/jsx-runtime";
5
+ import ae, { createContext as fe, useState as b, useEffect as j, useCallback as S, useContext as pe } from "react";
6
+ const ye = "_container_u3o0e_1", ve = "_padding_u3o0e_7", X = {
7
+ container: ye,
8
+ padding: ve,
9
+ "maxWidth-sm": "_maxWidth-sm_u3o0e_12",
10
+ "maxWidth-md": "_maxWidth-md_u3o0e_16",
11
+ "maxWidth-lg": "_maxWidth-lg_u3o0e_20",
12
+ "maxWidth-xl": "_maxWidth-xl_u3o0e_24",
13
+ "maxWidth-full": "_maxWidth-full_u3o0e_28"
14
+ }, vs = ({
15
+ children: e,
16
+ maxWidth: s = "xl",
17
+ padding: t = !0,
18
+ className: o = "",
19
+ style: d
20
+ }) => /* @__PURE__ */ r(
21
+ "div",
22
+ {
23
+ className: `${X.container} ${X[`maxWidth-${s}`]} ${t ? X.padding : ""} ${o}`,
24
+ style: d,
25
+ children: e
26
+ }
27
+ ), $e = "_topBar_10g3c_1", be = "_content_10g3c_13", we = "_left_10g3c_23", Ne = "_right_10g3c_30", Ae = "_logo_10g3c_36", P = {
28
+ topBar: $e,
29
+ content: be,
30
+ left: we,
31
+ right: Ne,
32
+ logo: Ae
33
+ }, $s = ({
34
+ logo: e,
35
+ leftContent: s,
36
+ rightContent: t,
37
+ className: o = ""
38
+ }) => /* @__PURE__ */ r("header", { className: `${P.topBar} ${o}`, children: /* @__PURE__ */ m("div", { className: P.content, children: [
39
+ /* @__PURE__ */ m("div", { className: P.left, children: [
40
+ e && /* @__PURE__ */ r("div", { className: P.logo, children: e }),
41
+ s
42
+ ] }),
43
+ /* @__PURE__ */ r("div", { className: P.right, children: t })
44
+ ] }) }), Se = "_footer_zjuj8_1", xe = "_content_zjuj8_7", Te = "_defaultContent_zjuj8_13", Ce = "_copyright_zjuj8_21", ke = "_disclaimer_zjuj8_26", B = {
45
+ footer: Se,
46
+ content: xe,
47
+ defaultContent: Te,
48
+ copyright: Ce,
49
+ disclaimer: ke
50
+ }, bs = ({ children: e, className: s = "" }) => /* @__PURE__ */ r("footer", { className: `${B.footer} ${s}`, children: /* @__PURE__ */ r("div", { className: B.content, children: e || /* @__PURE__ */ m("div", { className: B.defaultContent, children: [
51
+ /* @__PURE__ */ m("p", { className: B.copyright, children: [
52
+ "© ",
53
+ (/* @__PURE__ */ new Date()).getFullYear(),
54
+ " The Astrogator's Table. All rights reserved."
55
+ ] }),
56
+ /* @__PURE__ */ r("p", { className: B.disclaimer, children: "Star Wars: Galaxy of Heroes is a trademark of Electronic Arts Inc." })
57
+ ] }) }) }), Ee = "_button_159ms_1", We = "_sm_159ms_22", Ie = "_md_159ms_28", Le = "_lg_159ms_34", qe = "_primary_159ms_41", Re = "_secondary_159ms_55", Pe = "_outline_159ms_69", Be = "_ghost_159ms_80", Ue = "_danger_159ms_89", je = "_fullWidth_159ms_100", Fe = "_loading_159ms_105", De = "_loadingSpinner_159ms_110", Oe = "_spinner_159ms_116", ze = "_spin_159ms_116", Me = "_loadingText_159ms_131", x = {
58
+ button: Ee,
59
+ sm: We,
60
+ md: Ie,
61
+ lg: Le,
62
+ primary: qe,
63
+ secondary: Re,
64
+ outline: Pe,
65
+ ghost: Be,
66
+ danger: Ue,
67
+ fullWidth: je,
68
+ loading: Fe,
69
+ loadingSpinner: De,
70
+ spinner: Oe,
71
+ spin: ze,
72
+ loadingText: Me
73
+ }, M = ({
74
+ children: e,
75
+ variant: s = "primary",
76
+ size: t = "md",
77
+ fullWidth: o = !1,
78
+ loading: d = !1,
79
+ disabled: g = !1,
80
+ className: c = "",
81
+ ...l
82
+ }) => /* @__PURE__ */ r(
83
+ "button",
84
+ {
85
+ className: `${x.button} ${x[s]} ${x[t]} ${o ? x.fullWidth : ""} ${d ? x.loading : ""} ${c}`,
86
+ disabled: g || d,
87
+ ...l,
88
+ children: d ? /* @__PURE__ */ m("span", { className: x.loadingSpinner, children: [
89
+ /* @__PURE__ */ r("span", { className: x.spinner }),
90
+ /* @__PURE__ */ r("span", { className: x.loadingText, children: e })
91
+ ] }) : e
92
+ }
93
+ ), Je = "_inputWrapper_15t4g_1", He = "_fullWidth_15t4g_7", Ye = "_label_15t4g_11", Ge = "_required_15t4g_20", Ke = "_input_15t4g_1", Ve = "_error_15t4g_55", Qe = "_errorText_15t4g_63", Xe = "_helperText_15t4g_68", T = {
94
+ inputWrapper: Je,
95
+ fullWidth: He,
96
+ label: Ye,
97
+ required: Ge,
98
+ input: Ke,
99
+ error: Ve,
100
+ errorText: Qe,
101
+ helperText: Xe
102
+ }, ne = ae.forwardRef(
103
+ ({
104
+ label: e,
105
+ error: s,
106
+ helperText: t,
107
+ fullWidth: o = !1,
108
+ className: d = "",
109
+ id: g,
110
+ ...c
111
+ }, l) => {
112
+ const i = g || `input-${Math.random().toString(36).substr(2, 9)}`, h = !!s;
113
+ return /* @__PURE__ */ m("div", { className: `${T.inputWrapper} ${o ? T.fullWidth : ""} ${d}`, children: [
114
+ e && /* @__PURE__ */ m("label", { htmlFor: i, className: T.label, children: [
115
+ e,
116
+ c.required && /* @__PURE__ */ r("span", { className: T.required, children: "*" })
117
+ ] }),
118
+ /* @__PURE__ */ r(
119
+ "input",
120
+ {
121
+ ref: l,
122
+ id: i,
123
+ className: `${T.input} ${h ? T.error : ""}`,
124
+ ...c
125
+ }
126
+ ),
127
+ s && /* @__PURE__ */ r("span", { className: T.errorText, children: s }),
128
+ t && !s && /* @__PURE__ */ r("span", { className: T.helperText, children: t })
129
+ ] });
130
+ }
131
+ );
132
+ ne.displayName = "Input";
133
+ const Ze = "_selectWrapper_ir4bq_1", et = "_fullWidth_ir4bq_7", tt = "_label_ir4bq_11", st = "_required_ir4bq_20", ot = "_selectContainer_ir4bq_24", rt = "_select_ir4bq_1", at = "_error_ir4bq_63", nt = "_arrow_ir4bq_71", lt = "_errorText_ir4bq_81", ct = "_helperText_ir4bq_86", w = {
134
+ selectWrapper: Ze,
135
+ fullWidth: et,
136
+ label: tt,
137
+ required: st,
138
+ selectContainer: ot,
139
+ select: rt,
140
+ error: at,
141
+ arrow: nt,
142
+ errorText: lt,
143
+ helperText: ct
144
+ }, le = ae.forwardRef(
145
+ ({
146
+ label: e,
147
+ error: s,
148
+ helperText: t,
149
+ options: o,
150
+ placeholder: d,
151
+ fullWidth: g = !1,
152
+ className: c = "",
153
+ id: l,
154
+ ...i
155
+ }, h) => {
156
+ const p = l || `select-${Math.random().toString(36).substr(2, 9)}`, N = !!s;
157
+ return /* @__PURE__ */ m("div", { className: `${w.selectWrapper} ${g ? w.fullWidth : ""} ${c}`, children: [
158
+ e && /* @__PURE__ */ m("label", { htmlFor: p, className: w.label, children: [
159
+ e,
160
+ i.required && /* @__PURE__ */ r("span", { className: w.required, children: "*" })
161
+ ] }),
162
+ /* @__PURE__ */ m("div", { className: w.selectContainer, children: [
163
+ /* @__PURE__ */ m(
164
+ "select",
165
+ {
166
+ ref: h,
167
+ id: p,
168
+ className: `${w.select} ${N ? w.error : ""}`,
169
+ ...i,
170
+ children: [
171
+ d && /* @__PURE__ */ r("option", { value: "", disabled: !0, children: d }),
172
+ o && o.map((f) => /* @__PURE__ */ r(
173
+ "option",
174
+ {
175
+ value: f.value,
176
+ disabled: f.disabled,
177
+ children: f.label
178
+ },
179
+ f.value
180
+ )),
181
+ !o && i.children
182
+ ]
183
+ }
184
+ ),
185
+ /* @__PURE__ */ r("span", { className: w.arrow, children: "▼" })
186
+ ] }),
187
+ s && /* @__PURE__ */ r("span", { className: w.errorText, children: s }),
188
+ t && !s && /* @__PURE__ */ r("span", { className: w.helperText, children: t })
189
+ ] });
190
+ }
191
+ );
192
+ le.displayName = "Select";
193
+ const te = "astrogators_access_token", se = "astrogators_refresh_token", ce = () => localStorage.getItem(te), it = (e) => {
194
+ localStorage.setItem(te, e);
195
+ }, dt = () => {
196
+ localStorage.removeItem(te);
197
+ }, _t = () => localStorage.getItem(se), mt = (e) => {
198
+ localStorage.setItem(se, e);
199
+ }, ut = () => {
200
+ localStorage.removeItem(se);
201
+ }, ie = (e, s) => {
202
+ it(e), mt(s);
203
+ }, ee = () => {
204
+ dt(), ut();
205
+ }, ht = () => !!ce();
206
+ class gt {
207
+ constructor(s) {
208
+ R(this, "baseURL");
209
+ R(this, "onUnauthorized");
210
+ R(this, "isRefreshing", !1);
211
+ R(this, "refreshPromise", null);
212
+ this.baseURL = s.baseURL, this.onUnauthorized = s.onUnauthorized;
213
+ }
214
+ async refreshAccessToken() {
215
+ var d;
216
+ const s = _t();
217
+ if (!s)
218
+ throw new Error("No refresh token available");
219
+ const t = await fetch(`${this.baseURL}/api/v1/auth/refresh-token`, {
220
+ method: "POST",
221
+ headers: {
222
+ "Content-Type": "application/json"
223
+ },
224
+ body: JSON.stringify({ refresh_token: s })
225
+ });
226
+ if (!t.ok)
227
+ throw ee(), (d = this.onUnauthorized) == null || d.call(this), new Error("Token refresh failed");
228
+ const o = await t.json();
229
+ return ie(o.access_token, s), o.access_token;
230
+ }
231
+ async request(s, t = {}) {
232
+ const o = ce(), d = {
233
+ "Content-Type": "application/json",
234
+ ...t.headers
235
+ };
236
+ o && (d.Authorization = `Bearer ${o}`);
237
+ const g = `${this.baseURL}${s}`;
238
+ let c = await fetch(g, {
239
+ ...t,
240
+ headers: d
241
+ });
242
+ if (c.status === 401 && o) {
243
+ this.isRefreshing || (this.isRefreshing = !0, this.refreshPromise = this.refreshAccessToken().finally(() => {
244
+ this.isRefreshing = !1, this.refreshPromise = null;
245
+ }));
246
+ try {
247
+ const l = await this.refreshPromise;
248
+ d.Authorization = `Bearer ${l}`, c = await fetch(g, {
249
+ ...t,
250
+ headers: d
251
+ });
252
+ } catch {
253
+ throw new Error("Authentication failed");
254
+ }
255
+ }
256
+ if (!c.ok) {
257
+ const l = {
258
+ message: c.statusText,
259
+ status: c.status
260
+ };
261
+ try {
262
+ const i = await c.json();
263
+ if (c.status === 422 && Array.isArray(i.detail)) {
264
+ const h = i.detail.map((p) => p.msg || "Validation error").join(", ");
265
+ l.message = h;
266
+ } else typeof i.detail == "string" ? l.message = i.detail : i.message && (l.message = i.message);
267
+ l.detail = i.detail;
268
+ } catch {
269
+ }
270
+ throw l;
271
+ }
272
+ return c.status === 204 ? {} : c.json();
273
+ }
274
+ async get(s, t) {
275
+ return this.request(s, { ...t, method: "GET" });
276
+ }
277
+ async post(s, t, o) {
278
+ return this.request(s, {
279
+ ...o,
280
+ method: "POST",
281
+ body: t ? JSON.stringify(t) : void 0
282
+ });
283
+ }
284
+ async put(s, t, o) {
285
+ return this.request(s, {
286
+ ...o,
287
+ method: "PUT",
288
+ body: t ? JSON.stringify(t) : void 0
289
+ });
290
+ }
291
+ async patch(s, t, o) {
292
+ return this.request(s, {
293
+ ...o,
294
+ method: "PATCH",
295
+ body: t ? JSON.stringify(t) : void 0
296
+ });
297
+ }
298
+ async delete(s, t) {
299
+ return this.request(s, { ...t, method: "DELETE" });
300
+ }
301
+ }
302
+ let y;
303
+ const ft = (e) => {
304
+ y = new gt(e);
305
+ }, F = "astrogators_ally_codes", H = "astrogators_selected_ally_code", A = () => {
306
+ try {
307
+ const e = localStorage.getItem(F);
308
+ return e ? JSON.parse(e) : [];
309
+ } catch (e) {
310
+ return console.error("Failed to read ally codes from localStorage:", e), [];
311
+ }
312
+ }, pt = (e) => {
313
+ try {
314
+ const s = A();
315
+ if (s.some((o) => o.ally_code === e.ally_code))
316
+ return;
317
+ s.push(e), localStorage.setItem(F, JSON.stringify(s));
318
+ } catch (s) {
319
+ console.error("Failed to save ally code to localStorage:", s);
320
+ }
321
+ }, yt = (e) => {
322
+ try {
323
+ const t = A().filter((o) => o.ally_code !== e);
324
+ localStorage.setItem(F, JSON.stringify(t));
325
+ } catch (s) {
326
+ console.error("Failed to remove ally code from localStorage:", s);
327
+ }
328
+ }, re = (e) => {
329
+ try {
330
+ const t = A().map(
331
+ (o) => o.ally_code === e ? { ...o, last_used_at: (/* @__PURE__ */ new Date()).toISOString() } : o
332
+ );
333
+ localStorage.setItem(F, JSON.stringify(t));
334
+ } catch (s) {
335
+ console.error("Failed to update ally code last used:", s);
336
+ }
337
+ }, vt = () => localStorage.getItem(H), $t = (e) => {
338
+ e ? localStorage.setItem(H, e) : localStorage.removeItem(H);
339
+ }, bt = () => {
340
+ localStorage.removeItem(F), localStorage.removeItem(H);
341
+ }, de = fe(void 0), ws = ({ children: e, apiBaseUrl: s }) => {
342
+ const [t, o] = b(null), [d, g] = b(!0), [c, l] = b([]), [i, h] = b(null), [p, N] = b(!1), [f, k] = b({
343
+ show: !1,
344
+ localStorageCodes: []
345
+ });
346
+ j(() => {
347
+ ft({
348
+ baseURL: s
349
+ });
350
+ }, [s]);
351
+ const W = S(async () => {
352
+ if (!ht()) {
353
+ o(null), g(!1);
354
+ return;
355
+ }
356
+ try {
357
+ const a = await y.get("/api/v1/users/me");
358
+ o(a);
359
+ } catch (a) {
360
+ console.error("Failed to fetch user:", a), o(null), ee();
361
+ } finally {
362
+ g(!1);
363
+ }
364
+ }, []);
365
+ j(() => {
366
+ W();
367
+ }, [W]);
368
+ const I = async (a) => {
369
+ try {
370
+ const n = await y.post("/api/v1/auth/login", a);
371
+ ie(n.access_token, n.refresh_token);
372
+ const u = await y.get("/api/v1/users/me");
373
+ o(u);
374
+ } catch (n) {
375
+ throw console.error("Login failed:", n), n;
376
+ }
377
+ }, D = async (a) => {
378
+ try {
379
+ await y.post("/api/v1/auth/register", a);
380
+ } catch (n) {
381
+ throw console.error("Registration failed:", n), n;
382
+ }
383
+ }, O = () => {
384
+ ee(), o(null), l([]), h(null), k({ show: !1, localStorageCodes: [] });
385
+ }, Y = async () => {
386
+ await W();
387
+ }, G = async (a) => {
388
+ try {
389
+ return (await y.post(
390
+ "/api/v1/auth/forgot-password",
391
+ a
392
+ )).message;
393
+ } catch (n) {
394
+ throw console.error("Forgot password failed:", n), n;
395
+ }
396
+ }, K = async (a) => {
397
+ try {
398
+ return (await y.post(
399
+ "/api/v1/auth/reset-password",
400
+ a
401
+ )).message;
402
+ } catch (n) {
403
+ throw console.error("Reset password failed:", n), n;
404
+ }
405
+ }, V = async (a) => {
406
+ try {
407
+ return (await y.post(
408
+ "/api/v1/auth/resend-verification",
409
+ a
410
+ )).message;
411
+ } catch (n) {
412
+ throw console.error("Resend verification failed:", n), n;
413
+ }
414
+ }, _ = S(async () => {
415
+ N(!0);
416
+ try {
417
+ if (t) {
418
+ const n = await y.get("/api/v1/users/me/ally-codes");
419
+ l(n.ally_codes);
420
+ const u = A();
421
+ u.length > 0 && k({
422
+ show: !0,
423
+ localStorageCodes: u.map((q) => q.ally_code)
424
+ });
425
+ } else {
426
+ const n = A();
427
+ l(n);
428
+ }
429
+ const a = vt();
430
+ h(a);
431
+ } catch (a) {
432
+ console.error("Failed to fetch ally codes:", a), l([]);
433
+ } finally {
434
+ N(!1);
435
+ }
436
+ }, [t]), v = S(async (a) => {
437
+ var n;
438
+ if (!/^\d{9}$/.test(a))
439
+ throw new Error("Ally code must be exactly 9 digits");
440
+ if (t) {
441
+ const u = await y.post(
442
+ "/api/v1/users/me/ally-codes",
443
+ { ally_code: a }
444
+ );
445
+ l((q) => [u, ...q]), c.length === 0 && z(a);
446
+ } else {
447
+ const u = await y.get(`/api/v1/player-data/player/${a}`);
448
+ if (!u)
449
+ throw new Error("Invalid ally code - player not found");
450
+ const q = {
451
+ ally_code: a,
452
+ player_name: ((n = u == null ? void 0 : u.data) == null ? void 0 : n.name) || null,
453
+ last_used_at: (/* @__PURE__ */ new Date()).toISOString()
454
+ };
455
+ pt(q), l(A()), c.length === 0 && z(a);
456
+ }
457
+ }, [t, c.length]), L = S(async (a) => {
458
+ t && typeof a == "number" ? (await y.delete(`/api/v1/users/me/ally-codes/${a}`), l((n) => n.filter((u) => "id" in u && u.id !== a))) : !t && typeof a == "string" && (yt(a), l(A()), i === a && z(null));
459
+ }, [t, i]), z = S((a) => {
460
+ if (h(a), $t(a), a && t) {
461
+ const n = c.find((u) => "ally_code" in u && u.ally_code === a);
462
+ n && "id" in n && oe(n.id);
463
+ } else a && !t && re(a);
464
+ }, [t, c]), oe = S(async (a) => {
465
+ t && typeof a == "number" ? (await y.put(`/api/v1/users/me/ally-codes/${a}/use`, {}), await _()) : !t && typeof a == "string" && (re(a), l(A()));
466
+ }, [t, _]), Q = S(() => {
467
+ k({ show: !1, localStorageCodes: [] });
468
+ }, []), _e = S(async () => {
469
+ if (!t) return;
470
+ const a = A();
471
+ for (const n of a)
472
+ try {
473
+ await v(n.ally_code);
474
+ } catch (u) {
475
+ console.error(`Failed to migrate ally code ${n.ally_code}:`, u);
476
+ }
477
+ bt(), Q();
478
+ }, [t, v, Q]);
479
+ j(() => {
480
+ _();
481
+ }, [_]);
482
+ const me = {
483
+ user: t,
484
+ isAuthenticated: !!t,
485
+ isLoading: d,
486
+ login: I,
487
+ register: D,
488
+ logout: O,
489
+ refreshUser: Y,
490
+ forgotPassword: G,
491
+ resetPassword: K,
492
+ resendVerification: V,
493
+ // Ally code values
494
+ allyCodes: c,
495
+ selectedAllyCode: i,
496
+ isLoadingAllyCodes: p,
497
+ fetchAllyCodes: _,
498
+ addAllyCode: v,
499
+ removeAllyCode: L,
500
+ selectAllyCode: z,
501
+ updateAllyCodeLastUsed: oe,
502
+ migrationPrompt: f,
503
+ dismissMigrationPrompt: Q,
504
+ migrateLocalStorageCodes: _e
505
+ };
506
+ return /* @__PURE__ */ r(de.Provider, { value: me, children: e });
507
+ }, wt = () => {
508
+ const e = pe(de);
509
+ if (e === void 0)
510
+ throw new Error("useAuth must be used within an AuthProvider");
511
+ return e;
512
+ }, J = (e) => !e || e.length !== 9 ? e : `${e.slice(0, 3)}-${e.slice(3, 6)}-${e.slice(6, 9)}`, Ns = (e) => e.replace(/-/g, ""), Nt = "_allyCodeDropdown_1m0tw_1", At = "_select_1m0tw_8", St = "_manageButton_1m0tw_12", xt = "_managePanel_1m0tw_16", Tt = "_addSection_1m0tw_37", Ct = "_addInputGroup_1m0tw_43", kt = "_error_1m0tw_55", Et = "_success_1m0tw_61", Wt = "_codesList_1m0tw_67", It = "_codeItem_1m0tw_71", Lt = "_doneButton_1m0tw_88", $ = {
513
+ allyCodeDropdown: Nt,
514
+ select: At,
515
+ manageButton: St,
516
+ managePanel: xt,
517
+ addSection: Tt,
518
+ addInputGroup: Ct,
519
+ error: kt,
520
+ success: Et,
521
+ codesList: Wt,
522
+ codeItem: It,
523
+ doneButton: Lt
524
+ }, As = ({
525
+ onAllyCodeSelected: e,
526
+ className: s = ""
527
+ }) => {
528
+ const {
529
+ allyCodes: t,
530
+ selectedAllyCode: o,
531
+ selectAllyCode: d,
532
+ removeAllyCode: g,
533
+ addAllyCode: c,
534
+ isLoadingAllyCodes: l
535
+ } = wt(), [i, h] = b(!1), [p, N] = b(""), [f, k] = b(""), [W, I] = b(""), [D, O] = b(!1), Y = t.map((_) => ({
536
+ value: _.ally_code,
537
+ label: _.player_name ? `${_.player_name} (${J(_.ally_code)})` : J(_.ally_code)
538
+ })), G = (_) => {
539
+ const v = _.target.value || null;
540
+ d(v), e == null || e(v);
541
+ }, K = async (_) => {
542
+ const v = t.find((L) => L.ally_code === _);
543
+ if (v) {
544
+ const L = "id" in v ? v.id : v.ally_code;
545
+ await g(L);
546
+ }
547
+ }, V = async () => {
548
+ if (k(""), I(""), !/^\d{9}$/.test(p)) {
549
+ k("Ally code must be exactly 9 digits");
550
+ return;
551
+ }
552
+ O(!0);
553
+ try {
554
+ await c(p), I("Added successfully!"), N(""), setTimeout(() => I(""), 2e3);
555
+ } catch (_) {
556
+ k(_.message || "Failed to add ally code");
557
+ } finally {
558
+ O(!1);
559
+ }
560
+ };
561
+ return t.length === 0 ? null : /* @__PURE__ */ m("div", { className: `${$.allyCodeDropdown} ${s}`, children: [
562
+ /* @__PURE__ */ r(
563
+ le,
564
+ {
565
+ options: Y,
566
+ value: o || "",
567
+ onChange: G,
568
+ placeholder: "Select ally code",
569
+ disabled: l,
570
+ className: $.select
571
+ }
572
+ ),
573
+ i && /* @__PURE__ */ m("div", { className: $.managePanel, children: [
574
+ /* @__PURE__ */ r("h4", { children: "Manage Ally Codes" }),
575
+ /* @__PURE__ */ m("div", { className: $.addSection, children: [
576
+ /* @__PURE__ */ m("div", { className: $.addInputGroup, children: [
577
+ /* @__PURE__ */ r(
578
+ ne,
579
+ {
580
+ type: "text",
581
+ placeholder: "9-digit ally code",
582
+ value: p,
583
+ onChange: (_) => N(_.target.value.replace(/\D/g, "").slice(0, 9)),
584
+ disabled: D
585
+ }
586
+ ),
587
+ /* @__PURE__ */ r(
588
+ M,
589
+ {
590
+ variant: "primary",
591
+ size: "sm",
592
+ onClick: V,
593
+ loading: D,
594
+ disabled: p.length !== 9,
595
+ children: "Add"
596
+ }
597
+ )
598
+ ] }),
599
+ f && /* @__PURE__ */ r("div", { className: $.error, children: f }),
600
+ W && /* @__PURE__ */ r("div", { className: $.success, children: W })
601
+ ] }),
602
+ /* @__PURE__ */ r("div", { className: $.codesList, children: t.map((_) => /* @__PURE__ */ m("div", { className: $.codeItem, children: [
603
+ /* @__PURE__ */ r("span", { children: _.player_name ? `${_.player_name} (${J(_.ally_code)})` : J(_.ally_code) }),
604
+ /* @__PURE__ */ r(
605
+ M,
606
+ {
607
+ variant: "ghost",
608
+ size: "sm",
609
+ onClick: () => K(_.ally_code),
610
+ children: "Remove"
611
+ }
612
+ )
613
+ ] }, _.ally_code)) }),
614
+ /* @__PURE__ */ r(
615
+ M,
616
+ {
617
+ variant: "secondary",
618
+ size: "sm",
619
+ onClick: () => h(!1),
620
+ className: $.doneButton,
621
+ children: "Done"
622
+ }
623
+ )
624
+ ] }),
625
+ /* @__PURE__ */ r(
626
+ M,
627
+ {
628
+ variant: "ghost",
629
+ size: "sm",
630
+ onClick: () => h(!i),
631
+ className: $.manageButton,
632
+ children: "Manage"
633
+ }
634
+ )
635
+ ] });
636
+ }, qt = "_card_b4471_1", Rt = "_chamfered_b4471_8", Pt = "_elevated_b4471_17", Bt = "_outline_b4471_22", Ut = "_hoverable_b4471_45", U = {
637
+ card: qt,
638
+ chamfered: Rt,
639
+ default: "_default_b4471_13",
640
+ elevated: Pt,
641
+ outline: Bt,
642
+ "padding-none": "_padding-none_b4471_28",
643
+ "padding-sm": "_padding-sm_b4471_32",
644
+ "padding-md": "_padding-md_b4471_36",
645
+ "padding-lg": "_padding-lg_b4471_40",
646
+ hoverable: Ut
647
+ }, Ss = ({
648
+ children: e,
649
+ variant: s = "default",
650
+ chamfered: t = !1,
651
+ chamferSize: o = "md",
652
+ padding: d = "md",
653
+ hoverable: g = !1,
654
+ showDiagonalBorders: c = !1,
655
+ diagonalBorderColor: l,
656
+ className: i = "",
657
+ onClick: h,
658
+ style: p
659
+ }) => {
660
+ const N = t ? o === "asymmetric" ? "chamfered-box-asymmetric" : o === "sm" ? "chamfered-box-sm" : o === "lg" ? "chamfered-box-lg" : "chamfered-box" : "", f = l ? { color: l } : void 0;
661
+ return /* @__PURE__ */ m(
662
+ "div",
663
+ {
664
+ className: `${U.card} ${t ? U.chamfered : ""} ${U[s]} ${U[`padding-${d}`]} ${N} ${g ? U.hoverable : ""} ${i}`,
665
+ onClick: h,
666
+ role: h ? "button" : void 0,
667
+ tabIndex: h ? 0 : void 0,
668
+ style: p,
669
+ children: [
670
+ c && /* @__PURE__ */ m(ge, { children: [
671
+ /* @__PURE__ */ r("div", { className: "chamfered-diagonal-border chamfered-diagonal-tl", style: f }),
672
+ /* @__PURE__ */ r("div", { className: "chamfered-diagonal-border chamfered-diagonal-tr", style: f }),
673
+ /* @__PURE__ */ r("div", { className: "chamfered-diagonal-border chamfered-diagonal-bl", style: f }),
674
+ /* @__PURE__ */ r("div", { className: `chamfered-diagonal-border ${o === "asymmetric" ? "chamfered-diagonal-br-large" : "chamfered-diagonal-br"}`, style: f })
675
+ ] }),
676
+ e
677
+ ]
678
+ }
679
+ );
680
+ }, jt = "_badge_rk7t5_1", Ft = "_sm_rk7t5_11", Dt = "_md_rk7t5_16", Ot = "_lg_rk7t5_21", zt = "_primary_rk7t5_32", Mt = "_secondary_rk7t5_37", Jt = "_success_rk7t5_42", Ht = "_warning_rk7t5_47", Yt = "_error_rk7t5_52", Gt = "_info_rk7t5_57", Z = {
681
+ badge: jt,
682
+ sm: Ft,
683
+ md: Dt,
684
+ lg: Ot,
685
+ default: "_default_rk7t5_27",
686
+ primary: zt,
687
+ secondary: Mt,
688
+ success: Jt,
689
+ warning: Ht,
690
+ error: Yt,
691
+ info: Gt
692
+ }, xs = ({
693
+ children: e,
694
+ variant: s = "default",
695
+ size: t = "md",
696
+ className: o = ""
697
+ }) => /* @__PURE__ */ r("span", { className: `${Z.badge} ${Z[s]} ${Z[t]} ${o}`, children: e }), Kt = "_overlay_1b3yt_1", Vt = "_fadeIn_1b3yt_1", Qt = "_modal_1b3yt_13", Xt = "_slideUp_1b3yt_1", Zt = "_sm_1b3yt_25", es = "_md_1b3yt_30", ts = "_lg_1b3yt_35", ss = "_xl_1b3yt_40", os = "_header_1b3yt_45", rs = "_title_1b3yt_53", as = "_closeButton_1b3yt_60", ns = "_content_1b3yt_78", E = {
698
+ overlay: Kt,
699
+ fadeIn: Vt,
700
+ modal: Qt,
701
+ slideUp: Xt,
702
+ sm: Zt,
703
+ md: es,
704
+ lg: ts,
705
+ xl: ss,
706
+ header: os,
707
+ title: rs,
708
+ closeButton: as,
709
+ content: ns
710
+ }, Ts = ({
711
+ isOpen: e,
712
+ onClose: s,
713
+ title: t,
714
+ children: o,
715
+ size: d = "md",
716
+ closeOnOverlayClick: g = !0,
717
+ className: c = ""
718
+ }) => {
719
+ if (j(() => (e ? document.body.style.overflow = "hidden" : document.body.style.overflow = "unset", () => {
720
+ document.body.style.overflow = "unset";
721
+ }), [e]), j(() => {
722
+ const i = (h) => {
723
+ h.key === "Escape" && e && s();
724
+ };
725
+ return document.addEventListener("keydown", i), () => document.removeEventListener("keydown", i);
726
+ }, [e, s]), !e) return null;
727
+ const l = (i) => {
728
+ g && i.target === i.currentTarget && s();
729
+ };
730
+ return /* @__PURE__ */ r("div", { className: E.overlay, onClick: l, children: /* @__PURE__ */ m("div", { className: `${E.modal} ${E[d]} ${c}`, role: "dialog", "aria-modal": "true", children: [
731
+ t && /* @__PURE__ */ m("div", { className: E.header, children: [
732
+ /* @__PURE__ */ r("h2", { className: E.title, children: t }),
733
+ /* @__PURE__ */ r("button", { className: E.closeButton, onClick: s, "aria-label": "Close modal", children: "✕" })
734
+ ] }),
735
+ /* @__PURE__ */ r("div", { className: E.content, children: o })
736
+ ] }) });
737
+ }, ls = "_spinner_1uhnh_2", cs = "_spin_1uhnh_2", is = "_sm_1uhnh_9", ds = "_md_1uhnh_15", _s = "_lg_1uhnh_21", ms = "_dots_1uhnh_34", us = "_dot_1uhnh_34", hs = "_bounce_1uhnh_1", gs = "_visuallyHidden_1uhnh_91", C = {
738
+ spinner: ls,
739
+ spin: cs,
740
+ sm: is,
741
+ md: ds,
742
+ lg: _s,
743
+ dots: ms,
744
+ dot: us,
745
+ bounce: hs,
746
+ visuallyHidden: gs
747
+ }, Cs = ({
748
+ size: e = "md",
749
+ variant: s = "spinner",
750
+ className: t = ""
751
+ }) => s === "dots" ? /* @__PURE__ */ m("div", { className: `${C.dots} ${C[e]} ${t}`, children: [
752
+ /* @__PURE__ */ r("span", { className: C.dot }),
753
+ /* @__PURE__ */ r("span", { className: C.dot }),
754
+ /* @__PURE__ */ r("span", { className: C.dot })
755
+ ] }) : /* @__PURE__ */ r("div", { className: `${C.spinner} ${C[e]} ${t}`, role: "status", children: /* @__PURE__ */ r("span", { className: C.visuallyHidden, children: "Loading..." }) });
756
+ export {
757
+ As as AllyCodeDropdown,
758
+ gt as ApiClient,
759
+ ws as AuthProvider,
760
+ xs as Badge,
761
+ M as Button,
762
+ Ss as Card,
763
+ vs as Container,
764
+ bs as Footer,
765
+ ne as Input,
766
+ Cs as Loader,
767
+ Ts as Modal,
768
+ le as Select,
769
+ $s as TopBar,
770
+ y as apiClient,
771
+ bt as clearAllyCodes,
772
+ ee as clearTokens,
773
+ J as formatAllyCode,
774
+ ce as getAccessToken,
775
+ A as getAllyCodesFromStorage,
776
+ _t as getRefreshToken,
777
+ vt as getSelectedAllyCode,
778
+ ft as initializeApiClient,
779
+ ht as isAuthenticated,
780
+ dt as removeAccessToken,
781
+ yt as removeAllyCodeFromStorage,
782
+ ut as removeRefreshToken,
783
+ pt as saveAllyCodeToStorage,
784
+ it as setAccessToken,
785
+ mt as setRefreshToken,
786
+ $t as setSelectedAllyCode,
787
+ ie as setTokens,
788
+ Ns as unformatAllyCode,
789
+ re as updateAllyCodeLastUsed,
790
+ wt as useAuth
791
+ };