try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`d0e6cc69-78e2-4946-9259-0c66a5ff3fa1`,e._sentryDebugIdIdentifier=`sentry-dbid-d0e6cc69-78e2-4946-9259-0c66a5ff3fa1`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{Ag as t,Gt as n,Ht as r,Kt as i,Lm as a,Mm as o,Nm as s,Tm as c,Ut as l,Wt as u,Zm as d,jg as f,jm as p,ng as m,qt as h,yg as g}from"./entry.client-mpghtlrl.js";var _=e(f(),1),v=t(),y=new Map,b=new AbortController,x=()=>b.signal,S=()=>{b.abort()},C=()=>{b=new AbortController},w=e=>{S(),C(),y.set(e,{startTimestamp:performance.now()})},T=(e,t)=>{if(typeof window>`u`)return;let n=n=>{let r=n.state.navigation.state,i=n.state.location.pathname,a=null;return n.subscribe(n=>{let o=n.navigation.state,s=n.navigation.location?.pathname??n.location.pathname;r===`idle`&&o!==`idle`?(w(s),t?.(s),a={type:`navigation`,name:`navigation`,startTimestamp:performance.now(),duration:0,url:s,sourceUrl:i,destinationUrl:s}):r!==`idle`&&o===`idle`&&(a!==null&&(a.duration=Math.floor(performance.now()-a.startTimestamp),e(a)),a=null,i=n.location.pathname),r=o})},r=window.__reactRouterDataRouter;if(!r){h.error(`HydratedRouter not found on window. Navigation tracking will not be installed.`);return}return n(r)},E=(e,t)=>{let n=(0,v.c)(11),r=s(),i=p(),a;n[0]!==r.location||n[1]!==i.pathname?(a=()=>({pathname:r.location?.pathname||i.pathname,endTimestamp:performance.now()}),n[0]=r.location,n[1]=i.pathname,n[2]=a):a=n[2];let[o]=(0,_.useState)(a),c=(0,_.useRef)(!1),l,u;n[3]!==o||n[4]!==e?(l=()=>{if(c.current)return;c.current=!0;let{pathname:t,endTimestamp:n}=o;e({type:`navigation`,name:`navigation`,startTimestamp:0,duration:Math.floor(n),url:t,sourceUrl:t,destinationUrl:t})},u=[o,e],n[3]=o,n[4]=e,n[5]=l,n[6]=u):(l=n[5],u=n[6]),(0,_.useEffect)(l,u);let d,f;n[7]!==e||n[8]!==t?(d=()=>T(e,t),f=[e,t],n[7]=e,n[8]=t,n[9]=d,n[10]=f):(d=n[9],f=n[10]),(0,_.useEffect)(d,f)},D=6e4,O=(e,t)=>new Promise(n=>{let r=setTimeout(()=>n(`timeout`),e),i=()=>{clearTimeout(r),n(`aborted`)};if(t.aborted){i();return}t.addEventListener(`abort`,i,{once:!0})});function k(e){let t=p(),i=o(),a=n(),s=i[i.length-1]?.id,c=(0,_.useRef)(void 0);(0,_.useEffect)(()=>{let n=x();if(n.aborted)return;let i=t.pathname,o=y.get(i)?.startTimestamp??0,d=new AbortController,f=!1,p=()=>d.abort();n.addEventListener(`abort`,p,{once:!0});let m=(t,n)=>{if(f)return;let r=`${i}|${o}|${s??``}`;if(c.current===r)return;c.current=r;let a=performance.now()-o;h.debug(`usePageRenderTracker`,`Page render for ${i} took ${a} ms. timedOut: ${t}, lastCompletedStep: ${n}`),e({type:`page-rendered`,name:t?`Page rendered (timeout)`:`Page rendered`,startTimestamp:o,duration:Math.floor(a),url:i,routeId:s,timedOut:t,lastCompletedStep:n})};return(async()=>{if(d.signal.aborted||f)return;let e,t=!1,n=await Promise.race([(async()=>{try{return await u(d.signal),e=`stylesheets`,await l(d.signal),e=`fonts`,await a(d.signal),e=`loaders`,await r(d.signal),e=`images`,d.signal.aborted||f?`aborted`:(h.debug(`usePageRenderTracker`,`All tracked assets are ready for ${i}`),`assets`)}catch(e){if(d.signal.aborted)return`aborted`;throw e}})(),O(D,d.signal)]);n!==`aborted`&&(n===`timeout`&&(t=!0,d.abort()),m(t,e))})(),()=>{f=!0,d.abort(),n.removeEventListener(`abort`,p)}},[t.pathname,t.search,e,s,a])}var A=m(),j=e=>{let{reporter:t,onNavigationStart:n}=e;return E(t,n),k(t),null},M=e=>{let t=(0,v.c)(6),{children:n,reporter:r,onNavigationStart:a}=e,o;t[0]!==r||t[1]!==a?(o=(0,A.jsx)(j,{reporter:r,onNavigationStart:a}),t[0]=r,t[1]=a,t[2]=o):o=t[2];let s;return t[3]!==o||t[4]!==n?(s=(0,A.jsxs)(i,{children:[o,n]}),t[3]=o,t[4]=n,t[5]=s):s=t[5],s},N=new Map,P=0;function F(e){P+=1;let t=(N.get(e)??0)+1;return N.set(e,t),{renderType:P===1?`entry`:t===1?`cold`:`warm`,renderCount:t,totalRenderCount:P}}var I=new g(`PerformanceMeasurementLayout`),L=a(function(){let{performanceMetrics:e}=d(),t=(0,_.useCallback)(()=>{e.notifyNavigationStarted()},[e]);return(0,A.jsx)(A.Fragment,{children:(0,A.jsx)(M,{reporter:(0,_.useCallback)(t=>{t.type===`page-rendered`&&e.notifyPageRendered();try{let{name:n,startTimestamp:r,duration:i,url:a,...o}=t,s=n,c=o;if(t.type===`page-rendered`&&t.routeId){let{renderType:e,renderCount:n,totalRenderCount:r}=F(t.routeId),i=`page.load.${e}`;s=t.timedOut?`${i}.timeout`:i,c={...o,renderType:e,renderCount:n,totalRenderCount:r,isInitialRender:n===1}}e.reportManualMeasurement(s,r,i,a,c)}catch(e){I.error(`Error reporting performance event:`,e)}},[e]),onNavigationStart:t,children:(0,A.jsx)(c,{})})})});export{L as default};