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