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