{"version":3,"file":"Match.cjs","names":[],"sources":["../../src/Match.tsx"],"sourcesContent":["import * as React from 'react'\nimport { useStore } from '@tanstack/react-store'\nimport {\n  createControlledPromise,\n  getLocationChangeInfo,\n  invariant,\n  isNotFound,\n  isRedirect,\n  rootRouteId,\n} from '@tanstack/router-core'\nimport { isServer } from '@tanstack/router-core/isServer'\nimport { CatchBoundary, ErrorComponent } from './CatchBoundary'\nimport { useRouter } from './useRouter'\nimport { CatchNotFound } from './not-found'\nimport { matchContext } from './matchContext'\nimport { SafeFragment } from './SafeFragment'\nimport { renderRouteNotFound } from './renderRouteNotFound'\nimport { ScrollRestoration } from './scroll-restoration'\nimport { ClientOnly } from './ClientOnly'\nimport { useLayoutEffect } from './utils'\nimport type { AnyRoute, RootRouteOptions } from '@tanstack/router-core'\n\nexport const Match = React.memo(function MatchImpl({\n  matchId,\n}: {\n  matchId: string\n}) {\n  const router = useRouter()\n\n  if (isServer ?? router.isServer) {\n    const match = router.stores.activeMatchStoresById.get(matchId)?.state\n    if (!match) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n        )\n      }\n\n      invariant()\n    }\n\n    const routeId = match.routeId as string\n    const parentRouteId = (router.routesById[routeId] as AnyRoute).parentRoute\n      ?.id\n\n    return (\n      <MatchView\n        router={router}\n        matchId={matchId}\n        resetKey={router.stores.loadedAt.state}\n        matchState={{\n          routeId,\n          ssr: match.ssr,\n          _displayPending: match._displayPending,\n          parentRouteId,\n        }}\n      />\n    )\n  }\n\n  // Subscribe directly to the match store from the pool.\n  // The matchId prop is stable for this component's lifetime (set by Outlet),\n  // and reconcileMatchPool reuses stores for the same matchId.\n\n  const matchStore = router.stores.activeMatchStoresById.get(matchId)\n  if (!matchStore) {\n    if (process.env.NODE_ENV !== 'production') {\n      throw new Error(\n        `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n      )\n    }\n\n    invariant()\n  }\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const resetKey = useStore(router.stores.loadedAt, (loadedAt) => loadedAt)\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const match = useStore(matchStore, (value) => value)\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const matchState = React.useMemo(() => {\n    const routeId = match.routeId as string\n    const parentRouteId = (router.routesById[routeId] as AnyRoute).parentRoute\n      ?.id\n\n    return {\n      routeId,\n      ssr: match.ssr,\n      _displayPending: match._displayPending,\n      parentRouteId: parentRouteId as string | undefined,\n    } satisfies MatchViewState\n  }, [match._displayPending, match.routeId, match.ssr, router.routesById])\n\n  return (\n    <MatchView\n      router={router}\n      matchId={matchId}\n      resetKey={resetKey}\n      matchState={matchState}\n    />\n  )\n})\n\ntype MatchViewState = {\n  routeId: string\n  ssr: boolean | 'data-only' | undefined\n  _displayPending: boolean | undefined\n  parentRouteId: string | undefined\n}\n\nfunction MatchView({\n  router,\n  matchId,\n  resetKey,\n  matchState,\n}: {\n  router: ReturnType<typeof useRouter>\n  matchId: string\n  resetKey: number\n  matchState: MatchViewState\n}) {\n  const route: AnyRoute = router.routesById[matchState.routeId]\n\n  const PendingComponent =\n    route.options.pendingComponent ?? router.options.defaultPendingComponent\n\n  const pendingElement = PendingComponent ? <PendingComponent /> : null\n\n  const routeErrorComponent =\n    route.options.errorComponent ?? router.options.defaultErrorComponent\n\n  const routeOnCatch = route.options.onCatch ?? router.options.defaultOnCatch\n\n  const routeNotFoundComponent = route.isRoot\n    ? // If it's the root route, use the globalNotFound option, with fallback to the notFoundRoute's component\n      (route.options.notFoundComponent ??\n      router.options.notFoundRoute?.options.component)\n    : route.options.notFoundComponent\n\n  const resolvedNoSsr =\n    matchState.ssr === false || matchState.ssr === 'data-only'\n  const ResolvedSuspenseBoundary =\n    // If we're on the root route, allow forcefully wrapping in suspense\n    (!route.isRoot || route.options.wrapInSuspense || resolvedNoSsr) &&\n    (route.options.wrapInSuspense ??\n      PendingComponent ??\n      ((route.options.errorComponent as any)?.preload || resolvedNoSsr))\n      ? React.Suspense\n      : SafeFragment\n\n  const ResolvedCatchBoundary = routeErrorComponent\n    ? CatchBoundary\n    : SafeFragment\n\n  const ResolvedNotFoundBoundary = routeNotFoundComponent\n    ? CatchNotFound\n    : SafeFragment\n\n  const ShellComponent = route.isRoot\n    ? ((route.options as RootRouteOptions).shellComponent ?? SafeFragment)\n    : SafeFragment\n  return (\n    <ShellComponent>\n      <matchContext.Provider value={matchId}>\n        <ResolvedSuspenseBoundary fallback={pendingElement}>\n          <ResolvedCatchBoundary\n            getResetKey={() => resetKey}\n            errorComponent={routeErrorComponent || ErrorComponent}\n            onCatch={(error, errorInfo) => {\n              // Forward not found errors (we don't want to show the error component for these)\n              if (isNotFound(error)) {\n                error.routeId ??= matchState.routeId as any\n                throw error\n              }\n              if (process.env.NODE_ENV !== 'production') {\n                console.warn(`Warning: Error in route match: ${matchId}`)\n              }\n              routeOnCatch?.(error, errorInfo)\n            }}\n          >\n            <ResolvedNotFoundBoundary\n              fallback={(error) => {\n                error.routeId ??= matchState.routeId as any\n\n                // If the current not found handler doesn't exist or it has a\n                // route ID which doesn't match the current route, rethrow the error\n                if (\n                  !routeNotFoundComponent ||\n                  (error.routeId && error.routeId !== matchState.routeId) ||\n                  (!error.routeId && !route.isRoot)\n                )\n                  throw error\n\n                return React.createElement(routeNotFoundComponent, error as any)\n              }}\n            >\n              {resolvedNoSsr || matchState._displayPending ? (\n                <ClientOnly fallback={pendingElement}>\n                  <MatchInner matchId={matchId} />\n                </ClientOnly>\n              ) : (\n                <MatchInner matchId={matchId} />\n              )}\n            </ResolvedNotFoundBoundary>\n          </ResolvedCatchBoundary>\n        </ResolvedSuspenseBoundary>\n      </matchContext.Provider>\n      {matchState.parentRouteId === rootRouteId ? (\n        <>\n          <OnRendered resetKey={resetKey} />\n          {router.options.scrollRestoration && (isServer ?? router.isServer) ? (\n            <ScrollRestoration />\n          ) : null}\n        </>\n      ) : null}\n    </ShellComponent>\n  )\n}\n\n// On Rendered can't happen above the root layout because it needs to run after\n// the route subtree has committed below the root layout. Keeping it here lets\n// us fire onRendered even after a hydration mismatch above the root layout\n// (like bad head/link tags, which is common).\nfunction OnRendered({ resetKey }: { resetKey: number }) {\n  const router = useRouter()\n\n  if (isServer ?? router.isServer) {\n    return null\n  }\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const prevHrefRef = React.useRef<string | undefined>(undefined)\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  useLayoutEffect(() => {\n    const currentHref = router.latestLocation.href\n\n    if (\n      prevHrefRef.current === undefined ||\n      prevHrefRef.current !== currentHref\n    ) {\n      router.emit({\n        type: 'onRendered',\n        ...getLocationChangeInfo(\n          router.stores.location.state,\n          router.stores.resolvedLocation.state,\n        ),\n      })\n      prevHrefRef.current = currentHref\n    }\n  }, [router.latestLocation.state.__TSR_key, resetKey, router])\n\n  return null\n}\n\nexport const MatchInner = React.memo(function MatchInnerImpl({\n  matchId,\n}: {\n  matchId: string\n}): any {\n  const router = useRouter()\n\n  if (isServer ?? router.isServer) {\n    const match = router.stores.activeMatchStoresById.get(matchId)?.state\n    if (!match) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n        )\n      }\n\n      invariant()\n    }\n\n    const routeId = match.routeId as string\n    const route = router.routesById[routeId] as AnyRoute\n    const remountFn =\n      (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n      router.options.defaultRemountDeps\n    const remountDeps = remountFn?.({\n      routeId,\n      loaderDeps: match.loaderDeps,\n      params: match._strictParams,\n      search: match._strictSearch,\n    })\n    const key = remountDeps ? JSON.stringify(remountDeps) : undefined\n    const Comp = route.options.component ?? router.options.defaultComponent\n    const out = Comp ? <Comp key={key} /> : <Outlet />\n\n    if (match._displayPending) {\n      throw router.getMatch(match.id)?._nonReactive.displayPendingPromise\n    }\n\n    if (match._forcePending) {\n      throw router.getMatch(match.id)?._nonReactive.minPendingPromise\n    }\n\n    if (match.status === 'pending') {\n      throw router.getMatch(match.id)?._nonReactive.loadPromise\n    }\n\n    if (match.status === 'notFound') {\n      if (!isNotFound(match.error)) {\n        if (process.env.NODE_ENV !== 'production') {\n          throw new Error('Invariant failed: Expected a notFound error')\n        }\n\n        invariant()\n      }\n      return renderRouteNotFound(router, route, match.error)\n    }\n\n    if (match.status === 'redirected') {\n      if (!isRedirect(match.error)) {\n        if (process.env.NODE_ENV !== 'production') {\n          throw new Error('Invariant failed: Expected a redirect error')\n        }\n\n        invariant()\n      }\n      throw router.getMatch(match.id)?._nonReactive.loadPromise\n    }\n\n    if (match.status === 'error') {\n      const RouteErrorComponent =\n        (route.options.errorComponent ??\n          router.options.defaultErrorComponent) ||\n        ErrorComponent\n      return (\n        <RouteErrorComponent\n          error={match.error as any}\n          reset={undefined as any}\n          info={{\n            componentStack: '',\n          }}\n        />\n      )\n    }\n\n    return out\n  }\n\n  const matchStore = router.stores.activeMatchStoresById.get(matchId)\n  if (!matchStore) {\n    if (process.env.NODE_ENV !== 'production') {\n      throw new Error(\n        `Invariant failed: Could not find match for matchId \"${matchId}\". Please file an issue!`,\n      )\n    }\n\n    invariant()\n  }\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const match = useStore(matchStore, (value) => value)\n  const routeId = match.routeId as string\n  const route = router.routesById[routeId] as AnyRoute\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const key = React.useMemo(() => {\n    const remountFn =\n      (router.routesById[routeId] as AnyRoute).options.remountDeps ??\n      router.options.defaultRemountDeps\n    const remountDeps = remountFn?.({\n      routeId,\n      loaderDeps: match.loaderDeps,\n      params: match._strictParams,\n      search: match._strictSearch,\n    })\n    return remountDeps ? JSON.stringify(remountDeps) : undefined\n  }, [\n    routeId,\n    match.loaderDeps,\n    match._strictParams,\n    match._strictSearch,\n    router.options.defaultRemountDeps,\n    router.routesById,\n  ])\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const out = React.useMemo(() => {\n    const Comp = route.options.component ?? router.options.defaultComponent\n    if (Comp) {\n      return <Comp key={key} />\n    }\n    return <Outlet />\n  }, [key, route.options.component, router.options.defaultComponent])\n\n  if (match._displayPending) {\n    throw router.getMatch(match.id)?._nonReactive.displayPendingPromise\n  }\n\n  if (match._forcePending) {\n    throw router.getMatch(match.id)?._nonReactive.minPendingPromise\n  }\n\n  // see also hydrate() in packages/router-core/src/ssr/ssr-client.ts\n  if (match.status === 'pending') {\n    // We're pending, and if we have a minPendingMs, we need to wait for it\n    const pendingMinMs =\n      route.options.pendingMinMs ?? router.options.defaultPendingMinMs\n    if (pendingMinMs) {\n      const routerMatch = router.getMatch(match.id)\n      if (routerMatch && !routerMatch._nonReactive.minPendingPromise) {\n        // Create a promise that will resolve after the minPendingMs\n        if (!(isServer ?? router.isServer)) {\n          const minPendingPromise = createControlledPromise<void>()\n\n          routerMatch._nonReactive.minPendingPromise = minPendingPromise\n\n          setTimeout(() => {\n            minPendingPromise.resolve()\n            // We've handled the minPendingPromise, so we can delete it\n            routerMatch._nonReactive.minPendingPromise = undefined\n          }, pendingMinMs)\n        }\n      }\n    }\n    throw router.getMatch(match.id)?._nonReactive.loadPromise\n  }\n\n  if (match.status === 'notFound') {\n    if (!isNotFound(match.error)) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error('Invariant failed: Expected a notFound error')\n      }\n\n      invariant()\n    }\n    return renderRouteNotFound(router, route, match.error)\n  }\n\n  if (match.status === 'redirected') {\n    // Redirects should be handled by the router transition. If we happen to\n    // encounter a redirect here, it's a bug. Let's warn, but render nothing.\n    if (!isRedirect(match.error)) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error('Invariant failed: Expected a redirect error')\n      }\n\n      invariant()\n    }\n\n    // warning(\n    //   false,\n    //   'Tried to render a redirected route match! This is a weird circumstance, please file an issue!',\n    // )\n    throw router.getMatch(match.id)?._nonReactive.loadPromise\n  }\n\n  if (match.status === 'error') {\n    // If we're on the server, we need to use React's new and super\n    // wonky api for throwing errors from a server side render inside\n    // of a suspense boundary. This is the only way to get\n    // renderToPipeableStream to not hang indefinitely.\n    // We'll serialize the error and rethrow it on the client.\n    if (isServer ?? router.isServer) {\n      const RouteErrorComponent =\n        (route.options.errorComponent ??\n          router.options.defaultErrorComponent) ||\n        ErrorComponent\n      return (\n        <RouteErrorComponent\n          error={match.error as any}\n          reset={undefined as any}\n          info={{\n            componentStack: '',\n          }}\n        />\n      )\n    }\n\n    throw match.error\n  }\n\n  return out\n})\n\n/**\n * Render the next child match in the route tree. Typically used inside\n * a route component to render nested routes.\n *\n * @link https://tanstack.com/router/latest/docs/framework/react/api/router/outletComponent\n */\nexport const Outlet = React.memo(function OutletImpl() {\n  const router = useRouter()\n  const matchId = React.useContext(matchContext)\n\n  let routeId: string | undefined\n  let parentGlobalNotFound = false\n  let childMatchId: string | undefined\n\n  if (isServer ?? router.isServer) {\n    const matches = router.stores.activeMatchesSnapshot.state\n    const parentIndex = matchId\n      ? matches.findIndex((match) => match.id === matchId)\n      : -1\n    const parentMatch = parentIndex >= 0 ? matches[parentIndex] : undefined\n    routeId = parentMatch?.routeId as string | undefined\n    parentGlobalNotFound = parentMatch?.globalNotFound ?? false\n    childMatchId =\n      parentIndex >= 0 ? (matches[parentIndex + 1]?.id as string) : undefined\n  } else {\n    // Subscribe directly to the match store from the pool instead of\n    // the two-level byId → matchStore pattern.\n    const parentMatchStore = matchId\n      ? router.stores.activeMatchStoresById.get(matchId)\n      : undefined\n\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    ;[routeId, parentGlobalNotFound] = useStore(parentMatchStore, (match) => [\n      match?.routeId as string | undefined,\n      match?.globalNotFound ?? false,\n    ])\n\n    // eslint-disable-next-line react-hooks/rules-of-hooks\n    childMatchId = useStore(router.stores.matchesId, (ids) => {\n      const index = ids.findIndex((id) => id === matchId)\n      return ids[index + 1]\n    })\n  }\n\n  const route = routeId ? router.routesById[routeId] : undefined\n\n  const pendingElement = router.options.defaultPendingComponent ? (\n    <router.options.defaultPendingComponent />\n  ) : null\n\n  if (parentGlobalNotFound) {\n    if (!route) {\n      if (process.env.NODE_ENV !== 'production') {\n        throw new Error(\n          'Invariant failed: Could not resolve route for Outlet render',\n        )\n      }\n\n      invariant()\n    }\n    return renderRouteNotFound(router, route, undefined)\n  }\n\n  if (!childMatchId) {\n    return null\n  }\n\n  const nextMatch = <Match matchId={childMatchId} />\n\n  if (routeId === rootRouteId) {\n    return (\n      <React.Suspense fallback={pendingElement}>{nextMatch}</React.Suspense>\n    )\n  }\n\n  return nextMatch\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AAsBA,IAAa,QAAQ,MAAM,KAAK,SAAS,UAAU,EACjD,WAGC;CACD,MAAM,SAAS,kBAAA,WAAW;AAE1B,KAAI,+BAAA,YAAY,OAAO,UAAU;EAC/B,MAAM,QAAQ,OAAO,OAAO,sBAAsB,IAAI,QAAQ,EAAE;AAChE,MAAI,CAAC,OAAO;AACV,OAAA,QAAA,IAAA,aAA6B,aAC3B,OAAM,IAAI,MACR,uDAAuD,QAAQ,0BAChE;AAGH,IAAA,GAAA,sBAAA,YAAW;;EAGb,MAAM,UAAU,MAAM;EACtB,MAAM,gBAAiB,OAAO,WAAW,SAAsB,aAC3D;AAEJ,SACE,iBAAA,GAAA,kBAAA,KAAC,WAAD;GACU;GACC;GACT,UAAU,OAAO,OAAO,SAAS;GACjC,YAAY;IACV;IACA,KAAK,MAAM;IACX,iBAAiB,MAAM;IACvB;IACD;GACD,CAAA;;CAQN,MAAM,aAAa,OAAO,OAAO,sBAAsB,IAAI,QAAQ;AACnE,KAAI,CAAC,YAAY;AACf,MAAA,QAAA,IAAA,aAA6B,aAC3B,OAAM,IAAI,MACR,uDAAuD,QAAQ,0BAChE;AAGH,GAAA,GAAA,sBAAA,YAAW;;CAGb,MAAM,YAAA,GAAA,sBAAA,UAAoB,OAAO,OAAO,WAAW,aAAa,SAAS;CAEzE,MAAM,SAAA,GAAA,sBAAA,UAAiB,aAAa,UAAU,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