const g=16.666666666666668;function h(t){const n=t.find(e=>e.name==="first-contentful-paint");return n?l(n.startTime):null}function E(t){if(t.length===0)return null;const n=t[t.length-1];return l(n.renderTime??n.loadTime??n.startTime)}function v(t){const n=t.filter(s=>!s.hadRecentInput);if(n.length===0)return null;n.sort((s,c)=>s.startTime-c.startTime);let e=0,o=0,u=0,m=0;for(const s of n)o&&(s.startTime-m>1e3||s.startTime-u>5e3)&&(o=0,u=s.startTime),o===0&&(u=s.startTime),o+=s.value,m=s.startTime,o>e&&(e=o);return l(e,4)}function C(t){return t.length===0?null:l(Math.max(...t.map(n=>n.duration)))}function M(t){return t?l(t.responseStart-t.startTime):null}function L(t){return{fcp:h(t.paints??[]),lcp:E(t.lcp??[]),cls:v(t.shifts??[]),inp:C(t.events??[]),ttfb:M(t.navigation??null)}}function y(t){if(!t)return{pageLoadTime:null,domReadyTime:null,resourceLoadTime:null};const n=t.loadEventEnd>0?l(t.loadEventEnd-t.startTime):null,e=t.domContentLoadedEventEnd>0?l(t.domContentLoadedEventEnd-t.startTime):null,o=t.loadEventEnd>0&&t.domContentLoadedEventEnd>0?l(t.loadEventEnd-t.domContentLoadedEventEnd):null;return{pageLoadTime:n,domReadyTime:e,resourceLoadTime:o}}function w(t){const{longTasks:n,windowMs:e}=t,o=n.reduce((c,i)=>c+i.duration,0),u=n.reduce((c,i)=>Math.max(c,i.duration),0),m=n.reduce((c,i)=>c+Math.max(0,Math.floor(i.duration/g)-1),0),s=e>0?l(Math.min(1,o/e),4):null;return{memory:t.memory??null,cpuEstimate:s,longTasks:{count:n.length,totalDuration:l(o),maxDuration:l(u)},frameDrops:m}}function l(t,n=2){const e=10**n;return Math.round(t*e)/e}function p(t,n,e){try{const o=new t(u=>e(u.getEntries()));return o.observe({type:n,buffered:!0}),o}catch{return null}}function b(t){const n=[],e=[],o=[],u=[],m=[],s=[],c=t.now(),i={paints:16,lcp:32,shifts:1e3,events:1e3,longTasks:2e3},f=(r,a,T)=>{r.push(...a),r.length>T&&r.splice(0,r.length-T)},d=t.PerformanceObserverCtor;if(d){const r=a=>a&&s.push(a);r(p(d,"paint",a=>f(n,a,i.paints))),r(p(d,"largest-contentful-paint",a=>f(e,a,i.lcp))),r(p(d,"layout-shift",a=>f(o,a,i.shifts))),r(p(d,"event",a=>f(u,a,i.events))),r(p(d,"longtask",a=>f(m,a,i.longTasks)))}return{startedAt:c,snapshot(){const r=t.getNavigation();return{timestamp:t.now(),pageUrl:t.pageUrl(),vitals:L({paints:n,lcp:e,shifts:o,events:u,navigation:r}),navigation:y(r),runtime:w({longTasks:m,windowMs:t.now()-c,memory:t.getMemory()})}},uninstall(){s.forEach(r=>{try{r.disconnect()}catch{}})}}}export{b as i};
//# sourceMappingURL=chunk-bF5G6gLQ.js.map
