@hortiview/modulebase 0.0.11535 → 0.0.12109

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