| 1 |  | 
| 2 |  | 
| 3 |  | 
| 4 |  | 
| 5 |  | 
| 6 |  | 
| 7 |  | 
| 8 |  | 
| 9 |  | 
| 10 | 
 | 
| 11 | import { UNSAFE_invariant, joinPaths, matchPath, UNSAFE_getPathContributingMatches, UNSAFE_warning, resolveTo, parsePath, matchRoutes, Action, isRouteErrorResponse, createMemoryHistory, stripBasename, AbortedDeferredError, createRouter } from '@remix-run/router';
 | 
| 12 | export { AbortedDeferredError, Action as NavigationType, createPath, defer, generatePath, isRouteErrorResponse, json, matchPath, matchRoutes, parsePath, redirect, resolvePath } from '@remix-run/router';
 | 
| 13 | import * as React from 'react';
 | 
| 14 | 
 | 
| 15 |  | 
| 16 |  | 
| 17 |  | 
| 18 |  | 
| 19 |  | 
| 20 | 
 | 
| 21 |  | 
| 22 |  | 
| 23 |  | 
| 24 | 
 | 
| 25 | 
 | 
| 26 | function isPolyfill(x, y) {
 | 
| 27 |   return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y 
 | 
| 28 |   ;
 | 
| 29 | }
 | 
| 30 | 
 | 
| 31 | const is = typeof Object.is === "function" ? Object.is : isPolyfill; 
 | 
| 32 | 
 | 
| 33 | 
 | 
| 34 | const {
 | 
| 35 |   useState,
 | 
| 36 |   useEffect,
 | 
| 37 |   useLayoutEffect,
 | 
| 38 |   useDebugValue
 | 
| 39 | } = React;
 | 
| 40 | let didWarnOld18Alpha = false;
 | 
| 41 | let didWarnUncachedGetSnapshot = false; 
 | 
| 42 | 
 | 
| 43 | 
 | 
| 44 | 
 | 
| 45 | 
 | 
| 46 | 
 | 
| 47 | 
 | 
| 48 | 
 | 
| 49 | 
 | 
| 50 | 
 | 
| 51 | 
 | 
| 52 | function useSyncExternalStore$2(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
 | 
| 53 | // React do not expose a way to check if we're hydrating. So users of the shim
 | 
| 54 | 
 | 
| 55 | 
 | 
| 56 | getServerSnapshot) {
 | 
| 57 |   {
 | 
| 58 |     if (!didWarnOld18Alpha) {
 | 
| 59 |       if ("startTransition" in React) {
 | 
| 60 |         didWarnOld18Alpha = true;
 | 
| 61 |         console.error("You are using an outdated, pre-release alpha of React 18 that " + "does not support useSyncExternalStore. The " + "use-sync-external-store shim will not work correctly. Upgrade " + "to a newer pre-release.");
 | 
| 62 |       }
 | 
| 63 |     }
 | 
| 64 |   } 
 | 
| 65 |   
 | 
| 66 |   
 | 
| 67 |   
 | 
| 68 | 
 | 
| 69 | 
 | 
| 70 |   const value = getSnapshot();
 | 
| 71 | 
 | 
| 72 |   {
 | 
| 73 |     if (!didWarnUncachedGetSnapshot) {
 | 
| 74 |       const cachedValue = getSnapshot();
 | 
| 75 | 
 | 
| 76 |       if (!is(value, cachedValue)) {
 | 
| 77 |         console.error("The result of getSnapshot should be cached to avoid an infinite loop");
 | 
| 78 |         didWarnUncachedGetSnapshot = true;
 | 
| 79 |       }
 | 
| 80 |     }
 | 
| 81 |   } 
 | 
| 82 |   
 | 
| 83 |   
 | 
| 84 |   
 | 
| 85 |   
 | 
| 86 |   
 | 
| 87 |   
 | 
| 88 |   
 | 
| 89 |   
 | 
| 90 |   
 | 
| 91 |   
 | 
| 92 |   
 | 
| 93 |   
 | 
| 94 |   
 | 
| 95 | 
 | 
| 96 | 
 | 
| 97 |   const [{
 | 
| 98 |     inst
 | 
| 99 |   }, forceUpdate] = useState({
 | 
| 100 |     inst: {
 | 
| 101 |       value,
 | 
| 102 |       getSnapshot
 | 
| 103 |     }
 | 
| 104 |   }); 
 | 
| 105 |   
 | 
| 106 |   
 | 
| 107 | 
 | 
| 108 |   useLayoutEffect(() => {
 | 
| 109 |     inst.value = value;
 | 
| 110 |     inst.getSnapshot = getSnapshot; 
 | 
| 111 |     
 | 
| 112 |     
 | 
| 113 |     
 | 
| 114 | 
 | 
| 115 |     if (checkIfSnapshotChanged(inst)) {
 | 
| 116 |       
 | 
| 117 |       forceUpdate({
 | 
| 118 |         inst
 | 
| 119 |       });
 | 
| 120 |     } 
 | 
| 121 | 
 | 
| 122 |   }, [subscribe, value, getSnapshot]);
 | 
| 123 |   useEffect(() => {
 | 
| 124 |     
 | 
| 125 |     
 | 
| 126 |     if (checkIfSnapshotChanged(inst)) {
 | 
| 127 |       
 | 
| 128 |       forceUpdate({
 | 
| 129 |         inst
 | 
| 130 |       });
 | 
| 131 |     }
 | 
| 132 | 
 | 
| 133 |     const handleStoreChange = () => {
 | 
| 134 |       
 | 
| 135 |       
 | 
| 136 |       
 | 
| 137 |       
 | 
| 138 |       
 | 
| 139 |       
 | 
| 140 |       if (checkIfSnapshotChanged(inst)) {
 | 
| 141 |         
 | 
| 142 |         forceUpdate({
 | 
| 143 |           inst
 | 
| 144 |         });
 | 
| 145 |       }
 | 
| 146 |     }; 
 | 
| 147 | 
 | 
| 148 | 
 | 
| 149 |     return subscribe(handleStoreChange); 
 | 
| 150 |   }, [subscribe]);
 | 
| 151 |   useDebugValue(value);
 | 
| 152 |   return value;
 | 
| 153 | }
 | 
| 154 | 
 | 
| 155 | function checkIfSnapshotChanged(inst) {
 | 
| 156 |   const latestGetSnapshot = inst.getSnapshot;
 | 
| 157 |   const prevValue = inst.value;
 | 
| 158 | 
 | 
| 159 |   try {
 | 
| 160 |     const nextValue = latestGetSnapshot();
 | 
| 161 |     return !is(prevValue, nextValue);
 | 
| 162 |   } catch (error) {
 | 
| 163 |     return true;
 | 
| 164 |   }
 | 
| 165 | }
 | 
| 166 | 
 | 
| 167 |  | 
| 168 |  | 
| 169 |  | 
| 170 |  | 
| 171 |  | 
| 172 |  | 
| 173 |  | 
| 174 | 
 | 
| 175 | function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
 | 
| 176 |   
 | 
| 177 |   
 | 
| 178 |   
 | 
| 179 |   
 | 
| 180 |   return getSnapshot();
 | 
| 181 | }
 | 
| 182 | 
 | 
| 183 |  | 
| 184 |  | 
| 185 |  | 
| 186 |  | 
| 187 | 
 | 
| 188 | const canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
 | 
| 189 | const isServerEnvironment = !canUseDOM;
 | 
| 190 | const shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore$2;
 | 
| 191 | const useSyncExternalStore = "useSyncExternalStore" in React ? (module => module.useSyncExternalStore)(React) : shim;
 | 
| 192 | 
 | 
| 193 | const DataRouterContext = React.createContext(null);
 | 
| 194 | 
 | 
