import{nt as e,ot as t,q as n,st as r}from"./app-elements-CWGamLYk.js";import{t as i}from"./implicit-tags-DLsLJVsO.js";import{a,i as o,n as s,r as c,t as l}from"./text-stream-Ddra2dVe.js";import{i as u,t as d,u as f,v as p}from"./app-page-stream-ClqdkjJm.js";async function m(m){let h=p(m.renderToReadableStream(m.element,{onError:m.onError}),m.captureRscData),g={value:null},_=m.getFontPreloads(),v=await(await m.loadSsrHandler()).handleSsr(h.ssrStream,m.getNavigationContext(),{links:m.getFontLinks(),styles:m.getFontStyles(),preloads:_},{basePath:m.basePath,clientTraceMetadata:m.clientTraceMetadata,reactMaxHeadersLength:m.reactMaxHeadersLength,rootParams:m.rootParams,waitForAllReady:m.waitForAllReady,...h.sideStream?{sideStream:h.sideStream,capturedRscDataRef:g}:{}}),y=u(v)?v.htmlStream:v,b=d(u(v)?v.linkHeader:void 0,f(_),m.reactMaxHeadersLength),x=await l(y),S;if(m.captureRscData){let e=g.value;if(!e)throw Error(`[vinext] Expected captured RSC data while rendering app page cache artifacts`);S=await e}let C=e(),w=i(m.cleanPathname,n(),m.route.routeSegments),T=s();r(),t();let E={html:x,htmlRenderObservation:o({boundaryOutcome:{kind:`success`},cacheability:`public`,cacheTags:w,cleanPathname:m.cleanPathname,completeness:`complete`,output:c({element:m.element,renderEpoch:null,rootBoundaryId:null,routePattern:m.route.pattern}),params:m.navigationParams,state:T}),...b?{linkHeader:b}:{},tags:w,cacheControl:typeof C?.revalidate==`number`?{revalidate:C.revalidate,expire:C.expire}:void 0};return m.captureRscData&&(E.rscData=S,E.rscRenderObservation=o({boundaryOutcome:{kind:`success`},cacheability:`public`,cacheTags:w,cleanPathname:m.cleanPathname,completeness:`complete`,output:a({element:m.element,mountedSlotsHeader:m.mountedSlotsHeader,renderEpoch:null,rootBoundaryId:null,routePattern:m.route.pattern}),params:m.navigationParams,state:T})),E}export{m as renderAppPageCacheArtifacts};