{"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 { VaryParamsIterable } 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 these are client references\n  PlaceValidationBoundaryBelowThisLevel,\n  SlotMarker,\n} from '../../../client/components/instant-validation/boundary'\nimport {\n  INSTANT_SLOT_MARKER_PREFIX,\n  INSTANT_SLOT_MARKER_SUFFIX,\n} from './boundary-constants'\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 type { DebugChannelPair } from '../debug-channel-server'\nimport type { FlightComponentMod } from '../stream-ops'\n\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport { createFromNodeStream } from 'react-server-dom-webpack/client'\nimport {\n  addSearchParamsIfPageSegment,\n  isGroupSegment,\n  PAGE_SEGMENT_KEY,\n  DEFAULT_SEGMENT_KEY,\n  NOT_FOUND_SEGMENT_KEY,\n} from '../../../shared/lib/segment'\nimport {\n  isFrameworkErrorRoute,\n  isImplicitValidationSegment,\n} from './instant-config'\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.ShellRuntime\n  | RenderStage.Runtime\n  | RenderStage.Dynamic\n\n/** The stages that a prefetched segment can be in. */\ntype PrefetchedSegmentStage = Exclude<SegmentStage, RenderStage.Dynamic>\n\nexport type StageChunks = Record<SegmentStage, Uint8Array[]>\n\nexport type StageEndTimes = Record<PrefetchedSegmentStage, number>\n\ntype RenderToFlightStream = (\n  ComponentMod: FlightComponentMod,\n  payload: any,\n  clientModules: any,\n  opts: any\n) => AsyncIterable<Uint8Array>\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  prefetchKind: ValidationPrefetchKind,\n  ComponentMod: FlightComponentMod,\n  renderFlightStream: RenderToFlightStream,\n  fullPageChunks: StageChunks,\n  fullPageDebugChunks: Uint8Array[] | null,\n  startTime: number,\n  stageEndTimes: StageEndTimes,\n  clientReferenceManifest: ClientReferenceManifest,\n  createDebugChannel: () => DebugChannelPair | undefined\n): Promise<{ cache: SegmentCache; payload: InitialRSCPayload }> {\n  const cache = createSegmentCache()\n\n  let partialStages: SegmentStage[]\n  switch (prefetchKind) {\n    case ValidationPrefetchKind.Shell: {\n      partialStages = [RenderStage.ShellRuntime, RenderStage.Runtime]\n      break\n    }\n    case ValidationPrefetchKind.LegacySpeculative: {\n      partialStages = [RenderStage.Static, RenderStage.Runtime]\n      break\n    }\n  }\n\n  const doStage = async (targetStage: SegmentStage) => {\n    const endTime =\n      targetStage !== RenderStage.Dynamic\n        ? stageEndTimes[targetStage]\n        : undefined\n    const firstStage = partialStages[0]\n    return await collectSegmentDataForStage(\n      ComponentMod,\n      renderFlightStream,\n      fullPageChunks,\n      fullPageDebugChunks,\n      clientReferenceManifest,\n      createDebugChannel,\n      cache,\n      firstStage,\n      targetStage,\n      startTime,\n      endTime\n    )\n  }\n\n  for (const targetStage of partialStages) {\n    await doStage(targetStage)\n  }\n  const payload = await doStage(RenderStage.Dynamic)\n\n  return { cache, payload }\n}\n\nasync function collectSegmentDataForStage(\n  ComponentMod: FlightComponentMod,\n  renderFlightStream: RenderToFlightStream,\n  fullPageChunks: StageChunks,\n  fullPageDebugChunks: Uint8Array[] | null,\n  clientReferenceManifest: ClientReferenceManifest,\n  createDebugChannel: () => DebugChannelPair | undefined,\n  cache: SegmentCache,\n  firstStage: SegmentStage,\n  targetStage: SegmentStage,\n  startTime: number,\n  endTime: number | undefined\n): Promise<InitialRSCPayload> {\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.Before:\n      case RenderStage.Static:\n        return 'Prerender'\n      case RenderStage.ShellRuntime: // TODO(app-shells) - proper environmentName\n      case RenderStage.Runtime:\n        return 'Prefetch'\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 partially so that we can traverse the structure.\n\n  const serverConsumerManifest = {\n    moduleLoading: null,\n    moduleMap: clientReferenceManifest.rscModuleMapping,\n    serverModuleMap: getServerModuleMap(),\n  }\n\n  const payloadPromise = createFromNodeStream<InitialRSCPayload>(\n    stream,\n    serverConsumerManifest,\n    {\n      findSourceMapURL,\n      debugChannel: debugStream ?? undefined,\n      startTime,\n      // Each stage is decoded with an `endTime` corresponding to\n      // when it finished rendering, so that we can avoid pointing to\n      // IO that finished after the stage is done.\n      // This needs to happen during the first deserialization, because\n      // when we serialize the segments afterwards, React will clamp the\n      // timestamps of IO to the current time, and we will lose the ability\n      // to omit info about IO that hasn't resolved in this stage.\n      endTime,\n    }\n  )\n\n  // We expect the outer structure of the payload to be readable in any stage,\n  // even if the segments are incomplete.\n  // NOTE: This must be done after the `createFromNodeStream` call but *before*\n  // the result is awaited, otherwise we'll deadlock.\n  controller.advanceStage(firstStage)\n\n  const payload = await payloadPromise\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 pendingTasks: Promise<void>[] = []\n\n  const renderIntoStageEntry = async (\n    data: HeadData | SegmentData,\n    stageEntry: SegmentCacheItemStageEntry\n  ): Promise<void> => {\n    const segmentDebugChannel = stageEntry.debugChunks\n      ? createDebugChannel()\n      : undefined\n\n    const itemStream = renderFlightStream(\n      ComponentMod,\n      data,\n      clientReferenceManifest.clientModules,\n      {\n        filterStackFrame,\n        debugChannel: segmentDebugChannel?.serverSide,\n        environmentName,\n        startTime,\n        onError: onFlightRenderError,\n      }\n    )\n\n    await Promise.all([\n      // accumulate Flight chunks\n      (async () => {\n        for await (const chunk of itemStream) {\n          if (controller.currentStage === RenderStage.Before) {\n            throw new InvariantError('Unexpected chunk emitted in Before stage')\n          }\n          writeChunk(stageEntry, controller.currentStage, targetStage, chunk)\n        }\n      })(),\n      // accumulate Debug chunks\n      segmentDebugChannel &&\n        (async () => {\n          for await (const chunk of segmentDebugChannel.clientSide.readable) {\n            stageEntry.debugChunks!.push(chunk)\n          }\n        })(),\n    ])\n  }\n\n  // Each stage is rendered in a separate pass (passed in as targetStage),\n  // so we only need two stages:\n  // 1. the target stage\n  // 2. the dynamic stage (for late-release debug info)\n  await runInSequentialTasks(\n    () => {\n      if (targetStage !== RenderStage.Dynamic) {\n        controller.advanceStage(targetStage)\n      }\n\n      const withDebugChunks = !!fullPageDebugChunks\n\n      {\n        let headCacheItem = cache.head\n        if (!headCacheItem) {\n          headCacheItem = createSegmentCacheItem()\n          cache.head = headCacheItem\n        }\n        const stageEntry = getOrCreateStageEntry(\n          headCacheItem,\n          targetStage,\n          withDebugChunks\n        )\n        pendingTasks.push(renderIntoStageEntry(head, stageEntry))\n      }\n\n      for (const [segmentPath, segmentData] of segments) {\n        let segmentCacheItem = cache.segments.get(segmentPath)\n        if (!segmentCacheItem) {\n          segmentCacheItem = createSegmentCacheItem()\n          cache.segments.set(segmentPath, segmentCacheItem)\n        }\n        const stageEntry = getOrCreateStageEntry(\n          segmentCacheItem,\n          targetStage,\n          withDebugChunks\n        )\n        pendingTasks.push(renderIntoStageEntry(segmentData, stageEntry))\n      }\n    },\n    () => {\n      controller.advanceStage(RenderStage.Dynamic)\n    }\n  )\n  await Promise.all(pendingTasks)\n\n  return payload\n}\n\nfunction onFlightRenderError(error: unknown): string | undefined {\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 (process.env.NEXT_DEBUG_BUILD || process.env.__NEXT_VERBOSE_LOGGING) {\n    const workStore = workAsyncStorage.getStore()\n    printDebugThrownValueForProspectiveRender(\n      error,\n      workStore?.route ?? 'unknown route',\n      Phase.InstantValidation\n    )\n  }\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  let chunkIx = 0\n  let currentStage: SegmentStage | RenderStage.Before = RenderStage.Before\n  let closed = false\n\n  function emitNewChunks(chunks: Uint8Array[]) {\n    for (; chunkIx < chunks.length; chunkIx++) {\n      stream.push(allChunks[chunkIx])\n    }\n  }\n\n  function close() {\n    closed = true\n    stream.push(null)\n  }\n\n  const stream = new Readable({ read() {} })\n\n  function advanceStage(stage: SegmentStage): boolean {\n    if (closed) return true\n\n    // NOTE: we don't special handling for skipping stages,\n    // emitNewChunks will emit anything that hasn't been emitted before.\n    currentStage = stage\n    emitNewChunks(stageChunks[stage])\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  stageData: SegmentCacheItemStageEntry,\n  currentStage: SegmentStage,\n  targetStage: SegmentStage,\n  chunk: Uint8Array\n) {\n  if (currentStage <= targetStage) {\n    stageData.chunks.push(chunk)\n  }\n  stageData.allChunks.push(chunk)\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  ComponentMod: FlightComponentMod,\n  renderFlightStream: RenderToFlightStream,\n  payload: InitialRSCPayload,\n  extraChunksAbortController: AbortController,\n  renderSignal: AbortSignal,\n  clientReferenceManifest: ClientReferenceManifest,\n  startTime: number,\n  isDebugChannelEnabled: boolean,\n  createDebugChannel: () => DebugChannelPair | undefined\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 = renderFlightStream(\n        ComponentMod,\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) {\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) {\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. The\n  // valid shapes are a single root path with no segment prefix: 4 elements\n  // ([tree, seedData, head, isHeadPartial], per getRSCPayload) or 3 when\n  // reconstructed without the isHeadPartial flag (see the payload literals\n  // in this module).\n  const flightDataPaths = initialRSCPayload.f\n  if (\n    flightDataPaths.length !== 1 ||\n    (flightDataPaths[0].length !== 3 && flightDataPaths[0].length !== 4)\n  ) {\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  stage: PrefetchedSegmentStage\n): Promise<HeadData> {\n  const segmentCacheItem = cache.head\n  if (!segmentCacheItem) {\n    throw new InvariantError(`Missing segment data: <head>`)\n  }\n  const stageEntry = getStageEntry(segmentCacheItem, stage)\n  return await deserializeFromChunks<HeadData>(\n    stageEntry.chunks,\n    stageEntry.allChunks,\n    stageEntry.debugChunks,\n    releaseSignal,\n    clientReferenceManifest,\n    // NOTE: We're not passing an endTime, because the debug info has already been\n    // truncated to the appropriate `endTime` when the segment cache was filled.\n    { startTime: undefined, endTime: undefined }\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: VaryParamsIterable | 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(): SegmentCacheItem {\n  return {\n    [RenderStage.Static]: null,\n    [RenderStage.ShellRuntime]: null,\n    [RenderStage.Runtime]: null,\n    [RenderStage.Dynamic]: null,\n  }\n}\n\nfunction createSegmentCacheItemStageEntry(\n  withDebugChunks: boolean\n): SegmentCacheItemStageEntry {\n  return {\n    allChunks: [],\n    chunks: [],\n    debugChunks: withDebugChunks ? [] : null,\n  }\n}\n\nfunction getOrCreateStageEntry(\n  segmentCacheItem: SegmentCacheItem,\n  stage: SegmentStage,\n  withDebugChunks: boolean\n): SegmentCacheItemStageEntry {\n  let data = segmentCacheItem[stage]\n  if (!data) {\n    data = createSegmentCacheItemStageEntry(withDebugChunks)\n    segmentCacheItem[stage] = data\n  }\n  return data\n}\n\nfunction getStageEntry(\n  segmentCacheItem: SegmentCacheItem,\n  stage: SegmentStage\n): SegmentCacheItemStageEntry {\n  const data = segmentCacheItem[stage]\n  if (!data) {\n    // Indicates that we didn't fill the cache at this stage.\n    throw new InvariantError(\n      `Expected segment cache to have data for stage '${RenderStage[stage]}'`\n    )\n  }\n  return data\n}\n\nexport type SegmentCache = {\n  head: SegmentCacheItem | null\n  segments: Map<SegmentPath, SegmentCacheItem>\n}\n\ntype SegmentCacheItem = Record<SegmentStage, SegmentCacheItemStageEntry | null>\n\ntype SegmentCacheItemStageEntry = {\n  chunks: Uint8Array[]\n  allChunks: Uint8Array[]\n  debugChunks: Uint8Array[] | null\n}\n\ntype TreeResult = {\n  seedData: CacheNodeSeedData\n  requiresInstantUI: boolean\n  createInstantStack: (() => Error) | null\n  /** First module file path encountered (DFS) inside this subtree,\n   * or null if unavailable. The boundary's own segment may not own a\n   * layout/page module (e.g. a directory whose page lives in a\n   * __PAGE__ child), so we propagate the first one we find upward.\n   * Surfaced in the missing-boundary fallback message as a pointer\n   * to \"something inside the subtree that didn't render\". */\n  firstModFilePath: string | null\n  /** How deep in the tree the config was found. Higher = more specific.\n   * Used to prefer deeper configs over shallower ones when multiple\n   * slots have configs. */\n  configDepth: number\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  /** Per-slot config factories indexed by slot marker index. When a\n   * boundary spans multiple parallel slots, each slot gets a marker\n   * component in the tree. The marker's index maps to this array to\n   * find the right config for error attribution. */\n  slotStacks: Array<(() => Error) | null>\n}\n\nexport enum ValidationPrefetchKind {\n  /** App Shells, for `<Link>` without `prefetch={true}` */\n  Shell = 1,\n  // TODO(app-shells): validate speculative prefetches\n  // Speculative = 2,\n  /** Behavior when Partial Prefetching is not enabled. */\n  LegacySpeculative = 3,\n}\n\nexport async function createCombinedPayloadAtDepth(\n  prefetchKind: ValidationPrefetchKind,\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  useRuntimeStageForPartialSegments: boolean\n): Promise<ValidationPayloadResult | null> {\n  const workStore = workAsyncStorage.getStore()\n  if (!workStore) {\n    throw new InvariantError(\n      'createCombinedPayloadAtDepth must run inside a WorkStore'\n    )\n  }\n  const { validationLevel, route } = workStore\n\n  let hasStaticSegments = false\n  let hasRuntimeSegments = false\n\n  // Index 0 is reserved for the root config. Slot markers start at 1.\n  const slotStacks: Array<(() => Error) | null> = [null]\n\n  /**\n   * When a segment has multiple parallel routes (a fork), wrap each\n   * slot's seed data with a slot marker component. The marker's index\n   * in the component stack maps to `slotStacks` for per-slot error\n   * attribution. Slot markers start at index 1 (index 0 is root).\n   */\n  function wrapSlotsWithMarkers(\n    slots: CacheNodeSeedDataSlots,\n    results: Map<string, TreeResult>\n  ): void {\n    const keys = Object.keys(slots)\n    if (keys.length <= 1) return\n\n    for (const key of keys) {\n      const slotSeedData = slots[key]\n      if (slotSeedData === null) continue\n      const result = results.get(key)\n      const markerIndex = slotStacks.length\n      slotStacks.push(result?.createInstantStack ?? null)\n      const markerName = `${INSTANT_SLOT_MARKER_PREFIX}${markerIndex - 1}${INSTANT_SLOT_MARKER_SUFFIX}`\n      const [node, parallelRoutesData, unused, isPartial, varyParams] =\n        slotSeedData\n      slots[key] = [\n        // eslint-disable-next-line @next/internal/no-ambiguous-jsx -- bundled in the server layer\n        <SlotMarker name={markerName} key=\"sm\">\n          {node}\n        </SlotMarker>,\n        parallelRoutesData,\n        unused,\n        isPartial,\n        varyParams,\n      ]\n    }\n  }\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 stageEntry = getStageEntry(segmentCacheItem, RenderStage.Dynamic)\n    const dynamicChunks = stageEntry.chunks\n    const segmentData = await deserializeFromChunks<SegmentData>(\n      dynamicChunks,\n      dynamicChunks,\n      stageEntry.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      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      const slotResults = new Map<string, TreeResult>()\n      let requiresInstantUI = false\n      let createInstantStack: (() => Error) | null = null\n      let bestConfigDepth = -1\n      // Collect the first mod file path from each slot's subtree.\n      // Don't include the boundary segment's own layout/page — that\n      // file DID render (it wraps the boundary). What didn't render\n      // is the content inside the children slots.\n      const slotModFilePaths: string[] = []\n      let firstModFilePath: string | null = null\n\n      for (const parallelRouteKey in parallelRoutes) {\n        const result = await buildNewTreeSeedData(\n          parallelRoutes[parallelRouteKey],\n          path,\n          parallelRouteKey,\n          0 /* segmentDepth */\n        )\n        slotResults.set(parallelRouteKey, result)\n        slots[parallelRouteKey] = result.seedData\n        if (result.firstModFilePath !== null) {\n          slotModFilePaths.push(result.firstModFilePath)\n          if (firstModFilePath === null) {\n            firstModFilePath = result.firstModFilePath\n          }\n        }\n        if (result.requiresInstantUI) {\n          requiresInstantUI = true\n          if (\n            result.configDepth > bestConfigDepth ||\n            (result.configDepth === bestConfigDepth &&\n              parallelRouteKey === 'children')\n          ) {\n            bestConfigDepth = result.configDepth\n            createInstantStack = result.createInstantStack\n          }\n        }\n      }\n\n      // Only require this boundary to render if the subtree has an\n      // instant config. Unconfigured slot subtrees are allowed to not\n      // render (e.g. conditionally excluded by a layout).\n      if (requiresInstantUI) {\n        boundaryState.requiredIds.set(path, slotModFilePaths)\n      }\n\n      wrapSlotsWithMarkers(slots, slotResults)\n\n      return {\n        seedData: getCacheNodeSeedDataFromSegment(finalSegmentData, slots),\n        requiresInstantUI,\n        createInstantStack,\n        firstModFilePath,\n        configDepth: bestConfigDepth,\n      }\n    }\n\n    // Not at the boundary yet — keep walking as shared.\n    const slots: CacheNodeSeedDataSlots = {}\n    const slotResults = new Map<string, TreeResult>()\n    let requiresInstantUI = false\n    let createInstantStack: (() => Error) | null = null\n    let bestConfigDepth = -1\n    let firstModFilePath: string | 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      slotResults.set(parallelRouteKey, result)\n      slots[parallelRouteKey] = result.seedData\n      if (firstModFilePath === null) {\n        firstModFilePath = result.firstModFilePath\n      }\n      if (result.requiresInstantUI) {\n        requiresInstantUI = true\n        if (\n          result.configDepth > bestConfigDepth ||\n          (result.configDepth === bestConfigDepth &&\n            parallelRouteKey === 'children')\n        ) {\n          bestConfigDepth = result.configDepth\n          createInstantStack = result.createInstantStack\n        }\n      }\n    }\n\n    wrapSlotsWithMarkers(slots, slotResults)\n\n    return {\n      seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),\n      requiresInstantUI,\n      createInstantStack,\n      firstModFilePath,\n      configDepth: bestConfigDepth,\n    }\n  }\n\n  async function buildNewTreeSeedData(\n    lt: LoaderTree,\n    parentPath: SegmentPath | null,\n    key: string | null,\n    segmentDepth: number\n  ): Promise<TreeResult> {\n    const { parallelRoutes } = parseLoaderTree(lt)\n    const { mod: layoutOrPageMod, filePath: layoutOrPageFilePath } =\n      await getLayoutOrPageModule(lt)\n    const localModFilePath: string | null = layoutOrPageFilePath ?? null\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 = (layoutOrPageMod as AppSegmentConfig).instant ?? null\n\n      // When the default validation level is active and this is a page or\n      // default segment without an explicit config, treat it as if\n      // instant = true was exported. Framework-synthesized error\n      // routes are excluded — see isFrameworkErrorRoute.\n      if (\n        instantConfig === null &&\n        validationLevel !== 'manual-warning' &&\n        validationLevel !== 'experimental-manual-error' &&\n        isImplicitValidationSegment(segment) &&\n        !isFrameworkErrorRoute(route)\n      ) {\n        instantConfig = true\n      }\n\n      if (\n        instantConfig === true ||\n        (typeof instantConfig === 'object' && instantConfig !== null)\n      ) {\n        const rawFactory: unknown = (layoutOrPageMod as any)\n          .__debugCreateInstantConfigStack\n        localCreateInstantStack =\n          typeof rawFactory === 'function' ? (rawFactory as () => Error) : null\n      }\n    }\n\n    const segmentCacheItem = cache.segments.get(path)\n    if (!segmentCacheItem) {\n      throw new InvariantError(`Missing segment data: ${path}`)\n    }\n\n    let stage: PrefetchedSegmentStage\n\n    switch (prefetchKind) {\n      case ValidationPrefetchKind.Shell: {\n        if (useRuntimeStageForPartialSegments) {\n          stage = RenderStage.Runtime\n        } else {\n          stage = RenderStage.ShellRuntime\n        }\n        // We do not track `has{Static,Runtime}Segments` because they do not\n        // affect shell prefetches.\n        break\n      }\n      case ValidationPrefetchKind.LegacySpeculative: {\n        if (useRuntimeStageForPartialSegments) {\n          stage = RenderStage.Runtime\n        } else {\n          // In legacy speculative prefetches, we always use static.\n          stage = RenderStage.Static\n        }\n        break\n      }\n    }\n\n    switch (stage) {\n      case RenderStage.Static: {\n        hasStaticSegments = true\n        break\n      }\n      case RenderStage.ShellRuntime: {\n        break\n      }\n      case RenderStage.Runtime: {\n        hasRuntimeSegments = true\n        break\n      }\n    }\n\n    debug?.(`    ${path || '/'} - ${RenderStage[stage]}`)\n\n    const stageEntry = getStageEntry(segmentCacheItem, stage)\n    const segmentData = await deserializeFromChunks<SegmentData>(\n      stageEntry.chunks,\n      stageEntry.allChunks,\n      stageEntry.debugChunks,\n      releaseSignal,\n      clientReferenceManifest,\n      // NOTE: We're not passing an endTime, because the debug info has already been\n      // truncated to the appropriate `endTime` when the segment cache was filled.\n      { startTime: undefined, endTime: undefined }\n    )\n\n    // Build children first, then determine requiresInstantUI.\n    const slots: CacheNodeSeedDataSlots = {}\n    const slotResults = new Map<string, TreeResult>()\n    let childrenRequireInstantUI = false\n    let childCreateInstantStack: (() => Error) | null = null\n    let bestChildConfigDepth = -1\n    let childFirstModFilePath: string | null = null\n    for (const parallelRouteKey in parallelRoutes) {\n      const childSegmentDepth = segmentConsumesURLDepth(segment)\n        ? segmentDepth + 1\n        : segmentDepth\n      const result = await buildNewTreeSeedData(\n        parallelRoutes[parallelRouteKey],\n        path,\n        parallelRouteKey,\n        childSegmentDepth\n      )\n      slotResults.set(parallelRouteKey, result)\n      slots[parallelRouteKey] = result.seedData\n      if (childFirstModFilePath === null) {\n        childFirstModFilePath = result.firstModFilePath\n      }\n      if (result.requiresInstantUI) {\n        childrenRequireInstantUI = true\n        if (\n          result.configDepth > bestChildConfigDepth ||\n          (result.configDepth === bestChildConfigDepth &&\n            parallelRouteKey === 'children')\n        ) {\n          bestChildConfigDepth = result.configDepth\n          childCreateInstantStack = result.createInstantStack\n        }\n      }\n    }\n\n    wrapSlotsWithMarkers(slots, slotResults)\n\n    // Local config takes precedence over children.\n    let requiresInstantUI: boolean\n    let createInstantStack: (() => Error) | null\n    let configDepth: number\n    if (instantConfig === false) {\n      requiresInstantUI = false\n      createInstantStack = null\n      configDepth = -1\n    } else if (\n      instantConfig === true ||\n      (typeof instantConfig === 'object' && instantConfig !== null)\n    ) {\n      requiresInstantUI = true\n      createInstantStack = localCreateInstantStack\n      configDepth = segmentDepth\n    } else {\n      requiresInstantUI = childrenRequireInstantUI\n      createInstantStack = childCreateInstantStack\n      configDepth = bestChildConfigDepth\n    }\n\n    // First mod we find in DFS order: this segment's own layout/page if\n    // any, otherwise the first non-null we got from a child.\n    const firstModFilePath = localModFilePath ?? childFirstModFilePath\n\n    return {\n      seedData: getCacheNodeSeedDataFromSegment(segmentData, slots),\n      requiresInstantUI,\n      createInstantStack,\n      firstModFilePath,\n      configDepth,\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  // Set the root config at index 0. This is the fallback for errors\n  // that occur above any fork (no slot marker in the component stack).\n  slotStacks[0] = createInstantStack\n\n  const { flightRouterState } = getRootDataFromPayload(initialRSCPayload)\n\n  let headStage: PrefetchedSegmentStage\n  switch (prefetchKind) {\n    case ValidationPrefetchKind.Shell: {\n      if (useRuntimeStageForPartialSegments) {\n        headStage = RenderStage.Runtime\n      } else {\n        headStage = RenderStage.ShellRuntime\n      }\n      break\n    }\n    case ValidationPrefetchKind.LegacySpeculative: {\n      headStage = hasRuntimeSegments ? RenderStage.Runtime : RenderStage.Static\n      break\n    }\n  }\n  debug?.(`    /_head - ${RenderStage[headStage]}`)\n\n  let hasAmbiguousErrors: boolean\n  switch (prefetchKind) {\n    case ValidationPrefetchKind.Shell: {\n      // In a shell prefetch, holes are always ambiguous\n      // (they can be either link data or dynamic data)\n      // unless we're already overriding and using the runtime stage,\n      // which resolves link data.\n      hasAmbiguousErrors = !useRuntimeStageForPartialSegments\n      break\n    }\n    case ValidationPrefetchKind.LegacySpeculative: {\n      // In the old prefetching mechanism, holes in static segments are ambiguous\n      // (they can be either runtime data or dynamic data).\n      hasAmbiguousErrors = hasStaticSegments\n      break\n    }\n  }\n\n  const head = await createValidationHead(\n    cache,\n    releaseSignal,\n    clientReferenceManifest,\n    headStage\n  )\n\n  const payload: InitialRSCPayload = {\n    ...initialRSCPayload,\n    f: [[flightRouterState, seedData, head]],\n  }\n\n  return {\n    payload,\n    hasAmbiguousErrors,\n    slotStacks,\n  }\n}\n"],"names":["ValidationPrefetchKind","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","prefetchKind","ComponentMod","renderFlightStream","fullPageChunks","fullPageDebugChunks","startTime","stageEndTimes","clientReferenceManifest","createDebugChannel","cache","createSegmentCache","partialStages","RenderStage","ShellRuntime","Runtime","Static","doStage","targetStage","endTime","Dynamic","firstStage","collectSegmentDataForStage","payload","debugChannelAbortController","AbortController","debugStream","createNodeStreamFromChunks","signal","stream","controller","createStagedStreamFromChunks","on","setImmediate","abort","environmentName","currentStage","Before","serverConsumerManifest","moduleLoading","moduleMap","rscModuleMapping","serverModuleMap","getServerModuleMap","payloadPromise","createFromNodeStream","debugChannel","advanceStage","head","segments","Map","segmentPath","set","createSegmentData","pendingTasks","renderIntoStageEntry","data","stageEntry","segmentDebugChannel","debugChunks","itemStream","clientModules","serverSide","onError","onFlightRenderError","Promise","all","chunk","writeChunk","clientSide","readable","push","runInSequentialTasks","withDebugChunks","headCacheItem","createSegmentCacheItem","getOrCreateStageEntry","segmentData","segmentCacheItem","get","error","digest","getDigestForWellKnownError","NEXT_DEBUG_BUILD","__NEXT_VERBOSE_LOGGING","workStore","workAsyncStorage","getStore","printDebugThrownValueForProspectiveRender","Phase","InstantValidation","stageChunks","allChunks","chunkIx","closed","emitNewChunks","chunks","length","close","Readable","read","stage","stageData","extraChunksAbortController","renderSignal","isDebugChannelEnabled","isRenderable","renderableChunks","streamFinished","createNodeStreamWithLateRelease","flightDataPaths","f","createValidationHead","releaseSignal","getStageEntry","deserializeFromChunks","partialChunks","timings","segmentStream","node","_parallelRoutesData","_unused","isPartial","varyParams","getCacheNodeSeedDataFromSegment","slots","createSegmentCacheItemStageEntry","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","validationLevel","hasStaticSegments","hasRuntimeSegments","slotStacks","wrapSlotsWithMarkers","results","keys","Object","slotSeedData","result","markerIndex","createInstantStack","markerName","INSTANT_SLOT_MARKER_PREFIX","INSTANT_SLOT_MARKER_SUFFIX","unused","SlotMarker","name","getSegment","dynamicParam","treeSegment","addSearchParamsIfPageSegment","buildSharedTreeSeedData","urlDepthConsumed","groupDepthConsumed","dynamicChunks","consumesUrlDepth","isGroup","currentGroupDepth","pastUrlBoundary","isBoundary","finalSegmentData","PlaceValidationBoundaryBelowThisLevel","id","slotResults","requiresInstantUI","bestConfigDepth","slotModFilePaths","firstModFilePath","buildNewTreeSeedData","configDepth","requiredIds","lt","segmentDepth","mod","layoutOrPageMod","filePath","layoutOrPageFilePath","getLayoutOrPageModule","localModFilePath","instantConfig","localCreateInstantStack","instant","isImplicitValidationSegment","isFrameworkErrorRoute","rawFactory","__debugCreateInstantConfigStack","childrenRequireInstantUI","childCreateInstantStack","bestChildConfigDepth","childFirstModFilePath","childSegmentDepth","headStage","hasAmbiguousErrors"],"mappings":";;;;;;;;;;;;;;;;;;IAo/BYA,sBAAsB;eAAtBA;;IA3xBUC,wBAAwB;eAAxBA;;IAoyBAC,4BAA4B;eAA5BA;;IA3cAC,2BAA2B;eAA3BA;;IAuXNC,wBAAwB;eAAxBA;;;;gCAj6Be;iCACH;oCACO;sCACE;0CACJ;wCAI1B;oCACoC;0BAKpC;mCAIA;8BAKA;iCACyB;4BAMP;6BAIlB;wBAK8B;yBAO9B;+BAIA;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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