@gen-epix/ui-client-common 4.3.0 → 4.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.
Files changed (49) hide show
  1. package/dist/_chunks/Breadcrumbs.js +22 -22
  2. package/dist/_chunks/Table.js +559 -3173
  3. package/dist/_chunks/Table.js.map +1 -1
  4. package/dist/_chunks/{oidc-client-ts.js → UserManagerUtil.js} +222 -198
  5. package/dist/_chunks/UserManagerUtil.js.map +1 -0
  6. package/dist/_chunks/middleware.js +1 -1
  7. package/dist/_chunks/middleware.js.map +1 -1
  8. package/dist/_chunks/omit.js +1 -1
  9. package/dist/_chunks/omit.js.map +1 -1
  10. package/dist/_chunks/react.js +1 -1
  11. package/dist/_chunks/react.js.map +1 -1
  12. package/dist/_chunks/useColumnsMenu.js +2 -2
  13. package/dist/_chunks/useColumnsMenu.js.map +1 -1
  14. package/dist/_chunks/useQueryMemo.js +1 -1
  15. package/dist/_chunks/useQueryMemo.js.map +1 -1
  16. package/dist/_chunks/vanilla.js +1 -1
  17. package/dist/_chunks/vanilla.js.map +1 -1
  18. package/dist/_chunks/yup.js +2 -2
  19. package/dist/_chunks/yup.js.map +1 -1
  20. package/dist/classes/services/LogService/index.js +1 -1
  21. package/dist/classes/services/LogService/index.js.map +1 -1
  22. package/dist/classes/services/RouterService/index.js +4 -4
  23. package/dist/components/app/App/index.js +35 -100
  24. package/dist/components/app/App/index.js.map +1 -1
  25. package/dist/components/app/AuthenticationWrapper/index.js +38 -38
  26. package/dist/components/app/AuthorizationWrapper/index.js +20 -20
  27. package/dist/components/app/RouterRoot/index.js +58 -59
  28. package/dist/components/app/RouterRoot/index.js.map +1 -1
  29. package/dist/components/ui/ApplicationBar/index.js +146 -146
  30. package/dist/components/ui/ApplicationBar/index.js.map +1 -1
  31. package/dist/components/ui/GenericErrorMessage/index.js +34 -34
  32. package/dist/components/ui/GenericErrorMessage/index.js.map +1 -1
  33. package/dist/components/ui/NavLink/index.js +8 -8
  34. package/dist/components/ui/PageContainer/index.js +1 -1
  35. package/dist/components/ui/PageContainer/index.js.map +1 -1
  36. package/dist/pages/AcceptInvitationPage/index.js +28 -28
  37. package/dist/pages/AdminPage/index.js +23 -23
  38. package/dist/pages/OrganizationContactsAdminPage/index.js +29 -29
  39. package/dist/pages/OrganizationSitesAdminPage/index.js +25 -25
  40. package/dist/pages/PostLoginPage/index.js +11 -11
  41. package/dist/pages/RouterErrorPage/index.js +10 -10
  42. package/dist/utils/UserManagerUtil/index.js +2 -31
  43. package/package.json +13 -8
  44. package/dist/_chunks/chunk-OB3PAWPO.js +0 -3742
  45. package/dist/_chunks/chunk-OB3PAWPO.js.map +0 -1
  46. package/dist/_chunks/oidc-client-ts.js.map +0 -1
  47. package/dist/_chunks/react-oidc-context.js +0 -201
  48. package/dist/_chunks/react-oidc-context.js.map +0 -1
  49. package/dist/utils/UserManagerUtil/index.js.map +0 -1
