function h(n){if(n.length===0)return null;const t=n[n.length-1];return{vitals:t.vitals,navigation:t.navigation,longTasks:t.runtime?.longTasks??null,memoryBytes:t.runtime?.memory?.usedJSHeapSize??null,...t.pageUrl===void 0?{}:{pageUrl:t.pageUrl},capturedAt:t.timestamp,samples:n.length}}const g={lcp:.2,fcp:.2,ttfb:.25,inp:.25,cls:.3,pageLoadTime:.2,longTaskTime:.3},b=[{key:"lcp",label:"Largest Contentful Paint",unit:"ms"},{key:"fcp",label:"First Contentful Paint",unit:"ms"},{key:"ttfb",label:"Time to First Byte",unit:"ms"},{key:"inp",label:"Interaction to Next Paint",unit:"ms"},{key:"cls",label:"Cumulative Layout Shift",unit:"score"},{key:"pageLoadTime",label:"Page load",unit:"ms"},{key:"longTaskTime",label:"Long-task time",unit:"ms"}];function d(n,t){return t==="pageLoadTime"?n.navigation?.pageLoadTime??null:t==="longTaskTime"?n.longTasks?.totalDuration??null:n.vitals?.[t]??null}function p(n,t,u){if(!n||!t)return{metrics:[],verdict:"insufficient-data",basis:!n&&!t?"Neither execution recorded performance data — telemetry capture was off, or the page could not be instrumented.":"Only one of the two executions recorded performance data, so there is nothing to compare it against."};if(u.samePage===!1)return{metrics:[],verdict:"insufficient-data",basis:"The two executions measured different pages. Load timings are not comparable across pages."};const r=b.map(e=>{const i=d(n,e.key),a=d(t,e.key);if(i===null||a===null)return{...e,before:i,after:a,deltaPercent:null,verdict:"not-measured",reason:i===null&&a===null?"Neither execution measured this.":i===null?"The earlier execution did not measure this, so there is no baseline.":"This execution did not measure it — INP needs an interaction, and LCP needs a large element to paint."};if(i===0)return{...e,before:i,after:a,deltaPercent:null,verdict:a===0?"unchanged":"worse"};const l=(a-i)/i,m=g[e.key]??.2,f=Math.abs(l)<m?"unchanged":l>0?"worse":"better";return{...e,before:i,after:a,deltaPercent:Math.round(l*100),verdict:f}}),o=r.filter(e=>e.verdict==="worse"),c=r.filter(e=>e.verdict==="better"),s=r.filter(e=>e.verdict!=="not-measured");return s.length===0?{metrics:r,verdict:"insufficient-data",basis:"No metric was measured on both executions, so nothing can be compared."}:o.length>0&&!u.sameEnvironment?{metrics:r,verdict:"environment-differs",basis:`${String(o.length)} metric${o.length===1?" is":"s are"} worse, but these two executions ran in different environments. Compare the environments before treating this as an application regression.`}:o.length>0?{metrics:r,verdict:"regression",basis:`${o.map(e=>`${e.label} ${String(e.deltaPercent)}% worse`).join(", ")}, in an identical environment.`}:c.length>0?{metrics:r,verdict:"improvement",basis:`${c.map(e=>`${e.label} ${String(Math.abs(e.deltaPercent??0))}% better`).join(", ")}.`}:{metrics:r,verdict:"no-change",basis:`${String(s.length)} metric${s.length===1?"":"s"} compared; every one is within its run-to-run noise floor.`}}export{p as comparePerformance,h as summarizePerformance};
//# sourceMappingURL=chunk-BgfJmpf-.js.map
