{"version":3,"file":"router.cjs","names":[],"sources":["../../src/router.ts"],"sourcesContent":["import { createBrowserHistory, parseHref } from '@tanstack/history'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport {\n  DEFAULT_PROTOCOL_ALLOWLIST,\n  createControlledPromise,\n  decodePath,\n  deepEqual,\n  encodePathLikeUrl,\n  findLast,\n  functionalUpdate,\n  isDangerousProtocol,\n  last,\n  nullReplaceEqualDeep,\n  replaceEqualDeep,\n} from './utils'\nimport {\n  findFlatMatch,\n  findRouteMatch,\n  findSingleMatch,\n  processRouteMasks,\n  processRouteTree,\n} from './new-process-route-tree'\nimport {\n  cleanPath,\n  compileDecodeCharMap,\n  interpolatePath,\n  resolvePath,\n  trimPath,\n  trimPathRight,\n} from './path'\nimport { createLRUCache } from './lru-cache'\nimport { isNotFound } from './not-found'\nimport { setupScrollRestoration } from './scroll-restoration'\nimport { defaultParseSearch, defaultStringifySearch } from './searchParams'\nimport { rootRouteId } from './root'\nimport { isRedirect, redirect } from './redirect'\nimport { loadMatches, loadRouteChunk, routeNeedsPreload } from './load-matches'\nimport {\n  composeRewrites,\n  executeRewriteInput,\n  executeRewriteOutput,\n  rewriteBasepath,\n} from './rewrite'\nimport { createRouterStores } from './stores'\nimport type { LRUCache } from './lru-cache'\nimport type {\n  ProcessRouteTreeResult,\n  ProcessedTree,\n} from './new-process-route-tree'\nimport type { SearchParser, SearchSerializer } from './searchParams'\nimport type { AnyRedirect, ResolvedRedirect } from './redirect'\nimport type {\n  HistoryLocation,\n  HistoryState,\n  ParsedHistoryState,\n  RouterHistory,\n} from '@tanstack/history'\n\nimport type {\n  Awaitable,\n  Constrain,\n  ControlledPromise,\n  NoInfer,\n  NonNullableUpdater,\n  PickAsRequired,\n  Updater,\n} from './utils'\nimport type { ParsedLocation } from './location'\nimport type {\n  AnyContext,\n  AnyRoute,\n  AnyRouteWithContext,\n  LoaderStaleReloadMode,\n  MakeRemountDepsOptionsUnion,\n  RouteContextOptions,\n  RouteLike,\n  RouteMask,\n  SearchMiddleware,\n} from './route'\nimport type {\n  FullSearchSchema,\n  RouteById,\n  RoutePaths,\n  RoutesById,\n  RoutesByPath,\n} from './routeInfo'\nimport type {\n  AnyRouteMatch,\n  MakeRouteMatch,\n  MakeRouteMatchUnion,\n  MatchRouteOptions,\n} from './Matches'\nimport type {\n  BuildLocationFn,\n  CommitLocationOptions,\n  NavigateFn,\n} from './RouterProvider'\nimport type { Manifest, RouterManagedTag } from './manifest'\nimport type { AnySchema, AnyValidator } from './validators'\nimport type { NavigateOptions, ResolveRelativePath, ToOptions } from './link'\nimport type { NotFoundError } from './not-found'\nimport type {\n  AnySerializationAdapter,\n  ValidateSerializableInput,\n} from './ssr/serializer/transformer'\nimport type { GetStoreConfig, RouterStores } from './stores'\n\nexport type ControllablePromise<T = any> = Promise<T> & {\n  resolve: (value: T) => void\n  reject: (value?: any) => void\n}\n\nexport type InjectedHtmlEntry = Promise<string>\n\nexport interface Register {\n  // Lots of things on here like...\n  // router\n  // config\n  // ssr\n}\n\nexport type RegisteredSsr<TRegister = Register> = TRegister extends {\n  ssr: infer TSSR\n}\n  ? TSSR\n  : false\n\nexport type RegisteredRouter<TRegister = Register> = TRegister extends {\n  router: infer TRouter\n}\n  ? TRouter\n  : AnyRouter\n\nexport type RegisteredConfigType<TRegister, TKey> = TRegister extends {\n  config: infer TConfig\n}\n  ? TConfig extends {\n      '~types': infer TTypes\n    }\n    ? TKey extends keyof TTypes\n      ? TTypes[TKey]\n      : unknown\n    : unknown\n  : unknown\n\nexport type DefaultRemountDepsFn<TRouteTree extends AnyRoute> = (\n  opts: MakeRemountDepsOptionsUnion<TRouteTree>,\n) => any\n\nexport interface DefaultRouterOptionsExtensions {}\n\nexport interface RouterOptionsExtensions extends DefaultRouterOptionsExtensions {}\n\nexport type SSROption = boolean | 'data-only'\n\nexport interface RouterOptions<\n  TRouteTree extends AnyRoute,\n  TTrailingSlashOption extends TrailingSlashOption,\n  TDefaultStructuralSharingOption extends boolean = false,\n  TRouterHistory extends RouterHistory = RouterHistory,\n  TDehydrated = undefined,\n> extends RouterOptionsExtensions {\n  /**\n   * The history object that will be used to manage the browser history.\n   *\n   * If not provided, a new createBrowserHistory instance will be created and used.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#history-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/history-types)\n   */\n  history?: TRouterHistory\n  /**\n   * A function that will be used to stringify search params when generating links.\n   *\n   * @default defaultStringifySearch\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#stringifysearch-method)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)\n   */\n  stringifySearch?: SearchSerializer\n  /**\n   * A function that will be used to parse search params when parsing the current location.\n   *\n   * @default defaultParseSearch\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#parsesearch-method)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/custom-search-param-serialization)\n   */\n  parseSearch?: SearchParser\n  /**\n   * If `false`, routes will not be preloaded by default in any way.\n   *\n   * If `'intent'`, routes will be preloaded by default when the user hovers over a link or a `touchstart` event is detected on a `<Link>`.\n   *\n   * If `'viewport'`, routes will be preloaded by default when they are within the viewport.\n   *\n   * @default false\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreload-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n   */\n  defaultPreload?: false | 'intent' | 'viewport' | 'render'\n  /**\n   * The delay in milliseconds that a route must be hovered over or touched before it is preloaded.\n   *\n   * @default 50\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloaddelay-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-delay)\n   */\n  defaultPreloadDelay?: number\n  /**\n   * The default `preloadIntentProximity` a route should use if no preloadIntentProximity is provided.\n   *\n   * @default 0\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadintentproximity-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading#preload-intent-proximity)\n   */\n  defaultPreloadIntentProximity?: number\n  /**\n   * The default `pendingMs` a route should use if no pendingMs is provided.\n   *\n   * @default 1000\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingms-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)\n   */\n  defaultPendingMs?: number\n  /**\n   * The default `pendingMinMs` a route should use if no pendingMinMs is provided.\n   *\n   * @default 500\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpendingminms-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#avoiding-pending-component-flash)\n   */\n  defaultPendingMinMs?: number\n  /**\n   * The default `staleTime` a route should use if no staleTime is provided. This is the time in milliseconds that a route will be considered fresh.\n   *\n   * @default 0\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstaletime-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)\n   */\n  defaultStaleTime?: number\n  /**\n   * The default stale reload mode a route loader should use if no `loader.staleReloadMode` is provided.\n   *\n   * `'background'` preserves the current stale-while-revalidate behavior.\n   * `'blocking'` waits for stale loader reloads to complete before resolving navigation.\n   *\n   * @default 'background'\n   */\n  defaultStaleReloadMode?: LoaderStaleReloadMode\n  /**\n   * The default `preloadStaleTime` a route should use if no preloadStaleTime is provided.\n   *\n   * @default 30_000 `(30 seconds)`\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadstaletime-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n   */\n  defaultPreloadStaleTime?: number\n  /**\n   * The default `defaultPreloadGcTime` a route should use if no preloadGcTime is provided.\n   *\n   * @default 1_800_000 `(30 minutes)`\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultpreloadgctime-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/preloading)\n   */\n  defaultPreloadGcTime?: number\n  /**\n   * If `true`, route navigations will called using `document.startViewTransition()`.\n   *\n   * If the browser does not support this api, this option will be ignored.\n   *\n   * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Document/startViewTransition) for more information on how this function works.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultviewtransition-property)\n   */\n  defaultViewTransition?: boolean | ViewTransitionOptions\n  /**\n   * The default `hashScrollIntoView` a route should use if no hashScrollIntoView is provided while navigating\n   *\n   * See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) for more information on `ScrollIntoViewOptions`.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaulthashscrollintoview-property)\n   */\n  defaultHashScrollIntoView?: boolean | ScrollIntoViewOptions\n  /**\n   * @default 'fuzzy'\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundmode-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/not-found-errors#the-notfoundmode-option)\n   */\n  notFoundMode?: 'root' | 'fuzzy'\n  /**\n   * The default `gcTime` a route should use if no gcTime is provided.\n   *\n   * @default 1_800_000 `(30 minutes)`\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultgctime-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/data-loading#key-options)\n   */\n  defaultGcTime?: number\n  /**\n   * If `true`, all routes will be matched as case-sensitive.\n   *\n   * @default false\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#casesensitive-property)\n   */\n  caseSensitive?: boolean\n  /**\n   *\n   * The route tree that will be used to configure the router instance.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routetree-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/routing/route-trees)\n   */\n  routeTree?: TRouteTree\n  /**\n   * The basepath for then entire router. This is useful for mounting a router instance at a subpath.\n   * ```\n   * @default '/'\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#basepath-property)\n   */\n  basepath?: string\n  /**\n   * The root context that will be provided to all routes in the route tree.\n   *\n   * This can be used to provide a context to all routes in the tree without having to provide it to each route individually.\n   *\n   * Optional or required if the root route was created with [`createRootRouteWithContext()`](https://tanstack.com/router/latest/docs/framework/react/api/router/createRootRouteWithContextFunction).\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#context-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/router-context)\n   */\n  context?: InferRouterContext<TRouteTree>\n\n  additionalContext?: any\n\n  /**\n   * A function that will be called when the router is dehydrated.\n   *\n   * The return value of this function will be serialized and stored in the router's dehydrated state.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#dehydrate-method)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)\n   */\n  dehydrate?: () => Constrain<\n    TDehydrated,\n    ValidateSerializableInput<Register, TDehydrated>\n  >\n  /**\n   * A function that will be called when the router is hydrated.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#hydrate-method)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/external-data-loading#critical-dehydrationhydration)\n   */\n  hydrate?: (dehydrated: TDehydrated) => Awaitable<void>\n  /**\n   * An array of route masks that will be used to mask routes in the route tree.\n   *\n   * Route masking is when you display a route at a different path than the one it is configured to match, like a modal popup that when shared will unmask to the modal's content instead of the modal's context.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#routemasks-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking)\n   */\n  routeMasks?: Array<RouteMask<TRouteTree>>\n  /**\n   * If `true`, route masks will, by default, be removed when the page is reloaded.\n   *\n   * This can be overridden on a per-mask basis by setting the `unmaskOnReload` option on the mask, or on a per-navigation basis by setting the `unmaskOnReload` option in the `Navigate` options.\n   *\n   * @default false\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#unmaskonreload-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/route-masking#unmasking-on-page-reload)\n   */\n  unmaskOnReload?: boolean\n\n  /**\n   * Use `notFoundComponent` instead.\n   *\n   * @deprecated\n   * See https://tanstack.com/router/v1/docs/guide/not-found-errors#migrating-from-notfoundroute for more info.\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#notfoundroute-property)\n   */\n  notFoundRoute?: AnyRoute\n  /**\n   * Configures how trailing slashes are treated.\n   *\n   * - `'always'` will add a trailing slash if not present\n   * - `'never'` will remove the trailing slash if present\n   * - `'preserve'` will not modify the trailing slash.\n   *\n   * @default 'never'\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#trailingslash-property)\n   */\n  trailingSlash?: TTrailingSlashOption\n  /**\n   * While usually automatic, sometimes it can be useful to force the router into a server-side state, e.g. when using the router in a non-browser environment that has access to a global.document object.\n   *\n   * @default typeof document !== 'undefined'\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#isserver-property)\n   */\n  isServer?: boolean\n\n  /**\n   * @default false\n   */\n  isShell?: boolean\n\n  /**\n   * @default false\n   */\n  isPrerendering?: boolean\n\n  /**\n   * The default `ssr` a route should use if no `ssr` is provided.\n   *\n   * @default true\n   */\n  defaultSsr?: SSROption\n\n  search?: {\n    /**\n     * Configures how unknown search params (= not returned by any `validateSearch`) are treated.\n     *\n     * @default false\n     * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#search.strict-property)\n     */\n    strict?: boolean\n  }\n\n  /**\n   * Configures whether structural sharing is enabled by default for fine-grained selectors.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#defaultstructuralsharing-property)\n   */\n  defaultStructuralSharing?: TDefaultStructuralSharingOption\n\n  /**\n   * Configures which URI characters are allowed in path params that would ordinarily be escaped by encodeURIComponent.\n   *\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#pathparamsallowedcharacters-property)\n   * @link [Guide](https://tanstack.com/router/latest/docs/framework/react/guide/path-params#allowed-characters)\n   */\n  pathParamsAllowedCharacters?: Array<\n    ';' | ':' | '@' | '&' | '=' | '+' | '$' | ','\n  >\n\n  defaultRemountDeps?: DefaultRemountDepsFn<TRouteTree>\n\n  /**\n   * If `true`, scroll restoration will be enabled\n   *\n   * @default false\n   */\n  scrollRestoration?:\n    | boolean\n    | ((opts: { location: ParsedLocation }) => boolean)\n\n  /**\n   * A function that will be called to get the key for the scroll restoration cache.\n   *\n   * @default (location) => location.href\n   */\n  getScrollRestorationKey?: (location: ParsedLocation) => string\n  /**\n   * The default behavior for scroll restoration.\n   *\n   * @default 'auto'\n   */\n  scrollRestorationBehavior?: ScrollBehavior\n  /**\n   * An array of selectors that will be used to scroll to the top of the page in addition to `window`\n   *\n   * @default ['window']\n   */\n  scrollToTopSelectors?: Array<string | (() => Element | null | undefined)>\n\n  /**\n   * When `true`, disables the global catch boundary that normally wraps all route matches.\n   * This allows unhandled errors to bubble up to top-level error handlers in the browser.\n   *\n   * Useful for testing tools (like Storybook Test Runner), error reporting services,\n   * and debugging scenarios where you want errors to reach the browser's global error handlers.\n   *\n   * @default false\n   */\n  disableGlobalCatchBoundary?: boolean\n\n  /**\n   * An array of URL protocols to allow in links, redirects, and navigation.\n   * Absolute URLs with protocols not in this list will be rejected.\n   *\n   * @default DEFAULT_PROTOCOL_ALLOWLIST (http:, https:, mailto:, tel:)\n   * @link [API Docs](https://tanstack.com/router/latest/docs/framework/react/api/router/RouterOptionsType#protocolallowlist-property)\n   */\n  protocolAllowlist?: Array<string>\n\n  serializationAdapters?: ReadonlyArray<AnySerializationAdapter>\n  /**\n   * Configures how the router will rewrite the location between the actual href and the internal href of the router.\n   *\n   * @default undefined\n   * @description You can provide a custom rewrite pair (in/out).\n   * This is useful for shifting data from the origin to the path (for things like subdomain routing), or other advanced use cases.\n   */\n  rewrite?: LocationRewrite\n  origin?: string\n  ssr?: {\n    nonce?: string\n  }\n}\n\nexport type LocationRewrite = {\n  /**\n   * A function that will be called to rewrite the URL before it is interpreted by the router from the history instance.\n   *\n   * @default undefined\n   */\n  input?: LocationRewriteFunction\n  /**\n   * A function that will be called to rewrite the URL before it is committed to the actual history instance from the router.\n   *\n   * @default undefined\n   */\n  output?: LocationRewriteFunction\n}\n\n/**\n * A function that will be called to rewrite the URL.\n *\n * @param url The URL to rewrite.\n * @returns The rewritten URL (as a URL instance or full href string) or undefined if no rewrite is needed.\n */\nexport type LocationRewriteFunction = ({\n  url,\n}: {\n  url: URL\n}) => undefined | string | URL\n\nexport interface RouterState<\n  in out TRouteTree extends AnyRoute = AnyRoute,\n  in out TRouteMatch = MakeRouteMatchUnion,\n> {\n  status: 'pending' | 'idle'\n  loadedAt: number\n  isLoading: boolean\n  isTransitioning: boolean\n  matches: Array<TRouteMatch>\n  location: ParsedLocation<FullSearchSchema<TRouteTree>>\n  resolvedLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>\n  statusCode: number\n  redirect?: AnyRedirect\n}\n\nexport interface BuildNextOptions {\n  to?: string | number | null\n  params?: true | Updater<unknown>\n  search?: true | Updater<unknown>\n  hash?: true | Updater<string>\n  state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>\n  mask?: {\n    to?: string | number | null\n    params?: true | Updater<unknown>\n    search?: true | Updater<unknown>\n    hash?: true | Updater<string>\n    state?: true | NonNullableUpdater<ParsedHistoryState, HistoryState>\n    unmaskOnReload?: boolean\n  }\n  from?: string\n  href?: string\n  _fromLocation?: ParsedLocation\n  unsafeRelative?: 'path'\n  _isNavigate?: boolean\n}\n\ntype NavigationEventInfo = {\n  fromLocation?: ParsedLocation\n  toLocation: ParsedLocation\n  pathChanged: boolean\n  hrefChanged: boolean\n  hashChanged: boolean\n}\n\nexport interface RouterEvents {\n  onBeforeNavigate: {\n    type: 'onBeforeNavigate'\n  } & NavigationEventInfo\n  onBeforeLoad: {\n    type: 'onBeforeLoad'\n  } & NavigationEventInfo\n  onLoad: {\n    type: 'onLoad'\n  } & NavigationEventInfo\n  onResolved: {\n    type: 'onResolved'\n  } & NavigationEventInfo\n  onBeforeRouteMount: {\n    type: 'onBeforeRouteMount'\n  } & NavigationEventInfo\n  onRendered: {\n    type: 'onRendered'\n  } & NavigationEventInfo\n}\n\nexport type RouterEvent = RouterEvents[keyof RouterEvents]\n\nexport type ListenerFn<TEvent extends RouterEvent> = (event: TEvent) => void\n\nexport type RouterListener<TRouterEvent extends RouterEvent> = {\n  eventType: TRouterEvent['type']\n  fn: ListenerFn<TRouterEvent>\n}\n\nexport type SubscribeFn = <TType extends keyof RouterEvents>(\n  eventType: TType,\n  fn: ListenerFn<RouterEvents[TType]>,\n) => () => void\n\nexport interface MatchRoutesOpts {\n  preload?: boolean\n  throwOnError?: boolean\n  dest?: BuildNextOptions\n}\n\nexport type InferRouterContext<TRouteTree extends AnyRoute> =\n  TRouteTree['types']['routerContext']\n\nexport type RouterContextOptions<TRouteTree extends AnyRoute> =\n  AnyContext extends InferRouterContext<TRouteTree>\n    ? {\n        context?: InferRouterContext<TRouteTree>\n      }\n    : {\n        context: InferRouterContext<TRouteTree>\n      }\n\nexport type RouterConstructorOptions<\n  TRouteTree extends AnyRoute,\n  TTrailingSlashOption extends TrailingSlashOption,\n  TDefaultStructuralSharingOption extends boolean,\n  TRouterHistory extends RouterHistory,\n  TDehydrated extends Record<string, any>,\n> = Omit<\n  RouterOptions<\n    TRouteTree,\n    TTrailingSlashOption,\n    TDefaultStructuralSharingOption,\n    TRouterHistory,\n    TDehydrated\n  >,\n  'context' | 'serializationAdapters' | 'defaultSsr'\n> &\n  RouterContextOptions<TRouteTree>\n\nexport type PreloadRouteFn<\n  TRouteTree extends AnyRoute,\n  TTrailingSlashOption extends TrailingSlashOption,\n  TDefaultStructuralSharingOption extends boolean,\n  TRouterHistory extends RouterHistory,\n> = <\n  TFrom extends RoutePaths<TRouteTree> | string = string,\n  TTo extends string | undefined = undefined,\n  TMaskFrom extends RoutePaths<TRouteTree> | string = TFrom,\n  TMaskTo extends string = '',\n>(\n  opts: NavigateOptions<\n    RouterCore<\n      TRouteTree,\n      TTrailingSlashOption,\n      TDefaultStructuralSharingOption,\n      TRouterHistory\n    >,\n    TFrom,\n    TTo,\n    TMaskFrom,\n    TMaskTo\n  > & {\n    /**\n     * @internal\n     * A **trusted** built location that can be used to redirect to.\n     */\n    _builtLocation?: ParsedLocation\n  },\n) => Promise<Array<AnyRouteMatch> | undefined>\n\nexport type MatchRouteFn<\n  TRouteTree extends AnyRoute,\n  TTrailingSlashOption extends TrailingSlashOption,\n  TDefaultStructuralSharingOption extends boolean,\n  TRouterHistory extends RouterHistory,\n> = <\n  TFrom extends RoutePaths<TRouteTree> = '/',\n  TTo extends string | undefined = undefined,\n  TResolved = ResolveRelativePath<TFrom, NoInfer<TTo>>,\n>(\n  location: ToOptions<\n    RouterCore<\n      TRouteTree,\n      TTrailingSlashOption,\n      TDefaultStructuralSharingOption,\n      TRouterHistory\n    >,\n    TFrom,\n    TTo\n  >,\n  opts?: MatchRouteOptions,\n) => false | RouteById<TRouteTree, TResolved>['types']['allParams']\n\nexport type UpdateFn<\n  TRouteTree extends AnyRoute,\n  TTrailingSlashOption extends TrailingSlashOption,\n  TDefaultStructuralSharingOption extends boolean,\n  TRouterHistory extends RouterHistory,\n  TDehydrated extends Record<string, any>,\n> = (\n  newOptions: RouterConstructorOptions<\n    TRouteTree,\n    TTrailingSlashOption,\n    TDefaultStructuralSharingOption,\n    TRouterHistory,\n    TDehydrated\n  >,\n) => void\n\nexport type InvalidateFn<TRouter extends AnyRouter> = (opts?: {\n  filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean\n  sync?: boolean\n  forcePending?: boolean\n}) => Promise<void>\n\nexport type ParseLocationFn<TRouteTree extends AnyRoute> = (\n  locationToParse: HistoryLocation,\n  previousLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>,\n) => ParsedLocation<FullSearchSchema<TRouteTree>>\n\nexport type GetMatchRoutesFn = (pathname: string) => {\n  matchedRoutes: ReadonlyArray<AnyRoute>\n  /** exhaustive params, still in their string form */\n  routeParams: Record<string, string>\n  /** partial params, parsed from routeParams during matching */\n  parsedParams: Record<string, unknown> | undefined\n  foundRoute: AnyRoute | undefined\n  parseError?: unknown\n}\n\nexport type EmitFn = (routerEvent: RouterEvent) => void\n\nexport type LoadFn = (opts?: { sync?: boolean }) => Promise<void>\n\nexport type CommitLocationFn = ({\n  viewTransition,\n  ignoreBlocker,\n  ...next\n}: ParsedLocation & CommitLocationOptions) => Promise<void>\n\nexport type StartTransitionFn = (fn: () => void) => void\n\nexport interface MatchRoutesFn {\n  (\n    pathname: string,\n    locationSearch?: AnySchema,\n    opts?: MatchRoutesOpts,\n  ): Array<MakeRouteMatchUnion>\n  /**\n   * @deprecated use the following signature instead\n   */\n  (next: ParsedLocation, opts?: MatchRoutesOpts): Array<AnyRouteMatch>\n  (\n    pathnameOrNext: string | ParsedLocation,\n    locationSearchOrOpts?: AnySchema | MatchRoutesOpts,\n    opts?: MatchRoutesOpts,\n  ): Array<AnyRouteMatch>\n}\n\nexport type GetMatchFn = (matchId: string) => AnyRouteMatch | undefined\n\nexport type UpdateMatchFn = (\n  id: string,\n  updater: (match: AnyRouteMatch) => AnyRouteMatch,\n) => void\n\nexport type LoadRouteChunkFn = (route: AnyRoute) => Promise<Array<void>>\n\nexport type ResolveRedirect = (err: AnyRedirect) => ResolvedRedirect\n\nexport type ClearCacheFn<TRouter extends AnyRouter> = (opts?: {\n  filter?: (d: MakeRouteMatchUnion<TRouter>) => boolean\n}) => void\n\nexport interface ServerSsr {\n  /**\n   * Injects HTML synchronously into the stream.\n   * Emits an onInjectedHtml event that listeners can handle.\n   * If no subscriber is listening, the HTML is buffered and can be retrieved via takeBufferedHtml().\n   */\n  injectHtml: (html: string) => void\n  /**\n   * Injects a script tag synchronously into the stream.\n   */\n  injectScript: (script: string) => void\n  isDehydrated: () => boolean\n  isSerializationFinished: () => boolean\n  onRenderFinished: (listener: () => void) => void\n  setRenderFinished: () => void\n  cleanup: () => void\n  onSerializationFinished: (listener: () => void) => void\n  dehydrate: (opts?: {\n    requestAssets?: Array<RouterManagedTag>\n  }) => Promise<void>\n  takeBufferedScripts: () => RouterManagedTag | undefined\n  /**\n   * Takes any buffered HTML that was injected.\n   * Returns the buffered HTML string (which may include multiple script tags) or undefined if empty.\n   */\n  takeBufferedHtml: () => string | undefined\n  liftScriptBarrier: () => void\n}\n\nexport type AnyRouterWithContext<TContext> = RouterCore<\n  AnyRouteWithContext<TContext>,\n  any,\n  any,\n  any,\n  any\n>\n\nexport type AnyRouter = RouterCore<any, any, any, any, any>\n\nexport interface ViewTransitionOptions {\n  types:\n    | Array<string>\n    | ((locationChangeInfo: {\n        fromLocation?: ParsedLocation\n        toLocation: ParsedLocation\n        pathChanged: boolean\n        hrefChanged: boolean\n        hashChanged: boolean\n      }) => Array<string> | false)\n}\n\n// TODO where is this used? can we remove this?\n/**\n * Convert an unknown error into a minimal, serializable object.\n * Includes name and message (and stack in development).\n */\nexport function defaultSerializeError(err: unknown) {\n  if (err instanceof Error) {\n    const obj = {\n      name: err.name,\n      message: err.message,\n    }\n\n    if (process.env.NODE_ENV === 'development') {\n      ;(obj as any).stack = err.stack\n    }\n\n    return obj\n  }\n\n  return {\n    data: err,\n  }\n}\n\n/** Options for configuring trailing-slash behavior. */\nexport const trailingSlashOptions = {\n  always: 'always',\n  never: 'never',\n  preserve: 'preserve',\n} as const\n\nexport type TrailingSlashOption =\n  (typeof trailingSlashOptions)[keyof typeof trailingSlashOptions]\n\n/**\n * Compute whether path, href or hash changed between previous and current\n * resolved locations.\n */\nexport function getLocationChangeInfo(\n  location: ParsedLocation,\n  resolvedLocation?: ParsedLocation,\n) {\n  const fromLocation = resolvedLocation\n  const toLocation = location\n  const pathChanged = fromLocation?.pathname !== toLocation.pathname\n  const hrefChanged = fromLocation?.href !== toLocation.href\n  const hashChanged = fromLocation?.hash !== toLocation.hash\n  return { fromLocation, toLocation, pathChanged, hrefChanged, hashChanged }\n}\n\nexport type CreateRouterFn = <\n  TRouteTree extends AnyRoute,\n  TTrailingSlashOption extends TrailingSlashOption = 'never',\n  TDefaultStructuralSharingOption extends boolean = false,\n  TRouterHistory extends RouterHistory = RouterHistory,\n  TDehydrated extends Record<string, any> = Record<string, any>,\n>(\n  options: undefined extends number\n    ? 'strictNullChecks must be enabled in tsconfig.json'\n    : RouterConstructorOptions<\n        TRouteTree,\n        TTrailingSlashOption,\n        TDefaultStructuralSharingOption,\n        TRouterHistory,\n        TDehydrated\n      >,\n) => RouterCore<\n  TRouteTree,\n  TTrailingSlashOption,\n  TDefaultStructuralSharingOption,\n  TRouterHistory,\n  TDehydrated\n>\n\ndeclare global {\n  // eslint-disable-next-line no-var\n  var __TSR_CACHE__:\n    | {\n        routeTree: AnyRoute\n        processRouteTreeResult: ProcessRouteTreeResult<AnyRoute>\n        resolvePathCache: LRUCache<string, string>\n      }\n    | undefined\n}\n\n/**\n * Core, framework-agnostic router engine that powers TanStack Router.\n *\n * Provides navigation, matching, loading, preloading, caching and event APIs\n * used by framework adapters (React/Solid). Prefer framework helpers like\n * `createRouter` in app code.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType\n */\nexport class RouterCore<\n  in out TRouteTree extends AnyRoute,\n  in out TTrailingSlashOption extends TrailingSlashOption,\n  in out TDefaultStructuralSharingOption extends boolean,\n  in out TRouterHistory extends RouterHistory = RouterHistory,\n  in out TDehydrated extends Record<string, any> = Record<string, any>,\n> {\n  // Option-independent properties\n  tempLocationKey: string | undefined = `${Math.round(\n    Math.random() * 10000000,\n  )}`\n  resetNextScroll = true\n  shouldViewTransition?: boolean | ViewTransitionOptions = undefined\n  isViewTransitionTypesSupported?: boolean = undefined\n  subscribers = new Set<RouterListener<RouterEvent>>()\n  viewTransitionPromise?: ControlledPromise<true>\n  isScrollRestoring = false\n  isScrollRestorationSetup = false\n\n  // Must build in constructor\n  stores!: RouterStores<TRouteTree>\n  private getStoreConfig!: GetStoreConfig\n  batch!: (fn: () => void) => void\n\n  options!: PickAsRequired<\n    RouterOptions<\n      TRouteTree,\n      TTrailingSlashOption,\n      TDefaultStructuralSharingOption,\n      TRouterHistory,\n      TDehydrated\n    >,\n    'stringifySearch' | 'parseSearch' | 'context'\n  >\n  history!: TRouterHistory\n  rewrite?: LocationRewrite\n  origin?: string\n  latestLocation!: ParsedLocation<FullSearchSchema<TRouteTree>>\n  pendingBuiltLocation?: ParsedLocation<FullSearchSchema<TRouteTree>>\n  basepath!: string\n  routeTree!: TRouteTree\n  routesById!: RoutesById<TRouteTree>\n  routesByPath!: RoutesByPath<TRouteTree>\n  processedTree!: ProcessedTree<TRouteTree, any, any>\n  resolvePathCache!: LRUCache<string, string>\n  isServer!: boolean\n  pathParamsDecoder?: (encoded: string) => string\n  protocolAllowlist!: Set<string>\n\n  /**\n   * @deprecated Use the `createRouter` function instead\n   */\n  constructor(\n    options: RouterConstructorOptions<\n      TRouteTree,\n      TTrailingSlashOption,\n      TDefaultStructuralSharingOption,\n      TRouterHistory,\n      TDehydrated\n    >,\n    getStoreConfig: GetStoreConfig,\n  ) {\n    this.getStoreConfig = getStoreConfig\n\n    this.update({\n      defaultPreloadDelay: 50,\n      defaultPendingMs: 1000,\n      defaultPendingMinMs: 500,\n      context: undefined!,\n      ...options,\n      caseSensitive: options.caseSensitive ?? false,\n      notFoundMode: options.notFoundMode ?? 'fuzzy',\n      stringifySearch: options.stringifySearch ?? defaultStringifySearch,\n      parseSearch: options.parseSearch ?? defaultParseSearch,\n      protocolAllowlist:\n        options.protocolAllowlist ?? DEFAULT_PROTOCOL_ALLOWLIST,\n    })\n\n    if (typeof document !== 'undefined') {\n      self.__TSR_ROUTER__ = this\n    }\n  }\n\n  // This is a default implementation that can optionally be overridden\n  // by the router provider once rendered. We provide this so that the\n  // router can be used in a non-react environment if necessary\n  startTransition: StartTransitionFn = (fn) => fn()\n\n  isShell() {\n    return !!this.options.isShell\n  }\n\n  isPrerendering() {\n    return !!this.options.isPrerendering\n  }\n\n  update: UpdateFn<\n    TRouteTree,\n    TTrailingSlashOption,\n    TDefaultStructuralSharingOption,\n    TRouterHistory,\n    TDehydrated\n  > = (newOptions) => {\n    if (process.env.NODE_ENV !== 'production') {\n      if (newOptions.notFoundRoute) {\n        console.warn(\n          'The notFoundRoute API is deprecated and will be removed in the next major version. See https://tanstack.com/router/v1/docs/framework/react/guide/not-found-errors#migrating-from-notfoundroute for more info.',\n        )\n      }\n    }\n\n    const prevOptions = this.options\n    const prevBasepath = this.basepath ?? prevOptions?.basepath ?? '/'\n    const basepathWasUnset = this.basepath === undefined\n    const prevRewriteOption = prevOptions?.rewrite\n\n    this.options = {\n      ...prevOptions,\n      ...newOptions,\n    }\n\n    this.isServer = this.options.isServer ?? typeof document === 'undefined'\n\n    this.protocolAllowlist = new Set(this.options.protocolAllowlist)\n\n    if (this.options.pathParamsAllowedCharacters)\n      this.pathParamsDecoder = compileDecodeCharMap(\n        this.options.pathParamsAllowedCharacters,\n      )\n\n    if (\n      !this.history ||\n      (this.options.history && this.options.history !== this.history)\n    ) {\n      if (!this.options.history) {\n        if (!(isServer ?? this.isServer)) {\n          this.history = createBrowserHistory() as TRouterHistory\n        }\n      } else {\n        this.history = this.options.history\n      }\n    }\n\n    this.origin = this.options.origin\n    if (!this.origin) {\n      if (\n        !(isServer ?? this.isServer) &&\n        window?.origin &&\n        window.origin !== 'null'\n      ) {\n        this.origin = window.origin\n      } else {\n        // fallback for the server, can be overridden by calling router.update({origin}) on the server\n        this.origin = 'http://localhost'\n      }\n    }\n\n    if (this.history) {\n      this.updateLatestLocation()\n    }\n\n    if (this.options.routeTree !== this.routeTree) {\n      this.routeTree = this.options.routeTree as TRouteTree\n      let processRouteTreeResult: ProcessRouteTreeResult<TRouteTree>\n      if (\n        (isServer ?? this.isServer) &&\n        process.env.NODE_ENV !== 'development' &&\n        globalThis.__TSR_CACHE__ &&\n        globalThis.__TSR_CACHE__.routeTree === this.routeTree\n      ) {\n        const cached = globalThis.__TSR_CACHE__\n        this.resolvePathCache = cached.resolvePathCache\n        processRouteTreeResult = cached.processRouteTreeResult as any\n      } else {\n        this.resolvePathCache = createLRUCache(1000)\n        processRouteTreeResult = this.buildRouteTree()\n        // only cache if nothing else is cached yet\n        if (\n          (isServer ?? this.isServer) &&\n          process.env.NODE_ENV !== 'development' &&\n          globalThis.__TSR_CACHE__ === undefined\n        ) {\n          globalThis.__TSR_CACHE__ = {\n            routeTree: this.routeTree,\n            processRouteTreeResult: processRouteTreeResult as any,\n            resolvePathCache: this.resolvePathCache,\n          }\n        }\n      }\n      this.setRoutes(processRouteTreeResult)\n    }\n\n    if (!this.stores && this.latestLocation) {\n      const config = this.getStoreConfig(this)\n      this.batch = config.batch\n      this.stores = createRouterStores(\n        getInitialRouterState(this.latestLocation),\n        config,\n      )\n\n      if (!(isServer ?? this.isServer)) {\n        setupScrollRestoration(this)\n      }\n    }\n\n    let needsLocationUpdate = false\n    const nextBasepath = this.options.basepath ?? '/'\n    const nextRewriteOption = this.options.rewrite\n    const basepathChanged = basepathWasUnset || prevBasepath !== nextBasepath\n    const rewriteChanged = prevRewriteOption !== nextRewriteOption\n\n    if (basepathChanged || rewriteChanged) {\n      this.basepath = nextBasepath\n\n      const rewrites: Array<LocationRewrite> = []\n      const trimmed = trimPath(nextBasepath)\n      if (trimmed && trimmed !== '/') {\n        rewrites.push(\n          rewriteBasepath({\n            basepath: nextBasepath,\n          }),\n        )\n      }\n      if (nextRewriteOption) {\n        rewrites.push(nextRewriteOption)\n      }\n\n      this.rewrite =\n        rewrites.length === 0\n          ? undefined\n          : rewrites.length === 1\n            ? rewrites[0]\n            : composeRewrites(rewrites)\n\n      if (this.history) {\n        this.updateLatestLocation()\n      }\n\n      needsLocationUpdate = true\n    }\n\n    if (needsLocationUpdate && this.stores) {\n      this.stores.location.set(this.latestLocation)\n    }\n\n    if (\n      typeof window !== 'undefined' &&\n      'CSS' in window &&\n      typeof window.CSS?.supports === 'function'\n    ) {\n      this.isViewTransitionTypesSupported = window.CSS.supports(\n        'selector(:active-view-transition-type(a)',\n      )\n    }\n  }\n\n  get state(): RouterState<TRouteTree> {\n    return this.stores.__store.get()\n  }\n\n  updateLatestLocation = () => {\n    this.latestLocation = this.parseLocation(\n      this.history.location,\n      this.latestLocation,\n    )\n  }\n\n  buildRouteTree = () => {\n    const result = processRouteTree(\n      this.routeTree,\n      this.options.caseSensitive,\n      (route, i) => {\n        route.init({\n          originalIndex: i,\n        })\n      },\n    )\n    if (this.options.routeMasks) {\n      processRouteMasks(this.options.routeMasks, result.processedTree)\n    }\n\n    return result\n  }\n\n  setRoutes({\n    routesById,\n    routesByPath,\n    processedTree,\n  }: ProcessRouteTreeResult<TRouteTree>) {\n    this.routesById = routesById as RoutesById<TRouteTree>\n    this.routesByPath = routesByPath as RoutesByPath<TRouteTree>\n    this.processedTree = processedTree\n\n    const notFoundRoute = this.options.notFoundRoute\n\n    if (notFoundRoute) {\n      notFoundRoute.init({\n        originalIndex: 99999999999,\n      })\n      this.routesById[notFoundRoute.id] = notFoundRoute\n    }\n  }\n\n  /**\n   * Subscribe to router lifecycle events like `onBeforeNavigate`, `onLoad`,\n   * `onResolved`, etc. Returns an unsubscribe function.\n   *\n   * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterEventsType\n   */\n  subscribe: SubscribeFn = (eventType, fn) => {\n    const listener: RouterListener<any> = {\n      eventType,\n      fn,\n    }\n\n    this.subscribers.add(listener)\n\n    return () => {\n      this.subscribers.delete(listener)\n    }\n  }\n\n  emit: EmitFn = (routerEvent) => {\n    this.subscribers.forEach((listener) => {\n      if (listener.eventType === routerEvent.type) {\n        listener.fn(routerEvent)\n      }\n    })\n  }\n\n  /**\n   * Parse a HistoryLocation into a strongly-typed ParsedLocation using the\n   * current router options, rewrite rules and search parser/stringifier.\n   */\n  parseLocation: ParseLocationFn<TRouteTree> = (\n    locationToParse,\n    previousLocation,\n  ) => {\n    const parse = ({\n      pathname,\n      search,\n      hash,\n      href,\n      state,\n    }: HistoryLocation): ParsedLocation<FullSearchSchema<TRouteTree>> => {\n      // Fast path: no rewrite configured and pathname doesn't need encoding\n      // Characters that need encoding: space, high unicode, control chars\n      // eslint-disable-next-line no-control-regex\n      if (!this.rewrite && !/[ \\x00-\\x1f\\x7f\\u0080-\\uffff]/.test(pathname)) {\n        const parsedSearch = this.options.parseSearch(search)\n        const searchStr = this.options.stringifySearch(parsedSearch)\n\n        return {\n          href: pathname + searchStr + hash,\n          publicHref: pathname + searchStr + hash,\n          pathname: decodePath(pathname).path,\n          external: false,\n          searchStr,\n          search: nullReplaceEqualDeep(\n            previousLocation?.search,\n            parsedSearch,\n          ) as any,\n          hash: decodePath(hash.slice(1)).path,\n          state: replaceEqualDeep(previousLocation?.state, state),\n        }\n      }\n\n      // Before we do any processing, we need to allow rewrites to modify the URL\n      // build up the full URL by combining the href from history with the router's origin\n      const fullUrl = new URL(href, this.origin)\n\n      const url = executeRewriteInput(this.rewrite, fullUrl)\n\n      const parsedSearch = this.options.parseSearch(url.search)\n      const searchStr = this.options.stringifySearch(parsedSearch)\n      // Make sure our final url uses the re-stringified pathname, search, and has for consistency\n      // (We were already doing this, so just keeping it for now)\n      url.search = searchStr\n\n      const fullPath = url.href.replace(url.origin, '')\n\n      return {\n        href: fullPath,\n        publicHref: href,\n        pathname: decodePath(url.pathname).path,\n        external: !!this.rewrite && url.origin !== this.origin,\n        searchStr,\n        search: nullReplaceEqualDeep(\n          previousLocation?.search,\n          parsedSearch,\n        ) as any,\n        hash: decodePath(url.hash.slice(1)).path,\n        state: replaceEqualDeep(previousLocation?.state, state),\n      }\n    }\n\n    const location = parse(locationToParse)\n\n    const { __tempLocation, __tempKey } = location.state\n\n    if (__tempLocation && (!__tempKey || __tempKey === this.tempLocationKey)) {\n      // Sync up the location keys\n      const parsedTempLocation = parse(__tempLocation) as any\n      parsedTempLocation.state.key = location.state.key // TODO: Remove in v2 - use __TSR_key instead\n      parsedTempLocation.state.__TSR_key = location.state.__TSR_key\n\n      delete parsedTempLocation.state.__tempLocation\n\n      return {\n        ...parsedTempLocation,\n        maskedLocation: location,\n      }\n    }\n    return location\n  }\n\n  /** Resolve a path against the router basepath and trailing-slash policy. */\n  resolvePathWithBase = (from: string, path: string) => {\n    const resolvedPath = resolvePath({\n      base: from,\n      to: cleanPath(path),\n      trailingSlash: this.options.trailingSlash,\n      cache: this.resolvePathCache,\n    })\n    return resolvedPath\n  }\n\n  get looseRoutesById() {\n    return this.routesById as Record<string, AnyRoute>\n  }\n\n  matchRoutes: MatchRoutesFn = (\n    pathnameOrNext: string | ParsedLocation,\n    locationSearchOrOpts?: AnySchema | MatchRoutesOpts,\n    opts?: MatchRoutesOpts,\n  ) => {\n    if (typeof pathnameOrNext === 'string') {\n      return this.matchRoutesInternal(\n        {\n          pathname: pathnameOrNext,\n          search: locationSearchOrOpts,\n        } as ParsedLocation,\n        opts,\n      )\n    }\n\n    return this.matchRoutesInternal(pathnameOrNext, locationSearchOrOpts)\n  }\n\n  private getParentContext(parentMatch?: AnyRouteMatch) {\n    const parentMatchId = parentMatch?.id\n\n    const parentContext = !parentMatchId\n      ? ((this.options.context as any) ?? undefined)\n      : (parentMatch.context ?? this.options.context ?? undefined)\n\n    return parentContext\n  }\n\n  private matchRoutesInternal(\n    next: ParsedLocation,\n    opts?: MatchRoutesOpts,\n  ): Array<AnyRouteMatch> {\n    const matchedRoutesResult = this.getMatchedRoutes(next.pathname)\n    const { foundRoute, routeParams, parsedParams } = matchedRoutesResult\n    let { matchedRoutes } = matchedRoutesResult\n    let isGlobalNotFound = false\n\n    // Check to see if the route needs a 404 entry\n    if (\n      // If we found a route, and it's not an index route and we have left over path\n      foundRoute\n        ? foundRoute.path !== '/' && routeParams['**']\n        : // Or if we didn't find a route and we have left over path\n          trimPathRight(next.pathname)\n    ) {\n      // If the user has defined an (old) 404 route, use it\n      if (this.options.notFoundRoute) {\n        matchedRoutes = [...matchedRoutes, this.options.notFoundRoute]\n      } else {\n        // If there is no routes found during path matching\n        isGlobalNotFound = true\n      }\n    }\n\n    const globalNotFoundRouteId = isGlobalNotFound\n      ? findGlobalNotFoundRouteId(this.options.notFoundMode, matchedRoutes)\n      : undefined\n\n    const matches = new Array<AnyRouteMatch>(matchedRoutes.length)\n    // Snapshot of active match state keyed by routeId, used to stabilise\n    // params/search across navigations.\n    const previousActiveMatchesByRouteId = new Map<string, AnyRouteMatch>()\n    for (const store of this.stores.matchStores.values()) {\n      if (store.routeId) {\n        previousActiveMatchesByRouteId.set(store.routeId, store.get())\n      }\n    }\n\n    for (let index = 0; index < matchedRoutes.length; index++) {\n      const route = matchedRoutes[index]!\n      // Take each matched route and resolve + validate its search params\n      // This has to happen serially because each route's search params\n      // can depend on the parent route's search params\n      // It must also happen before we create the match so that we can\n      // pass the search params to the route's potential key function\n      // which is used to uniquely identify the route match in state\n\n      const parentMatch = matches[index - 1]\n\n      let preMatchSearch: Record<string, any>\n      let strictMatchSearch: Record<string, any>\n      let searchError: any\n      {\n        // Validate the search params and stabilize them\n        const parentSearch = parentMatch?.search ?? next.search\n        const parentStrictSearch = parentMatch?._strictSearch ?? undefined\n\n        try {\n          const strictSearch =\n            validateSearch(route.options.validateSearch, { ...parentSearch }) ??\n            undefined\n\n          preMatchSearch = {\n            ...parentSearch,\n            ...strictSearch,\n          }\n          strictMatchSearch = { ...parentStrictSearch, ...strictSearch }\n          searchError = undefined\n        } catch (err: any) {\n          let searchParamError = err\n          if (!(err instanceof SearchParamError)) {\n            searchParamError = new SearchParamError(err.message, {\n              cause: err,\n            })\n          }\n\n          if (opts?.throwOnError) {\n            throw searchParamError\n          }\n\n          preMatchSearch = parentSearch\n          strictMatchSearch = {}\n          searchError = searchParamError\n        }\n      }\n\n      // This is where we need to call route.options.loaderDeps() to get any additional\n      // deps that the route's loader function might need to run. We need to do this\n      // before we create the match so that we can pass the deps to the route's\n      // potential key function which is used to uniquely identify the route match in state\n\n      const loaderDeps =\n        route.options.loaderDeps?.({\n          search: preMatchSearch,\n        }) ?? ''\n\n      const loaderDepsHash = loaderDeps ? JSON.stringify(loaderDeps) : ''\n\n      const { interpolatedPath, usedParams } = interpolatePath({\n        path: route.fullPath,\n        params: routeParams,\n        decoder: this.pathParamsDecoder,\n        server: this.isServer,\n      })\n\n      // Waste not, want not. If we already have a match for this route,\n      // reuse it. This is important for layout routes, which might stick\n      // around between navigation actions that only change leaf routes.\n\n      // Existing matches are matches that are already loaded along with\n      // pending matches that are still loading\n      const matchId =\n        // route.id for disambiguation\n        route.id +\n        // interpolatedPath for param changes\n        interpolatedPath +\n        // explicit deps\n        loaderDepsHash\n\n      const existingMatch = this.getMatch(matchId)\n\n      const previousMatch = previousActiveMatchesByRouteId.get(route.id)\n\n      const strictParams = existingMatch?._strictParams ?? usedParams\n\n      let paramsError: unknown = undefined\n\n      if (!existingMatch) {\n        try {\n          extractStrictParams(route, usedParams, parsedParams!, strictParams)\n        } catch (err: any) {\n          if (isNotFound(err) || isRedirect(err)) {\n            paramsError = err\n          } else {\n            paramsError = new PathParamError(err.message, {\n              cause: err,\n            })\n          }\n\n          if (opts?.throwOnError) {\n            throw paramsError\n          }\n        }\n      }\n\n      Object.assign(routeParams, strictParams)\n\n      const cause = previousMatch ? 'stay' : 'enter'\n\n      let match: AnyRouteMatch\n\n      if (existingMatch) {\n        match = {\n          ...existingMatch,\n          cause,\n          params: previousMatch?.params ?? routeParams,\n          _strictParams: strictParams,\n          search: previousMatch\n            ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch)\n            : nullReplaceEqualDeep(existingMatch.search, preMatchSearch),\n          _strictSearch: strictMatchSearch,\n        }\n      } else {\n        const status =\n          route.options.loader ||\n          route.options.beforeLoad ||\n          route.lazyFn ||\n          routeNeedsPreload(route)\n            ? 'pending'\n            : 'success'\n\n        match = {\n          id: matchId,\n          ssr: (isServer ?? this.isServer) ? undefined : route.options.ssr,\n          index,\n          routeId: route.id,\n          params: previousMatch?.params ?? routeParams,\n          _strictParams: strictParams,\n          pathname: interpolatedPath,\n          updatedAt: Date.now(),\n          search: previousMatch\n            ? nullReplaceEqualDeep(previousMatch.search, preMatchSearch)\n            : preMatchSearch,\n          _strictSearch: strictMatchSearch,\n          searchError: undefined,\n          status,\n          isFetching: false,\n          error: undefined,\n          paramsError,\n          __routeContext: undefined,\n          _nonReactive: {\n            loadPromise: createControlledPromise(),\n          },\n          __beforeLoadContext: undefined,\n          context: {},\n          abortController: new AbortController(),\n          fetchCount: 0,\n          cause,\n          loaderDeps: previousMatch\n            ? replaceEqualDeep(previousMatch.loaderDeps, loaderDeps)\n            : loaderDeps,\n          invalid: false,\n          preload: false,\n          links: undefined,\n          scripts: undefined,\n          headScripts: undefined,\n          meta: undefined,\n          staticData: route.options.staticData || {},\n          fullPath: route.fullPath,\n        }\n      }\n\n      if (!opts?.preload) {\n        // If we have a global not found, mark the right match as global not found\n        match.globalNotFound = globalNotFoundRouteId === route.id\n      }\n\n      // update the searchError if there is one\n      match.searchError = searchError\n\n      const parentContext = this.getParentContext(parentMatch)\n\n      match.context = {\n        ...parentContext,\n        ...match.__routeContext,\n        ...match.__beforeLoadContext,\n      }\n\n      matches[index] = match\n    }\n\n    for (let index = 0; index < matches.length; index++) {\n      const match = matches[index]!\n      const route = this.looseRoutesById[match.routeId]!\n      const existingMatch = this.getMatch(match.id)\n\n      // Update the match's params\n      const previousMatch = previousActiveMatchesByRouteId.get(match.routeId)\n      match.params = previousMatch\n        ? nullReplaceEqualDeep(previousMatch.params, routeParams)\n        : routeParams\n\n      if (!existingMatch) {\n        const parentMatch = matches[index - 1]\n        const parentContext = this.getParentContext(parentMatch)\n\n        // Update the match's context\n\n        if (route.options.context) {\n          const contextFnContext: RouteContextOptions<any, any, any, any, any> =\n            {\n              deps: match.loaderDeps,\n              params: match.params,\n              context: parentContext ?? {},\n              location: next,\n              navigate: (opts: any) =>\n                this.navigate({ ...opts, _fromLocation: next }),\n              buildLocation: this.buildLocation,\n              cause: match.cause,\n              abortController: match.abortController,\n              preload: !!match.preload,\n              matches,\n              routeId: route.id,\n            }\n          // Get the route context\n          match.__routeContext =\n            route.options.context(contextFnContext) ?? undefined\n        }\n\n        match.context = {\n          ...parentContext,\n          ...match.__routeContext,\n          ...match.__beforeLoadContext,\n        }\n      }\n    }\n\n    return matches\n  }\n\n  getMatchedRoutes: GetMatchRoutesFn = (pathname) => {\n    return getMatchedRoutes({\n      pathname,\n      routesById: this.routesById,\n      processedTree: this.processedTree,\n    })\n  }\n\n  /**\n   * Lightweight route matching for buildLocation.\n   * Only computes fullPath, accumulated search, and params - skipping expensive\n   * operations like AbortController, ControlledPromise, loaderDeps, and full match objects.\n   */\n  private matchRoutesLightweight(location: ParsedLocation): {\n    matchedRoutes: ReadonlyArray<AnyRoute>\n    fullPath: string\n    search: Record<string, unknown>\n    params: Record<string, unknown>\n  } {\n    const { matchedRoutes, routeParams, parsedParams } = this.getMatchedRoutes(\n      location.pathname,\n    )\n    const lastRoute = last(matchedRoutes)!\n\n    // I don't know if we should run the full search middleware chain, or just validateSearch\n    // // Accumulate search validation through the route chain\n    // const accumulatedSearch: Record<string, unknown> = applySearchMiddleware({\n    //   search: { ...location.search },\n    //   dest: location,\n    //   destRoutes: matchedRoutes,\n    //   _includeValidateSearch: true,\n    // })\n\n    // Accumulate search validation through route chain\n    const accumulatedSearch = { ...location.search }\n    for (const route of matchedRoutes) {\n      try {\n        Object.assign(\n          accumulatedSearch,\n          validateSearch(route.options.validateSearch, accumulatedSearch),\n        )\n      } catch {\n        // Ignore errors, we're not actually routing\n      }\n    }\n\n    // Determine params: reuse from state if possible, otherwise parse\n    const lastStateMatchId = last(this.stores.matchesId.get())\n    const lastStateMatch =\n      lastStateMatchId && this.stores.matchStores.get(lastStateMatchId)?.get()\n    const canReuseParams =\n      lastStateMatch &&\n      lastStateMatch.routeId === lastRoute.id &&\n      lastStateMatch.pathname === location.pathname\n\n    let params: Record<string, unknown>\n    if (canReuseParams) {\n      params = lastStateMatch.params\n    } else {\n      // Parse params through the route chain\n      const strictParams: Record<string, unknown> = Object.assign(\n        Object.create(null),\n        routeParams,\n      )\n      for (const route of matchedRoutes) {\n        try {\n          extractStrictParams(\n            route,\n            routeParams,\n            parsedParams ?? {},\n            strictParams,\n          )\n        } catch {\n          // Ignore errors, we're not actually routing\n        }\n      }\n      params = strictParams\n    }\n\n    return {\n      matchedRoutes,\n      fullPath: lastRoute.fullPath,\n      search: accumulatedSearch,\n      params,\n    }\n  }\n\n  cancelMatch = (id: string) => {\n    const match = this.getMatch(id)\n\n    if (!match) return\n\n    match.abortController.abort()\n    clearTimeout(match._nonReactive.pendingTimeout)\n    match._nonReactive.pendingTimeout = undefined\n  }\n\n  cancelMatches = () => {\n    this.stores.pendingIds.get().forEach((matchId) => {\n      this.cancelMatch(matchId)\n    })\n\n    this.stores.matchesId.get().forEach((matchId) => {\n      if (this.stores.pendingMatchStores.has(matchId)) {\n        return\n      }\n\n      const match = this.stores.matchStores.get(matchId)?.get()\n      if (!match) {\n        return\n      }\n\n      if (match.status === 'pending' || match.isFetching === 'loader') {\n        this.cancelMatch(matchId)\n      }\n    })\n  }\n\n  /**\n   * Build the next ParsedLocation from navigation options without committing.\n   * Resolves `to`/`from`, params/search/hash/state, applies search validation\n   * and middlewares, and returns a stable, stringified location object.\n   *\n   * @link https://tanstack.com/router/latest/docs/framework/react/api/router/RouterType#buildlocation-method\n   */\n  buildLocation: BuildLocationFn = (opts) => {\n    const build = (\n      dest: BuildNextOptions & {\n        unmaskOnReload?: boolean\n      } = {},\n    ): ParsedLocation => {\n      // We allow the caller to override the current location\n      const currentLocation =\n        dest._fromLocation || this.pendingBuiltLocation || this.latestLocation\n\n      // Use lightweight matching - only computes what buildLocation needs\n      // (fullPath, search, params) without creating full match objects\n      const lightweightResult = this.matchRoutesLightweight(currentLocation)\n\n      // check that from path exists in the current route tree\n      // do this check only on navigations during test or development\n      if (\n        dest.from &&\n        process.env.NODE_ENV !== 'production' &&\n        dest._isNavigate\n      ) {\n        const allFromMatches = this.getMatchedRoutes(dest.from).matchedRoutes\n\n        const matchedFrom = findLast(lightweightResult.matchedRoutes, (d) => {\n          return comparePaths(d.fullPath, dest.from!)\n        })\n\n        const matchedCurrent = findLast(allFromMatches, (d) => {\n          return comparePaths(d.fullPath, lightweightResult.fullPath)\n        })\n\n        // for from to be invalid it shouldn't just be unmatched to currentLocation\n        // but the currentLocation should also be unmatched to from\n        if (!matchedFrom && !matchedCurrent) {\n          console.warn(`Could not find match for from: ${dest.from}`)\n        }\n      }\n\n      const defaultedFromPath =\n        dest.unsafeRelative === 'path'\n          ? currentLocation.pathname\n          : (dest.from ?? lightweightResult.fullPath)\n\n      // ensure this includes the basePath if set\n      const fromPath = this.resolvePathWithBase(defaultedFromPath, '.')\n\n      // From search should always use the current location\n      const fromSearch = lightweightResult.search\n      // Same with params. It can't hurt to provide as many as possible\n      const fromParams = Object.assign(\n        Object.create(null),\n        lightweightResult.params,\n      )\n\n      // Resolve the next to\n      // ensure this includes the basePath if set\n      const nextTo = dest.to\n        ? this.resolvePathWithBase(fromPath, `${dest.to}`)\n        : this.resolvePathWithBase(fromPath, '.')\n\n      // Resolve the next params\n      const nextParams =\n        dest.params === false || dest.params === null\n          ? Object.create(null)\n          : (dest.params ?? true) === true\n            ? fromParams\n            : Object.assign(\n                fromParams,\n                functionalUpdate(dest.params as any, fromParams),\n              )\n\n      // Use lightweight getMatchedRoutes instead of matchRoutesInternal\n      // This avoids creating full match objects (AbortController, ControlledPromise, etc.)\n      // which are expensive and not needed for buildLocation\n      const destMatchResult = this.getMatchedRoutes(nextTo)\n      let destRoutes = destMatchResult.matchedRoutes\n\n      // Compute globalNotFoundRouteId using the same logic as matchRoutesInternal\n      const isGlobalNotFound =\n        !destMatchResult.foundRoute ||\n        (destMatchResult.foundRoute.path !== '/' &&\n          destMatchResult.routeParams['**'])\n\n      if (isGlobalNotFound && this.options.notFoundRoute) {\n        destRoutes = [...destRoutes, this.options.notFoundRoute]\n      }\n\n      // If there are any params, we need to stringify them\n      if (Object.keys(nextParams).length > 0) {\n        for (const route of destRoutes) {\n          const fn =\n            route.options.params?.stringify ?? route.options.stringifyParams\n          if (fn) {\n            try {\n              Object.assign(nextParams, fn(nextParams))\n            } catch {\n              // Ignore errors here. When a paired parseParams is defined,\n              // extractStrictParams will re-throw during route matching,\n              // storing the error on the match and allowing the route's\n              // errorComponent to render. If no parseParams is defined,\n              // the stringify error is silently dropped.\n            }\n          }\n        }\n      }\n\n      const nextPathname = opts.leaveParams\n        ? // Use the original template path for interpolation\n          // This preserves the original parameter syntax including optional parameters\n          nextTo\n        : decodePath(\n            interpolatePath({\n              path: nextTo,\n              params: nextParams,\n              decoder: this.pathParamsDecoder,\n              server: this.isServer,\n            }).interpolatedPath,\n          ).path\n\n      // Resolve the next search\n      let nextSearch = fromSearch\n      if (opts._includeValidateSearch && this.options.search?.strict) {\n        const validatedSearch = {}\n        destRoutes.forEach((route) => {\n          if (route.options.validateSearch) {\n            try {\n              Object.assign(\n                validatedSearch,\n                validateSearch(route.options.validateSearch, {\n                  ...validatedSearch,\n                  ...nextSearch,\n                }),\n              )\n            } catch {\n              // ignore errors here because they are already handled in matchRoutes\n            }\n          }\n        })\n        nextSearch = validatedSearch\n      }\n\n      nextSearch = applySearchMiddleware({\n        search: nextSearch,\n        dest,\n        destRoutes,\n        _includeValidateSearch: opts._includeValidateSearch,\n      })\n\n      // Replace the equal deep\n      nextSearch = nullReplaceEqualDeep(fromSearch, nextSearch)\n\n      // Stringify the next search\n      const searchStr = this.options.stringifySearch(nextSearch)\n\n      // Resolve the next hash\n      const hash =\n        dest.hash === true\n          ? currentLocation.hash\n          : dest.hash\n            ? functionalUpdate(dest.hash, currentLocation.hash)\n            : undefined\n\n      // Resolve the next hash string\n      const hashStr = hash ? `#${hash}` : ''\n\n      // Resolve the next state\n      let nextState =\n        dest.state === true\n          ? currentLocation.state\n          : dest.state\n            ? functionalUpdate(dest.state, currentLocation.state)\n            : {}\n\n      // Replace the equal deep\n      nextState = replaceEqualDeep(currentLocation.state, nextState)\n\n      // Create the full path of the location\n      const fullPath = `${nextPathname}${searchStr}${hashStr}`\n\n      // Compute href and publicHref without URL construction when no rewrite\n      let href: string\n      let publicHref: string\n      let external = false\n\n      if (this.rewrite) {\n        // With rewrite, we need to construct URL to apply the rewrite\n        const url = new URL(fullPath, this.origin)\n        const rewrittenUrl = executeRewriteOutput(this.rewrite, url)\n        href = url.href.replace(url.origin, '')\n        // If rewrite changed the origin, publicHref needs full URL\n        // Otherwise just use the path components\n        if (rewrittenUrl.origin !== this.origin) {\n          publicHref = rewrittenUrl.href\n          external = true\n        } else {\n          publicHref =\n            rewrittenUrl.pathname + rewrittenUrl.search + rewrittenUrl.hash\n        }\n      } else {\n        // Fast path: no rewrite, skip URL construction entirely\n        // fullPath is already the correct href (origin-stripped)\n        // We need to encode non-ASCII (unicode) characters for the href\n        // since decodePath decoded them from the interpolated path\n        href = encodePathLikeUrl(fullPath)\n        publicHref = href\n      }\n\n      return {\n        publicHref,\n        href,\n        pathname: nextPathname,\n        search: nextSearch,\n        searchStr,\n        state: nextState as any,\n        hash: hash ?? '',\n        external,\n        unmaskOnReload: dest.unmaskOnReload,\n      }\n    }\n\n    const buildWithMatches = (\n      dest: BuildNextOptions = {},\n      maskedDest?: BuildNextOptions,\n    ) => {\n      const next = build(dest)\n\n      let maskedNext = maskedDest ? build(maskedDest) : undefined\n\n      if (!maskedNext) {\n        const params = Object.create(null)\n\n        if (this.options.routeMasks) {\n          const match = findFlatMatch<RouteMask<TRouteTree>>(\n            next.pathname,\n            this.processedTree,\n          )\n          if (match) {\n            Object.assign(params, match.rawParams) // Copy params, because they're cached\n            const {\n              from: _from,\n              params: maskParams,\n              ...maskProps\n            } = match.route\n\n            // If mask has a params function, call it with the matched params as context\n            // Otherwise, use the matched params or the provided params value\n            const nextParams =\n              maskParams === false || maskParams === null\n                ? Object.create(null)\n                : (maskParams ?? true) === true\n                  ? params\n                  : Object.assign(params, functionalUpdate(maskParams, params))\n\n            maskedDest = {\n              from: opts.from,\n              ...maskProps,\n              params: nextParams,\n            }\n            maskedNext = build(maskedDest)\n          }\n        }\n      }\n\n      if (maskedNext) {\n        next.maskedLocation = maskedNext\n      }\n\n      return next\n    }\n\n    if (opts.mask) {\n      return buildWithMatches(opts, {\n        from: opts.from,\n        ...opts.mask,\n      })\n    }\n\n    return buildWithMatches(opts)\n  }\n\n  commitLocationPromise: undefined | ControlledPromise<void>\n\n  /**\n   * Commit a previously built location to history (push/replace), optionally\n   * using view transitions and scroll restoration options.\n   */\n  commitLocation: CommitLocationFn = async ({\n    viewTransition,\n    ignoreBlocker,\n    ...next\n  }) => {\n    const isSameState = () => {\n      // the following props are ignored but may still be provided when navigating,\n      // temporarily add the previous values to the next state so they don't affect\n      // the comparison\n      const ignoredProps = [\n        'key', // TODO: Remove in v2 - use __TSR_key instead\n        '__TSR_key',\n        '__TSR_index',\n        '__hashScrollIntoViewOptions',\n      ] as const\n      ignoredProps.forEach((prop) => {\n        ;(next.state as any)[prop] = this.latestLocation.state[prop]\n      })\n      const isEqual = deepEqual(next.state, this.latestLocation.state)\n      ignoredProps.forEach((prop) => {\n        delete next.state[prop]\n      })\n      return isEqual\n    }\n\n    const isSameUrl =\n      trimPathRight(this.latestLocation.href) === trimPathRight(next.href)\n\n    let previousCommitPromise = this.commitLocationPromise\n    this.commitLocationPromise = createControlledPromise<void>(() => {\n      previousCommitPromise?.resolve()\n      previousCommitPromise = undefined\n    })\n\n    // Don't commit to history if nothing changed\n    if (isSameUrl && isSameState()) {\n      this.load()\n    } else {\n      let {\n        // eslint-disable-next-line prefer-const\n        maskedLocation,\n        // eslint-disable-next-line prefer-const\n        hashScrollIntoView,\n        ...nextHistory\n      } = next\n\n      if (maskedLocation) {\n        nextHistory = {\n          ...maskedLocation,\n          state: {\n            ...maskedLocation.state,\n            __tempKey: undefined,\n            __tempLocation: {\n              ...nextHistory,\n              search: nextHistory.searchStr,\n              state: {\n                ...nextHistory.state,\n                __tempKey: undefined!,\n                __tempLocation: undefined!,\n                __TSR_key: undefined!,\n                key: undefined!, // TODO: Remove in v2 - use __TSR_key instead\n              },\n            },\n          },\n        }\n\n        if (\n          nextHistory.unmaskOnReload ??\n          this.options.unmaskOnReload ??\n          false\n        ) {\n          nextHistory.state.__tempKey = this.tempLocationKey\n        }\n      }\n\n      nextHistory.state.__hashScrollIntoViewOptions =\n        hashScrollIntoView ?? this.options.defaultHashScrollIntoView ?? true\n\n      this.shouldViewTransition = viewTransition\n\n      this.history[next.replace ? 'replace' : 'push'](\n        nextHistory.publicHref,\n        nextHistory.state,\n        { ignoreBlocker },\n      )\n    }\n\n    this.resetNextScroll = next.resetScroll ?? true\n\n    if (!this.history.subscribers.size) {\n      this.load()\n    }\n\n    return this.commitLocationPromise\n  }\n\n  /** Convenience helper: build a location from options, then commit it. */\n  buildAndCommitLocation = ({\n    replace,\n    resetScroll,\n    hashScrollIntoView,\n    viewTransition,\n    ignoreBlocker,\n    href,\n    ...rest\n  }: BuildNextOptions & CommitLocationOptions = {}) => {\n    if (href) {\n      const currentIndex = this.history.location.state.__TSR_index\n\n      const parsed = parseHref(href, {\n        __TSR_index: replace ? currentIndex : currentIndex + 1,\n      })\n\n      // If the href contains the basepath, we need to strip it before setting `to`\n      // because `buildLocation` will add the basepath back when creating the final URL.\n      // Without this, hrefs like '/app/about' would become '/app/app/about'.\n      const hrefUrl = new URL(parsed.pathname, this.origin)\n      const rewrittenUrl = executeRewriteInput(this.rewrite, hrefUrl)\n\n      rest.to = rewrittenUrl.pathname\n      rest.search = this.options.parseSearch(parsed.search)\n      // remove the leading `#` from the hash\n      rest.hash = parsed.hash.slice(1)\n    }\n\n    const location = this.buildLocation({\n      ...(rest as any),\n      _includeValidateSearch: true,\n    })\n\n    this.pendingBuiltLocation = location as ParsedLocation<\n      FullSearchSchema<TRouteTree>\n    >\n\n    const commitPromise = this.commitLocation({\n      ...location,\n      viewTransition,\n      replace,\n      resetScroll,\n      hashScrollIntoView,\n      ignoreBlocker,\n    })\n\n    // Clear pending location after commit starts\n    // We do this on next microtask to allow synchronous navigate calls to chain\n    Promise.resolve().then(() => {\n      if (this.pendingBuiltLocation === location) {\n        this.pendingBuiltLocation = undefined\n      }\n    })\n\n    return commitPromise\n  }\n\n  /**\n   * Imperatively navigate using standard `NavigateOptions`. When `reloadDocument`\n   * or an absolute `href` is provided, performs a full document navigation.\n   * Otherwise, builds and commits a client-side location.\n   *\n   * @link https://tanstack.com/router/latest/docs/framework/react/api/router/NavigateOptionsType\n   */\n  navigate: NavigateFn = async ({\n    to,\n    reloadDocument,\n    href,\n    publicHref,\n    ...rest\n  }) => {\n    let hrefIsUrl = false\n\n    if (href) {\n      try {\n        new URL(`${href}`)\n        hrefIsUrl = true\n      } catch {}\n    }\n\n    if (hrefIsUrl && !reloadDocument) {\n      reloadDocument = true\n    }\n\n    if (reloadDocument) {\n      // When to is provided, always build a location to get the proper publicHref\n      // (this handles redirects where href might be an internal path from resolveRedirect)\n      // When only href is provided (no to), use it directly as it should already\n      // be a complete path (possibly with basepath)\n      if (to !== undefined || !href) {\n        const location = this.buildLocation({ to, ...rest } as any)\n        // Use publicHref which contains the path (origin-stripped is fine for reload)\n        href = href ?? location.publicHref\n        publicHref = publicHref ?? location.publicHref\n      }\n\n      // Use publicHref when available and href is not a full URL,\n      // otherwise use href directly (which may already include basepath)\n      const reloadHref = !hrefIsUrl && publicHref ? publicHref : href\n\n      // Block dangerous protocols like javascript:, blob:, data:\n      // These could execute arbitrary code if passed to window.location\n      if (isDangerousProtocol(reloadHref, this.protocolAllowlist)) {\n        if (process.env.NODE_ENV !== 'production') {\n          console.warn(\n            `Blocked navigation to dangerous protocol: ${reloadHref}`,\n          )\n        }\n        return Promise.resolve()\n      }\n\n      // Check blockers for external URLs unless ignoreBlocker is true\n      if (!rest.ignoreBlocker) {\n        // Cast to access internal getBlockers method\n        const historyWithBlockers = this.history as any\n        const blockers = historyWithBlockers.getBlockers?.() ?? []\n        for (const blocker of blockers) {\n          if (blocker?.blockerFn) {\n            const shouldBlock = await blocker.blockerFn({\n              currentLocation: this.latestLocation,\n              nextLocation: this.latestLocation, // External URLs don't have a next location in our router\n              action: 'PUSH',\n            })\n            if (shouldBlock) {\n              return Promise.resolve()\n            }\n          }\n        }\n      }\n\n      if (rest.replace) {\n        window.location.replace(reloadHref)\n      } else {\n        window.location.href = reloadHref\n      }\n      return Promise.resolve()\n    }\n\n    return this.buildAndCommitLocation({\n      ...rest,\n      href,\n      to: to as string,\n      _isNavigate: true,\n    })\n  }\n\n  latestLoadPromise: undefined | Promise<void>\n\n  beforeLoad = () => {\n    // Cancel any pending matches\n    this.cancelMatches()\n    this.updateLatestLocation()\n\n    if (isServer ?? this.isServer) {\n      // for SPAs on the initial load, this is handled by the Transitioner\n      const nextLocation = this.buildLocation({\n        to: this.latestLocation.pathname,\n        search: true,\n        params: true,\n        hash: true,\n        state: true,\n        _includeValidateSearch: true,\n      })\n\n      // Check if location changed - origin check is unnecessary since buildLocation\n      // always uses this.origin when constructing URLs\n      if (this.latestLocation.publicHref !== nextLocation.publicHref) {\n        const href = this.getParsedLocationHref(nextLocation)\n        if (nextLocation.external) {\n          throw redirect({ href })\n        } else {\n          throw redirect({ href, _builtLocation: nextLocation })\n        }\n      }\n    }\n\n    // Match the routes\n    const pendingMatches = this.matchRoutes(this.latestLocation)\n\n    const nextCachedMatches = this.stores.cachedMatches\n      .get()\n      .filter((d) => !pendingMatches.some((e) => e.id === d.id))\n\n    // Ingest the new matches\n    this.batch(() => {\n      this.stores.status.set('pending')\n      this.stores.statusCode.set(200)\n      this.stores.isLoading.set(true)\n      this.stores.location.set(this.latestLocation)\n      this.stores.setPending(pendingMatches)\n      // If a cached match moved to pending matches, remove it from cached matches\n      this.stores.setCached(nextCachedMatches)\n    })\n  }\n\n  load: LoadFn = async (opts?: { sync?: boolean }): Promise<void> => {\n    let redirect: AnyRedirect | undefined\n    let notFound: NotFoundError | undefined\n    let loadPromise: Promise<void>\n    const previousLocation =\n      this.stores.resolvedLocation.get() ?? this.stores.location.get()\n\n    // eslint-disable-next-line prefer-const\n    loadPromise = new Promise<void>((resolve) => {\n      this.startTransition(async () => {\n        try {\n          this.beforeLoad()\n          const next = this.latestLocation\n          const prevLocation = this.stores.resolvedLocation.get()\n          const locationChangeInfo = getLocationChangeInfo(next, prevLocation)\n\n          if (!this.stores.redirect.get()) {\n            this.emit({\n              type: 'onBeforeNavigate',\n              ...locationChangeInfo,\n            })\n          }\n\n          this.emit({\n            type: 'onBeforeLoad',\n            ...locationChangeInfo,\n          })\n\n          await loadMatches({\n            router: this,\n            sync: opts?.sync,\n            forceStaleReload: previousLocation.href === next.href,\n            matches: this.stores.pendingMatches.get(),\n            location: next,\n            updateMatch: this.updateMatch,\n            // eslint-disable-next-line @typescript-eslint/require-await\n            onReady: async () => {\n              // Wrap batch in framework-specific transition wrapper (e.g., Solid's startTransition)\n              this.startTransition(() => {\n                this.startViewTransition(async () => {\n                  // this.viewTransitionPromise = createControlledPromise<true>()\n\n                  // Commit the pending matches. If a previous match was\n                  // removed, place it in the cachedMatches\n                  //\n                  // exitingMatches uses match.id (routeId + params + loaderDeps) so\n                  // navigating /foo?page=1 → /foo?page=2 correctly caches the page=1 entry.\n                  let exitingMatches: Array<AnyRouteMatch> | null = null\n\n                  // Lifecycle-hook identity uses routeId only so that navigating between\n                  // different params/deps of the same route fires onStay (not onLeave+onEnter).\n                  let hookExitingMatches: Array<AnyRouteMatch> | null = null\n                  let hookEnteringMatches: Array<AnyRouteMatch> | null = null\n                  let hookStayingMatches: Array<AnyRouteMatch> | null = null\n\n                  this.batch(() => {\n                    const pendingMatches = this.stores.pendingMatches.get()\n                    const mountPending = pendingMatches.length\n                    const currentMatches = this.stores.matches.get()\n\n                    exitingMatches = mountPending\n                      ? currentMatches.filter(\n                          (match) =>\n                            !this.stores.pendingMatchStores.has(match.id),\n                        )\n                      : null\n\n                    // Lifecycle-hook identity: routeId only (route presence in tree)\n                    // Build routeId sets from pools to avoid derived stores.\n                    const pendingRouteIds = new Set<string>()\n                    for (const s of this.stores.pendingMatchStores.values()) {\n                      if (s.routeId) pendingRouteIds.add(s.routeId)\n                    }\n                    const activeRouteIds = new Set<string>()\n                    for (const s of this.stores.matchStores.values()) {\n                      if (s.routeId) activeRouteIds.add(s.routeId)\n                    }\n\n                    hookExitingMatches = mountPending\n                      ? currentMatches.filter(\n                          (match) => !pendingRouteIds.has(match.routeId),\n                        )\n                      : null\n                    hookEnteringMatches = mountPending\n                      ? pendingMatches.filter(\n                          (match) => !activeRouteIds.has(match.routeId),\n                        )\n                      : null\n                    hookStayingMatches = mountPending\n                      ? pendingMatches.filter((match) =>\n                          activeRouteIds.has(match.routeId),\n                        )\n                      : currentMatches\n\n                    this.stores.isLoading.set(false)\n                    this.stores.loadedAt.set(Date.now())\n                    /**\n                     * When committing new matches, cache any exiting matches that are still usable.\n                     * Routes that resolved with `status: 'error'` or `status: 'notFound'` are\n                     * deliberately excluded from `cachedMatches` so that subsequent invalidations\n                     * or reloads re-run their loaders instead of reusing the failed/not-found data.\n                     */\n                    if (mountPending) {\n                      this.stores.setMatches(pendingMatches)\n                      this.stores.setPending([])\n                      this.stores.setCached([\n                        ...this.stores.cachedMatches.get(),\n                        ...exitingMatches!.filter(\n                          (d) =>\n                            d.status !== 'error' &&\n                            d.status !== 'notFound' &&\n                            d.status !== 'redirected',\n                        ),\n                      ])\n                      this.clearExpiredCache()\n                    }\n                  })\n\n                  //\n                  for (const [matches, hook] of [\n                    [hookExitingMatches, 'onLeave'],\n                    [hookEnteringMatches, 'onEnter'],\n                    [hookStayingMatches, 'onStay'],\n                  ] as const) {\n                    if (!matches) continue\n                    for (const match of matches as Array<AnyRouteMatch>) {\n                      this.looseRoutesById[match.routeId]!.options[hook]?.(\n                        match,\n                      )\n                    }\n                  }\n                })\n              })\n            },\n          })\n        } catch (err) {\n          if (isRedirect(err)) {\n            redirect = err\n            if (!(isServer ?? this.isServer)) {\n              this.navigate({\n                ...redirect.options,\n                replace: true,\n                ignoreBlocker: true,\n              })\n            }\n          } else if (isNotFound(err)) {\n            notFound = err\n          }\n\n          const nextStatusCode = redirect\n            ? redirect.status\n            : notFound\n              ? 404\n              : this.stores.matches.get().some((d) => d.status === 'error')\n                ? 500\n                : 200\n\n          this.batch(() => {\n            this.stores.statusCode.set(nextStatusCode)\n            this.stores.redirect.set(redirect)\n          })\n        }\n\n        if (this.latestLoadPromise === loadPromise) {\n          this.commitLocationPromise?.resolve()\n          this.latestLoadPromise = undefined\n          this.commitLocationPromise = undefined\n        }\n\n        resolve()\n      })\n    })\n\n    this.latestLoadPromise = loadPromise\n\n    await loadPromise\n\n    while (\n      (this.latestLoadPromise as any) &&\n      loadPromise !== this.latestLoadPromise\n    ) {\n      await this.latestLoadPromise\n    }\n\n    let newStatusCode: number | undefined = undefined\n    if (this.hasNotFoundMatch()) {\n      newStatusCode = 404\n    } else if (this.stores.matches.get().some((d) => d.status === 'error')) {\n      newStatusCode = 500\n    }\n    if (newStatusCode !== undefined) {\n      this.stores.statusCode.set(newStatusCode)\n    }\n  }\n\n  startViewTransition = (fn: () => Promise<void>) => {\n    // Determine if we should start a view transition from the navigation\n    // or from the router default\n    const shouldViewTransition =\n      this.shouldViewTransition ?? this.options.defaultViewTransition\n\n    // Reset the view transition flag\n    this.shouldViewTransition = undefined\n\n    // Attempt to start a view transition (or just apply the changes if we can't)\n    if (\n      shouldViewTransition &&\n      typeof document !== 'undefined' &&\n      'startViewTransition' in document &&\n      typeof document.startViewTransition === 'function'\n    ) {\n      // lib.dom.ts doesn't support viewTransition types variant yet.\n      // TODO: Fix this when dom types are updated\n      let startViewTransitionParams: any\n\n      if (\n        typeof shouldViewTransition === 'object' &&\n        this.isViewTransitionTypesSupported\n      ) {\n        const next = this.latestLocation\n        const prevLocation = this.stores.resolvedLocation.get()\n\n        const resolvedViewTransitionTypes =\n          typeof shouldViewTransition.types === 'function'\n            ? shouldViewTransition.types(\n                getLocationChangeInfo(next, prevLocation),\n              )\n            : shouldViewTransition.types\n\n        if (resolvedViewTransitionTypes === false) {\n          fn()\n          return\n        }\n\n        startViewTransitionParams = {\n          update: fn,\n          types: resolvedViewTransitionTypes,\n        }\n      } else {\n        startViewTransitionParams = fn\n      }\n\n      document.startViewTransition(startViewTransitionParams)\n    } else {\n      fn()\n    }\n  }\n\n  updateMatch: UpdateMatchFn = (id, updater) => {\n    this.startTransition(() => {\n      const pendingMatch = this.stores.pendingMatchStores.get(id)\n      if (pendingMatch) {\n        pendingMatch.set(updater)\n        return\n      }\n\n      const activeMatch = this.stores.matchStores.get(id)\n      if (activeMatch) {\n        activeMatch.set(updater)\n        return\n      }\n\n      const cachedMatch = this.stores.cachedMatchStores.get(id)\n      if (cachedMatch) {\n        const next = updater(cachedMatch.get())\n        if (next.status === 'redirected') {\n          const deleted = this.stores.cachedMatchStores.delete(id)\n          if (deleted) {\n            this.stores.cachedIds.set((prev) =>\n              prev.filter((matchId) => matchId !== id),\n            )\n          }\n        } else {\n          cachedMatch.set(next)\n        }\n      }\n    })\n  }\n\n  getMatch: GetMatchFn = (matchId: string): AnyRouteMatch | undefined => {\n    return (\n      this.stores.cachedMatchStores.get(matchId)?.get() ??\n      this.stores.pendingMatchStores.get(matchId)?.get() ??\n      this.stores.matchStores.get(matchId)?.get()\n    )\n  }\n\n  /**\n   * Invalidate the current matches and optionally force them back into a pending state.\n   *\n   * - Marks all matches that pass the optional `filter` as `invalid: true`.\n   * - If `forcePending` is true, or a match is currently in `'error'` or `'notFound'` status,\n   *   its status is reset to `'pending'` and its `error` cleared so that the loader is re-run\n   *   on the next `load()` call (eg. after HMR or a manual invalidation).\n   */\n  invalidate: InvalidateFn<\n    RouterCore<\n      TRouteTree,\n      TTrailingSlashOption,\n      TDefaultStructuralSharingOption,\n      TRouterHistory,\n      TDehydrated\n    >\n  > = (opts) => {\n    const invalidate = (d: MakeRouteMatch<TRouteTree>) => {\n      if (opts?.filter?.(d as MakeRouteMatchUnion<this>) ?? true) {\n        return {\n          ...d,\n          invalid: true,\n          ...(opts?.forcePending ||\n          d.status === 'error' ||\n          d.status === 'notFound'\n            ? ({ status: 'pending', error: undefined } as const)\n            : undefined),\n        }\n      }\n      return d\n    }\n\n    this.batch(() => {\n      this.stores.setMatches(this.stores.matches.get().map(invalidate))\n      this.stores.setCached(this.stores.cachedMatches.get().map(invalidate))\n      this.stores.setPending(this.stores.pendingMatches.get().map(invalidate))\n    })\n\n    this.shouldViewTransition = false\n    return this.load({ sync: opts?.sync })\n  }\n\n  getParsedLocationHref = (location: ParsedLocation) => {\n    // For redirects and external use, we need publicHref (with rewrite output applied)\n    // href is the internal path after rewrite input, publicHref is user-facing\n    return location.publicHref || '/'\n  }\n\n  resolveRedirect = (redirect: AnyRedirect): AnyRedirect => {\n    const locationHeader = redirect.headers.get('Location')\n\n    if (!redirect.options.href || redirect.options._builtLocation) {\n      const location =\n        redirect.options._builtLocation ?? this.buildLocation(redirect.options)\n      const href = this.getParsedLocationHref(location)\n      redirect.options.href = href\n      redirect.headers.set('Location', href)\n    } else if (locationHeader) {\n      try {\n        const url = new URL(locationHeader)\n        if (this.origin && url.origin === this.origin) {\n          const href = url.pathname + url.search + url.hash\n          redirect.options.href = href\n          redirect.headers.set('Location', href)\n        }\n      } catch {\n        // ignore invalid URLs\n      }\n    }\n\n    if (\n      redirect.options.href &&\n      !redirect.options._builtLocation &&\n      // Check for dangerous protocols before processing the redirect\n      isDangerousProtocol(redirect.options.href, this.protocolAllowlist)\n    ) {\n      throw new Error(\n        process.env.NODE_ENV !== 'production'\n          ? `Redirect blocked: unsafe protocol in href \"${redirect.options.href}\". Allowed protocols: ${Array.from(this.protocolAllowlist).join(', ')}.`\n          : 'Redirect blocked: unsafe protocol',\n      )\n    }\n\n    if (!redirect.headers.get('Location')) {\n      redirect.headers.set('Location', redirect.options.href)\n    }\n\n    return redirect\n  }\n\n  clearCache: ClearCacheFn<this> = (opts) => {\n    const filter = opts?.filter\n    if (filter !== undefined) {\n      this.stores.setCached(\n        this.stores.cachedMatches\n          .get()\n          .filter((m) => !filter(m as MakeRouteMatchUnion<this>)),\n      )\n    } else {\n      this.stores.setCached([])\n    }\n  }\n\n  clearExpiredCache = () => {\n    const now = Date.now()\n    // This is where all of the garbage collection magic happens\n    const filter = (d: MakeRouteMatch<TRouteTree>) => {\n      const route = this.looseRoutesById[d.routeId]!\n\n      if (!route.options.loader) {\n        return true\n      }\n\n      // If the route was preloaded, use the preloadGcTime\n      // otherwise, use the gcTime\n      const gcTime =\n        (d.preload\n          ? (route.options.preloadGcTime ?? this.options.defaultPreloadGcTime)\n          : (route.options.gcTime ?? this.options.defaultGcTime)) ??\n        5 * 60 * 1000\n\n      const isError = d.status === 'error'\n      if (isError) return true\n\n      const gcEligible = now - d.updatedAt >= gcTime\n      return gcEligible\n    }\n    this.clearCache({ filter })\n  }\n\n  loadRouteChunk = loadRouteChunk\n\n  preloadRoute: PreloadRouteFn<\n    TRouteTree,\n    TTrailingSlashOption,\n    TDefaultStructuralSharingOption,\n    TRouterHistory\n  > = async (opts) => {\n    const next = opts._builtLocation ?? this.buildLocation(opts as any)\n\n    let matches = this.matchRoutes(next, {\n      throwOnError: true,\n      preload: true,\n      dest: opts,\n    })\n\n    const activeMatchIds = new Set([\n      ...this.stores.matchesId.get(),\n      ...this.stores.pendingIds.get(),\n    ])\n\n    const loadedMatchIds = new Set([\n      ...activeMatchIds,\n      ...this.stores.cachedIds.get(),\n    ])\n\n    // If the matches are already loaded, we need to add them to the cached matches.\n    const matchesToCache = matches.filter(\n      (match) => !loadedMatchIds.has(match.id),\n    )\n    if (matchesToCache.length) {\n      const cachedMatches = this.stores.cachedMatches.get()\n      this.stores.setCached([...cachedMatches, ...matchesToCache])\n    }\n\n    try {\n      matches = await loadMatches({\n        router: this,\n        matches,\n        location: next,\n        preload: true,\n        updateMatch: (id, updater) => {\n          // Don't update the match if it's currently loaded\n          if (activeMatchIds.has(id)) {\n            matches = matches.map((d) => (d.id === id ? updater(d) : d))\n          } else {\n            this.updateMatch(id, updater)\n          }\n        },\n      })\n\n      return matches\n    } catch (err) {\n      if (isRedirect(err)) {\n        if (err.options.reloadDocument) {\n          return undefined\n        }\n\n        return await this.preloadRoute({\n          ...err.options,\n          _fromLocation: next,\n        })\n      }\n      if (!isNotFound(err)) {\n        // Preload errors are not fatal, but we should still log them\n        console.error(err)\n      }\n      return undefined\n    }\n  }\n\n  matchRoute: MatchRouteFn<\n    TRouteTree,\n    TTrailingSlashOption,\n    TDefaultStructuralSharingOption,\n    TRouterHistory\n  > = (location, opts) => {\n    const matchLocation = {\n      ...location,\n      to: location.to\n        ? this.resolvePathWithBase(location.from || '', location.to as string)\n        : undefined,\n      params: location.params || {},\n      leaveParams: true,\n    }\n    const next = this.buildLocation(matchLocation as any)\n\n    if (opts?.pending && this.stores.status.get() !== 'pending') {\n      return false\n    }\n\n    const pending =\n      opts?.pending === undefined ? !this.stores.isLoading.get() : opts.pending\n\n    const baseLocation = pending\n      ? this.latestLocation\n      : this.stores.resolvedLocation.get() || this.stores.location.get()\n\n    const match = findSingleMatch(\n      next.pathname,\n      opts?.caseSensitive ?? false,\n      opts?.fuzzy ?? false,\n      baseLocation.pathname,\n      this.processedTree,\n    )\n\n    if (!match) {\n      return false\n    }\n\n    if (location.params) {\n      if (!deepEqual(match.rawParams, location.params, { partial: true })) {\n        return false\n      }\n    }\n\n    if (opts?.includeSearch ?? true) {\n      return deepEqual(baseLocation.search, next.search, { partial: true })\n        ? match.rawParams\n        : false\n    }\n\n    return match.rawParams\n  }\n\n  ssr?: {\n    manifest: Manifest | undefined\n  }\n\n  serverSsr?: ServerSsr\n\n  hasNotFoundMatch = () => {\n    return this.stores.matches\n      .get()\n      .some((d) => d.status === 'notFound' || d.globalNotFound)\n  }\n}\n\n/** Error thrown when search parameter validation fails. */\nexport class SearchParamError extends Error {}\n\n/** Error thrown when path parameter parsing/validation fails. */\nexport class PathParamError extends Error {}\n\nconst normalize = (str: string) =>\n  str.endsWith('/') && str.length > 1 ? str.slice(0, -1) : str\nfunction comparePaths(a: string, b: string) {\n  return normalize(a) === normalize(b)\n}\n\n/**\n * Lazily import a module function and forward arguments to it, retaining\n * parameter and return types for the selected export key.\n */\nexport function lazyFn<\n  T extends Record<string, (...args: Array<any>) => any>,\n  TKey extends keyof T = 'default',\n>(fn: () => Promise<T>, key?: TKey) {\n  return async (\n    ...args: Parameters<T[TKey]>\n  ): Promise<Awaited<ReturnType<T[TKey]>>> => {\n    const imported = await fn()\n    return imported[key || 'default'](...args)\n  }\n}\n\n/** Create an initial RouterState from a parsed location. */\nexport function getInitialRouterState(\n  location: ParsedLocation,\n): RouterState<any> {\n  return {\n    loadedAt: 0,\n    isLoading: false,\n    isTransitioning: false,\n    status: 'idle',\n    resolvedLocation: undefined,\n    location,\n    matches: [],\n    statusCode: 200,\n  }\n}\n\nfunction validateSearch(validateSearch: AnyValidator, input: unknown): unknown {\n  if (validateSearch == null) return {}\n\n  if ('~standard' in validateSearch) {\n    const result = validateSearch['~standard'].validate(input)\n\n    if (result instanceof Promise)\n      throw new SearchParamError('Async validation not supported')\n\n    if (result.issues)\n      throw new SearchParamError(JSON.stringify(result.issues, undefined, 2), {\n        cause: result,\n      })\n\n    return result.value\n  }\n\n  if ('parse' in validateSearch) {\n    return validateSearch.parse(input)\n  }\n\n  if (typeof validateSearch === 'function') {\n    return validateSearch(input)\n  }\n\n  return {}\n}\n\n/**\n * Build the matched route chain and extract params for a pathname.\n * Falls back to the root route if no specific route is found.\n */\nexport function getMatchedRoutes<TRouteLike extends RouteLike>({\n  pathname,\n  routesById,\n  processedTree,\n}: {\n  pathname: string\n  routesById: Record<string, TRouteLike>\n  processedTree: ProcessedTree<any, any, any>\n}) {\n  const routeParams: Record<string, string> = Object.create(null)\n  const trimmedPath = trimPathRight(pathname)\n\n  let foundRoute: TRouteLike | undefined = undefined\n  let parsedParams: Record<string, unknown> | undefined = undefined\n  const match = findRouteMatch<TRouteLike>(trimmedPath, processedTree, true)\n  if (match) {\n    foundRoute = match.route\n    Object.assign(routeParams, match.rawParams) // Copy params, because they're cached\n    parsedParams = Object.assign(Object.create(null), match.parsedParams)\n  }\n\n  const matchedRoutes = match?.branch || [routesById[rootRouteId]!]\n\n  return { matchedRoutes, routeParams, foundRoute, parsedParams }\n}\n\n/**\n * TODO: once caches are persisted across requests on the server,\n * we can cache the built middleware chain using `last(destRoutes)` as the key\n */\nfunction applySearchMiddleware({\n  search,\n  dest,\n  destRoutes,\n  _includeValidateSearch,\n}: {\n  search: any\n  dest: { search?: unknown }\n  destRoutes: ReadonlyArray<AnyRoute>\n  _includeValidateSearch: boolean | undefined\n}) {\n  const middleware = buildMiddlewareChain(destRoutes)\n  return middleware(search, dest, _includeValidateSearch ?? false)\n}\n\nfunction buildMiddlewareChain(destRoutes: ReadonlyArray<AnyRoute>) {\n  const context = {\n    dest: null as unknown as BuildNextOptions,\n    _includeValidateSearch: false,\n    middlewares: [] as Array<SearchMiddleware<any>>,\n  }\n\n  for (const route of destRoutes) {\n    if ('search' in route.options) {\n      if (route.options.search?.middlewares) {\n        context.middlewares.push(...route.options.search.middlewares)\n      }\n    }\n    // TODO remove preSearchFilters and postSearchFilters in v2\n    else if (\n      route.options.preSearchFilters ||\n      route.options.postSearchFilters\n    ) {\n      const legacyMiddleware: SearchMiddleware<any> = ({ search, next }) => {\n        let nextSearch = search\n\n        if (\n          'preSearchFilters' in route.options &&\n          route.options.preSearchFilters\n        ) {\n          nextSearch = route.options.preSearchFilters.reduce(\n            (prev, next) => next(prev),\n            search,\n          )\n        }\n\n        const result = next(nextSearch)\n\n        if (\n          'postSearchFilters' in route.options &&\n          route.options.postSearchFilters\n        ) {\n          return route.options.postSearchFilters.reduce(\n            (prev, next) => next(prev),\n            result,\n          )\n        }\n\n        return result\n      }\n      context.middlewares.push(legacyMiddleware)\n    }\n\n    if (route.options.validateSearch) {\n      const validate: SearchMiddleware<any> = ({ search, next }) => {\n        const result = next(search)\n        if (!context._includeValidateSearch) return result\n        try {\n          const validatedSearch = {\n            ...result,\n            ...(validateSearch(route.options.validateSearch, result) ??\n              undefined),\n          }\n          return validatedSearch\n        } catch {\n          // ignore errors here because they are already handled in matchRoutes\n          return result\n        }\n      }\n\n      context.middlewares.push(validate)\n    }\n  }\n\n  // the chain ends here since `next` is not called\n  const final: SearchMiddleware<any> = ({ search }) => {\n    const dest = context.dest\n    if (!dest.search) {\n      return {}\n    }\n    if (dest.search === true) {\n      return search\n    }\n    return functionalUpdate(dest.search, search)\n  }\n\n  context.middlewares.push(final)\n\n  const applyNext = (\n    index: number,\n    currentSearch: any,\n    middlewares: Array<SearchMiddleware<any>>,\n  ): any => {\n    // no more middlewares left, return the current search\n    if (index >= middlewares.length) {\n      return currentSearch\n    }\n\n    const middleware = middlewares[index]!\n\n    const next = (newSearch: any): any => {\n      return applyNext(index + 1, newSearch, middlewares)\n    }\n\n    return middleware({ search: currentSearch, next })\n  }\n\n  return function middleware(\n    search: any,\n    dest: BuildNextOptions,\n    _includeValidateSearch: boolean,\n  ) {\n    context.dest = dest\n    context._includeValidateSearch = _includeValidateSearch\n    return applyNext(0, search, context.middlewares)\n  }\n}\n\nfunction findGlobalNotFoundRouteId(\n  notFoundMode: 'root' | 'fuzzy' | undefined,\n  routes: ReadonlyArray<AnyRoute>,\n) {\n  if (notFoundMode !== 'root') {\n    for (let i = routes.length - 1; i >= 0; i--) {\n      const route = routes[i]!\n      if (route.children) {\n        return route.id\n      }\n    }\n  }\n  return rootRouteId\n}\n\nfunction extractStrictParams(\n  route: AnyRoute,\n  referenceParams: Record<string, unknown>,\n  parsedParams: Record<string, unknown>,\n  accumulatedParams: Record<string, unknown>,\n) {\n  const parseParams = route.options.params?.parse ?? route.options.parseParams\n  if (parseParams) {\n    if (route.options.skipRouteOnParseError) {\n      // Use pre-parsed params from route matching for skipRouteOnParseError routes\n      for (const key in referenceParams) {\n        if (key in parsedParams) {\n          accumulatedParams[key] = parsedParams[key]\n        }\n      }\n    } else {\n      const result = parseParams(accumulatedParams as Record<string, string>)\n      Object.assign(accumulatedParams, result)\n    }\n  }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAw0BA,SAAgB,sBAAsB,KAAc;AAClD,KAAI,eAAe,OAAO;EACxB,MAAM,MAAM;GACV,MAAM,IAAI;GACV,SAAS,IAAI;GACd;AAED,MAAA,QAAA,IAAA,aAA6B,cACzB,KAAY,QAAQ,IAAI;AAG5B,SAAO;;AAGT,QAAO,EACL,MAAM,KACP;;;AAIH,IAAa,uBAAuB;CAClC,QAAQ;CACR,OAAO;CACP,UAAU;CACX;;;;;AASD,SAAgB,sBACd,UACA,kBACA;CACA,MAAM,eAAe;CACrB,MAAM,aAAa;AAInB,QAAO;EAAE;EAAc;EAAY,aAHf,cAAc,aAAa,WAAW;EAGV,aAF5B,cAAc,SAAS,WAAW;EAEO,aADzC,cAAc,SAAS,WAAW;EACoB;;;;;;;;;;;AA+C5E,IAAa,aAAb,MAME;;;;CA8CA,YACE,SAOA,gBACA;yBArDoC,GAAG,KAAK,MAC5C,KAAK,QAAQ,GAAG,IACjB;yBACiB;8BACuC,KAAA;wCACd,KAAA;qCAC7B,IAAI,KAAkC;2BAEhC;kCACO;0BAqEW,OAAO,IAAI;iBAgB5C,eAAe;AAClB,OAAA,QAAA,IAAA,aAA6B;QACvB,WAAW,cACb,SAAQ,KACN,gNACD;;GAIL,MAAM,cAAc,KAAK;GACzB,MAAM,eAAe,KAAK,YAAY,aAA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