@@ -1,3742 +0,0 @@
1
- import * as e from "react";
2
- //#region ../../node_modules/.pnpm/react-router@7.18.4_react-dom@19.3.0_react@19.3.0__react@19.3.0/node_modules/react-router/dist/development/chunk-OB3PAWPO.mjs
3
- var t = (e) => {
4
- throw TypeError(e);
5
- }, n = (e, n, r) => n.has(e) || t("Cannot " + r), r = (e, t, r) => (n(e, t, "read from private field"), r ? r.call(e) : t.get(e)), i = (e, n, r) => n.has(e) ? t("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, r), a = (e, t, r, i) => (n(e, t, "write to private field"), i ? i.call(e, r) : t.set(e, r), r), o = /^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i, s = /^[\\/]{2}/;
6
- function c(e, t) {
7
- return t + e.replace(/\\/g, "/");
8
- }
9
- var l = "popstate";
10
- function u(e) {
11
- return typeof e == "object" && !!e && "pathname" in e && "search" in e && "hash" in e && "state" in e && "key" in e;
12
- }
13
- function d(e = {}) {
14
- function t(e, t) {
15
- let n = t.state?.masked, { pathname: r, search: i, hash: a } = n || e.location;
16
- return g("", {
17
- pathname: r,
18
- search: i,
19
- hash: a
20
- }, t.state && t.state.usr || null, t.state && t.state.key || "default", n ? {
21
- pathname: e.location.pathname,
22
- search: e.location.search,
23
- hash: e.location.hash
24
- } : void 0);
25
- }
26
- function n(e, t) {
27
- return typeof t == "string" ? t : _(t);
28
- }
29
- return y(t, n, null, e);
30
- }
31
- function f(e, t) {
32
- if (e === !1 || e == null) throw Error(t);
33
- }
34
- function p(e, t) {
35
- if (!e) {
36
- typeof console < "u" && console.warn(t);
37
- try {
38
- throw Error(t);
39
- } catch {}
40
- }
41
- }
42
- function m() {
43
- return Math.random().toString(36).substring(2, 10);
44
- }
45
- function h(e, t) {
46
- return {
47
- usr: e.state,
48
- key: e.key,
49
- idx: t,
50
- masked: e.mask ? {
51
- pathname: e.pathname,
52
- search: e.search,
53
- hash: e.hash
54
- } : void 0
55
- };
56
- }
57
- function g(e, t, n = null, r, i) {
58
- return {
59
- pathname: typeof e == "string" ? e : e.pathname,
60
- search: "",
61
- hash: "",
62
- ...typeof t == "string" ? v(t) : t,
63
- state: n,
64
- key: t && t.key || r || m(),
65
- mask: i
66
- };
67
- }
68
- function _({ pathname: e = "/", search: t = "", hash: n = "" }) {
69
- return t && t !== "?" && (e += t.charAt(0) === "?" ? t : "?" + t), n && n !== "#" && (e += n.charAt(0) === "#" ? n : "#" + n), e;
70
- }
71
- function v(e) {
72
- let t = {};
73
- if (e) {
74
- let n = e.indexOf("#");
75
- n >= 0 && (t.hash = e.substring(n), e = e.substring(0, n));
76
- let r = e.indexOf("?");
77
- r >= 0 && (t.search = e.substring(r), e = e.substring(0, r)), e && (t.pathname = e);
78
- }
79
- return t;
80
- }
81
- function y(e, t, n, r = {}) {
82
- let { window: i = document.defaultView, v5Compat: a = !1 } = r, o = i.history, s = "POP", c = null, d = f();
83
- d ?? (d = 0, o.replaceState({
84
- ...o.state,
85
- idx: d
86
- }, ""));
87
- function f() {
88
- return (o.state || { idx: null }).idx;
89
- }
90
- function p() {
91
- s = "POP";
92
- let e = f(), t = e == null ? null : e - d;
93
- d = e, c && c({
94
- action: s,
95
- location: y.location,
96
- delta: t
97
- });
98
- }
99
- function m(e, t) {
100
- s = "PUSH";
101
- let r = u(e) ? e : g(y.location, e, t);
102
- n && n(r, e), d = f() + 1;
103
- let l = h(r, d), p = y.createHref(r.mask || r);
104
- try {
105
- o.pushState(l, "", p);
106
- } catch (e) {
107
- if (e instanceof DOMException && e.name === "DataCloneError") throw e;
108
- i.location.assign(p);
109
- }
110
- a && c && c({
111
- action: s,
112
- location: y.location,
113
- delta: 1
114
- });
115
- }
116
- function _(e, t) {
117
- s = "REPLACE";
118
- let r = u(e) ? e : g(y.location, e, t);
119
- n && n(r, e), d = f();
120
- let i = h(r, d), l = y.createHref(r.mask || r);
121
- o.replaceState(i, "", l), a && c && c({
122
- action: s,
123
- location: y.location,
124
- delta: 0
125
- });
126
- }
127
- function v(e) {
128
- return b(i, e);
129
- }
130
- let y = {
131
- get action() {
132
- return s;
133
- },
134
- get location() {
135
- return e(i, o);
136
- },
137
- listen(e) {
138
- if (c) throw Error("A history only accepts one active listener");
139
- return i.addEventListener(l, p), c = e, () => {
140
- i.removeEventListener(l, p), c = null;
141
- };
142
- },
143
- createHref(e) {
144
- return t(i, e);
145
- },
146
- createURL: v,
147
- encodeLocation(e) {
148
- let t = v(e);
149
- return {
150
- pathname: t.pathname,
151
- search: t.search,
152
- hash: t.hash
153
- };
154
- },
155
- push: m,
156
- replace: _,
157
- go(e) {
158
- return o.go(e);
159
- }
160
- };
161
- return y;
162
- }
163
- function b(e, t, n = !1) {
164
- let r = "http://localhost";
165
- e && (r = e.location.origin === "null" ? e.location.href : e.location.origin), f(r, "No window.location.(origin|href) available to create URL");
166
- let i = typeof t == "string" ? t : _(t);
167
- return i = i.replace(/ $/, "%20"), !n && s.test(i) && (i = r + i), new URL(i, r);
168
- }
169
- function x(e) {
170
- return { defaultValue: e };
171
- }
172
- var S, C = class {
173
- constructor(e) {
174
- if (i(this, S, /* @__PURE__ */ new Map()), e) for (let [t, n] of e) this.set(t, n);
175
- }
176
- get(e) {
177
- if (r(this, S).has(e)) return r(this, S).get(e);
178
- if (e.defaultValue !== void 0) return e.defaultValue;
179
- throw Error("No value found for context");
180
- }
181
- set(e, t) {
182
- r(this, S).set(e, t);
183
- }
184
- };
185
- S = /* @__PURE__ */ new WeakMap();
186
- var w = /* @__PURE__ */ new Set([
187
- "lazy",
188
- "caseSensitive",
189
- "path",
190
- "id",
191
- "index",
192
- "children"
193
- ]);
194
- function T(e) {
195
- return w.has(e);
196
- }
197
- var E = /* @__PURE__ */ new Set([
198
- "lazy",
199
- "caseSensitive",
200
- "path",
201
- "id",
202
- "index",
203
- "middleware",
204
- "children"
205
- ]);
206
- function D(e) {
207
- return E.has(e);
208
- }
209
- function O(e) {
210
- return e.index === !0;
211
- }
212
- function k(e, t, n = [], r = {}, i = !1) {
213
- return e.map((e, a) => {
214
- let o = [...n, String(a)], s = typeof e.id == "string" ? e.id : o.join("-");
215
- if (f(e.index !== !0 || !e.children, "Cannot specify children on an index route"), f(i || !r[s], `Found a route id collision on id "${s}". Route id's must be globally unique within Data Router usages`), O(e)) {
216
- let n = {
217
- ...e,
218
- id: s
219
- };
220
- return r[s] = A(n, t(n)), n;
221
- }
222
- {
223
- let n = {
224
- ...e,
225
- id: s,
226
- children: void 0
227
- };
228
- return r[s] = A(n, t(n)), e.children && (n.children = k(e.children, t, o, r, i)), n;
229
- }
230
- });
231
- }
232
- function A(e, t) {
233
- return Object.assign(e, {
234
- ...t,
235
- ...typeof t.lazy == "object" && t.lazy != null ? { lazy: {
236
- ...e.lazy,
237
- ...t.lazy
238
- } } : {}
239
- });
240
- }
241
- function j(e, t, n = "/") {
242
- return M(e, t, n, !1);
243
- }
244
- function M(e, t, n, r, i) {
245
- let a = H((typeof t == "string" ? v(t) : t).pathname || "/", n);
246
- if (a == null) return null;
247
- let o = i ?? N(e), s = null, c = le(a);
248
- for (let e = 0; s == null && e < o.length; ++e) s = oe(o[e], c, r);
249
- return s;
250
- }
251
- function ee(e, t) {
252
- let { route: n, pathname: r, params: i } = e;
253
- return {
254
- id: n.id,
255
- pathname: r,
256
- params: i,
257
- data: t[n.id],
258
- loaderData: t[n.id],
259
- handle: n.handle
260
- };
261
- }
262
- function N(e) {
263
- let t = P(e);
264
- return I(t), t;
265
- }
266
- function P(e, t = [], n = [], r = "", i = !1) {
267
- let a = (e, a, o = i, s) => {
268
- let c = {
269
- relativePath: s === void 0 ? e.path || "" : s,
270
- caseSensitive: e.caseSensitive === !0,
271
- childrenIndex: a,
272
- route: e
273
- };
274
- if (c.relativePath.startsWith("/")) {
275
- if (!c.relativePath.startsWith(r) && o) return;
276
- f(c.relativePath.startsWith(r), `Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`), c.relativePath = c.relativePath.slice(r.length);
277
- }
278
- let l = W([r, c.relativePath]), u = n.concat(c);
279
- e.children && e.children.length > 0 && (f(e.index !== !0, `Index routes must not have child routes. Please remove all child routes from route path "${l}".`), P(e.children, t, u, l, o)), !(e.path == null && !e.index) && t.push({
280
- path: l,
281
- score: ae(l, e.index),
282
- routesMeta: u.map((e, t) => {
283
- let [n, r] = V(e.relativePath, e.caseSensitive, t === u.length - 1);
284
- return {
285
- ...e,
286
- matcher: n,
287
- compiledParams: r
288
- };
289
- })
290
- });
291
- };
292
- return e.forEach((e, t) => {
293
- if (e.path === "" || !e.path?.includes("?")) a(e, t);
294
- else for (let n of F(e.path)) a(e, t, !0, n);
295
- }), t;
296
- }
297
- function F(e) {
298
- let t = e.split("/");
299
- if (t.length === 0) return [];
300
- let [n, ...r] = t, i = n.endsWith("?"), a = n.replace(/\?$/, "");
301
- if (r.length === 0) return i ? [a, ""] : [a];
302
- let o = F(r.join("/")), s = [];
303
- return s.push(...o.map((e) => e === "" ? a : [a, e].join("/"))), i && s.push(...o), s.map((t) => e.startsWith("/") && t === "" ? "/" : t);
304
- }
305
- function I(e) {
306
- e.sort((e, t) => e.score === t.score ? B(e.routesMeta.map((e) => e.childrenIndex), t.routesMeta.map((e) => e.childrenIndex)) : t.score - e.score);
307
- }
308
- var te = /^:[\w-]+$/, L = 3, ne = 2, re = 1, R = 10, z = -2, ie = (e) => e === "*";
309
- function ae(e, t) {
310
- let n = e.split("/"), r = n.length;
311
- return n.some(ie) && (r += z), t && (r += ne), n.filter((e) => !ie(e)).reduce((e, t) => e + (te.test(t) ? L : t === "" ? re : R), r);
312
- }
313
- function B(e, t) {
314
- return e.length === t.length && e.slice(0, -1).every((e, n) => e === t[n]) ? e[e.length - 1] - t[t.length - 1] : 0;
315
- }
316
- function oe(e, t, n = !1) {
317
- let { routesMeta: r } = e, i = {}, a = "/", o = [];
318
- for (let e = 0; e < r.length; ++e) {
319
- let s = r[e], c = e === r.length - 1, l = a === "/" ? t : t.slice(a.length) || "/", u = {
320
- path: s.relativePath,
321
- caseSensitive: s.caseSensitive,
322
- end: c
323
- }, d = s.matcher && s.compiledParams ? ce(u, l, s.matcher, s.compiledParams) : se(u, l), f = s.route;
324
- if (!d && c && n && !r[r.length - 1].route.index && (d = se({
325
- path: s.relativePath,
326
- caseSensitive: s.caseSensitive,
327
- end: !1
328
- }, l)), !d) return null;
329
- Object.assign(i, d.params), o.push({
330
- params: i,
331
- pathname: W([a, d.pathname]),
332
- pathnameBase: ve(W([a, d.pathnameBase])),
333
- route: f
334
- }), d.pathnameBase !== "/" && (a = W([a, d.pathnameBase]));
335
- }
336
- return o;
337
- }
338
- function se(e, t) {
339
- typeof e == "string" && (e = {
340
- path: e,
341
- caseSensitive: !1,
342
- end: !0
343
- });
344
- let [n, r] = V(e.path, e.caseSensitive, e.end);
345
- return ce(e, t, n, r);
346
- }
347
- function ce(e, t, n, r) {
348
- let i = t.match(n);
349
- if (!i) return null;
350
- let a = i[0], o = G(a, 1), s = i.slice(1);
351
- return {
352
- params: r.reduce((e, { paramName: t, isOptional: n }, r) => {
353
- if (t === "*") {
354
- let e = s[r] || "";
355
- o = G(a.slice(0, a.length - e.length), 1);
356
- }
357
- let i = s[r];
358
- return e[t] = n && !i ? void 0 : (i || "").replace(/%2F/g, "/"), e;
359
- }, {}),
360
- pathname: a,
361
- pathnameBase: o,
362
- pattern: e
363
- };
364
- }
365
- function V(e, t = !1, n = !0) {
366
- p(e === "*" || !e.endsWith("*") || e.endsWith("/*"), `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(/\*$/, "/*")}".`);
367
- let r = [], i = "^" + e.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (e, t, n, i, a) => {
368
- if (r.push({
369
- paramName: t,
370
- isOptional: n != null
371
- }), n) {
372
- let t = a.charAt(i + e.length);
373
- return t && t !== "/" ? "/([^\\/]*)" : "(?:/([^\\/]*))?";
374
- }
375
- return "/([^\\/]+)";
376
- }).replace(/\/([\w-]+)\?(\/|$)/g, "(/$1)?$2");
377
- return e.endsWith("*") ? (r.push({ paramName: "*" }), i += e === "*" || e === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$") : n ? i += "\\/*$" : e !== "" && e !== "/" && (i += "(?:(?=\\/|$))"), [new RegExp(i, t ? void 0 : "i"), r];
378
- }
379
- function le(e) {
380
- try {
381
- return e.split("/").map((e) => decodeURIComponent(e).replace(/\//g, "%2F")).join("/");
382
- } catch (t) {
383
- return p(!1, `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}).`), e;
384
- }
385
- }
386
- function H(e, t) {
387
- if (t === "/") return e;
388
- if (!e.toLowerCase().startsWith(t.toLowerCase())) return null;
389
- let n = t.endsWith("/") ? t.length - 1 : t.length, r = e.charAt(n);
390
- return r && r !== "/" ? null : e.slice(n) || "/";
391
- }
392
- function ue({ basename: e, pathname: t }) {
393
- return t === "/" ? e : W([e, t]);
394
- }
395
- var de = (e) => o.test(e);
396
- function U(e, t = "/") {
397
- let { pathname: n, search: r = "", hash: i = "" } = typeof e == "string" ? v(e) : e, a;
398
- return n ? (n = _e(n), a = n.startsWith("/") || n.startsWith("\\") ? fe(n.substring(1), "/") : fe(n, t)) : a = t, {
399
- pathname: a,
400
- search: ye(r),
401
- hash: be(i)
402
- };
403
- }
404
- function fe(e, t) {
405
- let n = G(t).split("/");
406
- return e.split("/").forEach((e) => {
407
- e === ".." ? n.length > 1 && n.pop() : e !== "." && n.push(e);
408
- }), n.length > 1 ? n.join("/") : "/";
409
- }
410
- function pe(e, t, n, r) {
411
- return `Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`;
412
- }
413
- function me(e) {
414
- return e.filter((e, t) => t === 0 || e.route.path && e.route.path.length > 0);
415
- }
416
- function he(e) {
417
- let t = me(e);
418
- return t.map((e, n) => n === t.length - 1 ? e.pathname : e.pathnameBase);
419
- }
420
- function ge(e, t, n, r = !1) {
421
- let i;
422
- typeof e == "string" ? i = v(e) : (i = { ...e }, f(!i.pathname || !i.pathname.includes("?"), pe("?", "pathname", "search", i)), f(!i.pathname || !i.pathname.includes("#"), pe("#", "pathname", "hash", i)), f(!i.search || !i.search.includes("#"), pe("#", "search", "hash", i)));
423
- let a = e === "" || i.pathname === "", o = a ? "/" : i.pathname, s;
424
- if (o == null) s = n;
425
- else {
426
- let e = t.length - 1;
427
- if (!r && o.startsWith("..")) {
428
- let t = o.split("/");
429
- for (; t[0] === "..";) t.shift(), --e;
430
- i.pathname = t.join("/");
431
- }
432
- s = e >= 0 ? t[e] : "/";
433
- }
434
- let c = U(i, s), l = o && o !== "/" && o.endsWith("/"), u = (a || o === ".") && n.endsWith("/");
435
- return !c.pathname.endsWith("/") && (l || u) && (c.pathname += "/"), c;
436
- }
437
- var _e = (e) => e.replace(/[\\/]{2,}/g, "/"), W = (e) => _e(e.join("/"));
438
- function G(e, t = 0) {
439
- let n = e.length;
440
- for (; n > t && e.charCodeAt(n - 1) === 47;) n--;
441
- return n === e.length ? e : e.slice(0, n);
442
- }
443
- var ve = (e) => G(e).replace(/^\/*/, "/"), ye = (e) => !e || e === "?" ? "" : e.startsWith("?") ? e : "?" + e, be = (e) => !e || e === "#" ? "" : e.startsWith("#") ? e : "#" + e, xe = [
444
- "EvalError",
445
- "RangeError",
446
- "ReferenceError",
447
- "SyntaxError",
448
- "TypeError",
449
- "URIError"
450
- ], Se = class {
451
- constructor(e, t, n, r = !1) {
452
- this.status = e, this.statusText = t || "", this.internal = r, n instanceof Error ? (this.data = n.toString(), this.error = n) : this.data = n;
453
- }
454
- };
455
- function Ce(e) {
456
- return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.internal == "boolean" && "data" in e;
457
- }
458
- function we(e) {
459
- return W(e.map((e) => e.route.path).filter(Boolean)) || "/";
460
- }
461
- var Te = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
462
- function Ee(e, t) {
463
- let n = e;
464
- if (typeof n != "string" || !o.test(n)) return {
465
- absoluteURL: void 0,
466
- isExternal: !1,
467
- to: n
468
- };
469
- let r = n, i = !1;
470
- if (Te) try {
471
- let e = new URL(window.location.href), r = s.test(n) ? new URL(c(n, e.protocol)) : new URL(n), a = H(r.pathname, t);
472
- r.origin === e.origin && a != null ? n = a + r.search + r.hash : i = !0;
473
- } catch {
474
- p(!1, `<Link to="${n}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`);
475
- }
476
- return {
477
- absoluteURL: r,
478
- isExternal: i,
479
- to: n
480
- };
481
- }
482
- var De = Symbol("Uninstrumented");
483
- function Oe(e, t) {
484
- let n = {
485
- lazy: [],
486
- "lazy.loader": [],
487
- "lazy.action": [],
488
- "lazy.middleware": [],
489
- middleware: [],
490
- loader: [],
491
- action: []
492
- };
493
- e.forEach((e) => e({
494
- id: t.id,
495
- index: t.index,
496
- path: t.path,
497
- instrument(e) {
498
- let t = Object.keys(n);
499
- for (let r of t) e[r] && n[r].push(e[r]);
500
- }
501
- }));
502
- let r = {};
503
- if (typeof t.lazy == "function" && n.lazy.length > 0) {
504
- let e = Ae(n.lazy, t.lazy, () => void 0);
505
- e && (r.lazy = e);
506
- }
507
- if (typeof t.lazy == "object") {
508
- let e = t.lazy;
509
- [
510
- "middleware",
511
- "loader",
512
- "action"
513
- ].forEach((t) => {
514
- let i = e[t], a = n[`lazy.${t}`];
515
- if (typeof i == "function" && a.length > 0) {
516
- let e = Ae(a, i, () => void 0);
517
- e && (r.lazy = Object.assign(r.lazy || {}, { [t]: e }));
518
- }
519
- });
520
- }
521
- return ["loader", "action"].forEach((e) => {
522
- let i = t[e];
523
- if (typeof i == "function" && n[e].length > 0) {
524
- let t = i[De] ?? i, a = Ae(n[e], t, (...e) => Me(e[0]));
525
- a && (e === "loader" && t.hydrate === !0 && (a.hydrate = !0), a[De] = t, r[e] = a);
526
- }
527
- }), t.middleware && t.middleware.length > 0 && n.middleware.length > 0 && (r.middleware = t.middleware.map((e) => {
528
- let t = e[De] ?? e, r = Ae(n.middleware, t, (...e) => Me(e[0]));
529
- return r ? (r[De] = t, r) : e;
530
- })), r;
531
- }
532
- function ke(e, t) {
533
- let n = {
534
- navigate: [],
535
- fetch: []
536
- };
537
- if (t.forEach((e) => e({ instrument(e) {
538
- let t = Object.keys(e);
539
- for (let r of t) e[r] && n[r].push(e[r]);
540
- } })), n.navigate.length > 0) {
541
- let t = e.navigate[De] ?? e.navigate, r = Ae(n.navigate, t, (...t) => {
542
- let [n, r] = t;
543
- return {
544
- to: typeof n == "number" || typeof n == "string" ? n : n ? _(n) : ".",
545
- ...Ne(e, r ?? {})
546
- };
547
- });
548
- r && (r[De] = t, e.navigate = r);
549
- }
550
- if (n.fetch.length > 0) {
551
- let t = e.fetch[De] ?? e.fetch, r = Ae(n.fetch, t, (...t) => {
552
- let [n, , r, i] = t;
553
- return {
554
- href: r ?? ".",
555
- fetcherKey: n,
556
- ...Ne(e, i ?? {})
557
- };
558
- });
559
- r && (r[De] = t, e.fetch = r);
560
- }
561
- return e;
562
- }
563
- function Ae(e, t, n) {
564
- return e.length === 0 ? null : async (...r) => {
565
- let i = await je(e, n(...r), () => t(...r), e.length - 1);
566
- if (i.type === "error") throw i.value;
567
- return i.value;
568
- };
569
- }
570
- async function je(e, t, n, r) {
571
- let i = e[r], a;
572
- if (i) {
573
- let o, s = async () => (o ? console.error("You cannot call instrumented handlers more than once") : o = je(e, t, n, r - 1), a = await o, f(a, "Expected a result"), a.type === "error" && a.value instanceof Error ? {
574
- status: "error",
575
- error: a.value
576
- } : {
577
- status: "success",
578
- error: void 0
579
- });
580
- try {
581
- await i(s, t);
582
- } catch (e) {
583
- console.error("An instrumentation function threw an error:", e);
584
- }
585
- o || await s(), await o;
586
- } else try {
587
- a = {
588
- type: "success",
589
- value: await n()
590
- };
591
- } catch (e) {
592
- a = {
593
- type: "error",
594
- value: e
595
- };
596
- }
597
- return a || {
598
- type: "error",
599
- value: /* @__PURE__ */ Error("No result assigned in instrumentation chain.")
600
- };
601
- }
602
- function Me(e) {
603
- let { request: t, context: n, params: r, pattern: i } = e;
604
- return {
605
- request: Pe(t),
606
- params: { ...r },
607
- pattern: i,
608
- context: K(n)
609
- };
610
- }
611
- function Ne(e, t) {
612
- return {
613
- currentUrl: _(e.state.location),
614
- ..."formMethod" in t ? { formMethod: t.formMethod } : {},
615
- ..."formEncType" in t ? { formEncType: t.formEncType } : {},
616
- ..."formData" in t ? { formData: t.formData } : {},
617
- ..."body" in t ? { body: t.body } : {}
618
- };
619
- }
620
- function Pe(e) {
621
- return {
622
- method: e.method,
623
- url: e.url,
624
- headers: { get: (...t) => e.headers.get(...t) }
625
- };
626
- }
627
- function K(e) {
628
- if (Ie(e)) {
629
- let t = { ...e };
630
- return Object.freeze(t), t;
631
- }
632
- return { get: (t) => e.get(t) };
633
- }
634
- var Fe = Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
635
- function Ie(e) {
636
- if (typeof e != "object" || !e) return !1;
637
- let t = Object.getPrototypeOf(e);
638
- return t === Object.prototype || t === null || Object.getOwnPropertyNames(t).sort().join("\0") === Fe;
639
- }
640
- var Le = new URL("http://localhost");
641
- function Re(e) {
642
- if (e.createURL) return e.createURL("/");
643
- try {
644
- return new URL(e.createHref("/"), Le);
645
- } catch {
646
- return Le;
647
- }
648
- }
649
- function ze(e, t) {
650
- return e.origin === t.origin && (e.origin !== "null" || e.protocol === t.protocol && e.host === t.host);
651
- }
652
- function Be(e, t) {
653
- if (e.startsWith("//")) return !0;
654
- let n = t.protocol.toLowerCase();
655
- return e.toLowerCase().startsWith(n) ? t.host === "" || e.slice(n.length).startsWith("//") : !1;
656
- }
657
- function Ve(e, t, n, r) {
658
- let i = null;
659
- try {
660
- i = e == null ? null : new URL(e, n);
661
- } catch {}
662
- let a = new URL(t, n), o = i != null && !ze(i, n), s = !ze(a, n);
663
- if (r === "reject") {
664
- if (o || s) throw Error("External navigation is not allowed");
665
- } else if (s && (i == null || !Be(e, i) || !ze(i, a))) throw Error("External navigation is not allowed");
666
- }
667
- var He = [
668
- "POST",
669
- "PUT",
670
- "PATCH",
671
- "DELETE"
672
- ], Ue = new Set(He), We = ["GET", ...He], Ge = new Set(We), Ke = /* @__PURE__ */ new Set([
673
- 301,
674
- 302,
675
- 303,
676
- 307,
677
- 308
678
- ]), qe = /* @__PURE__ */ new Set([307, 308]), Je = {
679
- state: "idle",
680
- location: void 0,
681
- matches: void 0,
682
- historyAction: void 0,
683
- formMethod: void 0,
684
- formAction: void 0,
685
- formEncType: void 0,
686
- formData: void 0,
687
- json: void 0,
688
- text: void 0
689
- }, Ye = {
690
- state: "idle",
691
- data: void 0,
692
- formMethod: void 0,
693
- formAction: void 0,
694
- formEncType: void 0,
695
- formData: void 0,
696
- json: void 0,
697
- text: void 0
698
- }, Xe = {
699
- state: "unblocked",
700
- proceed: void 0,
701
- reset: void 0,
702
- location: void 0
703
- }, Ze = (e) => ({ hasErrorBoundary: !!e.hasErrorBoundary }), Qe = "remix-router-transitions", $e = Symbol("ResetLoaderData"), et, tt, nt, rt, it = class {
704
- constructor(e) {
705
- i(this, et), i(this, tt), i(this, nt), i(this, rt), a(this, et, e), a(this, tt, N(e));
706
- }
707
- get stableRoutes() {
708
- return r(this, et);
709
- }
710
- get activeRoutes() {
711
- return r(this, nt) ?? r(this, et);
712
- }
713
- get branches() {
714
- return r(this, rt) ?? r(this, tt);
715
- }
716
- get hasHMRRoutes() {
717
- return r(this, nt) != null;
718
- }
719
- setRoutes(e) {
720
- a(this, et, e), a(this, tt, N(e));
721
- }
722
- setHmrRoutes(e) {
723
- a(this, nt, e), a(this, rt, N(e));
724
- }
725
- commitHmrRoutes() {
726
- r(this, nt) && (a(this, et, r(this, nt)), a(this, tt, r(this, rt)), a(this, nt, void 0), a(this, rt, void 0));
727
- }
728
- };
729
- et = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), nt = /* @__PURE__ */ new WeakMap(), rt = /* @__PURE__ */ new WeakMap();
730
- function at(e) {
731
- let t = e.window ? e.window : typeof window < "u" ? window : void 0, n = t !== void 0 && t.document !== void 0 && t.document.createElement !== void 0;
732
- f(e.routes.length > 0, "You must provide a non-empty routes array to createRouter");
733
- let r = e.hydrationRouteProperties || [], i = e.mapRouteProperties || Ze, a = i;
734
- if (e.instrumentations) {
735
- let t = e.instrumentations;
736
- a = (e) => ({
737
- ...i(e),
738
- ...Oe(t.map((e) => e.route).filter(Boolean), e)
739
- });
740
- }
741
- let o = {}, c = new it(k(e.routes, a, void 0, o)), l = e.basename || "/";
742
- l.startsWith("/") || (l = `/${l}`);
743
- let u = e.dataStrategy || St, d = { ...e.future }, m = null, h = /* @__PURE__ */ new Set(), y = null, x = null, S = null, w = null, T = e.hydrationData != null, E = M(c.activeRoutes, e.history.location, l, !1, c.branches), D = !1, O = null, A, j;
744
- if (E == null && !e.patchRoutesOnNavigation) {
745
- let t = q(404, { pathname: e.history.location.pathname }), { matches: n, route: r } = Kt(c.activeRoutes);
746
- A = !0, j = !A, E = n, O = { [r.id]: t };
747
- } else if (E && !e.hydrationData && ot(E, c.activeRoutes, e.history.location.pathname).active && (E = null), !E) {
748
- A = !1, j = !A, E = [];
749
- let t = ot(null, c.activeRoutes, e.history.location.pathname);
750
- t.active && t.matches && (D = !0, E = t.matches);
751
- } else if (E.some((e) => e.route.lazy)) A = !1, j = !A;
752
- else if (!E.some((e) => ut(e.route))) A = !0, j = !A;
753
- else {
754
- let t = e.hydrationData ? e.hydrationData.loaderData : null, n = e.hydrationData ? e.hydrationData.errors : null, r = E;
755
- if (n) {
756
- let e = E.findIndex((e) => n[e.route.id] !== void 0);
757
- r = r.slice(0, e + 1);
758
- }
759
- j = !1, A = !0, r.forEach((e) => {
760
- let r = dt(e.route, t, n);
761
- j ||= r.renderFallback, A &&= !r.shouldLoad;
762
- });
763
- }
764
- let N, P = {
765
- historyAction: e.history.action,
766
- location: e.history.location,
767
- matches: E,
768
- initialized: A,
769
- renderFallback: j,
770
- navigation: Je,
771
- restoreScrollPosition: e.hydrationData == null && null,
772
- preventScrollReset: !1,
773
- revalidation: "idle",
774
- loaderData: e.hydrationData && e.hydrationData.loaderData || {},
775
- actionData: e.hydrationData && e.hydrationData.actionData || null,
776
- errors: e.hydrationData && e.hydrationData.errors || O,
777
- fetchers: /* @__PURE__ */ new Map(),
778
- blockers: /* @__PURE__ */ new Map()
779
- }, F = "POP", I = null, te = !1, L, ne = !1, re = /* @__PURE__ */ new Map(), R = null, z = !1, ie = !1, ae = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Map(), oe = 0, se = -1, ce = /* @__PURE__ */ new Map(), V = /* @__PURE__ */ new Set(), le = /* @__PURE__ */ new Map(), ue = /* @__PURE__ */ new Map(), U = /* @__PURE__ */ new Set(), fe = /* @__PURE__ */ new Map(), pe, me = null;
780
- function he() {
781
- if (m = e.history.listen(({ action: t, location: n, delta: r }) => {
782
- if (pe) {
783
- pe(), pe = void 0;
784
- return;
785
- }
786
- p(fe.size === 0 || r != null, "You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");
787
- let i = $e({
788
- currentLocation: P.location,
789
- nextLocation: n,
790
- historyAction: t
791
- });
792
- if (i && r != null) {
793
- let t = new Promise((e) => {
794
- pe = e;
795
- });
796
- e.history.go(r * -1), Qe(i, {
797
- state: "blocked",
798
- location: n,
799
- proceed() {
800
- Qe(i, {
801
- state: "proceeding",
802
- proceed: void 0,
803
- reset: void 0,
804
- location: n
805
- }), t.then(() => e.history.go(r));
806
- },
807
- reset() {
808
- let e = new Map(P.blockers);
809
- e.set(i, Xe), W({ blockers: e });
810
- }
811
- }), I?.resolve(), I = null;
812
- return;
813
- }
814
- return be(t, n);
815
- }), n) {
816
- mn(t, re);
817
- let e = () => hn(t, re);
818
- t.addEventListener("pagehide", e), R = () => t.removeEventListener("pagehide", e);
819
- }
820
- return P.initialized || be("POP", P.location, { initialHydration: !0 }), N;
821
- }
822
- function ge() {
823
- m && m(), R && R(), h.clear(), L && L.abort(), P.fetchers.forEach((e, t) => Re(P.fetchers, t)), P.blockers.forEach((e, t) => Ke(t));
824
- }
825
- function _e(e) {
826
- if (h.add(e), y) {
827
- let { newErrors: t } = y;
828
- y = null, e(P, {
829
- deletedFetchers: [],
830
- newErrors: t,
831
- viewTransitionOpts: void 0,
832
- flushSync: !1
833
- });
834
- }
835
- return () => h.delete(e);
836
- }
837
- function W(e, t = {}) {
838
- e.matches &&= e.matches.map((e) => {
839
- let t = o[e.route.id], n = e.route;
840
- return n.element !== t.element || n.errorElement !== t.errorElement || n.hydrateFallbackElement !== t.hydrateFallbackElement ? {
841
- ...e,
842
- route: t
843
- } : e;
844
- }), P = {
845
- ...P,
846
- ...e
847
- };
848
- let n = [], r = [];
849
- P.fetchers.forEach((e, t) => {
850
- e.state === "idle" && (U.has(t) ? n.push(t) : r.push(t));
851
- }), U.forEach((e) => {
852
- !P.fetchers.has(e) && !B.has(e) && n.push(e);
853
- }), h.size === 0 && (y = { newErrors: e.errors ?? null }), [...h].forEach((r) => r(P, {
854
- deletedFetchers: n,
855
- newErrors: e.errors ?? null,
856
- viewTransitionOpts: t.viewTransitionOpts,
857
- flushSync: t.flushSync === !0
858
- })), n.forEach((e) => Re(P.fetchers, e)), r.forEach((e) => P.fetchers.delete(e));
859
- }
860
- function G(t, n, { flushSync: r } = {}) {
861
- let i = P.actionData != null && P.navigation.formMethod != null && Y(P.navigation.formMethod) && P.navigation.state === "loading" && t.state?._isRedirect !== !0, a;
862
- a = n.actionData ? Object.keys(n.actionData).length > 0 ? n.actionData : null : i ? P.actionData : null;
863
- let o = n.loaderData ? Ut(P.loaderData, n.loaderData, n.matches || [], n.errors) : P.loaderData, s = P.blockers;
864
- s.size > 0 && (s = new Map(s), s.forEach((e, t) => s.set(t, Xe)));
865
- let l = !z && at(t, n.matches || P.matches), u = te === !0 || P.navigation.formMethod != null && Y(P.navigation.formMethod) && t.state?._isRedirect !== !0;
866
- c.commitHmrRoutes(), z || F === "POP" || (F === "PUSH" ? e.history.push(t, t.state) : F === "REPLACE" && e.history.replace(t, t.state));
867
- let d;
868
- if (F === "POP" && !z && t !== P.location) {
869
- let e = re.get(P.location.pathname);
870
- e && e.has(t.pathname) ? d = {
871
- currentLocation: P.location,
872
- nextLocation: t
873
- } : re.has(t.pathname) && (d = {
874
- currentLocation: t,
875
- nextLocation: P.location
876
- });
877
- } else if (ne) {
878
- let e = re.get(P.location.pathname);
879
- e ? e.add(t.pathname) : (e = /* @__PURE__ */ new Set([t.pathname]), re.set(P.location.pathname, e)), d = {
880
- currentLocation: P.location,
881
- nextLocation: t
882
- };
883
- }
884
- W({
885
- ...n,
886
- actionData: a,
887
- loaderData: o,
888
- historyAction: F,
889
- location: t,
890
- initialized: !0,
891
- renderFallback: !1,
892
- navigation: Je,
893
- revalidation: "idle",
894
- restoreScrollPosition: l,
895
- preventScrollReset: u,
896
- blockers: s
897
- }, {
898
- viewTransitionOpts: d,
899
- flushSync: r === !0
900
- }), F = "POP", te = !1, ne = !1, z = !1, ie = !1, I?.resolve(), I = null, me?.resolve(), me = null;
901
- }
902
- async function ve(t, n) {
903
- if (I?.resolve(), I = null, typeof t == "number") {
904
- I ||= gn();
905
- let n = I.promise;
906
- return e.history.go(t), n;
907
- }
908
- let { path: r, submission: i, error: a } = ct(!1, st(P.location, P.matches, l, t, n?.fromRouteId, n?.relative), n), o;
909
- if (n?.mask) {
910
- let t = typeof n.mask == "string" ? v(n.mask) : {
911
- ...P.location.mask,
912
- ...n.mask
913
- };
914
- if (o = {
915
- pathname: t.pathname ?? "",
916
- search: t.search ?? "",
917
- hash: t.hash ?? ""
918
- }, s.test(o.pathname)) throw Error("External navigation is not allowed");
919
- o.pathname.startsWith("\\") && (o.pathname = o.pathname.replace(/^\\+/, "/")), Ve(typeof n.mask == "string" ? n.mask : _(n.mask), _(o), e.history.createURL("/"), "reject");
920
- }
921
- let c = P.location, u = g(c, r, n && n.state, void 0, o);
922
- u = {
923
- ...u,
924
- ...e.history.encodeLocation(u)
925
- }, Ve(t == null ? e.history.createHref(P.location) : typeof t == "string" ? t : _(t), e.history.createHref(u.mask || u), e.history.createURL("/"), "reject");
926
- let d = n && n.replace != null ? n.replace : void 0, f = "PUSH";
927
- d === !0 ? f = "REPLACE" : d === !1 || i != null && Y(i.formMethod) && i.formAction === P.location.pathname + P.location.search && (f = "REPLACE");
928
- let p = n && "preventScrollReset" in n ? n.preventScrollReset === !0 : void 0, m = (n && n.flushSync) === !0, h = $e({
929
- currentLocation: c,
930
- nextLocation: u,
931
- historyAction: f
932
- });
933
- if (h) {
934
- Qe(h, {
935
- state: "blocked",
936
- location: u,
937
- proceed() {
938
- Qe(h, {
939
- state: "proceeding",
940
- proceed: void 0,
941
- reset: void 0,
942
- location: u
943
- }), ve(t, n);
944
- },
945
- reset() {
946
- let e = new Map(P.blockers);
947
- e.set(h, Xe), W({ blockers: e });
948
- }
949
- });
950
- return;
951
- }
952
- await be(f, u, {
953
- submission: i,
954
- pendingError: a,
955
- preventScrollReset: p,
956
- replace: n && n.replace,
957
- enableViewTransition: n && n.viewTransition,
958
- flushSync: m,
959
- callSiteDefaultShouldRevalidate: n && n.defaultShouldRevalidate
960
- });
961
- }
962
- function ye() {
963
- me ||= gn(), Pe(), W({ revalidation: "loading" });
964
- let e = me.promise;
965
- return P.navigation.state === "submitting" ? e : P.navigation.state === "idle" ? (be(P.historyAction, P.location, { startUninterruptedRevalidation: !0 }), e) : (be(F || P.historyAction, P.navigation.location, {
966
- overrideNavigation: P.navigation,
967
- enableViewTransition: ne === !0
968
- }), e);
969
- }
970
- async function be(t, n, r) {
971
- L && L.abort(), L = null, F = t, z = (r && r.startUninterruptedRevalidation) === !0, rt(P.location, P.matches), te = (r && r.preventScrollReset) === !0, ne = (r && r.enableViewTransition) === !0;
972
- let i = c.activeRoutes, a = r?.initialHydration && P.matches && P.matches.length > 0 && !D ? P.matches : M(i, n, l, !1, c.branches), o = (r && r.flushSync) === !0;
973
- if (a && P.initialized && !ie && Yt(P.location, n) && !(r && r.submission && Y(r.submission.formMethod))) {
974
- G(n, { matches: a }, { flushSync: o });
975
- return;
976
- }
977
- let s = ot(a, i, n.pathname);
978
- if (s.active && s.matches && (a = s.matches), !a) {
979
- let { error: e, notFoundMatches: t, route: r } = et(n.pathname);
980
- G(n, {
981
- matches: t,
982
- loaderData: {},
983
- errors: { [r.id]: e }
984
- }, { flushSync: o });
985
- return;
986
- }
987
- let u = r && r.overrideNavigation ? {
988
- ...r.overrideNavigation,
989
- matches: a,
990
- historyAction: t
991
- } : void 0;
992
- L = new AbortController();
993
- let d = Lt(e.history, n, L.signal, r && r.submission), f = e.getContext ? await e.getContext() : new C(), p;
994
- if (r && r.pendingError) p = [Gt(a).route.id, {
995
- type: "error",
996
- error: r.pendingError
997
- }];
998
- else if (r && r.submission && Y(r.submission.formMethod)) {
999
- let i = await xe(d, n, r.submission, a, t, f, s.active, r && r.initialHydration === !0, {
1000
- replace: r.replace,
1001
- flushSync: o
1002
- });
1003
- if (i.shortCircuited) return;
1004
- if (i.pendingActionResult) {
1005
- let [e, t] = i.pendingActionResult;
1006
- if (J(t) && Ce(t.error) && t.error.status === 404) {
1007
- L = null, G(n, {
1008
- matches: i.matches,
1009
- loaderData: {},
1010
- errors: { [e]: t.error }
1011
- });
1012
- return;
1013
- }
1014
- }
1015
- a = i.matches || a, p = i.pendingActionResult, u = un(n, a, t, r.submission), o = !1, s.active = !1, d = Lt(e.history, d.url, d.signal);
1016
- }
1017
- let { shortCircuited: m, matches: h, loaderData: g, errors: _, workingFetchers: v } = await Se(d, n, a, t, f, s.active, u, r && r.submission, r && r.fetcherSubmission, r && r.replace, r && r.initialHydration === !0, o, p, r && r.callSiteDefaultShouldRevalidate);
1018
- m || (L = null, G(n, {
1019
- matches: h || a,
1020
- ...Wt(p),
1021
- loaderData: g,
1022
- errors: _,
1023
- ...v ? { fetchers: v } : {}
1024
- }));
1025
- }
1026
- async function xe(t, n, i, s, u, d, f, p, m = {}) {
1027
- if (Pe(), W({ navigation: dn(n, s, u, i) }, { flushSync: m.flushSync === !0 }), f) {
1028
- let e = await ft(s, n.pathname, t.signal);
1029
- if (e.type === "aborted") return { shortCircuited: !0 };
1030
- if (e.type === "error") {
1031
- if (e.partialMatches.length === 0) {
1032
- let { matches: t, route: n } = Kt(c.activeRoutes);
1033
- return {
1034
- matches: t,
1035
- pendingActionResult: [n.id, {
1036
- type: "error",
1037
- error: e.error
1038
- }]
1039
- };
1040
- }
1041
- let t = Gt(e.partialMatches).route.id;
1042
- return {
1043
- matches: e.partialMatches,
1044
- pendingActionResult: [t, {
1045
- type: "error",
1046
- error: e.error
1047
- }]
1048
- };
1049
- }
1050
- if (e.matches) s = e.matches;
1051
- else {
1052
- let { notFoundMatches: e, error: t, route: r } = et(n.pathname);
1053
- return {
1054
- matches: e,
1055
- pendingActionResult: [r.id, {
1056
- type: "error",
1057
- error: t
1058
- }]
1059
- };
1060
- }
1061
- }
1062
- let h, g = cn(s, n);
1063
- if (!g.route.action && !g.route.lazy) h = {
1064
- type: "error",
1065
- error: q(405, {
1066
- method: t.method,
1067
- pathname: n.pathname,
1068
- routeId: g.route.id
1069
- })
1070
- };
1071
- else {
1072
- let e = await Me(t, n, Ot(a, o, t, n, s, g, p ? [] : r, d), d, null);
1073
- if (h = e[g.route.id], !h) {
1074
- for (let t of s) if (e[t.route.id]) {
1075
- h = e[t.route.id];
1076
- break;
1077
- }
1078
- }
1079
- if (t.signal.aborted) return { shortCircuited: !0 };
1080
- }
1081
- if (en(h)) {
1082
- let n;
1083
- return n = m && m.replace != null ? m.replace : It(h.response.headers.get("Location"), new URL(t.url), l, e.history) === P.location.pathname + P.location.search, await je(t, h, !0, {
1084
- submission: i,
1085
- replace: n
1086
- }), { shortCircuited: !0 };
1087
- }
1088
- if (J(h)) {
1089
- let e = Gt(s, g.route.id);
1090
- return (m && m.replace) !== !0 && (F = "PUSH"), {
1091
- matches: s,
1092
- pendingActionResult: [
1093
- e.route.id,
1094
- h,
1095
- g.route.id
1096
- ]
1097
- };
1098
- }
1099
- return {
1100
- matches: s,
1101
- pendingActionResult: [g.route.id, h]
1102
- };
1103
- }
1104
- async function Se(t, n, i, s, u, d, f, p, m, h, g, _, v, y) {
1105
- let b = f || un(n, i, s, p), x = p || m || ln(b), S = !z && !g;
1106
- if (d) {
1107
- if (S) {
1108
- let e = we(v);
1109
- W({
1110
- navigation: b,
1111
- ...e === void 0 ? {} : { actionData: e }
1112
- }, { flushSync: _ });
1113
- }
1114
- let e = await ft(i, n.pathname, t.signal);
1115
- if (e.type === "aborted") return { shortCircuited: !0 };
1116
- if (e.type === "error") {
1117
- if (e.partialMatches.length === 0) {
1118
- let { matches: t, route: n } = Kt(c.activeRoutes);
1119
- return {
1120
- matches: t,
1121
- loaderData: {},
1122
- errors: { [n.id]: e.error }
1123
- };
1124
- }
1125
- let t = Gt(e.partialMatches).route.id;
1126
- return {
1127
- matches: e.partialMatches,
1128
- loaderData: {},
1129
- errors: { [t]: e.error }
1130
- };
1131
- }
1132
- if (e.matches) i = e.matches;
1133
- else {
1134
- let { error: e, notFoundMatches: t, route: r } = et(n.pathname);
1135
- return {
1136
- matches: t,
1137
- loaderData: {},
1138
- errors: { [r.id]: e }
1139
- };
1140
- }
1141
- }
1142
- let C = c.activeRoutes, { dsMatches: w, revalidatingFetchers: T } = lt(t, u, a, o, e.history, P, i, x, n, g ? [] : r, g === !0, ie, ae, U, le, V, C, l, e.patchRoutesOnNavigation != null, c.branches, v, y);
1143
- if (se = ++oe, !e.dataStrategy && !w.some((e) => e.shouldLoad) && !w.some((e) => e.route.middleware && e.route.middleware.length > 0) && T.length === 0) {
1144
- let e = new Map(P.fetchers), t = Ue(e);
1145
- return G(n, {
1146
- matches: i,
1147
- loaderData: {},
1148
- errors: v && J(v[1]) ? { [v[0]]: v[1].error } : null,
1149
- ...Wt(v),
1150
- ...t ? { fetchers: e } : {}
1151
- }, { flushSync: _ }), { shortCircuited: !0 };
1152
- }
1153
- if (S) {
1154
- let e = {};
1155
- if (!d) {
1156
- e.navigation = b;
1157
- let t = we(v);
1158
- t !== void 0 && (e.actionData = t);
1159
- }
1160
- T.length > 0 && (e.fetchers = Te(T)), W(e, { flushSync: _ });
1161
- }
1162
- T.forEach((e) => {
1163
- Be(e.key), e.controller && B.set(e.key, e.controller);
1164
- });
1165
- let E = () => T.forEach((e) => Be(e.key));
1166
- L && L.signal.addEventListener("abort", E);
1167
- let { loaderResults: D, fetcherResults: O } = await Ne(w, T, t, n, u);
1168
- if (t.signal.aborted) return { shortCircuited: !0 };
1169
- L && L.signal.removeEventListener("abort", E), T.forEach((e) => B.delete(e.key));
1170
- let k = qt(D);
1171
- if (k) return await je(t, k.result, !0, { replace: h }), { shortCircuited: !0 };
1172
- if (k = qt(O), k) return V.add(k.key), await je(t, k.result, !0, { replace: h }), { shortCircuited: !0 };
1173
- let A = new Map(P.fetchers), { loaderData: j, errors: M } = Ht(P, i, D, v, T, O, A);
1174
- g && P.errors && (M = {
1175
- ...P.errors,
1176
- ...M
1177
- });
1178
- let ee = Ue(A), N = We(se, A), F = ee || N || T.length > 0;
1179
- return {
1180
- matches: i,
1181
- loaderData: j,
1182
- errors: M,
1183
- ...F ? { workingFetchers: A } : {}
1184
- };
1185
- }
1186
- function we(e) {
1187
- if (e && !J(e[1])) return { [e[0]]: e[1].data };
1188
- if (P.actionData) return Object.keys(P.actionData).length === 0 ? null : P.actionData;
1189
- }
1190
- function Te(e) {
1191
- let t = new Map(P.fetchers);
1192
- return e.forEach((e) => {
1193
- let n = t.get(e.key), r = fn(void 0, n ? n.data : void 0);
1194
- t.set(e.key, r);
1195
- }), t;
1196
- }
1197
- async function Ee(t, n, r, i) {
1198
- Be(t);
1199
- let a = (i && i.flushSync) === !0, o = c.activeRoutes, s = st(P.location, P.matches, l, r, n, i?.relative), u = M(o, s, l, !1, c.branches), d = ot(u, o, s);
1200
- if (d.active && d.matches && (u = d.matches), !u) {
1201
- Fe(t, n, q(404, { pathname: s }), { flushSync: a });
1202
- return;
1203
- }
1204
- let { path: f, submission: p, error: m } = ct(!0, s, i);
1205
- if (m) {
1206
- Fe(t, n, m, { flushSync: a });
1207
- return;
1208
- }
1209
- let h = e.getContext ? await e.getContext() : new C(), g = (i && i.preventScrollReset) === !0;
1210
- if (p && Y(p.formMethod)) {
1211
- await De(t, n, f, u, h, d.active, a, g, p, i && i.defaultShouldRevalidate);
1212
- return;
1213
- }
1214
- le.set(t, {
1215
- routeId: n,
1216
- path: f
1217
- }), await Ae(t, n, f, u, h, d.active, a, g, p);
1218
- }
1219
- async function De(t, n, i, s, u, d, p, m, h, g) {
1220
- Pe(), le.delete(t), K(t, pn(h, P.fetchers.get(t)), { flushSync: p });
1221
- let _ = new AbortController(), v = Lt(e.history, i, _.signal, h);
1222
- if (d) {
1223
- let e = await ft(s, new URL(v.url).pathname, v.signal, t);
1224
- if (e.type === "aborted") return;
1225
- if (e.type === "error") {
1226
- Fe(t, n, e.error, { flushSync: p });
1227
- return;
1228
- }
1229
- if (e.matches) s = e.matches;
1230
- else {
1231
- Fe(t, n, q(404, { pathname: i }), { flushSync: p });
1232
- return;
1233
- }
1234
- }
1235
- let y = cn(s, i);
1236
- if (!y.route.action && !y.route.lazy) {
1237
- Fe(t, n, q(405, {
1238
- method: h.formMethod,
1239
- pathname: i,
1240
- routeId: n
1241
- }), { flushSync: p });
1242
- return;
1243
- }
1244
- B.set(t, _);
1245
- let b = oe, x = Ot(a, o, v, i, s, y, r, u), S = await Me(v, i, x, u, t), C = S[y.route.id];
1246
- if (!C) {
1247
- for (let e of x) if (S[e.route.id]) {
1248
- C = S[e.route.id];
1249
- break;
1250
- }
1251
- }
1252
- if (v.signal.aborted) {
1253
- B.get(t) === _ && B.delete(t);
1254
- return;
1255
- }
1256
- if (U.has(t)) {
1257
- if (en(C) || J(C)) {
1258
- K(t, X(void 0));
1259
- return;
1260
- }
1261
- } else {
1262
- if (en(C)) {
1263
- if (B.delete(t), se > b) {
1264
- K(t, X(void 0));
1265
- return;
1266
- }
1267
- return V.add(t), K(t, fn(h)), je(v, C, !1, {
1268
- fetcherSubmission: h,
1269
- preventScrollReset: m
1270
- });
1271
- }
1272
- if (J(C)) {
1273
- Fe(t, n, C.error);
1274
- return;
1275
- }
1276
- }
1277
- let w = P.navigation.location || P.location, T = Lt(e.history, w, _.signal), E = c.activeRoutes, D = P.navigation.state === "idle" ? P.matches : M(E, P.navigation.location, l, !1, c.branches);
1278
- f(D, "Didn't find any matches after fetcher action");
1279
- let O = ++oe;
1280
- ce.set(t, O);
1281
- let { dsMatches: k, revalidatingFetchers: A } = lt(T, u, a, o, e.history, P, D, h, w, r, !1, ie, ae, U, le, V, E, l, e.patchRoutesOnNavigation != null, c.branches, [y.route.id, C], g), j = fn(h, C.data), ee = new Map(P.fetchers);
1282
- ee.set(t, j), A.filter((e) => e.key !== t).forEach((e) => {
1283
- let t = e.key, n = ee.get(t), r = fn(void 0, n ? n.data : void 0);
1284
- ee.set(t, r), Be(t), e.controller && B.set(t, e.controller);
1285
- }), W({ fetchers: ee });
1286
- let N = () => A.forEach((e) => Be(e.key));
1287
- _.signal.addEventListener("abort", N);
1288
- let { loaderResults: I, fetcherResults: te } = await Ne(k, A, T, w, u);
1289
- if (_.signal.aborted) return;
1290
- _.signal.removeEventListener("abort", N), ce.delete(t), B.delete(t), A.forEach((e) => B.delete(e.key));
1291
- let ne = P.fetchers.has(t), re = (e) => {
1292
- if (!ne) return e;
1293
- let n = new Map(e.fetchers);
1294
- return n.set(t, X(C.data)), {
1295
- ...e,
1296
- fetchers: n
1297
- };
1298
- }, R = qt(I);
1299
- if (R) return P = re(P), je(T, R.result, !1, { preventScrollReset: m });
1300
- if (R = qt(te), R) return V.add(R.key), P = re(P), je(T, R.result, !1, { preventScrollReset: m });
1301
- let z = new Map(P.fetchers);
1302
- ne && z.set(t, X(C.data));
1303
- let { loaderData: H, errors: ue } = Ht(P, D, I, void 0, A, te, z);
1304
- We(O, z), P.navigation.state === "loading" && O > se ? (f(F, "Expected pending action"), L && L.abort(), G(P.navigation.location, {
1305
- matches: D,
1306
- loaderData: H,
1307
- errors: ue,
1308
- fetchers: z
1309
- })) : (W({
1310
- errors: ue,
1311
- loaderData: Ut(P.loaderData, H, D, ue),
1312
- fetchers: z
1313
- }), ie = !1);
1314
- }
1315
- async function Ae(t, n, i, s, c, l, u, d, f) {
1316
- let p = P.fetchers.get(t);
1317
- K(t, fn(f, p ? p.data : void 0), { flushSync: u });
1318
- let m = new AbortController(), h = Lt(e.history, i, m.signal);
1319
- if (l) {
1320
- let e = await ft(s, new URL(h.url).pathname, h.signal, t);
1321
- if (e.type === "aborted") return;
1322
- if (e.type === "error") {
1323
- Fe(t, n, e.error, { flushSync: u });
1324
- return;
1325
- }
1326
- if (e.matches) s = e.matches;
1327
- else {
1328
- Fe(t, n, q(404, { pathname: i }), { flushSync: u });
1329
- return;
1330
- }
1331
- }
1332
- let g = cn(s, i);
1333
- B.set(t, m);
1334
- let _ = oe, v = await Me(h, i, Ot(a, o, h, i, s, g, r, c), c, t), y = v[g.route.id];
1335
- if (!y) {
1336
- for (let e of s) if (v[e.route.id]) {
1337
- y = v[e.route.id];
1338
- break;
1339
- }
1340
- }
1341
- if (B.get(t) === m && B.delete(t), !h.signal.aborted) {
1342
- if (U.has(t)) {
1343
- K(t, X(void 0));
1344
- return;
1345
- }
1346
- if (en(y)) {
1347
- if (se > _) {
1348
- K(t, X(void 0));
1349
- return;
1350
- }
1351
- V.add(t), await je(h, y, !1, { preventScrollReset: d });
1352
- return;
1353
- }
1354
- if (J(y)) {
1355
- Fe(t, n, y.error);
1356
- return;
1357
- }
1358
- K(t, X(y.data));
1359
- }
1360
- }
1361
- async function je(r, i, a, { submission: o, fetcherSubmission: s, preventScrollReset: c, replace: u } = {}) {
1362
- a || (I?.resolve(), I = null), i.response.headers.has("X-Remix-Revalidate") && (ie = !0);
1363
- let d = i.response.headers.get("Location");
1364
- f(d, "Expected a Location header on the redirect Response");
1365
- let p = d, m = new URL(r.url);
1366
- d = It(d, m, l, e.history), Ve(p, d, m, "allow-explicit");
1367
- let h = g(P.location, d, { _isRedirect: !0 });
1368
- if (n) {
1369
- let e = !1;
1370
- if (i.response.headers.has("X-Remix-Reload-Document")) e = !0;
1371
- else if (de(d)) {
1372
- let n = b(t, d, !0);
1373
- e = n.origin !== t.location.origin || H(n.pathname, l) == null;
1374
- }
1375
- if (e) {
1376
- u ? t.location.replace(d) : t.location.assign(d);
1377
- return;
1378
- }
1379
- }
1380
- L = null;
1381
- let _ = u === !0 || i.response.headers.has("X-Remix-Replace") ? "REPLACE" : "PUSH", { formMethod: v, formAction: y, formEncType: x } = P.navigation;
1382
- !o && !s && v && y && x && (o = ln(P.navigation));
1383
- let S = o || s;
1384
- qe.has(i.response.status) && S && Y(S.formMethod) ? await be(_, h, {
1385
- submission: {
1386
- ...S,
1387
- formAction: d
1388
- },
1389
- preventScrollReset: c || te,
1390
- enableViewTransition: a ? ne : void 0
1391
- }) : await be(_, h, {
1392
- overrideNavigation: un(h, [], _, o),
1393
- fetcherSubmission: s,
1394
- preventScrollReset: c || te,
1395
- enableViewTransition: a ? ne : void 0
1396
- });
1397
- }
1398
- async function Me(e, t, n, r, i) {
1399
- let a, o = {};
1400
- try {
1401
- a = await kt(u, e, t, n, i, r, !1);
1402
- } catch (e) {
1403
- return n.filter((e) => e.shouldLoad).forEach((t) => {
1404
- o[t.route.id] = {
1405
- type: "error",
1406
- error: e
1407
- };
1408
- }), o;
1409
- }
1410
- if (e.signal.aborted) return o;
1411
- if (!Y(e.method)) for (let e of n) {
1412
- if (a[e.route.id]?.type === "error") break;
1413
- !a.hasOwnProperty(e.route.id) && !P.loaderData.hasOwnProperty(e.route.id) && (!P.errors || !P.errors.hasOwnProperty(e.route.id)) && e.shouldCallHandler() && (a[e.route.id] = {
1414
- type: "error",
1415
- result: /* @__PURE__ */ Error(`No result returned from dataStrategy for route ${e.route.id}`)
1416
- });
1417
- }
1418
- for (let [t, r] of Object.entries(a)) if ($t(r)) {
1419
- let i = r.result;
1420
- o[t] = {
1421
- type: "redirect",
1422
- response: Nt(i, e, t, n, l)
1423
- };
1424
- } else o[t] = await Mt(r);
1425
- return o;
1426
- }
1427
- async function Ne(e, t, n, r, i) {
1428
- let a = Me(n, r, e, i, null), o = Promise.all(t.map(async (e) => {
1429
- if (e.matches && e.match && e.request && e.controller) {
1430
- let t = (await Me(e.request, e.path, e.matches, i, e.key))[e.match.route.id];
1431
- return { [e.key]: t };
1432
- }
1433
- return Promise.resolve({ [e.key]: {
1434
- type: "error",
1435
- error: q(404, { pathname: e.path })
1436
- } });
1437
- }));
1438
- return {
1439
- loaderResults: await a,
1440
- fetcherResults: (await o).reduce((e, t) => Object.assign(e, t), {})
1441
- };
1442
- }
1443
- function Pe() {
1444
- ie = !0, le.forEach((e, t) => {
1445
- B.has(t) && ae.add(t), Be(t);
1446
- });
1447
- }
1448
- function K(e, t, n = {}) {
1449
- let r = new Map(P.fetchers);
1450
- r.set(e, t), W({ fetchers: r }, { flushSync: (n && n.flushSync) === !0 });
1451
- }
1452
- function Fe(e, t, n, r = {}) {
1453
- let i = Gt(P.matches, t), a = new Map(P.fetchers);
1454
- Re(a, e), W({
1455
- errors: { [i.route.id]: n },
1456
- fetchers: a
1457
- }, { flushSync: (r && r.flushSync) === !0 });
1458
- }
1459
- function Ie(e) {
1460
- return ue.set(e, (ue.get(e) || 0) + 1), U.has(e) && U.delete(e), P.fetchers.get(e) || Ye;
1461
- }
1462
- function Le(e, t) {
1463
- Be(e, t?.reason), K(e, X(null));
1464
- }
1465
- function Re(e, t) {
1466
- let n = P.fetchers.get(t);
1467
- B.has(t) && !(n && n.state === "loading" && ce.has(t)) && Be(t), le.delete(t), ce.delete(t), V.delete(t), U.delete(t), ae.delete(t), e.delete(t);
1468
- }
1469
- function ze(e) {
1470
- let t = (ue.get(e) || 0) - 1;
1471
- t <= 0 ? (ue.delete(e), U.add(e)) : ue.set(e, t), W({ fetchers: new Map(P.fetchers) });
1472
- }
1473
- function Be(e, t) {
1474
- let n = B.get(e);
1475
- n && (n.abort(t), B.delete(e));
1476
- }
1477
- function He(e, t) {
1478
- for (let n of e) {
1479
- let e = t.get(n);
1480
- f(e, `Expected fetcher: ${n}`);
1481
- let r = X(e.data);
1482
- t.set(n, r);
1483
- }
1484
- }
1485
- function Ue(e) {
1486
- let t = [], n = !1;
1487
- for (let r of V) {
1488
- let i = e.get(r);
1489
- f(i, `Expected fetcher: ${r}`), i.state === "loading" && (V.delete(r), t.push(r), n = !0);
1490
- }
1491
- return He(t, e), n;
1492
- }
1493
- function We(e, t) {
1494
- let n = [];
1495
- for (let [r, i] of ce) if (i < e) {
1496
- let e = t.get(r);
1497
- f(e, `Expected fetcher: ${r}`), e.state === "loading" && (Be(r), ce.delete(r), n.push(r));
1498
- }
1499
- return He(n, t), n.length > 0;
1500
- }
1501
- function Ge(e, t) {
1502
- let n = P.blockers.get(e) || Xe;
1503
- return fe.get(e) !== t && fe.set(e, t), n;
1504
- }
1505
- function Ke(e) {
1506
- P.blockers.delete(e), fe.delete(e);
1507
- }
1508
- function Qe(e, t) {
1509
- let n = P.blockers.get(e) || Xe;
1510
- f(n.state === "unblocked" && t.state === "blocked" || n.state === "blocked" && t.state === "blocked" || n.state === "blocked" && t.state === "proceeding" || n.state === "blocked" && t.state === "unblocked" || n.state === "proceeding" && t.state === "unblocked", `Invalid blocker state transition: ${n.state} -> ${t.state}`);
1511
- let r = new Map(P.blockers);
1512
- r.set(e, t), W({ blockers: r });
1513
- }
1514
- function $e({ currentLocation: e, nextLocation: t, historyAction: n }) {
1515
- if (fe.size === 0) return;
1516
- fe.size > 1 && p(!1, "A router only supports one blocker at a time");
1517
- let r = Array.from(fe.entries()), [i, a] = r[r.length - 1], o = P.blockers.get(i);
1518
- if (!(o && o.state === "proceeding") && a({
1519
- currentLocation: e,
1520
- nextLocation: t,
1521
- historyAction: n
1522
- })) return i;
1523
- }
1524
- function et(e) {
1525
- let t = q(404, { pathname: e }), n = c.activeRoutes, { matches: r, route: i } = Kt(n);
1526
- return {
1527
- notFoundMatches: r,
1528
- route: i,
1529
- error: t
1530
- };
1531
- }
1532
- function tt(e, t, n) {
1533
- if (x = e, w = t, S = n || null, !T && P.navigation === Je) {
1534
- T = !0;
1535
- let e = at(P.location, P.matches);
1536
- e != null && W({ restoreScrollPosition: e });
1537
- }
1538
- return () => {
1539
- x = null, w = null, S = null;
1540
- };
1541
- }
1542
- function nt(e, t) {
1543
- return S && S(e, t.map((e) => ee(e, P.loaderData))) || e.key;
1544
- }
1545
- function rt(e, t) {
1546
- if (x && w) {
1547
- let n = nt(e, t);
1548
- x[n] = w();
1549
- }
1550
- }
1551
- function at(e, t) {
1552
- if (x) {
1553
- let n = nt(e, t), r = x[n];
1554
- if (typeof r == "number") return r;
1555
- }
1556
- return null;
1557
- }
1558
- function ot(t, n, r) {
1559
- if (e.patchRoutesOnNavigation) {
1560
- let e = c.branches;
1561
- if (!t) return {
1562
- active: !0,
1563
- matches: M(n, r, l, !0, e) || []
1564
- };
1565
- if (Object.keys(t[0].params).length > 0) return {
1566
- active: !0,
1567
- matches: M(n, r, l, !0, e)
1568
- };
1569
- }
1570
- return {
1571
- active: !1,
1572
- matches: null
1573
- };
1574
- }
1575
- async function ft(t, n, r, i) {
1576
- if (!e.patchRoutesOnNavigation) return {
1577
- type: "success",
1578
- matches: t
1579
- };
1580
- let s = t;
1581
- for (;;) {
1582
- let t = o;
1583
- try {
1584
- await e.patchRoutesOnNavigation({
1585
- signal: r,
1586
- path: n,
1587
- matches: s,
1588
- fetcherKey: i,
1589
- patch: (e, n) => {
1590
- r.aborted || ht(e, n, c, t, a, !1);
1591
- }
1592
- });
1593
- } catch (e) {
1594
- return {
1595
- type: "error",
1596
- error: e,
1597
- partialMatches: s
1598
- };
1599
- }
1600
- if (r.aborted) return { type: "aborted" };
1601
- let u = c.branches, d = M(c.activeRoutes, n, l, !1, u), f = null;
1602
- if (d && (Object.keys(d[0].params).length === 0 || (f = M(c.activeRoutes, n, l, !0, u), !(f && s.length < f.length && pt(s, f.slice(0, s.length)))))) return {
1603
- type: "success",
1604
- matches: d
1605
- };
1606
- if (f ||= M(c.activeRoutes, n, l, !0, u), !f || pt(s, f)) return {
1607
- type: "success",
1608
- matches: null
1609
- };
1610
- s = f;
1611
- }
1612
- }
1613
- function pt(e, t) {
1614
- return e.length === t.length && e.every((e, n) => e.route.id === t[n].route.id);
1615
- }
1616
- function mt(e) {
1617
- o = {}, c.setHmrRoutes(k(e, a, void 0, o));
1618
- }
1619
- function gt(e, t, n = !1) {
1620
- ht(e, t, c, o, a, n), c.hasHMRRoutes || W({});
1621
- }
1622
- return N = {
1623
- get basename() {
1624
- return l;
1625
- },
1626
- get future() {
1627
- return d;
1628
- },
1629
- get state() {
1630
- return P;
1631
- },
1632
- get routes() {
1633
- return c.stableRoutes;
1634
- },
1635
- get branches() {
1636
- return c.branches;
1637
- },
1638
- get manifest() {
1639
- return o;
1640
- },
1641
- get window() {
1642
- return t;
1643
- },
1644
- initialize: he,
1645
- subscribe: _e,
1646
- enableScrollRestoration: tt,
1647
- navigate: ve,
1648
- fetch: Ee,
1649
- revalidate: ye,
1650
- createHref: (t) => e.history.createHref(t),
1651
- createURL: (t) => e.history.createURL(t),
1652
- encodeLocation: (t) => e.history.encodeLocation(t),
1653
- getFetcher: Ie,
1654
- resetFetcher: Le,
1655
- deleteFetcher: ze,
1656
- dispose: ge,
1657
- getBlocker: Ge,
1658
- deleteBlocker: Ke,
1659
- patchRoutes: gt,
1660
- _internalFetchControllers: B,
1661
- _internalSetRoutes: mt,
1662
- _internalSetStateDoNotUseOrYouWillBreakYourApp(e) {
1663
- W(e);
1664
- }
1665
- }, e.instrumentations && (N = ke(N, e.instrumentations.map((e) => e.router).filter(Boolean))), N;
1666
- }
1667
- function ot(e) {
1668
- return e != null && ("formData" in e && e.formData != null || "body" in e && e.body !== void 0);
1669
- }
1670
- function st(e, t, n, r, i, a) {
1671
- let o, s;
1672
- if (i) {
1673
- o = [];
1674
- for (let e of t) if (o.push(e), e.route.id === i) {
1675
- s = e;
1676
- break;
1677
- }
1678
- } else o = t, s = t[t.length - 1];
1679
- let c = ge(r || ".", he(o), H(e.pathname, n) || e.pathname, a === "path");
1680
- if (r ?? (c.search = e.search, c.hash = e.hash), (r == null || r === "" || r === ".") && s) {
1681
- let e = sn(c.search);
1682
- if (s.route.index && !e) c.search = c.search ? c.search.replace(/^\?/, "?index&") : "?index";
1683
- else if (!s.route.index && e) {
1684
- let e = new URLSearchParams(c.search), t = e.getAll("index");
1685
- e.delete("index"), t.filter((e) => e).forEach((t) => e.append("index", t));
1686
- let n = e.toString();
1687
- c.search = n ? `?${n}` : "";
1688
- }
1689
- }
1690
- return n !== "/" && (c.pathname = ue({
1691
- basename: n,
1692
- pathname: c.pathname
1693
- })), _(c);
1694
- }
1695
- function ct(e, t, n) {
1696
- if (!n || !ot(n)) return { path: t };
1697
- if (n.formMethod && !on(n.formMethod)) return {
1698
- path: t,
1699
- error: q(405, { method: n.formMethod })
1700
- };
1701
- let r = () => ({
1702
- path: t,
1703
- error: q(400, { type: "invalid-body" })
1704
- }), i = (n.formMethod || "get").toUpperCase(), a = Jt(t);
1705
- if (n.body !== void 0) {
1706
- if (n.formEncType === "text/plain") {
1707
- if (!Y(i)) return r();
1708
- let e = typeof n.body == "string" ? n.body : n.body instanceof FormData || n.body instanceof URLSearchParams ? Array.from(n.body.entries()).reduce((e, [t, n]) => `${e}${t}=${n}
1709
- `, "") : String(n.body);
1710
- return {
1711
- path: t,
1712
- submission: {
1713
- formMethod: i,
1714
- formAction: a,
1715
- formEncType: n.formEncType,
1716
- formData: void 0,
1717
- json: void 0,
1718
- text: e
1719
- }
1720
- };
1721
- }
1722
- if (n.formEncType === "application/json") {
1723
- if (!Y(i)) return r();
1724
- try {
1725
- let e = typeof n.body == "string" ? JSON.parse(n.body) : n.body;
1726
- return {
1727
- path: t,
1728
- submission: {
1729
- formMethod: i,
1730
- formAction: a,
1731
- formEncType: n.formEncType,
1732
- formData: void 0,
1733
- json: e,
1734
- text: void 0
1735
- }
1736
- };
1737
- } catch {
1738
- return r();
1739
- }
1740
- }
1741
- }
1742
- f(typeof FormData == "function", "FormData is not available in this environment");
1743
- let o, s;
1744
- if (n.formData) o = zt(n.formData), s = n.formData;
1745
- else if (n.body instanceof FormData) o = zt(n.body), s = n.body;
1746
- else if (n.body instanceof URLSearchParams) o = n.body, s = Bt(o);
1747
- else if (n.body == null) o = new URLSearchParams(), s = new FormData();
1748
- else try {
1749
- o = new URLSearchParams(n.body), s = Bt(o);
1750
- } catch {
1751
- return r();
1752
- }
1753
- let c = {
1754
- formMethod: i,
1755
- formAction: a,
1756
- formEncType: n && n.formEncType || "application/x-www-form-urlencoded",
1757
- formData: s,
1758
- json: void 0,
1759
- text: void 0
1760
- };
1761
- if (Y(c.formMethod)) return {
1762
- path: t,
1763
- submission: c
1764
- };
1765
- let l = v(t);
1766
- return e && l.search && sn(l.search) && o.append("index", ""), l.search = `?${o}`, {
1767
- path: _(l),
1768
- submission: c
1769
- };
1770
- }
1771
- function lt(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y, b, x) {
1772
- let S = b ? J(b[1]) ? b[1].error : b[1].data : void 0, C = i.createURL(a.location), w = i.createURL(c), T;
1773
- if (u && a.errors) {
1774
- let e = Object.keys(a.errors)[0];
1775
- T = o.findIndex((t) => t.route.id === e);
1776
- } else if (b && J(b[1])) {
1777
- let e = b[0];
1778
- T = o.findIndex((t) => t.route.id === e) - 1;
1779
- }
1780
- let E = b ? b[1].statusCode : void 0, D = E && E >= 400, O = {
1781
- currentUrl: C,
1782
- currentParams: a.matches[0]?.params || {},
1783
- nextUrl: w,
1784
- nextParams: o[0].params,
1785
- ...s,
1786
- actionResult: S,
1787
- actionStatus: E
1788
- }, k = we(o), A = o.map((i, o) => {
1789
- let { route: s } = i, f = null;
1790
- if (T != null && o > T) f = !1;
1791
- else if (s.lazy) f = !0;
1792
- else if (!ut(s)) f = !1;
1793
- else if (u) {
1794
- let { shouldLoad: e } = dt(s, a.loaderData, a.errors);
1795
- f = e;
1796
- } else ft(a.loaderData, a.matches[o], i) && (f = !0);
1797
- if (f !== null) return Dt(n, r, e, c, k, i, l, t, f);
1798
- let p = !1;
1799
- typeof x == "boolean" ? p = x : D ? p = !1 : d || C.pathname + C.search === w.pathname + w.search ? p = !0 : C.search === w.search ? pt(a.matches[o], i) && (p = !0) : p = !0;
1800
- let m = {
1801
- ...O,
1802
- defaultShouldRevalidate: p
1803
- }, h = mt(i, m);
1804
- return Dt(n, r, e, c, k, i, l, t, h, m, x);
1805
- }), j = [];
1806
- return m.forEach((e, s) => {
1807
- if (u || !o.some((t) => t.route.id === e.routeId) || p.has(s)) return;
1808
- let c = a.fetchers.get(s), m = c && c.state !== "idle" && c.data === void 0, b = M(g, e.path, _ ?? "/", !1, y);
1809
- if (!b) {
1810
- if (v && m) return;
1811
- j.push({
1812
- key: s,
1813
- routeId: e.routeId,
1814
- path: e.path,
1815
- matches: null,
1816
- match: null,
1817
- request: null,
1818
- controller: null
1819
- });
1820
- return;
1821
- }
1822
- if (h.has(s)) return;
1823
- let S = cn(b, e.path), C = new AbortController(), w = Lt(i, e.path, C.signal), T = null;
1824
- if (f.has(s)) f.delete(s), T = Ot(n, r, w, e.path, b, S, l, t);
1825
- else if (m) d && (T = Ot(n, r, w, e.path, b, S, l, t));
1826
- else {
1827
- let i;
1828
- i = typeof x == "boolean" ? x : !D && d;
1829
- let a = {
1830
- ...O,
1831
- defaultShouldRevalidate: i
1832
- };
1833
- mt(S, a) && (T = Ot(n, r, w, e.path, b, S, l, t, a));
1834
- }
1835
- T && j.push({
1836
- key: s,
1837
- routeId: e.routeId,
1838
- path: e.path,
1839
- matches: T,
1840
- match: S,
1841
- request: w,
1842
- controller: C
1843
- });
1844
- }), {
1845
- dsMatches: A,
1846
- revalidatingFetchers: j
1847
- };
1848
- }
1849
- function ut(e) {
1850
- return e.loader != null || e.middleware != null && e.middleware.length > 0;
1851
- }
1852
- function dt(e, t, n) {
1853
- if (e.lazy) return {
1854
- shouldLoad: !0,
1855
- renderFallback: !0
1856
- };
1857
- if (!ut(e)) return {
1858
- shouldLoad: !1,
1859
- renderFallback: !1
1860
- };
1861
- let r = t != null && e.id in t, i = n != null && n[e.id] !== void 0;
1862
- if (!r && i) return {
1863
- shouldLoad: !1,
1864
- renderFallback: !1
1865
- };
1866
- if (typeof e.loader == "function" && e.loader.hydrate === !0) return {
1867
- shouldLoad: !0,
1868
- renderFallback: !r
1869
- };
1870
- let a = !r && !i;
1871
- return {
1872
- shouldLoad: a,
1873
- renderFallback: a
1874
- };
1875
- }
1876
- function ft(e, t, n) {
1877
- let r = !t || n.route.id !== t.route.id, i = !e.hasOwnProperty(n.route.id);
1878
- return r || i;
1879
- }
1880
- function pt(e, t) {
1881
- let n = e.route.path;
1882
- return e.pathname !== t.pathname || n != null && n.endsWith("*") && e.params["*"] !== t.params["*"];
1883
- }
1884
- function mt(e, t) {
1885
- if (e.route.shouldRevalidate) {
1886
- let n = e.route.shouldRevalidate(t);
1887
- if (typeof n == "boolean") return n;
1888
- }
1889
- return t.defaultShouldRevalidate;
1890
- }
1891
- function ht(e, t, n, r, i, a) {
1892
- let o;
1893
- if (e) {
1894
- let t = r[e];
1895
- f(t, `No route found to patch children into: routeId = ${e}`), t.children ||= [], o = t.children;
1896
- } else o = n.activeRoutes;
1897
- let s = [], c = [];
1898
- if (t.forEach((e) => {
1899
- let t = o.find((t) => gt(e, t));
1900
- t ? c.push({
1901
- existingRoute: t,
1902
- newRoute: e
1903
- }) : s.push(e);
1904
- }), s.length > 0) {
1905
- let t = k(s, i, [
1906
- e || "_",
1907
- "patch",
1908
- String(o?.length || "0")
1909
- ], r);
1910
- o.push(...t);
1911
- }
1912
- if (a && c.length > 0) for (let e = 0; e < c.length; e++) {
1913
- let { existingRoute: t, newRoute: n } = c[e], r = t, [a] = k([n], i, [], {}, !0);
1914
- Object.assign(r, {
1915
- element: a.element ? a.element : r.element,
1916
- errorElement: a.errorElement ? a.errorElement : r.errorElement,
1917
- hydrateFallbackElement: a.hydrateFallbackElement ? a.hydrateFallbackElement : r.hydrateFallbackElement
1918
- });
1919
- }
1920
- n.hasHMRRoutes || n.setRoutes([...n.activeRoutes]);
1921
- }
1922
- function gt(e, t) {
1923
- return "id" in e && "id" in t && e.id === t.id ? !0 : e.index !== t.index || e.path !== t.path || e.caseSensitive !== t.caseSensitive ? !1 : (!e.children || e.children.length === 0) && (!t.children || t.children.length === 0) ? !0 : e.children?.every((e, n) => t.children?.some((t) => gt(e, t))) ?? !1;
1924
- }
1925
- var _t = /* @__PURE__ */ new WeakMap(), vt = ({ key: e, route: t, manifest: n, mapRouteProperties: r }) => {
1926
- let i = n[t.id];
1927
- if (f(i, "No route found in manifest"), !i.lazy || typeof i.lazy != "object") return;
1928
- let a = i.lazy[e];
1929
- if (!a) return;
1930
- let o = _t.get(i);
1931
- o || (o = {}, _t.set(i, o));
1932
- let s = o[e];
1933
- if (s) return s;
1934
- let c = (async () => {
1935
- let t = T(e), n = i[e] !== void 0 && e !== "hasErrorBoundary";
1936
- if (t) p(!t, "Route property " + e + " is not a supported lazy route property. This property will be ignored."), o[e] = Promise.resolve();
1937
- else if (n) p(!1, `Route "${i.id}" has a static property "${e}" defined. The lazy property will be ignored.`);
1938
- else {
1939
- let t = await a();
1940
- t != null && (Object.assign(i, { [e]: t }), Object.assign(i, r(i)));
1941
- }
1942
- typeof i.lazy == "object" && (i.lazy[e] = void 0, Object.values(i.lazy).every((e) => e === void 0) && (i.lazy = void 0));
1943
- })();
1944
- return o[e] = c, c;
1945
- }, yt = /* @__PURE__ */ new WeakMap();
1946
- function bt(e, t, n, r, i) {
1947
- let a = n[e.id];
1948
- if (f(a, "No route found in manifest"), !e.lazy) return {
1949
- lazyRoutePromise: void 0,
1950
- lazyHandlerPromise: void 0
1951
- };
1952
- if (typeof e.lazy == "function") {
1953
- let t = yt.get(a);
1954
- if (t) return {
1955
- lazyRoutePromise: t,
1956
- lazyHandlerPromise: t
1957
- };
1958
- let n = (async () => {
1959
- f(typeof e.lazy == "function", "No lazy route function found");
1960
- let t = await e.lazy(), n = {};
1961
- for (let e in t) {
1962
- let r = t[e];
1963
- if (r === void 0) continue;
1964
- let i = D(e), o = a[e] !== void 0 && e !== "hasErrorBoundary";
1965
- i ? p(!i, "Route property " + e + " is not a supported property to be returned from a lazy route function. This property will be ignored.") : o ? p(!o, `Route "${a.id}" has a static property "${e}" defined but its lazy function is also returning a value for this property. The lazy route property "${e}" will be ignored.`) : n[e] = r;
1966
- }
1967
- Object.assign(a, n), Object.assign(a, {
1968
- ...r(a),
1969
- lazy: void 0
1970
- });
1971
- })();
1972
- return yt.set(a, n), n.catch(() => {}), {
1973
- lazyRoutePromise: n,
1974
- lazyHandlerPromise: n
1975
- };
1976
- }
1977
- let o = Object.keys(e.lazy), s = [], c;
1978
- for (let a of o) {
1979
- if (i && i.includes(a)) continue;
1980
- let o = vt({
1981
- key: a,
1982
- route: e,
1983
- manifest: n,
1984
- mapRouteProperties: r
1985
- });
1986
- o && (s.push(o), a === t && (c = o));
1987
- }
1988
- let l = s.length > 0 ? Promise.all(s).then(() => {}) : void 0;
1989
- return l?.catch(() => {}), c?.catch(() => {}), {
1990
- lazyRoutePromise: l,
1991
- lazyHandlerPromise: c
1992
- };
1993
- }
1994
- async function xt(e) {
1995
- let t = e.matches.filter((e) => e.shouldLoad), n = {};
1996
- return (await Promise.all(t.map((e) => e.resolve()))).forEach((e, r) => {
1997
- n[t[r].route.id] = e;
1998
- }), n;
1999
- }
2000
- async function St(e) {
2001
- return e.matches.some((e) => e.route.middleware) ? Ct(e, () => xt(e)) : xt(e);
2002
- }
2003
- function Ct(e, t) {
2004
- return wt(e, t, (e) => {
2005
- if (an(e)) throw e;
2006
- return e;
2007
- }, Zt, n);
2008
- function n(t, n, r) {
2009
- if (r) return Promise.resolve(Object.assign(r.value, { [n]: {
2010
- type: "error",
2011
- result: t
2012
- } }));
2013
- {
2014
- let { matches: r } = e, i = Gt(r, r[Math.min(Math.max(r.findIndex((e) => e.route.id === n), 0), Math.max(r.findIndex((e) => e.shouldCallHandler()), 0))].route.id).route.id;
2015
- return Promise.resolve({ [i]: {
2016
- type: "error",
2017
- result: t
2018
- } });
2019
- }
2020
- }
2021
- }
2022
- async function wt(e, t, n, r, i) {
2023
- let { matches: a, ...o } = e;
2024
- return await Tt(o, a.flatMap((e) => e.route.middleware ? e.route.middleware.map((t) => [e.route.id, t]) : []), t, n, r, i);
2025
- }
2026
- async function Tt(e, t, n, r, i, a, o = 0) {
2027
- let { request: s } = e;
2028
- if (s.signal.aborted) throw s.signal.reason ?? /* @__PURE__ */ Error(`Request aborted: ${s.method} ${s.url}`);
2029
- let c = t[o];
2030
- if (!c) return await n();
2031
- let [l, u] = c, d, f = async () => {
2032
- if (d) throw Error("You may only call `next()` once per middleware");
2033
- try {
2034
- return d = { value: await Tt(e, t, n, r, i, a, o + 1) }, d.value;
2035
- } catch (e) {
2036
- return d = { value: await a(e, l, d) }, d.value;
2037
- }
2038
- };
2039
- try {
2040
- let t = await u(e, f), n = t == null ? void 0 : r(t);
2041
- return i(n) ? n : d ? n ?? d.value : (d = { value: await f() }, d.value);
2042
- } catch (e) {
2043
- return await a(e, l, d);
2044
- }
2045
- }
2046
- function Et(e, t, n, r, i) {
2047
- let a = vt({
2048
- key: "middleware",
2049
- route: r.route,
2050
- manifest: t,
2051
- mapRouteProperties: e
2052
- }), o = bt(r.route, Y(n.method) ? "action" : "loader", t, e, i);
2053
- return {
2054
- middleware: a,
2055
- route: o.lazyRoutePromise,
2056
- handler: o.lazyHandlerPromise
2057
- };
2058
- }
2059
- function Dt(e, t, n, r, i, a, o, s, c, l = null, u) {
2060
- let d = !1, f = Et(e, t, n, a, o);
2061
- return {
2062
- ...a,
2063
- _lazyPromises: f,
2064
- shouldLoad: c,
2065
- shouldRevalidateArgs: l,
2066
- shouldCallHandler(e) {
2067
- return d = !0, l ? typeof u == "boolean" ? mt(a, {
2068
- ...l,
2069
- defaultShouldRevalidate: u
2070
- }) : typeof e == "boolean" ? mt(a, {
2071
- ...l,
2072
- defaultShouldRevalidate: e
2073
- }) : mt(a, l) : c;
2074
- },
2075
- resolve(e) {
2076
- let { lazy: t, loader: o, middleware: l } = a.route, u = d || c || e && !Y(n.method) && (t || o), p = l && l.length > 0 && !o && !t;
2077
- return u && (Y(n.method) || !p) ? At({
2078
- request: n,
2079
- path: r,
2080
- pattern: i,
2081
- match: a,
2082
- lazyHandlerPromise: f?.handler,
2083
- lazyRoutePromise: f?.route,
2084
- handlerOverride: e,
2085
- scopedContext: s
2086
- }) : Promise.resolve({
2087
- type: "data",
2088
- result: void 0
2089
- });
2090
- }
2091
- };
2092
- }
2093
- function Ot(e, t, n, r, i, a, o, s, c = null) {
2094
- return i.map((l) => l.route.id === a.route.id ? Dt(e, t, n, r, we(i), l, o, s, !0, c) : {
2095
- ...l,
2096
- shouldLoad: !1,
2097
- shouldRevalidateArgs: c,
2098
- shouldCallHandler: () => !1,
2099
- _lazyPromises: Et(e, t, n, l, o),
2100
- resolve: () => Promise.resolve({
2101
- type: "data",
2102
- result: void 0
2103
- })
2104
- });
2105
- }
2106
- async function kt(e, t, n, r, i, a, o) {
2107
- r.some((e) => e._lazyPromises?.middleware) && await Promise.all(r.map((e) => e._lazyPromises?.middleware));
2108
- let s = {
2109
- request: t,
2110
- url: Rt(t, n),
2111
- pattern: we(r),
2112
- params: r[0].params,
2113
- context: a,
2114
- matches: r
2115
- }, c = o ? () => {
2116
- throw Error("You cannot call `runClientMiddleware()` from a static handler `dataStrategy`. Middleware is run outside of `dataStrategy` during SSR in order to bubble up the Response. You can enable middleware via the `respond` API in `query`/`queryRoute`");
2117
- } : (e) => {
2118
- let t = s;
2119
- return Ct(t, () => e({
2120
- ...t,
2121
- fetcherKey: i,
2122
- runClientMiddleware: () => {
2123
- throw Error("Cannot call `runClientMiddleware()` from within an `runClientMiddleware` handler");
2124
- }
2125
- }));
2126
- }, l = await e({
2127
- ...s,
2128
- fetcherKey: i,
2129
- runClientMiddleware: c
2130
- });
2131
- try {
2132
- await Promise.all(r.flatMap((e) => [e._lazyPromises?.handler, e._lazyPromises?.route]));
2133
- } catch {}
2134
- return l;
2135
- }
2136
- async function At({ request: e, path: t, pattern: n, match: r, lazyHandlerPromise: i, lazyRoutePromise: a, handlerOverride: o, scopedContext: s }) {
2137
- let c, l, u = Y(e.method), d = u ? "action" : "loader", f = (i) => {
2138
- let a, c = new Promise((e, t) => a = t);
2139
- l = () => a(), e.signal.addEventListener("abort", l);
2140
- let u = (a) => typeof i == "function" ? i({
2141
- request: e,
2142
- url: Rt(e, t),
2143
- pattern: n,
2144
- params: r.params,
2145
- context: s
2146
- }, ...a === void 0 ? [] : [a]) : Promise.reject(/* @__PURE__ */ Error(`You cannot call the handler for a route which defines a boolean "${d}" [routeId: ${r.route.id}]`)), f = (async () => {
2147
- try {
2148
- return {
2149
- type: "data",
2150
- result: await (o ? o((e) => u(e)) : u())
2151
- };
2152
- } catch (e) {
2153
- return {
2154
- type: "error",
2155
- result: e
2156
- };
2157
- }
2158
- })();
2159
- return Promise.race([f, c]);
2160
- };
2161
- try {
2162
- let t = u ? r.route.action : r.route.loader;
2163
- if (i || a) {
2164
- if (t) {
2165
- let e, [n] = await Promise.all([
2166
- f(t).catch((t) => {
2167
- e = t;
2168
- }),
2169
- i,
2170
- a
2171
- ]);
2172
- if (e !== void 0) throw e;
2173
- c = n;
2174
- } else {
2175
- await i;
2176
- let t = u ? r.route.action : r.route.loader;
2177
- if (t) [c] = await Promise.all([f(t), a]);
2178
- else if (d === "action") {
2179
- let t = new URL(e.url), n = t.pathname + t.search;
2180
- throw q(405, {
2181
- method: e.method,
2182
- pathname: n,
2183
- routeId: r.route.id
2184
- });
2185
- } else return {
2186
- type: "data",
2187
- result: void 0
2188
- };
2189
- }
2190
- } else if (t) c = await f(t);
2191
- else {
2192
- let t = new URL(e.url);
2193
- throw q(404, { pathname: t.pathname + t.search });
2194
- }
2195
- } catch (e) {
2196
- return {
2197
- type: "error",
2198
- result: e
2199
- };
2200
- } finally {
2201
- l && e.signal.removeEventListener("abort", l);
2202
- }
2203
- return c;
2204
- }
2205
- async function jt(e) {
2206
- let t = e.headers.get("Content-Type");
2207
- return t && /\bapplication\/json\b/.test(t) ? e.body == null ? null : e.json() : e.text();
2208
- }
2209
- async function Mt(e) {
2210
- let { result: t, type: n } = e;
2211
- if (nn(t)) {
2212
- let e;
2213
- try {
2214
- e = await jt(t);
2215
- } catch (e) {
2216
- return {
2217
- type: "error",
2218
- error: e
2219
- };
2220
- }
2221
- return n === "error" ? {
2222
- type: "error",
2223
- error: new Se(t.status, t.statusText, e),
2224
- statusCode: t.status,
2225
- headers: t.headers
2226
- } : {
2227
- type: "data",
2228
- data: e,
2229
- statusCode: t.status,
2230
- headers: t.headers
2231
- };
2232
- }
2233
- return n === "error" ? tn(t) ? t.data instanceof Error ? {
2234
- type: "error",
2235
- error: t.data,
2236
- statusCode: t.init?.status,
2237
- headers: t.init?.headers ? new Headers(t.init.headers) : void 0
2238
- } : {
2239
- type: "error",
2240
- error: Xt(t),
2241
- statusCode: Ce(t) ? t.status : void 0,
2242
- headers: t.init?.headers ? new Headers(t.init.headers) : void 0
2243
- } : {
2244
- type: "error",
2245
- error: t,
2246
- statusCode: Ce(t) ? t.status : void 0
2247
- } : tn(t) ? {
2248
- type: "data",
2249
- data: t.data,
2250
- statusCode: t.init?.status,
2251
- headers: t.init?.headers ? new Headers(t.init.headers) : void 0
2252
- } : {
2253
- type: "data",
2254
- data: t
2255
- };
2256
- }
2257
- function Nt(e, t, n, r, i) {
2258
- let a = e.headers.get("Location");
2259
- if (f(a, "Redirects returned/thrown from loaders/actions must have a Location header"), !de(a)) {
2260
- let o = r.slice(0, r.findIndex((e) => e.route.id === n) + 1);
2261
- a = st(new URL(t.url), o, i, a), e.headers.set("Location", a);
2262
- }
2263
- return e;
2264
- }
2265
- var Pt = [
2266
- "about:",
2267
- "blob:",
2268
- "chrome:",
2269
- "chrome-untrusted:",
2270
- "content:",
2271
- "data:",
2272
- "devtools:",
2273
- "file:",
2274
- "filesystem:",
2275
- "javascript:"
2276
- ];
2277
- function Ft(e) {
2278
- try {
2279
- return Pt.includes(new URL(e).protocol);
2280
- } catch {
2281
- return !1;
2282
- }
2283
- }
2284
- function It(e, t, n, r) {
2285
- if (de(e)) {
2286
- let r = e, i = s.test(r) ? new URL(c(r, t.protocol)) : new URL(r);
2287
- if (Ft(i.toString())) throw Error("Invalid redirect location");
2288
- let a = H(i.pathname, n) != null;
2289
- if (i.origin === t.origin && a) return _e(i.pathname) + i.search + i.hash;
2290
- }
2291
- try {
2292
- if (Ft(r.createURL(e).toString())) throw Error("Invalid redirect location");
2293
- } catch {}
2294
- return e;
2295
- }
2296
- function Lt(e, t, n, r) {
2297
- let i = e.createURL(Jt(t)).toString(), a = { signal: n };
2298
- if (r && Y(r.formMethod)) {
2299
- let { formMethod: e, formEncType: t } = r;
2300
- a.method = e.toUpperCase(), t === "application/json" ? (a.headers = new Headers({ "Content-Type": t }), a.body = JSON.stringify(r.json)) : a.body = t === "text/plain" ? r.text : t === "application/x-www-form-urlencoded" && r.formData ? zt(r.formData) : r.formData;
2301
- }
2302
- return new Request(i, a);
2303
- }
2304
- function Rt(e, t) {
2305
- let n = new URL(e.url), r = typeof t == "string" ? v(t) : t;
2306
- if (n.pathname = r.pathname || "/", r.search) {
2307
- let e = new URLSearchParams(r.search), t = e.getAll("index");
2308
- e.delete("index");
2309
- for (let n of t.filter(Boolean)) e.append("index", n);
2310
- n.search = e.size ? `?${e.toString()}` : "";
2311
- } else n.search = "";
2312
- return n.hash = r.hash || "", n;
2313
- }
2314
- function zt(e) {
2315
- let t = new URLSearchParams();
2316
- for (let [n, r] of e.entries()) t.append(n, typeof r == "string" ? r : r.name);
2317
- return t;
2318
- }
2319
- function Bt(e) {
2320
- let t = new FormData();
2321
- for (let [n, r] of e.entries()) t.append(n, r);
2322
- return t;
2323
- }
2324
- function Vt(e, t, n, r = !1, i = !1) {
2325
- let a = {}, o = null, s, c = !1, l = {}, u = n && J(n[1]) ? n[1].error : void 0;
2326
- return e.forEach((n) => {
2327
- if (!(n.route.id in t)) return;
2328
- let d = n.route.id, p = t[d];
2329
- if (f(!en(p), "Cannot handle redirect results in processLoaderData"), J(p)) {
2330
- let t = p.error;
2331
- if (u !== void 0 && (t = u, u = void 0), o ||= {}, i) o[d] = t;
2332
- else {
2333
- let n = Gt(e, d);
2334
- o[n.route.id] ?? (o[n.route.id] = t);
2335
- }
2336
- r || (a[d] = $e), c || (c = !0, s = Ce(p.error) ? p.error.status : 500), p.headers && (l[d] = p.headers);
2337
- } else a[d] = p.data, p.statusCode && p.statusCode !== 200 && !c && (s = p.statusCode), p.headers && (l[d] = p.headers);
2338
- }), u !== void 0 && n && (o = { [n[0]]: u }, n[2] && (a[n[2]] = void 0)), {
2339
- loaderData: a,
2340
- errors: o,
2341
- statusCode: s || 200,
2342
- loaderHeaders: l
2343
- };
2344
- }
2345
- function Ht(e, t, n, r, i, a, o) {
2346
- let { loaderData: s, errors: c } = Vt(t, n, r);
2347
- return i.filter((e) => !e.matches || e.matches.some((e) => e.shouldLoad)).forEach((t) => {
2348
- let { key: n, match: r, controller: i } = t;
2349
- if (i && i.signal.aborted) return;
2350
- let s = a[n];
2351
- if (f(s, "Did not find corresponding fetcher result"), J(s)) {
2352
- let t = Gt(e.matches, r?.route.id);
2353
- c && c[t.route.id] || (c = {
2354
- ...c,
2355
- [t.route.id]: s.error
2356
- }), o.delete(n);
2357
- } else if (en(s)) f(!1, "Unhandled fetcher revalidation redirect");
2358
- else {
2359
- let e = X(s.data);
2360
- o.set(n, e);
2361
- }
2362
- }), {
2363
- loaderData: s,
2364
- errors: c
2365
- };
2366
- }
2367
- function Ut(e, t, n, r) {
2368
- let i = Object.entries(t).filter(([, e]) => e !== $e).reduce((e, [t, n]) => (e[t] = n, e), {});
2369
- for (let a of n) {
2370
- let n = a.route.id;
2371
- if (!t.hasOwnProperty(n) && e.hasOwnProperty(n) && a.route.loader && (i[n] = e[n]), r && r.hasOwnProperty(n)) break;
2372
- }
2373
- return i;
2374
- }
2375
- function Wt(e) {
2376
- return e ? J(e[1]) ? { actionData: {} } : { actionData: { [e[0]]: e[1].data } } : {};
2377
- }
2378
- function Gt(e, t) {
2379
- return (t ? e.slice(0, e.findIndex((e) => e.route.id === t) + 1) : [...e]).reverse().find((e) => e.route.hasErrorBoundary === !0) || e[0];
2380
- }
2381
- function Kt(e) {
2382
- let t = e.length === 1 ? e[0] : e.find((e) => e.index || !e.path || e.path === "/") || { id: "__shim-error-route__" };
2383
- return {
2384
- matches: [{
2385
- params: {},
2386
- pathname: "",
2387
- pathnameBase: "",
2388
- route: t
2389
- }],
2390
- route: t
2391
- };
2392
- }
2393
- function q(e, { pathname: t, routeId: n, method: r, type: i, message: a } = {}) {
2394
- let o = "Unknown Server Error", s = "Unknown @remix-run/router error";
2395
- return e === 400 ? (o = "Bad Request", r && t && n ? s = `You made a ${r} request to "${t}" but did not provide a \`loader\` for route "${n}", so there is no way to handle the request.` : i === "invalid-body" && (s = "Unable to encode submission body")) : e === 403 ? (o = "Forbidden", s = `Route "${n}" does not match URL "${t}"`) : e === 404 ? (o = "Not Found", s = `No route matches URL "${t}"`) : e === 405 && (o = "Method Not Allowed", r && t && n ? s = `You made a ${r.toUpperCase()} request to "${t}" but did not provide an \`action\` for route "${n}", so there is no way to handle the request.` : r && (s = `Invalid request method "${r.toUpperCase()}"`)), new Se(e || 500, o, Error(s), !0);
2396
- }
2397
- function qt(e) {
2398
- let t = Object.entries(e);
2399
- for (let e = t.length - 1; e >= 0; e--) {
2400
- let [n, r] = t[e];
2401
- if (en(r)) return {
2402
- key: n,
2403
- result: r
2404
- };
2405
- }
2406
- }
2407
- function Jt(e) {
2408
- return _({
2409
- ...typeof e == "string" ? v(e) : e,
2410
- hash: ""
2411
- });
2412
- }
2413
- function Yt(e, t) {
2414
- return e.pathname !== t.pathname || e.search !== t.search ? !1 : e.hash === "" ? t.hash !== "" : e.hash === t.hash || t.hash !== "";
2415
- }
2416
- function Xt(e) {
2417
- return new Se(e.init?.status ?? 500, e.init?.statusText ?? "Internal Server Error", e.data);
2418
- }
2419
- function Zt(e) {
2420
- return typeof e == "object" && !!e && Object.entries(e).every(([e, t]) => typeof e == "string" && Qt(t));
2421
- }
2422
- function Qt(e) {
2423
- return typeof e == "object" && !!e && "type" in e && "result" in e && (e.type === "data" || e.type === "error");
2424
- }
2425
- function $t(e) {
2426
- return nn(e.result) && Ke.has(e.result.status);
2427
- }
2428
- function J(e) {
2429
- return e.type === "error";
2430
- }
2431
- function en(e) {
2432
- return (e && e.type) === "redirect";
2433
- }
2434
- function tn(e) {
2435
- return typeof e == "object" && !!e && "type" in e && "data" in e && "init" in e && e.type === "DataWithResponseInit";
2436
- }
2437
- function nn(e) {
2438
- return e != null && typeof e.status == "number" && typeof e.statusText == "string" && typeof e.headers == "object" && e.body !== void 0;
2439
- }
2440
- function rn(e) {
2441
- return Ke.has(e);
2442
- }
2443
- function an(e) {
2444
- return nn(e) && rn(e.status) && e.headers.has("Location");
2445
- }
2446
- function on(e) {
2447
- return Ge.has(e.toUpperCase());
2448
- }
2449
- function Y(e) {
2450
- return Ue.has(e.toUpperCase());
2451
- }
2452
- function sn(e) {
2453
- return new URLSearchParams(e).getAll("index").some((e) => e === "");
2454
- }
2455
- function cn(e, t) {
2456
- let n = typeof t == "string" ? v(t).search : t.search;
2457
- if (e[e.length - 1].route.index && sn(n || "")) return e[e.length - 1];
2458
- let r = me(e);
2459
- return r[r.length - 1];
2460
- }
2461
- function ln(e) {
2462
- let { formMethod: t, formAction: n, formEncType: r, text: i, formData: a, json: o } = e;
2463
- if (!(!t || !n || !r)) {
2464
- if (i != null) return {
2465
- formMethod: t,
2466
- formAction: n,
2467
- formEncType: r,
2468
- formData: void 0,
2469
- json: void 0,
2470
- text: i
2471
- };
2472
- if (a != null) return {
2473
- formMethod: t,
2474
- formAction: n,
2475
- formEncType: r,
2476
- formData: a,
2477
- json: void 0,
2478
- text: void 0
2479
- };
2480
- if (o !== void 0) return {
2481
- formMethod: t,
2482
- formAction: n,
2483
- formEncType: r,
2484
- formData: void 0,
2485
- json: o,
2486
- text: void 0
2487
- };
2488
- }
2489
- }
2490
- function un(e, t, n, r) {
2491
- return r ? {
2492
- state: "loading",
2493
- location: e,
2494
- matches: t,
2495
- historyAction: n,
2496
- formMethod: r.formMethod,
2497
- formAction: r.formAction,
2498
- formEncType: r.formEncType,
2499
- formData: r.formData,
2500
- json: r.json,
2501
- text: r.text
2502
- } : {
2503
- state: "loading",
2504
- location: e,
2505
- matches: t,
2506
- historyAction: n,
2507
- formMethod: void 0,
2508
- formAction: void 0,
2509
- formEncType: void 0,
2510
- formData: void 0,
2511
- json: void 0,
2512
- text: void 0
2513
- };
2514
- }
2515
- function dn(e, t, n, r) {
2516
- return {
2517
- state: "submitting",
2518
- location: e,
2519
- matches: t,
2520
- historyAction: n,
2521
- formMethod: r.formMethod,
2522
- formAction: r.formAction,
2523
- formEncType: r.formEncType,
2524
- formData: r.formData,
2525
- json: r.json,
2526
- text: r.text
2527
- };
2528
- }
2529
- function fn(e, t) {
2530
- return e ? {
2531
- state: "loading",
2532
- formMethod: e.formMethod,
2533
- formAction: e.formAction,
2534
- formEncType: e.formEncType,
2535
- formData: e.formData,
2536
- json: e.json,
2537
- text: e.text,
2538
- data: t
2539
- } : {
2540
- state: "loading",
2541
- formMethod: void 0,
2542
- formAction: void 0,
2543
- formEncType: void 0,
2544
- formData: void 0,
2545
- json: void 0,
2546
- text: void 0,
2547
- data: t
2548
- };
2549
- }
2550
- function pn(e, t) {
2551
- return {
2552
- state: "submitting",
2553
- formMethod: e.formMethod,
2554
- formAction: e.formAction,
2555
- formEncType: e.formEncType,
2556
- formData: e.formData,
2557
- json: e.json,
2558
- text: e.text,
2559
- data: t ? t.data : void 0
2560
- };
2561
- }
2562
- function X(e) {
2563
- return {
2564
- state: "idle",
2565
- formMethod: void 0,
2566
- formAction: void 0,
2567
- formEncType: void 0,
2568
- formData: void 0,
2569
- json: void 0,
2570
- text: void 0,
2571
- data: e
2572
- };
2573
- }
2574
- function mn(e, t) {
2575
- try {
2576
- let n = e.sessionStorage.getItem(Qe);
2577
- if (n) {
2578
- let e = JSON.parse(n);
2579
- for (let [n, r] of Object.entries(e || {})) r && Array.isArray(r) && t.set(n, new Set(r || []));
2580
- }
2581
- } catch {}
2582
- }
2583
- function hn(e, t) {
2584
- if (t.size > 0) {
2585
- let n = {};
2586
- for (let [e, r] of t) n[e] = [...r];
2587
- try {
2588
- e.sessionStorage.setItem(Qe, JSON.stringify(n));
2589
- } catch (e) {
2590
- p(!1, `Failed to save applied view transitions in sessionStorage (${e}).`);
2591
- }
2592
- }
2593
- }
2594
- function gn() {
2595
- let e, t, n = new Promise((r, i) => {
2596
- e = async (e) => {
2597
- r(e);
2598
- try {
2599
- await n;
2600
- } catch {}
2601
- }, t = async (e) => {
2602
- i(e);
2603
- try {
2604
- await n;
2605
- } catch {}
2606
- };
2607
- });
2608
- return {
2609
- promise: n,
2610
- resolve: e,
2611
- reject: t
2612
- };
2613
- }
2614
- var _n = e.createContext(null);
2615
- _n.displayName = "DataRouter";
2616
- var vn = e.createContext(null);
2617
- vn.displayName = "DataRouterState";
2618
- var yn = e.createContext(!1);
2619
- function bn() {
2620
- return e.useContext(yn);
2621
- }
2622
- var xn = e.createContext({ isTransitioning: !1 });
2623
- xn.displayName = "ViewTransition";
2624
- var Sn = e.createContext(/* @__PURE__ */ new Map());
2625
- Sn.displayName = "Fetchers";
2626
- var Cn = e.createContext(null);
2627
- Cn.displayName = "Await";
2628
- var Z = e.createContext(null);
2629
- Z.displayName = "Navigation";
2630
- var wn = e.createContext(null);
2631
- wn.displayName = "Location";
2632
- var Q = e.createContext({
2633
- outlet: null,
2634
- matches: [],
2635
- isDataRoute: !1
2636
- });
2637
- Q.displayName = "Route";
2638
- var Tn = e.createContext(null);
2639
- Tn.displayName = "RouteError";
2640
- var En = "REACT_ROUTER_ERROR", Dn = "REDIRECT", On = "ROUTE_ERROR_RESPONSE";
2641
- function kn(e) {
2642
- if (e.startsWith(`${En}:${Dn}:{`)) try {
2643
- let t = JSON.parse(e.slice(28));
2644
- 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") return t;
2645
- } catch {}
2646
- }
2647
- function An(e) {
2648
- if (e.startsWith(`${En}:${On}:{`)) try {
2649
- let t = JSON.parse(e.slice(40));
2650
- if (typeof t == "object" && t && typeof t.status == "number" && typeof t.statusText == "string") return new Se(t.status, t.statusText, t.data);
2651
- } catch {}
2652
- }
2653
- function jn(t, { relative: n } = {}) {
2654
- f(Mn(), "useHref() may be used only in the context of a <Router> component.");
2655
- let { basename: r, navigator: i } = e.useContext(Z), { hash: a, pathname: o, search: s } = Vn(t, { relative: n }), c = o;
2656
- return r !== "/" && (c = o === "/" ? r : W([r, o])), i.createHref({
2657
- pathname: c,
2658
- search: s,
2659
- hash: a
2660
- });
2661
- }
2662
- function Mn() {
2663
- return e.useContext(wn) != null;
2664
- }
2665
- function $() {
2666
- return f(Mn(), "useLocation() may be used only in the context of a <Router> component."), e.useContext(wn).location;
2667
- }
2668
- function Nn(t) {
2669
- f(Mn(), "useMatch() may be used only in the context of a <Router> component.");
2670
- let { pathname: n } = $();
2671
- return e.useMemo(() => se(t, le(n)), [n, t]);
2672
- }
2673
- var Pn = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
2674
- function Fn(t) {
2675
- e.useContext(Z).static || e.useLayoutEffect(t);
2676
- }
2677
- function In() {
2678
- let { isDataRoute: t } = e.useContext(Q);
2679
- return t ? ir() : Ln();
2680
- }
2681
- function Ln() {
2682
- f(Mn(), "useNavigate() may be used only in the context of a <Router> component.");
2683
- let t = e.useContext(_n), { basename: n, navigator: r } = e.useContext(Z), { matches: i } = e.useContext(Q), { pathname: a } = $(), o = JSON.stringify(he(i)), s = e.useRef(!1);
2684
- return Fn(() => {
2685
- s.current = !0;
2686
- }), e.useCallback((e, i = {}) => {
2687
- if (p(s.current, Pn), !s.current) return;
2688
- if (typeof e == "number") {
2689
- r.go(e);
2690
- return;
2691
- }
2692
- let c = ge(e, JSON.parse(o), a, i.relative === "path");
2693
- t == null && n !== "/" && (c.pathname = c.pathname === "/" ? n : W([n, c.pathname])), Ve(typeof e == "string" ? e : _(e), r.createHref(c), Re(r), "reject"), (i.replace ? r.replace : r.push)(c, i.state, i);
2694
- }, [
2695
- n,
2696
- r,
2697
- o,
2698
- a,
2699
- t
2700
- ]);
2701
- }
2702
- var Rn = e.createContext(null);
2703
- function zn(t) {
2704
- let n = e.useContext(Q).outlet;
2705
- return e.useMemo(() => n && /* @__PURE__ */ e.createElement(Rn.Provider, { value: t }, n), [n, t]);
2706
- }
2707
- function Bn() {
2708
- let { matches: t } = e.useContext(Q);
2709
- return t[t.length - 1]?.params ?? {};
2710
- }
2711
- function Vn(t, { relative: n } = {}) {
2712
- let { matches: r } = e.useContext(Q), { pathname: i } = $(), a = JSON.stringify(he(r));
2713
- return e.useMemo(() => ge(t, JSON.parse(a), i, n === "path"), [
2714
- t,
2715
- a,
2716
- i,
2717
- n
2718
- ]);
2719
- }
2720
- function Hn(t, n, r) {
2721
- f(Mn(), "useRoutes() may be used only in the context of a <Router> component.");
2722
- let { navigator: i } = e.useContext(Z), { matches: a } = e.useContext(Q), o = a[a.length - 1], s = o ? o.params : {}, c = o ? o.pathname : "/", l = o ? o.pathnameBase : "/", u = o && o.route;
2723
- {
2724
- let e = u && u.path || "";
2725
- or(c, !u || e.endsWith("*") || e.endsWith("*?"), `You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${e}">) 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.
2726
-
2727
- Please change the parent <Route path="${e}"> to <Route path="${e === "/" ? "*" : `${e}/*`}">.`);
2728
- }
2729
- let d = $(), m;
2730
- if (n) {
2731
- let e = typeof n == "string" ? v(n) : n;
2732
- f(l === "/" || e.pathname?.startsWith(l), `When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${l}" but pathname "${e.pathname}" was given in the \`location\` prop.`), m = e;
2733
- } else m = d;
2734
- let h = m.pathname || "/", g = h;
2735
- if (l !== "/") {
2736
- let e = l.replace(/^\//, "").split("/");
2737
- g = "/" + h.replace(/^\//, "").split("/").slice(e.length).join("/");
2738
- }
2739
- let _ = r && r.state.matches.length ? r.state.matches.map((e) => Object.assign(e, { route: r.manifest[e.route.id] || e.route })) : j(t, { pathname: g });
2740
- p(u || _ != null, `No routes matched location "${m.pathname}${m.search}${m.hash}" `), p(_ == null || _[_.length - 1].route.element !== void 0 || _[_.length - 1].route.Component !== void 0 || _[_.length - 1].route.lazy !== void 0, `Matched leaf route at location "${m.pathname}${m.search}${m.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.`);
2741
- let y = Yn(_ && _.map((e) => Object.assign({}, e, {
2742
- params: Object.assign({}, s, e.params),
2743
- pathname: W([l, i.encodeLocation ? i.encodeLocation(e.pathname.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")).pathname : e.pathname]),
2744
- pathnameBase: e.pathnameBase === "/" ? l : W([l, i.encodeLocation ? i.encodeLocation(e.pathnameBase.replace(/%/g, "%25").replace(/\?/g, "%3F").replace(/#/g, "%23")).pathname : e.pathnameBase])
2745
- })), a, r);
2746
- return n && y ? /* @__PURE__ */ e.createElement(wn.Provider, { value: {
2747
- location: {
2748
- pathname: "/",
2749
- search: "",
2750
- hash: "",
2751
- state: null,
2752
- key: "default",
2753
- mask: void 0,
2754
- ...m
2755
- },
2756
- navigationType: "POP"
2757
- } }, y) : y;
2758
- }
2759
- function Un() {
2760
- let t = rr(), n = Ce(t) ? `${t.status} ${t.statusText}` : t instanceof Error ? t.message : JSON.stringify(t), r = t instanceof Error ? t.stack : null, i = "rgba(200,200,200, 0.5)", a = {
2761
- padding: "0.5rem",
2762
- backgroundColor: i
2763
- }, o = {
2764
- padding: "2px 4px",
2765
- backgroundColor: i
2766
- }, s = null;
2767
- return console.error("Error handled by React Router default ErrorBoundary:", t), s = /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ e.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ e.createElement("code", { style: o }, "ErrorBoundary"), " or", " ", /* @__PURE__ */ e.createElement("code", { style: o }, "errorElement"), " prop on your route.")), /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ e.createElement("h3", { style: { fontStyle: "italic" } }, n), r ? /* @__PURE__ */ e.createElement("pre", { style: a }, r) : null, s);
2768
- }
2769
- var Wn = /* @__PURE__ */ e.createElement(Un, null), Gn = class extends e.Component {
2770
- constructor(e) {
2771
- super(e), this.state = {
2772
- location: e.location,
2773
- revalidation: e.revalidation,
2774
- error: e.error
2775
- };
2776
- }
2777
- static getDerivedStateFromError(e) {
2778
- return { error: e };
2779
- }
2780
- static getDerivedStateFromProps(e, t) {
2781
- return t.location !== e.location || t.revalidation !== "idle" && e.revalidation === "idle" ? {
2782
- error: e.error,
2783
- location: e.location,
2784
- revalidation: e.revalidation
2785
- } : {
2786
- error: e.error === void 0 ? t.error : e.error,
2787
- location: t.location,
2788
- revalidation: e.revalidation || t.revalidation
2789
- };
2790
- }
2791
- componentDidCatch(e, t) {
2792
- this.props.onError ? this.props.onError(e, t) : console.error("React Router caught the following error during render", e);
2793
- }
2794
- render() {
2795
- let t = this.state.error;
2796
- if (this.context && typeof t == "object" && t && "digest" in t && typeof t.digest == "string") {
2797
- let e = An(t.digest);
2798
- e && (t = e);
2799
- }
2800
- let n = t === void 0 ? this.props.children : /* @__PURE__ */ e.createElement(Q.Provider, { value: this.props.routeContext }, /* @__PURE__ */ e.createElement(Tn.Provider, {
2801
- value: t,
2802
- children: this.props.component
2803
- }));
2804
- return this.context ? /* @__PURE__ */ e.createElement(qn, { error: t }, n) : n;
2805
- }
2806
- };
2807
- Gn.contextType = yn;
2808
- var Kn = /* @__PURE__ */ new WeakMap();
2809
- function qn({ children: t, error: n }) {
2810
- let { basename: r, navigator: i } = e.useContext(Z);
2811
- if (typeof n == "object" && n && "digest" in n && typeof n.digest == "string") {
2812
- let t = kn(n.digest);
2813
- if (t) {
2814
- let a = Kn.get(n);
2815
- if (a) throw a;
2816
- let o = Ee(t.location, r), s = o.absoluteURL || o.to;
2817
- if (Ve(t.location, s, Re(i), "allow-explicit"), Ft(s)) throw Error("Invalid redirect location");
2818
- if (Te && !Kn.get(n)) {
2819
- if (o.isExternal || t.reloadDocument) window.location.href = s;
2820
- else {
2821
- let e = Promise.resolve().then(() => window.__reactRouterDataRouter.navigate(o.to, { replace: t.replace }));
2822
- throw Kn.set(n, e), e;
2823
- }
2824
- }
2825
- return /* @__PURE__ */ e.createElement("meta", {
2826
- httpEquiv: "refresh",
2827
- content: `0;url=${s}`
2828
- });
2829
- }
2830
- }
2831
- return t;
2832
- }
2833
- function Jn({ routeContext: t, match: n, children: r }) {
2834
- let i = e.useContext(_n);
2835
- return i && i.static && i.staticContext && (n.route.errorElement || n.route.ErrorBoundary) && (i.staticContext._deepestRenderedBoundaryId = n.route.id), /* @__PURE__ */ e.createElement(Q.Provider, { value: t }, r);
2836
- }
2837
- function Yn(t, n = [], r) {
2838
- let i = r?.state;
2839
- if (t == null) {
2840
- if (!i) return null;
2841
- if (i.errors) t = i.matches;
2842
- else if (n.length === 0 && !i.initialized && i.matches.length > 0) t = i.matches;
2843
- else return null;
2844
- }
2845
- let a = t, o = i?.errors;
2846
- if (o != null) {
2847
- let e = a.findIndex((e) => e.route.id && o?.[e.route.id] !== void 0);
2848
- f(e >= 0, `Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`), a = a.slice(0, Math.min(a.length, e + 1));
2849
- }
2850
- let s = !1, c = -1;
2851
- if (r && i) {
2852
- s = i.renderFallback;
2853
- for (let e = 0; e < a.length; e++) {
2854
- let t = a[e];
2855
- if ((t.route.HydrateFallback || t.route.hydrateFallbackElement) && (c = e), t.route.id) {
2856
- let { loaderData: e, errors: n } = i, o = t.route.loader && !e.hasOwnProperty(t.route.id) && (!n || n[t.route.id] === void 0);
2857
- if (t.route.lazy || o) {
2858
- r.isStatic && (s = !0), a = c >= 0 ? a.slice(0, c + 1) : [a[0]];
2859
- break;
2860
- }
2861
- }
2862
- }
2863
- }
2864
- let l = r?.onError, u = i && l ? (e, t) => {
2865
- l(e, {
2866
- location: i.location,
2867
- params: i.matches?.[0]?.params ?? {},
2868
- pattern: we(i.matches),
2869
- errorInfo: t
2870
- });
2871
- } : void 0;
2872
- return a.reduceRight((t, r, l) => {
2873
- let d, f = !1, p = null, m = null;
2874
- i && (d = o && r.route.id ? o[r.route.id] : void 0, p = r.route.errorElement || Wn, s && (c < 0 && l === 0 ? (or("route-fallback", !1, "No `HydrateFallback` element provided to render during initial hydration"), f = !0, m = null) : c === l && (f = !0, m = r.route.hydrateFallbackElement || null)));
2875
- let h = n.concat(a.slice(0, l + 1)), g = () => {
2876
- let n;
2877
- return n = d ? p : f ? m : r.route.Component ? /* @__PURE__ */ e.createElement(r.route.Component, null) : r.route.element ? r.route.element : t, /* @__PURE__ */ e.createElement(Jn, {
2878
- match: r,
2879
- routeContext: {
2880
- outlet: t,
2881
- matches: h,
2882
- isDataRoute: i != null
2883
- },
2884
- children: n
2885
- });
2886
- };
2887
- return i && (r.route.ErrorBoundary || r.route.errorElement || l === 0) ? /* @__PURE__ */ e.createElement(Gn, {
2888
- location: i.location,
2889
- revalidation: i.revalidation,
2890
- component: p,
2891
- error: d,
2892
- children: g(),
2893
- routeContext: {
2894
- outlet: null,
2895
- matches: h,
2896
- isDataRoute: !0
2897
- },
2898
- onError: u
2899
- }) : g();
2900
- }, null);
2901
- }
2902
- function Xn(e) {
2903
- return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
2904
- }
2905
- function Zn(t) {
2906
- let n = e.useContext(_n);
2907
- return f(n, Xn(t)), n;
2908
- }
2909
- function Qn(t) {
2910
- let n = e.useContext(vn);
2911
- return f(n, Xn(t)), n;
2912
- }
2913
- function $n(t) {
2914
- let n = e.useContext(Q);
2915
- return f(n, Xn(t)), n;
2916
- }
2917
- function er(e) {
2918
- let t = $n(e), n = t.matches[t.matches.length - 1];
2919
- return f(n.route.id, `${e} can only be used on routes that contain a unique "id"`), n.route.id;
2920
- }
2921
- function tr() {
2922
- return er("useRouteId");
2923
- }
2924
- function nr() {
2925
- let { matches: t, loaderData: n } = Qn("useMatches");
2926
- return e.useMemo(() => t.map((e) => ee(e, n)), [t, n]);
2927
- }
2928
- function rr() {
2929
- let t = e.useContext(Tn), n = Qn("useRouteError"), r = er("useRouteError");
2930
- return t === void 0 ? n.errors?.[r] : t;
2931
- }
2932
- function ir() {
2933
- let { router: t } = Zn("useNavigate"), n = er("useNavigate"), r = e.useRef(!1);
2934
- return Fn(() => {
2935
- r.current = !0;
2936
- }), e.useCallback(async (e, i = {}) => {
2937
- p(r.current, Pn), r.current && (typeof e == "number" ? await t.navigate(e) : await t.navigate(e, {
2938
- fromRouteId: n,
2939
- ...i
2940
- }));
2941
- }, [t, n]);
2942
- }
2943
- var ar = {};
2944
- function or(e, t, n) {
2945
- !t && !ar[e] && (ar[e] = !0, p(!1, n));
2946
- }
2947
- var sr = {};
2948
- function cr(e, t) {
2949
- !e && !sr[t] && (sr[t] = !0, console.warn(t));
2950
- }
2951
- var lr = e.useOptimistic, ur = () => void 0;
2952
- function dr(e) {
2953
- return lr ? lr(e) : [e, ur];
2954
- }
2955
- function fr(t) {
2956
- let n = { hasErrorBoundary: t.hasErrorBoundary || t.ErrorBoundary != null || t.errorElement != null };
2957
- return t.Component && (t.element && p(!1, "You should not include both `Component` and `element` on your route - `Component` will be used."), Object.assign(n, {
2958
- element: e.createElement(t.Component),
2959
- Component: void 0
2960
- })), t.HydrateFallback && (t.hydrateFallbackElement && p(!1, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used."), Object.assign(n, {
2961
- hydrateFallbackElement: e.createElement(t.HydrateFallback),
2962
- HydrateFallback: void 0
2963
- })), t.ErrorBoundary && (t.errorElement && p(!1, "You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used."), Object.assign(n, {
2964
- errorElement: e.createElement(t.ErrorBoundary),
2965
- ErrorBoundary: void 0
2966
- })), n;
2967
- }
2968
- var pr = ["HydrateFallback", "hydrateFallbackElement"], mr = class {
2969
- constructor() {
2970
- this.status = "pending", this.promise = new Promise((e, t) => {
2971
- this.resolve = (t) => {
2972
- this.status === "pending" && (this.status = "resolved", e(t));
2973
- }, this.reject = (e) => {
2974
- this.status === "pending" && (this.status = "rejected", t(e));
2975
- };
2976
- });
2977
- }
2978
- };
2979
- function hr({ router: t, flushSync: n, onError: r, useTransitions: i }) {
2980
- i = bn() || i;
2981
- let [a, o] = e.useState(t.state), [s, c] = dr(a), [l, u] = e.useState(), [d, f] = e.useState({ isTransitioning: !1 }), [p, m] = e.useState(), [h, g] = e.useState(), [_, v] = e.useState(), y = e.useRef(/* @__PURE__ */ new Map()), b = e.useCallback((a, { deletedFetchers: s, newErrors: l, flushSync: d, viewTransitionOpts: _ }) => {
2982
- l && r && Object.values(l).forEach((e) => r(e, {
2983
- location: a.location,
2984
- params: a.matches[0]?.params ?? {},
2985
- pattern: we(a.matches)
2986
- })), a.fetchers.forEach((e, t) => {
2987
- e.data !== void 0 && y.current.set(t, e.data);
2988
- }), s.forEach((e) => y.current.delete(e)), cr(d === !1 || n != null, "You provided the `flushSync` option to a router update, but you are not using the `<RouterProvider>` from `react-router/dom` so `ReactDOM.flushSync()` is unavailable. Please update your app to `import { RouterProvider } from \"react-router/dom\"` and ensure you have `react-dom` installed as a dependency to use the `flushSync` option.");
2989
- let b = t.window != null && t.window.document != null && typeof t.window.document.startViewTransition == "function";
2990
- if (cr(_ == null || b, "You provided the `viewTransition` option to a router update, but you do not appear to be running in a DOM environment as `window.startViewTransition` is not available."), !_ || !b) {
2991
- n && d ? n(() => o(a)) : i === !1 ? o(a) : e.startTransition(() => {
2992
- i === !0 && c((e) => gr(e, a)), o(a);
2993
- });
2994
- return;
2995
- }
2996
- if (n && d) {
2997
- n(() => {
2998
- h && (p?.resolve(), h.skipTransition()), f({
2999
- isTransitioning: !0,
3000
- flushSync: !0,
3001
- currentLocation: _.currentLocation,
3002
- nextLocation: _.nextLocation
3003
- });
3004
- });
3005
- let e = t.window.document.startViewTransition(() => {
3006
- n(() => o(a));
3007
- });
3008
- e.finished.finally(() => {
3009
- n(() => {
3010
- m(void 0), g(void 0), u(void 0), f({ isTransitioning: !1 });
3011
- });
3012
- }), n(() => g(e));
3013
- return;
3014
- }
3015
- h ? (p?.resolve(), h.skipTransition(), v({
3016
- state: a,
3017
- currentLocation: _.currentLocation,
3018
- nextLocation: _.nextLocation
3019
- })) : (u(a), f({
3020
- isTransitioning: !0,
3021
- flushSync: !1,
3022
- currentLocation: _.currentLocation,
3023
- nextLocation: _.nextLocation
3024
- }));
3025
- }, [
3026
- t.window,
3027
- n,
3028
- h,
3029
- p,
3030
- i,
3031
- c,
3032
- r
3033
- ]);
3034
- e.useLayoutEffect(() => t.subscribe(b), [t, b]), e.useEffect(() => {
3035
- d.isTransitioning && !d.flushSync && m(new mr());
3036
- }, [d]), e.useEffect(() => {
3037
- if (p && l && t.window) {
3038
- let n = l, r = p.promise, a = t.window.document.startViewTransition(async () => {
3039
- i === !1 ? o(n) : e.startTransition(() => {
3040
- i === !0 && c((e) => gr(e, n)), o(n);
3041
- }), await r;
3042
- });
3043
- a.finished.finally(() => {
3044
- m(void 0), g(void 0), u(void 0), f({ isTransitioning: !1 });
3045
- }), g(a);
3046
- }
3047
- }, [
3048
- l,
3049
- p,
3050
- t.window,
3051
- i,
3052
- c
3053
- ]), e.useEffect(() => {
3054
- p && l && s.location.key === l.location.key && p.resolve();
3055
- }, [
3056
- p,
3057
- h,
3058
- s.location,
3059
- l
3060
- ]), e.useEffect(() => {
3061
- !d.isTransitioning && _ && (u(_.state), f({
3062
- isTransitioning: !0,
3063
- flushSync: !1,
3064
- currentLocation: _.currentLocation,
3065
- nextLocation: _.nextLocation
3066
- }), v(void 0));
3067
- }, [d.isTransitioning, _]);
3068
- let x = e.useMemo(() => ({
3069
- createHref: t.createHref,
3070
- createURL: t.createURL,
3071
- encodeLocation: t.encodeLocation,
3072
- go: (e) => t.navigate(e),
3073
- push: (e, n, r) => t.navigate(e, {
3074
- state: n,
3075
- preventScrollReset: r?.preventScrollReset
3076
- }),
3077
- replace: (e, n, r) => t.navigate(e, {
3078
- replace: !0,
3079
- state: n,
3080
- preventScrollReset: r?.preventScrollReset
3081
- })
3082
- }), [t]), S = t.basename || "/", C = e.useMemo(() => ({
3083
- router: t,
3084
- navigator: x,
3085
- static: !1,
3086
- basename: S,
3087
- onError: r
3088
- }), [
3089
- t,
3090
- x,
3091
- S,
3092
- r
3093
- ]);
3094
- return /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(_n.Provider, { value: C }, /* @__PURE__ */ e.createElement(vn.Provider, { value: s }, /* @__PURE__ */ e.createElement(Sn.Provider, { value: y.current }, /* @__PURE__ */ e.createElement(xn.Provider, { value: d }, /* @__PURE__ */ e.createElement(br, {
3095
- basename: S,
3096
- location: s.location,
3097
- navigationType: s.historyAction,
3098
- navigator: x,
3099
- useTransitions: i
3100
- }, /* @__PURE__ */ e.createElement(_r, {
3101
- routes: t.routes,
3102
- manifest: t.manifest,
3103
- future: t.future,
3104
- state: s,
3105
- isStatic: !1,
3106
- onError: r
3107
- })))))), null);
3108
- }
3109
- function gr(e, t) {
3110
- return {
3111
- ...e,
3112
- navigation: t.navigation.state === "idle" ? e.navigation : t.navigation,
3113
- revalidation: t.revalidation === "idle" ? e.revalidation : t.revalidation,
3114
- actionData: t.navigation.state === "submitting" ? e.actionData : t.actionData,
3115
- fetchers: t.fetchers
3116
- };
3117
- }
3118
- var _r = e.memo(vr);
3119
- function vr({ routes: e, manifest: t, future: n, state: r, isStatic: i, onError: a }) {
3120
- return Hn(e, void 0, {
3121
- manifest: t,
3122
- state: r,
3123
- isStatic: i,
3124
- onError: a,
3125
- future: n
3126
- });
3127
- }
3128
- function yr(e) {
3129
- return zn(e.context);
3130
- }
3131
- function br({ basename: t = "/", children: n = null, location: r, navigationType: i = "POP", navigator: a, static: o = !1, useTransitions: s }) {
3132
- f(!Mn(), "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");
3133
- let c = t.replace(/^\/*/, "/"), l = e.useMemo(() => ({
3134
- basename: c,
3135
- navigator: a,
3136
- static: o,
3137
- useTransitions: s,
3138
- future: {}
3139
- }), [
3140
- c,
3141
- a,
3142
- o,
3143
- s
3144
- ]);
3145
- typeof r == "string" && (r = v(r));
3146
- let { pathname: u = "/", search: d = "", hash: m = "", state: h = null, key: g = "default", mask: _ } = r, y = e.useMemo(() => {
3147
- let e = H(u, c);
3148
- return e == null ? null : {
3149
- location: {
3150
- pathname: e,
3151
- search: d,
3152
- hash: m,
3153
- state: h,
3154
- key: g,
3155
- mask: _
3156
- },
3157
- navigationType: i
3158
- };
3159
- }, [
3160
- c,
3161
- u,
3162
- d,
3163
- m,
3164
- h,
3165
- g,
3166
- i,
3167
- _
3168
- ]);
3169
- return p(y != null, `<Router basename="${c}"> is not able to match the URL "${u}${d}${m}" because it does not start with the basename, so the <Router> won't render anything.`), y == null ? null : /* @__PURE__ */ e.createElement(Z.Provider, { value: l }, /* @__PURE__ */ e.createElement(wn.Provider, {
3170
- children: n,
3171
- value: y
3172
- }));
3173
- }
3174
- e.Component;
3175
- var xr = "get", Sr = "application/x-www-form-urlencoded";
3176
- function Cr(e) {
3177
- return typeof HTMLElement < "u" && e instanceof HTMLElement;
3178
- }
3179
- function wr(e) {
3180
- return Cr(e) && e.tagName.toLowerCase() === "button";
3181
- }
3182
- function Tr(e) {
3183
- return Cr(e) && e.tagName.toLowerCase() === "form";
3184
- }
3185
- function Er(e) {
3186
- return Cr(e) && e.tagName.toLowerCase() === "input";
3187
- }
3188
- function Dr(e) {
3189
- return !!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey);
3190
- }
3191
- function Or(e, t) {
3192
- return e.button === 0 && (!t || t === "_self") && !Dr(e);
3193
- }
3194
- var kr = null;
3195
- function Ar() {
3196
- if (kr === null) try {
3197
- new FormData(document.createElement("form"), 0), kr = !1;
3198
- } catch {
3199
- kr = !0;
3200
- }
3201
- return kr;
3202
- }
3203
- var jr = /* @__PURE__ */ new Set([
3204
- "application/x-www-form-urlencoded",
3205
- "multipart/form-data",
3206
- "text/plain"
3207
- ]);
3208
- function Mr(e) {
3209
- return e != null && !jr.has(e) ? (p(!1, `"${e}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${Sr}"`), null) : e;
3210
- }
3211
- function Nr(e, t) {
3212
- let n, r, i, a, o;
3213
- if (Tr(e)) {
3214
- let o = e.getAttribute("action");
3215
- r = o ? H(o, t) : null, n = e.getAttribute("method") || xr, i = Mr(e.getAttribute("enctype")) || Sr, a = new FormData(e);
3216
- } else if (wr(e) || Er(e) && (e.type === "submit" || e.type === "image")) {
3217
- let o = e.form;
3218
- if (o == null) throw Error("Cannot submit a <button> or <input type=\"submit\"> without a <form>");
3219
- let s = e.getAttribute("formaction") || o.getAttribute("action");
3220
- if (r = s ? H(s, t) : null, n = e.getAttribute("formmethod") || o.getAttribute("method") || xr, i = Mr(e.getAttribute("formenctype")) || Mr(o.getAttribute("enctype")) || Sr, a = new FormData(o, e), !Ar()) {
3221
- let { name: t, type: n, value: r } = e;
3222
- if (n === "image") {
3223
- let e = t ? `${t}.` : "";
3224
- a.append(`${e}x`, "0"), a.append(`${e}y`, "0");
3225
- } else t && a.append(t, r);
3226
- }
3227
- } else if (Cr(e)) throw Error("Cannot submit element that is not <form>, <button>, or <input type=\"submit|image\">");
3228
- else n = xr, r = null, i = Sr, o = e;
3229
- return a && i === "text/plain" && (o = a, a = void 0), {
3230
- action: r,
3231
- method: n.toLowerCase(),
3232
- encType: i,
3233
- formData: a,
3234
- body: o
3235
- };
3236
- }
3237
- Object.getOwnPropertyNames(Object.prototype).sort().join("\0");
3238
- function Pr(e, t) {
3239
- if (e === !1 || e == null) throw Error(t);
3240
- }
3241
- function Fr(e, t, n, r) {
3242
- let i = typeof e == "string" ? new URL(e, typeof window > "u" ? "server://singlefetch/" : window.location.origin) : e;
3243
- return i.pathname = n ? i.pathname.endsWith("/") ? `${i.pathname}_.${r}` : `${i.pathname}.${r}` : i.pathname === "/" ? `_root.${r}` : t && H(i.pathname, t) === "/" ? `${G(t)}/_root.${r}` : `${G(i.pathname)}.${r}`, i;
3244
- }
3245
- async function Ir(e, t) {
3246
- if (e.id in t) return t[e.id];
3247
- try {
3248
- let n = await import(
3249
- /* @vite-ignore */
3250
- /* webpackIgnore: true */
3251
- e.module
3252
- );
3253
- return t[e.id] = n, n;
3254
- } catch (t) {
3255
- return console.error(`Error loading route module \`${e.module}\`, reloading page...`), console.error(t), window.__reactRouterContext && window.__reactRouterContext.isSpaMode, window.location.reload(), new Promise(() => {});
3256
- }
3257
- }
3258
- function Lr(e) {
3259
- return e != null && typeof e.page == "string";
3260
- }
3261
- function Rr(e) {
3262
- 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";
3263
- }
3264
- async function zr(e, t, n) {
3265
- return Wr((await Promise.all(e.map(async (e) => {
3266
- let r = t.routes[e.route.id];
3267
- if (r) {
3268
- let e = await Ir(r, n);
3269
- return e.links ? e.links() : [];
3270
- }
3271
- return [];
3272
- }))).flat(1).filter(Rr).filter((e) => e.rel === "stylesheet" || e.rel === "preload").map((e) => e.rel === "stylesheet" ? {
3273
- ...e,
3274
- rel: "prefetch",
3275
- as: "style"
3276
- } : {
3277
- ...e,
3278
- rel: "prefetch"
3279
- }));
3280
- }
3281
- function Br(e, t, n, r, i, a) {
3282
- let o = (e, t) => !n[t] || e.route.id !== n[t].route.id, s = (e, t) => n[t].pathname !== e.pathname || n[t].route.path?.endsWith("*") && n[t].params["*"] !== e.params["*"];
3283
- return a === "assets" ? t.filter((e, t) => o(e, t) || s(e, t)) : a === "data" ? t.filter((t, a) => {
3284
- let c = r.routes[t.route.id];
3285
- if (!c || !c.hasLoader) return !1;
3286
- if (o(t, a) || s(t, a)) return !0;
3287
- if (t.route.shouldRevalidate) {
3288
- let r = t.route.shouldRevalidate({
3289
- currentUrl: new URL(i.pathname + i.search + i.hash, window.origin),
3290
- currentParams: n[0]?.params || {},
3291
- nextUrl: new URL(e, window.origin),
3292
- nextParams: t.params,
3293
- defaultShouldRevalidate: !0
3294
- });
3295
- if (typeof r == "boolean") return r;
3296
- }
3297
- return !0;
3298
- }) : [];
3299
- }
3300
- function Vr(e, t, { includeHydrateFallback: n } = {}) {
3301
- return Hr(e.map((e) => {
3302
- let r = t.routes[e.route.id];
3303
- if (!r) return [];
3304
- let i = [r.module];
3305
- return r.clientActionModule && (i = i.concat(r.clientActionModule)), r.clientLoaderModule && (i = i.concat(r.clientLoaderModule)), n && r.hydrateFallbackModule && (i = i.concat(r.hydrateFallbackModule)), r.imports && (i = i.concat(r.imports)), i;
3306
- }).flat(1));
3307
- }
3308
- function Hr(e) {
3309
- return [...new Set(e)];
3310
- }
3311
- function Ur(e) {
3312
- let t = {}, n = Object.keys(e).sort();
3313
- for (let r of n) t[r] = e[r];
3314
- return t;
3315
- }
3316
- function Wr(e, t) {
3317
- let n = /* @__PURE__ */ new Set(), r = new Set(t);
3318
- return e.reduce((e, i) => {
3319
- if (t && !Lr(i) && i.as === "script" && i.href && r.has(i.href)) return e;
3320
- let a = JSON.stringify(Ur(i));
3321
- return n.has(a) || (n.add(a), e.push({
3322
- key: a,
3323
- link: i
3324
- })), e;
3325
- }, []);
3326
- }
3327
- function Gr() {
3328
- let t = e.useContext(_n);
3329
- return Pr(t, "You must render this element inside a <DataRouterContext.Provider> element"), t;
3330
- }
3331
- function Kr() {
3332
- let t = e.useContext(vn);
3333
- return Pr(t, "You must render this element inside a <DataRouterStateContext.Provider> element"), t;
3334
- }
3335
- var qr = e.createContext(void 0);
3336
- qr.displayName = "FrameworkContext";
3337
- function Jr() {
3338
- let t = e.useContext(qr);
3339
- return Pr(t, "You must render this element inside a <HydratedRouter> element"), t;
3340
- }
3341
- function Yr(t, n) {
3342
- let r = e.useContext(qr), [i, a] = e.useState(!1), [o, s] = e.useState(!1), { onFocus: c, onBlur: l, onMouseEnter: u, onMouseLeave: d, onTouchStart: f } = n, p = e.useRef(null);
3343
- e.useEffect(() => {
3344
- if (t === "render" && s(!0), t === "viewport") {
3345
- let e = new IntersectionObserver((e) => {
3346
- e.forEach((e) => {
3347
- s(e.isIntersecting);
3348
- });
3349
- }, { threshold: .5 });
3350
- return p.current && e.observe(p.current), () => {
3351
- e.disconnect();
3352
- };
3353
- }
3354
- }, [t]), e.useEffect(() => {
3355
- if (i) {
3356
- let e = setTimeout(() => {
3357
- s(!0);
3358
- }, 100);
3359
- return () => {
3360
- clearTimeout(e);
3361
- };
3362
- }
3363
- }, [i]);
3364
- let m = () => {
3365
- a(!0);
3366
- }, h = () => {
3367
- a(!1), s(!1);
3368
- };
3369
- return r ? t === "intent" ? [
3370
- o,
3371
- p,
3372
- {
3373
- onFocus: Xr(c, m),
3374
- onBlur: Xr(l, h),
3375
- onMouseEnter: Xr(u, m),
3376
- onMouseLeave: Xr(d, h),
3377
- onTouchStart: Xr(f, m)
3378
- }
3379
- ] : [
3380
- o,
3381
- p,
3382
- {}
3383
- ] : [
3384
- !1,
3385
- p,
3386
- {}
3387
- ];
3388
- }
3389
- function Xr(e, t) {
3390
- return (n) => {
3391
- e && e(n), n.defaultPrevented || t(n);
3392
- };
3393
- }
3394
- function Zr({ page: t, ...n }) {
3395
- let r = bn(), { nonce: i } = Jr(), { router: a } = Gr(), o = e.useMemo(() => j(a.routes, t, a.basename), [
3396
- a.routes,
3397
- t,
3398
- a.basename
3399
- ]);
3400
- return o ? (n.nonce == null && i && (n = {
3401
- ...n,
3402
- nonce: i
3403
- }), r ? /* @__PURE__ */ e.createElement($r, {
3404
- page: t,
3405
- matches: o,
3406
- ...n
3407
- }) : /* @__PURE__ */ e.createElement(ei, {
3408
- page: t,
3409
- matches: o,
3410
- ...n
3411
- })) : null;
3412
- }
3413
- function Qr(t) {
3414
- let { manifest: n, routeModules: r } = Jr(), [i, a] = e.useState([]);
3415
- return e.useEffect(() => {
3416
- let e = !1;
3417
- return zr(t, n, r).then((t) => {
3418
- e || a(t);
3419
- }), () => {
3420
- e = !0;
3421
- };
3422
- }, [
3423
- t,
3424
- n,
3425
- r
3426
- ]), i;
3427
- }
3428
- function $r({ page: t, matches: n, ...r }) {
3429
- let i = $(), { future: a } = Jr(), { basename: o } = Gr(), s = e.useMemo(() => {
3430
- if (t === i.pathname + i.search + i.hash) return [];
3431
- let e = Fr(t, o, a.v8_trailingSlashAwareDataRequests, "rsc"), r = !1, s = [];
3432
- for (let e of n) typeof e.route.shouldRevalidate == "function" ? r = !0 : s.push(e.route.id);
3433
- return r && s.length > 0 && e.searchParams.set("_routes", s.join(",")), [e.pathname + e.search];
3434
- }, [
3435
- o,
3436
- a.v8_trailingSlashAwareDataRequests,
3437
- t,
3438
- i,
3439
- n
3440
- ]);
3441
- return /* @__PURE__ */ e.createElement(e.Fragment, null, s.map((t) => /* @__PURE__ */ e.createElement("link", {
3442
- key: t,
3443
- rel: "prefetch",
3444
- as: "fetch",
3445
- href: t,
3446
- ...r
3447
- })));
3448
- }
3449
- function ei({ page: t, matches: n, ...r }) {
3450
- let i = $(), { future: a, manifest: o, routeModules: s } = Jr(), { basename: c } = Gr(), { loaderData: l, matches: u } = Kr(), d = e.useMemo(() => Br(t, n, u, o, i, "data"), [
3451
- t,
3452
- n,
3453
- u,
3454
- o,
3455
- i
3456
- ]), f = e.useMemo(() => Br(t, n, u, o, i, "assets"), [
3457
- t,
3458
- n,
3459
- u,
3460
- o,
3461
- i
3462
- ]), p = e.useMemo(() => {
3463
- if (t === i.pathname + i.search + i.hash) return [];
3464
- let e = /* @__PURE__ */ new Set(), r = !1;
3465
- if (n.forEach((t) => {
3466
- let n = o.routes[t.route.id];
3467
- !n || !n.hasLoader || (!d.some((e) => e.route.id === t.route.id) && t.route.id in l && s[t.route.id]?.shouldRevalidate || n.hasClientLoader ? r = !0 : e.add(t.route.id));
3468
- }), e.size === 0) return [];
3469
- let u = Fr(t, c, a.v8_trailingSlashAwareDataRequests, "data");
3470
- return r && e.size > 0 && u.searchParams.set("_routes", n.filter((t) => e.has(t.route.id)).map((e) => e.route.id).join(",")), [u.pathname + u.search];
3471
- }, [
3472
- c,
3473
- a.v8_trailingSlashAwareDataRequests,
3474
- l,
3475
- i,
3476
- o,
3477
- d,
3478
- n,
3479
- t,
3480
- s
3481
- ]), m = e.useMemo(() => Vr(f, o), [f, o]), h = Qr(f);
3482
- return /* @__PURE__ */ e.createElement(e.Fragment, null, p.map((t) => /* @__PURE__ */ e.createElement("link", {
3483
- key: t,
3484
- rel: "prefetch",
3485
- as: "fetch",
3486
- href: t,
3487
- ...r
3488
- })), m.map((t) => /* @__PURE__ */ e.createElement("link", {
3489
- key: t,
3490
- rel: "modulepreload",
3491
- href: t,
3492
- ...r
3493
- })), h.map(({ key: t, link: n }) => /* @__PURE__ */ e.createElement("link", {
3494
- key: t,
3495
- nonce: r.nonce,
3496
- ...n,
3497
- crossOrigin: n.crossOrigin ?? r.crossOrigin
3498
- })));
3499
- }
3500
- function ti(...e) {
3501
- return (t) => {
3502
- e.forEach((e) => {
3503
- typeof e == "function" ? e(t) : e != null && (e.current = t);
3504
- });
3505
- };
3506
- }
3507
- e.Component;
3508
- var ni = typeof window < "u" && window.document !== void 0 && window.document.createElement !== void 0;
3509
- try {
3510
- ni && (window.__reactRouterVersion = "7.18.4");
3511
- } catch {}
3512
- function ri(e, t) {
3513
- return at({
3514
- basename: t?.basename,
3515
- getContext: t?.getContext,
3516
- future: t?.future,
3517
- history: d({ window: t?.window }),
3518
- hydrationData: t?.hydrationData || ii(),
3519
- routes: e,
3520
- mapRouteProperties: fr,
3521
- hydrationRouteProperties: pr,
3522
- dataStrategy: t?.dataStrategy,
3523
- patchRoutesOnNavigation: t?.patchRoutesOnNavigation,
3524
- window: t?.window,
3525
- instrumentations: t?.instrumentations
3526
- }).initialize();
3527
- }
3528
- function ii() {
3529
- let e = window?.__staticRouterHydrationData;
3530
- return e && e.errors && (e = {
3531
- ...e,
3532
- errors: ai(e.errors)
3533
- }), e;
3534
- }
3535
- function ai(e) {
3536
- if (!e) return null;
3537
- let t = Object.entries(e), n = {};
3538
- for (let [e, r] of t) if (r && r.__type === "RouteErrorResponse") n[e] = new Se(r.status, r.statusText, r.data, r.internal === !0);
3539
- else if (r && r.__type === "Error") {
3540
- if (typeof r.__subType == "string" && xe.includes(r.__subType)) {
3541
- let t = window[r.__subType];
3542
- if (typeof t == "function") try {
3543
- let i = new t(r.message);
3544
- i.stack = "", n[e] = i;
3545
- } catch {}
3546
- }
3547
- if (n[e] == null) {
3548
- let t = Error(r.message);
3549
- t.stack = "", n[e] = t;
3550
- }
3551
- } else n[e] = r;
3552
- return n;
3553
- }
3554
- var oi = e.forwardRef(function({ onClick: t, discover: n = "render", prefetch: r = "none", relative: i, reloadDocument: a, replace: s, mask: c, state: l, target: u, to: d, preventScrollReset: f, viewTransition: p, defaultShouldRevalidate: m, ...h }, g) {
3555
- let { basename: _, navigator: v, useTransitions: y } = e.useContext(Z), b = typeof d == "string" && o.test(d), x = Ee(d, _);
3556
- d = x.to;
3557
- let S = jn(d, { relative: i }), C = $(), w = null;
3558
- if (c) {
3559
- let e = ge(c, [], C.mask ? C.mask.pathname : "/", !0);
3560
- _ !== "/" && (e.pathname = e.pathname === "/" ? _ : W([_, e.pathname])), w = v.createHref(e);
3561
- }
3562
- let [T, E, D] = Yr(r, h), O = di(d, {
3563
- replace: s,
3564
- mask: c,
3565
- state: l,
3566
- target: u,
3567
- preventScrollReset: f,
3568
- relative: i,
3569
- viewTransition: p,
3570
- defaultShouldRevalidate: m,
3571
- useTransitions: y
3572
- });
3573
- function k(e) {
3574
- t && t(e), e.defaultPrevented || O(e);
3575
- }
3576
- let A = !(x.isExternal || a), j = /* @__PURE__ */ e.createElement("a", {
3577
- ...h,
3578
- ...D,
3579
- href: (A ? w : void 0) || x.absoluteURL || S,
3580
- onClick: A ? k : t,
3581
- ref: ti(g, E),
3582
- target: u,
3583
- "data-discover": !b && n === "render" ? "true" : void 0
3584
- });
3585
- return T && !b ? /* @__PURE__ */ e.createElement(e.Fragment, null, j, /* @__PURE__ */ e.createElement(Zr, { page: S })) : j;
3586
- });
3587
- oi.displayName = "Link";
3588
- var si = e.forwardRef(function({ "aria-current": t = "page", caseSensitive: n = !1, className: r = "", end: i = !1, style: a, to: o, viewTransition: s, children: c, ...l }, u) {
3589
- let d = Vn(o, { relative: l.relative }), f = $(), p = e.useContext(vn), { navigator: m, basename: h } = e.useContext(Z), g = p != null && gi(d) && s === !0, _ = m.encodeLocation ? m.encodeLocation(d).pathname : d.pathname, v = f.pathname, y = p && p.navigation && p.navigation.location ? p.navigation.location.pathname : null;
3590
- n || (v = v.toLowerCase(), y = y ? y.toLowerCase() : null, _ = _.toLowerCase()), y && h && (y = H(y, h) || y);
3591
- let b = _ !== "/" && _.endsWith("/") ? _.length - 1 : _.length, x = v === _ || !i && v.startsWith(_) && v.charAt(b) === "/", S = y != null && (y === _ || !i && y.startsWith(_) && y.charAt(_.length) === "/"), C = {
3592
- isActive: x,
3593
- isPending: S,
3594
- isTransitioning: g
3595
- }, w = x ? t : void 0, T;
3596
- T = typeof r == "function" ? r(C) : [
3597
- r,
3598
- x ? "active" : null,
3599
- S ? "pending" : null,
3600
- g ? "transitioning" : null
3601
- ].filter(Boolean).join(" ");
3602
- let E = typeof a == "function" ? a(C) : a;
3603
- return /* @__PURE__ */ e.createElement(oi, {
3604
- ...l,
3605
- "aria-current": w,
3606
- className: T,
3607
- ref: u,
3608
- style: E,
3609
- to: o,
3610
- viewTransition: s
3611
- }, typeof c == "function" ? c(C) : c);
3612
- });
3613
- si.displayName = "NavLink";
3614
- var ci = e.forwardRef(({ discover: t = "render", fetcherKey: n, navigate: r, reloadDocument: i, replace: a, state: s, method: c = xr, action: l, onSubmit: u, relative: d, preventScrollReset: f, viewTransition: p, defaultShouldRevalidate: m, ...h }, g) => {
3615
- let { useTransitions: _ } = e.useContext(Z), v = mi(), y = hi(l, { relative: d }), b = c.toLowerCase() === "get" ? "get" : "post", x = typeof l == "string" && o.test(l);
3616
- return /* @__PURE__ */ e.createElement("form", {
3617
- ref: g,
3618
- method: b,
3619
- action: y,
3620
- onSubmit: i ? u : (t) => {
3621
- if (u && u(t), t.defaultPrevented) return;
3622
- t.preventDefault();
3623
- let i = t.nativeEvent.submitter, o = i?.getAttribute("formmethod") || c, l = () => v(i || t.currentTarget, {
3624
- fetcherKey: n,
3625
- method: o,
3626
- navigate: r,
3627
- replace: a,
3628
- state: s,
3629
- relative: d,
3630
- preventScrollReset: f,
3631
- viewTransition: p,
3632
- defaultShouldRevalidate: m
3633
- });
3634
- _ && r !== !1 ? e.startTransition(() => l()) : l();
3635
- },
3636
- ...h,
3637
- "data-discover": !x && t === "render" ? "true" : void 0
3638
- });
3639
- });
3640
- ci.displayName = "Form";
3641
- function li(e) {
3642
- return `${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`;
3643
- }
3644
- function ui(t) {
3645
- let n = e.useContext(_n);
3646
- return f(n, li(t)), n;
3647
- }
3648
- function di(t, { target: n, replace: r, mask: i, state: a, preventScrollReset: o, relative: s, viewTransition: c, defaultShouldRevalidate: l, useTransitions: u } = {}) {
3649
- let d = In(), f = $(), p = Vn(t, { relative: s });
3650
- return e.useCallback((m) => {
3651
- if (Or(m, n)) {
3652
- m.preventDefault();
3653
- let n = r === void 0 ? _(f) === _(p) : r, h = () => d(t, {
3654
- replace: n,
3655
- mask: i,
3656
- state: a,
3657
- preventScrollReset: o,
3658
- relative: s,
3659
- viewTransition: c,
3660
- defaultShouldRevalidate: l
3661
- });
3662
- u ? e.startTransition(() => h()) : h();
3663
- }
3664
- }, [
3665
- f,
3666
- d,
3667
- p,
3668
- r,
3669
- i,
3670
- a,
3671
- n,
3672
- t,
3673
- o,
3674
- s,
3675
- c,
3676
- l,
3677
- u
3678
- ]);
3679
- }
3680
- var fi = 0, pi = () => `__${String(++fi)}__`;
3681
- function mi() {
3682
- let { router: t } = ui("useSubmit"), { basename: n } = e.useContext(Z), r = tr(), i = t.fetch, a = t.navigate;
3683
- return e.useCallback(async (e, t = {}) => {
3684
- let { action: o, method: s, encType: c, formData: l, body: u } = Nr(e, n);
3685
- if (t.navigate === !1) {
3686
- let e = t.fetcherKey || pi();
3687
- await i(e, r, t.action || o, {
3688
- defaultShouldRevalidate: t.defaultShouldRevalidate,
3689
- preventScrollReset: t.preventScrollReset,
3690
- formData: l,
3691
- body: u,
3692
- formMethod: t.method || s,
3693
- formEncType: t.encType || c,
3694
- flushSync: t.flushSync
3695
- });
3696
- } else await a(t.action || o, {
3697
- defaultShouldRevalidate: t.defaultShouldRevalidate,
3698
- preventScrollReset: t.preventScrollReset,
3699
- formData: l,
3700
- body: u,
3701
- formMethod: t.method || s,
3702
- formEncType: t.encType || c,
3703
- replace: t.replace,
3704
- state: t.state,
3705
- fromRouteId: r,
3706
- flushSync: t.flushSync,
3707
- viewTransition: t.viewTransition
3708
- });
3709
- }, [
3710
- i,
3711
- a,
3712
- n,
3713
- r
3714
- ]);
3715
- }
3716
- function hi(t, { relative: n } = {}) {
3717
- let { basename: r } = e.useContext(Z), i = e.useContext(Q);
3718
- f(i, "useFormAction must be used inside a RouteContext");
3719
- let [a] = i.matches.slice(-1), o = { ...Vn(t || ".", { relative: n }) }, s = $();
3720
- if (t == null) {
3721
- o.search = s.search;
3722
- let e = new URLSearchParams(o.search), t = e.getAll("index");
3723
- if (t.some((e) => e === "")) {
3724
- e.delete("index"), t.filter((e) => e).forEach((t) => e.append("index", t));
3725
- let n = e.toString();
3726
- o.search = n ? `?${n}` : "";
3727
- }
3728
- }
3729
- return (!t || t === ".") && a.route.index && (o.search = o.search ? o.search.replace(/^\?/, "?index&") : "?index"), r !== "/" && (o.pathname = o.pathname === "/" ? r : W([r, o.pathname])), _(o);
3730
- }
3731
- function gi(t, { relative: n } = {}) {
3732
- let r = e.useContext(xn);
3733
- f(r != null, "`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");
3734
- let { basename: i } = ui("useViewTransitionState"), a = Vn(t, { relative: n });
3735
- if (!r.isTransitioning) return !1;
3736
- let o = H(r.currentLocation.pathname, i) || r.currentLocation.pathname, s = H(r.nextLocation.pathname, i) || r.nextLocation.pathname;
3737
- return se(a.pathname, s) != null || se(a.pathname, o) != null;
3738
- }
3739
- //#endregion
3740
- export { x as a, $ as c, Bn as d, rr as f, ri as i, Nn as l, yr as n, Ce as o, hr as r, U as s, si as t, nr as u };
3741
-
3742
- //# sourceMappingURL=chunk-OB3PAWPO.js.map