source: imaps-frontend/node_modules/.vite/deps/react-router-dom.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 199.9 KB
RevLine 
[d565449]1import {
2 require_react_dom
3} from "./chunk-6VWAHX6D.js";
4import {
5 require_react
6} from "./chunk-QJTFJ6OV.js";
7import {
8 __toESM
9} from "./chunk-V4OQ3NZ2.js";
10
11// node_modules/react-router-dom/dist/index.js
12var React2 = __toESM(require_react());
13var ReactDOM = __toESM(require_react_dom());
14
15// node_modules/react-router/dist/index.js
16var React = __toESM(require_react());
17
18// node_modules/@remix-run/router/dist/router.js
19function _extends() {
20 _extends = Object.assign ? Object.assign.bind() : function(target) {
21 for (var i = 1; i < arguments.length; i++) {
22 var source = arguments[i];
23 for (var key in source) {
24 if (Object.prototype.hasOwnProperty.call(source, key)) {
25 target[key] = source[key];
26 }
27 }
28 }
29 return target;
30 };
31 return _extends.apply(this, arguments);
32}
33var Action;
34(function(Action2) {
35 Action2["Pop"] = "POP";
36 Action2["Push"] = "PUSH";
37 Action2["Replace"] = "REPLACE";
38})(Action || (Action = {}));
39var PopStateEventType = "popstate";
40function createMemoryHistory(options) {
41 if (options === void 0) {
42 options = {};
43 }
44 let {
45 initialEntries = ["/"],
46 initialIndex,
47 v5Compat = false
48 } = options;
49 let entries;
50 entries = initialEntries.map((entry, index2) => createMemoryLocation(entry, typeof entry === "string" ? null : entry.state, index2 === 0 ? "default" : void 0));
51 let index = clampIndex(initialIndex == null ? entries.length - 1 : initialIndex);
52 let action = Action.Pop;
53 let listener = null;
54 function clampIndex(n) {
55 return Math.min(Math.max(n, 0), entries.length - 1);
56 }
57 function getCurrentLocation() {
58 return entries[index];
59 }
60 function createMemoryLocation(to, state, key) {
61 if (state === void 0) {
62 state = null;
63 }
64 let location = createLocation(entries ? getCurrentLocation().pathname : "/", to, state, key);
65 warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in memory history: " + JSON.stringify(to));
66 return location;
67 }
68 function createHref(to) {
69 return typeof to === "string" ? to : createPath(to);
70 }
71 let history = {
72 get index() {
73 return index;
74 },
75 get action() {
76 return action;
77 },
78 get location() {
79 return getCurrentLocation();
80 },
81 createHref,
82 createURL(to) {
83 return new URL(createHref(to), "http://localhost");
84 },
85 encodeLocation(to) {
86 let path = typeof to === "string" ? parsePath(to) : to;
87 return {
88 pathname: path.pathname || "",
89 search: path.search || "",
90 hash: path.hash || ""
91 };
92 },
93 push(to, state) {
94 action = Action.Push;
95 let nextLocation = createMemoryLocation(to, state);
96 index += 1;
97 entries.splice(index, entries.length, nextLocation);
98 if (v5Compat && listener) {
99 listener({
100 action,
101 location: nextLocation,
102 delta: 1
103 });
104 }
105 },
106 replace(to, state) {
107 action = Action.Replace;
108 let nextLocation = createMemoryLocation(to, state);
109 entries[index] = nextLocation;
110 if (v5Compat && listener) {
111 listener({
112 action,
113 location: nextLocation,
114 delta: 0
115 });
116 }
117 },
118 go(delta) {
119 action = Action.Pop;
120 let nextIndex = clampIndex(index + delta);
121 let nextLocation = entries[nextIndex];
122 index = nextIndex;
123 if (listener) {
124 listener({
125 action,
126 location: nextLocation,
127 delta
128 });
129 }
130 },
131 listen(fn) {
132 listener = fn;
133 return () => {
134 listener = null;
135 };
136 }
137 };
138 return history;
139}
140function createBrowserHistory(options) {
141 if (options === void 0) {
142 options = {};
143 }
144 function createBrowserLocation(window2, globalHistory) {
145 let {
146 pathname,
147 search,
148 hash
149 } = window2.location;
150 return createLocation(
151 "",
152 {
153 pathname,
154 search,
155 hash
156 },
157 // state defaults to `null` because `window.history.state` does
158 globalHistory.state && globalHistory.state.usr || null,
159 globalHistory.state && globalHistory.state.key || "default"
160 );
161 }
162 function createBrowserHref(window2, to) {
163 return typeof to === "string" ? to : createPath(to);
164 }
165 return getUrlBasedHistory(createBrowserLocation, createBrowserHref, null, options);
166}
167function createHashHistory(options) {
168 if (options === void 0) {
169 options = {};
170 }
171 function createHashLocation(window2, globalHistory) {
172 let {
173 pathname = "/",
174 search = "",
175 hash = ""
176 } = parsePath(window2.location.hash.substr(1));
177 if (!pathname.startsWith("/") && !pathname.startsWith(".")) {
178 pathname = "/" + pathname;
179 }
180 return createLocation(
181 "",
182 {
183 pathname,
184 search,
185 hash
186 },
187 // state defaults to `null` because `window.history.state` does
188 globalHistory.state && globalHistory.state.usr || null,
189 globalHistory.state && globalHistory.state.key || "default"
190 );
191 }
192 function createHashHref(window2, to) {
193 let base = window2.document.querySelector("base");
194 let href = "";
195 if (base && base.getAttribute("href")) {
196 let url = window2.location.href;
197 let hashIndex = url.indexOf("#");
198 href = hashIndex === -1 ? url : url.slice(0, hashIndex);
199 }
200 return href + "#" + (typeof to === "string" ? to : createPath(to));
201 }
202 function validateHashLocation(location, to) {
203 warning(location.pathname.charAt(0) === "/", "relative pathnames are not supported in hash history.push(" + JSON.stringify(to) + ")");
204 }
205 return getUrlBasedHistory(createHashLocation, createHashHref, validateHashLocation, options);
206}
207function invariant(value, message) {
208 if (value === false || value === null || typeof value === "undefined") {
209 throw new Error(message);
210 }
211}
212function warning(cond, message) {
213 if (!cond) {
214 if (typeof console !== "undefined") console.warn(message);
215 try {
216 throw new Error(message);
217 } catch (e) {
218 }
219 }
220}
221function createKey() {
222 return Math.random().toString(36).substr(2, 8);
223}
224function getHistoryState(location, index) {
225 return {
226 usr: location.state,
227 key: location.key,
228 idx: index
229 };
230}
231function createLocation(current, to, state, key) {
232 if (state === void 0) {
233 state = null;
234 }
235 let location = _extends({
236 pathname: typeof current === "string" ? current : current.pathname,
237 search: "",
238 hash: ""
239 }, typeof to === "string" ? parsePath(to) : to, {
240 state,
241 // TODO: This could be cleaned up. push/replace should probably just take
242 // full Locations now and avoid the need to run through this flow at all
243 // But that's a pretty big refactor to the current test suite so going to
244 // keep as is for the time being and just let any incoming keys take precedence
245 key: to && to.key || key || createKey()
246 });
247 return location;
248}
249function createPath(_ref) {
250 let {
251 pathname = "/",
252 search = "",
253 hash = ""
254 } = _ref;
255 if (search && search !== "?") pathname += search.charAt(0) === "?" ? search : "?" + search;
256 if (hash && hash !== "#") pathname += hash.charAt(0) === "#" ? hash : "#" + hash;
257 return pathname;
258}
259function parsePath(path) {
260 let parsedPath = {};
261 if (path) {
262 let hashIndex = path.indexOf("#");
263 if (hashIndex >= 0) {
264 parsedPath.hash = path.substr(hashIndex);
265 path = path.substr(0, hashIndex);
266 }
267 let searchIndex = path.indexOf("?");
268 if (searchIndex >= 0) {
269 parsedPath.search = path.substr(searchIndex);
270 path = path.substr(0, searchIndex);
271 }
272 if (path) {
273 parsedPath.pathname = path;
274 }
275 }
276 return parsedPath;
277}
278function getUrlBasedHistory(getLocation, createHref, validateLocation, options) {
279 if (options === void 0) {
280 options = {};
281 }
282 let {
283 window: window2 = document.defaultView,
284 v5Compat = false
285 } = options;
286 let globalHistory = window2.history;
287 let action = Action.Pop;
288 let listener = null;
289 let index = getIndex();
290 if (index == null) {
291 index = 0;
292 globalHistory.replaceState(_extends({}, globalHistory.state, {
293 idx: index
294 }), "");
295 }
296 function getIndex() {
297 let state = globalHistory.state || {
298 idx: null
299 };
300 return state.idx;
301 }
302 function handlePop() {
303 action = Action.Pop;
304 let nextIndex = getIndex();
305 let delta = nextIndex == null ? null : nextIndex - index;
306 index = nextIndex;
307 if (listener) {
308 listener({
309 action,
310 location: history.location,
311 delta
312 });
313 }
314 }
315 function push(to, state) {
316 action = Action.Push;
317 let location = createLocation(history.location, to, state);
318 if (validateLocation) validateLocation(location, to);
319 index = getIndex() + 1;
320 let historyState = getHistoryState(location, index);
321 let url = history.createHref(location);
322 try {
323 globalHistory.pushState(historyState, "", url);
324 } catch (error) {
325 if (error instanceof DOMException && error.name === "DataCloneError") {
326 throw error;
327 }
328 window2.location.assign(url);
329 }
330 if (v5Compat && listener) {
331 listener({
332 action,
333 location: history.location,
334 delta: 1
335 });
336 }
337 }
338 function replace2(to, state) {
339 action = Action.Replace;
340 let location = createLocation(history.location, to, state);
341 if (validateLocation) validateLocation(location, to);
342 index = getIndex();
343 let historyState = getHistoryState(location, index);
344 let url = history.createHref(location);
345 globalHistory.replaceState(historyState, "", url);
346 if (v5Compat && listener) {
347 listener({
348 action,
349 location: history.location,
350 delta: 0
351 });
352 }
353 }
354 function createURL(to) {
355 let base = window2.location.origin !== "null" ? window2.location.origin : window2.location.href;
356 let href = typeof to === "string" ? to : createPath(to);
357 href = href.replace(/ $/, "%20");
358 invariant(base, "No window.location.(origin|href) available to create URL for href: " + href);
359 return new URL(href, base);
360 }
361 let history = {
362 get action() {
363 return action;
364 },
365 get location() {
366 return getLocation(window2, globalHistory);
367 },
368 listen(fn) {
369 if (listener) {
370 throw new Error("A history only accepts one active listener");
371 }
372 window2.addEventListener(PopStateEventType, handlePop);
373 listener = fn;
374 return () => {
375 window2.removeEventListener(PopStateEventType, handlePop);
376 listener = null;
377 };
378 },
379 createHref(to) {
380 return createHref(window2, to);
381 },
382 createURL,
383 encodeLocation(to) {
384 let url = createURL(to);
385 return {
386 pathname: url.pathname,
387 search: url.search,
388 hash: url.hash
389 };
390 },
391 push,
392 replace: replace2,
393 go(n) {
394 return globalHistory.go(n);
395 }
396 };
397 return history;
398}
399var ResultType;
400(function(ResultType2) {
401 ResultType2["data"] = "data";
402 ResultType2["deferred"] = "deferred";
403 ResultType2["redirect"] = "redirect";
404 ResultType2["error"] = "error";
405})(ResultType || (ResultType = {}));
406var immutableRouteKeys = /* @__PURE__ */ new Set(["lazy", "caseSensitive", "path", "id", "index", "children"]);
407function isIndexRoute(route) {
408 return route.index === true;
409}
410function convertRoutesToDataRoutes(routes, mapRouteProperties2, parentPath, manifest) {
411 if (parentPath === void 0) {
412 parentPath = [];
413 }
414 if (manifest === void 0) {
415 manifest = {};
416 }
417 return routes.map((route, index) => {
418 let treePath = [...parentPath, String(index)];
419 let id = typeof route.id === "string" ? route.id : treePath.join("-");
420 invariant(route.index !== true || !route.children, "Cannot specify children on an index route");
421 invariant(!manifest[id], 'Found a route id collision on id "' + id + `". Route id's must be globally unique within Data Router usages`);
422 if (isIndexRoute(route)) {
423 let indexRoute = _extends({}, route, mapRouteProperties2(route), {
424 id
425 });
426 manifest[id] = indexRoute;
427 return indexRoute;
428 } else {
429 let pathOrLayoutRoute = _extends({}, route, mapRouteProperties2(route), {
430 id,
431 children: void 0
432 });
433 manifest[id] = pathOrLayoutRoute;
434 if (route.children) {
435 pathOrLayoutRoute.children = convertRoutesToDataRoutes(route.children, mapRouteProperties2, treePath, manifest);
436 }
437 return pathOrLayoutRoute;
438 }
439 });
440}
441function matchRoutes(routes, locationArg, basename) {
442 if (basename === void 0) {
443 basename = "/";
444 }
445 return matchRoutesImpl(routes, locationArg, basename, false);
446}
447function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
448 let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
449 let pathname = stripBasename(location.pathname || "/", basename);
450 if (pathname == null) {
451 return null;
452 }
453 let branches = flattenRoutes(routes);
454 rankRouteBranches(branches);
455 let matches = null;
456 for (let i = 0; matches == null && i < branches.length; ++i) {
457 let decoded = decodePath(pathname);
458 matches = matchRouteBranch(branches[i], decoded, allowPartial);
459 }
460 return matches;
461}
462function convertRouteMatchToUiMatch(match, loaderData) {
463 let {
464 route,
465 pathname,
466 params
467 } = match;
468 return {
469 id: route.id,
470 pathname,
471 params,
472 data: loaderData[route.id],
473 handle: route.handle
474 };
475}
476function flattenRoutes(routes, branches, parentsMeta, parentPath) {
477 if (branches === void 0) {
478 branches = [];
479 }
480 if (parentsMeta === void 0) {
481 parentsMeta = [];
482 }
483 if (parentPath === void 0) {
484 parentPath = "";
485 }
486 let flattenRoute = (route, index, relativePath) => {
487 let meta = {
488 relativePath: relativePath === void 0 ? route.path || "" : relativePath,
489 caseSensitive: route.caseSensitive === true,
490 childrenIndex: index,
491 route
492 };
493 if (meta.relativePath.startsWith("/")) {
494 invariant(meta.relativePath.startsWith(parentPath), 'Absolute route path "' + meta.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes.");
495 meta.relativePath = meta.relativePath.slice(parentPath.length);
496 }
497 let path = joinPaths([parentPath, meta.relativePath]);
498 let routesMeta = parentsMeta.concat(meta);
499 if (route.children && route.children.length > 0) {
500 invariant(
501 // Our types know better, but runtime JS may not!
502 // @ts-expect-error
503 route.index !== true,
504 "Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".')
505 );
506 flattenRoutes(route.children, branches, routesMeta, path);
507 }
508 if (route.path == null && !route.index) {
509 return;
510 }
511 branches.push({
512 path,
513 score: computeScore(path, route.index),
514 routesMeta
515 });
516 };
517 routes.forEach((route, index) => {
518 var _route$path;
519 if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
520 flattenRoute(route, index);
521 } else {
522 for (let exploded of explodeOptionalSegments(route.path)) {
523 flattenRoute(route, index, exploded);
524 }
525 }
526 });
527 return branches;
528}
529function explodeOptionalSegments(path) {
530 let segments = path.split("/");
531 if (segments.length === 0) return [];
532 let [first, ...rest] = segments;
533 let isOptional = first.endsWith("?");
534 let required = first.replace(/\?$/, "");
535 if (rest.length === 0) {
536 return isOptional ? [required, ""] : [required];
537 }
538 let restExploded = explodeOptionalSegments(rest.join("/"));
539 let result = [];
540 result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
541 if (isOptional) {
542 result.push(...restExploded);
543 }
544 return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
545}
546function rankRouteBranches(branches) {
547 branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
548}
549var paramRe = /^:[\w-]+$/;
550var dynamicSegmentValue = 3;
551var indexRouteValue = 2;
552var emptySegmentValue = 1;
553var staticSegmentValue = 10;
554var splatPenalty = -2;
555var isSplat = (s) => s === "*";
556function computeScore(path, index) {
557 let segments = path.split("/");
558 let initialScore = segments.length;
559 if (segments.some(isSplat)) {
560 initialScore += splatPenalty;
561 }
562 if (index) {
563 initialScore += indexRouteValue;
564 }
565 return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
566}
567function compareIndexes(a, b) {
568 let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
569 return siblings ? (
570 // If two routes are siblings, we should try to match the earlier sibling
571 // first. This allows people to have fine-grained control over the matching
572 // behavior by simply putting routes with identical paths in the order they
573 // want them tried.
574 a[a.length - 1] - b[b.length - 1]
575 ) : (
576 // Otherwise, it doesn't really make sense to rank non-siblings by index,
577 // so they sort equally.
578 0
579 );
580}
581function matchRouteBranch(branch, pathname, allowPartial) {
582 if (allowPartial === void 0) {
583 allowPartial = false;
584 }
585 let {
586 routesMeta
587 } = branch;
588 let matchedParams = {};
589 let matchedPathname = "/";
590 let matches = [];
591 for (let i = 0; i < routesMeta.length; ++i) {
592 let meta = routesMeta[i];
593 let end = i === routesMeta.length - 1;
594 let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
595 let match = matchPath({
596 path: meta.relativePath,
597 caseSensitive: meta.caseSensitive,
598 end
599 }, remainingPathname);
600 let route = meta.route;
601 if (!match && end && allowPartial && !routesMeta[routesMeta.length - 1].route.index) {
602 match = matchPath({
603 path: meta.relativePath,
604 caseSensitive: meta.caseSensitive,
605 end: false
606 }, remainingPathname);
607 }
608 if (!match) {
609 return null;
610 }
611 Object.assign(matchedParams, match.params);
612 matches.push({
613 // TODO: Can this as be avoided?
614 params: matchedParams,
615 pathname: joinPaths([matchedPathname, match.pathname]),
616 pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
617 route
618 });
619 if (match.pathnameBase !== "/") {
620 matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
621 }
622 }
623 return matches;
624}
625function generatePath(originalPath, params) {
626 if (params === void 0) {
627 params = {};
628 }
629 let path = originalPath;
630 if (path.endsWith("*") && path !== "*" && !path.endsWith("/*")) {
631 warning(false, 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
632 path = path.replace(/\*$/, "/*");
633 }
634 const prefix = path.startsWith("/") ? "/" : "";
635 const stringify = (p) => p == null ? "" : typeof p === "string" ? p : String(p);
636 const segments = path.split(/\/+/).map((segment, index, array) => {
637 const isLastSegment = index === array.length - 1;
638 if (isLastSegment && segment === "*") {
639 const star = "*";
640 return stringify(params[star]);
641 }
642 const keyMatch = segment.match(/^:([\w-]+)(\??)$/);
643 if (keyMatch) {
644 const [, key, optional] = keyMatch;
645 let param = params[key];
646 invariant(optional === "?" || param != null, 'Missing ":' + key + '" param');
647 return stringify(param);
648 }
649 return segment.replace(/\?$/g, "");
650 }).filter((segment) => !!segment);
651 return prefix + segments.join("/");
652}
653function matchPath(pattern, pathname) {
654 if (typeof pattern === "string") {
655 pattern = {
656 path: pattern,
657 caseSensitive: false,
658 end: true
659 };
660 }
661 let [matcher, compiledParams] = compilePath(pattern.path, pattern.caseSensitive, pattern.end);
662 let match = pathname.match(matcher);
663 if (!match) return null;
664 let matchedPathname = match[0];
665 let pathnameBase = matchedPathname.replace(/(.)\/+$/, "$1");
666 let captureGroups = match.slice(1);
667 let params = compiledParams.reduce((memo2, _ref, index) => {
668 let {
669 paramName,
670 isOptional
671 } = _ref;
672 if (paramName === "*") {
673 let splatValue = captureGroups[index] || "";
674 pathnameBase = matchedPathname.slice(0, matchedPathname.length - splatValue.length).replace(/(.)\/+$/, "$1");
675 }
676 const value = captureGroups[index];
677 if (isOptional && !value) {
678 memo2[paramName] = void 0;
679 } else {
680 memo2[paramName] = (value || "").replace(/%2F/g, "/");
681 }
682 return memo2;
683 }, {});
684 return {
685 params,
686 pathname: matchedPathname,
687 pathnameBase,
688 pattern
689 };
690}
691function compilePath(path, caseSensitive, end) {
692 if (caseSensitive === void 0) {
693 caseSensitive = false;
694 }
695 if (end === void 0) {
696 end = true;
697 }
698 warning(path === "*" || !path.endsWith("*") || path.endsWith("/*"), 'Route path "' + path + '" will be treated as if it were ' + ('"' + path.replace(/\*$/, "/*") + '" because the `*` character must ') + "always follow a `/` in the pattern. To get rid of this warning, " + ('please change the route path to "' + path.replace(/\*$/, "/*") + '".'));
699 let params = [];
700 let regexpSource = "^" + path.replace(/\/*\*?$/, "").replace(/^\/*/, "/").replace(/[\\.*+^${}|()[\]]/g, "\\$&").replace(/\/:([\w-]+)(\?)?/g, (_, paramName, isOptional) => {
701 params.push({
702 paramName,
703 isOptional: isOptional != null
704 });
705 return isOptional ? "/?([^\\/]+)?" : "/([^\\/]+)";
706 });
707 if (path.endsWith("*")) {
708 params.push({
709 paramName: "*"
710 });
711 regexpSource += path === "*" || path === "/*" ? "(.*)$" : "(?:\\/(.+)|\\/*)$";
712 } else if (end) {
713 regexpSource += "\\/*$";
714 } else if (path !== "" && path !== "/") {
715 regexpSource += "(?:(?=\\/|$))";
716 } else ;
717 let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
718 return [matcher, params];
719}
720function decodePath(value) {
721 try {
722 return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
723 } catch (error) {
724 warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
725 return value;
726 }
727}
728function stripBasename(pathname, basename) {
729 if (basename === "/") return pathname;
730 if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
731 return null;
732 }
733 let startIndex = basename.endsWith("/") ? basename.length - 1 : basename.length;
734 let nextChar = pathname.charAt(startIndex);
735 if (nextChar && nextChar !== "/") {
736 return null;
737 }
738 return pathname.slice(startIndex) || "/";
739}
740function resolvePath(to, fromPathname) {
741 if (fromPathname === void 0) {
742 fromPathname = "/";
743 }
744 let {
745 pathname: toPathname,
746 search = "",
747 hash = ""
748 } = typeof to === "string" ? parsePath(to) : to;
749 let pathname = toPathname ? toPathname.startsWith("/") ? toPathname : resolvePathname(toPathname, fromPathname) : fromPathname;
750 return {
751 pathname,
752 search: normalizeSearch(search),
753 hash: normalizeHash(hash)
754 };
755}
756function resolvePathname(relativePath, fromPathname) {
757 let segments = fromPathname.replace(/\/+$/, "").split("/");
758 let relativeSegments = relativePath.split("/");
759 relativeSegments.forEach((segment) => {
760 if (segment === "..") {
761 if (segments.length > 1) segments.pop();
762 } else if (segment !== ".") {
763 segments.push(segment);
764 }
765 });
766 return segments.length > 1 ? segments.join("/") : "/";
767}
768function getInvalidPathError(char, field, dest, path) {
769 return "Cannot include a '" + char + "' character in a manually specified " + ("`to." + field + "` field [" + JSON.stringify(path) + "]. Please separate it out to the ") + ("`to." + dest + "` field. Alternatively you may provide the full path as ") + 'a string in <Link to="..."> and the router will parse it for you.';
770}
771function getPathContributingMatches(matches) {
772 return matches.filter((match, index) => index === 0 || match.route.path && match.route.path.length > 0);
773}
774function getResolveToMatches(matches, v7_relativeSplatPath) {
775 let pathMatches = getPathContributingMatches(matches);
776 if (v7_relativeSplatPath) {
777 return pathMatches.map((match, idx) => idx === pathMatches.length - 1 ? match.pathname : match.pathnameBase);
778 }
779 return pathMatches.map((match) => match.pathnameBase);
780}
781function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
782 if (isPathRelative === void 0) {
783 isPathRelative = false;
784 }
785 let to;
786 if (typeof toArg === "string") {
787 to = parsePath(toArg);
788 } else {
789 to = _extends({}, toArg);
790 invariant(!to.pathname || !to.pathname.includes("?"), getInvalidPathError("?", "pathname", "search", to));
791 invariant(!to.pathname || !to.pathname.includes("#"), getInvalidPathError("#", "pathname", "hash", to));
792 invariant(!to.search || !to.search.includes("#"), getInvalidPathError("#", "search", "hash", to));
793 }
794 let isEmptyPath = toArg === "" || to.pathname === "";
795 let toPathname = isEmptyPath ? "/" : to.pathname;
796 let from;
797 if (toPathname == null) {
798 from = locationPathname;
799 } else {
800 let routePathnameIndex = routePathnames.length - 1;
801 if (!isPathRelative && toPathname.startsWith("..")) {
802 let toSegments = toPathname.split("/");
803 while (toSegments[0] === "..") {
804 toSegments.shift();
805 routePathnameIndex -= 1;
806 }
807 to.pathname = toSegments.join("/");
808 }
809 from = routePathnameIndex >= 0 ? routePathnames[routePathnameIndex] : "/";
810 }
811 let path = resolvePath(to, from);
812 let hasExplicitTrailingSlash = toPathname && toPathname !== "/" && toPathname.endsWith("/");
813 let hasCurrentTrailingSlash = (isEmptyPath || toPathname === ".") && locationPathname.endsWith("/");
814 if (!path.pathname.endsWith("/") && (hasExplicitTrailingSlash || hasCurrentTrailingSlash)) {
815 path.pathname += "/";
816 }
817 return path;
818}
819var joinPaths = (paths) => paths.join("/").replace(/\/\/+/g, "/");
820var normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
821var normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
822var normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
823var json = function json2(data, init) {
824 if (init === void 0) {
825 init = {};
826 }
827 let responseInit = typeof init === "number" ? {
828 status: init
829 } : init;
830 let headers = new Headers(responseInit.headers);
831 if (!headers.has("Content-Type")) {
832 headers.set("Content-Type", "application/json; charset=utf-8");
833 }
834 return new Response(JSON.stringify(data), _extends({}, responseInit, {
835 headers
836 }));
837};
838var AbortedDeferredError = class extends Error {
839};
840var DeferredData = class {
841 constructor(data, responseInit) {
842 this.pendingKeysSet = /* @__PURE__ */ new Set();
843 this.subscribers = /* @__PURE__ */ new Set();
844 this.deferredKeys = [];
845 invariant(data && typeof data === "object" && !Array.isArray(data), "defer() only accepts plain objects");
846 let reject;
847 this.abortPromise = new Promise((_, r) => reject = r);
848 this.controller = new AbortController();
849 let onAbort = () => reject(new AbortedDeferredError("Deferred data aborted"));
850 this.unlistenAbortSignal = () => this.controller.signal.removeEventListener("abort", onAbort);
851 this.controller.signal.addEventListener("abort", onAbort);
852 this.data = Object.entries(data).reduce((acc, _ref2) => {
853 let [key, value] = _ref2;
854 return Object.assign(acc, {
855 [key]: this.trackPromise(key, value)
856 });
857 }, {});
858 if (this.done) {
859 this.unlistenAbortSignal();
860 }
861 this.init = responseInit;
862 }
863 trackPromise(key, value) {
864 if (!(value instanceof Promise)) {
865 return value;
866 }
867 this.deferredKeys.push(key);
868 this.pendingKeysSet.add(key);
869 let promise = Promise.race([value, this.abortPromise]).then((data) => this.onSettle(promise, key, void 0, data), (error) => this.onSettle(promise, key, error));
870 promise.catch(() => {
871 });
872 Object.defineProperty(promise, "_tracked", {
873 get: () => true
874 });
875 return promise;
876 }
877 onSettle(promise, key, error, data) {
878 if (this.controller.signal.aborted && error instanceof AbortedDeferredError) {
879 this.unlistenAbortSignal();
880 Object.defineProperty(promise, "_error", {
881 get: () => error
882 });
883 return Promise.reject(error);
884 }
885 this.pendingKeysSet.delete(key);
886 if (this.done) {
887 this.unlistenAbortSignal();
888 }
889 if (error === void 0 && data === void 0) {
890 let undefinedError = new Error('Deferred data for key "' + key + '" resolved/rejected with `undefined`, you must resolve/reject with a value or `null`.');
891 Object.defineProperty(promise, "_error", {
892 get: () => undefinedError
893 });
894 this.emit(false, key);
895 return Promise.reject(undefinedError);
896 }
897 if (data === void 0) {
898 Object.defineProperty(promise, "_error", {
899 get: () => error
900 });
901 this.emit(false, key);
902 return Promise.reject(error);
903 }
904 Object.defineProperty(promise, "_data", {
905 get: () => data
906 });
907 this.emit(false, key);
908 return data;
909 }
910 emit(aborted, settledKey) {
911 this.subscribers.forEach((subscriber) => subscriber(aborted, settledKey));
912 }
913 subscribe(fn) {
914 this.subscribers.add(fn);
915 return () => this.subscribers.delete(fn);
916 }
917 cancel() {
918 this.controller.abort();
919 this.pendingKeysSet.forEach((v, k) => this.pendingKeysSet.delete(k));
920 this.emit(true);
921 }
922 async resolveData(signal) {
923 let aborted = false;
924 if (!this.done) {
925 let onAbort = () => this.cancel();
926 signal.addEventListener("abort", onAbort);
927 aborted = await new Promise((resolve) => {
928 this.subscribe((aborted2) => {
929 signal.removeEventListener("abort", onAbort);
930 if (aborted2 || this.done) {
931 resolve(aborted2);
932 }
933 });
934 });
935 }
936 return aborted;
937 }
938 get done() {
939 return this.pendingKeysSet.size === 0;
940 }
941 get unwrappedData() {
942 invariant(this.data !== null && this.done, "Can only unwrap data on initialized and settled deferreds");
943 return Object.entries(this.data).reduce((acc, _ref3) => {
944 let [key, value] = _ref3;
945 return Object.assign(acc, {
946 [key]: unwrapTrackedPromise(value)
947 });
948 }, {});
949 }
950 get pendingKeys() {
951 return Array.from(this.pendingKeysSet);
952 }
953};
954function isTrackedPromise(value) {
955 return value instanceof Promise && value._tracked === true;
956}
957function unwrapTrackedPromise(value) {
958 if (!isTrackedPromise(value)) {
959 return value;
960 }
961 if (value._error) {
962 throw value._error;
963 }
964 return value._data;
965}
966var defer = function defer2(data, init) {
967 if (init === void 0) {
968 init = {};
969 }
970 let responseInit = typeof init === "number" ? {
971 status: init
972 } : init;
973 return new DeferredData(data, responseInit);
974};
975var redirect = function redirect2(url, init) {
976 if (init === void 0) {
977 init = 302;
978 }
979 let responseInit = init;
980 if (typeof responseInit === "number") {
981 responseInit = {
982 status: responseInit
983 };
984 } else if (typeof responseInit.status === "undefined") {
985 responseInit.status = 302;
986 }
987 let headers = new Headers(responseInit.headers);
988 headers.set("Location", url);
989 return new Response(null, _extends({}, responseInit, {
990 headers
991 }));
992};
993var redirectDocument = (url, init) => {
994 let response = redirect(url, init);
995 response.headers.set("X-Remix-Reload-Document", "true");
996 return response;
997};
998var replace = (url, init) => {
999 let response = redirect(url, init);
1000 response.headers.set("X-Remix-Replace", "true");
1001 return response;
1002};
1003var ErrorResponseImpl = class {
1004 constructor(status, statusText, data, internal) {
1005 if (internal === void 0) {
1006 internal = false;
1007 }
1008 this.status = status;
1009 this.statusText = statusText || "";
1010 this.internal = internal;
1011 if (data instanceof Error) {
1012 this.data = data.toString();
1013 this.error = data;
1014 } else {
1015 this.data = data;
1016 }
1017 }
1018};
1019function isRouteErrorResponse(error) {
1020 return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
1021}
1022var validMutationMethodsArr = ["post", "put", "patch", "delete"];
1023var validMutationMethods = new Set(validMutationMethodsArr);
1024var validRequestMethodsArr = ["get", ...validMutationMethodsArr];
1025var validRequestMethods = new Set(validRequestMethodsArr);
1026var redirectStatusCodes = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
1027var redirectPreserveMethodStatusCodes = /* @__PURE__ */ new Set([307, 308]);
1028var IDLE_NAVIGATION = {
1029 state: "idle",
1030 location: void 0,
1031 formMethod: void 0,
1032 formAction: void 0,
1033 formEncType: void 0,
1034 formData: void 0,
1035 json: void 0,
1036 text: void 0
1037};
1038var IDLE_FETCHER = {
1039 state: "idle",
1040 data: void 0,
1041 formMethod: void 0,
1042 formAction: void 0,
1043 formEncType: void 0,
1044 formData: void 0,
1045 json: void 0,
1046 text: void 0
1047};
1048var IDLE_BLOCKER = {
1049 state: "unblocked",
1050 proceed: void 0,
1051 reset: void 0,
1052 location: void 0
1053};
1054var ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
1055var defaultMapRouteProperties = (route) => ({
1056 hasErrorBoundary: Boolean(route.hasErrorBoundary)
1057});
1058var TRANSITIONS_STORAGE_KEY = "remix-router-transitions";
1059function createRouter(init) {
1060 const routerWindow = init.window ? init.window : typeof window !== "undefined" ? window : void 0;
1061 const isBrowser2 = typeof routerWindow !== "undefined" && typeof routerWindow.document !== "undefined" && typeof routerWindow.document.createElement !== "undefined";
1062 const isServer = !isBrowser2;
1063 invariant(init.routes.length > 0, "You must provide a non-empty routes array to createRouter");
1064 let mapRouteProperties2;
1065 if (init.mapRouteProperties) {
1066 mapRouteProperties2 = init.mapRouteProperties;
1067 } else if (init.detectErrorBoundary) {
1068 let detectErrorBoundary = init.detectErrorBoundary;
1069 mapRouteProperties2 = (route) => ({
1070 hasErrorBoundary: detectErrorBoundary(route)
1071 });
1072 } else {
1073 mapRouteProperties2 = defaultMapRouteProperties;
1074 }
1075 let manifest = {};
1076 let dataRoutes = convertRoutesToDataRoutes(init.routes, mapRouteProperties2, void 0, manifest);
1077 let inFlightDataRoutes;
1078 let basename = init.basename || "/";
1079 let dataStrategyImpl = init.unstable_dataStrategy || defaultDataStrategy;
1080 let patchRoutesOnMissImpl = init.unstable_patchRoutesOnMiss;
1081 let future = _extends({
1082 v7_fetcherPersist: false,
1083 v7_normalizeFormMethod: false,
1084 v7_partialHydration: false,
1085 v7_prependBasename: false,
1086 v7_relativeSplatPath: false,
1087 v7_skipActionErrorRevalidation: false
1088 }, init.future);
1089 let unlistenHistory = null;
1090 let subscribers = /* @__PURE__ */ new Set();
1091 let savedScrollPositions2 = null;
1092 let getScrollRestorationKey = null;
1093 let getScrollPosition = null;
1094 let initialScrollRestored = init.hydrationData != null;
1095 let initialMatches = matchRoutes(dataRoutes, init.history.location, basename);
1096 let initialErrors = null;
1097 if (initialMatches == null && !patchRoutesOnMissImpl) {
1098 let error = getInternalRouterError(404, {
1099 pathname: init.history.location.pathname
1100 });
1101 let {
1102 matches,
1103 route
1104 } = getShortCircuitMatches(dataRoutes);
1105 initialMatches = matches;
1106 initialErrors = {
1107 [route.id]: error
1108 };
1109 }
1110 if (initialMatches && !init.hydrationData) {
1111 let fogOfWar = checkFogOfWar(initialMatches, dataRoutes, init.history.location.pathname);
1112 if (fogOfWar.active) {
1113 initialMatches = null;
1114 }
1115 }
1116 let initialized;
1117 if (!initialMatches) {
1118 initialized = false;
1119 initialMatches = [];
1120 if (future.v7_partialHydration) {
1121 let fogOfWar = checkFogOfWar(null, dataRoutes, init.history.location.pathname);
1122 if (fogOfWar.active && fogOfWar.matches) {
1123 initialMatches = fogOfWar.matches;
1124 }
1125 }
1126 } else if (initialMatches.some((m) => m.route.lazy)) {
1127 initialized = false;
1128 } else if (!initialMatches.some((m) => m.route.loader)) {
1129 initialized = true;
1130 } else if (future.v7_partialHydration) {
1131 let loaderData = init.hydrationData ? init.hydrationData.loaderData : null;
1132 let errors = init.hydrationData ? init.hydrationData.errors : null;
1133 let isRouteInitialized = (m) => {
1134 if (!m.route.loader) {
1135 return true;
1136 }
1137 if (typeof m.route.loader === "function" && m.route.loader.hydrate === true) {
1138 return false;
1139 }
1140 return loaderData && loaderData[m.route.id] !== void 0 || errors && errors[m.route.id] !== void 0;
1141 };
1142 if (errors) {
1143 let idx = initialMatches.findIndex((m) => errors[m.route.id] !== void 0);
1144 initialized = initialMatches.slice(0, idx + 1).every(isRouteInitialized);
1145 } else {
1146 initialized = initialMatches.every(isRouteInitialized);
1147 }
1148 } else {
1149 initialized = init.hydrationData != null;
1150 }
1151 let router;
1152 let state = {
1153 historyAction: init.history.action,
1154 location: init.history.location,
1155 matches: initialMatches,
1156 initialized,
1157 navigation: IDLE_NAVIGATION,
1158 // Don't restore on initial updateState() if we were SSR'd
1159 restoreScrollPosition: init.hydrationData != null ? false : null,
1160 preventScrollReset: false,
1161 revalidation: "idle",
1162 loaderData: init.hydrationData && init.hydrationData.loaderData || {},
1163 actionData: init.hydrationData && init.hydrationData.actionData || null,
1164 errors: init.hydrationData && init.hydrationData.errors || initialErrors,
1165 fetchers: /* @__PURE__ */ new Map(),
1166 blockers: /* @__PURE__ */ new Map()
1167 };
1168 let pendingAction = Action.Pop;
1169 let pendingPreventScrollReset = false;
1170 let pendingNavigationController;
1171 let pendingViewTransitionEnabled = false;
1172 let appliedViewTransitions = /* @__PURE__ */ new Map();
1173 let removePageHideEventListener = null;
1174 let isUninterruptedRevalidation = false;
1175 let isRevalidationRequired = false;
1176 let cancelledDeferredRoutes = [];
1177 let cancelledFetcherLoads = /* @__PURE__ */ new Set();
1178 let fetchControllers = /* @__PURE__ */ new Map();
1179 let incrementingLoadId = 0;
1180 let pendingNavigationLoadId = -1;
1181 let fetchReloadIds = /* @__PURE__ */ new Map();
1182 let fetchRedirectIds = /* @__PURE__ */ new Set();
1183 let fetchLoadMatches = /* @__PURE__ */ new Map();
1184 let activeFetchers = /* @__PURE__ */ new Map();
1185 let deletedFetchers = /* @__PURE__ */ new Set();
1186 let activeDeferreds = /* @__PURE__ */ new Map();
1187 let blockerFunctions = /* @__PURE__ */ new Map();
1188 let pendingPatchRoutes = /* @__PURE__ */ new Map();
1189 let ignoreNextHistoryUpdate = false;
1190 function initialize() {
1191 unlistenHistory = init.history.listen((_ref) => {
1192 let {
1193 action: historyAction,
1194 location,
1195 delta
1196 } = _ref;
1197 if (ignoreNextHistoryUpdate) {
1198 ignoreNextHistoryUpdate = false;
1199 return;
1200 }
1201 warning(blockerFunctions.size === 0 || delta != null, "You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");
1202 let blockerKey = shouldBlockNavigation({
1203 currentLocation: state.location,
1204 nextLocation: location,
1205 historyAction
1206 });
1207 if (blockerKey && delta != null) {
1208 ignoreNextHistoryUpdate = true;
1209 init.history.go(delta * -1);
1210 updateBlocker(blockerKey, {
1211 state: "blocked",
1212 location,
1213 proceed() {
1214 updateBlocker(blockerKey, {
1215 state: "proceeding",
1216 proceed: void 0,
1217 reset: void 0,
1218 location
1219 });
1220 init.history.go(delta);
1221 },
1222 reset() {
1223 let blockers = new Map(state.blockers);
1224 blockers.set(blockerKey, IDLE_BLOCKER);
1225 updateState({
1226 blockers
1227 });
1228 }
1229 });
1230 return;
1231 }
1232 return startNavigation(historyAction, location);
1233 });
1234 if (isBrowser2) {
1235 restoreAppliedTransitions(routerWindow, appliedViewTransitions);
1236 let _saveAppliedTransitions = () => persistAppliedTransitions(routerWindow, appliedViewTransitions);
1237 routerWindow.addEventListener("pagehide", _saveAppliedTransitions);
1238 removePageHideEventListener = () => routerWindow.removeEventListener("pagehide", _saveAppliedTransitions);
1239 }
1240 if (!state.initialized) {
1241 startNavigation(Action.Pop, state.location, {
1242 initialHydration: true
1243 });
1244 }
1245 return router;
1246 }
1247 function dispose() {
1248 if (unlistenHistory) {
1249 unlistenHistory();
1250 }
1251 if (removePageHideEventListener) {
1252 removePageHideEventListener();
1253 }
1254 subscribers.clear();
1255 pendingNavigationController && pendingNavigationController.abort();
1256 state.fetchers.forEach((_, key) => deleteFetcher(key));
1257 state.blockers.forEach((_, key) => deleteBlocker(key));
1258 }
1259 function subscribe(fn) {
1260 subscribers.add(fn);
1261 return () => subscribers.delete(fn);
1262 }
1263 function updateState(newState, opts) {
1264 if (opts === void 0) {
1265 opts = {};
1266 }
1267 state = _extends({}, state, newState);
1268 let completedFetchers = [];
1269 let deletedFetchersKeys = [];
1270 if (future.v7_fetcherPersist) {
1271 state.fetchers.forEach((fetcher, key) => {
1272 if (fetcher.state === "idle") {
1273 if (deletedFetchers.has(key)) {
1274 deletedFetchersKeys.push(key);
1275 } else {
1276 completedFetchers.push(key);
1277 }
1278 }
1279 });
1280 }
1281 [...subscribers].forEach((subscriber) => subscriber(state, {
1282 deletedFetchers: deletedFetchersKeys,
1283 unstable_viewTransitionOpts: opts.viewTransitionOpts,
1284 unstable_flushSync: opts.flushSync === true
1285 }));
1286 if (future.v7_fetcherPersist) {
1287 completedFetchers.forEach((key) => state.fetchers.delete(key));
1288 deletedFetchersKeys.forEach((key) => deleteFetcher(key));
1289 }
1290 }
1291 function completeNavigation(location, newState, _temp) {
1292 var _location$state, _location$state2;
1293 let {
1294 flushSync
1295 } = _temp === void 0 ? {} : _temp;
1296 let isActionReload = state.actionData != null && state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && state.navigation.state === "loading" && ((_location$state = location.state) == null ? void 0 : _location$state._isRedirect) !== true;
1297 let actionData;
1298 if (newState.actionData) {
1299 if (Object.keys(newState.actionData).length > 0) {
1300 actionData = newState.actionData;
1301 } else {
1302 actionData = null;
1303 }
1304 } else if (isActionReload) {
1305 actionData = state.actionData;
1306 } else {
1307 actionData = null;
1308 }
1309 let loaderData = newState.loaderData ? mergeLoaderData(state.loaderData, newState.loaderData, newState.matches || [], newState.errors) : state.loaderData;
1310 let blockers = state.blockers;
1311 if (blockers.size > 0) {
1312 blockers = new Map(blockers);
1313 blockers.forEach((_, k) => blockers.set(k, IDLE_BLOCKER));
1314 }
1315 let preventScrollReset = pendingPreventScrollReset === true || state.navigation.formMethod != null && isMutationMethod(state.navigation.formMethod) && ((_location$state2 = location.state) == null ? void 0 : _location$state2._isRedirect) !== true;
1316 if (inFlightDataRoutes) {
1317 dataRoutes = inFlightDataRoutes;
1318 inFlightDataRoutes = void 0;
1319 }
1320 if (isUninterruptedRevalidation) ;
1321 else if (pendingAction === Action.Pop) ;
1322 else if (pendingAction === Action.Push) {
1323 init.history.push(location, location.state);
1324 } else if (pendingAction === Action.Replace) {
1325 init.history.replace(location, location.state);
1326 }
1327 let viewTransitionOpts;
1328 if (pendingAction === Action.Pop) {
1329 let priorPaths = appliedViewTransitions.get(state.location.pathname);
1330 if (priorPaths && priorPaths.has(location.pathname)) {
1331 viewTransitionOpts = {
1332 currentLocation: state.location,
1333 nextLocation: location
1334 };
1335 } else if (appliedViewTransitions.has(location.pathname)) {
1336 viewTransitionOpts = {
1337 currentLocation: location,
1338 nextLocation: state.location
1339 };
1340 }
1341 } else if (pendingViewTransitionEnabled) {
1342 let toPaths = appliedViewTransitions.get(state.location.pathname);
1343 if (toPaths) {
1344 toPaths.add(location.pathname);
1345 } else {
1346 toPaths = /* @__PURE__ */ new Set([location.pathname]);
1347 appliedViewTransitions.set(state.location.pathname, toPaths);
1348 }
1349 viewTransitionOpts = {
1350 currentLocation: state.location,
1351 nextLocation: location
1352 };
1353 }
1354 updateState(_extends({}, newState, {
1355 actionData,
1356 loaderData,
1357 historyAction: pendingAction,
1358 location,
1359 initialized: true,
1360 navigation: IDLE_NAVIGATION,
1361 revalidation: "idle",
1362 restoreScrollPosition: getSavedScrollPosition(location, newState.matches || state.matches),
1363 preventScrollReset,
1364 blockers
1365 }), {
1366 viewTransitionOpts,
1367 flushSync: flushSync === true
1368 });
1369 pendingAction = Action.Pop;
1370 pendingPreventScrollReset = false;
1371 pendingViewTransitionEnabled = false;
1372 isUninterruptedRevalidation = false;
1373 isRevalidationRequired = false;
1374 cancelledDeferredRoutes = [];
1375 }
1376 async function navigate(to, opts) {
1377 if (typeof to === "number") {
1378 init.history.go(to);
1379 return;
1380 }
1381 let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, to, future.v7_relativeSplatPath, opts == null ? void 0 : opts.fromRouteId, opts == null ? void 0 : opts.relative);
1382 let {
1383 path,
1384 submission,
1385 error
1386 } = normalizeNavigateOptions(future.v7_normalizeFormMethod, false, normalizedPath, opts);
1387 let currentLocation = state.location;
1388 let nextLocation = createLocation(state.location, path, opts && opts.state);
1389 nextLocation = _extends({}, nextLocation, init.history.encodeLocation(nextLocation));
1390 let userReplace = opts && opts.replace != null ? opts.replace : void 0;
1391 let historyAction = Action.Push;
1392 if (userReplace === true) {
1393 historyAction = Action.Replace;
1394 } else if (userReplace === false) ;
1395 else if (submission != null && isMutationMethod(submission.formMethod) && submission.formAction === state.location.pathname + state.location.search) {
1396 historyAction = Action.Replace;
1397 }
1398 let preventScrollReset = opts && "preventScrollReset" in opts ? opts.preventScrollReset === true : void 0;
1399 let flushSync = (opts && opts.unstable_flushSync) === true;
1400 let blockerKey = shouldBlockNavigation({
1401 currentLocation,
1402 nextLocation,
1403 historyAction
1404 });
1405 if (blockerKey) {
1406 updateBlocker(blockerKey, {
1407 state: "blocked",
1408 location: nextLocation,
1409 proceed() {
1410 updateBlocker(blockerKey, {
1411 state: "proceeding",
1412 proceed: void 0,
1413 reset: void 0,
1414 location: nextLocation
1415 });
1416 navigate(to, opts);
1417 },
1418 reset() {
1419 let blockers = new Map(state.blockers);
1420 blockers.set(blockerKey, IDLE_BLOCKER);
1421 updateState({
1422 blockers
1423 });
1424 }
1425 });
1426 return;
1427 }
1428 return await startNavigation(historyAction, nextLocation, {
1429 submission,
1430 // Send through the formData serialization error if we have one so we can
1431 // render at the right error boundary after we match routes
1432 pendingError: error,
1433 preventScrollReset,
1434 replace: opts && opts.replace,
1435 enableViewTransition: opts && opts.unstable_viewTransition,
1436 flushSync
1437 });
1438 }
1439 function revalidate() {
1440 interruptActiveLoads();
1441 updateState({
1442 revalidation: "loading"
1443 });
1444 if (state.navigation.state === "submitting") {
1445 return;
1446 }
1447 if (state.navigation.state === "idle") {
1448 startNavigation(state.historyAction, state.location, {
1449 startUninterruptedRevalidation: true
1450 });
1451 return;
1452 }
1453 startNavigation(pendingAction || state.historyAction, state.navigation.location, {
1454 overrideNavigation: state.navigation
1455 });
1456 }
1457 async function startNavigation(historyAction, location, opts) {
1458 pendingNavigationController && pendingNavigationController.abort();
1459 pendingNavigationController = null;
1460 pendingAction = historyAction;
1461 isUninterruptedRevalidation = (opts && opts.startUninterruptedRevalidation) === true;
1462 saveScrollPosition(state.location, state.matches);
1463 pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
1464 pendingViewTransitionEnabled = (opts && opts.enableViewTransition) === true;
1465 let routesToUse = inFlightDataRoutes || dataRoutes;
1466 let loadingNavigation = opts && opts.overrideNavigation;
1467 let matches = matchRoutes(routesToUse, location, basename);
1468 let flushSync = (opts && opts.flushSync) === true;
1469 let fogOfWar = checkFogOfWar(matches, routesToUse, location.pathname);
1470 if (fogOfWar.active && fogOfWar.matches) {
1471 matches = fogOfWar.matches;
1472 }
1473 if (!matches) {
1474 let {
1475 error,
1476 notFoundMatches,
1477 route
1478 } = handleNavigational404(location.pathname);
1479 completeNavigation(location, {
1480 matches: notFoundMatches,
1481 loaderData: {},
1482 errors: {
1483 [route.id]: error
1484 }
1485 }, {
1486 flushSync
1487 });
1488 return;
1489 }
1490 if (state.initialized && !isRevalidationRequired && isHashChangeOnly(state.location, location) && !(opts && opts.submission && isMutationMethod(opts.submission.formMethod))) {
1491 completeNavigation(location, {
1492 matches
1493 }, {
1494 flushSync
1495 });
1496 return;
1497 }
1498 pendingNavigationController = new AbortController();
1499 let request = createClientSideRequest(init.history, location, pendingNavigationController.signal, opts && opts.submission);
1500 let pendingActionResult;
1501 if (opts && opts.pendingError) {
1502 pendingActionResult = [findNearestBoundary(matches).route.id, {
1503 type: ResultType.error,
1504 error: opts.pendingError
1505 }];
1506 } else if (opts && opts.submission && isMutationMethod(opts.submission.formMethod)) {
1507 let actionResult = await handleAction(request, location, opts.submission, matches, fogOfWar.active, {
1508 replace: opts.replace,
1509 flushSync
1510 });
1511 if (actionResult.shortCircuited) {
1512 return;
1513 }
1514 if (actionResult.pendingActionResult) {
1515 let [routeId, result] = actionResult.pendingActionResult;
1516 if (isErrorResult(result) && isRouteErrorResponse(result.error) && result.error.status === 404) {
1517 pendingNavigationController = null;
1518 completeNavigation(location, {
1519 matches: actionResult.matches,
1520 loaderData: {},
1521 errors: {
1522 [routeId]: result.error
1523 }
1524 });
1525 return;
1526 }
1527 }
1528 matches = actionResult.matches || matches;
1529 pendingActionResult = actionResult.pendingActionResult;
1530 loadingNavigation = getLoadingNavigation(location, opts.submission);
1531 flushSync = false;
1532 fogOfWar.active = false;
1533 request = createClientSideRequest(init.history, request.url, request.signal);
1534 }
1535 let {
1536 shortCircuited,
1537 matches: updatedMatches,
1538 loaderData,
1539 errors
1540 } = await handleLoaders(request, location, matches, fogOfWar.active, loadingNavigation, opts && opts.submission, opts && opts.fetcherSubmission, opts && opts.replace, opts && opts.initialHydration === true, flushSync, pendingActionResult);
1541 if (shortCircuited) {
1542 return;
1543 }
1544 pendingNavigationController = null;
1545 completeNavigation(location, _extends({
1546 matches: updatedMatches || matches
1547 }, getActionDataForCommit(pendingActionResult), {
1548 loaderData,
1549 errors
1550 }));
1551 }
1552 async function handleAction(request, location, submission, matches, isFogOfWar, opts) {
1553 if (opts === void 0) {
1554 opts = {};
1555 }
1556 interruptActiveLoads();
1557 let navigation = getSubmittingNavigation(location, submission);
1558 updateState({
1559 navigation
1560 }, {
1561 flushSync: opts.flushSync === true
1562 });
1563 if (isFogOfWar) {
1564 let discoverResult = await discoverRoutes(matches, location.pathname, request.signal);
1565 if (discoverResult.type === "aborted") {
1566 return {
1567 shortCircuited: true
1568 };
1569 } else if (discoverResult.type === "error") {
1570 let {
1571 boundaryId,
1572 error
1573 } = handleDiscoverRouteError(location.pathname, discoverResult);
1574 return {
1575 matches: discoverResult.partialMatches,
1576 pendingActionResult: [boundaryId, {
1577 type: ResultType.error,
1578 error
1579 }]
1580 };
1581 } else if (!discoverResult.matches) {
1582 let {
1583 notFoundMatches,
1584 error,
1585 route
1586 } = handleNavigational404(location.pathname);
1587 return {
1588 matches: notFoundMatches,
1589 pendingActionResult: [route.id, {
1590 type: ResultType.error,
1591 error
1592 }]
1593 };
1594 } else {
1595 matches = discoverResult.matches;
1596 }
1597 }
1598 let result;
1599 let actionMatch = getTargetMatch(matches, location);
1600 if (!actionMatch.route.action && !actionMatch.route.lazy) {
1601 result = {
1602 type: ResultType.error,
1603 error: getInternalRouterError(405, {
1604 method: request.method,
1605 pathname: location.pathname,
1606 routeId: actionMatch.route.id
1607 })
1608 };
1609 } else {
1610 let results = await callDataStrategy("action", request, [actionMatch], matches);
1611 result = results[0];
1612 if (request.signal.aborted) {
1613 return {
1614 shortCircuited: true
1615 };
1616 }
1617 }
1618 if (isRedirectResult(result)) {
1619 let replace2;
1620 if (opts && opts.replace != null) {
1621 replace2 = opts.replace;
1622 } else {
1623 let location2 = normalizeRedirectLocation(result.response.headers.get("Location"), new URL(request.url), basename);
1624 replace2 = location2 === state.location.pathname + state.location.search;
1625 }
1626 await startRedirectNavigation(request, result, {
1627 submission,
1628 replace: replace2
1629 });
1630 return {
1631 shortCircuited: true
1632 };
1633 }
1634 if (isDeferredResult(result)) {
1635 throw getInternalRouterError(400, {
1636 type: "defer-action"
1637 });
1638 }
1639 if (isErrorResult(result)) {
1640 let boundaryMatch = findNearestBoundary(matches, actionMatch.route.id);
1641 if ((opts && opts.replace) !== true) {
1642 pendingAction = Action.Push;
1643 }
1644 return {
1645 matches,
1646 pendingActionResult: [boundaryMatch.route.id, result]
1647 };
1648 }
1649 return {
1650 matches,
1651 pendingActionResult: [actionMatch.route.id, result]
1652 };
1653 }
1654 async function handleLoaders(request, location, matches, isFogOfWar, overrideNavigation, submission, fetcherSubmission, replace2, initialHydration, flushSync, pendingActionResult) {
1655 let loadingNavigation = overrideNavigation || getLoadingNavigation(location, submission);
1656 let activeSubmission = submission || fetcherSubmission || getSubmissionFromNavigation(loadingNavigation);
1657 let shouldUpdateNavigationState = !isUninterruptedRevalidation && (!future.v7_partialHydration || !initialHydration);
1658 if (isFogOfWar) {
1659 if (shouldUpdateNavigationState) {
1660 let actionData = getUpdatedActionData(pendingActionResult);
1661 updateState(_extends({
1662 navigation: loadingNavigation
1663 }, actionData !== void 0 ? {
1664 actionData
1665 } : {}), {
1666 flushSync
1667 });
1668 }
1669 let discoverResult = await discoverRoutes(matches, location.pathname, request.signal);
1670 if (discoverResult.type === "aborted") {
1671 return {
1672 shortCircuited: true
1673 };
1674 } else if (discoverResult.type === "error") {
1675 let {
1676 boundaryId,
1677 error
1678 } = handleDiscoverRouteError(location.pathname, discoverResult);
1679 return {
1680 matches: discoverResult.partialMatches,
1681 loaderData: {},
1682 errors: {
1683 [boundaryId]: error
1684 }
1685 };
1686 } else if (!discoverResult.matches) {
1687 let {
1688 error,
1689 notFoundMatches,
1690 route
1691 } = handleNavigational404(location.pathname);
1692 return {
1693 matches: notFoundMatches,
1694 loaderData: {},
1695 errors: {
1696 [route.id]: error
1697 }
1698 };
1699 } else {
1700 matches = discoverResult.matches;
1701 }
1702 }
1703 let routesToUse = inFlightDataRoutes || dataRoutes;
1704 let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, activeSubmission, location, future.v7_partialHydration && initialHydration === true, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult);
1705 cancelActiveDeferreds((routeId) => !(matches && matches.some((m) => m.route.id === routeId)) || matchesToLoad && matchesToLoad.some((m) => m.route.id === routeId));
1706 pendingNavigationLoadId = ++incrementingLoadId;
1707 if (matchesToLoad.length === 0 && revalidatingFetchers.length === 0) {
1708 let updatedFetchers2 = markFetchRedirectsDone();
1709 completeNavigation(location, _extends({
1710 matches,
1711 loaderData: {},
1712 // Commit pending error if we're short circuiting
1713 errors: pendingActionResult && isErrorResult(pendingActionResult[1]) ? {
1714 [pendingActionResult[0]]: pendingActionResult[1].error
1715 } : null
1716 }, getActionDataForCommit(pendingActionResult), updatedFetchers2 ? {
1717 fetchers: new Map(state.fetchers)
1718 } : {}), {
1719 flushSync
1720 });
1721 return {
1722 shortCircuited: true
1723 };
1724 }
1725 if (shouldUpdateNavigationState) {
1726 let updates = {};
1727 if (!isFogOfWar) {
1728 updates.navigation = loadingNavigation;
1729 let actionData = getUpdatedActionData(pendingActionResult);
1730 if (actionData !== void 0) {
1731 updates.actionData = actionData;
1732 }
1733 }
1734 if (revalidatingFetchers.length > 0) {
1735 updates.fetchers = getUpdatedRevalidatingFetchers(revalidatingFetchers);
1736 }
1737 updateState(updates, {
1738 flushSync
1739 });
1740 }
1741 revalidatingFetchers.forEach((rf) => {
1742 if (fetchControllers.has(rf.key)) {
1743 abortFetcher(rf.key);
1744 }
1745 if (rf.controller) {
1746 fetchControllers.set(rf.key, rf.controller);
1747 }
1748 });
1749 let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((f) => abortFetcher(f.key));
1750 if (pendingNavigationController) {
1751 pendingNavigationController.signal.addEventListener("abort", abortPendingFetchRevalidations);
1752 }
1753 let {
1754 loaderResults,
1755 fetcherResults
1756 } = await callLoadersAndMaybeResolveData(state.matches, matches, matchesToLoad, revalidatingFetchers, request);
1757 if (request.signal.aborted) {
1758 return {
1759 shortCircuited: true
1760 };
1761 }
1762 if (pendingNavigationController) {
1763 pendingNavigationController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
1764 }
1765 revalidatingFetchers.forEach((rf) => fetchControllers.delete(rf.key));
1766 let redirect3 = findRedirect([...loaderResults, ...fetcherResults]);
1767 if (redirect3) {
1768 if (redirect3.idx >= matchesToLoad.length) {
1769 let fetcherKey = revalidatingFetchers[redirect3.idx - matchesToLoad.length].key;
1770 fetchRedirectIds.add(fetcherKey);
1771 }
1772 await startRedirectNavigation(request, redirect3.result, {
1773 replace: replace2
1774 });
1775 return {
1776 shortCircuited: true
1777 };
1778 }
1779 let {
1780 loaderData,
1781 errors
1782 } = processLoaderData(state, matches, matchesToLoad, loaderResults, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds);
1783 activeDeferreds.forEach((deferredData, routeId) => {
1784 deferredData.subscribe((aborted) => {
1785 if (aborted || deferredData.done) {
1786 activeDeferreds.delete(routeId);
1787 }
1788 });
1789 });
1790 if (future.v7_partialHydration && initialHydration && state.errors) {
1791 Object.entries(state.errors).filter((_ref2) => {
1792 let [id] = _ref2;
1793 return !matchesToLoad.some((m) => m.route.id === id);
1794 }).forEach((_ref3) => {
1795 let [routeId, error] = _ref3;
1796 errors = Object.assign(errors || {}, {
1797 [routeId]: error
1798 });
1799 });
1800 }
1801 let updatedFetchers = markFetchRedirectsDone();
1802 let didAbortFetchLoads = abortStaleFetchLoads(pendingNavigationLoadId);
1803 let shouldUpdateFetchers = updatedFetchers || didAbortFetchLoads || revalidatingFetchers.length > 0;
1804 return _extends({
1805 matches,
1806 loaderData,
1807 errors
1808 }, shouldUpdateFetchers ? {
1809 fetchers: new Map(state.fetchers)
1810 } : {});
1811 }
1812 function getUpdatedActionData(pendingActionResult) {
1813 if (pendingActionResult && !isErrorResult(pendingActionResult[1])) {
1814 return {
1815 [pendingActionResult[0]]: pendingActionResult[1].data
1816 };
1817 } else if (state.actionData) {
1818 if (Object.keys(state.actionData).length === 0) {
1819 return null;
1820 } else {
1821 return state.actionData;
1822 }
1823 }
1824 }
1825 function getUpdatedRevalidatingFetchers(revalidatingFetchers) {
1826 revalidatingFetchers.forEach((rf) => {
1827 let fetcher = state.fetchers.get(rf.key);
1828 let revalidatingFetcher = getLoadingFetcher(void 0, fetcher ? fetcher.data : void 0);
1829 state.fetchers.set(rf.key, revalidatingFetcher);
1830 });
1831 return new Map(state.fetchers);
1832 }
1833 function fetch(key, routeId, href, opts) {
1834 if (isServer) {
1835 throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");
1836 }
1837 if (fetchControllers.has(key)) abortFetcher(key);
1838 let flushSync = (opts && opts.unstable_flushSync) === true;
1839 let routesToUse = inFlightDataRoutes || dataRoutes;
1840 let normalizedPath = normalizeTo(state.location, state.matches, basename, future.v7_prependBasename, href, future.v7_relativeSplatPath, routeId, opts == null ? void 0 : opts.relative);
1841 let matches = matchRoutes(routesToUse, normalizedPath, basename);
1842 let fogOfWar = checkFogOfWar(matches, routesToUse, normalizedPath);
1843 if (fogOfWar.active && fogOfWar.matches) {
1844 matches = fogOfWar.matches;
1845 }
1846 if (!matches) {
1847 setFetcherError(key, routeId, getInternalRouterError(404, {
1848 pathname: normalizedPath
1849 }), {
1850 flushSync
1851 });
1852 return;
1853 }
1854 let {
1855 path,
1856 submission,
1857 error
1858 } = normalizeNavigateOptions(future.v7_normalizeFormMethod, true, normalizedPath, opts);
1859 if (error) {
1860 setFetcherError(key, routeId, error, {
1861 flushSync
1862 });
1863 return;
1864 }
1865 let match = getTargetMatch(matches, path);
1866 pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;
1867 if (submission && isMutationMethod(submission.formMethod)) {
1868 handleFetcherAction(key, routeId, path, match, matches, fogOfWar.active, flushSync, submission);
1869 return;
1870 }
1871 fetchLoadMatches.set(key, {
1872 routeId,
1873 path
1874 });
1875 handleFetcherLoader(key, routeId, path, match, matches, fogOfWar.active, flushSync, submission);
1876 }
1877 async function handleFetcherAction(key, routeId, path, match, requestMatches, isFogOfWar, flushSync, submission) {
1878 interruptActiveLoads();
1879 fetchLoadMatches.delete(key);
1880 function detectAndHandle405Error(m) {
1881 if (!m.route.action && !m.route.lazy) {
1882 let error = getInternalRouterError(405, {
1883 method: submission.formMethod,
1884 pathname: path,
1885 routeId
1886 });
1887 setFetcherError(key, routeId, error, {
1888 flushSync
1889 });
1890 return true;
1891 }
1892 return false;
1893 }
1894 if (!isFogOfWar && detectAndHandle405Error(match)) {
1895 return;
1896 }
1897 let existingFetcher = state.fetchers.get(key);
1898 updateFetcherState(key, getSubmittingFetcher(submission, existingFetcher), {
1899 flushSync
1900 });
1901 let abortController = new AbortController();
1902 let fetchRequest = createClientSideRequest(init.history, path, abortController.signal, submission);
1903 if (isFogOfWar) {
1904 let discoverResult = await discoverRoutes(requestMatches, path, fetchRequest.signal);
1905 if (discoverResult.type === "aborted") {
1906 return;
1907 } else if (discoverResult.type === "error") {
1908 let {
1909 error
1910 } = handleDiscoverRouteError(path, discoverResult);
1911 setFetcherError(key, routeId, error, {
1912 flushSync
1913 });
1914 return;
1915 } else if (!discoverResult.matches) {
1916 setFetcherError(key, routeId, getInternalRouterError(404, {
1917 pathname: path
1918 }), {
1919 flushSync
1920 });
1921 return;
1922 } else {
1923 requestMatches = discoverResult.matches;
1924 match = getTargetMatch(requestMatches, path);
1925 if (detectAndHandle405Error(match)) {
1926 return;
1927 }
1928 }
1929 }
1930 fetchControllers.set(key, abortController);
1931 let originatingLoadId = incrementingLoadId;
1932 let actionResults = await callDataStrategy("action", fetchRequest, [match], requestMatches);
1933 let actionResult = actionResults[0];
1934 if (fetchRequest.signal.aborted) {
1935 if (fetchControllers.get(key) === abortController) {
1936 fetchControllers.delete(key);
1937 }
1938 return;
1939 }
1940 if (future.v7_fetcherPersist && deletedFetchers.has(key)) {
1941 if (isRedirectResult(actionResult) || isErrorResult(actionResult)) {
1942 updateFetcherState(key, getDoneFetcher(void 0));
1943 return;
1944 }
1945 } else {
1946 if (isRedirectResult(actionResult)) {
1947 fetchControllers.delete(key);
1948 if (pendingNavigationLoadId > originatingLoadId) {
1949 updateFetcherState(key, getDoneFetcher(void 0));
1950 return;
1951 } else {
1952 fetchRedirectIds.add(key);
1953 updateFetcherState(key, getLoadingFetcher(submission));
1954 return startRedirectNavigation(fetchRequest, actionResult, {
1955 fetcherSubmission: submission
1956 });
1957 }
1958 }
1959 if (isErrorResult(actionResult)) {
1960 setFetcherError(key, routeId, actionResult.error);
1961 return;
1962 }
1963 }
1964 if (isDeferredResult(actionResult)) {
1965 throw getInternalRouterError(400, {
1966 type: "defer-action"
1967 });
1968 }
1969 let nextLocation = state.navigation.location || state.location;
1970 let revalidationRequest = createClientSideRequest(init.history, nextLocation, abortController.signal);
1971 let routesToUse = inFlightDataRoutes || dataRoutes;
1972 let matches = state.navigation.state !== "idle" ? matchRoutes(routesToUse, state.navigation.location, basename) : state.matches;
1973 invariant(matches, "Didn't find any matches after fetcher action");
1974 let loadId = ++incrementingLoadId;
1975 fetchReloadIds.set(key, loadId);
1976 let loadFetcher = getLoadingFetcher(submission, actionResult.data);
1977 state.fetchers.set(key, loadFetcher);
1978 let [matchesToLoad, revalidatingFetchers] = getMatchesToLoad(init.history, state, matches, submission, nextLocation, false, future.v7_skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, [match.route.id, actionResult]);
1979 revalidatingFetchers.filter((rf) => rf.key !== key).forEach((rf) => {
1980 let staleKey = rf.key;
1981 let existingFetcher2 = state.fetchers.get(staleKey);
1982 let revalidatingFetcher = getLoadingFetcher(void 0, existingFetcher2 ? existingFetcher2.data : void 0);
1983 state.fetchers.set(staleKey, revalidatingFetcher);
1984 if (fetchControllers.has(staleKey)) {
1985 abortFetcher(staleKey);
1986 }
1987 if (rf.controller) {
1988 fetchControllers.set(staleKey, rf.controller);
1989 }
1990 });
1991 updateState({
1992 fetchers: new Map(state.fetchers)
1993 });
1994 let abortPendingFetchRevalidations = () => revalidatingFetchers.forEach((rf) => abortFetcher(rf.key));
1995 abortController.signal.addEventListener("abort", abortPendingFetchRevalidations);
1996 let {
1997 loaderResults,
1998 fetcherResults
1999 } = await callLoadersAndMaybeResolveData(state.matches, matches, matchesToLoad, revalidatingFetchers, revalidationRequest);
2000 if (abortController.signal.aborted) {
2001 return;
2002 }
2003 abortController.signal.removeEventListener("abort", abortPendingFetchRevalidations);
2004 fetchReloadIds.delete(key);
2005 fetchControllers.delete(key);
2006 revalidatingFetchers.forEach((r) => fetchControllers.delete(r.key));
2007 let redirect3 = findRedirect([...loaderResults, ...fetcherResults]);
2008 if (redirect3) {
2009 if (redirect3.idx >= matchesToLoad.length) {
2010 let fetcherKey = revalidatingFetchers[redirect3.idx - matchesToLoad.length].key;
2011 fetchRedirectIds.add(fetcherKey);
2012 }
2013 return startRedirectNavigation(revalidationRequest, redirect3.result);
2014 }
2015 let {
2016 loaderData,
2017 errors
2018 } = processLoaderData(state, state.matches, matchesToLoad, loaderResults, void 0, revalidatingFetchers, fetcherResults, activeDeferreds);
2019 if (state.fetchers.has(key)) {
2020 let doneFetcher = getDoneFetcher(actionResult.data);
2021 state.fetchers.set(key, doneFetcher);
2022 }
2023 abortStaleFetchLoads(loadId);
2024 if (state.navigation.state === "loading" && loadId > pendingNavigationLoadId) {
2025 invariant(pendingAction, "Expected pending action");
2026 pendingNavigationController && pendingNavigationController.abort();
2027 completeNavigation(state.navigation.location, {
2028 matches,
2029 loaderData,
2030 errors,
2031 fetchers: new Map(state.fetchers)
2032 });
2033 } else {
2034 updateState({
2035 errors,
2036 loaderData: mergeLoaderData(state.loaderData, loaderData, matches, errors),
2037 fetchers: new Map(state.fetchers)
2038 });
2039 isRevalidationRequired = false;
2040 }
2041 }
2042 async function handleFetcherLoader(key, routeId, path, match, matches, isFogOfWar, flushSync, submission) {
2043 let existingFetcher = state.fetchers.get(key);
2044 updateFetcherState(key, getLoadingFetcher(submission, existingFetcher ? existingFetcher.data : void 0), {
2045 flushSync
2046 });
2047 let abortController = new AbortController();
2048 let fetchRequest = createClientSideRequest(init.history, path, abortController.signal);
2049 if (isFogOfWar) {
2050 let discoverResult = await discoverRoutes(matches, path, fetchRequest.signal);
2051 if (discoverResult.type === "aborted") {
2052 return;
2053 } else if (discoverResult.type === "error") {
2054 let {
2055 error
2056 } = handleDiscoverRouteError(path, discoverResult);
2057 setFetcherError(key, routeId, error, {
2058 flushSync
2059 });
2060 return;
2061 } else if (!discoverResult.matches) {
2062 setFetcherError(key, routeId, getInternalRouterError(404, {
2063 pathname: path
2064 }), {
2065 flushSync
2066 });
2067 return;
2068 } else {
2069 matches = discoverResult.matches;
2070 match = getTargetMatch(matches, path);
2071 }
2072 }
2073 fetchControllers.set(key, abortController);
2074 let originatingLoadId = incrementingLoadId;
2075 let results = await callDataStrategy("loader", fetchRequest, [match], matches);
2076 let result = results[0];
2077 if (isDeferredResult(result)) {
2078 result = await resolveDeferredData(result, fetchRequest.signal, true) || result;
2079 }
2080 if (fetchControllers.get(key) === abortController) {
2081 fetchControllers.delete(key);
2082 }
2083 if (fetchRequest.signal.aborted) {
2084 return;
2085 }
2086 if (deletedFetchers.has(key)) {
2087 updateFetcherState(key, getDoneFetcher(void 0));
2088 return;
2089 }
2090 if (isRedirectResult(result)) {
2091 if (pendingNavigationLoadId > originatingLoadId) {
2092 updateFetcherState(key, getDoneFetcher(void 0));
2093 return;
2094 } else {
2095 fetchRedirectIds.add(key);
2096 await startRedirectNavigation(fetchRequest, result);
2097 return;
2098 }
2099 }
2100 if (isErrorResult(result)) {
2101 setFetcherError(key, routeId, result.error);
2102 return;
2103 }
2104 invariant(!isDeferredResult(result), "Unhandled fetcher deferred data");
2105 updateFetcherState(key, getDoneFetcher(result.data));
2106 }
2107 async function startRedirectNavigation(request, redirect3, _temp2) {
2108 let {
2109 submission,
2110 fetcherSubmission,
2111 replace: replace2
2112 } = _temp2 === void 0 ? {} : _temp2;
2113 if (redirect3.response.headers.has("X-Remix-Revalidate")) {
2114 isRevalidationRequired = true;
2115 }
2116 let location = redirect3.response.headers.get("Location");
2117 invariant(location, "Expected a Location header on the redirect Response");
2118 location = normalizeRedirectLocation(location, new URL(request.url), basename);
2119 let redirectLocation = createLocation(state.location, location, {
2120 _isRedirect: true
2121 });
2122 if (isBrowser2) {
2123 let isDocumentReload = false;
2124 if (redirect3.response.headers.has("X-Remix-Reload-Document")) {
2125 isDocumentReload = true;
2126 } else if (ABSOLUTE_URL_REGEX.test(location)) {
2127 const url = init.history.createURL(location);
2128 isDocumentReload = // Hard reload if it's an absolute URL to a new origin
2129 url.origin !== routerWindow.location.origin || // Hard reload if it's an absolute URL that does not match our basename
2130 stripBasename(url.pathname, basename) == null;
2131 }
2132 if (isDocumentReload) {
2133 if (replace2) {
2134 routerWindow.location.replace(location);
2135 } else {
2136 routerWindow.location.assign(location);
2137 }
2138 return;
2139 }
2140 }
2141 pendingNavigationController = null;
2142 let redirectHistoryAction = replace2 === true || redirect3.response.headers.has("X-Remix-Replace") ? Action.Replace : Action.Push;
2143 let {
2144 formMethod,
2145 formAction,
2146 formEncType
2147 } = state.navigation;
2148 if (!submission && !fetcherSubmission && formMethod && formAction && formEncType) {
2149 submission = getSubmissionFromNavigation(state.navigation);
2150 }
2151 let activeSubmission = submission || fetcherSubmission;
2152 if (redirectPreserveMethodStatusCodes.has(redirect3.response.status) && activeSubmission && isMutationMethod(activeSubmission.formMethod)) {
2153 await startNavigation(redirectHistoryAction, redirectLocation, {
2154 submission: _extends({}, activeSubmission, {
2155 formAction: location
2156 }),
2157 // Preserve this flag across redirects
2158 preventScrollReset: pendingPreventScrollReset
2159 });
2160 } else {
2161 let overrideNavigation = getLoadingNavigation(redirectLocation, submission);
2162 await startNavigation(redirectHistoryAction, redirectLocation, {
2163 overrideNavigation,
2164 // Send fetcher submissions through for shouldRevalidate
2165 fetcherSubmission,
2166 // Preserve this flag across redirects
2167 preventScrollReset: pendingPreventScrollReset
2168 });
2169 }
2170 }
2171 async function callDataStrategy(type, request, matchesToLoad, matches) {
2172 try {
2173 let results = await callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, manifest, mapRouteProperties2);
2174 return await Promise.all(results.map((result, i) => {
2175 if (isRedirectHandlerResult(result)) {
2176 let response = result.result;
2177 return {
2178 type: ResultType.redirect,
2179 response: normalizeRelativeRoutingRedirectResponse(response, request, matchesToLoad[i].route.id, matches, basename, future.v7_relativeSplatPath)
2180 };
2181 }
2182 return convertHandlerResultToDataResult(result);
2183 }));
2184 } catch (e) {
2185 return matchesToLoad.map(() => ({
2186 type: ResultType.error,
2187 error: e
2188 }));
2189 }
2190 }
2191 async function callLoadersAndMaybeResolveData(currentMatches, matches, matchesToLoad, fetchersToLoad, request) {
2192 let [loaderResults, ...fetcherResults] = await Promise.all([matchesToLoad.length ? callDataStrategy("loader", request, matchesToLoad, matches) : [], ...fetchersToLoad.map((f) => {
2193 if (f.matches && f.match && f.controller) {
2194 let fetcherRequest = createClientSideRequest(init.history, f.path, f.controller.signal);
2195 return callDataStrategy("loader", fetcherRequest, [f.match], f.matches).then((r) => r[0]);
2196 } else {
2197 return Promise.resolve({
2198 type: ResultType.error,
2199 error: getInternalRouterError(404, {
2200 pathname: f.path
2201 })
2202 });
2203 }
2204 })]);
2205 await Promise.all([resolveDeferredResults(currentMatches, matchesToLoad, loaderResults, loaderResults.map(() => request.signal), false, state.loaderData), resolveDeferredResults(currentMatches, fetchersToLoad.map((f) => f.match), fetcherResults, fetchersToLoad.map((f) => f.controller ? f.controller.signal : null), true)]);
2206 return {
2207 loaderResults,
2208 fetcherResults
2209 };
2210 }
2211 function interruptActiveLoads() {
2212 isRevalidationRequired = true;
2213 cancelledDeferredRoutes.push(...cancelActiveDeferreds());
2214 fetchLoadMatches.forEach((_, key) => {
2215 if (fetchControllers.has(key)) {
2216 cancelledFetcherLoads.add(key);
2217 abortFetcher(key);
2218 }
2219 });
2220 }
2221 function updateFetcherState(key, fetcher, opts) {
2222 if (opts === void 0) {
2223 opts = {};
2224 }
2225 state.fetchers.set(key, fetcher);
2226 updateState({
2227 fetchers: new Map(state.fetchers)
2228 }, {
2229 flushSync: (opts && opts.flushSync) === true
2230 });
2231 }
2232 function setFetcherError(key, routeId, error, opts) {
2233 if (opts === void 0) {
2234 opts = {};
2235 }
2236 let boundaryMatch = findNearestBoundary(state.matches, routeId);
2237 deleteFetcher(key);
2238 updateState({
2239 errors: {
2240 [boundaryMatch.route.id]: error
2241 },
2242 fetchers: new Map(state.fetchers)
2243 }, {
2244 flushSync: (opts && opts.flushSync) === true
2245 });
2246 }
2247 function getFetcher(key) {
2248 if (future.v7_fetcherPersist) {
2249 activeFetchers.set(key, (activeFetchers.get(key) || 0) + 1);
2250 if (deletedFetchers.has(key)) {
2251 deletedFetchers.delete(key);
2252 }
2253 }
2254 return state.fetchers.get(key) || IDLE_FETCHER;
2255 }
2256 function deleteFetcher(key) {
2257 let fetcher = state.fetchers.get(key);
2258 if (fetchControllers.has(key) && !(fetcher && fetcher.state === "loading" && fetchReloadIds.has(key))) {
2259 abortFetcher(key);
2260 }
2261 fetchLoadMatches.delete(key);
2262 fetchReloadIds.delete(key);
2263 fetchRedirectIds.delete(key);
2264 deletedFetchers.delete(key);
2265 cancelledFetcherLoads.delete(key);
2266 state.fetchers.delete(key);
2267 }
2268 function deleteFetcherAndUpdateState(key) {
2269 if (future.v7_fetcherPersist) {
2270 let count = (activeFetchers.get(key) || 0) - 1;
2271 if (count <= 0) {
2272 activeFetchers.delete(key);
2273 deletedFetchers.add(key);
2274 } else {
2275 activeFetchers.set(key, count);
2276 }
2277 } else {
2278 deleteFetcher(key);
2279 }
2280 updateState({
2281 fetchers: new Map(state.fetchers)
2282 });
2283 }
2284 function abortFetcher(key) {
2285 let controller = fetchControllers.get(key);
2286 invariant(controller, "Expected fetch controller: " + key);
2287 controller.abort();
2288 fetchControllers.delete(key);
2289 }
2290 function markFetchersDone(keys) {
2291 for (let key of keys) {
2292 let fetcher = getFetcher(key);
2293 let doneFetcher = getDoneFetcher(fetcher.data);
2294 state.fetchers.set(key, doneFetcher);
2295 }
2296 }
2297 function markFetchRedirectsDone() {
2298 let doneKeys = [];
2299 let updatedFetchers = false;
2300 for (let key of fetchRedirectIds) {
2301 let fetcher = state.fetchers.get(key);
2302 invariant(fetcher, "Expected fetcher: " + key);
2303 if (fetcher.state === "loading") {
2304 fetchRedirectIds.delete(key);
2305 doneKeys.push(key);
2306 updatedFetchers = true;
2307 }
2308 }
2309 markFetchersDone(doneKeys);
2310 return updatedFetchers;
2311 }
2312 function abortStaleFetchLoads(landedId) {
2313 let yeetedKeys = [];
2314 for (let [key, id] of fetchReloadIds) {
2315 if (id < landedId) {
2316 let fetcher = state.fetchers.get(key);
2317 invariant(fetcher, "Expected fetcher: " + key);
2318 if (fetcher.state === "loading") {
2319 abortFetcher(key);
2320 fetchReloadIds.delete(key);
2321 yeetedKeys.push(key);
2322 }
2323 }
2324 }
2325 markFetchersDone(yeetedKeys);
2326 return yeetedKeys.length > 0;
2327 }
2328 function getBlocker(key, fn) {
2329 let blocker = state.blockers.get(key) || IDLE_BLOCKER;
2330 if (blockerFunctions.get(key) !== fn) {
2331 blockerFunctions.set(key, fn);
2332 }
2333 return blocker;
2334 }
2335 function deleteBlocker(key) {
2336 state.blockers.delete(key);
2337 blockerFunctions.delete(key);
2338 }
2339 function updateBlocker(key, newBlocker) {
2340 let blocker = state.blockers.get(key) || IDLE_BLOCKER;
2341 invariant(blocker.state === "unblocked" && newBlocker.state === "blocked" || blocker.state === "blocked" && newBlocker.state === "blocked" || blocker.state === "blocked" && newBlocker.state === "proceeding" || blocker.state === "blocked" && newBlocker.state === "unblocked" || blocker.state === "proceeding" && newBlocker.state === "unblocked", "Invalid blocker state transition: " + blocker.state + " -> " + newBlocker.state);
2342 let blockers = new Map(state.blockers);
2343 blockers.set(key, newBlocker);
2344 updateState({
2345 blockers
2346 });
2347 }
2348 function shouldBlockNavigation(_ref4) {
2349 let {
2350 currentLocation,
2351 nextLocation,
2352 historyAction
2353 } = _ref4;
2354 if (blockerFunctions.size === 0) {
2355 return;
2356 }
2357 if (blockerFunctions.size > 1) {
2358 warning(false, "A router only supports one blocker at a time");
2359 }
2360 let entries = Array.from(blockerFunctions.entries());
2361 let [blockerKey, blockerFunction] = entries[entries.length - 1];
2362 let blocker = state.blockers.get(blockerKey);
2363 if (blocker && blocker.state === "proceeding") {
2364 return;
2365 }
2366 if (blockerFunction({
2367 currentLocation,
2368 nextLocation,
2369 historyAction
2370 })) {
2371 return blockerKey;
2372 }
2373 }
2374 function handleNavigational404(pathname) {
2375 let error = getInternalRouterError(404, {
2376 pathname
2377 });
2378 let routesToUse = inFlightDataRoutes || dataRoutes;
2379 let {
2380 matches,
2381 route
2382 } = getShortCircuitMatches(routesToUse);
2383 cancelActiveDeferreds();
2384 return {
2385 notFoundMatches: matches,
2386 route,
2387 error
2388 };
2389 }
2390 function handleDiscoverRouteError(pathname, discoverResult) {
2391 return {
2392 boundaryId: findNearestBoundary(discoverResult.partialMatches).route.id,
2393 error: getInternalRouterError(400, {
2394 type: "route-discovery",
2395 pathname,
2396 message: discoverResult.error != null && "message" in discoverResult.error ? discoverResult.error : String(discoverResult.error)
2397 })
2398 };
2399 }
2400 function cancelActiveDeferreds(predicate) {
2401 let cancelledRouteIds = [];
2402 activeDeferreds.forEach((dfd, routeId) => {
2403 if (!predicate || predicate(routeId)) {
2404 dfd.cancel();
2405 cancelledRouteIds.push(routeId);
2406 activeDeferreds.delete(routeId);
2407 }
2408 });
2409 return cancelledRouteIds;
2410 }
2411 function enableScrollRestoration(positions, getPosition, getKey) {
2412 savedScrollPositions2 = positions;
2413 getScrollPosition = getPosition;
2414 getScrollRestorationKey = getKey || null;
2415 if (!initialScrollRestored && state.navigation === IDLE_NAVIGATION) {
2416 initialScrollRestored = true;
2417 let y = getSavedScrollPosition(state.location, state.matches);
2418 if (y != null) {
2419 updateState({
2420 restoreScrollPosition: y
2421 });
2422 }
2423 }
2424 return () => {
2425 savedScrollPositions2 = null;
2426 getScrollPosition = null;
2427 getScrollRestorationKey = null;
2428 };
2429 }
2430 function getScrollKey(location, matches) {
2431 if (getScrollRestorationKey) {
2432 let key = getScrollRestorationKey(location, matches.map((m) => convertRouteMatchToUiMatch(m, state.loaderData)));
2433 return key || location.key;
2434 }
2435 return location.key;
2436 }
2437 function saveScrollPosition(location, matches) {
2438 if (savedScrollPositions2 && getScrollPosition) {
2439 let key = getScrollKey(location, matches);
2440 savedScrollPositions2[key] = getScrollPosition();
2441 }
2442 }
2443 function getSavedScrollPosition(location, matches) {
2444 if (savedScrollPositions2) {
2445 let key = getScrollKey(location, matches);
2446 let y = savedScrollPositions2[key];
2447 if (typeof y === "number") {
2448 return y;
2449 }
2450 }
2451 return null;
2452 }
2453 function checkFogOfWar(matches, routesToUse, pathname) {
2454 if (patchRoutesOnMissImpl) {
2455 if (!matches) {
2456 let fogMatches = matchRoutesImpl(routesToUse, pathname, basename, true);
2457 return {
2458 active: true,
2459 matches: fogMatches || []
2460 };
2461 } else {
2462 let leafRoute = matches[matches.length - 1].route;
2463 if (leafRoute.path && (leafRoute.path === "*" || leafRoute.path.endsWith("/*"))) {
2464 let partialMatches = matchRoutesImpl(routesToUse, pathname, basename, true);
2465 return {
2466 active: true,
2467 matches: partialMatches
2468 };
2469 }
2470 }
2471 }
2472 return {
2473 active: false,
2474 matches: null
2475 };
2476 }
2477 async function discoverRoutes(matches, pathname, signal) {
2478 let partialMatches = matches;
2479 let route = partialMatches.length > 0 ? partialMatches[partialMatches.length - 1].route : null;
2480 while (true) {
2481 let isNonHMR = inFlightDataRoutes == null;
2482 let routesToUse = inFlightDataRoutes || dataRoutes;
2483 try {
2484 await loadLazyRouteChildren(patchRoutesOnMissImpl, pathname, partialMatches, routesToUse, manifest, mapRouteProperties2, pendingPatchRoutes, signal);
2485 } catch (e) {
2486 return {
2487 type: "error",
2488 error: e,
2489 partialMatches
2490 };
2491 } finally {
2492 if (isNonHMR) {
2493 dataRoutes = [...dataRoutes];
2494 }
2495 }
2496 if (signal.aborted) {
2497 return {
2498 type: "aborted"
2499 };
2500 }
2501 let newMatches = matchRoutes(routesToUse, pathname, basename);
2502 let matchedSplat = false;
2503 if (newMatches) {
2504 let leafRoute = newMatches[newMatches.length - 1].route;
2505 if (leafRoute.index) {
2506 return {
2507 type: "success",
2508 matches: newMatches
2509 };
2510 }
2511 if (leafRoute.path && leafRoute.path.length > 0) {
2512 if (leafRoute.path === "*") {
2513 matchedSplat = true;
2514 } else {
2515 return {
2516 type: "success",
2517 matches: newMatches
2518 };
2519 }
2520 }
2521 }
2522 let newPartialMatches = matchRoutesImpl(routesToUse, pathname, basename, true);
2523 if (!newPartialMatches || partialMatches.map((m) => m.route.id).join("-") === newPartialMatches.map((m) => m.route.id).join("-")) {
2524 return {
2525 type: "success",
2526 matches: matchedSplat ? newMatches : null
2527 };
2528 }
2529 partialMatches = newPartialMatches;
2530 route = partialMatches[partialMatches.length - 1].route;
2531 if (route.path === "*") {
2532 return {
2533 type: "success",
2534 matches: partialMatches
2535 };
2536 }
2537 }
2538 }
2539 function _internalSetRoutes(newRoutes) {
2540 manifest = {};
2541 inFlightDataRoutes = convertRoutesToDataRoutes(newRoutes, mapRouteProperties2, void 0, manifest);
2542 }
2543 function patchRoutes(routeId, children) {
2544 let isNonHMR = inFlightDataRoutes == null;
2545 let routesToUse = inFlightDataRoutes || dataRoutes;
2546 patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2);
2547 if (isNonHMR) {
2548 dataRoutes = [...dataRoutes];
2549 updateState({});
2550 }
2551 }
2552 router = {
2553 get basename() {
2554 return basename;
2555 },
2556 get future() {
2557 return future;
2558 },
2559 get state() {
2560 return state;
2561 },
2562 get routes() {
2563 return dataRoutes;
2564 },
2565 get window() {
2566 return routerWindow;
2567 },
2568 initialize,
2569 subscribe,
2570 enableScrollRestoration,
2571 navigate,
2572 fetch,
2573 revalidate,
2574 // Passthrough to history-aware createHref used by useHref so we get proper
2575 // hash-aware URLs in DOM paths
2576 createHref: (to) => init.history.createHref(to),
2577 encodeLocation: (to) => init.history.encodeLocation(to),
2578 getFetcher,
2579 deleteFetcher: deleteFetcherAndUpdateState,
2580 dispose,
2581 getBlocker,
2582 deleteBlocker,
2583 patchRoutes,
2584 _internalFetchControllers: fetchControllers,
2585 _internalActiveDeferreds: activeDeferreds,
2586 // TODO: Remove setRoutes, it's temporary to avoid dealing with
2587 // updating the tree while validating the update algorithm.
2588 _internalSetRoutes
2589 };
2590 return router;
2591}
2592var UNSAFE_DEFERRED_SYMBOL = Symbol("deferred");
2593function isSubmissionNavigation(opts) {
2594 return opts != null && ("formData" in opts && opts.formData != null || "body" in opts && opts.body !== void 0);
2595}
2596function normalizeTo(location, matches, basename, prependBasename, to, v7_relativeSplatPath, fromRouteId, relative) {
2597 let contextualMatches;
2598 let activeRouteMatch;
2599 if (fromRouteId) {
2600 contextualMatches = [];
2601 for (let match of matches) {
2602 contextualMatches.push(match);
2603 if (match.route.id === fromRouteId) {
2604 activeRouteMatch = match;
2605 break;
2606 }
2607 }
2608 } else {
2609 contextualMatches = matches;
2610 activeRouteMatch = matches[matches.length - 1];
2611 }
2612 let path = resolveTo(to ? to : ".", getResolveToMatches(contextualMatches, v7_relativeSplatPath), stripBasename(location.pathname, basename) || location.pathname, relative === "path");
2613 if (to == null) {
2614 path.search = location.search;
2615 path.hash = location.hash;
2616 }
2617 if ((to == null || to === "" || to === ".") && activeRouteMatch && activeRouteMatch.route.index && !hasNakedIndexQuery(path.search)) {
2618 path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
2619 }
2620 if (prependBasename && basename !== "/") {
2621 path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
2622 }
2623 return createPath(path);
2624}
2625function normalizeNavigateOptions(normalizeFormMethod, isFetcher, path, opts) {
2626 if (!opts || !isSubmissionNavigation(opts)) {
2627 return {
2628 path
2629 };
2630 }
2631 if (opts.formMethod && !isValidMethod(opts.formMethod)) {
2632 return {
2633 path,
2634 error: getInternalRouterError(405, {
2635 method: opts.formMethod
2636 })
2637 };
2638 }
2639 let getInvalidBodyError = () => ({
2640 path,
2641 error: getInternalRouterError(400, {
2642 type: "invalid-body"
2643 })
2644 });
2645 let rawFormMethod = opts.formMethod || "get";
2646 let formMethod = normalizeFormMethod ? rawFormMethod.toUpperCase() : rawFormMethod.toLowerCase();
2647 let formAction = stripHashFromPath(path);
2648 if (opts.body !== void 0) {
2649 if (opts.formEncType === "text/plain") {
2650 if (!isMutationMethod(formMethod)) {
2651 return getInvalidBodyError();
2652 }
2653 let text = typeof opts.body === "string" ? opts.body : opts.body instanceof FormData || opts.body instanceof URLSearchParams ? (
2654 // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#plain-text-form-data
2655 Array.from(opts.body.entries()).reduce((acc, _ref5) => {
2656 let [name, value] = _ref5;
2657 return "" + acc + name + "=" + value + "\n";
2658 }, "")
2659 ) : String(opts.body);
2660 return {
2661 path,
2662 submission: {
2663 formMethod,
2664 formAction,
2665 formEncType: opts.formEncType,
2666 formData: void 0,
2667 json: void 0,
2668 text
2669 }
2670 };
2671 } else if (opts.formEncType === "application/json") {
2672 if (!isMutationMethod(formMethod)) {
2673 return getInvalidBodyError();
2674 }
2675 try {
2676 let json3 = typeof opts.body === "string" ? JSON.parse(opts.body) : opts.body;
2677 return {
2678 path,
2679 submission: {
2680 formMethod,
2681 formAction,
2682 formEncType: opts.formEncType,
2683 formData: void 0,
2684 json: json3,
2685 text: void 0
2686 }
2687 };
2688 } catch (e) {
2689 return getInvalidBodyError();
2690 }
2691 }
2692 }
2693 invariant(typeof FormData === "function", "FormData is not available in this environment");
2694 let searchParams;
2695 let formData;
2696 if (opts.formData) {
2697 searchParams = convertFormDataToSearchParams(opts.formData);
2698 formData = opts.formData;
2699 } else if (opts.body instanceof FormData) {
2700 searchParams = convertFormDataToSearchParams(opts.body);
2701 formData = opts.body;
2702 } else if (opts.body instanceof URLSearchParams) {
2703 searchParams = opts.body;
2704 formData = convertSearchParamsToFormData(searchParams);
2705 } else if (opts.body == null) {
2706 searchParams = new URLSearchParams();
2707 formData = new FormData();
2708 } else {
2709 try {
2710 searchParams = new URLSearchParams(opts.body);
2711 formData = convertSearchParamsToFormData(searchParams);
2712 } catch (e) {
2713 return getInvalidBodyError();
2714 }
2715 }
2716 let submission = {
2717 formMethod,
2718 formAction,
2719 formEncType: opts && opts.formEncType || "application/x-www-form-urlencoded",
2720 formData,
2721 json: void 0,
2722 text: void 0
2723 };
2724 if (isMutationMethod(submission.formMethod)) {
2725 return {
2726 path,
2727 submission
2728 };
2729 }
2730 let parsedPath = parsePath(path);
2731 if (isFetcher && parsedPath.search && hasNakedIndexQuery(parsedPath.search)) {
2732 searchParams.append("index", "");
2733 }
2734 parsedPath.search = "?" + searchParams;
2735 return {
2736 path: createPath(parsedPath),
2737 submission
2738 };
2739}
2740function getLoaderMatchesUntilBoundary(matches, boundaryId) {
2741 let boundaryMatches = matches;
2742 if (boundaryId) {
2743 let index = matches.findIndex((m) => m.route.id === boundaryId);
2744 if (index >= 0) {
2745 boundaryMatches = matches.slice(0, index);
2746 }
2747 }
2748 return boundaryMatches;
2749}
2750function getMatchesToLoad(history, state, matches, submission, location, isInitialLoad, skipActionErrorRevalidation, isRevalidationRequired, cancelledDeferredRoutes, cancelledFetcherLoads, deletedFetchers, fetchLoadMatches, fetchRedirectIds, routesToUse, basename, pendingActionResult) {
2751 let actionResult = pendingActionResult ? isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : pendingActionResult[1].data : void 0;
2752 let currentUrl = history.createURL(state.location);
2753 let nextUrl = history.createURL(location);
2754 let boundaryId = pendingActionResult && isErrorResult(pendingActionResult[1]) ? pendingActionResult[0] : void 0;
2755 let boundaryMatches = boundaryId ? getLoaderMatchesUntilBoundary(matches, boundaryId) : matches;
2756 let actionStatus = pendingActionResult ? pendingActionResult[1].statusCode : void 0;
2757 let shouldSkipRevalidation = skipActionErrorRevalidation && actionStatus && actionStatus >= 400;
2758 let navigationMatches = boundaryMatches.filter((match, index) => {
2759 let {
2760 route
2761 } = match;
2762 if (route.lazy) {
2763 return true;
2764 }
2765 if (route.loader == null) {
2766 return false;
2767 }
2768 if (isInitialLoad) {
2769 if (typeof route.loader !== "function" || route.loader.hydrate) {
2770 return true;
2771 }
2772 return state.loaderData[route.id] === void 0 && // Don't re-run if the loader ran and threw an error
2773 (!state.errors || state.errors[route.id] === void 0);
2774 }
2775 if (isNewLoader(state.loaderData, state.matches[index], match) || cancelledDeferredRoutes.some((id) => id === match.route.id)) {
2776 return true;
2777 }
2778 let currentRouteMatch = state.matches[index];
2779 let nextRouteMatch = match;
2780 return shouldRevalidateLoader(match, _extends({
2781 currentUrl,
2782 currentParams: currentRouteMatch.params,
2783 nextUrl,
2784 nextParams: nextRouteMatch.params
2785 }, submission, {
2786 actionResult,
2787 actionStatus,
2788 defaultShouldRevalidate: shouldSkipRevalidation ? false : (
2789 // Forced revalidation due to submission, useRevalidator, or X-Remix-Revalidate
2790 isRevalidationRequired || currentUrl.pathname + currentUrl.search === nextUrl.pathname + nextUrl.search || // Search params affect all loaders
2791 currentUrl.search !== nextUrl.search || isNewRouteInstance(currentRouteMatch, nextRouteMatch)
2792 )
2793 }));
2794 });
2795 let revalidatingFetchers = [];
2796 fetchLoadMatches.forEach((f, key) => {
2797 if (isInitialLoad || !matches.some((m) => m.route.id === f.routeId) || deletedFetchers.has(key)) {
2798 return;
2799 }
2800 let fetcherMatches = matchRoutes(routesToUse, f.path, basename);
2801 if (!fetcherMatches) {
2802 revalidatingFetchers.push({
2803 key,
2804 routeId: f.routeId,
2805 path: f.path,
2806 matches: null,
2807 match: null,
2808 controller: null
2809 });
2810 return;
2811 }
2812 let fetcher = state.fetchers.get(key);
2813 let fetcherMatch = getTargetMatch(fetcherMatches, f.path);
2814 let shouldRevalidate = false;
2815 if (fetchRedirectIds.has(key)) {
2816 shouldRevalidate = false;
2817 } else if (cancelledFetcherLoads.has(key)) {
2818 cancelledFetcherLoads.delete(key);
2819 shouldRevalidate = true;
2820 } else if (fetcher && fetcher.state !== "idle" && fetcher.data === void 0) {
2821 shouldRevalidate = isRevalidationRequired;
2822 } else {
2823 shouldRevalidate = shouldRevalidateLoader(fetcherMatch, _extends({
2824 currentUrl,
2825 currentParams: state.matches[state.matches.length - 1].params,
2826 nextUrl,
2827 nextParams: matches[matches.length - 1].params
2828 }, submission, {
2829 actionResult,
2830 actionStatus,
2831 defaultShouldRevalidate: shouldSkipRevalidation ? false : isRevalidationRequired
2832 }));
2833 }
2834 if (shouldRevalidate) {
2835 revalidatingFetchers.push({
2836 key,
2837 routeId: f.routeId,
2838 path: f.path,
2839 matches: fetcherMatches,
2840 match: fetcherMatch,
2841 controller: new AbortController()
2842 });
2843 }
2844 });
2845 return [navigationMatches, revalidatingFetchers];
2846}
2847function isNewLoader(currentLoaderData, currentMatch, match) {
2848 let isNew = (
2849 // [a] -> [a, b]
2850 !currentMatch || // [a, b] -> [a, c]
2851 match.route.id !== currentMatch.route.id
2852 );
2853 let isMissingData = currentLoaderData[match.route.id] === void 0;
2854 return isNew || isMissingData;
2855}
2856function isNewRouteInstance(currentMatch, match) {
2857 let currentPath = currentMatch.route.path;
2858 return (
2859 // param change for this match, /users/123 -> /users/456
2860 currentMatch.pathname !== match.pathname || // splat param changed, which is not present in match.path
2861 // e.g. /files/images/avatar.jpg -> files/finances.xls
2862 currentPath != null && currentPath.endsWith("*") && currentMatch.params["*"] !== match.params["*"]
2863 );
2864}
2865function shouldRevalidateLoader(loaderMatch, arg) {
2866 if (loaderMatch.route.shouldRevalidate) {
2867 let routeChoice = loaderMatch.route.shouldRevalidate(arg);
2868 if (typeof routeChoice === "boolean") {
2869 return routeChoice;
2870 }
2871 }
2872 return arg.defaultShouldRevalidate;
2873}
2874async function loadLazyRouteChildren(patchRoutesOnMissImpl, path, matches, routes, manifest, mapRouteProperties2, pendingRouteChildren, signal) {
2875 let key = [path, ...matches.map((m) => m.route.id)].join("-");
2876 try {
2877 let pending = pendingRouteChildren.get(key);
2878 if (!pending) {
2879 pending = patchRoutesOnMissImpl({
2880 path,
2881 matches,
2882 patch: (routeId, children) => {
2883 if (!signal.aborted) {
2884 patchRoutesImpl(routeId, children, routes, manifest, mapRouteProperties2);
2885 }
2886 }
2887 });
2888 pendingRouteChildren.set(key, pending);
2889 }
2890 if (pending && isPromise(pending)) {
2891 await pending;
2892 }
2893 } finally {
2894 pendingRouteChildren.delete(key);
2895 }
2896}
2897function patchRoutesImpl(routeId, children, routesToUse, manifest, mapRouteProperties2) {
2898 if (routeId) {
2899 var _route$children;
2900 let route = manifest[routeId];
2901 invariant(route, "No route found to patch children into: routeId = " + routeId);
2902 let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties2, [routeId, "patch", String(((_route$children = route.children) == null ? void 0 : _route$children.length) || "0")], manifest);
2903 if (route.children) {
2904 route.children.push(...dataChildren);
2905 } else {
2906 route.children = dataChildren;
2907 }
2908 } else {
2909 let dataChildren = convertRoutesToDataRoutes(children, mapRouteProperties2, ["patch", String(routesToUse.length || "0")], manifest);
2910 routesToUse.push(...dataChildren);
2911 }
2912}
2913async function loadLazyRouteModule(route, mapRouteProperties2, manifest) {
2914 if (!route.lazy) {
2915 return;
2916 }
2917 let lazyRoute = await route.lazy();
2918 if (!route.lazy) {
2919 return;
2920 }
2921 let routeToUpdate = manifest[route.id];
2922 invariant(routeToUpdate, "No route found in manifest");
2923 let routeUpdates = {};
2924 for (let lazyRouteProperty in lazyRoute) {
2925 let staticRouteValue = routeToUpdate[lazyRouteProperty];
2926 let isPropertyStaticallyDefined = staticRouteValue !== void 0 && // This property isn't static since it should always be updated based
2927 // on the route updates
2928 lazyRouteProperty !== "hasErrorBoundary";
2929 warning(!isPropertyStaticallyDefined, 'Route "' + routeToUpdate.id + '" has a static property "' + lazyRouteProperty + '" defined but its lazy function is also returning a value for this property. ' + ('The lazy route property "' + lazyRouteProperty + '" will be ignored.'));
2930 if (!isPropertyStaticallyDefined && !immutableRouteKeys.has(lazyRouteProperty)) {
2931 routeUpdates[lazyRouteProperty] = lazyRoute[lazyRouteProperty];
2932 }
2933 }
2934 Object.assign(routeToUpdate, routeUpdates);
2935 Object.assign(routeToUpdate, _extends({}, mapRouteProperties2(routeToUpdate), {
2936 lazy: void 0
2937 }));
2938}
2939function defaultDataStrategy(opts) {
2940 return Promise.all(opts.matches.map((m) => m.resolve()));
2941}
2942async function callDataStrategyImpl(dataStrategyImpl, type, request, matchesToLoad, matches, manifest, mapRouteProperties2, requestContext) {
2943 let routeIdsToLoad = matchesToLoad.reduce((acc, m) => acc.add(m.route.id), /* @__PURE__ */ new Set());
2944 let loadedMatches = /* @__PURE__ */ new Set();
2945 let results = await dataStrategyImpl({
2946 matches: matches.map((match) => {
2947 let shouldLoad = routeIdsToLoad.has(match.route.id);
2948 let resolve = (handlerOverride) => {
2949 loadedMatches.add(match.route.id);
2950 return shouldLoad ? callLoaderOrAction(type, request, match, manifest, mapRouteProperties2, handlerOverride, requestContext) : Promise.resolve({
2951 type: ResultType.data,
2952 result: void 0
2953 });
2954 };
2955 return _extends({}, match, {
2956 shouldLoad,
2957 resolve
2958 });
2959 }),
2960 request,
2961 params: matches[0].params,
2962 context: requestContext
2963 });
2964 matches.forEach((m) => invariant(loadedMatches.has(m.route.id), '`match.resolve()` was not called for route id "' + m.route.id + '". You must call `match.resolve()` on every match passed to `dataStrategy` to ensure all routes are properly loaded.'));
2965 return results.filter((_, i) => routeIdsToLoad.has(matches[i].route.id));
2966}
2967async function callLoaderOrAction(type, request, match, manifest, mapRouteProperties2, handlerOverride, staticContext) {
2968 let result;
2969 let onReject;
2970 let runHandler = (handler) => {
2971 let reject;
2972 let abortPromise = new Promise((_, r) => reject = r);
2973 onReject = () => reject();
2974 request.signal.addEventListener("abort", onReject);
2975 let actualHandler = (ctx) => {
2976 if (typeof handler !== "function") {
2977 return Promise.reject(new Error("You cannot call the handler for a route which defines a boolean " + ('"' + type + '" [routeId: ' + match.route.id + "]")));
2978 }
2979 return handler({
2980 request,
2981 params: match.params,
2982 context: staticContext
2983 }, ...ctx !== void 0 ? [ctx] : []);
2984 };
2985 let handlerPromise;
2986 if (handlerOverride) {
2987 handlerPromise = handlerOverride((ctx) => actualHandler(ctx));
2988 } else {
2989 handlerPromise = (async () => {
2990 try {
2991 let val = await actualHandler();
2992 return {
2993 type: "data",
2994 result: val
2995 };
2996 } catch (e) {
2997 return {
2998 type: "error",
2999 result: e
3000 };
3001 }
3002 })();
3003 }
3004 return Promise.race([handlerPromise, abortPromise]);
3005 };
3006 try {
3007 let handler = match.route[type];
3008 if (match.route.lazy) {
3009 if (handler) {
3010 let handlerError;
3011 let [value] = await Promise.all([
3012 // If the handler throws, don't let it immediately bubble out,
3013 // since we need to let the lazy() execution finish so we know if this
3014 // route has a boundary that can handle the error
3015 runHandler(handler).catch((e) => {
3016 handlerError = e;
3017 }),
3018 loadLazyRouteModule(match.route, mapRouteProperties2, manifest)
3019 ]);
3020 if (handlerError !== void 0) {
3021 throw handlerError;
3022 }
3023 result = value;
3024 } else {
3025 await loadLazyRouteModule(match.route, mapRouteProperties2, manifest);
3026 handler = match.route[type];
3027 if (handler) {
3028 result = await runHandler(handler);
3029 } else if (type === "action") {
3030 let url = new URL(request.url);
3031 let pathname = url.pathname + url.search;
3032 throw getInternalRouterError(405, {
3033 method: request.method,
3034 pathname,
3035 routeId: match.route.id
3036 });
3037 } else {
3038 return {
3039 type: ResultType.data,
3040 result: void 0
3041 };
3042 }
3043 }
3044 } else if (!handler) {
3045 let url = new URL(request.url);
3046 let pathname = url.pathname + url.search;
3047 throw getInternalRouterError(404, {
3048 pathname
3049 });
3050 } else {
3051 result = await runHandler(handler);
3052 }
3053 invariant(result.result !== void 0, "You defined " + (type === "action" ? "an action" : "a loader") + " for route " + ('"' + match.route.id + "\" but didn't return anything from your `" + type + "` ") + "function. Please return a value or `null`.");
3054 } catch (e) {
3055 return {
3056 type: ResultType.error,
3057 result: e
3058 };
3059 } finally {
3060 if (onReject) {
3061 request.signal.removeEventListener("abort", onReject);
3062 }
3063 }
3064 return result;
3065}
3066async function convertHandlerResultToDataResult(handlerResult) {
3067 let {
3068 result,
3069 type
3070 } = handlerResult;
3071 if (isResponse(result)) {
3072 let data;
3073 try {
3074 let contentType = result.headers.get("Content-Type");
3075 if (contentType && /\bapplication\/json\b/.test(contentType)) {
3076 if (result.body == null) {
3077 data = null;
3078 } else {
3079 data = await result.json();
3080 }
3081 } else {
3082 data = await result.text();
3083 }
3084 } catch (e) {
3085 return {
3086 type: ResultType.error,
3087 error: e
3088 };
3089 }
3090 if (type === ResultType.error) {
3091 return {
3092 type: ResultType.error,
3093 error: new ErrorResponseImpl(result.status, result.statusText, data),
3094 statusCode: result.status,
3095 headers: result.headers
3096 };
3097 }
3098 return {
3099 type: ResultType.data,
3100 data,
3101 statusCode: result.status,
3102 headers: result.headers
3103 };
3104 }
3105 if (type === ResultType.error) {
3106 if (isDataWithResponseInit(result)) {
3107 var _result$init2;
3108 if (result.data instanceof Error) {
3109 var _result$init;
3110 return {
3111 type: ResultType.error,
3112 error: result.data,
3113 statusCode: (_result$init = result.init) == null ? void 0 : _result$init.status
3114 };
3115 }
3116 result = new ErrorResponseImpl(((_result$init2 = result.init) == null ? void 0 : _result$init2.status) || 500, void 0, result.data);
3117 }
3118 return {
3119 type: ResultType.error,
3120 error: result,
3121 statusCode: isRouteErrorResponse(result) ? result.status : void 0
3122 };
3123 }
3124 if (isDeferredData(result)) {
3125 var _result$init3, _result$init4;
3126 return {
3127 type: ResultType.deferred,
3128 deferredData: result,
3129 statusCode: (_result$init3 = result.init) == null ? void 0 : _result$init3.status,
3130 headers: ((_result$init4 = result.init) == null ? void 0 : _result$init4.headers) && new Headers(result.init.headers)
3131 };
3132 }
3133 if (isDataWithResponseInit(result)) {
3134 var _result$init5, _result$init6;
3135 return {
3136 type: ResultType.data,
3137 data: result.data,
3138 statusCode: (_result$init5 = result.init) == null ? void 0 : _result$init5.status,
3139 headers: (_result$init6 = result.init) != null && _result$init6.headers ? new Headers(result.init.headers) : void 0
3140 };
3141 }
3142 return {
3143 type: ResultType.data,
3144 data: result
3145 };
3146}
3147function normalizeRelativeRoutingRedirectResponse(response, request, routeId, matches, basename, v7_relativeSplatPath) {
3148 let location = response.headers.get("Location");
3149 invariant(location, "Redirects returned/thrown from loaders/actions must have a Location header");
3150 if (!ABSOLUTE_URL_REGEX.test(location)) {
3151 let trimmedMatches = matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1);
3152 location = normalizeTo(new URL(request.url), trimmedMatches, basename, true, location, v7_relativeSplatPath);
3153 response.headers.set("Location", location);
3154 }
3155 return response;
3156}
3157function normalizeRedirectLocation(location, currentUrl, basename) {
3158 if (ABSOLUTE_URL_REGEX.test(location)) {
3159 let normalizedLocation = location;
3160 let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
3161 let isSameBasename = stripBasename(url.pathname, basename) != null;
3162 if (url.origin === currentUrl.origin && isSameBasename) {
3163 return url.pathname + url.search + url.hash;
3164 }
3165 }
3166 return location;
3167}
3168function createClientSideRequest(history, location, signal, submission) {
3169 let url = history.createURL(stripHashFromPath(location)).toString();
3170 let init = {
3171 signal
3172 };
3173 if (submission && isMutationMethod(submission.formMethod)) {
3174 let {
3175 formMethod,
3176 formEncType
3177 } = submission;
3178 init.method = formMethod.toUpperCase();
3179 if (formEncType === "application/json") {
3180 init.headers = new Headers({
3181 "Content-Type": formEncType
3182 });
3183 init.body = JSON.stringify(submission.json);
3184 } else if (formEncType === "text/plain") {
3185 init.body = submission.text;
3186 } else if (formEncType === "application/x-www-form-urlencoded" && submission.formData) {
3187 init.body = convertFormDataToSearchParams(submission.formData);
3188 } else {
3189 init.body = submission.formData;
3190 }
3191 }
3192 return new Request(url, init);
3193}
3194function convertFormDataToSearchParams(formData) {
3195 let searchParams = new URLSearchParams();
3196 for (let [key, value] of formData.entries()) {
3197 searchParams.append(key, typeof value === "string" ? value : value.name);
3198 }
3199 return searchParams;
3200}
3201function convertSearchParamsToFormData(searchParams) {
3202 let formData = new FormData();
3203 for (let [key, value] of searchParams.entries()) {
3204 formData.append(key, value);
3205 }
3206 return formData;
3207}
3208function processRouteLoaderData(matches, matchesToLoad, results, pendingActionResult, activeDeferreds, skipLoaderErrorBubbling) {
3209 let loaderData = {};
3210 let errors = null;
3211 let statusCode;
3212 let foundError = false;
3213 let loaderHeaders = {};
3214 let pendingError = pendingActionResult && isErrorResult(pendingActionResult[1]) ? pendingActionResult[1].error : void 0;
3215 results.forEach((result, index) => {
3216 let id = matchesToLoad[index].route.id;
3217 invariant(!isRedirectResult(result), "Cannot handle redirect results in processLoaderData");
3218 if (isErrorResult(result)) {
3219 let error = result.error;
3220 if (pendingError !== void 0) {
3221 error = pendingError;
3222 pendingError = void 0;
3223 }
3224 errors = errors || {};
3225 if (skipLoaderErrorBubbling) {
3226 errors[id] = error;
3227 } else {
3228 let boundaryMatch = findNearestBoundary(matches, id);
3229 if (errors[boundaryMatch.route.id] == null) {
3230 errors[boundaryMatch.route.id] = error;
3231 }
3232 }
3233 loaderData[id] = void 0;
3234 if (!foundError) {
3235 foundError = true;
3236 statusCode = isRouteErrorResponse(result.error) ? result.error.status : 500;
3237 }
3238 if (result.headers) {
3239 loaderHeaders[id] = result.headers;
3240 }
3241 } else {
3242 if (isDeferredResult(result)) {
3243 activeDeferreds.set(id, result.deferredData);
3244 loaderData[id] = result.deferredData.data;
3245 if (result.statusCode != null && result.statusCode !== 200 && !foundError) {
3246 statusCode = result.statusCode;
3247 }
3248 if (result.headers) {
3249 loaderHeaders[id] = result.headers;
3250 }
3251 } else {
3252 loaderData[id] = result.data;
3253 if (result.statusCode && result.statusCode !== 200 && !foundError) {
3254 statusCode = result.statusCode;
3255 }
3256 if (result.headers) {
3257 loaderHeaders[id] = result.headers;
3258 }
3259 }
3260 }
3261 });
3262 if (pendingError !== void 0 && pendingActionResult) {
3263 errors = {
3264 [pendingActionResult[0]]: pendingError
3265 };
3266 loaderData[pendingActionResult[0]] = void 0;
3267 }
3268 return {
3269 loaderData,
3270 errors,
3271 statusCode: statusCode || 200,
3272 loaderHeaders
3273 };
3274}
3275function processLoaderData(state, matches, matchesToLoad, results, pendingActionResult, revalidatingFetchers, fetcherResults, activeDeferreds) {
3276 let {
3277 loaderData,
3278 errors
3279 } = processRouteLoaderData(
3280 matches,
3281 matchesToLoad,
3282 results,
3283 pendingActionResult,
3284 activeDeferreds,
3285 false
3286 // This method is only called client side so we always want to bubble
3287 );
3288 for (let index = 0; index < revalidatingFetchers.length; index++) {
3289 let {
3290 key,
3291 match,
3292 controller
3293 } = revalidatingFetchers[index];
3294 invariant(fetcherResults !== void 0 && fetcherResults[index] !== void 0, "Did not find corresponding fetcher result");
3295 let result = fetcherResults[index];
3296 if (controller && controller.signal.aborted) {
3297 continue;
3298 } else if (isErrorResult(result)) {
3299 let boundaryMatch = findNearestBoundary(state.matches, match == null ? void 0 : match.route.id);
3300 if (!(errors && errors[boundaryMatch.route.id])) {
3301 errors = _extends({}, errors, {
3302 [boundaryMatch.route.id]: result.error
3303 });
3304 }
3305 state.fetchers.delete(key);
3306 } else if (isRedirectResult(result)) {
3307 invariant(false, "Unhandled fetcher revalidation redirect");
3308 } else if (isDeferredResult(result)) {
3309 invariant(false, "Unhandled fetcher deferred data");
3310 } else {
3311 let doneFetcher = getDoneFetcher(result.data);
3312 state.fetchers.set(key, doneFetcher);
3313 }
3314 }
3315 return {
3316 loaderData,
3317 errors
3318 };
3319}
3320function mergeLoaderData(loaderData, newLoaderData, matches, errors) {
3321 let mergedLoaderData = _extends({}, newLoaderData);
3322 for (let match of matches) {
3323 let id = match.route.id;
3324 if (newLoaderData.hasOwnProperty(id)) {
3325 if (newLoaderData[id] !== void 0) {
3326 mergedLoaderData[id] = newLoaderData[id];
3327 }
3328 } else if (loaderData[id] !== void 0 && match.route.loader) {
3329 mergedLoaderData[id] = loaderData[id];
3330 }
3331 if (errors && errors.hasOwnProperty(id)) {
3332 break;
3333 }
3334 }
3335 return mergedLoaderData;
3336}
3337function getActionDataForCommit(pendingActionResult) {
3338 if (!pendingActionResult) {
3339 return {};
3340 }
3341 return isErrorResult(pendingActionResult[1]) ? {
3342 // Clear out prior actionData on errors
3343 actionData: {}
3344 } : {
3345 actionData: {
3346 [pendingActionResult[0]]: pendingActionResult[1].data
3347 }
3348 };
3349}
3350function findNearestBoundary(matches, routeId) {
3351 let eligibleMatches = routeId ? matches.slice(0, matches.findIndex((m) => m.route.id === routeId) + 1) : [...matches];
3352 return eligibleMatches.reverse().find((m) => m.route.hasErrorBoundary === true) || matches[0];
3353}
3354function getShortCircuitMatches(routes) {
3355 let route = routes.length === 1 ? routes[0] : routes.find((r) => r.index || !r.path || r.path === "/") || {
3356 id: "__shim-error-route__"
3357 };
3358 return {
3359 matches: [{
3360 params: {},
3361 pathname: "",
3362 pathnameBase: "",
3363 route
3364 }],
3365 route
3366 };
3367}
3368function getInternalRouterError(status, _temp5) {
3369 let {
3370 pathname,
3371 routeId,
3372 method,
3373 type,
3374 message
3375 } = _temp5 === void 0 ? {} : _temp5;
3376 let statusText = "Unknown Server Error";
3377 let errorMessage = "Unknown @remix-run/router error";
3378 if (status === 400) {
3379 statusText = "Bad Request";
3380 if (type === "route-discovery") {
3381 errorMessage = 'Unable to match URL "' + pathname + '" - the `unstable_patchRoutesOnMiss()` ' + ("function threw the following error:\n" + message);
3382 } else if (method && pathname && routeId) {
3383 errorMessage = "You made a " + method + ' request to "' + pathname + '" but ' + ('did not provide a `loader` for route "' + routeId + '", ') + "so there is no way to handle the request.";
3384 } else if (type === "defer-action") {
3385 errorMessage = "defer() is not supported in actions";
3386 } else if (type === "invalid-body") {
3387 errorMessage = "Unable to encode submission body";
3388 }
3389 } else if (status === 403) {
3390 statusText = "Forbidden";
3391 errorMessage = 'Route "' + routeId + '" does not match URL "' + pathname + '"';
3392 } else if (status === 404) {
3393 statusText = "Not Found";
3394 errorMessage = 'No route matches URL "' + pathname + '"';
3395 } else if (status === 405) {
3396 statusText = "Method Not Allowed";
3397 if (method && pathname && routeId) {
3398 errorMessage = "You made a " + method.toUpperCase() + ' request to "' + pathname + '" but ' + ('did not provide an `action` for route "' + routeId + '", ') + "so there is no way to handle the request.";
3399 } else if (method) {
3400 errorMessage = 'Invalid request method "' + method.toUpperCase() + '"';
3401 }
3402 }
3403 return new ErrorResponseImpl(status || 500, statusText, new Error(errorMessage), true);
3404}
3405function findRedirect(results) {
3406 for (let i = results.length - 1; i >= 0; i--) {
3407 let result = results[i];
3408 if (isRedirectResult(result)) {
3409 return {
3410 result,
3411 idx: i
3412 };
3413 }
3414 }
3415}
3416function stripHashFromPath(path) {
3417 let parsedPath = typeof path === "string" ? parsePath(path) : path;
3418 return createPath(_extends({}, parsedPath, {
3419 hash: ""
3420 }));
3421}
3422function isHashChangeOnly(a, b) {
3423 if (a.pathname !== b.pathname || a.search !== b.search) {
3424 return false;
3425 }
3426 if (a.hash === "") {
3427 return b.hash !== "";
3428 } else if (a.hash === b.hash) {
3429 return true;
3430 } else if (b.hash !== "") {
3431 return true;
3432 }
3433 return false;
3434}
3435function isPromise(val) {
3436 return typeof val === "object" && val != null && "then" in val;
3437}
3438function isRedirectHandlerResult(result) {
3439 return isResponse(result.result) && redirectStatusCodes.has(result.result.status);
3440}
3441function isDeferredResult(result) {
3442 return result.type === ResultType.deferred;
3443}
3444function isErrorResult(result) {
3445 return result.type === ResultType.error;
3446}
3447function isRedirectResult(result) {
3448 return (result && result.type) === ResultType.redirect;
3449}
3450function isDataWithResponseInit(value) {
3451 return typeof value === "object" && value != null && "type" in value && "data" in value && "init" in value && value.type === "DataWithResponseInit";
3452}
3453function isDeferredData(value) {
3454 let deferred = value;
3455 return deferred && typeof deferred === "object" && typeof deferred.data === "object" && typeof deferred.subscribe === "function" && typeof deferred.cancel === "function" && typeof deferred.resolveData === "function";
3456}
3457function isResponse(value) {
3458 return value != null && typeof value.status === "number" && typeof value.statusText === "string" && typeof value.headers === "object" && typeof value.body !== "undefined";
3459}
3460function isValidMethod(method) {
3461 return validRequestMethods.has(method.toLowerCase());
3462}
3463function isMutationMethod(method) {
3464 return validMutationMethods.has(method.toLowerCase());
3465}
3466async function resolveDeferredResults(currentMatches, matchesToLoad, results, signals, isFetcher, currentLoaderData) {
3467 for (let index = 0; index < results.length; index++) {
3468 let result = results[index];
3469 let match = matchesToLoad[index];
3470 if (!match) {
3471 continue;
3472 }
3473 let currentMatch = currentMatches.find((m) => m.route.id === match.route.id);
3474 let isRevalidatingLoader = currentMatch != null && !isNewRouteInstance(currentMatch, match) && (currentLoaderData && currentLoaderData[match.route.id]) !== void 0;
3475 if (isDeferredResult(result) && (isFetcher || isRevalidatingLoader)) {
3476 let signal = signals[index];
3477 invariant(signal, "Expected an AbortSignal for revalidating fetcher deferred result");
3478 await resolveDeferredData(result, signal, isFetcher).then((result2) => {
3479 if (result2) {
3480 results[index] = result2 || results[index];
3481 }
3482 });
3483 }
3484 }
3485}
3486async function resolveDeferredData(result, signal, unwrap) {
3487 if (unwrap === void 0) {
3488 unwrap = false;
3489 }
3490 let aborted = await result.deferredData.resolveData(signal);
3491 if (aborted) {
3492 return;
3493 }
3494 if (unwrap) {
3495 try {
3496 return {
3497 type: ResultType.data,
3498 data: result.deferredData.unwrappedData
3499 };
3500 } catch (e) {
3501 return {
3502 type: ResultType.error,
3503 error: e
3504 };
3505 }
3506 }
3507 return {
3508 type: ResultType.data,
3509 data: result.deferredData.data
3510 };
3511}
3512function hasNakedIndexQuery(search) {
3513 return new URLSearchParams(search).getAll("index").some((v) => v === "");
3514}
3515function getTargetMatch(matches, location) {
3516 let search = typeof location === "string" ? parsePath(location).search : location.search;
3517 if (matches[matches.length - 1].route.index && hasNakedIndexQuery(search || "")) {
3518 return matches[matches.length - 1];
3519 }
3520 let pathMatches = getPathContributingMatches(matches);
3521 return pathMatches[pathMatches.length - 1];
3522}
3523function getSubmissionFromNavigation(navigation) {
3524 let {
3525 formMethod,
3526 formAction,
3527 formEncType,
3528 text,
3529 formData,
3530 json: json3
3531 } = navigation;
3532 if (!formMethod || !formAction || !formEncType) {
3533 return;
3534 }
3535 if (text != null) {
3536 return {
3537 formMethod,
3538 formAction,
3539 formEncType,
3540 formData: void 0,
3541 json: void 0,
3542 text
3543 };
3544 } else if (formData != null) {
3545 return {
3546 formMethod,
3547 formAction,
3548 formEncType,
3549 formData,
3550 json: void 0,
3551 text: void 0
3552 };
3553 } else if (json3 !== void 0) {
3554 return {
3555 formMethod,
3556 formAction,
3557 formEncType,
3558 formData: void 0,
3559 json: json3,
3560 text: void 0
3561 };
3562 }
3563}
3564function getLoadingNavigation(location, submission) {
3565 if (submission) {
3566 let navigation = {
3567 state: "loading",
3568 location,
3569 formMethod: submission.formMethod,
3570 formAction: submission.formAction,
3571 formEncType: submission.formEncType,
3572 formData: submission.formData,
3573 json: submission.json,
3574 text: submission.text
3575 };
3576 return navigation;
3577 } else {
3578 let navigation = {
3579 state: "loading",
3580 location,
3581 formMethod: void 0,
3582 formAction: void 0,
3583 formEncType: void 0,
3584 formData: void 0,
3585 json: void 0,
3586 text: void 0
3587 };
3588 return navigation;
3589 }
3590}
3591function getSubmittingNavigation(location, submission) {
3592 let navigation = {
3593 state: "submitting",
3594 location,
3595 formMethod: submission.formMethod,
3596 formAction: submission.formAction,
3597 formEncType: submission.formEncType,
3598 formData: submission.formData,
3599 json: submission.json,
3600 text: submission.text
3601 };
3602 return navigation;
3603}
3604function getLoadingFetcher(submission, data) {
3605 if (submission) {
3606 let fetcher = {
3607 state: "loading",
3608 formMethod: submission.formMethod,
3609 formAction: submission.formAction,
3610 formEncType: submission.formEncType,
3611 formData: submission.formData,
3612 json: submission.json,
3613 text: submission.text,
3614 data
3615 };
3616 return fetcher;
3617 } else {
3618 let fetcher = {
3619 state: "loading",
3620 formMethod: void 0,
3621 formAction: void 0,
3622 formEncType: void 0,
3623 formData: void 0,
3624 json: void 0,
3625 text: void 0,
3626 data
3627 };
3628 return fetcher;
3629 }
3630}
3631function getSubmittingFetcher(submission, existingFetcher) {
3632 let fetcher = {
3633 state: "submitting",
3634 formMethod: submission.formMethod,
3635 formAction: submission.formAction,
3636 formEncType: submission.formEncType,
3637 formData: submission.formData,
3638 json: submission.json,
3639 text: submission.text,
3640 data: existingFetcher ? existingFetcher.data : void 0
3641 };
3642 return fetcher;
3643}
3644function getDoneFetcher(data) {
3645 let fetcher = {
3646 state: "idle",
3647 formMethod: void 0,
3648 formAction: void 0,
3649 formEncType: void 0,
3650 formData: void 0,
3651 json: void 0,
3652 text: void 0,
3653 data
3654 };
3655 return fetcher;
3656}
3657function restoreAppliedTransitions(_window, transitions) {
3658 try {
3659 let sessionPositions = _window.sessionStorage.getItem(TRANSITIONS_STORAGE_KEY);
3660 if (sessionPositions) {
3661 let json3 = JSON.parse(sessionPositions);
3662 for (let [k, v] of Object.entries(json3 || {})) {
3663 if (v && Array.isArray(v)) {
3664 transitions.set(k, new Set(v || []));
3665 }
3666 }
3667 }
3668 } catch (e) {
3669 }
3670}
3671function persistAppliedTransitions(_window, transitions) {
3672 if (transitions.size > 0) {
3673 let json3 = {};
3674 for (let [k, v] of transitions) {
3675 json3[k] = [...v];
3676 }
3677 try {
3678 _window.sessionStorage.setItem(TRANSITIONS_STORAGE_KEY, JSON.stringify(json3));
3679 } catch (error) {
3680 warning(false, "Failed to save applied view transitions in sessionStorage (" + error + ").");
3681 }
3682 }
3683}
3684
3685// node_modules/react-router/dist/index.js
3686function _extends2() {
3687 _extends2 = Object.assign ? Object.assign.bind() : function(target) {
3688 for (var i = 1; i < arguments.length; i++) {
3689 var source = arguments[i];
3690 for (var key in source) {
3691 if (Object.prototype.hasOwnProperty.call(source, key)) {
3692 target[key] = source[key];
3693 }
3694 }
3695 }
3696 return target;
3697 };
3698 return _extends2.apply(this, arguments);
3699}
3700var DataRouterContext = React.createContext(null);
3701if (true) {
3702 DataRouterContext.displayName = "DataRouter";
3703}
3704var DataRouterStateContext = React.createContext(null);
3705if (true) {
3706 DataRouterStateContext.displayName = "DataRouterState";
3707}
3708var AwaitContext = React.createContext(null);
3709if (true) {
3710 AwaitContext.displayName = "Await";
3711}
3712var NavigationContext = React.createContext(null);
3713if (true) {
3714 NavigationContext.displayName = "Navigation";
3715}
3716var LocationContext = React.createContext(null);
3717if (true) {
3718 LocationContext.displayName = "Location";
3719}
3720var RouteContext = React.createContext({
3721 outlet: null,
3722 matches: [],
3723 isDataRoute: false
3724});
3725if (true) {
3726 RouteContext.displayName = "Route";
3727}
3728var RouteErrorContext = React.createContext(null);
3729if (true) {
3730 RouteErrorContext.displayName = "RouteError";
3731}
3732function useHref(to, _temp) {
3733 let {
3734 relative
3735 } = _temp === void 0 ? {} : _temp;
3736 !useInRouterContext() ? true ? invariant(
3737 false,
3738 // TODO: This error is probably because they somehow have 2 versions of the
3739 // router loaded. We can help them understand how to avoid that.
3740 "useHref() may be used only in the context of a <Router> component."
3741 ) : invariant(false) : void 0;
3742 let {
3743 basename,
3744 navigator
3745 } = React.useContext(NavigationContext);
3746 let {
3747 hash,
3748 pathname,
3749 search
3750 } = useResolvedPath(to, {
3751 relative
3752 });
3753 let joinedPathname = pathname;
3754 if (basename !== "/") {
3755 joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
3756 }
3757 return navigator.createHref({
3758 pathname: joinedPathname,
3759 search,
3760 hash
3761 });
3762}
3763function useInRouterContext() {
3764 return React.useContext(LocationContext) != null;
3765}
3766function useLocation() {
3767 !useInRouterContext() ? true ? invariant(
3768 false,
3769 // TODO: This error is probably because they somehow have 2 versions of the
3770 // router loaded. We can help them understand how to avoid that.
3771 "useLocation() may be used only in the context of a <Router> component."
3772 ) : invariant(false) : void 0;
3773 return React.useContext(LocationContext).location;
3774}
3775function useNavigationType() {
3776 return React.useContext(LocationContext).navigationType;
3777}
3778function useMatch(pattern) {
3779 !useInRouterContext() ? true ? invariant(
3780 false,
3781 // TODO: This error is probably because they somehow have 2 versions of the
3782 // router loaded. We can help them understand how to avoid that.
3783 "useMatch() may be used only in the context of a <Router> component."
3784 ) : invariant(false) : void 0;
3785 let {
3786 pathname
3787 } = useLocation();
3788 return React.useMemo(() => matchPath(pattern, decodePath(pathname)), [pathname, pattern]);
3789}
3790var navigateEffectWarning = "You should call navigate() in a React.useEffect(), not when your component is first rendered.";
3791function useIsomorphicLayoutEffect(cb) {
3792 let isStatic = React.useContext(NavigationContext).static;
3793 if (!isStatic) {
3794 React.useLayoutEffect(cb);
3795 }
3796}
3797function useNavigate() {
3798 let {
3799 isDataRoute
3800 } = React.useContext(RouteContext);
3801 return isDataRoute ? useNavigateStable() : useNavigateUnstable();
3802}
3803function useNavigateUnstable() {
3804 !useInRouterContext() ? true ? invariant(
3805 false,
3806 // TODO: This error is probably because they somehow have 2 versions of the
3807 // router loaded. We can help them understand how to avoid that.
3808 "useNavigate() may be used only in the context of a <Router> component."
3809 ) : invariant(false) : void 0;
3810 let dataRouterContext = React.useContext(DataRouterContext);
3811 let {
3812 basename,
3813 future,
3814 navigator
3815 } = React.useContext(NavigationContext);
3816 let {
3817 matches
3818 } = React.useContext(RouteContext);
3819 let {
3820 pathname: locationPathname
3821 } = useLocation();
3822 let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
3823 let activeRef = React.useRef(false);
3824 useIsomorphicLayoutEffect(() => {
3825 activeRef.current = true;
3826 });
3827 let navigate = React.useCallback(function(to, options) {
3828 if (options === void 0) {
3829 options = {};
3830 }
3831 true ? warning(activeRef.current, navigateEffectWarning) : void 0;
3832 if (!activeRef.current) return;
3833 if (typeof to === "number") {
3834 navigator.go(to);
3835 return;
3836 }
3837 let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path");
3838 if (dataRouterContext == null && basename !== "/") {
3839 path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
3840 }
3841 (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
3842 }, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
3843 return navigate;
3844}
3845var OutletContext = React.createContext(null);
3846function useOutletContext() {
3847 return React.useContext(OutletContext);
3848}
3849function useOutlet(context) {
3850 let outlet = React.useContext(RouteContext).outlet;
3851 if (outlet) {
3852 return React.createElement(OutletContext.Provider, {
3853 value: context
3854 }, outlet);
3855 }
3856 return outlet;
3857}
3858function useParams() {
3859 let {
3860 matches
3861 } = React.useContext(RouteContext);
3862 let routeMatch = matches[matches.length - 1];
3863 return routeMatch ? routeMatch.params : {};
3864}
3865function useResolvedPath(to, _temp2) {
3866 let {
3867 relative
3868 } = _temp2 === void 0 ? {} : _temp2;
3869 let {
3870 future
3871 } = React.useContext(NavigationContext);
3872 let {
3873 matches
3874 } = React.useContext(RouteContext);
3875 let {
3876 pathname: locationPathname
3877 } = useLocation();
3878 let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
3879 return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
3880}
3881function useRoutes(routes, locationArg) {
3882 return useRoutesImpl(routes, locationArg);
3883}
3884function useRoutesImpl(routes, locationArg, dataRouterState, future) {
3885 !useInRouterContext() ? true ? invariant(
3886 false,
3887 // TODO: This error is probably because they somehow have 2 versions of the
3888 // router loaded. We can help them understand how to avoid that.
3889 "useRoutes() may be used only in the context of a <Router> component."
3890 ) : invariant(false) : void 0;
3891 let {
3892 navigator
3893 } = React.useContext(NavigationContext);
3894 let {
3895 matches: parentMatches
3896 } = React.useContext(RouteContext);
3897 let routeMatch = parentMatches[parentMatches.length - 1];
3898 let parentParams = routeMatch ? routeMatch.params : {};
3899 let parentPathname = routeMatch ? routeMatch.pathname : "/";
3900 let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
3901 let parentRoute = routeMatch && routeMatch.route;
3902 if (true) {
3903 let parentPath = parentRoute && parentRoute.path || "";
3904 warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ('"' + parentPathname + '" (under <Route path="' + parentPath + '">) 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.
3905
3906` + ('Please change the parent <Route path="' + parentPath + '"> to <Route ') + ('path="' + (parentPath === "/" ? "*" : parentPath + "/*") + '">.'));
3907 }
3908 let locationFromContext = useLocation();
3909 let location;
3910 if (locationArg) {
3911 var _parsedLocationArg$pa;
3912 let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
3913 !(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? true ? invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was " + ('matched by all parent routes. The current pathname base is "' + parentPathnameBase + '" ') + ('but pathname "' + parsedLocationArg.pathname + '" was given in the `location` prop.')) : invariant(false) : void 0;
3914 location = parsedLocationArg;
3915 } else {
3916 location = locationFromContext;
3917 }
3918 let pathname = location.pathname || "/";
3919 let remainingPathname = pathname;
3920 if (parentPathnameBase !== "/") {
3921 let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
3922 let segments = pathname.replace(/^\//, "").split("/");
3923 remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
3924 }
3925 let matches = matchRoutes(routes, {
3926 pathname: remainingPathname
3927 });
3928 if (true) {
3929 true ? warning(parentRoute || matches != null, 'No routes matched location "' + location.pathname + location.search + location.hash + '" ') : void 0;
3930 true ? warning(matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0, 'Matched leaf route at location "' + location.pathname + location.search + location.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.') : void 0;
3931 }
3932 let renderedMatches = _renderMatches(matches && matches.map((match) => Object.assign({}, match, {
3933 params: Object.assign({}, parentParams, match.params),
3934 pathname: joinPaths([
3935 parentPathnameBase,
3936 // Re-encode pathnames that were decoded inside matchRoutes
3937 navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
3938 ]),
3939 pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
3940 parentPathnameBase,
3941 // Re-encode pathnames that were decoded inside matchRoutes
3942 navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
3943 ])
3944 })), parentMatches, dataRouterState, future);
3945 if (locationArg && renderedMatches) {
3946 return React.createElement(LocationContext.Provider, {
3947 value: {
3948 location: _extends2({
3949 pathname: "/",
3950 search: "",
3951 hash: "",
3952 state: null,
3953 key: "default"
3954 }, location),
3955 navigationType: Action.Pop
3956 }
3957 }, renderedMatches);
3958 }
3959 return renderedMatches;
3960}
3961function DefaultErrorComponent() {
3962 let error = useRouteError();
3963 let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
3964 let stack = error instanceof Error ? error.stack : null;
3965 let lightgrey = "rgba(200,200,200, 0.5)";
3966 let preStyles = {
3967 padding: "0.5rem",
3968 backgroundColor: lightgrey
3969 };
3970 let codeStyles = {
3971 padding: "2px 4px",
3972 backgroundColor: lightgrey
3973 };
3974 let devInfo = null;
3975 if (true) {
3976 console.error("Error handled by React Router default ErrorBoundary:", error);
3977 devInfo = React.createElement(React.Fragment, null, React.createElement("p", null, "💿 Hey developer 👋"), React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", React.createElement("code", {
3978 style: codeStyles
3979 }, "ErrorBoundary"), " or", " ", React.createElement("code", {
3980 style: codeStyles
3981 }, "errorElement"), " prop on your route."));
3982 }
3983 return React.createElement(React.Fragment, null, React.createElement("h2", null, "Unexpected Application Error!"), React.createElement("h3", {
3984 style: {
3985 fontStyle: "italic"
3986 }
3987 }, message), stack ? React.createElement("pre", {
3988 style: preStyles
3989 }, stack) : null, devInfo);
3990}
3991var defaultErrorElement = React.createElement(DefaultErrorComponent, null);
3992var RenderErrorBoundary = class extends React.Component {
3993 constructor(props) {
3994 super(props);
3995 this.state = {
3996 location: props.location,
3997 revalidation: props.revalidation,
3998 error: props.error
3999 };
4000 }
4001 static getDerivedStateFromError(error) {
4002 return {
4003 error
4004 };
4005 }
4006 static getDerivedStateFromProps(props, state) {
4007 if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
4008 return {
4009 error: props.error,
4010 location: props.location,
4011 revalidation: props.revalidation
4012 };
4013 }
4014 return {
4015 error: props.error !== void 0 ? props.error : state.error,
4016 location: state.location,
4017 revalidation: props.revalidation || state.revalidation
4018 };
4019 }
4020 componentDidCatch(error, errorInfo) {
4021 console.error("React Router caught the following error during render", error, errorInfo);
4022 }
4023 render() {
4024 return this.state.error !== void 0 ? React.createElement(RouteContext.Provider, {
4025 value: this.props.routeContext
4026 }, React.createElement(RouteErrorContext.Provider, {
4027 value: this.state.error,
4028 children: this.props.component
4029 })) : this.props.children;
4030 }
4031};
4032function RenderedRoute(_ref) {
4033 let {
4034 routeContext,
4035 match,
4036 children
4037 } = _ref;
4038 let dataRouterContext = React.useContext(DataRouterContext);
4039 if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
4040 dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
4041 }
4042 return React.createElement(RouteContext.Provider, {
4043 value: routeContext
4044 }, children);
4045}
4046function _renderMatches(matches, parentMatches, dataRouterState, future) {
4047 var _dataRouterState;
4048 if (parentMatches === void 0) {
4049 parentMatches = [];
4050 }
4051 if (dataRouterState === void 0) {
4052 dataRouterState = null;
4053 }
4054 if (future === void 0) {
4055 future = null;
4056 }
4057 if (matches == null) {
4058 var _future;
4059 if (!dataRouterState) {
4060 return null;
4061 }
4062 if (dataRouterState.errors) {
4063 matches = dataRouterState.matches;
4064 } else if ((_future = future) != null && _future.v7_partialHydration && parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
4065 matches = dataRouterState.matches;
4066 } else {
4067 return null;
4068 }
4069 }
4070 let renderedMatches = matches;
4071 let errors = (_dataRouterState = dataRouterState) == null ? void 0 : _dataRouterState.errors;
4072 if (errors != null) {
4073 let errorIndex = renderedMatches.findIndex((m) => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== void 0);
4074 !(errorIndex >= 0) ? true ? invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : invariant(false) : void 0;
4075 renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
4076 }
4077 let renderFallback = false;
4078 let fallbackIndex = -1;
4079 if (dataRouterState && future && future.v7_partialHydration) {
4080 for (let i = 0; i < renderedMatches.length; i++) {
4081 let match = renderedMatches[i];
4082 if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
4083 fallbackIndex = i;
4084 }
4085 if (match.route.id) {
4086 let {
4087 loaderData,
4088 errors: errors2
4089 } = dataRouterState;
4090 let needsToRunLoader = match.route.loader && loaderData[match.route.id] === void 0 && (!errors2 || errors2[match.route.id] === void 0);
4091 if (match.route.lazy || needsToRunLoader) {
4092 renderFallback = true;
4093 if (fallbackIndex >= 0) {
4094 renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
4095 } else {
4096 renderedMatches = [renderedMatches[0]];
4097 }
4098 break;
4099 }
4100 }
4101 }
4102 }
4103 return renderedMatches.reduceRight((outlet, match, index) => {
4104 let error;
4105 let shouldRenderHydrateFallback = false;
4106 let errorElement = null;
4107 let hydrateFallbackElement = null;
4108 if (dataRouterState) {
4109 error = errors && match.route.id ? errors[match.route.id] : void 0;
4110 errorElement = match.route.errorElement || defaultErrorElement;
4111 if (renderFallback) {
4112 if (fallbackIndex < 0 && index === 0) {
4113 warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
4114 shouldRenderHydrateFallback = true;
4115 hydrateFallbackElement = null;
4116 } else if (fallbackIndex === index) {
4117 shouldRenderHydrateFallback = true;
4118 hydrateFallbackElement = match.route.hydrateFallbackElement || null;
4119 }
4120 }
4121 }
4122 let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
4123 let getChildren = () => {
4124 let children;
4125 if (error) {
4126 children = errorElement;
4127 } else if (shouldRenderHydrateFallback) {
4128 children = hydrateFallbackElement;
4129 } else if (match.route.Component) {
4130 children = React.createElement(match.route.Component, null);
4131 } else if (match.route.element) {
4132 children = match.route.element;
4133 } else {
4134 children = outlet;
4135 }
4136 return React.createElement(RenderedRoute, {
4137 match,
4138 routeContext: {
4139 outlet,
4140 matches: matches2,
4141 isDataRoute: dataRouterState != null
4142 },
4143 children
4144 });
4145 };
4146 return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? React.createElement(RenderErrorBoundary, {
4147 location: dataRouterState.location,
4148 revalidation: dataRouterState.revalidation,
4149 component: errorElement,
4150 error,
4151 children: getChildren(),
4152 routeContext: {
4153 outlet: null,
4154 matches: matches2,
4155 isDataRoute: true
4156 }
4157 }) : getChildren();
4158 }, null);
4159}
4160var DataRouterHook = function(DataRouterHook3) {
4161 DataRouterHook3["UseBlocker"] = "useBlocker";
4162 DataRouterHook3["UseRevalidator"] = "useRevalidator";
4163 DataRouterHook3["UseNavigateStable"] = "useNavigate";
4164 return DataRouterHook3;
4165}(DataRouterHook || {});
4166var DataRouterStateHook = function(DataRouterStateHook3) {
4167 DataRouterStateHook3["UseBlocker"] = "useBlocker";
4168 DataRouterStateHook3["UseLoaderData"] = "useLoaderData";
4169 DataRouterStateHook3["UseActionData"] = "useActionData";
4170 DataRouterStateHook3["UseRouteError"] = "useRouteError";
4171 DataRouterStateHook3["UseNavigation"] = "useNavigation";
4172 DataRouterStateHook3["UseRouteLoaderData"] = "useRouteLoaderData";
4173 DataRouterStateHook3["UseMatches"] = "useMatches";
4174 DataRouterStateHook3["UseRevalidator"] = "useRevalidator";
4175 DataRouterStateHook3["UseNavigateStable"] = "useNavigate";
4176 DataRouterStateHook3["UseRouteId"] = "useRouteId";
4177 return DataRouterStateHook3;
4178}(DataRouterStateHook || {});
4179function getDataRouterConsoleError(hookName) {
4180 return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
4181}
4182function useDataRouterContext(hookName) {
4183 let ctx = React.useContext(DataRouterContext);
4184 !ctx ? true ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
4185 return ctx;
4186}
4187function useDataRouterState(hookName) {
4188 let state = React.useContext(DataRouterStateContext);
4189 !state ? true ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
4190 return state;
4191}
4192function useRouteContext(hookName) {
4193 let route = React.useContext(RouteContext);
4194 !route ? true ? invariant(false, getDataRouterConsoleError(hookName)) : invariant(false) : void 0;
4195 return route;
4196}
4197function useCurrentRouteId(hookName) {
4198 let route = useRouteContext(hookName);
4199 let thisRoute = route.matches[route.matches.length - 1];
4200 !thisRoute.route.id ? true ? invariant(false, hookName + ' can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
4201 return thisRoute.route.id;
4202}
4203function useRouteId() {
4204 return useCurrentRouteId(DataRouterStateHook.UseRouteId);
4205}
4206function useNavigation() {
4207 let state = useDataRouterState(DataRouterStateHook.UseNavigation);
4208 return state.navigation;
4209}
4210function useRevalidator() {
4211 let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
4212 let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
4213 return React.useMemo(() => ({
4214 revalidate: dataRouterContext.router.revalidate,
4215 state: state.revalidation
4216 }), [dataRouterContext.router.revalidate, state.revalidation]);
4217}
4218function useMatches() {
4219 let {
4220 matches,
4221 loaderData
4222 } = useDataRouterState(DataRouterStateHook.UseMatches);
4223 return React.useMemo(() => matches.map((m) => convertRouteMatchToUiMatch(m, loaderData)), [matches, loaderData]);
4224}
4225function useLoaderData() {
4226 let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
4227 let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
4228 if (state.errors && state.errors[routeId] != null) {
4229 console.error("You cannot `useLoaderData` in an errorElement (routeId: " + routeId + ")");
4230 return void 0;
4231 }
4232 return state.loaderData[routeId];
4233}
4234function useRouteLoaderData(routeId) {
4235 let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);
4236 return state.loaderData[routeId];
4237}
4238function useActionData() {
4239 let state = useDataRouterState(DataRouterStateHook.UseActionData);
4240 let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
4241 return state.actionData ? state.actionData[routeId] : void 0;
4242}
4243function useRouteError() {
4244 var _state$errors;
4245 let error = React.useContext(RouteErrorContext);
4246 let state = useDataRouterState(DataRouterStateHook.UseRouteError);
4247 let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError);
4248 if (error !== void 0) {
4249 return error;
4250 }
4251 return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
4252}
4253function useAsyncValue() {
4254 let value = React.useContext(AwaitContext);
4255 return value == null ? void 0 : value._data;
4256}
4257function useAsyncError() {
4258 let value = React.useContext(AwaitContext);
4259 return value == null ? void 0 : value._error;
4260}
4261var blockerId = 0;
4262function useBlocker(shouldBlock) {
4263 let {
4264 router,
4265 basename
4266 } = useDataRouterContext(DataRouterHook.UseBlocker);
4267 let state = useDataRouterState(DataRouterStateHook.UseBlocker);
4268 let [blockerKey, setBlockerKey] = React.useState("");
4269 let blockerFunction = React.useCallback((arg) => {
4270 if (typeof shouldBlock !== "function") {
4271 return !!shouldBlock;
4272 }
4273 if (basename === "/") {
4274 return shouldBlock(arg);
4275 }
4276 let {
4277 currentLocation,
4278 nextLocation,
4279 historyAction
4280 } = arg;
4281 return shouldBlock({
4282 currentLocation: _extends2({}, currentLocation, {
4283 pathname: stripBasename(currentLocation.pathname, basename) || currentLocation.pathname
4284 }),
4285 nextLocation: _extends2({}, nextLocation, {
4286 pathname: stripBasename(nextLocation.pathname, basename) || nextLocation.pathname
4287 }),
4288 historyAction
4289 });
4290 }, [basename, shouldBlock]);
4291 React.useEffect(() => {
4292 let key = String(++blockerId);
4293 setBlockerKey(key);
4294 return () => router.deleteBlocker(key);
4295 }, [router]);
4296 React.useEffect(() => {
4297 if (blockerKey !== "") {
4298 router.getBlocker(blockerKey, blockerFunction);
4299 }
4300 }, [router, blockerKey, blockerFunction]);
4301 return blockerKey && state.blockers.has(blockerKey) ? state.blockers.get(blockerKey) : IDLE_BLOCKER;
4302}
4303function useNavigateStable() {
4304 let {
4305 router
4306 } = useDataRouterContext(DataRouterHook.UseNavigateStable);
4307 let id = useCurrentRouteId(DataRouterStateHook.UseNavigateStable);
4308 let activeRef = React.useRef(false);
4309 useIsomorphicLayoutEffect(() => {
4310 activeRef.current = true;
4311 });
4312 let navigate = React.useCallback(function(to, options) {
4313 if (options === void 0) {
4314 options = {};
4315 }
4316 true ? warning(activeRef.current, navigateEffectWarning) : void 0;
4317 if (!activeRef.current) return;
4318 if (typeof to === "number") {
4319 router.navigate(to);
4320 } else {
4321 router.navigate(to, _extends2({
4322 fromRouteId: id
4323 }, options));
4324 }
4325 }, [router, id]);
4326 return navigate;
4327}
4328var alreadyWarned = {};
4329function warningOnce(key, cond, message) {
4330 if (!cond && !alreadyWarned[key]) {
4331 alreadyWarned[key] = true;
4332 true ? warning(false, message) : void 0;
4333 }
4334}
4335var START_TRANSITION = "startTransition";
4336var startTransitionImpl = React[START_TRANSITION];
4337function MemoryRouter(_ref3) {
4338 let {
4339 basename,
4340 children,
4341 initialEntries,
4342 initialIndex,
4343 future
4344 } = _ref3;
4345 let historyRef = React.useRef();
4346 if (historyRef.current == null) {
4347 historyRef.current = createMemoryHistory({
4348 initialEntries,
4349 initialIndex,
4350 v5Compat: true
4351 });
4352 }
4353 let history = historyRef.current;
4354 let [state, setStateImpl] = React.useState({
4355 action: history.action,
4356 location: history.location
4357 });
4358 let {
4359 v7_startTransition
4360 } = future || {};
4361 let setState = React.useCallback((newState) => {
4362 v7_startTransition && startTransitionImpl ? startTransitionImpl(() => setStateImpl(newState)) : setStateImpl(newState);
4363 }, [setStateImpl, v7_startTransition]);
4364 React.useLayoutEffect(() => history.listen(setState), [history, setState]);
4365 return React.createElement(Router, {
4366 basename,
4367 children,
4368 location: state.location,
4369 navigationType: state.action,
4370 navigator: history,
4371 future
4372 });
4373}
4374function Navigate(_ref4) {
4375 let {
4376 to,
4377 replace: replace2,
4378 state,
4379 relative
4380 } = _ref4;
4381 !useInRouterContext() ? true ? invariant(
4382 false,
4383 // TODO: This error is probably because they somehow have 2 versions of
4384 // the router loaded. We can help them understand how to avoid that.
4385 "<Navigate> may be used only in the context of a <Router> component."
4386 ) : invariant(false) : void 0;
4387 let {
4388 future,
4389 static: isStatic
4390 } = React.useContext(NavigationContext);
4391 true ? warning(!isStatic, "<Navigate> must not be used on the initial render in a <StaticRouter>. This is a no-op, but you should modify your code so the <Navigate> is only ever rendered in response to some user interaction or state change.") : void 0;
4392 let {
4393 matches
4394 } = React.useContext(RouteContext);
4395 let {
4396 pathname: locationPathname
4397 } = useLocation();
4398 let navigate = useNavigate();
4399 let path = resolveTo(to, getResolveToMatches(matches, future.v7_relativeSplatPath), locationPathname, relative === "path");
4400 let jsonPath = JSON.stringify(path);
4401 React.useEffect(() => navigate(JSON.parse(jsonPath), {
4402 replace: replace2,
4403 state,
4404 relative
4405 }), [navigate, jsonPath, relative, replace2, state]);
4406 return null;
4407}
4408function Outlet(props) {
4409 return useOutlet(props.context);
4410}
4411function Route(_props) {
4412 true ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false);
4413}
4414function Router(_ref5) {
4415 let {
4416 basename: basenameProp = "/",
4417 children = null,
4418 location: locationProp,
4419 navigationType = Action.Pop,
4420 navigator,
4421 static: staticProp = false,
4422 future
4423 } = _ref5;
4424 !!useInRouterContext() ? true ? invariant(false, "You cannot render a <Router> inside another <Router>. You should never have more than one in your app.") : invariant(false) : void 0;
4425 let basename = basenameProp.replace(/^\/*/, "/");
4426 let navigationContext = React.useMemo(() => ({
4427 basename,
4428 navigator,
4429 static: staticProp,
4430 future: _extends2({
4431 v7_relativeSplatPath: false
4432 }, future)
4433 }), [basename, future, navigator, staticProp]);
4434 if (typeof locationProp === "string") {
4435 locationProp = parsePath(locationProp);
4436 }
4437 let {
4438 pathname = "/",
4439 search = "",
4440 hash = "",
4441 state = null,
4442 key = "default"
4443 } = locationProp;
4444 let locationContext = React.useMemo(() => {
4445 let trailingPathname = stripBasename(pathname, basename);
4446 if (trailingPathname == null) {
4447 return null;
4448 }
4449 return {
4450 location: {
4451 pathname: trailingPathname,
4452 search,
4453 hash,
4454 state,
4455 key
4456 },
4457 navigationType
4458 };
4459 }, [basename, pathname, search, hash, state, key, navigationType]);
4460 true ? warning(locationContext != null, '<Router basename="' + basename + '"> is not able to match the URL ' + ('"' + pathname + search + hash + '" because it does not start with the ') + "basename, so the <Router> won't render anything.") : void 0;
4461 if (locationContext == null) {
4462 return null;
4463 }
4464 return React.createElement(NavigationContext.Provider, {
4465 value: navigationContext
4466 }, React.createElement(LocationContext.Provider, {
4467 children,
4468 value: locationContext
4469 }));
4470}
4471function Routes(_ref6) {
4472 let {
4473 children,
4474 location
4475 } = _ref6;
4476 return useRoutes(createRoutesFromChildren(children), location);
4477}
4478function Await(_ref7) {
4479 let {
4480 children,
4481 errorElement,
4482 resolve
4483 } = _ref7;
4484 return React.createElement(AwaitErrorBoundary, {
4485 resolve,
4486 errorElement
4487 }, React.createElement(ResolveAwait, null, children));
4488}
4489var AwaitRenderStatus = function(AwaitRenderStatus2) {
4490 AwaitRenderStatus2[AwaitRenderStatus2["pending"] = 0] = "pending";
4491 AwaitRenderStatus2[AwaitRenderStatus2["success"] = 1] = "success";
4492 AwaitRenderStatus2[AwaitRenderStatus2["error"] = 2] = "error";
4493 return AwaitRenderStatus2;
4494}(AwaitRenderStatus || {});
4495var neverSettledPromise = new Promise(() => {
4496});
4497var AwaitErrorBoundary = class extends React.Component {
4498 constructor(props) {
4499 super(props);
4500 this.state = {
4501 error: null
4502 };
4503 }
4504 static getDerivedStateFromError(error) {
4505 return {
4506 error
4507 };
4508 }
4509 componentDidCatch(error, errorInfo) {
4510 console.error("<Await> caught the following error during render", error, errorInfo);
4511 }
4512 render() {
4513 let {
4514 children,
4515 errorElement,
4516 resolve
4517 } = this.props;
4518 let promise = null;
4519 let status = AwaitRenderStatus.pending;
4520 if (!(resolve instanceof Promise)) {
4521 status = AwaitRenderStatus.success;
4522 promise = Promise.resolve();
4523 Object.defineProperty(promise, "_tracked", {
4524 get: () => true
4525 });
4526 Object.defineProperty(promise, "_data", {
4527 get: () => resolve
4528 });
4529 } else if (this.state.error) {
4530 status = AwaitRenderStatus.error;
4531 let renderError = this.state.error;
4532 promise = Promise.reject().catch(() => {
4533 });
4534 Object.defineProperty(promise, "_tracked", {
4535 get: () => true
4536 });
4537 Object.defineProperty(promise, "_error", {
4538 get: () => renderError
4539 });
4540 } else if (resolve._tracked) {
4541 promise = resolve;
4542 status = "_error" in promise ? AwaitRenderStatus.error : "_data" in promise ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
4543 } else {
4544 status = AwaitRenderStatus.pending;
4545 Object.defineProperty(resolve, "_tracked", {
4546 get: () => true
4547 });
4548 promise = resolve.then((data) => Object.defineProperty(resolve, "_data", {
4549 get: () => data
4550 }), (error) => Object.defineProperty(resolve, "_error", {
4551 get: () => error
4552 }));
4553 }
4554 if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
4555 throw neverSettledPromise;
4556 }
4557 if (status === AwaitRenderStatus.error && !errorElement) {
4558 throw promise._error;
4559 }
4560 if (status === AwaitRenderStatus.error) {
4561 return React.createElement(AwaitContext.Provider, {
4562 value: promise,
4563 children: errorElement
4564 });
4565 }
4566 if (status === AwaitRenderStatus.success) {
4567 return React.createElement(AwaitContext.Provider, {
4568 value: promise,
4569 children
4570 });
4571 }
4572 throw promise;
4573 }
4574};
4575function ResolveAwait(_ref8) {
4576 let {
4577 children
4578 } = _ref8;
4579 let data = useAsyncValue();
4580 let toRender = typeof children === "function" ? children(data) : children;
4581 return React.createElement(React.Fragment, null, toRender);
4582}
4583function createRoutesFromChildren(children, parentPath) {
4584 if (parentPath === void 0) {
4585 parentPath = [];
4586 }
4587 let routes = [];
4588 React.Children.forEach(children, (element, index) => {
4589 if (!React.isValidElement(element)) {
4590 return;
4591 }
4592 let treePath = [...parentPath, index];
4593 if (element.type === React.Fragment) {
4594 routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
4595 return;
4596 }
4597 !(element.type === Route) ? true ? invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : invariant(false) : void 0;
4598 !(!element.props.index || !element.props.children) ? true ? invariant(false, "An index route cannot have child routes.") : invariant(false) : void 0;
4599 let route = {
4600 id: element.props.id || treePath.join("-"),
4601 caseSensitive: element.props.caseSensitive,
4602 element: element.props.element,
4603 Component: element.props.Component,
4604 index: element.props.index,
4605 path: element.props.path,
4606 loader: element.props.loader,
4607 action: element.props.action,
4608 errorElement: element.props.errorElement,
4609 ErrorBoundary: element.props.ErrorBoundary,
4610 hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
4611 shouldRevalidate: element.props.shouldRevalidate,
4612 handle: element.props.handle,
4613 lazy: element.props.lazy
4614 };
4615 if (element.props.children) {
4616 route.children = createRoutesFromChildren(element.props.children, treePath);
4617 }
4618 routes.push(route);
4619 });
4620 return routes;
4621}
4622function renderMatches(matches) {
4623 return _renderMatches(matches);
4624}
4625function mapRouteProperties(route) {
4626 let updates = {
4627 // Note: this check also occurs in createRoutesFromChildren so update
4628 // there if you change this -- please and thank you!
4629 hasErrorBoundary: route.ErrorBoundary != null || route.errorElement != null
4630 };
4631 if (route.Component) {
4632 if (true) {
4633 if (route.element) {
4634 true ? warning(false, "You should not include both `Component` and `element` on your route - `Component` will be used.") : void 0;
4635 }
4636 }
4637 Object.assign(updates, {
4638 element: React.createElement(route.Component),
4639 Component: void 0
4640 });
4641 }
4642 if (route.HydrateFallback) {
4643 if (true) {
4644 if (route.hydrateFallbackElement) {
4645 true ? warning(false, "You should not include both `HydrateFallback` and `hydrateFallbackElement` on your route - `HydrateFallback` will be used.") : void 0;
4646 }
4647 }
4648 Object.assign(updates, {
4649 hydrateFallbackElement: React.createElement(route.HydrateFallback),
4650 HydrateFallback: void 0
4651 });
4652 }
4653 if (route.ErrorBoundary) {
4654 if (true) {
4655 if (route.errorElement) {
4656 true ? warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - `ErrorBoundary` will be used.") : void 0;
4657 }
4658 }
4659 Object.assign(updates, {
4660 errorElement: React.createElement(route.ErrorBoundary),
4661 ErrorBoundary: void 0
4662 });
4663 }
4664 return updates;
4665}
4666function createMemoryRouter(routes, opts) {
4667 return createRouter({
4668 basename: opts == null ? void 0 : opts.basename,
4669 future: _extends2({}, opts == null ? void 0 : opts.future, {
4670 v7_prependBasename: true
4671 }),
4672 history: createMemoryHistory({
4673 initialEntries: opts == null ? void 0 : opts.initialEntries,
4674 initialIndex: opts == null ? void 0 : opts.initialIndex
4675 }),
4676 hydrationData: opts == null ? void 0 : opts.hydrationData,
4677 routes,
4678 mapRouteProperties,
4679 unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
4680 unstable_patchRoutesOnMiss: opts == null ? void 0 : opts.unstable_patchRoutesOnMiss
4681 }).initialize();
4682}
4683
4684// node_modules/react-router-dom/dist/index.js
4685function _extends3() {
4686 _extends3 = Object.assign ? Object.assign.bind() : function(target) {
4687 for (var i = 1; i < arguments.length; i++) {
4688 var source = arguments[i];
4689 for (var key in source) {
4690 if (Object.prototype.hasOwnProperty.call(source, key)) {
4691 target[key] = source[key];
4692 }
4693 }
4694 }
4695 return target;
4696 };
4697 return _extends3.apply(this, arguments);
4698}
4699function _objectWithoutPropertiesLoose(source, excluded) {
4700 if (source == null) return {};
4701 var target = {};
4702 var sourceKeys = Object.keys(source);
4703 var key, i;
4704 for (i = 0; i < sourceKeys.length; i++) {
4705 key = sourceKeys[i];
4706 if (excluded.indexOf(key) >= 0) continue;
4707 target[key] = source[key];
4708 }
4709 return target;
4710}
4711var defaultMethod = "get";
4712var defaultEncType = "application/x-www-form-urlencoded";
4713function isHtmlElement(object) {
4714 return object != null && typeof object.tagName === "string";
4715}
4716function isButtonElement(object) {
4717 return isHtmlElement(object) && object.tagName.toLowerCase() === "button";
4718}
4719function isFormElement(object) {
4720 return isHtmlElement(object) && object.tagName.toLowerCase() === "form";
4721}
4722function isInputElement(object) {
4723 return isHtmlElement(object) && object.tagName.toLowerCase() === "input";
4724}
4725function isModifiedEvent(event) {
4726 return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
4727}
4728function shouldProcessLinkClick(event, target) {
4729 return event.button === 0 && // Ignore everything but left clicks
4730 (!target || target === "_self") && // Let browser handle "target=_blank" etc.
4731 !isModifiedEvent(event);
4732}
4733function createSearchParams(init) {
4734 if (init === void 0) {
4735 init = "";
4736 }
4737 return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo2, key) => {
4738 let value = init[key];
4739 return memo2.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
4740 }, []));
4741}
4742function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
4743 let searchParams = createSearchParams(locationSearch);
4744 if (defaultSearchParams) {
4745 defaultSearchParams.forEach((_, key) => {
4746 if (!searchParams.has(key)) {
4747 defaultSearchParams.getAll(key).forEach((value) => {
4748 searchParams.append(key, value);
4749 });
4750 }
4751 });
4752 }
4753 return searchParams;
4754}
4755var _formDataSupportsSubmitter = null;
4756function isFormDataSubmitterSupported() {
4757 if (_formDataSupportsSubmitter === null) {
4758 try {
4759 new FormData(
4760 document.createElement("form"),
4761 // @ts-expect-error if FormData supports the submitter parameter, this will throw
4762 0
4763 );
4764 _formDataSupportsSubmitter = false;
4765 } catch (e) {
4766 _formDataSupportsSubmitter = true;
4767 }
4768 }
4769 return _formDataSupportsSubmitter;
4770}
4771var supportedFormEncTypes = /* @__PURE__ */ new Set(["application/x-www-form-urlencoded", "multipart/form-data", "text/plain"]);
4772function getFormEncType(encType) {
4773 if (encType != null && !supportedFormEncTypes.has(encType)) {
4774 true ? warning(false, '"' + encType + '" is not a valid `encType` for `<Form>`/`<fetcher.Form>` ' + ('and will default to "' + defaultEncType + '"')) : void 0;
4775 return null;
4776 }
4777 return encType;
4778}
4779function getFormSubmissionInfo(target, basename) {
4780 let method;
4781 let action;
4782 let encType;
4783 let formData;
4784 let body;
4785 if (isFormElement(target)) {
4786 let attr = target.getAttribute("action");
4787 action = attr ? stripBasename(attr, basename) : null;
4788 method = target.getAttribute("method") || defaultMethod;
4789 encType = getFormEncType(target.getAttribute("enctype")) || defaultEncType;
4790 formData = new FormData(target);
4791 } else if (isButtonElement(target) || isInputElement(target) && (target.type === "submit" || target.type === "image")) {
4792 let form = target.form;
4793 if (form == null) {
4794 throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');
4795 }
4796 let attr = target.getAttribute("formaction") || form.getAttribute("action");
4797 action = attr ? stripBasename(attr, basename) : null;
4798 method = target.getAttribute("formmethod") || form.getAttribute("method") || defaultMethod;
4799 encType = getFormEncType(target.getAttribute("formenctype")) || getFormEncType(form.getAttribute("enctype")) || defaultEncType;
4800 formData = new FormData(form, target);
4801 if (!isFormDataSubmitterSupported()) {
4802 let {
4803 name,
4804 type,
4805 value
4806 } = target;
4807 if (type === "image") {
4808 let prefix = name ? name + "." : "";
4809 formData.append(prefix + "x", "0");
4810 formData.append(prefix + "y", "0");
4811 } else if (name) {
4812 formData.append(name, value);
4813 }
4814 }
4815 } else if (isHtmlElement(target)) {
4816 throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');
4817 } else {
4818 method = defaultMethod;
4819 action = null;
4820 encType = defaultEncType;
4821 body = target;
4822 }
4823 if (formData && encType === "text/plain") {
4824 body = formData;
4825 formData = void 0;
4826 }
4827 return {
4828 action,
4829 method: method.toLowerCase(),
4830 encType,
4831 formData,
4832 body
4833 };
4834}
4835var _excluded = ["onClick", "relative", "reloadDocument", "replace", "state", "target", "to", "preventScrollReset", "unstable_viewTransition"];
4836var _excluded2 = ["aria-current", "caseSensitive", "className", "end", "style", "to", "unstable_viewTransition", "children"];
4837var _excluded3 = ["fetcherKey", "navigate", "reloadDocument", "replace", "state", "method", "action", "onSubmit", "relative", "preventScrollReset", "unstable_viewTransition"];
4838var REACT_ROUTER_VERSION = "6";
4839try {
4840 window.__reactRouterVersion = REACT_ROUTER_VERSION;
4841} catch (e) {
4842}
4843function createBrowserRouter(routes, opts) {
4844 return createRouter({
4845 basename: opts == null ? void 0 : opts.basename,
4846 future: _extends3({}, opts == null ? void 0 : opts.future, {
4847 v7_prependBasename: true
4848 }),
4849 history: createBrowserHistory({
4850 window: opts == null ? void 0 : opts.window
4851 }),
4852 hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
4853 routes,
4854 mapRouteProperties,
4855 unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
4856 unstable_patchRoutesOnMiss: opts == null ? void 0 : opts.unstable_patchRoutesOnMiss,
4857 window: opts == null ? void 0 : opts.window
4858 }).initialize();
4859}
4860function createHashRouter(routes, opts) {
4861 return createRouter({
4862 basename: opts == null ? void 0 : opts.basename,
4863 future: _extends3({}, opts == null ? void 0 : opts.future, {
4864 v7_prependBasename: true
4865 }),
4866 history: createHashHistory({
4867 window: opts == null ? void 0 : opts.window
4868 }),
4869 hydrationData: (opts == null ? void 0 : opts.hydrationData) || parseHydrationData(),
4870 routes,
4871 mapRouteProperties,
4872 unstable_dataStrategy: opts == null ? void 0 : opts.unstable_dataStrategy,
4873 unstable_patchRoutesOnMiss: opts == null ? void 0 : opts.unstable_patchRoutesOnMiss,
4874 window: opts == null ? void 0 : opts.window
4875 }).initialize();
4876}
4877function parseHydrationData() {
4878 var _window;
4879 let state = (_window = window) == null ? void 0 : _window.__staticRouterHydrationData;
4880 if (state && state.errors) {
4881 state = _extends3({}, state, {
4882 errors: deserializeErrors(state.errors)
4883 });
4884 }
4885 return state;
4886}
4887function deserializeErrors(errors) {
4888 if (!errors) return null;
4889 let entries = Object.entries(errors);
4890 let serialized = {};
4891 for (let [key, val] of entries) {
4892 if (val && val.__type === "RouteErrorResponse") {
4893 serialized[key] = new ErrorResponseImpl(val.status, val.statusText, val.data, val.internal === true);
4894 } else if (val && val.__type === "Error") {
4895 if (val.__subType) {
4896 let ErrorConstructor = window[val.__subType];
4897 if (typeof ErrorConstructor === "function") {
4898 try {
4899 let error = new ErrorConstructor(val.message);
4900 error.stack = "";
4901 serialized[key] = error;
4902 } catch (e) {
4903 }
4904 }
4905 }
4906 if (serialized[key] == null) {
4907 let error = new Error(val.message);
4908 error.stack = "";
4909 serialized[key] = error;
4910 }
4911 } else {
4912 serialized[key] = val;
4913 }
4914 }
4915 return serialized;
4916}
4917var ViewTransitionContext = React2.createContext({
4918 isTransitioning: false
4919});
4920if (true) {
4921 ViewTransitionContext.displayName = "ViewTransition";
4922}
4923var FetchersContext = React2.createContext(/* @__PURE__ */ new Map());
4924if (true) {
4925 FetchersContext.displayName = "Fetchers";
4926}
4927var START_TRANSITION2 = "startTransition";
4928var startTransitionImpl2 = React2[START_TRANSITION2];
4929var FLUSH_SYNC = "flushSync";
4930var flushSyncImpl = ReactDOM[FLUSH_SYNC];
4931var USE_ID = "useId";
4932var useIdImpl = React2[USE_ID];
4933function startTransitionSafe(cb) {
4934 if (startTransitionImpl2) {
4935 startTransitionImpl2(cb);
4936 } else {
4937 cb();
4938 }
4939}
4940function flushSyncSafe(cb) {
4941 if (flushSyncImpl) {
4942 flushSyncImpl(cb);
4943 } else {
4944 cb();
4945 }
4946}
4947var Deferred = class {
4948 constructor() {
4949 this.status = "pending";
4950 this.promise = new Promise((resolve, reject) => {
4951 this.resolve = (value) => {
4952 if (this.status === "pending") {
4953 this.status = "resolved";
4954 resolve(value);
4955 }
4956 };
4957 this.reject = (reason) => {
4958 if (this.status === "pending") {
4959 this.status = "rejected";
4960 reject(reason);
4961 }
4962 };
4963 });
4964 }
4965};
4966function RouterProvider(_ref) {
4967 let {
4968 fallbackElement,
4969 router,
4970 future
4971 } = _ref;
4972 let [state, setStateImpl] = React2.useState(router.state);
4973 let [pendingState, setPendingState] = React2.useState();
4974 let [vtContext, setVtContext] = React2.useState({
4975 isTransitioning: false
4976 });
4977 let [renderDfd, setRenderDfd] = React2.useState();
4978 let [transition, setTransition] = React2.useState();
4979 let [interruption, setInterruption] = React2.useState();
4980 let fetcherData = React2.useRef(/* @__PURE__ */ new Map());
4981 let {
4982 v7_startTransition
4983 } = future || {};
4984 let optInStartTransition = React2.useCallback((cb) => {
4985 if (v7_startTransition) {
4986 startTransitionSafe(cb);
4987 } else {
4988 cb();
4989 }
4990 }, [v7_startTransition]);
4991 let setState = React2.useCallback((newState, _ref2) => {
4992 let {
4993 deletedFetchers,
4994 unstable_flushSync: flushSync,
4995 unstable_viewTransitionOpts: viewTransitionOpts
4996 } = _ref2;
4997 deletedFetchers.forEach((key) => fetcherData.current.delete(key));
4998 newState.fetchers.forEach((fetcher, key) => {
4999 if (fetcher.data !== void 0) {
5000 fetcherData.current.set(key, fetcher.data);
5001 }
5002 });
5003 let isViewTransitionUnavailable = router.window == null || router.window.document == null || typeof router.window.document.startViewTransition !== "function";
5004 if (!viewTransitionOpts || isViewTransitionUnavailable) {
5005 if (flushSync) {
5006 flushSyncSafe(() => setStateImpl(newState));
5007 } else {
5008 optInStartTransition(() => setStateImpl(newState));
5009 }
5010 return;
5011 }
5012 if (flushSync) {
5013 flushSyncSafe(() => {
5014 if (transition) {
5015 renderDfd && renderDfd.resolve();
5016 transition.skipTransition();
5017 }
5018 setVtContext({
5019 isTransitioning: true,
5020 flushSync: true,
5021 currentLocation: viewTransitionOpts.currentLocation,
5022 nextLocation: viewTransitionOpts.nextLocation
5023 });
5024 });
5025 let t = router.window.document.startViewTransition(() => {
5026 flushSyncSafe(() => setStateImpl(newState));
5027 });
5028 t.finished.finally(() => {
5029 flushSyncSafe(() => {
5030 setRenderDfd(void 0);
5031 setTransition(void 0);
5032 setPendingState(void 0);
5033 setVtContext({
5034 isTransitioning: false
5035 });
5036 });
5037 });
5038 flushSyncSafe(() => setTransition(t));
5039 return;
5040 }
5041 if (transition) {
5042 renderDfd && renderDfd.resolve();
5043 transition.skipTransition();
5044 setInterruption({
5045 state: newState,
5046 currentLocation: viewTransitionOpts.currentLocation,
5047 nextLocation: viewTransitionOpts.nextLocation
5048 });
5049 } else {
5050 setPendingState(newState);
5051 setVtContext({
5052 isTransitioning: true,
5053 flushSync: false,
5054 currentLocation: viewTransitionOpts.currentLocation,
5055 nextLocation: viewTransitionOpts.nextLocation
5056 });
5057 }
5058 }, [router.window, transition, renderDfd, fetcherData, optInStartTransition]);
5059 React2.useLayoutEffect(() => router.subscribe(setState), [router, setState]);
5060 React2.useEffect(() => {
5061 if (vtContext.isTransitioning && !vtContext.flushSync) {
5062 setRenderDfd(new Deferred());
5063 }
5064 }, [vtContext]);
5065 React2.useEffect(() => {
5066 if (renderDfd && pendingState && router.window) {
5067 let newState = pendingState;
5068 let renderPromise = renderDfd.promise;
5069 let transition2 = router.window.document.startViewTransition(async () => {
5070 optInStartTransition(() => setStateImpl(newState));
5071 await renderPromise;
5072 });
5073 transition2.finished.finally(() => {
5074 setRenderDfd(void 0);
5075 setTransition(void 0);
5076 setPendingState(void 0);
5077 setVtContext({
5078 isTransitioning: false
5079 });
5080 });
5081 setTransition(transition2);
5082 }
5083 }, [optInStartTransition, pendingState, renderDfd, router.window]);
5084 React2.useEffect(() => {
5085 if (renderDfd && pendingState && state.location.key === pendingState.location.key) {
5086 renderDfd.resolve();
5087 }
5088 }, [renderDfd, transition, state.location, pendingState]);
5089 React2.useEffect(() => {
5090 if (!vtContext.isTransitioning && interruption) {
5091 setPendingState(interruption.state);
5092 setVtContext({
5093 isTransitioning: true,
5094 flushSync: false,
5095 currentLocation: interruption.currentLocation,
5096 nextLocation: interruption.nextLocation
5097 });
5098 setInterruption(void 0);
5099 }
5100 }, [vtContext.isTransitioning, interruption]);
5101 React2.useEffect(() => {
5102 true ? warning(fallbackElement == null || !router.future.v7_partialHydration, "`<RouterProvider fallbackElement>` is deprecated when using `v7_partialHydration`, use a `HydrateFallback` component instead") : void 0;
5103 }, []);
5104 let navigator = React2.useMemo(() => {
5105 return {
5106 createHref: router.createHref,
5107 encodeLocation: router.encodeLocation,
5108 go: (n) => router.navigate(n),
5109 push: (to, state2, opts) => router.navigate(to, {
5110 state: state2,
5111 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
5112 }),
5113 replace: (to, state2, opts) => router.navigate(to, {
5114 replace: true,
5115 state: state2,
5116 preventScrollReset: opts == null ? void 0 : opts.preventScrollReset
5117 })
5118 };
5119 }, [router]);
5120 let basename = router.basename || "/";
5121 let dataRouterContext = React2.useMemo(() => ({
5122 router,
5123 navigator,
5124 static: false,
5125 basename
5126 }), [router, navigator, basename]);
5127 let routerFuture = React2.useMemo(() => ({
5128 v7_relativeSplatPath: router.future.v7_relativeSplatPath
5129 }), [router.future.v7_relativeSplatPath]);
5130 return React2.createElement(React2.Fragment, null, React2.createElement(DataRouterContext.Provider, {
5131 value: dataRouterContext
5132 }, React2.createElement(DataRouterStateContext.Provider, {
5133 value: state
5134 }, React2.createElement(FetchersContext.Provider, {
5135 value: fetcherData.current
5136 }, React2.createElement(ViewTransitionContext.Provider, {
5137 value: vtContext
5138 }, React2.createElement(Router, {
5139 basename,
5140 location: state.location,
5141 navigationType: state.historyAction,
5142 navigator,
5143 future: routerFuture
5144 }, state.initialized || router.future.v7_partialHydration ? React2.createElement(MemoizedDataRoutes, {
5145 routes: router.routes,
5146 future: router.future,
5147 state
5148 }) : fallbackElement))))), null);
5149}
5150var MemoizedDataRoutes = React2.memo(DataRoutes);
5151function DataRoutes(_ref3) {
5152 let {
5153 routes,
5154 future,
5155 state
5156 } = _ref3;
5157 return useRoutesImpl(routes, void 0, state, future);
5158}
5159function BrowserRouter(_ref4) {
5160 let {
5161 basename,
5162 children,
5163 future,
5164 window: window2
5165 } = _ref4;
5166 let historyRef = React2.useRef();
5167 if (historyRef.current == null) {
5168 historyRef.current = createBrowserHistory({
5169 window: window2,
5170 v5Compat: true
5171 });
5172 }
5173 let history = historyRef.current;
5174 let [state, setStateImpl] = React2.useState({
5175 action: history.action,
5176 location: history.location
5177 });
5178 let {
5179 v7_startTransition
5180 } = future || {};
5181 let setState = React2.useCallback((newState) => {
5182 v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
5183 }, [setStateImpl, v7_startTransition]);
5184 React2.useLayoutEffect(() => history.listen(setState), [history, setState]);
5185 return React2.createElement(Router, {
5186 basename,
5187 children,
5188 location: state.location,
5189 navigationType: state.action,
5190 navigator: history,
5191 future
5192 });
5193}
5194function HashRouter(_ref5) {
5195 let {
5196 basename,
5197 children,
5198 future,
5199 window: window2
5200 } = _ref5;
5201 let historyRef = React2.useRef();
5202 if (historyRef.current == null) {
5203 historyRef.current = createHashHistory({
5204 window: window2,
5205 v5Compat: true
5206 });
5207 }
5208 let history = historyRef.current;
5209 let [state, setStateImpl] = React2.useState({
5210 action: history.action,
5211 location: history.location
5212 });
5213 let {
5214 v7_startTransition
5215 } = future || {};
5216 let setState = React2.useCallback((newState) => {
5217 v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
5218 }, [setStateImpl, v7_startTransition]);
5219 React2.useLayoutEffect(() => history.listen(setState), [history, setState]);
5220 return React2.createElement(Router, {
5221 basename,
5222 children,
5223 location: state.location,
5224 navigationType: state.action,
5225 navigator: history,
5226 future
5227 });
5228}
5229function HistoryRouter(_ref6) {
5230 let {
5231 basename,
5232 children,
5233 future,
5234 history
5235 } = _ref6;
5236 let [state, setStateImpl] = React2.useState({
5237 action: history.action,
5238 location: history.location
5239 });
5240 let {
5241 v7_startTransition
5242 } = future || {};
5243 let setState = React2.useCallback((newState) => {
5244 v7_startTransition && startTransitionImpl2 ? startTransitionImpl2(() => setStateImpl(newState)) : setStateImpl(newState);
5245 }, [setStateImpl, v7_startTransition]);
5246 React2.useLayoutEffect(() => history.listen(setState), [history, setState]);
5247 return React2.createElement(Router, {
5248 basename,
5249 children,
5250 location: state.location,
5251 navigationType: state.action,
5252 navigator: history,
5253 future
5254 });
5255}
5256if (true) {
5257 HistoryRouter.displayName = "unstable_HistoryRouter";
5258}
5259var isBrowser = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
5260var ABSOLUTE_URL_REGEX2 = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
5261var Link = React2.forwardRef(function LinkWithRef(_ref7, ref) {
5262 let {
5263 onClick,
5264 relative,
5265 reloadDocument,
5266 replace: replace2,
5267 state,
5268 target,
5269 to,
5270 preventScrollReset,
5271 unstable_viewTransition
5272 } = _ref7, rest = _objectWithoutPropertiesLoose(_ref7, _excluded);
5273 let {
5274 basename
5275 } = React2.useContext(NavigationContext);
5276 let absoluteHref;
5277 let isExternal = false;
5278 if (typeof to === "string" && ABSOLUTE_URL_REGEX2.test(to)) {
5279 absoluteHref = to;
5280 if (isBrowser) {
5281 try {
5282 let currentUrl = new URL(window.location.href);
5283 let targetUrl = to.startsWith("//") ? new URL(currentUrl.protocol + to) : new URL(to);
5284 let path = stripBasename(targetUrl.pathname, basename);
5285 if (targetUrl.origin === currentUrl.origin && path != null) {
5286 to = path + targetUrl.search + targetUrl.hash;
5287 } else {
5288 isExternal = true;
5289 }
5290 } catch (e) {
5291 true ? warning(false, '<Link to="' + to + '"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.') : void 0;
5292 }
5293 }
5294 }
5295 let href = useHref(to, {
5296 relative
5297 });
5298 let internalOnClick = useLinkClickHandler(to, {
5299 replace: replace2,
5300 state,
5301 target,
5302 preventScrollReset,
5303 relative,
5304 unstable_viewTransition
5305 });
5306 function handleClick(event) {
5307 if (onClick) onClick(event);
5308 if (!event.defaultPrevented) {
5309 internalOnClick(event);
5310 }
5311 }
5312 return (
5313 // eslint-disable-next-line jsx-a11y/anchor-has-content
5314 React2.createElement("a", _extends3({}, rest, {
5315 href: absoluteHref || href,
5316 onClick: isExternal || reloadDocument ? onClick : handleClick,
5317 ref,
5318 target
5319 }))
5320 );
5321});
5322if (true) {
5323 Link.displayName = "Link";
5324}
5325var NavLink = React2.forwardRef(function NavLinkWithRef(_ref8, ref) {
5326 let {
5327 "aria-current": ariaCurrentProp = "page",
5328 caseSensitive = false,
5329 className: classNameProp = "",
5330 end = false,
5331 style: styleProp,
5332 to,
5333 unstable_viewTransition,
5334 children
5335 } = _ref8, rest = _objectWithoutPropertiesLoose(_ref8, _excluded2);
5336 let path = useResolvedPath(to, {
5337 relative: rest.relative
5338 });
5339 let location = useLocation();
5340 let routerState = React2.useContext(DataRouterStateContext);
5341 let {
5342 navigator,
5343 basename
5344 } = React2.useContext(NavigationContext);
5345 let isTransitioning = routerState != null && // Conditional usage is OK here because the usage of a data router is static
5346 // eslint-disable-next-line react-hooks/rules-of-hooks
5347 useViewTransitionState(path) && unstable_viewTransition === true;
5348 let toPathname = navigator.encodeLocation ? navigator.encodeLocation(path).pathname : path.pathname;
5349 let locationPathname = location.pathname;
5350 let nextLocationPathname = routerState && routerState.navigation && routerState.navigation.location ? routerState.navigation.location.pathname : null;
5351 if (!caseSensitive) {
5352 locationPathname = locationPathname.toLowerCase();
5353 nextLocationPathname = nextLocationPathname ? nextLocationPathname.toLowerCase() : null;
5354 toPathname = toPathname.toLowerCase();
5355 }
5356 if (nextLocationPathname && basename) {
5357 nextLocationPathname = stripBasename(nextLocationPathname, basename) || nextLocationPathname;
5358 }
5359 const endSlashPosition = toPathname !== "/" && toPathname.endsWith("/") ? toPathname.length - 1 : toPathname.length;
5360 let isActive = locationPathname === toPathname || !end && locationPathname.startsWith(toPathname) && locationPathname.charAt(endSlashPosition) === "/";
5361 let isPending = nextLocationPathname != null && (nextLocationPathname === toPathname || !end && nextLocationPathname.startsWith(toPathname) && nextLocationPathname.charAt(toPathname.length) === "/");
5362 let renderProps = {
5363 isActive,
5364 isPending,
5365 isTransitioning
5366 };
5367 let ariaCurrent = isActive ? ariaCurrentProp : void 0;
5368 let className;
5369 if (typeof classNameProp === "function") {
5370 className = classNameProp(renderProps);
5371 } else {
5372 className = [classNameProp, isActive ? "active" : null, isPending ? "pending" : null, isTransitioning ? "transitioning" : null].filter(Boolean).join(" ");
5373 }
5374 let style = typeof styleProp === "function" ? styleProp(renderProps) : styleProp;
5375 return React2.createElement(Link, _extends3({}, rest, {
5376 "aria-current": ariaCurrent,
5377 className,
5378 ref,
5379 style,
5380 to,
5381 unstable_viewTransition
5382 }), typeof children === "function" ? children(renderProps) : children);
5383});
5384if (true) {
5385 NavLink.displayName = "NavLink";
5386}
5387var Form = React2.forwardRef((_ref9, forwardedRef) => {
5388 let {
5389 fetcherKey,
5390 navigate,
5391 reloadDocument,
5392 replace: replace2,
5393 state,
5394 method = defaultMethod,
5395 action,
5396 onSubmit,
5397 relative,
5398 preventScrollReset,
5399 unstable_viewTransition
5400 } = _ref9, props = _objectWithoutPropertiesLoose(_ref9, _excluded3);
5401 let submit = useSubmit();
5402 let formAction = useFormAction(action, {
5403 relative
5404 });
5405 let formMethod = method.toLowerCase() === "get" ? "get" : "post";
5406 let submitHandler = (event) => {
5407 onSubmit && onSubmit(event);
5408 if (event.defaultPrevented) return;
5409 event.preventDefault();
5410 let submitter = event.nativeEvent.submitter;
5411 let submitMethod = (submitter == null ? void 0 : submitter.getAttribute("formmethod")) || method;
5412 submit(submitter || event.currentTarget, {
5413 fetcherKey,
5414 method: submitMethod,
5415 navigate,
5416 replace: replace2,
5417 state,
5418 relative,
5419 preventScrollReset,
5420 unstable_viewTransition
5421 });
5422 };
5423 return React2.createElement("form", _extends3({
5424 ref: forwardedRef,
5425 method: formMethod,
5426 action: formAction,
5427 onSubmit: reloadDocument ? onSubmit : submitHandler
5428 }, props));
5429});
5430if (true) {
5431 Form.displayName = "Form";
5432}
5433function ScrollRestoration(_ref10) {
5434 let {
5435 getKey,
5436 storageKey
5437 } = _ref10;
5438 useScrollRestoration({
5439 getKey,
5440 storageKey
5441 });
5442 return null;
5443}
5444if (true) {
5445 ScrollRestoration.displayName = "ScrollRestoration";
5446}
5447var DataRouterHook2;
5448(function(DataRouterHook3) {
5449 DataRouterHook3["UseScrollRestoration"] = "useScrollRestoration";
5450 DataRouterHook3["UseSubmit"] = "useSubmit";
5451 DataRouterHook3["UseSubmitFetcher"] = "useSubmitFetcher";
5452 DataRouterHook3["UseFetcher"] = "useFetcher";
5453 DataRouterHook3["useViewTransitionState"] = "useViewTransitionState";
5454})(DataRouterHook2 || (DataRouterHook2 = {}));
5455var DataRouterStateHook2;
5456(function(DataRouterStateHook3) {
5457 DataRouterStateHook3["UseFetcher"] = "useFetcher";
5458 DataRouterStateHook3["UseFetchers"] = "useFetchers";
5459 DataRouterStateHook3["UseScrollRestoration"] = "useScrollRestoration";
5460})(DataRouterStateHook2 || (DataRouterStateHook2 = {}));
5461function getDataRouterConsoleError2(hookName) {
5462 return hookName + " must be used within a data router. See https://reactrouter.com/routers/picking-a-router.";
5463}
5464function useDataRouterContext2(hookName) {
5465 let ctx = React2.useContext(DataRouterContext);
5466 !ctx ? true ? invariant(false, getDataRouterConsoleError2(hookName)) : invariant(false) : void 0;
5467 return ctx;
5468}
5469function useDataRouterState2(hookName) {
5470 let state = React2.useContext(DataRouterStateContext);
5471 !state ? true ? invariant(false, getDataRouterConsoleError2(hookName)) : invariant(false) : void 0;
5472 return state;
5473}
5474function useLinkClickHandler(to, _temp) {
5475 let {
5476 target,
5477 replace: replaceProp,
5478 state,
5479 preventScrollReset,
5480 relative,
5481 unstable_viewTransition
5482 } = _temp === void 0 ? {} : _temp;
5483 let navigate = useNavigate();
5484 let location = useLocation();
5485 let path = useResolvedPath(to, {
5486 relative
5487 });
5488 return React2.useCallback((event) => {
5489 if (shouldProcessLinkClick(event, target)) {
5490 event.preventDefault();
5491 let replace2 = replaceProp !== void 0 ? replaceProp : createPath(location) === createPath(path);
5492 navigate(to, {
5493 replace: replace2,
5494 state,
5495 preventScrollReset,
5496 relative,
5497 unstable_viewTransition
5498 });
5499 }
5500 }, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, unstable_viewTransition]);
5501}
5502function useSearchParams(defaultInit) {
5503 true ? warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.") : void 0;
5504 let defaultSearchParamsRef = React2.useRef(createSearchParams(defaultInit));
5505 let hasSetSearchParamsRef = React2.useRef(false);
5506 let location = useLocation();
5507 let searchParams = React2.useMemo(() => (
5508 // Only merge in the defaults if we haven't yet called setSearchParams.
5509 // Once we call that we want those to take precedence, otherwise you can't
5510 // remove a param with setSearchParams({}) if it has an initial value
5511 getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
5512 ), [location.search]);
5513 let navigate = useNavigate();
5514 let setSearchParams = React2.useCallback((nextInit, navigateOptions) => {
5515 const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
5516 hasSetSearchParamsRef.current = true;
5517 navigate("?" + newSearchParams, navigateOptions);
5518 }, [navigate, searchParams]);
5519 return [searchParams, setSearchParams];
5520}
5521function validateClientSideSubmission() {
5522 if (typeof document === "undefined") {
5523 throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
5524 }
5525}
5526var fetcherId = 0;
5527var getUniqueFetcherId = () => "__" + String(++fetcherId) + "__";
5528function useSubmit() {
5529 let {
5530 router
5531 } = useDataRouterContext2(DataRouterHook2.UseSubmit);
5532 let {
5533 basename
5534 } = React2.useContext(NavigationContext);
5535 let currentRouteId = useRouteId();
5536 return React2.useCallback(function(target, options) {
5537 if (options === void 0) {
5538 options = {};
5539 }
5540 validateClientSideSubmission();
5541 let {
5542 action,
5543 method,
5544 encType,
5545 formData,
5546 body
5547 } = getFormSubmissionInfo(target, basename);
5548 if (options.navigate === false) {
5549 let key = options.fetcherKey || getUniqueFetcherId();
5550 router.fetch(key, currentRouteId, options.action || action, {
5551 preventScrollReset: options.preventScrollReset,
5552 formData,
5553 body,
5554 formMethod: options.method || method,
5555 formEncType: options.encType || encType,
5556 unstable_flushSync: options.unstable_flushSync
5557 });
5558 } else {
5559 router.navigate(options.action || action, {
5560 preventScrollReset: options.preventScrollReset,
5561 formData,
5562 body,
5563 formMethod: options.method || method,
5564 formEncType: options.encType || encType,
5565 replace: options.replace,
5566 state: options.state,
5567 fromRouteId: currentRouteId,
5568 unstable_flushSync: options.unstable_flushSync,
5569 unstable_viewTransition: options.unstable_viewTransition
5570 });
5571 }
5572 }, [router, basename, currentRouteId]);
5573}
5574function useFormAction(action, _temp2) {
5575 let {
5576 relative
5577 } = _temp2 === void 0 ? {} : _temp2;
5578 let {
5579 basename
5580 } = React2.useContext(NavigationContext);
5581 let routeContext = React2.useContext(RouteContext);
5582 !routeContext ? true ? invariant(false, "useFormAction must be used inside a RouteContext") : invariant(false) : void 0;
5583 let [match] = routeContext.matches.slice(-1);
5584 let path = _extends3({}, useResolvedPath(action ? action : ".", {
5585 relative
5586 }));
5587 let location = useLocation();
5588 if (action == null) {
5589 path.search = location.search;
5590 let params = new URLSearchParams(path.search);
5591 if (params.has("index") && params.get("index") === "") {
5592 params.delete("index");
5593 path.search = params.toString() ? "?" + params.toString() : "";
5594 }
5595 }
5596 if ((!action || action === ".") && match.route.index) {
5597 path.search = path.search ? path.search.replace(/^\?/, "?index&") : "?index";
5598 }
5599 if (basename !== "/") {
5600 path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
5601 }
5602 return createPath(path);
5603}
5604function useFetcher(_temp3) {
5605 var _route$matches;
5606 let {
5607 key
5608 } = _temp3 === void 0 ? {} : _temp3;
5609 let {
5610 router
5611 } = useDataRouterContext2(DataRouterHook2.UseFetcher);
5612 let state = useDataRouterState2(DataRouterStateHook2.UseFetcher);
5613 let fetcherData = React2.useContext(FetchersContext);
5614 let route = React2.useContext(RouteContext);
5615 let routeId = (_route$matches = route.matches[route.matches.length - 1]) == null ? void 0 : _route$matches.route.id;
5616 !fetcherData ? true ? invariant(false, "useFetcher must be used inside a FetchersContext") : invariant(false) : void 0;
5617 !route ? true ? invariant(false, "useFetcher must be used inside a RouteContext") : invariant(false) : void 0;
5618 !(routeId != null) ? true ? invariant(false, 'useFetcher can only be used on routes that contain a unique "id"') : invariant(false) : void 0;
5619 let defaultKey = useIdImpl ? useIdImpl() : "";
5620 let [fetcherKey, setFetcherKey] = React2.useState(key || defaultKey);
5621 if (key && key !== fetcherKey) {
5622 setFetcherKey(key);
5623 } else if (!fetcherKey) {
5624 setFetcherKey(getUniqueFetcherId());
5625 }
5626 React2.useEffect(() => {
5627 router.getFetcher(fetcherKey);
5628 return () => {
5629 router.deleteFetcher(fetcherKey);
5630 };
5631 }, [router, fetcherKey]);
5632 let load = React2.useCallback((href, opts) => {
5633 !routeId ? true ? invariant(false, "No routeId available for fetcher.load()") : invariant(false) : void 0;
5634 router.fetch(fetcherKey, routeId, href, opts);
5635 }, [fetcherKey, routeId, router]);
5636 let submitImpl = useSubmit();
5637 let submit = React2.useCallback((target, opts) => {
5638 submitImpl(target, _extends3({}, opts, {
5639 navigate: false,
5640 fetcherKey
5641 }));
5642 }, [fetcherKey, submitImpl]);
5643 let FetcherForm = React2.useMemo(() => {
5644 let FetcherForm2 = React2.forwardRef((props, ref) => {
5645 return React2.createElement(Form, _extends3({}, props, {
5646 navigate: false,
5647 fetcherKey,
5648 ref
5649 }));
5650 });
5651 if (true) {
5652 FetcherForm2.displayName = "fetcher.Form";
5653 }
5654 return FetcherForm2;
5655 }, [fetcherKey]);
5656 let fetcher = state.fetchers.get(fetcherKey) || IDLE_FETCHER;
5657 let data = fetcherData.get(fetcherKey);
5658 let fetcherWithComponents = React2.useMemo(() => _extends3({
5659 Form: FetcherForm,
5660 submit,
5661 load
5662 }, fetcher, {
5663 data
5664 }), [FetcherForm, submit, load, fetcher, data]);
5665 return fetcherWithComponents;
5666}
5667function useFetchers() {
5668 let state = useDataRouterState2(DataRouterStateHook2.UseFetchers);
5669 return Array.from(state.fetchers.entries()).map((_ref11) => {
5670 let [key, fetcher] = _ref11;
5671 return _extends3({}, fetcher, {
5672 key
5673 });
5674 });
5675}
5676var SCROLL_RESTORATION_STORAGE_KEY = "react-router-scroll-positions";
5677var savedScrollPositions = {};
5678function useScrollRestoration(_temp4) {
5679 let {
5680 getKey,
5681 storageKey
5682 } = _temp4 === void 0 ? {} : _temp4;
5683 let {
5684 router
5685 } = useDataRouterContext2(DataRouterHook2.UseScrollRestoration);
5686 let {
5687 restoreScrollPosition,
5688 preventScrollReset
5689 } = useDataRouterState2(DataRouterStateHook2.UseScrollRestoration);
5690 let {
5691 basename
5692 } = React2.useContext(NavigationContext);
5693 let location = useLocation();
5694 let matches = useMatches();
5695 let navigation = useNavigation();
5696 React2.useEffect(() => {
5697 window.history.scrollRestoration = "manual";
5698 return () => {
5699 window.history.scrollRestoration = "auto";
5700 };
5701 }, []);
5702 usePageHide(React2.useCallback(() => {
5703 if (navigation.state === "idle") {
5704 let key = (getKey ? getKey(location, matches) : null) || location.key;
5705 savedScrollPositions[key] = window.scrollY;
5706 }
5707 try {
5708 sessionStorage.setItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY, JSON.stringify(savedScrollPositions));
5709 } catch (error) {
5710 true ? warning(false, "Failed to save scroll positions in sessionStorage, <ScrollRestoration /> will not work properly (" + error + ").") : void 0;
5711 }
5712 window.history.scrollRestoration = "auto";
5713 }, [storageKey, getKey, navigation.state, location, matches]));
5714 if (typeof document !== "undefined") {
5715 React2.useLayoutEffect(() => {
5716 try {
5717 let sessionPositions = sessionStorage.getItem(storageKey || SCROLL_RESTORATION_STORAGE_KEY);
5718 if (sessionPositions) {
5719 savedScrollPositions = JSON.parse(sessionPositions);
5720 }
5721 } catch (e) {
5722 }
5723 }, [storageKey]);
5724 React2.useLayoutEffect(() => {
5725 let getKeyWithoutBasename = getKey && basename !== "/" ? (location2, matches2) => getKey(
5726 // Strip the basename to match useLocation()
5727 _extends3({}, location2, {
5728 pathname: stripBasename(location2.pathname, basename) || location2.pathname
5729 }),
5730 matches2
5731 ) : getKey;
5732 let disableScrollRestoration = router == null ? void 0 : router.enableScrollRestoration(savedScrollPositions, () => window.scrollY, getKeyWithoutBasename);
5733 return () => disableScrollRestoration && disableScrollRestoration();
5734 }, [router, basename, getKey]);
5735 React2.useLayoutEffect(() => {
5736 if (restoreScrollPosition === false) {
5737 return;
5738 }
5739 if (typeof restoreScrollPosition === "number") {
5740 window.scrollTo(0, restoreScrollPosition);
5741 return;
5742 }
5743 if (location.hash) {
5744 let el = document.getElementById(decodeURIComponent(location.hash.slice(1)));
5745 if (el) {
5746 el.scrollIntoView();
5747 return;
5748 }
5749 }
5750 if (preventScrollReset === true) {
5751 return;
5752 }
5753 window.scrollTo(0, 0);
5754 }, [location, restoreScrollPosition, preventScrollReset]);
5755 }
5756}
5757function useBeforeUnload(callback, options) {
5758 let {
5759 capture
5760 } = options || {};
5761 React2.useEffect(() => {
5762 let opts = capture != null ? {
5763 capture
5764 } : void 0;
5765 window.addEventListener("beforeunload", callback, opts);
5766 return () => {
5767 window.removeEventListener("beforeunload", callback, opts);
5768 };
5769 }, [callback, capture]);
5770}
5771function usePageHide(callback, options) {
5772 let {
5773 capture
5774 } = options || {};
5775 React2.useEffect(() => {
5776 let opts = capture != null ? {
5777 capture
5778 } : void 0;
5779 window.addEventListener("pagehide", callback, opts);
5780 return () => {
5781 window.removeEventListener("pagehide", callback, opts);
5782 };
5783 }, [callback, capture]);
5784}
5785function usePrompt(_ref12) {
5786 let {
5787 when,
5788 message
5789 } = _ref12;
5790 let blocker = useBlocker(when);
5791 React2.useEffect(() => {
5792 if (blocker.state === "blocked") {
5793 let proceed = window.confirm(message);
5794 if (proceed) {
5795 setTimeout(blocker.proceed, 0);
5796 } else {
5797 blocker.reset();
5798 }
5799 }
5800 }, [blocker, message]);
5801 React2.useEffect(() => {
5802 if (blocker.state === "blocked" && !when) {
5803 blocker.reset();
5804 }
5805 }, [blocker, when]);
5806}
5807function useViewTransitionState(to, opts) {
5808 if (opts === void 0) {
5809 opts = {};
5810 }
5811 let vtContext = React2.useContext(ViewTransitionContext);
5812 !(vtContext != null) ? true ? invariant(false, "`unstable_useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?") : invariant(false) : void 0;
5813 let {
5814 basename
5815 } = useDataRouterContext2(DataRouterHook2.useViewTransitionState);
5816 let path = useResolvedPath(to, {
5817 relative: opts.relative
5818 });
5819 if (!vtContext.isTransitioning) {
5820 return false;
5821 }
5822 let currentPath = stripBasename(vtContext.currentLocation.pathname, basename) || vtContext.currentLocation.pathname;
5823 let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
5824 return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
5825}
5826export {
5827 AbortedDeferredError,
5828 Await,
5829 BrowserRouter,
5830 Form,
5831 HashRouter,
5832 Link,
5833 MemoryRouter,
5834 NavLink,
5835 Navigate,
5836 Action as NavigationType,
5837 Outlet,
5838 Route,
5839 Router,
5840 RouterProvider,
5841 Routes,
5842 ScrollRestoration,
5843 DataRouterContext as UNSAFE_DataRouterContext,
5844 DataRouterStateContext as UNSAFE_DataRouterStateContext,
5845 ErrorResponseImpl as UNSAFE_ErrorResponseImpl,
5846 FetchersContext as UNSAFE_FetchersContext,
5847 LocationContext as UNSAFE_LocationContext,
5848 NavigationContext as UNSAFE_NavigationContext,
5849 RouteContext as UNSAFE_RouteContext,
5850 ViewTransitionContext as UNSAFE_ViewTransitionContext,
5851 useRouteId as UNSAFE_useRouteId,
5852 useScrollRestoration as UNSAFE_useScrollRestoration,
5853 createBrowserRouter,
5854 createHashRouter,
5855 createMemoryRouter,
5856 createPath,
5857 createRoutesFromChildren,
5858 createRoutesFromChildren as createRoutesFromElements,
5859 createSearchParams,
5860 defer,
5861 generatePath,
5862 isRouteErrorResponse,
5863 json,
5864 matchPath,
5865 matchRoutes,
5866 parsePath,
5867 redirect,
5868 redirectDocument,
5869 renderMatches,
5870 replace,
5871 resolvePath,
5872 HistoryRouter as unstable_HistoryRouter,
5873 usePrompt as unstable_usePrompt,
5874 useViewTransitionState as unstable_useViewTransitionState,
5875 useActionData,
5876 useAsyncError,
5877 useAsyncValue,
5878 useBeforeUnload,
5879 useBlocker,
5880 useFetcher,
5881 useFetchers,
5882 useFormAction,
5883 useHref,
5884 useInRouterContext,
5885 useLinkClickHandler,
5886 useLoaderData,
5887 useLocation,
5888 useMatch,
5889 useMatches,
5890 useNavigate,
5891 useNavigation,
5892 useNavigationType,
5893 useOutlet,
5894 useOutletContext,
5895 useParams,
5896 useResolvedPath,
5897 useRevalidator,
5898 useRouteError,
5899 useRouteLoaderData,
5900 useRoutes,
5901 useSearchParams,
5902 useSubmit
5903};
5904/*! Bundled license information:
5905
5906@remix-run/router/dist/router.js:
5907 (**
5908 * @remix-run/router v1.19.0
5909 *
5910 * Copyright (c) Remix Software Inc.
5911 *
5912 * This source code is licensed under the MIT license found in the
5913 * LICENSE.md file in the root directory of this source tree.
5914 *
5915 * @license MIT
5916 *)
5917
5918react-router/dist/index.js:
5919 (**
5920 * React Router v6.26.0
5921 *
5922 * Copyright (c) Remix Software Inc.
5923 *
5924 * This source code is licensed under the MIT license found in the
5925 * LICENSE.md file in the root directory of this source tree.
5926 *
5927 * @license MIT
5928 *)
5929
5930react-router-dom/dist/index.js:
5931 (**
5932 * React Router DOM v6.26.0
5933 *
5934 * Copyright (c) Remix Software Inc.
5935 *
5936 * This source code is licensed under the MIT license found in the
5937 * LICENSE.md file in the root directory of this source tree.
5938 *
5939 * @license MIT
5940 *)
5941*/
5942//# sourceMappingURL=react-router-dom.js.map
Note: See TracBrowser for help on using the repository browser.