| 195 | {
 | 
| 196 |   DataRouterContext.displayName = "DataRouter";
 | 
| 197 | }
 | 
| 198 | 
 | 
| 199 | const DataRouterStateContext = React.createContext(null);
 | 
| 200 | 
 | 
| 201 | {
 | 
| 202 |   DataRouterStateContext.displayName = "DataRouterState";
 | 
| 203 | }
 | 
| 204 | 
 | 
| 205 | const AwaitContext = React.createContext(null);
 | 
| 206 | 
 | 
| 207 | {
 | 
| 208 |   AwaitContext.displayName = "Await";
 | 
| 209 | }
 | 
| 210 | 
 | 
| 211 | const NavigationContext = React.createContext(null);
 | 
| 212 | 
 | 
| 213 | {
 | 
| 214 |   NavigationContext.displayName = "Navigation";
 | 
| 215 | }
 | 
| 216 | 
 | 
| 217 | const LocationContext = React.createContext(null);
 | 
| 218 | 
 | 
| 219 | {
 | 
| 220 |   LocationContext.displayName = "Location";
 | 
| 221 | }
 | 
| 222 | 
 | 
| 223 | const RouteContext = React.createContext({
 | 
| 224 |   outlet: null,
 | 
| 225 |   matches: []
 | 
| 226 | });
 | 
| 227 | 
 | 
| 228 | {
 | 
| 229 |   RouteContext.displayName = "Route";
 | 
| 230 | }
 | 
| 231 | 
 | 
| 232 | const RouteErrorContext = React.createContext(null);
 | 
| 233 | 
 | 
| 234 | {
 | 
| 235 |   RouteErrorContext.displayName = "RouteError";
 | 
| 236 | }
 | 
| 237 | 
 | 
| 238 |  | 
| 239 |  | 
| 240 |  | 
| 241 |  | 
| 242 |  | 
| 243 | 
 | 
| 244 | 
 | 
| 245 | function useHref(to, {
 | 
| 246 |   relative
 | 
| 247 | } = {}) {
 | 
| 248 |   !useInRouterContext() ? UNSAFE_invariant(false, 
 | 
| 249 |   
 | 
| 250 |   `useHref() may be used only in the context of a <Router> component.`)  : void 0;
 | 
| 251 |   let {
 | 
| 252 |     basename,
 | 
| 253 |     navigator
 | 
| 254 |   } = React.useContext(NavigationContext);
 | 
| 255 |   let {
 | 
| 256 |     hash,
 | 
| 257 |     pathname,
 | 
| 258 |     search
 | 
| 259 |   } = useResolvedPath(to, {
 | 
| 260 |     relative
 | 
| 261 |   });
 | 
| 262 |   let joinedPathname = pathname; 
 | 
| 263 |   
 | 
| 264 |   
 | 
| 265 |   
 | 
| 266 | 
 | 
| 267 |   if (basename !== "/") {
 | 
| 268 |     joinedPathname = pathname === "/" ? basename : joinPaths([basename, pathname]);
 | 
| 269 |   }
 | 
| 270 | 
 | 
| 271 |   return navigator.createHref({
 | 
| 272 |     pathname: joinedPathname,
 | 
| 273 |     search,
 | 
| 274 |     hash
 | 
| 275 |   });
 | 
| 276 | }
 | 
| 277 |  | 
| 278 |  | 
| 279 |  | 
| 280 |  | 
| 281 | 
 | 
| 282 | 
 | 
| 283 | function useInRouterContext() {
 | 
| 284 |   return React.useContext(LocationContext) != null;
 | 
| 285 | }
 | 
| 286 |  | 
| 287 |  | 
| 288 |  | 
| 289 |  | 
| 290 |  | 
| 291 |  | 
| 292 |  | 
| 293 |  | 
| 294 |  | 
| 295 | 
 | 
| 296 | 
 | 
| 297 | function useLocation() {
 | 
| 298 |   !useInRouterContext() ? UNSAFE_invariant(false, 
 | 
| 299 |   
 | 
| 300 |   `useLocation() may be used only in the context of a <Router> component.`)  : void 0;
 | 
| 301 |   return React.useContext(LocationContext).location;
 | 
| 302 | }
 | 
| 303 |  | 
| 304 |  | 
| 305 |  | 
| 306 |  | 
| 307 |  | 
| 308 | 
 | 
| 309 | 
 | 
| 310 | function useNavigationType() {
 | 
| 311 |   return React.useContext(LocationContext).navigationType;
 | 
| 312 | }
 | 
| 313 |  | 
| 314 |  | 
| 315 |  | 
| 316 |  | 
| 317 |  | 
| 318 |  | 
| 319 | 
 | 
| 320 | 
 | 
| 321 | function useMatch(pattern) {
 | 
| 322 |   !useInRouterContext() ? UNSAFE_invariant(false, 
 | 
| 323 |   
 | 
| 324 |   `useMatch() may be used only in the context of a <Router> component.`)  : void 0;
 | 
| 325 |   let {
 | 
| 326 |     pathname
 | 
| 327 |   } = useLocation();
 | 
| 328 |   return React.useMemo(() => matchPath(pattern, pathname), [pathname, pattern]);
 | 
| 329 | }
 | 
| 330 |  | 
| 331 |  | 
| 332 |  | 
| 333 |  | 
| 334 |  | 
| 335 | 
 | 
| 336 | 
 | 
| 337 | function useNavigate() {
 | 
| 338 |   !useInRouterContext() ? UNSAFE_invariant(false, 
 | 
| 339 |   
 | 
| 340 |   `useNavigate() may be used only in the context of a <Router> component.`)  : void 0;
 | 
| 341 |   let {
 | 
| 342 |     basename,
 | 
| 343 |     navigator
 | 
| 344 |   } = React.useContext(NavigationContext);
 | 
| 345 |   let {
 | 
| 346 |     matches
 | 
| 347 |   } = React.useContext(RouteContext);
 | 
| 348 |   let {
 | 
| 349 |     pathname: locationPathname
 | 
| 350 |   } = useLocation();
 | 
| 351 |   let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
 | 
| 352 |   let activeRef = React.useRef(false);
 | 
| 353 |   React.useEffect(() => {
 | 
| 354 |     activeRef.current = true;
 | 
| 355 |   });
 | 
| 356 |   let navigate = React.useCallback((to, options = {}) => {
 | 
| 357 |     UNSAFE_warning(activeRef.current, `You should call navigate() in a React.useEffect(), not when ` + `your component is first rendered.`) ;
 | 
| 358 |     if (!activeRef.current) return;
 | 
| 359 | 
 | 
| 360 |     if (typeof to === "number") {
 | 
| 361 |       navigator.go(to);
 | 
| 362 |       return;
 | 
| 363 |     }
 | 
| 364 | 
 | 
| 365 |     let path = resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, options.relative === "path"); 
 | 
| 366 |     
 | 
| 367 |     
 | 
| 368 |     
 | 
| 369 | 
 | 
| 370 |     if (basename !== "/") {
 | 
| 371 |       path.pathname = path.pathname === "/" ? basename : joinPaths([basename, path.pathname]);
 | 
| 372 |     }
 | 
| 373 | 
 | 
| 374 |     (!!options.replace ? navigator.replace : navigator.push)(path, options.state, options);
 | 
| 375 |   }, [basename, navigator, routePathnamesJson, locationPathname]);
 | 
| 376 |   return navigate;
 | 
| 377 | }
 | 
| 378 | const OutletContext = React.createContext(null);
 | 
| 379 |  | 
| 380 |  | 
| 381 |  | 
| 382 |  | 
| 383 | 
 | 
| 384 | 
 | 
| 385 | function useOutletContext() {
 | 
| 386 |   return React.useContext(OutletContext);
 | 
| 387 | }
 | 
| 388 |  | 
| 389 |  | 
| 390 |  | 
| 391 |  | 
| 392 |  | 
| 393 | 
 | 
