{"version":3,"sources":["../../../../src/server/app-render/instant-validation/instant-validation.tsx"],"sourcesContent":["import type {\n  CacheNodeSeedData,\n  FlightRouterState,\n  HeadData,\n  InitialRSCPayload,\n  Segment,\n} from '../../../shared/lib/app-router-types'\nimport type { VaryParamsThenable } from '../../../shared/lib/segment-cache/vary-params-decoding'\nimport { InvariantError } from '../../../shared/lib/invariant-error'\nimport { RenderStage } from '../staged-rendering'\nimport { getServerModuleMap } from '../manifests-singleton'\nimport { runInSequentialTasks } from '../app-render-render-utils'\nimport { workAsyncStorage } from '../work-async-storage.external'\nimport {\n  Phase,\n  printDebugThrownValueForProspectiveRender,\n} from '../prospective-render-utils'\nimport { getDigestForWellKnownError } from '../create-error-handler'\nimport {\n  // NOTE: we're in the server layer, so this is a client reference\n  PlaceValidationBoundaryBelowThisLevel,\n} from '../../../client/components/instant-validation/boundary'\nimport type { ValidationBoundaryTracking } from './boundary-tracking'\nimport {\n  getLayoutOrPageModule,\n  type LoaderTree,\n} from '../../lib/app-dir-module'\nimport { parseLoaderTree } from '../../../shared/lib/router/utils/parse-loader-tree'\nimport type { GetDynamicParamFromSegment } from '../app-render'\nimport type {\n  AppSegmentConfig,\n  Instant,\n} from '../../../build/segment-config/app/app-segment-config'\nimport { Readable } from 'node:stream'\nimport {\n  createNodeStreamWithLateRelease,\n  createNodeStreamFromChunks,\n} from './stream-utils'\nimport { createDebugChannel } from '../debug-channel-server'\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { createFromNodeStream } from 'react-server-dom-webpack/client'\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { renderToReadableStream } from 'react-server-dom-webpack/server'\nimport {\n  addSearchParamsIfPageSegment,\n  isGroupSegment,\n  PAGE_SEGMENT_KEY,\n  DEFAULT_SEGMENT_KEY,\n  NOT_FOUND_SEGMENT_KEY,\n} from '../../../shared/lib/segment'\nimport type { NextParsedUrlQuery } from '../../request-meta'\n\nconst filterStackFrame =\n  process.env.NODE_ENV !== 'production'\n    ? (\n        require('../../lib/source-maps') as typeof import('../../lib/source-maps')\n      ).filterStackFrameDEV\n    : undefined\nconst findSourceMapURL =\n  process.env.NODE_ENV !== 'production'\n    ? (\n        require('../../lib/source-maps') as typeof import('../../lib/source-maps')\n      ).findSourceMapURLDEV\n    : undefined\n\n// FIXME: this causes typescript errors related to 'flight-client-entry-plugin.d.ts'\n// type ClientReferenceManifest = ReturnType<\n//   (typeof import('../manifests-singleton'))['getClientReferenceManifest']\n// >\ntype ClientReferenceManifest = Record<string, any>\n\nconst debug =\n  process.env.NEXT_PRIVATE_DEBUG_VALIDATION === '1' ? console.log : undefined\n\n//===============================================================\n// 1. Validation planning\n//===============================================================\n\n/** Used to identify a segment. Conceptually similar to request keys in the Client Segment Cache. */\nexport type SegmentPath = string & { _tag: 'SegmentPath' }\n\n/**\n * Isomorphic to a FlightRouterState, but with extra data attached.\n * Carries the segment path for each segment so we can easily get it from the cache.\n *  */\nexport type RouteTree = {\n  path: SegmentPath\n  segment: Segment\n  module: null | {\n    type: 'layout' | 'page'\n    // TODO(instant-validation): We should know if a layout segment is shared\n    instantConfig: Instant | null\n    conventionPath: string\n    createInstantStack: (() => Error) | null\n  }\n\n  slots: { [parallelRouteKey: string]: RouteTree } | null\n}\n\nfunction traverseRootSeedDataSegments(\n  initialRSCPayload: InitialRSCPayload,\n  processSegment: (\n    segmentPath: SegmentPath,\n    seedData: CacheNodeSeedData\n  ) => void\n) {\n  const { flightRouterState, seedData } =\n    getRootDataFromPayload(initialRSCPayload)\n\n  const [rootSegment] = flightRouterState\n  const rootPath = stringifySegment(rootSegment)\n  return traverseCacheNodeSegments(\n    rootPath,\n    flightRouterState,\n    seedData,\n    processSegment\n  )\n}\n\nfunction traverseCacheNodeSegments(\n  path: SegmentPath,\n  route: FlightRouterState,\n  seedData: CacheNodeSeedData,\n  processSegment: (\n    segmentPath: SegmentPath,\n    seedData: CacheNodeSeedData\n  ) => void\n): void {\n  processSegment(path, seedData)\n\n  const [_segment, childRoutes] = route\n  const [_node, parallelRoutesData, _loading, _isPartial] = seedData\n\n  for (const parallelRouteKey in childRoutes) {\n    const childSeedData = parallelRoutesData[parallelRouteKey]\n    if (!childSeedData) {\n      throw new InvariantError(\n        `Got unexpected empty seed data during instant validation`\n      )\n    }\n\n    const childRoute = childRoutes[parallelRouteKey]\n    // NOTE: if this is a __PAGE__ segment, it might have search params appended.\n    // Whoever reads from the cache needs to append them as well.\n    const [childSegment] = childRoute\n    const childPath = createChildSegmentPath(\n      path,\n      parallelRouteKey,\n      childSegment\n    )\n\n    traverseCacheNodeSegments(\n      childPath,\n      childRoute,\n      childSeedData,\n      processSegment\n    )\n  }\n}\n\nfunction createChildSegmentPath(\n  parentPath: SegmentPath,\n  parallelRouteKey: string,\n  segment: Segment\n): SegmentPath {\n  const parallelRoutePrefix =\n    parallelRouteKey === 'children'\n      ? ''\n      : `@${encodeURIComponent(parallelRouteKey)}/`\n  return `${parentPath}/${parallelRoutePrefix}${stringifySegment(segment)}` as SegmentPath\n}\n\nfunction stringifySegment(segment: Segment): SegmentPath {\n  return (\n    typeof segment === 'string'\n      ? encodeURIComponent(segment)\n      : encodeURIComponent(segment[0]) + '|' + segment[1] + '|' + segment[2]\n  ) as SegmentPath\n}\n\n//===============================================================\n// 2. Separating a stream into segments\n//===============================================================\n\nexport type SegmentStage =\n  | RenderStage.Static\n  | RenderStage.Runtime\n  | RenderStage.Dynamic\n\nexport type StageChunks = Record<SegmentStage, Uint8Array[]>\n\nexport type StageEndTimes = {\n  [RenderStage.Static]: number\n  [RenderStage.Runtime]: number\n}\n\n/**\n * Splits an existing staged stream (represented as arrays of chunks)\n * into separate staged streams (also in arrays-of-chunks form), one for each segment.\n * */\nexport async function collectStagedSegmentData(\n  fullPageChunks: StageChunks,\n  fullPageDebugChunks: Uint8Array[] | null,\n  startTime: number,\n  hasRuntimePrefetch: boolean,\n  clientReferenceManifest: ClientReferenceManifest\n) {\n  const debugChannelAbortController = new AbortController()\n  const debugStream = fullPageDebugChunks\n    ? createNodeStreamFromChunks(\n        fullPageDebugChunks,\n        debugChannelAbortController.signal\n      )\n    : null\n\n  const { stream, controller } = createStagedStreamFromChunks(fullPageChunks)\n  stream.on('end', () => {\n    // When the stream finishes, we have to close the debug stream too,\n    // but delay it to avoid \"Connection closed.\" errors.\n    setImmediate(() => debugChannelAbortController.abort())\n  })\n\n  // Technically we're just re-encoding, so nothing new should be emitted,\n  // but we add an environment name just in case.\n  const environmentName = () => {\n    const currentStage = controller.currentStage\n    switch (currentStage) {\n      case RenderStage.Static:\n        return 'Prerender'\n      case RenderStage.Runtime:\n        return hasRuntimePrefetch ? 'Prefetch' : 'Prefetchable'\n      case RenderStage.Dynamic:\n        return 'Server'\n      default:\n        currentStage satisfies never\n        throw new InvariantError(`Invalid render stage: ${currentStage}`)\n    }\n  }\n\n  // Deserialize the payload.\n  // NOTE: the stream will initially be in the static stage, so that's as far as we get here.\n  // We still expect the outer structure of the payload to be readable in this state.\n  const serverConsumerManifest = {\n    moduleLoading: null,\n    moduleMap: clientReferenceManifest.rscModuleMapping,\n    serverModuleMap: getServerModuleMap(),\n  }\n\n  const payload = await createFromNodeStream<InitialRSCPayload>(\n    stream,\n    serverConsumerManifest,\n    {\n      findSourceMapURL,\n      debugChannel: debugStream ?? undefined,\n      // Do not pass start/end timings - we do not want to omit any debug info.\n      startTime: undefined,\n      endTime: undefined,\n    }\n  )\n\n  // Deconstruct the payload into separate streams per segment.\n  // We have to preserve the stage information for each of them,\n  // so that we can later render each segment in any stage we need.\n\n  const { head } = getRootDataFromPayload(payload)\n\n  const segments = new Map<SegmentPath, SegmentData>()\n  traverseRootSeedDataSegments(payload, (segmentPath, seedData) => {\n    segments.set(segmentPath, createSegmentData(seedData))\n  })\n\n  const cache = createSegmentCache()\n  const pendingTasks: Promise<void>[] = []\n\n  /** Track when we advance stages so we can pass them as `endTime` later. */\n  const stageEndTimes: StageEndTimes = {\n    [RenderStage.Static]: -1,\n    [RenderStage.Runtime]: -1,\n  }\n\n  const renderIntoCacheItem = async (\n    data: HeadData | SegmentData,\n    cacheEntry: SegmentCacheItem\n  ): Promise<void> => {\n    const segmentDebugChannel = cacheEntry.debugChunks\n      ? createDebugChannel()\n      : undefined\n\n    const itemStream = renderToReadableStream(\n      data,\n      clientReferenceManifest.clientModules,\n      {\n        filterStackFrame,\n        debugChannel: segmentDebugChannel?.serverSide,\n        environmentName,\n        startTime,\n        onError(error: unknown) {\n          const digest = getDigestForWellKnownError(error)\n          if (digest) {\n            return digest\n          }\n\n          // Forward existing digests\n          if (\n            error &&\n            typeof error === 'object' &&\n            'digest' in error &&\n            typeof error.digest === 'string'\n          ) {\n            return error.digest\n          }\n\n          // We don't need to log the errors because we would have already done that\n          // when generating the original Flight stream for the whole page.\n          if (\n            process.env.NEXT_DEBUG_BUILD ||\n            process.env.__NEXT_VERBOSE_LOGGING\n          ) {\n            const workStore = workAsyncStorage.getStore()\n            printDebugThrownValueForProspectiveRender(\n              error,\n              workStore?.route ?? 'unknown route',\n              Phase.InstantValidation\n            )\n          }\n        },\n      }\n    )\n\n    await Promise.all([\n      // accumulate Flight chunks\n      (async () => {\n        for await (const chunk of itemStream.values()) {\n          writeChunk(cacheEntry.chunks, controller.currentStage, chunk)\n        }\n      })(),\n      // accumulate Debug chunks\n      segmentDebugChannel &&\n        (async () => {\n          for await (const chunk of segmentDebugChannel.clientSide.readable.values()) {\n            cacheEntry.debugChunks!.push(chunk)\n          }\n        })(),\n    ])\n  }\n\n  await runInSequentialTasks(\n    () => {\n      {\n        const headCacheItem = createSegmentCacheItem(!!fullPageDebugChunks)\n        cache.head = headCacheItem\n        pendingTasks.push(renderIntoCacheItem(head, headCacheItem))\n      }\n\n      for (const [segmentPath, segmentData] of segments) {\n        const segmentCacheItem = createSegmentCacheItem(!!fullPageDebugChunks)\n        cache.segments.set(segmentPath, segmentCacheItem)\n        pendingTasks.push(renderIntoCacheItem(segmentData, segmentCacheItem))\n      }\n    },\n    () => {\n      stageEndTimes[RenderStage.Static] =\n        performance.now() + performance.timeOrigin\n\n      controller.advanceStage(RenderStage.Runtime)\n    },\n    () => {\n      stageEndTimes[RenderStage.Runtime] =\n        performance.now() + performance.timeOrigin\n\n      controller.advanceStage(RenderStage.Dynamic)\n    }\n  )\n  await Promise.all(pendingTasks)\n\n  return { cache, payload, stageEndTimes }\n}\n\n/**\n * Turns accumulated stage chunks into a stream.\n * The stream starts out in Static stage, and can be advanced further\n * using the returned controller object.\n * Conceptually, this is similar to how we unblock more content\n * by advancing stages in a regular staged render.\n * */\nfunction createStagedStreamFromChunks(stageChunks: StageChunks) {\n  // The successive stages are supersets of one another,\n  // so we can index into the dynamic chunks everywhere\n  // and just look at the lengths of the Static/Runtime arrays\n  const allChunks = stageChunks[RenderStage.Dynamic]\n\n  const numStaticChunks = stageChunks[RenderStage.Static].length\n  const numRuntimeChunks = stageChunks[RenderStage.Runtime].length\n  const numDynamicChunks = stageChunks[RenderStage.Dynamic].length\n\n  let chunkIx = 0\n  let currentStage:\n    | RenderStage.Static\n    | RenderStage.Runtime\n    | RenderStage.Dynamic = RenderStage.Static\n  let closed = false\n\n  function push(chunk: Uint8Array) {\n    stream.push(chunk)\n  }\n\n  function close() {\n    closed = true\n    stream.push(null)\n  }\n\n  const stream = new Readable({\n    read() {\n      // Emit static chunks\n      for (; chunkIx < numStaticChunks; chunkIx++) {\n        push(allChunks[chunkIx])\n      }\n\n      // If there's no more chunks after this stage, finish the stream.\n      if (chunkIx >= allChunks.length) {\n        close()\n        return\n      }\n    },\n  })\n\n  function advanceStage(\n    stage: RenderStage.Runtime | RenderStage.Dynamic\n  ): boolean {\n    if (closed) return true\n\n    switch (stage) {\n      case RenderStage.Runtime: {\n        currentStage = RenderStage.Runtime\n        for (; chunkIx < numRuntimeChunks; chunkIx++) {\n          push(allChunks[chunkIx])\n        }\n        break\n      }\n\n      case RenderStage.Dynamic: {\n        currentStage = RenderStage.Dynamic\n        for (; chunkIx < numDynamicChunks; chunkIx++) {\n          push(allChunks[chunkIx])\n        }\n        break\n      }\n\n      default: {\n        stage satisfies never\n      }\n    }\n\n    // If there's no more chunks after this stage, finish the stream.\n    if (chunkIx >= allChunks.length) {\n      close()\n      return true\n    } else {\n      return false\n    }\n  }\n\n  return {\n    stream,\n    controller: {\n      get currentStage() {\n        return currentStage\n      },\n      advanceStage,\n    },\n  }\n}\n\nfunction writeChunk(\n  stageChunks: StageChunks,\n  stage: SegmentStage,\n  chunk: Uint8Array\n) {\n  switch (stage) {\n    case RenderStage.Static: {\n      stageChunks[RenderStage.Static].push(chunk)\n      // fallthrough\n    }\n    case RenderStage.Runtime: {\n      stageChunks[RenderStage.Runtime].push(chunk)\n      // fallthrough\n    }\n    case RenderStage.Dynamic: {\n      stageChunks[RenderStage.Dynamic].push(chunk)\n      break\n    }\n    default: {\n      stage satisfies never\n    }\n  }\n}\n\n//===============================================================\n// 3. Recombining segments into a new payload\n//===============================================================\n\n/**\n * Creates a late-release stream for a given payload.\n * When `renderSignal` is triggered, the stream will release late chunks\n * to provide extra debug info.\n * */\nexport async function createCombinedPayloadStream(\n  payload: InitialRSCPayload,\n  extraChunksAbortController: AbortController,\n  renderSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  startTime: number,\n  isDebugChannelEnabled: boolean\n) {\n  // Collect all the chunks so that we're not dependent on timing of the render.\n\n  let isRenderable = true\n  const renderableChunks: Uint8Array[] = []\n  const allChunks: Uint8Array[] = []\n\n  const debugChunks: Uint8Array[] | null = isDebugChannelEnabled ? [] : null\n  const debugChannel = isDebugChannelEnabled ? createDebugChannel() : null\n\n  let streamFinished: Promise<any>\n\n  await runInSequentialTasks(\n    () => {\n      const stream = renderToReadableStream(\n        payload,\n        clientReferenceManifest.clientModules,\n        {\n          filterStackFrame,\n          debugChannel: debugChannel?.serverSide,\n          startTime,\n          onError(error: unknown) {\n            const digest = getDigestForWellKnownError(error)\n            if (digest) {\n              return digest\n            }\n\n            // Forward existing digests\n            if (\n              error &&\n              typeof error === 'object' &&\n              'digest' in error &&\n              typeof error.digest === 'string'\n            ) {\n              return error.digest\n            }\n\n            // We don't need to log the errors because we would have already done that\n            // when generating the original Flight stream for the whole page.\n            if (\n              process.env.NEXT_DEBUG_BUILD ||\n              process.env.__NEXT_VERBOSE_LOGGING\n            ) {\n              const workStore = workAsyncStorage.getStore()\n              printDebugThrownValueForProspectiveRender(\n                error,\n                workStore?.route ?? 'unknown route',\n                Phase.InstantValidation\n              )\n            }\n          },\n        }\n      )\n\n      streamFinished = Promise.all([\n        // Accumulate Flight chunks\n        (async () => {\n          for await (const chunk of stream.values()) {\n            allChunks.push(chunk)\n            if (isRenderable) {\n              renderableChunks.push(chunk)\n            }\n          }\n        })(),\n        // Accumulate debug chunks\n        debugChannel &&\n          (async () => {\n            for await (const chunk of debugChannel.clientSide.readable.values()) {\n              debugChunks!.push(chunk)\n            }\n          })(),\n      ])\n    },\n    () => {\n      isRenderable = false\n      extraChunksAbortController.abort()\n    }\n  )\n\n  await streamFinished!\n\n  return {\n    stream: createNodeStreamWithLateRelease(\n      renderableChunks,\n      allChunks,\n      renderSignal\n    ),\n    debugStream: debugChunks\n      ? createNodeStreamFromChunks(debugChunks, renderSignal)\n      : null,\n  }\n}\n\nfunction getRootDataFromPayload(initialRSCPayload: InitialRSCPayload) {\n  // FlightDataPath is an unsound type, hence the additional checks.\n  const flightDataPaths = initialRSCPayload.f\n  if (flightDataPaths.length !== 1 && flightDataPaths[0].length !== 3) {\n    throw new InvariantError(\n      'InitialRSCPayload does not match the expected shape during instant validation.'\n    )\n  }\n  const flightRouterState: FlightRouterState = flightDataPaths[0][0]\n  const seedData: CacheNodeSeedData = flightDataPaths[0][1]\n  // TODO: handle head\n  const head: HeadData = flightDataPaths[0][2]\n\n  return { flightRouterState, seedData, head }\n}\n\nasync function createValidationHead(\n  cache: SegmentCache,\n  releaseSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  stageEndTimes: StageEndTimes,\n  stage: RenderStage.Static | RenderStage.Runtime\n): Promise<HeadData> {\n  const segmentCacheItem = cache.head\n  if (!segmentCacheItem) {\n    throw new InvariantError(`Missing segment data: <head>`)\n  }\n  return await deserializeFromChunks<HeadData>(\n    segmentCacheItem.chunks[stage],\n    segmentCacheItem.chunks[RenderStage.Dynamic],\n    segmentCacheItem.debugChunks,\n    releaseSignal,\n    clientReferenceManifest,\n    { startTime: undefined, endTime: stageEndTimes[stage] }\n  )\n}\n\ntype Timings = {\n  startTime?: number\n  endTime?: number\n}\n\n/**\n * Deserializes a (partial possibly partial) RSC stream, given as a chunk-array.\n * If the stream is partial, we'll wait for `releaseSignal` to fire\n * and then complete the deserialization using `allChunks`.\n *\n * This is used to obtain a partially-complete model (that might contain unresolved holes)\n * and then release any late debug info from chunks that came later before we abort the render.\n * */\nfunction deserializeFromChunks<T>(\n  partialChunks: Uint8Array[],\n  allChunks: Uint8Array[],\n  debugChunks: Uint8Array[] | null,\n  releaseSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  timings: Timings | null\n): Promise<T> {\n  const debugChannelAbortController = new AbortController()\n  const debugStream = debugChunks\n    ? createNodeStreamFromChunks(\n        debugChunks,\n        debugChannelAbortController.signal\n      )\n    : null\n\n  const serverConsumerManifest = {\n    moduleLoading: null,\n    moduleMap: clientReferenceManifest.rscModuleMapping,\n    serverModuleMap: getServerModuleMap(),\n  }\n\n  const segmentStream =\n    partialChunks.length < allChunks.length\n      ? createNodeStreamWithLateRelease(partialChunks, allChunks, releaseSignal)\n      : createNodeStreamFromChunks(partialChunks)\n\n  segmentStream.on('end', () => {\n    // When the stream finishes, we have to close the debug stream too,\n    // but delay it to avoid \"Connection closed.\" errors.\n    setImmediate(() => debugChannelAbortController.abort())\n  })\n\n  return createFromNodeStream(segmentStream, serverConsumerManifest, {\n    findSourceMapURL,\n    debugChannel: debugStream ?? undefined,\n    startTime: timings?.startTime,\n    endTime: timings?.endTime,\n  }) as Promise<T>\n}\n\n//===============================================================\n// Validation segment cache\n//===============================================================\n\n/** An object version of `CacheNodeSeedData`, without slots. */\ntype SegmentData = {\n  node: React.ReactNode | null\n  isPartial: boolean\n  varyParams: VaryParamsThenable | null\n}\n\nfunction createSegmentData(seedData: CacheNodeSeedData): SegmentData {\n  const [node, _parallelRoutesData, _unused, isPartial, varyParams] = seedData\n  return {\n    node,\n    isPartial,\n    varyParams,\n  }\n}\ntype CacheNodeSeedDataSlots = CacheNodeSeedData[1]\n\nfunction getCacheNodeSeedDataFromSegment(\n  data: SegmentData,\n  slots: CacheNodeSeedDataSlots\n): CacheNodeSeedData {\n  return [\n    data.node,\n    slots,\n    /* unused (previously `loading`) */ null,\n    data.isPartial,\n    data.varyParams,\n  ]\n}\n\nfunction createSegmentCache(): SegmentCache {\n  return { head: null, segments: new Map() }\n}\n\nfunction createSegmentCacheItem(withDebugChunks: boolean): SegmentCacheItem {\n  return {\n    chunks: {\n      [RenderStage.Static]: [],\n      [RenderStage.Runtime]: [],\n      [RenderStage.Dynamic]: [],\n    },\n    debugChunks: withDebugChunks ? [] : null,\n  }\n}\n\nexport type SegmentCache = {\n  head: SegmentCacheItem | null\n  segments: Map<SegmentPath, SegmentCacheItem>\n}\n\ntype SegmentCacheItem = {\n  chunks: StageChunks\n  debugChunks: Uint8Array[] | null\n}\n\ntype TreeResult = {\n  seedData: CacheNodeSeedData\n  requiresInstantUI: boolean\n  createInstantStack: (() => Error) | null\n}\n\n/**\n * Whether this segment consumes a URL depth level. Each URL depth\n * represents a potential navigation boundary.\n *\n * The root segment ('') consumes depth 0. Regular segments like\n * 'dashboard' consume the next depth — whether or not they have a\n * layout. Route groups, __PAGE__, __DEFAULT__, and /_not-found don't\n * consume a depth — they share the boundary of their parent.\n */\nfunction segmentConsumesURLDepth(segment: Segment): boolean {\n  // Dynamic segments (tuples) always consume a URL depth.\n  if (typeof segment !== 'string') return true\n  // Route groups, pages, defaults, and not-found don't consume a depth.\n  if (\n    segment.startsWith(PAGE_SEGMENT_KEY) ||\n    isGroupSegment(segment) ||\n    segment === DEFAULT_SEGMENT_KEY ||\n    segment === NOT_FOUND_SEGMENT_KEY\n  ) {\n    return false\n  }\n  // Everything else consumes a depth, including the root segment ''.\n  return true\n}\n\n/**\n * Walks the LoaderTree to discover validation depth bounds.\n *\n * Each route group between URL segments represents a potential\n * shared/new boundary in a client navigation. When a user navigates\n * between sibling routes that share a route group layout, that\n * layout is already mounted — its Suspense boundaries are revealed\n * and don't cover new content below. By tracking the max group\n * depth at each URL depth, we can iterate all possible group\n * boundaries and validate that blocking code is always covered by\n * Suspense in the new tree. This is conservative: some boundaries\n * may not correspond to real navigations (e.g. a route group with\n * no siblings), but it ensures we don't miss real violations.\n *\n * The max is taken across all parallel slots. When slots have\n * different numbers of groups, the deepest slot determines the\n * iteration range. Shallower slots simply stay entirely shared\n * at group depths beyond their own group count — they run out\n * of groups before reaching the boundary, so their content\n * remains in the Dynamic stage.\n *\n * Returns an array where:\n * - length = max URL depth (number of URL-consuming segments)\n * - array[i] = max group depth at URL depth i (number of route group\n *   segments between this URL depth and the next)\n *\n * For example, a tree like:\n *   '' / (outer) / (inner) / dashboard / page\n * returns [2, 0] — URL depth 0 (root) has 2 group layers before\n * the next URL segment (dashboard), and URL depth 1 (dashboard) has\n * 0 group layers before the leaf.\n */\nexport function discoverValidationDepths(loaderTree: LoaderTree): number[] {\n  const groupDepthsByUrlDepth: number[] = []\n\n  function recordGroupDepth(urlDepth: number, groupDepth: number): void {\n    while (groupDepthsByUrlDepth.length <= urlDepth) {\n      groupDepthsByUrlDepth.push(0)\n    }\n    if (groupDepth > groupDepthsByUrlDepth[urlDepth]) {\n      groupDepthsByUrlDepth[urlDepth] = groupDepth\n    }\n  }\n\n  // urlDepth tracks the index of the current URL-consuming segment.\n  // Groups accumulate at the same index. When the next URL segment\n  // is reached, it increments the index and resets the group counter.\n  // We start at -1 so the root segment '' increments to 0.\n  function walk(tree: LoaderTree, urlDepth: number, groupDepth: number): void {\n    const segment = tree[0]\n    const { parallelRoutes } = parseLoaderTree(tree)\n    const consumesDepth = segmentConsumesURLDepth(segment)\n\n    let nextUrlDepth = urlDepth\n    let nextGroupDepth = groupDepth\n    if (consumesDepth) {\n      nextUrlDepth = urlDepth + 1\n      nextGroupDepth = 0\n      recordGroupDepth(nextUrlDepth, 0)\n    } else if (\n      typeof segment === 'string' &&\n      isGroupSegment(segment) &&\n      segment !== '(__SLOT__)'\n    ) {\n      // Count real route groups but not the synthetic '(__SLOT__)' segment\n      // that Next.js inserts for parallel slots. The synthetic group\n      // can't be a real navigation boundary.\n      nextGroupDepth++\n      recordGroupDepth(urlDepth, nextGroupDepth)\n    }\n\n    for (const key in parallelRoutes) {\n      walk(parallelRoutes[key], nextUrlDepth, nextGroupDepth)\n    }\n  }\n\n  walk(loaderTree, -1, 0)\n  return groupDepthsByUrlDepth\n}\n\n/**\n * Builds a combined RSC payload for validation at a given URL depth.\n *\n * Walks the LoaderTree directly, loading modules and counting\n * URL-contributing layouts. When `depth` URL segments have been\n * consumed, the boundary flips from shared (dynamic stage) to new\n * (static/runtime stage). As the new subtree is built, we check for\n * instant configs. If none are found, returns null — no validation\n * needed at this depth or deeper.\n *\n * This combines module loading, tree walking, config discovery, and\n * payload construction into a single pass.\n */\nexport type ValidationPayloadResult = {\n  payload: InitialRSCPayload\n  /** Whether errors from this payload could be ambiguous between runtime\n   * API access (cookies, headers) and uncached IO (connection, fetch).\n   * True when some segments used Static stage. False when all segments\n   * used Runtime stage and errors are definitively from uncached IO. */\n  hasAmbiguousErrors: boolean\n  createInstantStack: (() => Error) | null\n}\n\nexport async function createCombinedPayloadAtDepth(\n  initialRSCPayload: InitialRSCPayload,\n  cache: SegmentCache,\n  initialLoaderTree: LoaderTree,\n  getDynamicParamFromSegment: GetDynamicParamFromSegment,\n  query: NextParsedUrlQuery | null,\n  depth: number,\n  groupDepth: number,\n  releaseSignal: AbortSignal,\n  boundaryState: ValidationBoundaryTracking,\n  clientReferenceManifest: ClientReferenceManifest,\n  stageEndTimes: StageEndTimes,\n  useRuntimeStageForPartialSegments: boolean\n): Promise<ValidationPayloadResult | null> {\n  let hasStaticSegments = false\n  let hasRuntimeSegments = false\n\n  function getSegment(loaderTree: LoaderTree): Segment {\n    const dynamicParam = getDynamicParamFromSegment(loaderTree)\n    if (dynamicParam) {\n      return dynamicParam.treeSegment\n    }\n    const segment = loaderTree[0]\n    return query ? addSearchParamsIfPageSegment(segment, query) : segment\n  }\n\n  async function buildSharedTreeSeedData(\n    loaderTree: LoaderTree,\n    parentPath: SegmentPath | null,\n    key: string | null,\n    urlDepthConsumed: number,\n    groupDepthConsumed: number\n  ): Promise<TreeResult> {\n    const { parallelRoutes } = parseLoaderTree(loaderTree)\n\n    const segment = getSegment(loaderTree)\n    const path: SegmentPath =\n      parentPath === null\n        ? stringifySegment(segment)\n        : createChildSegmentPath(parentPath, key!, segment)\n\n    debug?.(`    ${path || '/'} - Dynamic`)\n    const segmentCacheItem = cache.segments.get(path)\n    if (!segmentCacheItem) {\n      throw new InvariantError(`Missing segment data: ${path}`)\n    }\n\n    const segmentData = await deserializeFromChunks<SegmentData>(\n      segmentCacheItem.chunks[RenderStage.Dynamic],\n      segmentCacheItem.chunks[RenderStage.Dynamic],\n      segmentCacheItem.debugChunks,\n      releaseSignal,\n      clientReferenceManifest,\n      null\n    )\n\n    const consumesUrlDepth = segmentConsumesURLDepth(segment)\n    const isGroup =\n      typeof segment === 'string' &&\n      isGroupSegment(segment) &&\n      segment !== '(__SLOT__)'\n\n    // Advance counters for this segment before the boundary check,\n    // mirroring how discoverValidationDepths counts. URL segments\n    // increment urlDepthConsumed, groups increment groupDepthConsumed.\n    // The synthetic '(__SLOT__)' segment is excluded — it can't be a\n    // real navigation boundary.\n    let nextUrlDepth = urlDepthConsumed\n    let currentGroupDepth = groupDepthConsumed\n    if (consumesUrlDepth) {\n      nextUrlDepth++\n      currentGroupDepth = 0\n    } else if (isGroup) {\n      currentGroupDepth++\n    }\n\n    const pastUrlBoundary = nextUrlDepth > depth\n    const isBoundary = pastUrlBoundary && currentGroupDepth >= groupDepth\n\n    if (isBoundary) {\n      debug?.(\n        `    ['${path}' is the boundary (url=${nextUrlDepth}, group=${currentGroupDepth})]`\n      )\n      boundaryState.expectedIds.add(path)\n      const finalSegmentData: SegmentData = {\n        ...segmentData,\n        node: (\n          // eslint-disable-next-line @next/internal/no-ambiguous-jsx -- bundled in the server layer\n          <PlaceValidationBoundaryBelowThisLevel id={path} key=\"c\">\n            {segmentData.node}\n          </PlaceValidationBoundaryBelowThisLevel>\n        ),\n      }\n\n      const slots: CacheNodeSeedDataSlots = {}\n      let requiresInstantUI = false\n      let createInstantStack: (() => Error) | null = null\n      for (const parallelRouteKey in parallelRoutes) {\n        const result = await buildNewTreeSeedData(\n          parallelRoutes[parallelRouteKey],\n          path,\n          parallelRouteKey,\n          false /* isInsideRuntimePrefetch */\n        )\n        slots[parallelRouteKey] = result.seedData\n        if (result.requiresInstantUI) {\n          requiresInstantUI = true\n          if (createInstantStack === null) {\n            createInstantStack = result.createInstantStack\n          }\n        }\n      }\n      return {\n        seedData: getCacheNodeSeedDataFromSegment(finalSegmentData, slots),\n        requiresInstantUI,\n        createInstantStack,\n      }\n    }\n\n    // Not at the boundary yet — keep walking as shared.\n    const slots: CacheNodeSeedDataSlots = {}\n    let requiresInstantUI = false\n    let createInstantStack: (() => Error) | null = null\n    for (const parallelRouteKey in parallelRoutes) {\n      const result = await buildSharedTreeSeedData(\n        parallelRoutes[parallelRouteKey],\n        path,\n        parallelRouteKey,\n        nextUrlDepth,\n        currentGroupDepth\n      )\n      slots[parallelRouteKey] = result.seedData\n      if (result.requiresInstantUI) {\n        requiresInstantUI = true\n        if (createInstantStack === null) {\n          createInstantStack = result.createInstantStack\n        }\n      }\n    }\n    return {\n      seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),\n      requiresInstantUI,\n      createInstantStack,\n    }\n  }\n\n  async function buildNewTreeSeedData(\n    lt: LoaderTree,\n    parentPath: SegmentPath | null,\n    key: string | null,\n    isInsideRuntimePrefetch: boolean\n  ): Promise<TreeResult> {\n    const { parallelRoutes } = parseLoaderTree(lt)\n    const { mod: layoutOrPageMod } = await getLayoutOrPageModule(lt)\n\n    const segment = getSegment(lt)\n    const path: SegmentPath =\n      parentPath === null\n        ? stringifySegment(segment)\n        : createChildSegmentPath(parentPath, key!, segment)\n\n    let instantConfig: Instant | null = null\n    let localCreateInstantStack: (() => Error) | null = null\n    if (layoutOrPageMod !== undefined) {\n      instantConfig =\n        (layoutOrPageMod as AppSegmentConfig).unstable_instant ?? null\n      if (instantConfig && typeof instantConfig === 'object') {\n        const rawFactory: unknown = (layoutOrPageMod as any)\n          .__debugCreateInstantConfigStack\n        localCreateInstantStack =\n          typeof rawFactory === 'function' ? (rawFactory as () => Error) : null\n      }\n    }\n\n    let childIsInsideRuntimePrefetch = isInsideRuntimePrefetch\n    let stage: SegmentStage\n    if (!isInsideRuntimePrefetch) {\n      if (\n        instantConfig &&\n        typeof instantConfig === 'object' &&\n        instantConfig.prefetch === 'runtime'\n      ) {\n        stage = RenderStage.Runtime\n        childIsInsideRuntimePrefetch = true\n        hasRuntimeSegments = true\n      } else {\n        if (useRuntimeStageForPartialSegments) {\n          stage = RenderStage.Runtime\n          hasRuntimeSegments = true\n        } else {\n          stage = RenderStage.Static\n          hasStaticSegments = true\n        }\n      }\n    } else {\n      stage = RenderStage.Runtime\n      hasRuntimeSegments = true\n    }\n\n    debug?.(`    ${path || '/'} - ${RenderStage[stage]}`)\n    const segmentCacheItem = cache.segments.get(path)\n    if (!segmentCacheItem) {\n      throw new InvariantError(`Missing segment data: ${path}`)\n    }\n\n    const segmentData = await deserializeFromChunks<SegmentData>(\n      segmentCacheItem.chunks[stage],\n      segmentCacheItem.chunks[RenderStage.Dynamic],\n      segmentCacheItem.debugChunks,\n      releaseSignal,\n      clientReferenceManifest,\n      { startTime: undefined, endTime: stageEndTimes[stage] }\n    )\n\n    // Build children first, then determine requiresInstantUI.\n    const slots: CacheNodeSeedDataSlots = {}\n    let childrenRequireInstantUI = false\n    let childCreateInstantStack: (() => Error) | null = null\n    for (const parallelRouteKey in parallelRoutes) {\n      const result = await buildNewTreeSeedData(\n        parallelRoutes[parallelRouteKey],\n        path,\n        parallelRouteKey,\n        childIsInsideRuntimePrefetch\n      )\n      slots[parallelRouteKey] = result.seedData\n      if (result.requiresInstantUI) {\n        childrenRequireInstantUI = true\n        if (childCreateInstantStack === null) {\n          childCreateInstantStack = result.createInstantStack\n        }\n      }\n    }\n\n    // Local config takes precedence over children.\n    let requiresInstantUI: boolean\n    let createInstantStack: (() => Error) | null\n    if (instantConfig === false) {\n      requiresInstantUI = false\n      createInstantStack = null\n    } else if (instantConfig && typeof instantConfig === 'object') {\n      requiresInstantUI = true\n      createInstantStack = localCreateInstantStack\n    } else {\n      requiresInstantUI = childrenRequireInstantUI\n      createInstantStack = childCreateInstantStack\n    }\n\n    return {\n      seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),\n      requiresInstantUI,\n      createInstantStack,\n    }\n  }\n\n  const { seedData, requiresInstantUI, createInstantStack } =\n    await buildSharedTreeSeedData(\n      initialLoaderTree,\n      null /* parentPath */,\n      null /* key */,\n      0 /* urlDepthConsumed */,\n      0 /* groupDepthConsumed */\n    )\n\n  if (!requiresInstantUI) {\n    return null\n  }\n\n  const { flightRouterState } = getRootDataFromPayload(initialRSCPayload)\n\n  const headStage = hasRuntimeSegments\n    ? RenderStage.Runtime\n    : RenderStage.Static\n\n  const head = await createValidationHead(\n    cache,\n    releaseSignal,\n    clientReferenceManifest,\n    stageEndTimes,\n    headStage\n  )\n\n  const payload: InitialRSCPayload = {\n    ...initialRSCPayload,\n    f: [[flightRouterState, seedData, head]],\n  }\n\n  return {\n    payload,\n    hasAmbiguousErrors: hasStaticSegments,\n    createInstantStack,\n  }\n}\n"],"names":["collectStagedSegmentData","createCombinedPayloadAtDepth","createCombinedPayloadStream","discoverValidationDepths","filterStackFrame","process","env","NODE_ENV","require","filterStackFrameDEV","undefined","findSourceMapURL","findSourceMapURLDEV","debug","NEXT_PRIVATE_DEBUG_VALIDATION","console","log","traverseRootSeedDataSegments","initialRSCPayload","processSegment","flightRouterState","seedData","getRootDataFromPayload","rootSegment","rootPath","stringifySegment","traverseCacheNodeSegments","path","route","_segment","childRoutes","_node","parallelRoutesData","_loading","_isPartial","parallelRouteKey","childSeedData","InvariantError","childRoute","childSegment","childPath","createChildSegmentPath","parentPath","segment","parallelRoutePrefix","encodeURIComponent","fullPageChunks","fullPageDebugChunks","startTime","hasRuntimePrefetch","clientReferenceManifest","debugChannelAbortController","AbortController","debugStream","createNodeStreamFromChunks","signal","stream","controller","createStagedStreamFromChunks","on","setImmediate","abort","environmentName","currentStage","RenderStage","Static","Runtime","Dynamic","serverConsumerManifest","moduleLoading","moduleMap","rscModuleMapping","serverModuleMap","getServerModuleMap","payload","createFromNodeStream","debugChannel","endTime","head","segments","Map","segmentPath","set","createSegmentData","cache","createSegmentCache","pendingTasks","stageEndTimes","renderIntoCacheItem","data","cacheEntry","segmentDebugChannel","debugChunks","createDebugChannel","itemStream","renderToReadableStream","clientModules","serverSide","onError","error","digest","getDigestForWellKnownError","NEXT_DEBUG_BUILD","__NEXT_VERBOSE_LOGGING","workStore","workAsyncStorage","getStore","printDebugThrownValueForProspectiveRender","Phase","InstantValidation","Promise","all","chunk","values","writeChunk","chunks","clientSide","readable","push","runInSequentialTasks","headCacheItem","createSegmentCacheItem","segmentData","segmentCacheItem","performance","now","timeOrigin","advanceStage","stageChunks","allChunks","numStaticChunks","length","numRuntimeChunks","numDynamicChunks","chunkIx","closed","close","Readable","read","stage","extraChunksAbortController","renderSignal","isDebugChannelEnabled","isRenderable","renderableChunks","streamFinished","createNodeStreamWithLateRelease","flightDataPaths","f","createValidationHead","releaseSignal","deserializeFromChunks","partialChunks","timings","segmentStream","node","_parallelRoutesData","_unused","isPartial","varyParams","getCacheNodeSeedDataFromSegment","slots","withDebugChunks","segmentConsumesURLDepth","startsWith","PAGE_SEGMENT_KEY","isGroupSegment","DEFAULT_SEGMENT_KEY","NOT_FOUND_SEGMENT_KEY","loaderTree","groupDepthsByUrlDepth","recordGroupDepth","urlDepth","groupDepth","walk","tree","parallelRoutes","parseLoaderTree","consumesDepth","nextUrlDepth","nextGroupDepth","key","initialLoaderTree","getDynamicParamFromSegment","query","depth","boundaryState","useRuntimeStageForPartialSegments","hasStaticSegments","hasRuntimeSegments","getSegment","dynamicParam","treeSegment","addSearchParamsIfPageSegment","buildSharedTreeSeedData","urlDepthConsumed","groupDepthConsumed","get","consumesUrlDepth","isGroup","currentGroupDepth","pastUrlBoundary","isBoundary","expectedIds","add","finalSegmentData","PlaceValidationBoundaryBelowThisLevel","id","requiresInstantUI","createInstantStack","result","buildNewTreeSeedData","lt","isInsideRuntimePrefetch","mod","layoutOrPageMod","getLayoutOrPageModule","instantConfig","localCreateInstantStack","unstable_instant","rawFactory","__debugCreateInstantConfigStack","childIsInsideRuntimePrefetch","prefetch","childrenRequireInstantUI","childCreateInstantStack","headStage","hasAmbiguousErrors"],"mappings":";;;;;;;;;;;;;;;;;IAwMsBA,wBAAwB;eAAxBA;;IAkrBAC,4BAA4B;eAA5BA;;IAhYAC,2BAA2B;eAA3BA;;IAyTNC,wBAAwB;eAAxBA;;;;gCA3yBe;iCACH;oCACO;sCACE;0CACJ;wCAI1B;oCACoC;0BAIpC;8BAKA;iCACyB;4BAMP;6BAIlB;oCAC4B;wBAEE;wBAEE;yBAOhC;AAGP,MAAMC,mBACJC,QAAQC,GAAG,CAACC,QAAQ,KAAK,eACrB,AACEC,QAAQ,yBACRC,mBAAmB,GACrBC;AACN,MAAMC,mBACJN,QAAQC,GAAG,CAACC,QAAQ,KAAK,eACrB,AACEC,QAAQ,yBACRI,mBAAmB,GACrBF;AAQN,MAAMG,QACJR,QAAQC,GAAG,CAACQ,6BAA6B,KAAK,MAAMC,QAAQC,GAAG,GAAGN;AA2BpE,SAASO,6BACPC,iBAAoC,EACpCC,cAGS;IAET,MAAM,EAAEC,iBAAiB,EAAEC,QAAQ,EAAE,GACnCC,uBAAuBJ;IAEzB,MAAM,CAACK,YAA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