alex-evo-sh-auth 0.0.4 → 0.0.6

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.
@@ -1,345 +1,2251 @@
1
- import re, { createContext as te, useContext as ne, useState as oe, useCallback as ae, useEffect as se } from "react";
2
- const M = te(null);
3
- function W() {
4
- const a = ne(M);
5
- if (!a) throw new Error("useAuth must be used inside AuthProvider");
6
- return a;
7
- }
8
- function de({ children: a }) {
9
- const { loading: s, isAuthenticated: u } = W();
10
- return s || !u ? null : a;
11
- }
12
- var T = { exports: {} }, v = {};
13
- var F;
14
- function ue() {
15
- if (F) return v;
16
- F = 1;
17
- var a = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
18
- function u(f, l, i) {
19
- var d = null;
20
- if (i !== void 0 && (d = "" + i), l.key !== void 0 && (d = "" + l.key), "key" in l) {
21
- i = {};
22
- for (var c in l)
23
- c !== "key" && (i[c] = l[c]);
24
- } else i = l;
25
- return l = i.ref, {
26
- $$typeof: a,
27
- type: f,
28
- key: d,
29
- ref: l !== void 0 ? l : null,
30
- props: i
31
- };
1
+ import * as s from "react";
2
+ import Ct, { createContext as Er, useState as Ie, useMemo as wr, useCallback as ke, useEffect as Ae, useContext as _t } from "react";
3
+ async function br(e) {
4
+ const t = await fetch(`${e.authServer}/refresh`, {
5
+ method: "POST",
6
+ headers: {
7
+ "Content-Type": "application/json"
8
+ },
9
+ body: JSON.stringify({
10
+ grant_type: "refresh_token",
11
+ client_id: e.clientId
12
+ })
13
+ });
14
+ if (t.status === 401)
15
+ return localStorage.removeItem(e.baseKey + "_access"), null;
16
+ const r = await t.json();
17
+ return localStorage.setItem(e.baseKey + "_access", r.access), r.access;
18
+ }
19
+ class Sr {
20
+ constructor(t, r) {
21
+ this.onAuthFail = r, this.config = t;
22
+ }
23
+ refreshPromise = null;
24
+ config;
25
+ getToken() {
26
+ return localStorage.getItem(this.config.baseKey + "_access");
27
+ }
28
+ setToken(t) {
29
+ t ? localStorage.setItem(this.config.baseKey + "_access", t) : localStorage.removeItem(this.config.baseKey + "_access");
30
+ }
31
+ async getValidToken() {
32
+ let t = this.getToken();
33
+ return t || (this.refreshPromise || (this.refreshPromise = br(this.config).then((r) => (this.setToken(r), r)).finally(() => {
34
+ this.refreshPromise = null;
35
+ })), t = await this.refreshPromise, !t && this.onAuthFail && this.onAuthFail(), t);
36
+ }
37
+ }
38
+ class oa {
39
+ authServer;
40
+ clientId;
41
+ redirectUri;
42
+ homePage;
43
+ baseKey;
44
+ constructor(t, r, a, o, i) {
45
+ this.authServer = t, this.clientId = r, this.redirectUri = a, this.homePage = o, this.baseKey = i;
46
+ }
47
+ }
48
+ async function Pt(e, t, r = {}) {
49
+ let a = e.getToken();
50
+ const o = (l) => fetch(t, {
51
+ ...r,
52
+ headers: {
53
+ ...r.headers,
54
+ Authorization: l ? `Bearer ${l}` : ""
55
+ }
56
+ });
57
+ let i = await o(a);
58
+ return i.status !== 401 || (e.setToken(null), a = await e.getValidToken(), !a) ? i : o(a);
59
+ }
60
+ async function vt(e) {
61
+ const t = new URLSearchParams(window.location.search), r = t.get("code"), a = sessionStorage.getItem("oauth_state"), o = t.get("state");
62
+ if (!r) return;
63
+ if (!o || o !== a)
64
+ throw new Error("Invalid OAuth state");
65
+ const i = sessionStorage.getItem("pkce_verifier"), f = await (await fetch(`${e.config.authServer}/token`, {
66
+ method: "POST",
67
+ headers: {
68
+ "Content-Type": "application/json"
69
+ },
70
+ body: JSON.stringify({
71
+ client_id: e.config.clientId,
72
+ code: r,
73
+ code_verifier: i
74
+ })
75
+ })).json();
76
+ localStorage.setItem(e.config.baseKey + "_access", f.access), window.history.replaceState({}, document.title, e.config.homePage), window.location.href = e.config.homePage;
77
+ }
78
+ function xr(e = 64) {
79
+ const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
80
+ let r = "";
81
+ const a = new Uint8Array(e);
82
+ crypto.getRandomValues(a);
83
+ for (let o = 0; o < a.length; o++)
84
+ r += t[a[o] % t.length];
85
+ return r;
86
+ }
87
+ async function Cr(e) {
88
+ const r = new TextEncoder().encode(e), a = await crypto.subtle.digest("SHA-256", r);
89
+ return new Uint8Array(a);
90
+ }
91
+ function _r(e) {
92
+ return btoa(String.fromCharCode(...Array.from(e))).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
93
+ }
94
+ async function De(e) {
95
+ const t = xr(64), r = _r(await Cr(t));
96
+ sessionStorage.setItem("pkce_verifier", t);
97
+ const a = crypto.randomUUID();
98
+ sessionStorage.setItem("oauth_state", a);
99
+ const o = new URLSearchParams({
100
+ response_type: "code",
101
+ client_id: e.config.clientId,
102
+ redirect_uri: e.config.redirectUri,
103
+ code_challenge: r,
104
+ code_challenge_method: "S256",
105
+ state: a
106
+ });
107
+ window.location.href = `${e.config.authServer}/authorize?${o}`;
108
+ }
109
+ async function gt(e) {
110
+ try {
111
+ await Pt(e, `${e.config.authServer}/logout`, {
112
+ method: "POST",
113
+ headers: {
114
+ "Content-Type": "application/json"
115
+ },
116
+ body: JSON.stringify({
117
+ client_id: e.config.clientId
118
+ })
119
+ }), localStorage.removeItem(e.config.baseKey + "_access"), await De(e);
120
+ } catch (t) {
121
+ console.error(t);
122
+ }
123
+ }
124
+ const je = Er({
125
+ login: () => {
126
+ },
127
+ logout: () => {
128
+ },
129
+ loadMe: () => {
130
+ },
131
+ authManager: null,
132
+ user: null,
133
+ loading: !1
134
+ });
135
+ var de = { exports: {} }, ne = {};
136
+ var yt;
137
+ function Pr() {
138
+ if (yt) return ne;
139
+ yt = 1;
140
+ var e = Ct, t = /* @__PURE__ */ Symbol.for("react.element"), r = /* @__PURE__ */ Symbol.for("react.fragment"), a = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = { key: !0, ref: !0, __self: !0, __source: !0 };
141
+ function l(f, u, m) {
142
+ var h, c = {}, v = null, E = null;
143
+ m !== void 0 && (v = "" + m), u.key !== void 0 && (v = "" + u.key), u.ref !== void 0 && (E = u.ref);
144
+ for (h in u) a.call(u, h) && !i.hasOwnProperty(h) && (c[h] = u[h]);
145
+ if (f && f.defaultProps) for (h in u = f.defaultProps, u) c[h] === void 0 && (c[h] = u[h]);
146
+ return { $$typeof: t, type: f, key: v, ref: E, props: c, _owner: o.current };
32
147
  }
33
- return v.Fragment = s, v.jsx = u, v.jsxs = u, v;
34
- }
35
- var R = {};
36
- var D;
37
- function le() {
38
- return D || (D = 1, process.env.NODE_ENV !== "production" && (function() {
39
- function a(e) {
40
- if (e == null) return null;
41
- if (typeof e == "function")
42
- return e.$$typeof === Q ? null : e.displayName || e.name || null;
43
- if (typeof e == "string") return e;
44
- switch (e) {
45
- case w:
148
+ return ne.Fragment = r, ne.jsx = l, ne.jsxs = l, ne;
149
+ }
150
+ var ae = {};
151
+ var Rt;
152
+ function Tr() {
153
+ return Rt || (Rt = 1, process.env.NODE_ENV !== "production" && (function() {
154
+ var e = Ct, t = /* @__PURE__ */ Symbol.for("react.element"), r = /* @__PURE__ */ Symbol.for("react.portal"), a = /* @__PURE__ */ Symbol.for("react.fragment"), o = /* @__PURE__ */ Symbol.for("react.strict_mode"), i = /* @__PURE__ */ Symbol.for("react.profiler"), l = /* @__PURE__ */ Symbol.for("react.provider"), f = /* @__PURE__ */ Symbol.for("react.context"), u = /* @__PURE__ */ Symbol.for("react.forward_ref"), m = /* @__PURE__ */ Symbol.for("react.suspense"), h = /* @__PURE__ */ Symbol.for("react.suspense_list"), c = /* @__PURE__ */ Symbol.for("react.memo"), v = /* @__PURE__ */ Symbol.for("react.lazy"), E = /* @__PURE__ */ Symbol.for("react.offscreen"), w = Symbol.iterator, x = "@@iterator";
155
+ function y(n) {
156
+ if (n === null || typeof n != "object")
157
+ return null;
158
+ var d = w && n[w] || n[x];
159
+ return typeof d == "function" ? d : null;
160
+ }
161
+ var C = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
162
+ function R(n) {
163
+ {
164
+ for (var d = arguments.length, p = new Array(d > 1 ? d - 1 : 0), g = 1; g < d; g++)
165
+ p[g - 1] = arguments[g];
166
+ P("error", n, p);
167
+ }
168
+ }
169
+ function P(n, d, p) {
170
+ {
171
+ var g = C.ReactDebugCurrentFrame, _ = g.getStackAddendum();
172
+ _ !== "" && (d += "%s", p = p.concat([_]));
173
+ var T = p.map(function(S) {
174
+ return String(S);
175
+ });
176
+ T.unshift("Warning: " + d), Function.prototype.apply.call(console[n], console, T);
177
+ }
178
+ }
179
+ var j = !1, I = !1, M = !1, W = !1, K = !1, J;
180
+ J = /* @__PURE__ */ Symbol.for("react.module.reference");
181
+ function te(n) {
182
+ return !!(typeof n == "string" || typeof n == "function" || n === a || n === i || K || n === o || n === m || n === h || W || n === E || j || I || M || typeof n == "object" && n !== null && (n.$$typeof === v || n.$$typeof === c || n.$$typeof === l || n.$$typeof === f || n.$$typeof === u || // This needs to include all possible module reference object
183
+ // types supported by any Flight configuration anywhere since
184
+ // we don't know which Flight build this will end up being used
185
+ // with.
186
+ n.$$typeof === J || n.getModuleId !== void 0));
187
+ }
188
+ function Ee(n, d, p) {
189
+ var g = n.displayName;
190
+ if (g)
191
+ return g;
192
+ var _ = d.displayName || d.name || "";
193
+ return _ !== "" ? p + "(" + _ + ")" : p;
194
+ }
195
+ function le(n) {
196
+ return n.displayName || "Context";
197
+ }
198
+ function N(n) {
199
+ if (n == null)
200
+ return null;
201
+ if (typeof n.tag == "number" && R("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof n == "function")
202
+ return n.displayName || n.name || null;
203
+ if (typeof n == "string")
204
+ return n;
205
+ switch (n) {
206
+ case a:
46
207
  return "Fragment";
47
- case z:
208
+ case r:
209
+ return "Portal";
210
+ case i:
48
211
  return "Profiler";
49
- case q:
212
+ case o:
50
213
  return "StrictMode";
51
- case X:
214
+ case m:
52
215
  return "Suspense";
53
- case H:
216
+ case h:
54
217
  return "SuspenseList";
55
- case Z:
56
- return "Activity";
57
- }
58
- if (typeof e == "object")
59
- switch (typeof e.tag == "number" && console.error(
60
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
61
- ), e.$$typeof) {
62
- case U:
63
- return "Portal";
64
- case V:
65
- return e.displayName || "Context";
66
- case J:
67
- return (e._context.displayName || "Context") + ".Consumer";
68
- case G:
69
- var r = e.render;
70
- return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
71
- case B:
72
- return r = e.displayName || null, r !== null ? r : a(e.type) || "Memo";
73
- case A:
74
- r = e._payload, e = e._init;
218
+ }
219
+ if (typeof n == "object")
220
+ switch (n.$$typeof) {
221
+ case f:
222
+ var d = n;
223
+ return le(d) + ".Consumer";
224
+ case l:
225
+ var p = n;
226
+ return le(p._context) + ".Provider";
227
+ case u:
228
+ return Ee(n, n.render, "ForwardRef");
229
+ case c:
230
+ var g = n.displayName || null;
231
+ return g !== null ? g : N(n.type) || "Memo";
232
+ case v: {
233
+ var _ = n, T = _._payload, S = _._init;
75
234
  try {
76
- return a(e(r));
235
+ return N(S(T));
77
236
  } catch {
237
+ return null;
78
238
  }
239
+ }
79
240
  }
80
241
  return null;
81
242
  }
82
- function s(e) {
83
- return "" + e;
243
+ var B = Object.assign, D = 0, Je, ze, qe, Ge, Xe, Ze, Qe;
244
+ function et() {
245
+ }
246
+ et.__reactDisabledLog = !0;
247
+ function Jt() {
248
+ {
249
+ if (D === 0) {
250
+ Je = console.log, ze = console.info, qe = console.warn, Ge = console.error, Xe = console.group, Ze = console.groupCollapsed, Qe = console.groupEnd;
251
+ var n = {
252
+ configurable: !0,
253
+ enumerable: !0,
254
+ value: et,
255
+ writable: !0
256
+ };
257
+ Object.defineProperties(console, {
258
+ info: n,
259
+ log: n,
260
+ warn: n,
261
+ error: n,
262
+ group: n,
263
+ groupCollapsed: n,
264
+ groupEnd: n
265
+ });
266
+ }
267
+ D++;
268
+ }
269
+ }
270
+ function zt() {
271
+ {
272
+ if (D--, D === 0) {
273
+ var n = {
274
+ configurable: !0,
275
+ enumerable: !0,
276
+ writable: !0
277
+ };
278
+ Object.defineProperties(console, {
279
+ log: B({}, n, {
280
+ value: Je
281
+ }),
282
+ info: B({}, n, {
283
+ value: ze
284
+ }),
285
+ warn: B({}, n, {
286
+ value: qe
287
+ }),
288
+ error: B({}, n, {
289
+ value: Ge
290
+ }),
291
+ group: B({}, n, {
292
+ value: Xe
293
+ }),
294
+ groupCollapsed: B({}, n, {
295
+ value: Ze
296
+ }),
297
+ groupEnd: B({}, n, {
298
+ value: Qe
299
+ })
300
+ });
301
+ }
302
+ D < 0 && R("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
303
+ }
304
+ }
305
+ var we = C.ReactCurrentDispatcher, be;
306
+ function se(n, d, p) {
307
+ {
308
+ if (be === void 0)
309
+ try {
310
+ throw Error();
311
+ } catch (_) {
312
+ var g = _.stack.trim().match(/\n( *(at )?)/);
313
+ be = g && g[1] || "";
314
+ }
315
+ return `
316
+ ` + be + n;
317
+ }
318
+ }
319
+ var Se = !1, ue;
320
+ {
321
+ var qt = typeof WeakMap == "function" ? WeakMap : Map;
322
+ ue = new qt();
84
323
  }
85
- function u(e) {
324
+ function tt(n, d) {
325
+ if (!n || Se)
326
+ return "";
327
+ {
328
+ var p = ue.get(n);
329
+ if (p !== void 0)
330
+ return p;
331
+ }
332
+ var g;
333
+ Se = !0;
334
+ var _ = Error.prepareStackTrace;
335
+ Error.prepareStackTrace = void 0;
336
+ var T;
337
+ T = we.current, we.current = null, Jt();
86
338
  try {
87
- s(e);
88
- var r = !1;
89
- } catch {
90
- r = !0;
91
- }
92
- if (r) {
93
- r = console;
94
- var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
95
- return t.call(
96
- r,
97
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
98
- n
99
- ), s(e);
100
- }
101
- }
102
- function f(e) {
103
- if (e === w) return "<>";
104
- if (typeof e == "object" && e !== null && e.$$typeof === A)
105
- return "<...>";
339
+ if (d) {
340
+ var S = function() {
341
+ throw Error();
342
+ };
343
+ if (Object.defineProperty(S.prototype, "props", {
344
+ set: function() {
345
+ throw Error();
346
+ }
347
+ }), typeof Reflect == "object" && Reflect.construct) {
348
+ try {
349
+ Reflect.construct(S, []);
350
+ } catch (F) {
351
+ g = F;
352
+ }
353
+ Reflect.construct(n, [], S);
354
+ } else {
355
+ try {
356
+ S.call();
357
+ } catch (F) {
358
+ g = F;
359
+ }
360
+ n.call(S.prototype);
361
+ }
362
+ } else {
363
+ try {
364
+ throw Error();
365
+ } catch (F) {
366
+ g = F;
367
+ }
368
+ n();
369
+ }
370
+ } catch (F) {
371
+ if (F && g && typeof F.stack == "string") {
372
+ for (var b = F.stack.split(`
373
+ `), L = g.stack.split(`
374
+ `), k = b.length - 1, O = L.length - 1; k >= 1 && O >= 0 && b[k] !== L[O]; )
375
+ O--;
376
+ for (; k >= 1 && O >= 0; k--, O--)
377
+ if (b[k] !== L[O]) {
378
+ if (k !== 1 || O !== 1)
379
+ do
380
+ if (k--, O--, O < 0 || b[k] !== L[O]) {
381
+ var A = `
382
+ ` + b[k].replace(" at new ", " at ");
383
+ return n.displayName && A.includes("<anonymous>") && (A = A.replace("<anonymous>", n.displayName)), typeof n == "function" && ue.set(n, A), A;
384
+ }
385
+ while (k >= 1 && O >= 0);
386
+ break;
387
+ }
388
+ }
389
+ } finally {
390
+ Se = !1, we.current = T, zt(), Error.prepareStackTrace = _;
391
+ }
392
+ var Z = n ? n.displayName || n.name : "", G = Z ? se(Z) : "";
393
+ return typeof n == "function" && ue.set(n, G), G;
394
+ }
395
+ function Gt(n, d, p) {
396
+ return tt(n, !1);
397
+ }
398
+ function Xt(n) {
399
+ var d = n.prototype;
400
+ return !!(d && d.isReactComponent);
401
+ }
402
+ function ce(n, d, p) {
403
+ if (n == null)
404
+ return "";
405
+ if (typeof n == "function")
406
+ return tt(n, Xt(n));
407
+ if (typeof n == "string")
408
+ return se(n);
409
+ switch (n) {
410
+ case m:
411
+ return se("Suspense");
412
+ case h:
413
+ return se("SuspenseList");
414
+ }
415
+ if (typeof n == "object")
416
+ switch (n.$$typeof) {
417
+ case u:
418
+ return Gt(n.render);
419
+ case c:
420
+ return ce(n.type, d, p);
421
+ case v: {
422
+ var g = n, _ = g._payload, T = g._init;
423
+ try {
424
+ return ce(T(_), d, p);
425
+ } catch {
426
+ }
427
+ }
428
+ }
429
+ return "";
430
+ }
431
+ var re = Object.prototype.hasOwnProperty, rt = {}, nt = C.ReactDebugCurrentFrame;
432
+ function fe(n) {
433
+ if (n) {
434
+ var d = n._owner, p = ce(n.type, n._source, d ? d.type : null);
435
+ nt.setExtraStackFrame(p);
436
+ } else
437
+ nt.setExtraStackFrame(null);
438
+ }
439
+ function Zt(n, d, p, g, _) {
440
+ {
441
+ var T = Function.call.bind(re);
442
+ for (var S in n)
443
+ if (T(n, S)) {
444
+ var b = void 0;
445
+ try {
446
+ if (typeof n[S] != "function") {
447
+ var L = Error((g || "React class") + ": " + p + " type `" + S + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof n[S] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
448
+ throw L.name = "Invariant Violation", L;
449
+ }
450
+ b = n[S](d, S, g, p, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
451
+ } catch (k) {
452
+ b = k;
453
+ }
454
+ b && !(b instanceof Error) && (fe(_), R("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", g || "React class", p, S, typeof b), fe(null)), b instanceof Error && !(b.message in rt) && (rt[b.message] = !0, fe(_), R("Failed %s type: %s", p, b.message), fe(null));
455
+ }
456
+ }
457
+ }
458
+ var Qt = Array.isArray;
459
+ function xe(n) {
460
+ return Qt(n);
461
+ }
462
+ function er(n) {
463
+ {
464
+ var d = typeof Symbol == "function" && Symbol.toStringTag, p = d && n[Symbol.toStringTag] || n.constructor.name || "Object";
465
+ return p;
466
+ }
467
+ }
468
+ function tr(n) {
106
469
  try {
107
- var r = a(e);
108
- return r ? "<" + r + ">" : "<...>";
470
+ return at(n), !1;
109
471
  } catch {
110
- return "<...>";
472
+ return !0;
111
473
  }
112
474
  }
113
- function l() {
114
- var e = k.A;
115
- return e === null ? null : e.getOwner();
475
+ function at(n) {
476
+ return "" + n;
116
477
  }
117
- function i() {
118
- return Error("react-stack-top-frame");
478
+ function ot(n) {
479
+ if (tr(n))
480
+ return R("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", er(n)), at(n);
119
481
  }
120
- function d(e) {
121
- if (j.call(e, "key")) {
122
- var r = Object.getOwnPropertyDescriptor(e, "key").get;
123
- if (r && r.isReactWarning) return !1;
482
+ var it = C.ReactCurrentOwner, rr = {
483
+ key: !0,
484
+ ref: !0,
485
+ __self: !0,
486
+ __source: !0
487
+ }, lt, st;
488
+ function nr(n) {
489
+ if (re.call(n, "ref")) {
490
+ var d = Object.getOwnPropertyDescriptor(n, "ref").get;
491
+ if (d && d.isReactWarning)
492
+ return !1;
124
493
  }
125
- return e.key !== void 0;
494
+ return n.ref !== void 0;
126
495
  }
127
- function c(e, r) {
128
- function t() {
129
- C || (C = !0, console.error(
130
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
131
- r
132
- ));
496
+ function ar(n) {
497
+ if (re.call(n, "key")) {
498
+ var d = Object.getOwnPropertyDescriptor(n, "key").get;
499
+ if (d && d.isReactWarning)
500
+ return !1;
133
501
  }
134
- t.isReactWarning = !0, Object.defineProperty(e, "key", {
135
- get: t,
136
- configurable: !0
137
- });
502
+ return n.key !== void 0;
138
503
  }
139
- function h() {
140
- var e = a(this.type);
141
- return N[e] || (N[e] = !0, console.error(
142
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
143
- )), e = this.props.ref, e !== void 0 ? e : null;
144
- }
145
- function E(e, r, t, n, p, x) {
146
- var o = t.ref;
147
- return e = {
148
- $$typeof: y,
149
- type: e,
150
- key: r,
151
- props: t,
152
- _owner: n
153
- }, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
154
- enumerable: !1,
155
- get: h
156
- }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
157
- configurable: !1,
158
- enumerable: !1,
159
- writable: !0,
160
- value: 0
161
- }), Object.defineProperty(e, "_debugInfo", {
504
+ function or(n, d) {
505
+ typeof n.ref == "string" && it.current;
506
+ }
507
+ function ir(n, d) {
508
+ {
509
+ var p = function() {
510
+ lt || (lt = !0, R("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", d));
511
+ };
512
+ p.isReactWarning = !0, Object.defineProperty(n, "key", {
513
+ get: p,
514
+ configurable: !0
515
+ });
516
+ }
517
+ }
518
+ function lr(n, d) {
519
+ {
520
+ var p = function() {
521
+ st || (st = !0, R("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", d));
522
+ };
523
+ p.isReactWarning = !0, Object.defineProperty(n, "ref", {
524
+ get: p,
525
+ configurable: !0
526
+ });
527
+ }
528
+ }
529
+ var sr = function(n, d, p, g, _, T, S) {
530
+ var b = {
531
+ // This tag allows us to uniquely identify this as a React Element
532
+ $$typeof: t,
533
+ // Built-in properties that belong on the element
534
+ type: n,
535
+ key: d,
536
+ ref: p,
537
+ props: S,
538
+ // Record the component responsible for creating this element.
539
+ _owner: T
540
+ };
541
+ return b._store = {}, Object.defineProperty(b._store, "validated", {
162
542
  configurable: !1,
163
543
  enumerable: !1,
164
544
  writable: !0,
165
- value: null
166
- }), Object.defineProperty(e, "_debugStack", {
545
+ value: !1
546
+ }), Object.defineProperty(b, "_self", {
167
547
  configurable: !1,
168
548
  enumerable: !1,
169
- writable: !0,
170
- value: p
171
- }), Object.defineProperty(e, "_debugTask", {
549
+ writable: !1,
550
+ value: g
551
+ }), Object.defineProperty(b, "_source", {
172
552
  configurable: !1,
173
553
  enumerable: !1,
174
- writable: !0,
175
- value: x
176
- }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
177
- }
178
- function m(e, r, t, n, p, x) {
179
- var o = r.children;
180
- if (o !== void 0)
181
- if (n)
182
- if (K(o)) {
183
- for (n = 0; n < o.length; n++)
184
- O(o[n]);
185
- Object.freeze && Object.freeze(o);
186
- } else
187
- console.error(
188
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
189
- );
190
- else O(o);
191
- if (j.call(r, "key")) {
192
- o = a(e);
193
- var _ = Object.keys(r).filter(function(ee) {
194
- return ee !== "key";
195
- });
196
- n = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", I[o + n] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
197
- `A props object containing a "key" prop is being spread into JSX:
554
+ writable: !1,
555
+ value: _
556
+ }), Object.freeze && (Object.freeze(b.props), Object.freeze(b)), b;
557
+ };
558
+ function ur(n, d, p, g, _) {
559
+ {
560
+ var T, S = {}, b = null, L = null;
561
+ p !== void 0 && (ot(p), b = "" + p), ar(d) && (ot(d.key), b = "" + d.key), nr(d) && (L = d.ref, or(d, _));
562
+ for (T in d)
563
+ re.call(d, T) && !rr.hasOwnProperty(T) && (S[T] = d[T]);
564
+ if (n && n.defaultProps) {
565
+ var k = n.defaultProps;
566
+ for (T in k)
567
+ S[T] === void 0 && (S[T] = k[T]);
568
+ }
569
+ if (b || L) {
570
+ var O = typeof n == "function" ? n.displayName || n.name || "Unknown" : n;
571
+ b && ir(S, O), L && lr(S, O);
572
+ }
573
+ return sr(n, b, L, _, g, it.current, S);
574
+ }
575
+ }
576
+ var Ce = C.ReactCurrentOwner, ut = C.ReactDebugCurrentFrame;
577
+ function X(n) {
578
+ if (n) {
579
+ var d = n._owner, p = ce(n.type, n._source, d ? d.type : null);
580
+ ut.setExtraStackFrame(p);
581
+ } else
582
+ ut.setExtraStackFrame(null);
583
+ }
584
+ var _e;
585
+ _e = !1;
586
+ function Pe(n) {
587
+ return typeof n == "object" && n !== null && n.$$typeof === t;
588
+ }
589
+ function ct() {
590
+ {
591
+ if (Ce.current) {
592
+ var n = N(Ce.current.type);
593
+ if (n)
594
+ return `
595
+
596
+ Check the render method of \`` + n + "`.";
597
+ }
598
+ return "";
599
+ }
600
+ }
601
+ function cr(n) {
602
+ return "";
603
+ }
604
+ var ft = {};
605
+ function fr(n) {
606
+ {
607
+ var d = ct();
608
+ if (!d) {
609
+ var p = typeof n == "string" ? n : n.displayName || n.name;
610
+ p && (d = `
611
+
612
+ Check the top-level render call using <` + p + ">.");
613
+ }
614
+ return d;
615
+ }
616
+ }
617
+ function dt(n, d) {
618
+ {
619
+ if (!n._store || n._store.validated || n.key != null)
620
+ return;
621
+ n._store.validated = !0;
622
+ var p = fr(d);
623
+ if (ft[p])
624
+ return;
625
+ ft[p] = !0;
626
+ var g = "";
627
+ n && n._owner && n._owner !== Ce.current && (g = " It was passed a child from " + N(n._owner.type) + "."), X(n), R('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', p, g), X(null);
628
+ }
629
+ }
630
+ function ht(n, d) {
631
+ {
632
+ if (typeof n != "object")
633
+ return;
634
+ if (xe(n))
635
+ for (var p = 0; p < n.length; p++) {
636
+ var g = n[p];
637
+ Pe(g) && dt(g, d);
638
+ }
639
+ else if (Pe(n))
640
+ n._store && (n._store.validated = !0);
641
+ else if (n) {
642
+ var _ = y(n);
643
+ if (typeof _ == "function" && _ !== n.entries)
644
+ for (var T = _.call(n), S; !(S = T.next()).done; )
645
+ Pe(S.value) && dt(S.value, d);
646
+ }
647
+ }
648
+ }
649
+ function dr(n) {
650
+ {
651
+ var d = n.type;
652
+ if (d == null || typeof d == "string")
653
+ return;
654
+ var p;
655
+ if (typeof d == "function")
656
+ p = d.propTypes;
657
+ else if (typeof d == "object" && (d.$$typeof === u || // Note: Memo only checks outer props here.
658
+ // Inner props are checked in the reconciler.
659
+ d.$$typeof === c))
660
+ p = d.propTypes;
661
+ else
662
+ return;
663
+ if (p) {
664
+ var g = N(d);
665
+ Zt(p, n.props, "prop", g, n);
666
+ } else if (d.PropTypes !== void 0 && !_e) {
667
+ _e = !0;
668
+ var _ = N(d);
669
+ R("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _ || "Unknown");
670
+ }
671
+ typeof d.getDefaultProps == "function" && !d.getDefaultProps.isReactClassApproved && R("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
672
+ }
673
+ }
674
+ function hr(n) {
675
+ {
676
+ for (var d = Object.keys(n.props), p = 0; p < d.length; p++) {
677
+ var g = d[p];
678
+ if (g !== "children" && g !== "key") {
679
+ X(n), R("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", g), X(null);
680
+ break;
681
+ }
682
+ }
683
+ n.ref !== null && (X(n), R("Invalid attribute `ref` supplied to `React.Fragment`."), X(null));
684
+ }
685
+ }
686
+ var mt = {};
687
+ function pt(n, d, p, g, _, T) {
688
+ {
689
+ var S = te(n);
690
+ if (!S) {
691
+ var b = "";
692
+ (n === void 0 || typeof n == "object" && n !== null && Object.keys(n).length === 0) && (b += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
693
+ var L = cr();
694
+ L ? b += L : b += ct();
695
+ var k;
696
+ n === null ? k = "null" : xe(n) ? k = "array" : n !== void 0 && n.$$typeof === t ? (k = "<" + (N(n.type) || "Unknown") + " />", b = " Did you accidentally export a JSX literal instead of a component?") : k = typeof n, R("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", k, b);
697
+ }
698
+ var O = ur(n, d, p, _, T);
699
+ if (O == null)
700
+ return O;
701
+ if (S) {
702
+ var A = d.children;
703
+ if (A !== void 0)
704
+ if (g)
705
+ if (xe(A)) {
706
+ for (var Z = 0; Z < A.length; Z++)
707
+ ht(A[Z], n);
708
+ Object.freeze && Object.freeze(A);
709
+ } else
710
+ R("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
711
+ else
712
+ ht(A, n);
713
+ }
714
+ if (re.call(d, "key")) {
715
+ var G = N(n), F = Object.keys(d).filter(function(Rr) {
716
+ return Rr !== "key";
717
+ }), Te = F.length > 0 ? "{key: someKey, " + F.join(": ..., ") + ": ...}" : "{key: someKey}";
718
+ if (!mt[G + Te]) {
719
+ var yr = F.length > 0 ? "{" + F.join(": ..., ") + ": ...}" : "{}";
720
+ R(`A props object containing a "key" prop is being spread into JSX:
198
721
  let props = %s;
199
722
  <%s {...props} />
200
723
  React keys must be passed directly to JSX without using spread:
201
724
  let props = %s;
202
- <%s key={someKey} {...props} />`,
203
- n,
204
- o,
205
- _,
206
- o
207
- ), I[o + n] = !0);
208
- }
209
- if (o = null, t !== void 0 && (u(t), o = "" + t), d(r) && (u(r.key), o = "" + r.key), "key" in r) {
210
- t = {};
211
- for (var P in r)
212
- P !== "key" && (t[P] = r[P]);
213
- } else t = r;
214
- return o && c(
215
- t,
216
- typeof e == "function" ? e.displayName || e.name || "Unknown" : e
217
- ), E(
218
- e,
219
- o,
220
- t,
221
- l(),
222
- p,
223
- x
224
- );
725
+ <%s key={someKey} {...props} />`, Te, G, yr, G), mt[G + Te] = !0;
726
+ }
727
+ }
728
+ return n === a ? hr(O) : dr(O), O;
729
+ }
225
730
  }
226
- function O(e) {
227
- S(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? S(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
731
+ function mr(n, d, p) {
732
+ return pt(n, d, p, !0);
228
733
  }
229
- function S(e) {
230
- return typeof e == "object" && e !== null && e.$$typeof === y;
734
+ function pr(n, d, p) {
735
+ return pt(n, d, p, !1);
231
736
  }
232
- var b = re, y = /* @__PURE__ */ Symbol.for("react.transitional.element"), U = /* @__PURE__ */ Symbol.for("react.portal"), w = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), J = /* @__PURE__ */ Symbol.for("react.consumer"), V = /* @__PURE__ */ Symbol.for("react.context"), G = /* @__PURE__ */ Symbol.for("react.forward_ref"), X = /* @__PURE__ */ Symbol.for("react.suspense"), H = /* @__PURE__ */ Symbol.for("react.suspense_list"), B = /* @__PURE__ */ Symbol.for("react.memo"), A = /* @__PURE__ */ Symbol.for("react.lazy"), Z = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), k = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, j = Object.prototype.hasOwnProperty, K = Array.isArray, g = console.createTask ? console.createTask : function() {
233
- return null;
737
+ var vr = pr, gr = mr;
738
+ ae.Fragment = a, ae.jsx = vr, ae.jsxs = gr;
739
+ })()), ae;
740
+ }
741
+ var Et;
742
+ function kr() {
743
+ return Et || (Et = 1, process.env.NODE_ENV === "production" ? de.exports = Pr() : de.exports = Tr()), de.exports;
744
+ }
745
+ var Q = kr();
746
+ const ia = ({ children: e, authConfig: t }) => {
747
+ const [r, a] = Ie(null), [o, i] = Ie(!0), l = wr(() => new Sr(t), [t]), f = ke(async () => {
748
+ i(!0);
749
+ const h = localStorage.getItem(l.config.baseKey + "_access");
750
+ if (!h) {
751
+ a(null), i(!1);
752
+ return;
753
+ }
754
+ try {
755
+ const c = await Pt(l, `${l.config.authServer}/me`, {
756
+ headers: {
757
+ Authorization: `Bearer ${h}`
758
+ }
759
+ });
760
+ if (!c.ok) throw new Error("not found");
761
+ const v = await c.json();
762
+ a({
763
+ role: v.role.role_name,
764
+ userId: v.user_id,
765
+ userName: v.user_name,
766
+ privileges: v.role.privileges.map((E) => E.privilege.trim())
767
+ });
768
+ } catch {
769
+ a(null);
770
+ }
771
+ i(!1);
772
+ }, []);
773
+ Ae(() => {
774
+ f();
775
+ }, [f]);
776
+ const u = ke(() => {
777
+ De(l);
778
+ }, [De, l]), m = ke(() => {
779
+ gt(l), a(null);
780
+ }, [gt, l]);
781
+ return /* @__PURE__ */ Q.jsx(je.Provider, { value: { loadMe: f, loading: o, user: r, login: u, authManager: l, logout: m }, children: e });
782
+ }, la = () => {
783
+ const { authManager: e, loadMe: t } = _t(je);
784
+ return Ae(() => {
785
+ e && (vt(e), t());
786
+ }, [vt, e, t]), /* @__PURE__ */ Q.jsx("div", {});
787
+ };
788
+ function $(e, t) {
789
+ if (e === !1 || e === null || typeof e > "u")
790
+ throw new Error(t);
791
+ }
792
+ function Y(e, t) {
793
+ if (!e) {
794
+ typeof console < "u" && console.warn(t);
795
+ try {
796
+ throw new Error(t);
797
+ } catch {
798
+ }
799
+ }
800
+ }
801
+ function Fe({
802
+ pathname: e = "/",
803
+ search: t = "",
804
+ hash: r = ""
805
+ }) {
806
+ return t && t !== "?" && (e += t.charAt(0) === "?" ? t : "?" + t), r && r !== "#" && (e += r.charAt(0) === "#" ? r : "#" + r), e;
807
+ }
808
+ function Ne(e) {
809
+ let t = {};
810
+ if (e) {
811
+ let r = e.indexOf("#");
812
+ r >= 0 && (t.hash = e.substring(r), e = e.substring(0, r));
813
+ let a = e.indexOf("?");
814
+ a >= 0 && (t.search = e.substring(a), e = e.substring(0, a)), e && (t.pathname = e);
815
+ }
816
+ return t;
817
+ }
818
+ function Tt(e, t, r = "/") {
819
+ return Or(e, t, r, !1);
820
+ }
821
+ function Or(e, t, r, a) {
822
+ let o = typeof t == "string" ? Ne(t) : t, i = z(o.pathname || "/", r);
823
+ if (i == null)
824
+ return null;
825
+ let l = kt(e);
826
+ $r(l);
827
+ let f = null;
828
+ for (let u = 0; f == null && u < l.length; ++u) {
829
+ let m = Br(i);
830
+ f = Mr(
831
+ l[u],
832
+ m,
833
+ a
834
+ );
835
+ }
836
+ return f;
837
+ }
838
+ function kt(e, t = [], r = [], a = "", o = !1) {
839
+ let i = (l, f, u = o, m) => {
840
+ let h = {
841
+ relativePath: m === void 0 ? l.path || "" : m,
842
+ caseSensitive: l.caseSensitive === !0,
843
+ childrenIndex: f,
844
+ route: l
234
845
  };
235
- b = {
236
- react_stack_bottom_frame: function(e) {
237
- return e();
846
+ if (h.relativePath.startsWith("/")) {
847
+ if (!h.relativePath.startsWith(a) && u)
848
+ return;
849
+ $(
850
+ h.relativePath.startsWith(a),
851
+ `Absolute route path "${h.relativePath}" nested under path "${a}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`
852
+ ), h.relativePath = h.relativePath.slice(a.length);
853
+ }
854
+ let c = H([a, h.relativePath]), v = r.concat(h);
855
+ l.children && l.children.length > 0 && ($(
856
+ // Our types know better, but runtime JS may not!
857
+ // @ts-expect-error
858
+ l.index !== !0,
859
+ `Index routes must not have child routes. Please remove all child routes from route path "${c}".`
860
+ ), kt(
861
+ l.children,
862
+ t,
863
+ v,
864
+ c,
865
+ u
866
+ )), !(l.path == null && !l.index) && t.push({
867
+ path: c,
868
+ score: Nr(c, l.index),
869
+ routesMeta: v
870
+ });
871
+ };
872
+ return e.forEach((l, f) => {
873
+ if (l.path === "" || !l.path?.includes("?"))
874
+ i(l, f);
875
+ else
876
+ for (let u of Ot(l.path))
877
+ i(l, f, !0, u);
878
+ }), t;
879
+ }
880
+ function Ot(e) {
881
+ let t = e.split("/");
882
+ if (t.length === 0) return [];
883
+ let [r, ...a] = t, o = r.endsWith("?"), i = r.replace(/\?$/, "");
884
+ if (a.length === 0)
885
+ return o ? [i, ""] : [i];
886
+ let l = Ot(a.join("/")), f = [];
887
+ return f.push(
888
+ ...l.map(
889
+ (u) => u === "" ? i : [i, u].join("/")
890
+ )
891
+ ), o && f.push(...l), f.map(
892
+ (u) => e.startsWith("/") && u === "" ? "/" : u
893
+ );
894
+ }
895
+ function $r(e) {
896
+ e.sort(
897
+ (t, r) => t.score !== r.score ? r.score - t.score : Ur(
898
+ t.routesMeta.map((a) => a.childrenIndex),
899
+ r.routesMeta.map((a) => a.childrenIndex)
900
+ )
901
+ );
902
+ }
903
+ var Lr = /^:[\w-]+$/, Ir = 3, Dr = 2, Fr = 1, Ar = 10, jr = -2, wt = (e) => e === "*";
904
+ function Nr(e, t) {
905
+ let r = e.split("/"), a = r.length;
906
+ return r.some(wt) && (a += jr), t && (a += Dr), r.filter((o) => !wt(o)).reduce(
907
+ (o, i) => o + (Lr.test(i) ? Ir : i === "" ? Fr : Ar),
908
+ a
909
+ );
910
+ }
911
+ function Ur(e, t) {
912
+ return e.length === t.length && e.slice(0, -1).every((a, o) => a === t[o]) ? (
913
+ // If two routes are siblings, we should try to match the earlier sibling
914
+ // first. This allows people to have fine-grained control over the matching
915
+ // behavior by simply putting routes with identical paths in the order they
916
+ // want them tried.
917
+ e[e.length - 1] - t[t.length - 1]
918
+ ) : (
919
+ // Otherwise, it doesn't really make sense to rank non-siblings by index,
920
+ // so they sort equally.
921
+ 0
922
+ );
923
+ }
924
+ function Mr(e, t, r = !1) {
925
+ let { routesMeta: a } = e, o = {}, i = "/", l = [];
926
+ for (let f = 0; f < a.length; ++f) {
927
+ let u = a[f], m = f === a.length - 1, h = i === "/" ? t : t.slice(i.length) || "/", c = ve(
928
+ { path: u.relativePath, caseSensitive: u.caseSensitive, end: m },
929
+ h
930
+ ), v = u.route;
931
+ if (!c && m && r && !a[a.length - 1].route.index && (c = ve(
932
+ {
933
+ path: u.relativePath,
934
+ caseSensitive: u.caseSensitive,
935
+ end: !1
936
+ },
937
+ h
938
+ )), !c)
939
+ return null;
940
+ Object.assign(o, c.params), l.push({
941
+ // TODO: Can this as be avoided?
942
+ params: o,
943
+ pathname: H([i, c.pathname]),
944
+ pathnameBase: Kr(
945
+ H([i, c.pathnameBase])
946
+ ),
947
+ route: v
948
+ }), c.pathnameBase !== "/" && (i = H([i, c.pathnameBase]));
949
+ }
950
+ return l;
951
+ }
952
+ function ve(e, t) {
953
+ typeof e == "string" && (e = { path: e, caseSensitive: !1, end: !0 });
954
+ let [r, a] = Wr(
955
+ e.path,
956
+ e.caseSensitive,
957
+ e.end
958
+ ), o = t.match(r);
959
+ if (!o) return null;
960
+ let i = o[0], l = i.replace(/(.)\/+$/, "$1"), f = o.slice(1);
961
+ return {
962
+ params: a.reduce(
963
+ (m, { paramName: h, isOptional: c }, v) => {
964
+ if (h === "*") {
965
+ let w = f[v] || "";
966
+ l = i.slice(0, i.length - w.length).replace(/(.)\/+$/, "$1");
967
+ }
968
+ const E = f[v];
969
+ return c && !E ? m[h] = void 0 : m[h] = (E || "").replace(/%2F/g, "/"), m;
970
+ },
971
+ {}
972
+ ),
973
+ pathname: i,
974
+ pathnameBase: l,
975
+ pattern: e
976
+ };
977
+ }
978
+ function Wr(e, t = !1, r = !0) {
979
+ Y(
980
+ e === "*" || !e.endsWith("*") || e.endsWith("/*"),
981
+ `Route path "${e}" will be treated as if it were "${e.replace(/\*$/, "/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/, "/*")}".`
982
+ );
983
+ let a = [], o = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(
984
+ /\/:([\w-]+)(\?)?/g,
985
+ (l, f, u, m, h) => {
986
+ if (a.push({ paramName: f, isOptional: u != null }), u) {
987
+ let c = h.charAt(m + l.length);
988
+ return c && c !== "/" ? "/([^\\/]*)" : "(?:/([^\\/]*))?";
238
989
  }
990
+ return "/([^\\/]+)";
991
+ }
992
+ ).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
993
+ return e.endsWith("*") ? (a.push({ paramName: "*" }), o += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : r ? o += "\\/*$" : e !== "" && e !== "/" && (o += "(?:(?=\\/|$))"), [new RegExp(o, t ? void 0 : "i"), a];
994
+ }
995
+ function Br(e) {
996
+ try {
997
+ return e.split("/").map((t) => decodeURIComponent(t).replace(/\//g, "%2F")).join("/");
998
+ } catch (t) {
999
+ return Y(
1000
+ !1,
1001
+ `The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`
1002
+ ), e;
1003
+ }
1004
+ }
1005
+ function z(e, t) {
1006
+ if (t === "/") return e;
1007
+ if (!e.toLowerCase().startsWith(t.toLowerCase()))
1008
+ return null;
1009
+ let r = t.endsWith("/") ? t.length - 1 : t.length, a = e.charAt(r);
1010
+ return a && a !== "/" ? null : e.slice(r) || "/";
1011
+ }
1012
+ var Hr = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1013
+ function Vr(e, t = "/") {
1014
+ let {
1015
+ pathname: r,
1016
+ search: a = "",
1017
+ hash: o = ""
1018
+ } = typeof e == "string" ? Ne(e) : e, i;
1019
+ return r ? (r = r.replace(/\/\/+/g, "/"), r.startsWith("/") ? i = bt(r.substring(1), "/") : i = bt(r, t)) : i = t, {
1020
+ pathname: i,
1021
+ search: Jr(a),
1022
+ hash: zr(o)
1023
+ };
1024
+ }
1025
+ function bt(e, t) {
1026
+ let r = t.replace(/\/+$/, "").split("/");
1027
+ return e.split("/").forEach((o) => {
1028
+ o === ".." ? r.length > 1 && r.pop() : o !== "." && r.push(o);
1029
+ }), r.length > 1 ? r.join("/") : "/";
1030
+ }
1031
+ function Oe(e, t, r, a) {
1032
+ return `Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(
1033
+ a
1034
+ )}]. Please separate it out to the \`to.${r}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
1035
+ }
1036
+ function Yr(e) {
1037
+ return e.filter(
1038
+ (t, r) => r === 0 || t.route.path && t.route.path.length > 0
1039
+ );
1040
+ }
1041
+ function $t(e) {
1042
+ let t = Yr(e);
1043
+ return t.map(
1044
+ (r, a) => a === t.length - 1 ? r.pathname : r.pathnameBase
1045
+ );
1046
+ }
1047
+ function Ue(e, t, r, a = !1) {
1048
+ let o;
1049
+ typeof e == "string" ? o = Ne(e) : (o = { ...e }, $(
1050
+ !o.pathname || !o.pathname.includes("?"),
1051
+ Oe("?", "pathname", "search", o)
1052
+ ), $(
1053
+ !o.pathname || !o.pathname.includes("#"),
1054
+ Oe("#", "pathname", "hash", o)
1055
+ ), $(
1056
+ !o.search || !o.search.includes("#"),
1057
+ Oe("#", "search", "hash", o)
1058
+ ));
1059
+ let i = e === "" || o.pathname === "", l = i ? "/" : o.pathname, f;
1060
+ if (l == null)
1061
+ f = r;
1062
+ else {
1063
+ let c = t.length - 1;
1064
+ if (!a && l.startsWith("..")) {
1065
+ let v = l.split("/");
1066
+ for (; v[0] === ".."; )
1067
+ v.shift(), c -= 1;
1068
+ o.pathname = v.join("/");
1069
+ }
1070
+ f = c >= 0 ? t[c] : "/";
1071
+ }
1072
+ let u = Vr(o, f), m = l && l !== "/" && l.endsWith("/"), h = (i || l === ".") && r.endsWith("/");
1073
+ return !u.pathname.endsWith("/") && (m || h) && (u.pathname += "/"), u;
1074
+ }
1075
+ var H = (e) => e.join("/").replace(/\/\/+/g, "/"), Kr = (e) => e.replace(/\/+$/, "").replace(/^\/*/, "/"), Jr = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, zr = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e, qr = class {
1076
+ constructor(e, t, r, a = !1) {
1077
+ this.status = e, this.statusText = t || "", this.internal = a, r instanceof Error ? (this.data = r.toString(), this.error = r) : this.data = r;
1078
+ }
1079
+ };
1080
+ function Gr(e) {
1081
+ return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
1082
+ }
1083
+ function Xr(e) {
1084
+ return e.map((t) => t.route.path).filter(Boolean).join("/").replace(/\/\/*/g, "/") || "/";
1085
+ }
1086
+ var Lt = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
1087
+ function It(e, t) {
1088
+ let r = e;
1089
+ if (typeof r != "string" || !Hr.test(r))
1090
+ return {
1091
+ absoluteURL: void 0,
1092
+ isExternal: !1,
1093
+ to: r
239
1094
  };
240
- var C, N = {}, $ = b.react_stack_bottom_frame.bind(
241
- b,
242
- i
243
- )(), Y = g(f(i)), I = {};
244
- R.Fragment = w, R.jsx = function(e, r, t) {
245
- var n = 1e4 > k.recentlyCreatedOwnerStacks++;
246
- return m(
247
- e,
248
- r,
249
- t,
1095
+ let a = r, o = !1;
1096
+ if (Lt)
1097
+ try {
1098
+ let i = new URL(window.location.href), l = r.startsWith("//") ? new URL(i.protocol + r) : new URL(r), f = z(l.pathname, t);
1099
+ l.origin === i.origin && f != null ? r = f + l.search + l.hash : o = !0;
1100
+ } catch {
1101
+ Y(
250
1102
  !1,
251
- n ? Error("react-stack-top-frame") : $,
252
- n ? g(f(e)) : Y
1103
+ `<Link to="${r}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`
253
1104
  );
254
- }, R.jsxs = function(e, r, t) {
255
- var n = 1e4 > k.recentlyCreatedOwnerStacks++;
256
- return m(
257
- e,
258
- r,
259
- t,
260
- !0,
261
- n ? Error("react-stack-top-frame") : $,
262
- n ? g(f(e)) : Y
1105
+ }
1106
+ return {
1107
+ absoluteURL: a,
1108
+ isExternal: o,
1109
+ to: r
1110
+ };
1111
+ }
1112
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1113
+ var Dt = [
1114
+ "POST",
1115
+ "PUT",
1116
+ "PATCH",
1117
+ "DELETE"
1118
+ ];
1119
+ new Set(
1120
+ Dt
1121
+ );
1122
+ var Zr = [
1123
+ "GET",
1124
+ ...Dt
1125
+ ];
1126
+ new Set(Zr);
1127
+ var ee = s.createContext(null);
1128
+ ee.displayName = "DataRouter";
1129
+ var ge = s.createContext(null);
1130
+ ge.displayName = "DataRouterState";
1131
+ var Qr = s.createContext(!1), Ft = s.createContext({
1132
+ isTransitioning: !1
1133
+ });
1134
+ Ft.displayName = "ViewTransition";
1135
+ var en = s.createContext(
1136
+ /* @__PURE__ */ new Map()
1137
+ );
1138
+ en.displayName = "Fetchers";
1139
+ var tn = s.createContext(null);
1140
+ tn.displayName = "Await";
1141
+ var U = s.createContext(
1142
+ null
1143
+ );
1144
+ U.displayName = "Navigation";
1145
+ var Me = s.createContext(
1146
+ null
1147
+ );
1148
+ Me.displayName = "Location";
1149
+ var V = s.createContext({
1150
+ outlet: null,
1151
+ matches: [],
1152
+ isDataRoute: !1
1153
+ });
1154
+ V.displayName = "Route";
1155
+ var We = s.createContext(null);
1156
+ We.displayName = "RouteError";
1157
+ var At = "REACT_ROUTER_ERROR", rn = "REDIRECT", nn = "ROUTE_ERROR_RESPONSE";
1158
+ function an(e) {
1159
+ if (e.startsWith(`${At}:${rn}:{`))
1160
+ try {
1161
+ let t = JSON.parse(e.slice(28));
1162
+ if (typeof t == "object" && t && typeof t.status == "number" && typeof t.statusText == "string" && typeof t.location == "string" && typeof t.reloadDocument == "boolean" && typeof t.replace == "boolean")
1163
+ return t;
1164
+ } catch {
1165
+ }
1166
+ }
1167
+ function on(e) {
1168
+ if (e.startsWith(
1169
+ `${At}:${nn}:{`
1170
+ ))
1171
+ try {
1172
+ let t = JSON.parse(e.slice(40));
1173
+ if (typeof t == "object" && t && typeof t.status == "number" && typeof t.statusText == "string")
1174
+ return new qr(
1175
+ t.status,
1176
+ t.statusText,
1177
+ t.data
1178
+ );
1179
+ } catch {
1180
+ }
1181
+ }
1182
+ function ln(e, { relative: t } = {}) {
1183
+ $(
1184
+ ye(),
1185
+ // TODO: This error is probably because they somehow have 2 versions of the
1186
+ // router loaded. We can help them understand how to avoid that.
1187
+ "useHref() may be used only in the context of a <Router> component."
1188
+ );
1189
+ let { basename: r, navigator: a } = s.useContext(U), { hash: o, pathname: i, search: l } = ie(e, { relative: t }), f = i;
1190
+ return r !== "/" && (f = i === "/" ? r : H([r, i])), a.createHref({ pathname: f, search: l, hash: o });
1191
+ }
1192
+ function ye() {
1193
+ return s.useContext(Me) != null;
1194
+ }
1195
+ function q() {
1196
+ return $(
1197
+ ye(),
1198
+ // TODO: This error is probably because they somehow have 2 versions of the
1199
+ // router loaded. We can help them understand how to avoid that.
1200
+ "useLocation() may be used only in the context of a <Router> component."
1201
+ ), s.useContext(Me).location;
1202
+ }
1203
+ var jt = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
1204
+ function Nt(e) {
1205
+ s.useContext(U).static || s.useLayoutEffect(e);
1206
+ }
1207
+ function sn() {
1208
+ let { isDataRoute: e } = s.useContext(V);
1209
+ return e ? Sn() : un();
1210
+ }
1211
+ function un() {
1212
+ $(
1213
+ ye(),
1214
+ // TODO: This error is probably because they somehow have 2 versions of the
1215
+ // router loaded. We can help them understand how to avoid that.
1216
+ "useNavigate() may be used only in the context of a <Router> component."
1217
+ );
1218
+ let e = s.useContext(ee), { basename: t, navigator: r } = s.useContext(U), { matches: a } = s.useContext(V), { pathname: o } = q(), i = JSON.stringify($t(a)), l = s.useRef(!1);
1219
+ return Nt(() => {
1220
+ l.current = !0;
1221
+ }), s.useCallback(
1222
+ (u, m = {}) => {
1223
+ if (Y(l.current, jt), !l.current) return;
1224
+ if (typeof u == "number") {
1225
+ r.go(u);
1226
+ return;
1227
+ }
1228
+ let h = Ue(
1229
+ u,
1230
+ JSON.parse(i),
1231
+ o,
1232
+ m.relative === "path"
263
1233
  );
1234
+ e == null && t !== "/" && (h.pathname = h.pathname === "/" ? t : H([t, h.pathname])), (m.replace ? r.replace : r.push)(
1235
+ h,
1236
+ m.state,
1237
+ m
1238
+ );
1239
+ },
1240
+ [
1241
+ t,
1242
+ r,
1243
+ i,
1244
+ o,
1245
+ e
1246
+ ]
1247
+ );
1248
+ }
1249
+ var cn = s.createContext(null);
1250
+ function fn(e) {
1251
+ let t = s.useContext(V).outlet;
1252
+ return s.useMemo(
1253
+ () => t && /* @__PURE__ */ s.createElement(cn.Provider, { value: e }, t),
1254
+ [t, e]
1255
+ );
1256
+ }
1257
+ function ie(e, { relative: t } = {}) {
1258
+ let { matches: r } = s.useContext(V), { pathname: a } = q(), o = JSON.stringify($t(r));
1259
+ return s.useMemo(
1260
+ () => Ue(
1261
+ e,
1262
+ JSON.parse(o),
1263
+ a,
1264
+ t === "path"
1265
+ ),
1266
+ [e, o, a, t]
1267
+ );
1268
+ }
1269
+ function dn(e, t, r) {
1270
+ $(
1271
+ ye(),
1272
+ // TODO: This error is probably because they somehow have 2 versions of the
1273
+ // router loaded. We can help them understand how to avoid that.
1274
+ "useRoutes() may be used only in the context of a <Router> component."
1275
+ );
1276
+ let { navigator: a } = s.useContext(U), { matches: o } = s.useContext(V), i = o[o.length - 1], l = i ? i.params : {}, f = i ? i.pathname : "/", u = i ? i.pathnameBase : "/", m = i && i.route;
1277
+ {
1278
+ let y = m && m.path || "";
1279
+ Mt(
1280
+ f,
1281
+ !m || y.endsWith("*") || y.endsWith("*?"),
1282
+ `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${f}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
1283
+
1284
+ Please change the parent <Route path="${y}"> to <Route path="${y === "/" ? "*" : `${y}/*`}">.`
1285
+ );
1286
+ }
1287
+ let h = q(), c;
1288
+ c = h;
1289
+ let v = c.pathname || "/", E = v;
1290
+ if (u !== "/") {
1291
+ let y = u.replace(/^\//, "").split("/");
1292
+ E = "/" + v.replace(/^\//, "").split("/").slice(y.length).join("/");
1293
+ }
1294
+ let w = Tt(e, { pathname: E });
1295
+ return Y(
1296
+ m || w != null,
1297
+ `No routes matched location "${c.pathname}${c.search}${c.hash}" `
1298
+ ), Y(
1299
+ w == null || w[w.length - 1].route.element !== void 0 || w[w.length - 1].route.Component !== void 0 || w[w.length - 1].route.lazy !== void 0,
1300
+ `Matched leaf route at location "${c.pathname}${c.search}${c.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`
1301
+ ), gn(
1302
+ w && w.map(
1303
+ (y) => Object.assign({}, y, {
1304
+ params: Object.assign({}, l, y.params),
1305
+ pathname: H([
1306
+ u,
1307
+ // Re-encode pathnames that were decoded inside matchRoutes.
1308
+ // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
1309
+ // `new URL()` internally and we need to prevent it from treating
1310
+ // them as separators
1311
+ a.encodeLocation ? a.encodeLocation(
1312
+ y.pathname.replace(/\?/g, "%3F").replace(/#/g, "%23")
1313
+ ).pathname : y.pathname
1314
+ ]),
1315
+ pathnameBase: y.pathnameBase === "/" ? u : H([
1316
+ u,
1317
+ // Re-encode pathnames that were decoded inside matchRoutes
1318
+ // Pre-encode `?` and `#` ahead of `encodeLocation` because it uses
1319
+ // `new URL()` internally and we need to prevent it from treating
1320
+ // them as separators
1321
+ a.encodeLocation ? a.encodeLocation(
1322
+ y.pathnameBase.replace(/\?/g, "%3F").replace(/#/g, "%23")
1323
+ ).pathname : y.pathnameBase
1324
+ ])
1325
+ })
1326
+ ),
1327
+ o,
1328
+ r
1329
+ );
1330
+ }
1331
+ function hn() {
1332
+ let e = bn(), t = Gr(e) ? `${e.status} ${e.statusText}` : e instanceof Error ? e.message : JSON.stringify(e), r = e instanceof Error ? e.stack : null, a = "rgba(200,200,200, 0.5)", o = { padding: "0.5rem", backgroundColor: a }, i = { padding: "2px 4px", backgroundColor: a }, l = null;
1333
+ return console.error(
1334
+ "Error handled by React Router default ErrorBoundary:",
1335
+ e
1336
+ ), l = /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ s.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ s.createElement("code", { style: i }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ s.createElement("code", { style: i }, "errorElement"), " prop on your route.")), /* @__PURE__ */ s.createElement(s.Fragment, null, /* @__PURE__ */ s.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ s.createElement("h3", { style: { fontStyle: "italic" } }, t), r ? /* @__PURE__ */ s.createElement("pre", { style: o }, r) : null, l);
1337
+ }
1338
+ var mn = /* @__PURE__ */ s.createElement(hn, null), Ut = class extends s.Component {
1339
+ constructor(e) {
1340
+ super(e), this.state = {
1341
+ location: e.location,
1342
+ revalidation: e.revalidation,
1343
+ error: e.error
1344
+ };
1345
+ }
1346
+ static getDerivedStateFromError(e) {
1347
+ return { error: e };
1348
+ }
1349
+ static getDerivedStateFromProps(e, t) {
1350
+ return t.location !== e.location || t.revalidation !== "idle" && e.revalidation === "idle" ? {
1351
+ error: e.error,
1352
+ location: e.location,
1353
+ revalidation: e.revalidation
1354
+ } : {
1355
+ error: e.error !== void 0 ? e.error : t.error,
1356
+ location: t.location,
1357
+ revalidation: e.revalidation || t.revalidation
264
1358
  };
265
- })()), R;
266
- }
267
- var L;
268
- function ie() {
269
- return L || (L = 1, process.env.NODE_ENV === "production" ? T.exports = ue() : T.exports = le()), T.exports;
270
- }
271
- var ce = ie();
272
- function me({
273
- children: a,
274
- authUrl: s,
275
- authFrontendUrl: u,
276
- appId: f
1359
+ }
1360
+ componentDidCatch(e, t) {
1361
+ this.props.onError ? this.props.onError(e, t) : console.error(
1362
+ "React Router caught the following error during render",
1363
+ e
1364
+ );
1365
+ }
1366
+ render() {
1367
+ let e = this.state.error;
1368
+ if (this.context && typeof e == "object" && e && "digest" in e && typeof e.digest == "string") {
1369
+ const r = on(e.digest);
1370
+ r && (e = r);
1371
+ }
1372
+ let t = e !== void 0 ? /* @__PURE__ */ s.createElement(V.Provider, { value: this.props.routeContext }, /* @__PURE__ */ s.createElement(
1373
+ We.Provider,
1374
+ {
1375
+ value: e,
1376
+ children: this.props.component
1377
+ }
1378
+ )) : this.props.children;
1379
+ return this.context ? /* @__PURE__ */ s.createElement(pn, { error: e }, t) : t;
1380
+ }
1381
+ };
1382
+ Ut.contextType = Qr;
1383
+ var $e = /* @__PURE__ */ new WeakMap();
1384
+ function pn({
1385
+ children: e,
1386
+ error: t
277
1387
  }) {
278
- const [l, i] = oe({
279
- loading: !0,
280
- isAuthenticated: !1,
281
- user: null
282
- }), d = () => {
283
- const E = encodeURIComponent(window.location.href);
284
- let m = `${u}/login?next=${E}`;
285
- f && (m += `&app=${f}`), window.location.href = m;
286
- }, c = ae(async () => {
1388
+ let { basename: r } = s.useContext(U);
1389
+ if (typeof t == "object" && t && "digest" in t && typeof t.digest == "string") {
1390
+ let a = an(t.digest);
1391
+ if (a) {
1392
+ let o = $e.get(t);
1393
+ if (o) throw o;
1394
+ let i = It(a.location, r);
1395
+ if (Lt && !$e.get(t))
1396
+ if (i.isExternal || a.reloadDocument)
1397
+ window.location.href = i.absoluteURL || i.to;
1398
+ else {
1399
+ const l = Promise.resolve().then(
1400
+ () => window.__reactRouterDataRouter.navigate(i.to, {
1401
+ replace: a.replace
1402
+ })
1403
+ );
1404
+ throw $e.set(t, l), l;
1405
+ }
1406
+ return /* @__PURE__ */ s.createElement(
1407
+ "meta",
1408
+ {
1409
+ httpEquiv: "refresh",
1410
+ content: `0;url=${i.absoluteURL || i.to}`
1411
+ }
1412
+ );
1413
+ }
1414
+ }
1415
+ return e;
1416
+ }
1417
+ function vn({ routeContext: e, match: t, children: r }) {
1418
+ let a = s.useContext(ee);
1419
+ return a && a.static && a.staticContext && (t.route.errorElement || t.route.ErrorBoundary) && (a.staticContext._deepestRenderedBoundaryId = t.route.id), /* @__PURE__ */ s.createElement(V.Provider, { value: e }, r);
1420
+ }
1421
+ function gn(e, t = [], r) {
1422
+ let a = r?.state;
1423
+ if (e == null) {
1424
+ if (!a)
1425
+ return null;
1426
+ if (a.errors)
1427
+ e = a.matches;
1428
+ else if (t.length === 0 && !a.initialized && a.matches.length > 0)
1429
+ e = a.matches;
1430
+ else
1431
+ return null;
1432
+ }
1433
+ let o = e, i = a?.errors;
1434
+ if (i != null) {
1435
+ let h = o.findIndex(
1436
+ (c) => c.route.id && i?.[c.route.id] !== void 0
1437
+ );
1438
+ $(
1439
+ h >= 0,
1440
+ `Could not find a matching route for errors on route IDs: ${Object.keys(
1441
+ i
1442
+ ).join(",")}`
1443
+ ), o = o.slice(
1444
+ 0,
1445
+ Math.min(o.length, h + 1)
1446
+ );
1447
+ }
1448
+ let l = !1, f = -1;
1449
+ if (r && a) {
1450
+ l = a.renderFallback;
1451
+ for (let h = 0; h < o.length; h++) {
1452
+ let c = o[h];
1453
+ if ((c.route.HydrateFallback || c.route.hydrateFallbackElement) && (f = h), c.route.id) {
1454
+ let { loaderData: v, errors: E } = a, w = c.route.loader && !v.hasOwnProperty(c.route.id) && (!E || E[c.route.id] === void 0);
1455
+ if (c.route.lazy || w) {
1456
+ r.isStatic && (l = !0), f >= 0 ? o = o.slice(0, f + 1) : o = [o[0]];
1457
+ break;
1458
+ }
1459
+ }
1460
+ }
1461
+ }
1462
+ let u = r?.onError, m = a && u ? (h, c) => {
1463
+ u(h, {
1464
+ location: a.location,
1465
+ params: a.matches?.[0]?.params ?? {},
1466
+ unstable_pattern: Xr(a.matches),
1467
+ errorInfo: c
1468
+ });
1469
+ } : void 0;
1470
+ return o.reduceRight(
1471
+ (h, c, v) => {
1472
+ let E, w = !1, x = null, y = null;
1473
+ a && (E = i && c.route.id ? i[c.route.id] : void 0, x = c.route.errorElement || mn, l && (f < 0 && v === 0 ? (Mt(
1474
+ "route-fallback",
1475
+ !1,
1476
+ "No `HydrateFallback` element provided to render during initial hydration"
1477
+ ), w = !0, y = null) : f === v && (w = !0, y = c.route.hydrateFallbackElement || null)));
1478
+ let C = t.concat(o.slice(0, v + 1)), R = () => {
1479
+ let P;
1480
+ return E ? P = x : w ? P = y : c.route.Component ? P = /* @__PURE__ */ s.createElement(c.route.Component, null) : c.route.element ? P = c.route.element : P = h, /* @__PURE__ */ s.createElement(
1481
+ vn,
1482
+ {
1483
+ match: c,
1484
+ routeContext: {
1485
+ outlet: h,
1486
+ matches: C,
1487
+ isDataRoute: a != null
1488
+ },
1489
+ children: P
1490
+ }
1491
+ );
1492
+ };
1493
+ return a && (c.route.ErrorBoundary || c.route.errorElement || v === 0) ? /* @__PURE__ */ s.createElement(
1494
+ Ut,
1495
+ {
1496
+ location: a.location,
1497
+ revalidation: a.revalidation,
1498
+ component: x,
1499
+ error: E,
1500
+ children: R(),
1501
+ routeContext: { outlet: null, matches: C, isDataRoute: !0 },
1502
+ onError: m
1503
+ }
1504
+ ) : R();
1505
+ },
1506
+ null
1507
+ );
1508
+ }
1509
+ function Be(e) {
1510
+ return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
1511
+ }
1512
+ function yn(e) {
1513
+ let t = s.useContext(ee);
1514
+ return $(t, Be(e)), t;
1515
+ }
1516
+ function Rn(e) {
1517
+ let t = s.useContext(ge);
1518
+ return $(t, Be(e)), t;
1519
+ }
1520
+ function En(e) {
1521
+ let t = s.useContext(V);
1522
+ return $(t, Be(e)), t;
1523
+ }
1524
+ function He(e) {
1525
+ let t = En(e), r = t.matches[t.matches.length - 1];
1526
+ return $(
1527
+ r.route.id,
1528
+ `${e} can only be used on routes that contain a unique "id"`
1529
+ ), r.route.id;
1530
+ }
1531
+ function wn() {
1532
+ return He(
1533
+ "useRouteId"
1534
+ /* UseRouteId */
1535
+ );
1536
+ }
1537
+ function bn() {
1538
+ let e = s.useContext(We), t = Rn(
1539
+ "useRouteError"
1540
+ /* UseRouteError */
1541
+ ), r = He(
1542
+ "useRouteError"
1543
+ /* UseRouteError */
1544
+ );
1545
+ return e !== void 0 ? e : t.errors?.[r];
1546
+ }
1547
+ function Sn() {
1548
+ let { router: e } = yn(
1549
+ "useNavigate"
1550
+ /* UseNavigateStable */
1551
+ ), t = He(
1552
+ "useNavigate"
1553
+ /* UseNavigateStable */
1554
+ ), r = s.useRef(!1);
1555
+ return Nt(() => {
1556
+ r.current = !0;
1557
+ }), s.useCallback(
1558
+ async (o, i = {}) => {
1559
+ Y(r.current, jt), r.current && (typeof o == "number" ? await e.navigate(o) : await e.navigate(o, { fromRouteId: t, ...i }));
1560
+ },
1561
+ [e, t]
1562
+ );
1563
+ }
1564
+ var St = {};
1565
+ function Mt(e, t, r) {
1566
+ !t && !St[e] && (St[e] = !0, Y(!1, r));
1567
+ }
1568
+ s.memo(xn);
1569
+ function xn({
1570
+ routes: e,
1571
+ future: t,
1572
+ state: r,
1573
+ isStatic: a,
1574
+ onError: o
1575
+ }) {
1576
+ return dn(e, void 0, { state: r, isStatic: a, onError: o });
1577
+ }
1578
+ function Wt(e) {
1579
+ return fn(e.context);
1580
+ }
1581
+ var me = "get", pe = "application/x-www-form-urlencoded";
1582
+ function Re(e) {
1583
+ return typeof HTMLElement < "u" && e instanceof HTMLElement;
1584
+ }
1585
+ function Cn(e) {
1586
+ return Re(e) && e.tagName.toLowerCase() === "button";
1587
+ }
1588
+ function _n(e) {
1589
+ return Re(e) && e.tagName.toLowerCase() === "form";
1590
+ }
1591
+ function Pn(e) {
1592
+ return Re(e) && e.tagName.toLowerCase() === "input";
1593
+ }
1594
+ function Tn(e) {
1595
+ return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
1596
+ }
1597
+ function kn(e, t) {
1598
+ return e.button === 0 && // Ignore everything but left clicks
1599
+ (!t || t === "_self") && // Let browser handle "target=_blank" etc.
1600
+ !Tn(e);
1601
+ }
1602
+ var he = null;
1603
+ function On() {
1604
+ if (he === null)
287
1605
  try {
288
- const E = await fetch(`${s}/sso/me`, {
289
- credentials: "include"
290
- });
291
- if (!E.ok) throw new Error("unauthorized");
292
- const m = await E.json();
293
- i({
294
- loading: !1,
295
- isAuthenticated: !0,
296
- user: m
297
- });
1606
+ new FormData(
1607
+ document.createElement("form"),
1608
+ // @ts-expect-error if FormData supports the submitter parameter, this will throw
1609
+ 0
1610
+ ), he = !1;
298
1611
  } catch {
299
- i({
300
- loading: !1,
301
- isAuthenticated: !1,
302
- user: null
303
- }), d();
304
- }
305
- }, [s]), h = async () => {
306
- await fetch(`${s}/sso/logout`, {
307
- credentials: "include"
308
- }), d();
1612
+ he = !0;
1613
+ }
1614
+ return he;
1615
+ }
1616
+ var $n = /* @__PURE__ */ new Set([
1617
+ "application/x-www-form-urlencoded",
1618
+ "multipart/form-data",
1619
+ "text/plain"
1620
+ ]);
1621
+ function Le(e) {
1622
+ return e != null && !$n.has(e) ? (Y(
1623
+ !1,
1624
+ `"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${pe}"`
1625
+ ), null) : e;
1626
+ }
1627
+ function Ln(e, t) {
1628
+ let r, a, o, i, l;
1629
+ if (_n(e)) {
1630
+ let f = e.getAttribute("action");
1631
+ a = f ? z(f, t) : null, r = e.getAttribute("method") || me, o = Le(e.getAttribute("enctype")) || pe, i = new FormData(e);
1632
+ } else if (Cn(e) || Pn(e) && (e.type === "submit" || e.type === "image")) {
1633
+ let f = e.form;
1634
+ if (f == null)
1635
+ throw new Error(
1636
+ 'Cannot submit a <button> or <input type="submit"> without a <form>'
1637
+ );
1638
+ let u = e.getAttribute("formaction") || f.getAttribute("action");
1639
+ if (a = u ? z(u, t) : null, r = e.getAttribute("formmethod") || f.getAttribute("method") || me, o = Le(e.getAttribute("formenctype")) || Le(f.getAttribute("enctype")) || pe, i = new FormData(f, e), !On()) {
1640
+ let { name: m, type: h, value: c } = e;
1641
+ if (h === "image") {
1642
+ let v = m ? `${m}.` : "";
1643
+ i.append(`${v}x`, "0"), i.append(`${v}y`, "0");
1644
+ } else m && i.append(m, c);
1645
+ }
1646
+ } else {
1647
+ if (Re(e))
1648
+ throw new Error(
1649
+ 'Cannot submit element that is not <form>, <button>, or <input type="submit|image">'
1650
+ );
1651
+ r = me, a = null, o = pe, l = e;
1652
+ }
1653
+ return i && o === "text/plain" && (l = i, i = void 0), { action: a, method: r.toLowerCase(), encType: o, formData: i, body: l };
1654
+ }
1655
+ Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
1656
+ function Ve(e, t) {
1657
+ if (e === !1 || e === null || typeof e > "u")
1658
+ throw new Error(t);
1659
+ }
1660
+ function In(e, t, r, a) {
1661
+ let o = typeof e == "string" ? new URL(
1662
+ e,
1663
+ // This can be called during the SSR flow via PrefetchPageLinksImpl so
1664
+ // don't assume window is available
1665
+ typeof window > "u" ? "server://singlefetch/" : window.location.origin
1666
+ ) : e;
1667
+ return r ? o.pathname.endsWith("/") ? o.pathname = `${o.pathname}_.${a}` : o.pathname = `${o.pathname}.${a}` : o.pathname === "/" ? o.pathname = `_root.${a}` : t && z(o.pathname, t) === "/" ? o.pathname = `${t.replace(/\/$/, "")}/_root.${a}` : o.pathname = `${o.pathname.replace(/\/$/, "")}.${a}`, o;
1668
+ }
1669
+ async function Dn(e, t) {
1670
+ if (e.id in t)
1671
+ return t[e.id];
1672
+ try {
1673
+ let r = await import(
1674
+ /* @vite-ignore */
1675
+ /* webpackIgnore: true */
1676
+ e.module
1677
+ );
1678
+ return t[e.id] = r, r;
1679
+ } catch (r) {
1680
+ return console.error(
1681
+ `Error loading route module \`${e.module}\`, reloading page...`
1682
+ ), console.error(r), window.__reactRouterContext && window.__reactRouterContext.isSpaMode, window.location.reload(), new Promise(() => {
1683
+ });
1684
+ }
1685
+ }
1686
+ function Fn(e) {
1687
+ return e == null ? !1 : e.href == null ? e.rel === "preload" && typeof e.imageSrcSet == "string" && typeof e.imageSizes == "string" : typeof e.rel == "string" && typeof e.href == "string";
1688
+ }
1689
+ async function An(e, t, r) {
1690
+ let a = await Promise.all(
1691
+ e.map(async (o) => {
1692
+ let i = t.routes[o.route.id];
1693
+ if (i) {
1694
+ let l = await Dn(i, r);
1695
+ return l.links ? l.links() : [];
1696
+ }
1697
+ return [];
1698
+ })
1699
+ );
1700
+ return Mn(
1701
+ a.flat(1).filter(Fn).filter((o) => o.rel === "stylesheet" || o.rel === "preload").map(
1702
+ (o) => o.rel === "stylesheet" ? { ...o, rel: "prefetch", as: "style" } : { ...o, rel: "prefetch" }
1703
+ )
1704
+ );
1705
+ }
1706
+ function xt(e, t, r, a, o, i) {
1707
+ let l = (u, m) => r[m] ? u.route.id !== r[m].route.id : !0, f = (u, m) => (
1708
+ // param change, /users/123 -> /users/456
1709
+ r[m].pathname !== u.pathname || // splat param changed, which is not present in match.path
1710
+ // e.g. /files/images/avatar.jpg -> files/finances.xls
1711
+ r[m].route.path?.endsWith("*") && r[m].params["*"] !== u.params["*"]
1712
+ );
1713
+ return i === "assets" ? t.filter(
1714
+ (u, m) => l(u, m) || f(u, m)
1715
+ ) : i === "data" ? t.filter((u, m) => {
1716
+ let h = a.routes[u.route.id];
1717
+ if (!h || !h.hasLoader)
1718
+ return !1;
1719
+ if (l(u, m) || f(u, m))
1720
+ return !0;
1721
+ if (u.route.shouldRevalidate) {
1722
+ let c = u.route.shouldRevalidate({
1723
+ currentUrl: new URL(
1724
+ o.pathname + o.search + o.hash,
1725
+ window.origin
1726
+ ),
1727
+ currentParams: r[0]?.params || {},
1728
+ nextUrl: new URL(e, window.origin),
1729
+ nextParams: u.params,
1730
+ defaultShouldRevalidate: !0
1731
+ });
1732
+ if (typeof c == "boolean")
1733
+ return c;
1734
+ }
1735
+ return !0;
1736
+ }) : [];
1737
+ }
1738
+ function jn(e, t, { includeHydrateFallback: r } = {}) {
1739
+ return Nn(
1740
+ e.map((a) => {
1741
+ let o = t.routes[a.route.id];
1742
+ if (!o) return [];
1743
+ let i = [o.module];
1744
+ return o.clientActionModule && (i = i.concat(o.clientActionModule)), o.clientLoaderModule && (i = i.concat(o.clientLoaderModule)), r && o.hydrateFallbackModule && (i = i.concat(o.hydrateFallbackModule)), o.imports && (i = i.concat(o.imports)), i;
1745
+ }).flat(1)
1746
+ );
1747
+ }
1748
+ function Nn(e) {
1749
+ return [...new Set(e)];
1750
+ }
1751
+ function Un(e) {
1752
+ let t = {}, r = Object.keys(e).sort();
1753
+ for (let a of r)
1754
+ t[a] = e[a];
1755
+ return t;
1756
+ }
1757
+ function Mn(e, t) {
1758
+ let r = /* @__PURE__ */ new Set();
1759
+ return new Set(t), e.reduce((a, o) => {
1760
+ let i = JSON.stringify(Un(o));
1761
+ return r.has(i) || (r.add(i), a.push({ key: i, link: o })), a;
1762
+ }, []);
1763
+ }
1764
+ function Bt() {
1765
+ let e = s.useContext(ee);
1766
+ return Ve(
1767
+ e,
1768
+ "You must render this element inside a <DataRouterContext.Provider> element"
1769
+ ), e;
1770
+ }
1771
+ function Wn() {
1772
+ let e = s.useContext(ge);
1773
+ return Ve(
1774
+ e,
1775
+ "You must render this element inside a <DataRouterStateContext.Provider> element"
1776
+ ), e;
1777
+ }
1778
+ var Ye = s.createContext(void 0);
1779
+ Ye.displayName = "FrameworkContext";
1780
+ function Ht() {
1781
+ let e = s.useContext(Ye);
1782
+ return Ve(
1783
+ e,
1784
+ "You must render this element inside a <HydratedRouter> element"
1785
+ ), e;
1786
+ }
1787
+ function Bn(e, t) {
1788
+ let r = s.useContext(Ye), [a, o] = s.useState(!1), [i, l] = s.useState(!1), { onFocus: f, onBlur: u, onMouseEnter: m, onMouseLeave: h, onTouchStart: c } = t, v = s.useRef(null);
1789
+ s.useEffect(() => {
1790
+ if (e === "render" && l(!0), e === "viewport") {
1791
+ let x = (C) => {
1792
+ C.forEach((R) => {
1793
+ l(R.isIntersecting);
1794
+ });
1795
+ }, y = new IntersectionObserver(x, { threshold: 0.5 });
1796
+ return v.current && y.observe(v.current), () => {
1797
+ y.disconnect();
1798
+ };
1799
+ }
1800
+ }, [e]), s.useEffect(() => {
1801
+ if (a) {
1802
+ let x = setTimeout(() => {
1803
+ l(!0);
1804
+ }, 100);
1805
+ return () => {
1806
+ clearTimeout(x);
1807
+ };
1808
+ }
1809
+ }, [a]);
1810
+ let E = () => {
1811
+ o(!0);
1812
+ }, w = () => {
1813
+ o(!1), l(!1);
309
1814
  };
310
- return se(() => {
311
- c();
312
- }, [c]), /* @__PURE__ */ ce.jsx(
313
- M.Provider,
1815
+ return r ? e !== "intent" ? [i, v, {}] : [
1816
+ i,
1817
+ v,
314
1818
  {
315
- value: {
316
- ...l,
317
- refresh: c,
318
- logout: h,
319
- login: () => Promise.resolve()
1819
+ onFocus: oe(f, E),
1820
+ onBlur: oe(u, w),
1821
+ onMouseEnter: oe(m, E),
1822
+ onMouseLeave: oe(h, w),
1823
+ onTouchStart: oe(c, E)
1824
+ }
1825
+ ] : [!1, v, {}];
1826
+ }
1827
+ function oe(e, t) {
1828
+ return (r) => {
1829
+ e && e(r), r.defaultPrevented || t(r);
1830
+ };
1831
+ }
1832
+ function Hn({ page: e, ...t }) {
1833
+ let { router: r } = Bt(), a = s.useMemo(
1834
+ () => Tt(r.routes, e, r.basename),
1835
+ [r.routes, e, r.basename]
1836
+ );
1837
+ return a ? /* @__PURE__ */ s.createElement(Yn, { page: e, matches: a, ...t }) : null;
1838
+ }
1839
+ function Vn(e) {
1840
+ let { manifest: t, routeModules: r } = Ht(), [a, o] = s.useState([]);
1841
+ return s.useEffect(() => {
1842
+ let i = !1;
1843
+ return An(e, t, r).then(
1844
+ (l) => {
1845
+ i || o(l);
1846
+ }
1847
+ ), () => {
1848
+ i = !0;
1849
+ };
1850
+ }, [e, t, r]), a;
1851
+ }
1852
+ function Yn({
1853
+ page: e,
1854
+ matches: t,
1855
+ ...r
1856
+ }) {
1857
+ let a = q(), { future: o, manifest: i, routeModules: l } = Ht(), { basename: f } = Bt(), { loaderData: u, matches: m } = Wn(), h = s.useMemo(
1858
+ () => xt(
1859
+ e,
1860
+ t,
1861
+ m,
1862
+ i,
1863
+ a,
1864
+ "data"
1865
+ ),
1866
+ [e, t, m, i, a]
1867
+ ), c = s.useMemo(
1868
+ () => xt(
1869
+ e,
1870
+ t,
1871
+ m,
1872
+ i,
1873
+ a,
1874
+ "assets"
1875
+ ),
1876
+ [e, t, m, i, a]
1877
+ ), v = s.useMemo(() => {
1878
+ if (e === a.pathname + a.search + a.hash)
1879
+ return [];
1880
+ let x = /* @__PURE__ */ new Set(), y = !1;
1881
+ if (t.forEach((R) => {
1882
+ let P = i.routes[R.route.id];
1883
+ !P || !P.hasLoader || (!h.some((j) => j.route.id === R.route.id) && R.route.id in u && l[R.route.id]?.shouldRevalidate || P.hasClientLoader ? y = !0 : x.add(R.route.id));
1884
+ }), x.size === 0)
1885
+ return [];
1886
+ let C = In(
1887
+ e,
1888
+ f,
1889
+ o.unstable_trailingSlashAwareDataRequests,
1890
+ "data"
1891
+ );
1892
+ return y && x.size > 0 && C.searchParams.set(
1893
+ "_routes",
1894
+ t.filter((R) => x.has(R.route.id)).map((R) => R.route.id).join(",")
1895
+ ), [C.pathname + C.search];
1896
+ }, [
1897
+ f,
1898
+ o.unstable_trailingSlashAwareDataRequests,
1899
+ u,
1900
+ a,
1901
+ i,
1902
+ h,
1903
+ t,
1904
+ e,
1905
+ l
1906
+ ]), E = s.useMemo(
1907
+ () => jn(c, i),
1908
+ [c, i]
1909
+ ), w = Vn(c);
1910
+ return /* @__PURE__ */ s.createElement(s.Fragment, null, v.map((x) => /* @__PURE__ */ s.createElement("link", { key: x, rel: "prefetch", as: "fetch", href: x, ...r })), E.map((x) => /* @__PURE__ */ s.createElement("link", { key: x, rel: "modulepreload", href: x, ...r })), w.map(({ key: x, link: y }) => (
1911
+ // these don't spread `linkProps` because they are full link descriptors
1912
+ // already with their own props
1913
+ /* @__PURE__ */ s.createElement(
1914
+ "link",
1915
+ {
1916
+ key: x,
1917
+ nonce: r.nonce,
1918
+ ...y,
1919
+ crossOrigin: y.crossOrigin ?? r.crossOrigin
1920
+ }
1921
+ )
1922
+ )));
1923
+ }
1924
+ function Kn(...e) {
1925
+ return (t) => {
1926
+ e.forEach((r) => {
1927
+ typeof r == "function" ? r(t) : r != null && (r.current = t);
1928
+ });
1929
+ };
1930
+ }
1931
+ var Jn = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u";
1932
+ try {
1933
+ Jn && (window.__reactRouterVersion = // @ts-expect-error
1934
+ "7.13.1");
1935
+ } catch {
1936
+ }
1937
+ var Vt = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i, Yt = s.forwardRef(
1938
+ function({
1939
+ onClick: t,
1940
+ discover: r = "render",
1941
+ prefetch: a = "none",
1942
+ relative: o,
1943
+ reloadDocument: i,
1944
+ replace: l,
1945
+ unstable_mask: f,
1946
+ state: u,
1947
+ target: m,
1948
+ to: h,
1949
+ preventScrollReset: c,
1950
+ viewTransition: v,
1951
+ unstable_defaultShouldRevalidate: E,
1952
+ ...w
1953
+ }, x) {
1954
+ let { basename: y, navigator: C, unstable_useTransitions: R } = s.useContext(U), P = typeof h == "string" && Vt.test(h), j = It(h, y);
1955
+ h = j.to;
1956
+ let I = ln(h, { relative: o }), M = q(), W = null;
1957
+ if (f) {
1958
+ let D = Ue(
1959
+ f,
1960
+ [],
1961
+ M.unstable_mask ? M.unstable_mask.pathname : "/",
1962
+ !0
1963
+ );
1964
+ y !== "/" && (D.pathname = D.pathname === "/" ? y : H([y, D.pathname])), W = C.createHref(D);
1965
+ }
1966
+ let [K, J, te] = Bn(
1967
+ a,
1968
+ w
1969
+ ), Ee = Xn(h, {
1970
+ replace: l,
1971
+ unstable_mask: f,
1972
+ state: u,
1973
+ target: m,
1974
+ preventScrollReset: c,
1975
+ relative: o,
1976
+ viewTransition: v,
1977
+ unstable_defaultShouldRevalidate: E,
1978
+ unstable_useTransitions: R
1979
+ });
1980
+ function le(D) {
1981
+ t && t(D), D.defaultPrevented || Ee(D);
1982
+ }
1983
+ let N = !(j.isExternal || i), B = (
1984
+ // eslint-disable-next-line jsx-a11y/anchor-has-content
1985
+ /* @__PURE__ */ s.createElement(
1986
+ "a",
1987
+ {
1988
+ ...w,
1989
+ ...te,
1990
+ href: (N ? W : void 0) || j.absoluteURL || I,
1991
+ onClick: N ? le : t,
1992
+ ref: Kn(x, J),
1993
+ target: m,
1994
+ "data-discover": !P && r === "render" ? "true" : void 0
1995
+ }
1996
+ )
1997
+ );
1998
+ return K && !P ? /* @__PURE__ */ s.createElement(s.Fragment, null, B, /* @__PURE__ */ s.createElement(Hn, { page: I })) : B;
1999
+ }
2000
+ );
2001
+ Yt.displayName = "Link";
2002
+ var zn = s.forwardRef(
2003
+ function({
2004
+ "aria-current": t = "page",
2005
+ caseSensitive: r = !1,
2006
+ className: a = "",
2007
+ end: o = !1,
2008
+ style: i,
2009
+ to: l,
2010
+ viewTransition: f,
2011
+ children: u,
2012
+ ...m
2013
+ }, h) {
2014
+ let c = ie(l, { relative: m.relative }), v = q(), E = s.useContext(ge), { navigator: w, basename: x } = s.useContext(U), y = E != null && // Conditional usage is OK here because the usage of a data router is static
2015
+ // eslint-disable-next-line react-hooks/rules-of-hooks
2016
+ ra(c) && f === !0, C = w.encodeLocation ? w.encodeLocation(c).pathname : c.pathname, R = v.pathname, P = E && E.navigation && E.navigation.location ? E.navigation.location.pathname : null;
2017
+ r || (R = R.toLowerCase(), P = P ? P.toLowerCase() : null, C = C.toLowerCase()), P && x && (P = z(P, x) || P);
2018
+ const j = C !== "/" && C.endsWith("/") ? C.length - 1 : C.length;
2019
+ let I = R === C || !o && R.startsWith(C) && R.charAt(j) === "/", M = P != null && (P === C || !o && P.startsWith(C) && P.charAt(C.length) === "/"), W = {
2020
+ isActive: I,
2021
+ isPending: M,
2022
+ isTransitioning: y
2023
+ }, K = I ? t : void 0, J;
2024
+ typeof a == "function" ? J = a(W) : J = [
2025
+ a,
2026
+ I ? "active" : null,
2027
+ M ? "pending" : null,
2028
+ y ? "transitioning" : null
2029
+ ].filter(Boolean).join(" ");
2030
+ let te = typeof i == "function" ? i(W) : i;
2031
+ return /* @__PURE__ */ s.createElement(
2032
+ Yt,
2033
+ {
2034
+ ...m,
2035
+ "aria-current": K,
2036
+ className: J,
2037
+ ref: h,
2038
+ style: te,
2039
+ to: l,
2040
+ viewTransition: f
320
2041
  },
321
- children: a
2042
+ typeof u == "function" ? u(W) : u
2043
+ );
2044
+ }
2045
+ );
2046
+ zn.displayName = "NavLink";
2047
+ var qn = s.forwardRef(
2048
+ ({
2049
+ discover: e = "render",
2050
+ fetcherKey: t,
2051
+ navigate: r,
2052
+ reloadDocument: a,
2053
+ replace: o,
2054
+ state: i,
2055
+ method: l = me,
2056
+ action: f,
2057
+ onSubmit: u,
2058
+ relative: m,
2059
+ preventScrollReset: h,
2060
+ viewTransition: c,
2061
+ unstable_defaultShouldRevalidate: v,
2062
+ ...E
2063
+ }, w) => {
2064
+ let { unstable_useTransitions: x } = s.useContext(U), y = ea(), C = ta(f, { relative: m }), R = l.toLowerCase() === "get" ? "get" : "post", P = typeof f == "string" && Vt.test(f), j = (I) => {
2065
+ if (u && u(I), I.defaultPrevented) return;
2066
+ I.preventDefault();
2067
+ let M = I.nativeEvent.submitter, W = M?.getAttribute("formmethod") || l, K = () => y(M || I.currentTarget, {
2068
+ fetcherKey: t,
2069
+ method: W,
2070
+ navigate: r,
2071
+ replace: o,
2072
+ state: i,
2073
+ relative: m,
2074
+ preventScrollReset: h,
2075
+ viewTransition: c,
2076
+ unstable_defaultShouldRevalidate: v
2077
+ });
2078
+ x && r !== !1 ? s.startTransition(() => K()) : K();
2079
+ };
2080
+ return /* @__PURE__ */ s.createElement(
2081
+ "form",
2082
+ {
2083
+ ref: w,
2084
+ method: R,
2085
+ action: C,
2086
+ onSubmit: a ? u : j,
2087
+ ...E,
2088
+ "data-discover": !P && e === "render" ? "true" : void 0
2089
+ }
2090
+ );
2091
+ }
2092
+ );
2093
+ qn.displayName = "Form";
2094
+ function Gn(e) {
2095
+ return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
2096
+ }
2097
+ function Kt(e) {
2098
+ let t = s.useContext(ee);
2099
+ return $(t, Gn(e)), t;
2100
+ }
2101
+ function Xn(e, {
2102
+ target: t,
2103
+ replace: r,
2104
+ unstable_mask: a,
2105
+ state: o,
2106
+ preventScrollReset: i,
2107
+ relative: l,
2108
+ viewTransition: f,
2109
+ unstable_defaultShouldRevalidate: u,
2110
+ unstable_useTransitions: m
2111
+ } = {}) {
2112
+ let h = sn(), c = q(), v = ie(e, { relative: l });
2113
+ return s.useCallback(
2114
+ (E) => {
2115
+ if (kn(E, t)) {
2116
+ E.preventDefault();
2117
+ let w = r !== void 0 ? r : Fe(c) === Fe(v), x = () => h(e, {
2118
+ replace: w,
2119
+ unstable_mask: a,
2120
+ state: o,
2121
+ preventScrollReset: i,
2122
+ relative: l,
2123
+ viewTransition: f,
2124
+ unstable_defaultShouldRevalidate: u
2125
+ });
2126
+ m ? s.startTransition(() => x()) : x();
2127
+ }
2128
+ },
2129
+ [
2130
+ c,
2131
+ h,
2132
+ v,
2133
+ r,
2134
+ a,
2135
+ o,
2136
+ t,
2137
+ e,
2138
+ i,
2139
+ l,
2140
+ f,
2141
+ u,
2142
+ m
2143
+ ]
2144
+ );
2145
+ }
2146
+ var Zn = 0, Qn = () => `__${String(++Zn)}__`;
2147
+ function ea() {
2148
+ let { router: e } = Kt(
2149
+ "useSubmit"
2150
+ /* UseSubmit */
2151
+ ), { basename: t } = s.useContext(U), r = wn(), a = e.fetch, o = e.navigate;
2152
+ return s.useCallback(
2153
+ async (i, l = {}) => {
2154
+ let { action: f, method: u, encType: m, formData: h, body: c } = Ln(
2155
+ i,
2156
+ t
2157
+ );
2158
+ if (l.navigate === !1) {
2159
+ let v = l.fetcherKey || Qn();
2160
+ await a(v, r, l.action || f, {
2161
+ unstable_defaultShouldRevalidate: l.unstable_defaultShouldRevalidate,
2162
+ preventScrollReset: l.preventScrollReset,
2163
+ formData: h,
2164
+ body: c,
2165
+ formMethod: l.method || u,
2166
+ formEncType: l.encType || m,
2167
+ flushSync: l.flushSync
2168
+ });
2169
+ } else
2170
+ await o(l.action || f, {
2171
+ unstable_defaultShouldRevalidate: l.unstable_defaultShouldRevalidate,
2172
+ preventScrollReset: l.preventScrollReset,
2173
+ formData: h,
2174
+ body: c,
2175
+ formMethod: l.method || u,
2176
+ formEncType: l.encType || m,
2177
+ replace: l.replace,
2178
+ state: l.state,
2179
+ fromRouteId: r,
2180
+ flushSync: l.flushSync,
2181
+ viewTransition: l.viewTransition
2182
+ });
2183
+ },
2184
+ [a, o, t, r]
2185
+ );
2186
+ }
2187
+ function ta(e, { relative: t } = {}) {
2188
+ let { basename: r } = s.useContext(U), a = s.useContext(V);
2189
+ $(a, "useFormAction must be used inside a RouteContext");
2190
+ let [o] = a.matches.slice(-1), i = { ...ie(e || ".", { relative: t }) }, l = q();
2191
+ if (e == null) {
2192
+ i.search = l.search;
2193
+ let f = new URLSearchParams(i.search), u = f.getAll("index");
2194
+ if (u.some((h) => h === "")) {
2195
+ f.delete("index"), u.filter((c) => c).forEach((c) => f.append("index", c));
2196
+ let h = f.toString();
2197
+ i.search = h ? `?${h}` : "";
322
2198
  }
2199
+ }
2200
+ return (!e || e === ".") && o.route.index && (i.search = i.search ? i.search.replace(/^\?/, "?index&") : "?index"), r !== "/" && (i.pathname = i.pathname === "/" ? r : H([r, i.pathname])), Fe(i);
2201
+ }
2202
+ function ra(e, { relative: t } = {}) {
2203
+ let r = s.useContext(Ft);
2204
+ $(
2205
+ r != null,
2206
+ "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?"
323
2207
  );
2208
+ let { basename: a } = Kt(
2209
+ "useViewTransitionState"
2210
+ /* useViewTransitionState */
2211
+ ), o = ie(e, { relative: t });
2212
+ if (!r.isTransitioning)
2213
+ return !1;
2214
+ let i = z(r.currentLocation.pathname, a) || r.currentLocation.pathname, l = z(r.nextLocation.pathname, a) || r.nextLocation.pathname;
2215
+ return ve(o.pathname, l) != null || ve(o.pathname, i) != null;
324
2216
  }
325
- async function Ee(a, s = {}) {
326
- const u = await fetch(a, {
327
- ...s,
328
- credentials: "include"
329
- });
330
- return u.status === 401 && (window.location.href = "/login?next=" + encodeURIComponent(window.location.href)), u;
2217
+ const Ke = () => {
2218
+ const e = _t(je);
2219
+ if (!e || !e.authManager) throw new Error("AuthContext not found");
2220
+ return e;
2221
+ }, na = (e) => {
2222
+ const { user: t } = Ke();
2223
+ return !!t?.privileges?.includes(e);
2224
+ };
2225
+ function sa({ privilege: e, invalidPage: t, loadingPage: r }) {
2226
+ const { loading: a } = Ke(), o = na(e);
2227
+ return a ? r : o ? /* @__PURE__ */ Q.jsx(Wt, {}) : t;
331
2228
  }
332
- function _e(a) {
333
- const { user: s } = W();
334
- return s ? s.role.privileges.some(
335
- (u) => u.privilege === a && u.is === "true"
336
- ) : !1;
2229
+ function ua({ loadingPage: e }) {
2230
+ const { authManager: t, login: r, user: a } = Ke(), [o, i] = Ie(!0);
2231
+ return Ae(() => {
2232
+ if (!t) return;
2233
+ t.getToken() ? i(!1) : r();
2234
+ }, [t, a]), t ? o ? e ?? /* @__PURE__ */ Q.jsx("div", { children: "Loading..." }) : /* @__PURE__ */ Q.jsx(Wt, {}) : /* @__PURE__ */ Q.jsx("p", { children: "invalud config" });
337
2235
  }
338
2236
  export {
339
- M as AuthContext,
340
- de as AuthGuard,
341
- me as AuthProvider,
342
- Ee as authFetch,
343
- W as useAuth,
344
- _e as useHasPrivilege
2237
+ je as AuthContext,
2238
+ Sr as AuthManager,
2239
+ ia as AuthProvider,
2240
+ la as CallbackPage,
2241
+ oa as Config,
2242
+ sa as PrivilegeGate,
2243
+ ua as ProtectGate,
2244
+ Pt as apiFetch,
2245
+ vt as handleCallback,
2246
+ De as login,
2247
+ gt as logout,
2248
+ br as refreshToken,
2249
+ Ke as useAuth,
2250
+ na as usePrivilege
345
2251
  };