| 394 | 
 | 
| 395 | function useOutlet(context) {
 | 
| 396 |   let outlet = React.useContext(RouteContext).outlet;
 | 
| 397 | 
 | 
| 398 |   if (outlet) {
 | 
| 399 |     return React.createElement(OutletContext.Provider, {
 | 
| 400 |       value: context
 | 
| 401 |     }, outlet);
 | 
| 402 |   }
 | 
| 403 | 
 | 
| 404 |   return outlet;
 | 
| 405 | }
 | 
| 406 |  | 
| 407 |  | 
| 408 |  | 
| 409 |  | 
| 410 |  | 
| 411 | 
 | 
| 412 | 
 | 
| 413 | function useParams() {
 | 
| 414 |   let {
 | 
| 415 |     matches
 | 
| 416 |   } = React.useContext(RouteContext);
 | 
| 417 |   let routeMatch = matches[matches.length - 1];
 | 
| 418 |   return routeMatch ? routeMatch.params : {};
 | 
| 419 | }
 | 
| 420 |  | 
| 421 |  | 
| 422 |  | 
| 423 |  | 
| 424 | 
 | 
| 425 | 
 | 
| 426 | function useResolvedPath(to, {
 | 
| 427 |   relative
 | 
| 428 | } = {}) {
 | 
| 429 |   let {
 | 
| 430 |     matches
 | 
| 431 |   } = React.useContext(RouteContext);
 | 
| 432 |   let {
 | 
| 433 |     pathname: locationPathname
 | 
| 434 |   } = useLocation();
 | 
| 435 |   let routePathnamesJson = JSON.stringify(UNSAFE_getPathContributingMatches(matches).map(match => match.pathnameBase));
 | 
| 436 |   return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
 | 
| 437 | }
 | 
| 438 |  | 
| 439 |  | 
| 440 |  | 
| 441 |  | 
| 442 |  | 
| 443 |  | 
| 444 |  | 
| 445 | 
 | 
| 446 | 
 | 
| 447 | function useRoutes(routes, locationArg) {
 | 
| 448 |   !useInRouterContext() ? UNSAFE_invariant(false, 
 | 
| 449 |   
 | 
| 450 |   `useRoutes() may be used only in the context of a <Router> component.`)  : void 0;
 | 
| 451 |   let {
 | 
| 452 |     navigator
 | 
| 453 |   } = React.useContext(NavigationContext);
 | 
| 454 |   let dataRouterStateContext = React.useContext(DataRouterStateContext);
 | 
| 455 |   let {
 | 
| 456 |     matches: parentMatches
 | 
| 457 |   } = React.useContext(RouteContext);
 | 
| 458 |   let routeMatch = parentMatches[parentMatches.length - 1];
 | 
| 459 |   let parentParams = routeMatch ? routeMatch.params : {};
 | 
| 460 |   let parentPathname = routeMatch ? routeMatch.pathname : "/";
 | 
| 461 |   let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
 | 
| 462 |   let parentRoute = routeMatch && routeMatch.route;
 | 
| 463 | 
 | 
| 464 |   {
 | 
| 465 |     
 | 
| 466 |     
 | 
| 467 |     
 | 
| 468 |     
 | 
| 469 |     
 | 
| 470 |     
 | 
| 471 |     
 | 
| 472 |     
 | 
| 473 |     
 | 
| 474 |     
 | 
| 475 |     
 | 
| 476 |     
 | 
| 477 |     
 | 
| 478 |     
 | 
| 479 |     
 | 
| 480 |     
 | 
| 481 |     
 | 
| 482 |     
 | 
| 483 |     
 | 
| 484 |     
 | 
| 485 |     let parentPath = parentRoute && parentRoute.path || "";
 | 
| 486 |     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.\n\n` + `Please change the parent <Route path="${parentPath}"> to <Route ` + `path="${parentPath === "/" ? "*" : `${parentPath}/*`}">.`);
 | 
| 487 |   }
 | 
| 488 | 
 | 
| 489 |   let locationFromContext = useLocation();
 | 
| 490 |   let location;
 | 
| 491 | 
 | 
| 492 |   if (locationArg) {
 | 
| 493 |     let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
 | 
| 494 |     !(parentPathnameBase === "/" || parsedLocationArg.pathname?.startsWith(parentPathnameBase)) ? UNSAFE_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.`)  : void 0;
 | 
| 495 |     location = parsedLocationArg;
 | 
| 496 |   } else {
 | 
| 497 |     location = locationFromContext;
 | 
| 498 |   }
 | 
| 499 | 
 | 
| 500 |   let pathname = location.pathname || "/";
 | 
| 501 |   let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
 | 
| 502 |   let matches = matchRoutes(routes, {
 | 
| 503 |     pathname: remainingPathname
 | 
| 504 |   });
 | 
| 505 | 
 | 
| 506 |   {
 | 
| 507 |     UNSAFE_warning(parentRoute || matches != null, `No routes matched location "${location.pathname}${location.search}${location.hash}" `) ;
 | 
| 508 |     UNSAFE_warning(matches == null || matches[matches.length - 1].route.element !== undefined || matches[matches.length - 1].route.Component !== undefined, `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.`) ;
 | 
| 509 |   }
 | 
| 510 | 
 | 
| 511 |   let renderedMatches = _renderMatches(matches && matches.map(match => Object.assign({}, match, {
 | 
| 512 |     params: Object.assign({}, parentParams, match.params),
 | 
| 513 |     pathname: joinPaths([parentPathnameBase, 
 | 
| 514 |     navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname]),
 | 
| 515 |     pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([parentPathnameBase, 
 | 
| 516 |     navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase])
 | 
| 517 |   })), parentMatches, dataRouterStateContext || undefined); 
 | 
| 518 |   
 | 
| 519 |   
 | 
| 520 | 
 | 
| 521 | 
 | 
| 522 |   if (locationArg && renderedMatches) {
 | 
| 523 |     return React.createElement(LocationContext.Provider, {
 | 
| 524 |       value: {
 | 
| 525 |         location: {
 | 
| 526 |           pathname: "/",
 | 
| 527 |           search: "",
 | 
| 528 |           hash: "",
 | 
| 529 |           state: null,
 | 
| 530 |           key: "default",
 | 
| 531 |           ...location
 | 
| 532 |         },
 | 
| 533 |         navigationType: Action.Pop
 | 
| 534 |       }
 | 
| 535 |     }, renderedMatches);
 | 
| 536 |   }
 | 
| 537 | 
 | 
| 538 |   return renderedMatches;
 | 
| 539 | }
 | 
| 540 | 
 | 
| 541 | function DefaultErrorComponent() {
 | 
| 542 |   let error = useRouteError();
 | 
| 543 |   let message = isRouteErrorResponse(error) ? `${error.status} ${error.statusText}` : error instanceof Error ? error.message : JSON.stringify(error);
 | 
| 544 |   let stack = error instanceof Error ? error.stack : null;
 | 
| 545 |   let lightgrey = "rgba(200,200,200, 0.5)";
 | 
| 546 |   let preStyles = {
 | 
| 547 |     padding: "0.5rem",
 | 
| 548 |     backgroundColor: lightgrey
 | 
| 549 |   };
 | 
| 550 |   let codeStyles = {
 | 
| 551 |     padding: "2px 4px",
 | 
| 552 |     backgroundColor: lightgrey
 | 
| 553 |   };
 | 
| 554 |   let devInfo = null;
 | 
| 555 | 
 | 
| 556 |   {
 | 
| 557 |     devInfo = React.createElement(React.Fragment, null, React.createElement("p", null, "\uD83D\uDCBF Hey developer \uD83D\uDC4B"), React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own\u00A0", React.createElement("code", {
 | 
| 558 |       style: codeStyles
 | 
| 559 |     }, "ErrorBoundary"), " prop on\u00A0", React.createElement("code", {
 | 
| 560 |       style: codeStyles
 | 
| 561 |     }, "<Route>")));
 | 
| 562 |   }
 | 
| 563 | 
 | 
| 564 |   return React.createElement(React.Fragment, null, React.createElement("h2", null, "Unexpected Application Error!"), React.createElement("h3", {
 | 
| 565 |     style: {
 | 
| 566 |       fontStyle: "italic"
 | 
| 567 |     }
 | 
| 568 |   }, message), stack ? React.createElement("pre", {
 | 
| 569 |     style: preStyles
 | 
| 570 |   }, stack) : null, devInfo);
 | 
| 571 | }
 | 
| 572 | 
 | 
| 573 | class RenderErrorBoundary extends React.Component {
 | 
| 574 |   constructor(props) {
 | 
| 575 |     super(props);
 | 
| 576 |     this.state = {
 | 
| 577 |       location: props.location,
 | 
| 578 |       error: props.error
 | 
| 579 |     };
 | 
| 580 |   }
 | 
| 581 | 
 | 
| 582 |   static getDerivedStateFromError(error) {
 | 
| 583 |     return {
 | 
| 584 |       error: error
 | 
| 585 |     };
 | 
| 586 |   }
 | 
| 587 | 
 | 
| 588 |   static getDerivedStateFromProps(props, state) {
 | 
| 589 |     
 | 
| 590 |     
 | 
| 591 |     
 | 
| 592 |     
 | 
| 593 |     
 | 
| 594 |     
 | 
| 595 |     
 | 
| 596 |     
 | 
| 597 |     if (state.location !== props.location) {
 | 
| 598 |       return {
 | 
| 599 |         error: props.error,
 | 
| 600 |         location: props.location
 | 
| 601 |       };
 | 
| 602 |     } 
 | 
| 603 |     
 | 
| 604 |     
 | 
| 605 |     
 | 
| 606 | 
 | 
| 607 | 
 | 
| 608 |     return {
 | 
| 609 |       error: props.error || state.error,
 | 
| 610 |       location: state.location
 | 
| 611 |     };
 | 
| 612 |   }
 | 
| 613 | 
 | 
| 614 |   componentDidCatch(error, errorInfo) {
 | 
| 615 |     console.error("React Router caught the following error during render", error, errorInfo);
 | 
| 616 |   }
 | 
| 617 | 
 | 
| 618 |   render() {
 | 
| 619 |     return this.state.error ? React.createElement(RouteContext.Provider, {
 | 
| 620 |       value: this.props.routeContext
 | 
| 621 |     }, React.createElement(RouteErrorContext.Provider, {
 | 
| 622 |       value: this.state.error,
 | 
| 623 |       children: this.props.component
 | 
| 624 |     })) : this.props.children;
 | 
| 625 |   }
 | 
| 626 | 
 | 
| 627 | }
 | 
| 628 | 
 | 
| 629 | function RenderedRoute({
 | 
| 630 |   routeContext,
 | 
| 631 |   match,
 | 
| 632 |   children
 | 
| 633 | }) {
 | 
| 634 |   let dataRouterContext = React.useContext(DataRouterContext); 
 | 
| 635 |   
 | 
| 636 | 
 | 
| 637 |   if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
 | 
| 638 |     dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
 | 
| 639 |   }
 | 
| 640 | 
 | 
| 641 |   return React.createElement(RouteContext.Provider, {
 | 
| 642 |     value: routeContext
 | 
| 643 |   }, children);
 | 
| 644 | }
 | 
| 645 | 
 | 
| 646 | function _renderMatches(matches, parentMatches = [], dataRouterState) {
 | 
| 647 |   if (matches == null) {
 | 
| 648 |     if (dataRouterState?.errors) {
 | 
| 649 |       
 | 
| 650 |       
 | 
| 651 |       matches = dataRouterState.matches;
 | 
| 652 |     } else {
 | 
| 653 |       return null;
 | 
| 654 |     }
 | 
| 655 |   }
 | 
| 656 | 
 | 
| 657 |   let renderedMatches = matches; 
 | 
| 658 | 
 | 
| 659 |   let errors = dataRouterState?.errors;
 | 
| 660 | 
 | 
| 661 |   if (errors != null) {
 | 
| 662 |     let errorIndex = renderedMatches.findIndex(m => m.route.id && errors?.[m.route.id]);
 | 
| 663 |     !(errorIndex >= 0) ? UNSAFE_invariant(false, `Could not find a matching route for the current errors: ${errors}`)  : void 0;
 | 
| 664 |     renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
 | 
| 665 |   }
 | 
| 666 | 
 | 
| 667 |   return renderedMatches.reduceRight((outlet, match, index) => {
 | 
| 668 |     let error = match.route.id ? errors?.[match.route.id] : null; 
 | 
| 669 | 
 | 
| 670 |     let errorElement = null;
 | 
| 671 | 
 | 
| 672 |     if (dataRouterState) {
 | 
| 673 |       if (match.route.ErrorBoundary) {
 | 
| 674 |         errorElement = React.createElement(match.route.ErrorBoundary, null);
 | 
| 675 |       } else if (match.route.errorElement) {
 | 
| 676 |         errorElement = match.route.errorElement;
 | 
| 677 |       } else {
 | 
| 678 |         errorElement = React.createElement(DefaultErrorComponent, null);
 | 
| 679 |       }
 | 
| 680 |     }
 | 
| 681 | 
 | 
| 682 |     let matches = parentMatches.concat(renderedMatches.slice(0, index + 1));
 | 
| 683 | 
 | 
| 684 |     let getChildren = () => {
 | 
| 685 |       let children = outlet;
 | 
| 686 | 
 | 
| 687 |       if (error) {
 | 
| 688 |         children = errorElement;
 | 
| 689 |       } else if (match.route.Component) {
 | 
| 690 |         children = React.createElement(match.route.Component, null);
 | 
| 691 |       } else if (match.route.element) {
 | 
| 692 |         children = match.route.element;
 | 
| 693 |       }
 | 
| 694 | 
 | 
| 695 |       return React.createElement(RenderedRoute, {
 | 
| 696 |         match: match,
 | 
| 697 |         routeContext: {
 | 
| 698 |           outlet,
 | 
| 699 |           matches
 | 
| 700 |         },
 | 
| 701 |         children: children
 | 
| 702 |       });
 | 
| 703 |     }; 
 | 
| 704 |     
 | 
| 705 |     
 | 
| 706 | 
 | 
| 707 | 
 | 
| 708 |     return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? React.createElement(RenderErrorBoundary, {
 | 
| 709 |       location: dataRouterState.location,
 | 
| 710 |       component: errorElement,
 | 
| 711 |       error: error,
 | 
| 712 |       children: getChildren(),
 | 
| 713 |       routeContext: {
 | 
| 714 |         outlet: null,
 | 
| 715 |         matches
 | 
| 716 |       }
 | 
| 717 |     }) : getChildren();
 | 
| 718 |   }, null);
 | 
| 719 | }
 | 
| 720 | var DataRouterHook;
 | 
| 721 | 
 | 
| 722 | (function (DataRouterHook) {
 | 
| 723 |   DataRouterHook["UseBlocker"] = "useBlocker";
 | 
| 724 |   DataRouterHook["UseRevalidator"] = "useRevalidator";
 | 
| 725 | })(DataRouterHook || (DataRouterHook = {}));
 | 
| 726 | 
 | 
| 727 | var DataRouterStateHook;
 | 
| 728 | 
 | 
| 729 | (function (DataRouterStateHook) {
 | 
| 730 |   DataRouterStateHook["UseBlocker"] = "useBlocker";
 | 
| 731 |   DataRouterStateHook["UseLoaderData"] = "useLoaderData";
 | 
| 732 |   DataRouterStateHook["UseActionData"] = "useActionData";
 | 
| 733 |   DataRouterStateHook["UseRouteError"] = "useRouteError";
 | 
| 734 |   DataRouterStateHook["UseNavigation"] = "useNavigation";
 | 
| 735 |   DataRouterStateHook["UseRouteLoaderData"] = "useRouteLoaderData";
 | 
| 736 |   DataRouterStateHook["UseMatches"] = "useMatches";
 | 
| 737 |   DataRouterStateHook["UseRevalidator"] = "useRevalidator";
 | 
| 738 | })(DataRouterStateHook || (DataRouterStateHook = {}));
 | 
| 739 | 
 | 
| 740 | function getDataRouterConsoleError(hookName) {
 | 
| 741 |   return `${hookName} must be used within a data router.  See https://reactrouter.com/routers/picking-a-router.`;
 | 
| 742 | }
 | 
| 743 | 
 | 
| 744 | function useDataRouterContext(hookName) {
 | 
| 745 |   let ctx = React.useContext(DataRouterContext);
 | 
| 746 |   !ctx ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName))  : void 0;
 | 
| 747 |   return ctx;
 | 
| 748 | }
 | 
| 749 | 
 | 
| 750 | function useDataRouterState(hookName) {
 | 
| 751 |   let state = React.useContext(DataRouterStateContext);
 | 
| 752 |   !state ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName))  : void 0;
 | 
| 753 |   return state;
 | 
| 754 | }
 | 
| 755 | 
 | 
| 756 | function useRouteContext(hookName) {
 | 
| 757 |   let route = React.useContext(RouteContext);
 | 
| 758 |   !route ? UNSAFE_invariant(false, getDataRouterConsoleError(hookName))  : void 0;
 | 
| 759 |   return route;
 | 
| 760 | }
 | 
| 761 | 
 | 
| 762 | function useCurrentRouteId(hookName) {
 | 
| 763 |   let route = useRouteContext(hookName);
 | 
| 764 |   let thisRoute = route.matches[route.matches.length - 1];
 | 
| 765 |   !thisRoute.route.id ? UNSAFE_invariant(false, `${hookName} can only be used on routes that contain a unique "id"`)  : void 0;
 | 
| 766 |   return thisRoute.route.id;
 | 
| 767 | }
 | 
| 768 |  | 
| 769 |  | 
| 770 |  | 
| 771 | 
 | 
| 772 | 
 | 
| 773 | 
 | 
| 774 | function useNavigation() {
 | 
| 775 |   let state = useDataRouterState(DataRouterStateHook.UseNavigation);
 | 
| 776 |   return state.navigation;
 | 
| 777 | }
 | 
| 778 |  | 
| 779 |  | 
| 780 |  | 
| 781 | 
 | 
| 782 | 
 | 
| 783 | function useRevalidator() {
 | 
| 784 |   let dataRouterContext = useDataRouterContext(DataRouterHook.UseRevalidator);
 | 
| 785 |   let state = useDataRouterState(DataRouterStateHook.UseRevalidator);
 | 
| 786 |   return {
 | 
| 787 |     revalidate: dataRouterContext.router.revalidate,
 | 
| 788 |     state: state.revalidation
 | 
| 789 |   };
 | 
| 790 | }
 | 
| 791 |  | 
| 792 |  | 
| 793 |  | 
| 794 | 
 | 
| 795 | 
 | 
| 796 | function useMatches() {
 | 
| 797 |   let {
 | 
| 798 |     matches,
 | 
| 799 |     loaderData
 | 
| 800 |   } = useDataRouterState(DataRouterStateHook.UseMatches);
 | 
| 801 |   return React.useMemo(() => matches.map(match => {
 | 
| 802 |     let {
 | 
| 803 |       pathname,
 | 
| 804 |       params
 | 
| 805 |     } = match; 
 | 
| 806 |     
 | 
| 807 |     
 | 
| 808 | 
 | 
| 809 |     return {
 | 
| 810 |       id: match.route.id,
 | 
| 811 |       pathname,
 | 
| 812 |       params,
 | 
| 813 |       data: loaderData[match.route.id],
 | 
| 814 |       handle: match.route.handle
 | 
| 815 |     };
 | 
| 816 |   }), [matches, loaderData]);
 | 
| 817 | }
 | 
| 818 |  | 
| 819 |  | 
| 820 | 
 | 
| 821 | 
 | 
| 822 | function useLoaderData() {
 | 
| 823 |   let state = useDataRouterState(DataRouterStateHook.UseLoaderData);
 | 
| 824 |   let routeId = useCurrentRouteId(DataRouterStateHook.UseLoaderData);
 | 
| 825 | 
 | 
| 826 |   if (state.errors && state.errors[routeId] != null) {
 | 
| 827 |     console.error(`You cannot \`useLoaderData\` in an errorElement (routeId: ${routeId})`);
 | 
| 828 |     return undefined;
 | 
| 829 |   }
 | 
| 830 | 
 | 
| 831 |   return state.loaderData[routeId];
 | 
| 832 | }
 | 
| 833 |  | 
| 834 |  | 
| 835 | 
 | 
| 836 | 
 | 
| 837 | function useRouteLoaderData(routeId) {
 | 
| 838 |   let state = useDataRouterState(DataRouterStateHook.UseRouteLoaderData);
 | 
| 839 |   return state.loaderData[routeId];
 | 
| 840 | }
 | 
| 841 |  | 
| 842 |  | 
| 843 | 
 | 
| 844 | 
 | 
| 845 | function useActionData() {
 | 
| 846 |   let state = useDataRouterState(DataRouterStateHook.UseActionData);
 | 
| 847 |   let route = React.useContext(RouteContext);
 | 
| 848 |   !route ? UNSAFE_invariant(false, `useActionData must be used inside a RouteContext`)  : void 0;
 | 
| 849 |   return Object.values(state?.actionData || {})[0];
 | 
| 850 | }
 | 
| 851 |  | 
| 852 |  | 
| 853 |  | 
| 854 |  | 
| 855 | 
 | 
| 856 | 
 | 
| 857 | function useRouteError() {
 | 
| 858 |   let error = React.useContext(RouteErrorContext);
 | 
| 859 |   let state = useDataRouterState(DataRouterStateHook.UseRouteError);
 | 
| 860 |   let routeId = useCurrentRouteId(DataRouterStateHook.UseRouteError); 
 | 
| 861 |   
 | 
| 862 | 
 | 
| 863 |   if (error) {
 | 
| 864 |     return error;
 | 
| 865 |   } 
 | 
| 866 | 
 | 
| 867 | 
 | 
| 868 |   return state.errors?.[routeId];
 | 
| 869 | }
 | 
| 870 |  | 
| 871 |  | 
| 872 | 
 | 
| 873 | 
 | 
| 874 | function useAsyncValue() {
 | 
| 875 |   let value = React.useContext(AwaitContext);
 | 
| 876 |   return value?._data;
 | 
| 877 | }
 | 
| 878 |  | 
| 879 |  | 
| 880 | 
 | 
| 881 | 
 | 
| 882 | function useAsyncError() {
 | 
| 883 |   let value = React.useContext(AwaitContext);
 | 
| 884 |   return value?._error;
 | 
| 885 | }
 | 
| 886 | let blockerId = 0;
 | 
| 887 |  | 
| 888 |  | 
| 889 |  | 
| 890 |  | 
| 891 |  | 
| 892 | 
 | 
| 893 | 
 | 
| 894 | function useBlocker(shouldBlock) {
 | 
| 895 |   let {
 | 
| 896 |     router
 | 
| 897 |   } = useDataRouterContext(DataRouterHook.UseBlocker);
 | 
| 898 |   let state = useDataRouterState(DataRouterStateHook.UseBlocker);
 | 
| 899 |   let [blockerKey] = React.useState(() => String(++blockerId));
 | 
| 900 |   let blockerFunction = React.useCallback(args => {
 | 
| 901 |     return typeof shouldBlock === "function" ? !!shouldBlock(args) : !!shouldBlock;
 | 
| 902 |   }, [shouldBlock]);
 | 
| 903 |   let blocker = router.getBlocker(blockerKey, blockerFunction); 
 | 
| 904 | 
 | 
| 905 |   React.useEffect(() => () => router.deleteBlocker(blockerKey), [router, blockerKey]); 
 | 
| 906 |   
 | 
| 907 | 
 | 
| 908 |   return state.blockers.get(blockerKey) || blocker;
 | 
| 909 | }
 | 
| 910 | const alreadyWarned = {};
 | 
| 911 | 
 | 
| 912 | function warningOnce(key, cond, message) {
 | 
| 913 |   if (!cond && !alreadyWarned[key]) {
 | 
| 914 |     alreadyWarned[key] = true;
 | 
| 915 |     UNSAFE_warning(false, message) ;
 | 
| 916 |   }
 | 
| 917 | }
 | 
| 918 | 
 | 
| 919 |  | 
| 920 |  | 
| 921 | 
 | 
| 922 | 
 | 
| 923 | function RouterProvider({
 | 
| 924 |   fallbackElement,
 | 
| 925 |   router
 | 
| 926 | }) {
 | 
| 927 |   let getState = React.useCallback(() => router.state, [router]); 
 | 
| 928 | 
 | 
| 929 |   let state = useSyncExternalStore(router.subscribe, getState, 
 | 
| 930 |   
 | 
| 931 |   
 | 
| 932 |   getState);
 | 
| 933 |   let navigator = React.useMemo(() => {
 | 
| 934 |     return {
 | 
| 935 |       createHref: router.createHref,
 | 
| 936 |       encodeLocation: router.encodeLocation,
 | 
| 937 |       go: n => router.navigate(n),
 | 
| 938 |       push: (to, state, opts) => router.navigate(to, {
 | 
| 939 |         state,
 | 
| 940 |         preventScrollReset: opts?.preventScrollReset
 | 
| 941 |       }),
 | 
| 942 |       replace: (to, state, opts) => router.navigate(to, {
 | 
| 943 |         replace: true,
 | 
| 944 |         state,
 | 
| 945 |         preventScrollReset: opts?.preventScrollReset
 | 
| 946 |       })
 | 
| 947 |     };
 | 
| 948 |   }, [router]);
 | 
| 949 |   let basename = router.basename || "/";
 | 
| 950 |   let dataRouterContext = React.useMemo(() => ({
 | 
| 951 |     router,
 | 
| 952 |     navigator,
 | 
| 953 |     static: false,
 | 
| 954 |     basename
 | 
| 955 |   }), [router, navigator, basename]); 
 | 
| 956 |   
 | 
| 957 |   
 | 
| 958 |   
 | 
| 959 |   
 | 
| 960 |   
 | 
| 961 | 
 | 
| 962 |   return React.createElement(React.Fragment, null, React.createElement(DataRouterContext.Provider, {
 | 
| 963 |     value: dataRouterContext
 | 
| 964 |   }, React.createElement(DataRouterStateContext.Provider, {
 | 
| 965 |     value: state
 | 
| 966 |   }, React.createElement(Router, {
 | 
| 967 |     basename: router.basename,
 | 
| 968 |     location: router.state.location,
 | 
| 969 |     navigationType: router.state.historyAction,
 | 
| 970 |     navigator: navigator
 | 
| 971 |   }, router.state.initialized ? React.createElement(Routes, null) : fallbackElement))), null);
 | 
| 972 | }
 | 
| 973 |  | 
| 974 |  | 
| 975 |  | 
| 976 |  | 
| 977 | 
 | 
| 978 | 
 | 
| 979 | function MemoryRouter({
 | 
| 980 |   basename,
 | 
| 981 |   children,
 | 
| 982 |   initialEntries,
 | 
| 983 |   initialIndex
 | 
| 984 | }) {
 | 
| 985 |   let historyRef = React.useRef();
 | 
| 986 | 
 | 
| 987 |   if (historyRef.current == null) {
 | 
| 988 |     historyRef.current = createMemoryHistory({
 | 
| 989 |       initialEntries,
 | 
| 990 |       initialIndex,
 | 
| 991 |       v5Compat: true
 | 
| 992 |     });
 | 
| 993 |   }
 | 
| 994 | 
 | 
| 995 |   let history = historyRef.current;
 | 
| 996 |   let [state, setState] = React.useState({
 | 
| 997 |     action: history.action,
 | 
| 998 |     location: history.location
 | 
| 999 |   });
 | 
| 1000 |   React.useLayoutEffect(() => history.listen(setState), [history]);
 | 
| 1001 |   return React.createElement(Router, {
 | 
| 1002 |     basename: basename,
 | 
| 1003 |     children: children,
 | 
| 1004 |     location: state.location,
 | 
| 1005 |     navigationType: state.action,
 | 
| 1006 |     navigator: history
 | 
| 1007 |   });
 | 
| 1008 | }
 | 
| 1009 |  | 
| 1010 |  | 
| 1011 |  | 
| 1012 |  | 
| 1013 |  | 
| 1014 |  | 
| 1015 |  | 
| 1016 |  | 
| 1017 | 
 | 
| 1018 | 
 | 
| 1019 | function Navigate({
 | 
| 1020 |   to,
 | 
| 1021 |   replace,
 | 
| 1022 |   state,
 | 
| 1023 |   relative
 | 
| 1024 | }) {
 | 
| 1025 |   !useInRouterContext() ? UNSAFE_invariant(false, 
 | 
| 1026 |   
 | 
| 1027 |   `<Navigate> may be used only in the context of a <Router> component.`)  : void 0;
 | 
| 1028 |   UNSAFE_warning(!React.useContext(NavigationContext).static, `<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.`) ;
 | 
| 1029 |   let dataRouterState = React.useContext(DataRouterStateContext);
 | 
| 1030 |   let navigate = useNavigate();
 | 
| 1031 |   React.useEffect(() => {
 | 
| 1032 |     
 | 
| 1033 |     
 | 
| 1034 |     
 | 
| 1035 |     if (dataRouterState && dataRouterState.navigation.state !== "idle") {
 | 
| 1036 |       return;
 | 
| 1037 |     }
 | 
| 1038 | 
 | 
| 1039 |     navigate(to, {
 | 
| 1040 |       replace,
 | 
| 1041 |       state,
 | 
| 1042 |       relative
 | 
| 1043 |     });
 | 
| 1044 |   });
 | 
| 1045 |   return null;
 | 
| 1046 | }
 | 
| 1047 |  | 
| 1048 |  | 
| 1049 |  | 
| 1050 |  | 
| 1051 | 
 | 
| 1052 | 
 | 
| 1053 | function Outlet(props) {
 | 
| 1054 |   return useOutlet(props.context);
 | 
| 1055 | }
 | 
| 1056 |  | 
| 1057 |  | 
| 1058 |  | 
| 1059 |  | 
| 1060 | 
 | 
| 1061 | 
 | 
| 1062 | function Route(_props) {
 | 
| 1063 |   UNSAFE_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>.`)  ;
 | 
| 1064 | }
 | 
| 1065 |  | 
| 1066 |  | 
| 1067 |  | 
| 1068 |  | 
| 1069 |  | 
| 1070 |  | 
| 1071 |  | 
| 1072 |  | 
| 1073 | 
 | 
| 1074 | 
 | 
| 1075 | function Router({
 | 
| 1076 |   basename: basenameProp = "/",
 | 
| 1077 |   children = null,
 | 
| 1078 |   location: locationProp,
 | 
| 1079 |   navigationType = Action.Pop,
 | 
| 1080 |   navigator,
 | 
| 1081 |   static: staticProp = false
 | 
| 1082 | }) {
 | 
| 1083 |   !!useInRouterContext() ? UNSAFE_invariant(false, `You cannot render a <Router> inside another <Router>.` + ` You should never have more than one in your app.`)  : void 0; 
 | 
| 1084 |   
 | 
| 1085 | 
 | 
| 1086 |   let basename = basenameProp.replace(/^\/*/, "/");
 | 
| 1087 |   let navigationContext = React.useMemo(() => ({
 | 
| 1088 |     basename,
 | 
| 1089 |     navigator,
 | 
| 1090 |     static: staticProp
 | 
| 1091 |   }), [basename, navigator, staticProp]);
 | 
| 1092 | 
 | 
| 1093 |   if (typeof locationProp === "string") {
 | 
| 1094 |     locationProp = parsePath(locationProp);
 | 
| 1095 |   }
 | 
| 1096 | 
 | 
| 1097 |   let {
 | 
| 1098 |     pathname = "/",
 | 
| 1099 |     search = "",
 | 
| 1100 |     hash = "",
 | 
| 1101 |     state = null,
 | 
| 1102 |     key = "default"
 | 
| 1103 |   } = locationProp;
 | 
| 1104 |   let locationContext = React.useMemo(() => {
 | 
| 1105 |     let trailingPathname = stripBasename(pathname, basename);
 | 
| 1106 | 
 | 
| 1107 |     if (trailingPathname == null) {
 | 
| 1108 |       return null;
 | 
| 1109 |     }
 | 
| 1110 | 
 | 
| 1111 |     return {
 | 
| 1112 |       location: {
 | 
| 1113 |         pathname: trailingPathname,
 | 
| 1114 |         search,
 | 
| 1115 |         hash,
 | 
| 1116 |         state,
 | 
| 1117 |         key
 | 
| 1118 |       },
 | 
| 1119 |       navigationType
 | 
| 1120 |     };
 | 
| 1121 |   }, [basename, pathname, search, hash, state, key, navigationType]);
 | 
| 1122 |   UNSAFE_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.`) ;
 | 
| 1123 | 
 | 
| 1124 |   if (locationContext == null) {
 | 
| 1125 |     return null;
 | 
| 1126 |   }
 | 
| 1127 | 
 | 
| 1128 |   return React.createElement(NavigationContext.Provider, {
 | 
| 1129 |     value: navigationContext
 | 
| 1130 |   }, React.createElement(LocationContext.Provider, {
 | 
| 1131 |     children: children,
 | 
| 1132 |     value: locationContext
 | 
| 1133 |   }));
 | 
| 1134 | }
 | 
| 1135 |  | 
| 1136 |  | 
| 1137 |  | 
| 1138 |  | 
| 1139 |  | 
| 1140 | 
 | 
| 1141 | 
 | 
| 1142 | function Routes({
 | 
| 1143 |   children,
 | 
| 1144 |   location
 | 
| 1145 | }) {
 | 
| 1146 |   let dataRouterContext = React.useContext(DataRouterContext); 
 | 
| 1147 |   
 | 
| 1148 |   
 | 
| 1149 | 
 | 
| 1150 |   let routes = dataRouterContext && !children ? dataRouterContext.router.routes : createRoutesFromChildren(children);
 | 
| 1151 |   return useRoutes(routes, location);
 | 
| 1152 | }
 | 
| 1153 |  | 
| 1154 |  | 
| 1155 |  | 
| 1156 | 
 | 
| 1157 | 
 | 
| 1158 | function Await({
 | 
| 1159 |   children,
 | 
| 1160 |   errorElement,
 | 
| 1161 |   resolve
 | 
| 1162 | }) {
 | 
| 1163 |   return React.createElement(AwaitErrorBoundary, {
 | 
| 1164 |     resolve: resolve,
 | 
| 1165 |     errorElement: errorElement
 | 
| 1166 |   }, React.createElement(ResolveAwait, null, children));
 | 
| 1167 | }
 | 
| 1168 | var AwaitRenderStatus;
 | 
| 1169 | 
 | 
| 1170 | (function (AwaitRenderStatus) {
 | 
| 1171 |   AwaitRenderStatus[AwaitRenderStatus["pending"] = 0] = "pending";
 | 
| 1172 |   AwaitRenderStatus[AwaitRenderStatus["success"] = 1] = "success";
 | 
| 1173 |   AwaitRenderStatus[AwaitRenderStatus["error"] = 2] = "error";
 | 
| 1174 | })(AwaitRenderStatus || (AwaitRenderStatus = {}));
 | 
| 1175 | 
 | 
| 1176 | const neverSettledPromise = new Promise(() => {});
 | 
| 1177 | 
 | 
| 1178 | class AwaitErrorBoundary extends React.Component {
 | 
| 1179 |   constructor(props) {
 | 
| 1180 |     super(props);
 | 
| 1181 |     this.state = {
 | 
| 1182 |       error: null
 | 
| 1183 |     };
 | 
| 1184 |   }
 | 
| 1185 | 
 | 
| 1186 |   static getDerivedStateFromError(error) {
 | 
| 1187 |     return {
 | 
| 1188 |       error
 | 
| 1189 |     };
 | 
| 1190 |   }
 | 
| 1191 | 
 | 
| 1192 |   componentDidCatch(error, errorInfo) {
 | 
| 1193 |     console.error("<Await> caught the following error during render", error, errorInfo);
 | 
| 1194 |   }
 | 
| 1195 | 
 | 
| 1196 |   render() {
 | 
| 1197 |     let {
 | 
| 1198 |       children,
 | 
| 1199 |       errorElement,
 | 
| 1200 |       resolve
 | 
| 1201 |     } = this.props;
 | 
| 1202 |     let promise = null;
 | 
| 1203 |     let status = AwaitRenderStatus.pending;
 | 
| 1204 | 
 | 
| 1205 |     if (!(resolve instanceof Promise)) {
 | 
| 1206 |       
 | 
| 1207 |       status = AwaitRenderStatus.success;
 | 
| 1208 |       promise = Promise.resolve();
 | 
| 1209 |       Object.defineProperty(promise, "_tracked", {
 | 
| 1210 |         get: () => true
 | 
| 1211 |       });
 | 
| 1212 |       Object.defineProperty(promise, "_data", {
 | 
| 1213 |         get: () => resolve
 | 
| 1214 |       });
 | 
| 1215 |     } else if (this.state.error) {
 | 
| 1216 |       
 | 
| 1217 |       status = AwaitRenderStatus.error;
 | 
| 1218 |       let renderError = this.state.error;
 | 
| 1219 |       promise = Promise.reject().catch(() => {}); 
 | 
| 1220 | 
 | 
| 1221 |       Object.defineProperty(promise, "_tracked", {
 | 
| 1222 |         get: () => true
 | 
| 1223 |       });
 | 
| 1224 |       Object.defineProperty(promise, "_error", {
 | 
| 1225 |         get: () => renderError
 | 
| 1226 |       });
 | 
| 1227 |     } else if (resolve._tracked) {
 | 
| 1228 |       
 | 
| 1229 |       promise = resolve;
 | 
| 1230 |       status = promise._error !== undefined ? AwaitRenderStatus.error : promise._data !== undefined ? AwaitRenderStatus.success : AwaitRenderStatus.pending;
 | 
| 1231 |     } else {
 | 
| 1232 |       
 | 
| 1233 |       status = AwaitRenderStatus.pending;
 | 
| 1234 |       Object.defineProperty(resolve, "_tracked", {
 | 
| 1235 |         get: () => true
 | 
| 1236 |       });
 | 
| 1237 |       promise = resolve.then(data => Object.defineProperty(resolve, "_data", {
 | 
| 1238 |         get: () => data
 | 
| 1239 |       }), error => Object.defineProperty(resolve, "_error", {
 | 
| 1240 |         get: () => error
 | 
| 1241 |       }));
 | 
| 1242 |     }
 | 
| 1243 | 
 | 
| 1244 |     if (status === AwaitRenderStatus.error && promise._error instanceof AbortedDeferredError) {
 | 
| 1245 |       
 | 
| 1246 |       throw neverSettledPromise;
 | 
| 1247 |     }
 | 
| 1248 | 
 | 
| 1249 |     if (status === AwaitRenderStatus.error && !errorElement) {
 | 
| 1250 |       
 | 
| 1251 |       throw promise._error;
 | 
| 1252 |     }
 | 
| 1253 | 
 | 
| 1254 |     if (status === AwaitRenderStatus.error) {
 | 
| 1255 |       
 | 
| 1256 |       return React.createElement(AwaitContext.Provider, {
 | 
| 1257 |         value: promise,
 | 
| 1258 |         children: errorElement
 | 
| 1259 |       });
 | 
| 1260 |     }
 | 
| 1261 | 
 | 
| 1262 |     if (status === AwaitRenderStatus.success) {
 | 
| 1263 |       
 | 
| 1264 |       return React.createElement(AwaitContext.Provider, {
 | 
| 1265 |         value: promise,
 | 
| 1266 |         children: children
 | 
| 1267 |       });
 | 
| 1268 |     } 
 | 
| 1269 | 
 | 
| 1270 | 
 | 
| 1271 |     throw promise;
 | 
| 1272 |   }
 | 
| 1273 | 
 | 
| 1274 | }
 | 
| 1275 |  | 
| 1276 |  | 
| 1277 |  | 
| 1278 | 
 | 
| 1279 | 
 | 
| 1280 | 
 | 
| 1281 | function ResolveAwait({
 | 
| 1282 |   children
 | 
| 1283 | }) {
 | 
| 1284 |   let data = useAsyncValue();
 | 
| 1285 |   let toRender = typeof children === "function" ? children(data) : children;
 | 
| 1286 |   return React.createElement(React.Fragment, null, toRender);
 | 
| 1287 | } 
 | 
| 1288 | 
 | 
| 1289 | 
 | 
| 1290 | 
 | 
| 1291 |  | 
| 1292 |  | 
| 1293 |  | 
| 1294 |  | 
| 1295 |  | 
| 1296 |  | 
| 1297 | 
 | 
| 1298 | 
 | 
| 1299 | 
 | 
| 1300 | function createRoutesFromChildren(children, parentPath = []) {
 | 
| 1301 |   let routes = [];
 | 
| 1302 |   React.Children.forEach(children, (element, index) => {
 | 
| 1303 |     if (! React.isValidElement(element)) {
 | 
| 1304 |       
 | 
| 1305 |       
 | 
| 1306 |       return;
 | 
| 1307 |     }
 | 
| 1308 | 
 | 
| 1309 |     if (element.type === React.Fragment) {
 | 
| 1310 |       
 | 
| 1311 |       routes.push.apply(routes, createRoutesFromChildren(element.props.children, parentPath));
 | 
| 1312 |       return;
 | 
| 1313 |     }
 | 
| 1314 | 
 | 
| 1315 |     !(element.type === Route) ? UNSAFE_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>`)  : void 0;
 | 
| 1316 |     !(!element.props.index || !element.props.children) ? UNSAFE_invariant(false, "An index route cannot have child routes.")  : void 0;
 | 
| 1317 |     let treePath = [...parentPath, index];
 | 
| 1318 |     let route = {
 | 
| 1319 |       id: element.props.id || treePath.join("-"),
 | 
| 1320 |       caseSensitive: element.props.caseSensitive,
 | 
| 1321 |       element: element.props.element,
 | 
| 1322 |       Component: element.props.Component,
 | 
| 1323 |       index: element.props.index,
 | 
| 1324 |       path: element.props.path,
 | 
| 1325 |       loader: element.props.loader,
 | 
| 1326 |       action: element.props.action,
 | 
| 1327 |       errorElement: element.props.errorElement,
 | 
| 1328 |       ErrorBoundary: element.props.ErrorBoundary,
 | 
| 1329 |       hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
 | 
| 1330 |       shouldRevalidate: element.props.shouldRevalidate,
 | 
| 1331 |       handle: element.props.handle,
 | 
| 1332 |       lazy: element.props.lazy
 | 
| 1333 |     };
 | 
| 1334 | 
 | 
| 1335 |     if (element.props.children) {
 | 
| 1336 |       route.children = createRoutesFromChildren(element.props.children, treePath);
 | 
| 1337 |     }
 | 
| 1338 | 
 | 
| 1339 |     routes.push(route);
 | 
| 1340 |   });
 | 
| 1341 |   return routes;
 | 
| 1342 | }
 | 
| 1343 |  | 
| 1344 |  | 
| 1345 | 
 | 
| 1346 | 
 | 
| 1347 | function renderMatches(matches) {
 | 
| 1348 |   return _renderMatches(matches);
 | 
| 1349 | }
 | 
| 1350 | 
 | 
| 1351 | function detectErrorBoundary(route) {
 | 
| 1352 |   {
 | 
| 1353 |     if (route.Component && route.element) {
 | 
| 1354 |       UNSAFE_warning(false, "You should not include both `Component` and `element` on your route - " + "`element` will be ignored.") ;
 | 
| 1355 |     }
 | 
| 1356 | 
 | 
| 1357 |     if (route.ErrorBoundary && route.errorElement) {
 | 
| 1358 |       UNSAFE_warning(false, "You should not include both `ErrorBoundary` and `errorElement` on your route - " + "`errorElement` will be ignored.") ;
 | 
| 1359 |     }
 | 
| 1360 |   } 
 | 
| 1361 |   
 | 
| 1362 | 
 | 
| 1363 | 
 | 
| 1364 |   return Boolean(route.ErrorBoundary) || Boolean(route.errorElement);
 | 
| 1365 | }
 | 
| 1366 | 
 | 
| 1367 | function createMemoryRouter(routes, opts) {
 | 
| 1368 |   return createRouter({
 | 
| 1369 |     basename: opts?.basename,
 | 
| 1370 |     history: createMemoryHistory({
 | 
| 1371 |       initialEntries: opts?.initialEntries,
 | 
| 1372 |       initialIndex: opts?.initialIndex
 | 
| 1373 |     }),
 | 
| 1374 |     hydrationData: opts?.hydrationData,
 | 
| 1375 |     routes,
 | 
| 1376 |     detectErrorBoundary
 | 
| 1377 |   }).initialize();
 | 
| 1378 | } 
 | 
| 1379 | 
 | 
| 1380 | export { Await, MemoryRouter, Navigate, Outlet, Route, Router, RouterProvider, Routes, DataRouterContext as UNSAFE_DataRouterContext, DataRouterStateContext as UNSAFE_DataRouterStateContext, LocationContext as UNSAFE_LocationContext, NavigationContext as UNSAFE_NavigationContext, RouteContext as UNSAFE_RouteContext, detectErrorBoundary as UNSAFE_detectErrorBoundary, createMemoryRouter, createRoutesFromChildren, createRoutesFromChildren as createRoutesFromElements, renderMatches, useBlocker as unstable_useBlocker, useActionData, useAsyncError, useAsyncValue, useHref, useInRouterContext, useLoaderData, useLocation, useMatch, useMatches, useNavigate, useNavigation, useNavigationType, useOutlet, useOutletContext, useParams, useResolvedPath, useRevalidator, useRouteError, useRouteLoaderData, useRoutes };
 | 
| 1381 | 
 |