Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

web-vitals

Package Overview
Dependencies
Maintainers
3
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web-vitals - npm Package Compare versions

Comparing version 4.2.2-soft-navs to 4.2.2-soft-navs-2

3

dist/modules/attribution/onFCP.js

@@ -18,6 +18,7 @@ /*

import { getLoadState } from '../lib/getLoadState.js';
import { getNavigationEntry, hardNavId } from '../lib/getNavigationEntry.js';
import { getNavigationEntry } from '../lib/getNavigationEntry.js';
import { getSoftNavigationEntry } from '../lib/softNavs.js';
import { onFCP as unattributedOnFCP } from '../onFCP.js';
const attributeFCP = (metric) => {
const hardNavId = getNavigationEntry()?.navigationId || '1';
// Use a default object if no other attribution has been set.

@@ -24,0 +25,0 @@ let attribution = {

@@ -16,3 +16,3 @@ /*

*/
import { getNavigationEntry, hardNavId } from '../lib/getNavigationEntry.js';
import { getNavigationEntry } from '../lib/getNavigationEntry.js';
import { getSoftNavigationEntry } from '../lib/softNavs.js';

@@ -22,2 +22,3 @@ import { getSelector } from '../lib/getSelector.js';

const attributeLCP = (metric) => {
const hardNavId = getNavigationEntry()?.navigationId || '1';
// Use a default object if no other attribution has been set.

@@ -24,0 +25,0 @@ let attribution = {

export declare const getNavigationEntry: () => PerformanceNavigationTiming | void;
export declare const hardNavId: string;

@@ -33,2 +33,1 @@ /*

};
export const hardNavId = getNavigationEntry()?.navigationId || '1';

@@ -19,4 +19,5 @@ /*

import { getActivationStart } from './getActivationStart.js';
import { getNavigationEntry, hardNavId } from './getNavigationEntry.js';
import { getNavigationEntry } from './getNavigationEntry.js';
export const initMetric = (name, value, navigation, navigationId) => {
const hardNavId = getNavigationEntry()?.navigationId || '1';
const hardNavEntry = getNavigationEntry();

@@ -23,0 +24,0 @@ let navigationType = 'navigate';

@@ -16,3 +16,3 @@ /*

*/
import { hardNavId } from '../getNavigationEntry.js';
import { getNavigationEntry } from '../getNavigationEntry.js';
import { observe } from '../observe.js';

@@ -22,5 +22,7 @@ let interactionCountEstimate = 0;

let maxKnownInteractionId = 0;
let currentNavId = hardNavId;
let currentNavId = '';
let softNavsEnabled = false;
const updateEstimate = (entries) => {
if (!currentNavId)
currentNavId = getNavigationEntry()?.navigationId || '1';
entries.forEach((e) => {

@@ -27,0 +29,0 @@ if (e.interactionId) {

@@ -21,3 +21,3 @@ /*

import { getVisibilityWatcher } from './lib/getVisibilityWatcher.js';
import { hardNavId } from './lib/getNavigationEntry.js';
import { getNavigationEntry } from './lib/getNavigationEntry.js';
import { initMetric } from './lib/initMetric.js';

@@ -40,2 +40,3 @@ import { observe } from './lib/observe.js';

let metricNavStartTime = 0;
const hardNavId = getNavigationEntry()?.navigationId || '1';
whenActivated(() => {

@@ -42,0 +43,0 @@ let visibilityWatcher = getVisibilityWatcher();

@@ -19,3 +19,3 @@ /*

import { getVisibilityWatcher } from './lib/getVisibilityWatcher.js';
import { hardNavId } from './lib/getNavigationEntry.js';
import { getNavigationEntry } from './lib/getNavigationEntry.js';
import { initMetric } from './lib/initMetric.js';

@@ -42,2 +42,3 @@ import { observe } from './lib/observe.js';

const softNavsEnabled = softNavs(opts);
const hardNavId = getNavigationEntry()?.navigationId || '1';
whenActivated(() => {

@@ -44,0 +45,0 @@ let visibilityWatcher = getVisibilityWatcher();

@@ -21,3 +21,3 @@ /*

import { getVisibilityWatcher } from './lib/getVisibilityWatcher.js';
import { hardNavId } from './lib/getNavigationEntry.js';
import { getNavigationEntry } from './lib/getNavigationEntry.js';
import { initMetric } from './lib/initMetric.js';

@@ -48,2 +48,4 @@ import { observe } from './lib/observe.js';

let metricNavStartTime = 0;
const hardNavId = getNavigationEntry()?.navigationId || '1';
let finalizeNavId = '';
whenActivated(() => {

@@ -63,11 +65,3 @@ let visibilityWatcher = getVisibilityWatcher();

}
// Stop listening after input. Note: while scrolling is an input that
// stops LCP observation, it's unreliable since it can be programmatically
// generated. See: https://github.com/GoogleChrome/web-vitals/issues/75
['keydown', 'click'].forEach((type) => {
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
addEventListener(type, () => whenIdle(finalizeAllLCPs), { once: true });
});
addInputListeners();
};

@@ -117,3 +111,4 @@ const handleEntries = (entries) => {

};
const finalizeAllLCPs = () => {
const finalizeLCPs = () => {
removeInputListeners();
if (!reportedMetric) {

@@ -123,10 +118,48 @@ handleEntries(po.takeRecords());

po.disconnect();
reportedMetric = true;
report(true);
// As the clicks are handled when idle, check if the current metric was
// for the reported NavId and only if so, then report.
if (metric.navigationId === finalizeNavId) {
reportedMetric = true;
report(true);
}
}
};
const addInputListeners = () => {
['keydown', 'click'].forEach((type) => {
// Stop listening after input. Note: while scrolling is an input that
// stops LCP observation, it's unreliable since it can be programmatically
// generated. See: https://github.com/GoogleChrome/web-vitals/issues/75
addEventListener(type, () => handleInput(), true);
});
};
const removeInputListeners = () => {
['keydown', 'click'].forEach((type) => {
// Remove event listeners as no longer required
removeEventListener(type, () => handleInput(), true);
});
};
const handleInput = () => {
// Since we only finalize whenIdle, we only want to finalize the LCPs
// for the current navigationId at the time of the input and not any
// others that came after, and before it was idle. So note the current
// metric.navigationId.
finalizeNavId = metric.navigationId;
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
whenIdle(finalizeLCPs);
};
const handleHidden = () => {
// Finalise the current navigationId metric.
finalizeNavId = metric.navigationId;
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
finalizeLCPs();
};
const po = observe('largest-contentful-paint', handleEntries, opts);
if (po) {
report = bindReporter(onReport, metric, LCPThresholds, opts.reportAllChanges);
onHidden(finalizeAllLCPs);
addInputListeners();
onHidden(handleHidden);
// Only report after a bfcache restore if the `PerformanceObserver`

@@ -133,0 +166,0 @@ // successfully registered.

@@ -26,3 +26,2 @@ /*

export const TTFBThresholds = [800, 1800];
const hardNavEntry = getNavigationEntry();
/**

@@ -66,2 +65,3 @@ * Runs in the next task after the page is done loading and/or prerendering.

whenReady(() => {
const hardNavEntry = getNavigationEntry();
if (hardNavEntry) {

@@ -68,0 +68,0 @@ const responseStart = hardNavEntry.responseStart;

@@ -1,1 +0,1 @@

var webVitals=function(t){"use strict";var n,e,i,a,r=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},o=(null===(n=r())||void 0===n?void 0:n.navigationId)||"1",s=function(t){if("loading"===document.readyState)return"loading";var n=r();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},c=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},u=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:c(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},f=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},d=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},v=-1,l=function(){return v},g=function(t){addEventListener("pageshow",(function(n){n.persisted&&(v=n.timeStamp,t(n))}),!0)},m=function(){var t=r();return t&&t.activationStart||0},p=function(t,n,e,i){var a=r(),s="navigate";e?s=e:l()>=0?s="back-forward-cache":a&&(document.prerendering||m()>0?s="prerender":document.wasDiscarded?s="restore":a.type&&(s=a.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:s,navigationId:i||o}},h=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},T=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},I=function(t,n,e){var i=h(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},y=function(t){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t()}))},E=function(t){var n=!1;return function(){n||(t(),n=!0)}},S=-1,b=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},C=function(t){"hidden"===document.visibilityState&&S>-1&&(S="visibilitychange"===t.type?t.timeStamp:0,w())},L=function(){addEventListener("visibilitychange",C,!0),addEventListener("prerenderingchange",C,!0)},w=function(){removeEventListener("visibilitychange",C,!0),removeEventListener("prerenderingchange",C,!0)},M=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(S=-1),S<0&&(S=b(),L(),g((function(){setTimeout((function(){S=b(),L()}),0)}))),{get firstHiddenTime(){return S}}},D=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},k=[1800,3e3],F=function(t,n){var e=h(n=n||{}),i=0;D((function(){var a,r=M(),s=p("FCP"),c=I("paint",(function(u){u.forEach((function(u){if("first-contentful-paint"===u.name){e?u.navigationId&&u.navigationId!==s.navigationId&&function(e,o){if(s=p("FCP",0,e,o),a=f(t,s,k,n.reportAllChanges),"soft-navigation"===e){r=M(!0);var c=o?T(o):null;i=c&&c.startTime||0}}("soft-navigation",u.navigationId):c.disconnect();var d=0;if(u.navigationId&&u.navigationId!==o){var v=T(u.navigationId),l=v&&v.startTime?v.startTime:0;d=Math.max(u.startTime-l,0)}else d=Math.max(u.startTime-m(),0);var g=e&&u.navigationId?T(u.navigationId):null,h=g&&g.startTime?g.startTime:0;(u.startTime<r.firstHiddenTime||e&&u.navigationId&&u.navigationId!==s.navigationId&&u.navigationId!==o&&h>i)&&(s.value=d,s.entries.push(u),s.navigationId=u.navigationId||"1",a(!0))}}))}),n);c&&(a=f(t,s,k,n.reportAllChanges),g((function(e){s=p("FCP",0,"back-forward-cache",s.navigationId),a=f(t,s,k,n.reportAllChanges),d((function(){s.value=performance.now()-e.timeStamp,a(!0)}))})))}))},A=[.1,.25],P=0,x=1/0,B=0,O=o,N=!1,R=function(t){t.forEach((function(t){t.interactionId&&(N&&t.navigationId&&t.navigationId!==O&&(O=t.navigationId,P=0,x=1/0,B=0),x=Math.min(x,t.interactionId),B=Math.max(B,t.interactionId),P=B?(B-x)/7+1:0)}))},j=function(){return e?P:performance.interactionCount||0},q=function(t){"interactionCount"in performance||e||(e=I("event",R,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:N=t||!1}))},H=[],V=new Map,W=0,z=function(){W=j(),H.length=0,V.clear()},U=function(){var t=Math.min(H.length-1,Math.floor((j()-W)/50));return H[t]},_=[],G=function(t){if(_.forEach((function(n){return n(t)})),t.interactionId||"first-input"===t.entryType){var n=H[H.length-1],e=V.get(t.interactionId);if(e||H.length<10||t.duration>n.latency){if(e)t.duration>e.latency?(e.entries=[t],e.latency=t.duration):t.duration===e.latency&&t.startTime===e.entries[0].startTime&&e.entries.push(t);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};V.set(i.id,i),H.push(i)}H.sort((function(t,n){return n.latency-t.latency})),H.length>10&&H.splice(10).forEach((function(t){return V.delete(t.id)}))}}},J=function(t){var n=self.requestIdleCallback||self.setTimeout,e=-1;return t=E(t),"hidden"===document.visibilityState?t():(e=n(t),y(t)),e},K=[200,500],Q=function(t,n){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var e=h(n=n||{}),i=!1,a=0;D((function(){var r;q(e);var o,s=p("INP"),c=function(e,r){if(z(),s=p("INP",0,e,r),o=f(t,s,K,n.reportAllChanges),i=!1,"soft-navigation"===e){var c=T(r);a=c&&c.startTime?c.startTime:0}},u=function(t){J((function(){var e;t.forEach(G),(e=U())&&(e.latency!==s.value||n&&n.reportAllChanges)&&(s.value=e.latency,s.entries=e.entries),o()}))},v=I("event",u,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=f(t,s,K,n.reportAllChanges),v){v.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),y((function(){u(v.takeRecords()),o(!0)})),g((function(){z(),c("back-forward-cache",s.navigationId),d((function(){return o()}))}));e&&I("soft-navigation",(function(e){e.forEach((function(e){var r=T(e.navigationId),u=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==s.navigationId&&u>a&&(!i&&s.value>0&&o(!0),c("soft-navigation",e.navigationId),o=f(t,s,K,n.reportAllChanges))}))}),n)}}))}},X=[],Y=[],Z=new WeakMap,$=new Map,tt=-1,nt=function(t){X=X.concat(t),et()},et=function(){tt<0&&(tt=J(it))},it=function(){$.size>10&&$.forEach((function(t,n){V.has(n)||$.delete(n)}));var t=H.map((function(t){return Z.get(t.entries[0])})),n=Y.length-50;Y=Y.filter((function(e,i){return i>=n||t.includes(e)}));for(var e=new Set,i=0;i<Y.length;i++){var r=Y[i];ct(r.startTime,r.processingEnd).forEach((function(t){e.add(t)}))}for(var o=0;o<50;o++){var s=X[X.length-1-o];if(!s||s.startTime<a)break;e.add(s)}X=Array.from(e),tt=-1};_.push((function(t){t.interactionId&&t.target&&!$.has(t.interactionId)&&$.set(t.interactionId,t.target)}),(function(t){var n,e=t.startTime+t.duration;a=Math.max(a,t.processingEnd);for(var i=Y.length-1;i>=0;i--){var r=Y[i];if(Math.abs(e-r.renderTime)<=8){(n=r).startTime=Math.min(t.startTime,n.startTime),n.processingStart=Math.min(t.processingStart,n.processingStart),n.processingEnd=Math.max(t.processingEnd,n.processingEnd),n.entries.push(t);break}}n||(n={startTime:t.startTime,processingStart:t.processingStart,processingEnd:t.processingEnd,renderTime:e,entries:[t]},Y.push(n)),(t.interactionId||"first-input"===t.entryType)&&Z.set(t,n),et()}));var at,rt,ot,st,ct=function(t,n){for(var e,i=[],a=0;e=X[a];a++)if(!(e.startTime+e.duration<t)){if(e.startTime>n)break;i.push(e)}return i},ut=[2500,4e3],ft=[800,1800],dt=r(),vt=function t(n){document.prerendering?D((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},lt=function(t,n){var e=h(n=n||{}),i=p("TTFB"),a=f(t,i,ft,n.reportAllChanges);vt((function(){if(dt){var r=dt.responseStart;i.value=Math.max(r-m(),0),i.entries=[dt],a(!0),g((function(){i=p("TTFB",0,"back-forward-cache",i.navigationId),(a=f(t,i,ft,n.reportAllChanges))(!0)}));e&&I("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=p("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(a=f(t,i,ft,n.reportAllChanges))(!0))}))}),n)}}))},gt={passive:!0,capture:!0},mt=new Date,pt=function(t,n){at||(at=n,rt=t,ot=new Date,It(removeEventListener),ht())},ht=function(){if(rt>=0&&rt<ot-mt){var t={entryType:"first-input",name:at.type,target:at.target,cancelable:at.cancelable,startTime:at.timeStamp,processingStart:at.timeStamp+rt};st.forEach((function(n){n([t])})),st=[]}},Tt=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){pt(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,gt),removeEventListener("pointercancel",i,gt)};addEventListener("pointerup",e,gt),addEventListener("pointercancel",i,gt)}(n,t):pt(n,t)}},It=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,Tt,gt)}))},yt=[100,300],Et=function(t,n){var e=h(n=n||{});D((function(){var i,a=M(),r=p("FID"),s=function(s){s.forEach((function(s){var u,d;e?s.navigationId&&s.navigationId!==r.navigationId&&(u="soft-navigation",d=s.navigationId,"soft-navigation"===u&&(a=M(!0)),r=p("FID",0,u,d),i=f(t,r,yt,n.reportAllChanges)):c.disconnect(),s.startTime<a.firstHiddenTime&&(r.value=s.processingStart-s.startTime,r.entries.push(s),r.navigationId=s.navigationId||o,i(!0))}))},c=I("first-input",s,n);i=f(t,r,yt,n.reportAllChanges),c&&(y((function(){s(c.takeRecords()),e||c.disconnect()})),g((function(){var e;r=p("FID",0,"back-forward-cache",r.navigationId),i=f(t,r,yt,n.reportAllChanges),st=[],rt=-1,at=null,It(addEventListener),e=s,st.push(e),ht()})))}))};return t.CLSThresholds=A,t.FCPThresholds=k,t.FIDThresholds=yt,t.INPThresholds=K,t.LCPThresholds=ut,t.TTFBThresholds=ft,t.onCLS=function(t,n){!function(t,n){var e=h(n=n||{}),i=!1,a=0;F(E((function(){var r,o=p("CLS",0),s=0,c=[],u=function(e,c){if(o=p("CLS",0,e,c),r=f(t,o,A,n.reportAllChanges),s=0,i=!1,"soft-navigation"===e){var u=T(c);a=u&&u.startTime||0}},v=function(t){t.forEach((function(t){if(e&&t.navigationId&&t.navigationId!==o.navigationId&&(s>o.value&&(o.value=s,o.entries=c),r(!0),u("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=c[0],i=c[c.length-1];s&&t.startTime-i.startTime<1e3&&t.startTime-n.startTime<5e3?(s+=t.value,c.push(t)):(s=t.value,c=[t])}})),s>o.value&&(o.value=s,o.entries=c,r())},l=I("layout-shift",v,n);l&&(r=f(t,o,A,n.reportAllChanges),y((function(){v(l.takeRecords()),r(!0),i=!0})),g((function(){u("back-forward-cache",o.navigationId),d((function(){return r()}))})),e&&I("soft-navigation",(function(e){e.forEach((function(e){var s=e.navigationId,c=s?T(s):null;s&&s!==o.navigationId&&c&&(c.startTime||0)>a&&(i||r(!0),u("soft-navigation",e.navigationId),r=f(t,o,A,n.reportAllChanges))}))}),n),setTimeout(r,0))})))}((function(n){var e=function(t){var n,e={};if(t.entries.length){var i=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(i&&i.sources&&i.sources.length){var a=(n=i.sources).find((function(t){return t.node&&1===t.node.nodeType}))||n[0];a&&(e={largestShiftTarget:u(a.node),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:a,largestShiftEntry:i,loadState:s(i.startTime)})}}return Object.assign(t,{attribution:e})}(n);t(e)}),n)},t.onFCP=function(t,n){F((function(n){var e=function(t){var n={timeToFirstByte:0,firstByteToFCP:t.value,loadState:s(l())};if(t.entries.length){var e,i=t.entries[t.entries.length-1],a=0;if(t.navigationId&&t.navigationId!==o)a=(e=T(t.navigationId))?e.startTime:0;else if(e=r()){var c=e.responseStart,u=e.activationStart||0;a=Math.max(0,c-u)}e&&(n={timeToFirstByte:a,firstByteToFCP:t.value-a,loadState:s(t.entries[0].startTime),navigationEntry:e,fcpEntry:i})}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},t.onFID=function(t,n){Et((function(n){var e=function(t){var n=t.entries[0],e={eventTarget:u(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:s(n.startTime)};return Object.assign(t,{attribution:e})}(n);t(e)}),n)},t.onINP=function(t,n){i||(i=I("long-animation-frame",nt)),Q((function(n){var e=function(t){var n=t.entries[0],e=Z.get(n),i=n.processingStart,a=e.processingEnd,r=e.entries.sort((function(t,n){return t.processingStart-n.processingStart})),o=ct(n.startTime,a),c=t.entries.find((function(t){return t.target})),f=c&&c.target||$.get(n.interactionId),d=[n.startTime+n.duration,a].concat(o.map((function(t){return t.startTime+t.duration}))),v=Math.max.apply(Math,d),l={interactionTarget:u(f),interactionTargetElement:f,interactionType:n.name.startsWith("key")?"keyboard":"pointer",interactionTime:n.startTime,nextPaintTime:v,processedEventEntries:r,longAnimationFrameEntries:o,inputDelay:i-n.startTime,processingDuration:a-i,presentationDelay:Math.max(v-a,0),loadState:s(n.startTime)};return Object.assign(t,{attribution:l})}(n);t(e)}),n)},t.onLCP=function(t,n){!function(t,n){var e=!1,i=h(n=n||{}),a=0;D((function(){var r,s=M(),c=p("LCP"),u=function(i,o){if(c=p("LCP",0,i,o),r=f(t,c,ut,n.reportAllChanges),e=!1,"soft-navigation"===i){s=M(!0);var u=T(o);a=u&&u.startTime?u.startTime:0}["keydown","click"].forEach((function(t){addEventListener(t,(function(){return J(l)}),{once:!0})}))},v=function(t){t.forEach((function(t){if(t){i&&t.navigationId&&t.navigationId!==c.navigationId&&(e||r(!0),u("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==o){var a=T(t.navigationId),f=a&&a.startTime?a.startTime:0;n=Math.max(t.startTime-f,0)}else n=Math.max(t.startTime-m(),0);t.startTime<s.firstHiddenTime&&(c.value=n,c.entries=[t],c.navigationId=t.navigationId||o,r())}}))},l=function(){e||(v(h.takeRecords()),i||h.disconnect(),e=!0,r(!0))},h=I("largest-contentful-paint",v,n);h&&(r=f(t,c,ut,n.reportAllChanges),y(l),g((function(t){u("back-forward-cache",c.navigationId),d((function(){c.value=performance.now()-t.timeStamp,e=!0,r(!0)}))})),i&&I("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?T(t.navigationId):null;t.navigationId&&t.navigationId!==c.navigationId&&n&&(n.startTime||0)>a&&(e||r(!0),u("soft-navigation",t.navigationId))}))}),n))}))}((function(n){var e=function(t){var n={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:t.value};if(t.entries.length){var e,i=0,a=0,s=0;if(t.navigationId&&t.navigationId!==o?i=s=(e=T(t.navigationId))?e.startTime:0:(i=(e=r())&&e.activationStart?e.activationStart:0,a=e&&e.responseStart?e.responseStart:0),e){var c=t.entries[t.entries.length-1],f=c.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===c.url}))[0],d=Math.max(0,a-i),v=Math.max(d,f?(f.requestStart||f.startTime)-i:0),l=Math.max(v-s,f?f.responseEnd-i:0,0),g=Math.max(l-s,c?c.startTime-i:0,0);n={element:u(c.element),timeToFirstByte:d,resourceLoadDelay:v-d,resourceLoadDuration:l-v,elementRenderDelay:g-l,navigationEntry:e,lcpEntry:c},c.url&&(n.url=c.url),f&&(n.lcpResourceEntry=f)}}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},t.onTTFB=function(t,n){lt((function(n){var e=function(t){var n={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(t.entries.length){var e=t.entries[0],i=e.activationStart||0,a=Math.max((e.workerStart||e.fetchStart)-i,0),r=Math.max(e.domainLookupStart-i||0,0),o=Math.max(e.connectStart-i||0,0),s=Math.max(e.connectEnd-i||0,0);n={waitingDuration:a,cacheDuration:r-a,dnsDuration:o-r,connectionDuration:s-o,requestDuration:t.value-s,navigationEntry:e}}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},t}({});
var webVitals=function(n){"use strict";var t,e,i,a=function(){var n=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},r=function(n){if("loading"===document.readyState)return"loading";var t=a();if(t){if(n<t.domInteractive)return"loading";if(0===t.domContentLoadedEventStart||n<t.domContentLoadedEventStart)return"dom-interactive";if(0===t.domComplete||n<t.domComplete)return"dom-content-loaded"}return"complete"},o=function(n){var t=n.nodeName;return 1===n.nodeType?t.toLowerCase():t.toUpperCase().replace(/^#/,"")},s=function(n,t){var e="";try{for(;n&&9!==n.nodeType;){var i=n,a=i.id?"#"+i.id:o(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(t||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;n=i.parentNode}}catch(n){}return e},c=function(n,t,e,i){var a,r;return function(o){t.value>=0&&(o||i)&&((r=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=r,t.rating=function(n,t){return n>t[1]?"poor":n>t[0]?"needs-improvement":"good"}(t.value,e),n(t))}},u=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},d=-1,f=function(){return d},v=function(n){addEventListener("pageshow",(function(t){t.persisted&&(d=t.timeStamp,n(t))}),!0)},l=function(){var n=a();return n&&n.activationStart||0},g=function(n,t,e,i){var r,o=(null===(r=a())||void 0===r?void 0:r.navigationId)||"1",s=a(),c="navigate";e?c=e:f()>=0?c="back-forward-cache":s&&(document.prerendering||l()>0?c="prerender":document.wasDiscarded?c="restore":s.type&&(c=s.type.replace(/_/g,"-")));return{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:c,navigationId:i||o}},m=function(n){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&n&&n.reportSoftNavs},p=function(n){if(n){var t=window.performance.getEntriesByType("soft-navigation").filter((function(t){return t.navigationId===n}));return t?t[0]:void 0}},h=function(n,t,e){var i=m(e);try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var a=new PerformanceObserver((function(n){Promise.resolve().then((function(){t(n.getEntries())}))}));return a.observe(Object.assign({type:n,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(n){}},T=function(n){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&n()}))},I=function(n){var t=!1;return function(){t||(n(),t=!0)}},y=-1,E=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},S=function(n){"hidden"===document.visibilityState&&y>-1&&(y="visibilitychange"===n.type?n.timeStamp:0,C())},b=function(){addEventListener("visibilitychange",S,!0),addEventListener("prerenderingchange",S,!0)},C=function(){removeEventListener("visibilitychange",S,!0),removeEventListener("prerenderingchange",S,!0)},L=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(y=-1),y<0&&(y=E(),b(),v((function(){setTimeout((function(){y=E(),b()}),0)}))),{get firstHiddenTime(){return y}}},w=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},M=[1800,3e3],D=function(n,t){var e,i=m(t=t||{}),r=0,o=(null===(e=a())||void 0===e?void 0:e.navigationId)||"1";w((function(){var e,a=L(),s=g("FCP"),d=h("paint",(function(u){u.forEach((function(u){if("first-contentful-paint"===u.name){i?u.navigationId&&u.navigationId!==s.navigationId&&function(i,o){if(s=g("FCP",0,i,o),e=c(n,s,M,t.reportAllChanges),"soft-navigation"===i){a=L(!0);var u=o?p(o):null;r=u&&u.startTime||0}}("soft-navigation",u.navigationId):d.disconnect();var f=0;if(u.navigationId&&u.navigationId!==o){var v=p(u.navigationId),m=v&&v.startTime?v.startTime:0;f=Math.max(u.startTime-m,0)}else f=Math.max(u.startTime-l(),0);var h=i&&u.navigationId?p(u.navigationId):null,T=h&&h.startTime?h.startTime:0;(u.startTime<a.firstHiddenTime||i&&u.navigationId&&u.navigationId!==s.navigationId&&u.navigationId!==o&&T>r)&&(s.value=f,s.entries.push(u),s.navigationId=u.navigationId||"1",e(!0))}}))}),t);d&&(e=c(n,s,M,t.reportAllChanges),v((function(i){s=g("FCP",0,"back-forward-cache",s.navigationId),e=c(n,s,M,t.reportAllChanges),u((function(){s.value=performance.now()-i.timeStamp,e(!0)}))})))}))},k=[.1,.25],F=0,A=1/0,P=0,x="",B=!1,O=function(n){var t;x||(x=(null===(t=a())||void 0===t?void 0:t.navigationId)||"1"),n.forEach((function(n){n.interactionId&&(B&&n.navigationId&&n.navigationId!==x&&(x=n.navigationId,F=0,A=1/0,P=0),A=Math.min(A,n.interactionId),P=Math.max(P,n.interactionId),F=P?(P-A)/7+1:0)}))},N=function(){return t?F:performance.interactionCount||0},R=function(n){"interactionCount"in performance||t||(t=h("event",O,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:B=n||!1}))},j=[],q=new Map,H=0,V=function(){H=N(),j.length=0,q.clear()},W=function(){var n=Math.min(j.length-1,Math.floor((N()-H)/50));return j[n]},z=[],U=function(n){if(z.forEach((function(t){return t(n)})),n.interactionId||"first-input"===n.entryType){var t=j[j.length-1],e=q.get(n.interactionId);if(e||j.length<10||n.duration>t.latency){if(e)n.duration>e.latency?(e.entries=[n],e.latency=n.duration):n.duration===e.latency&&n.startTime===e.entries[0].startTime&&e.entries.push(n);else{var i={id:n.interactionId,latency:n.duration,entries:[n]};q.set(i.id,i),j.push(i)}j.sort((function(n,t){return t.latency-n.latency})),j.length>10&&j.splice(10).forEach((function(n){return q.delete(n.id)}))}}},_=function(n){var t=self.requestIdleCallback||self.setTimeout,e=-1;return n=I(n),"hidden"===document.visibilityState?n():(e=t(n),T(n)),e},G=[200,500],J=function(n,t){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var e=m(t=t||{}),i=!1,a=0;w((function(){var r;R(e);var o,s=g("INP"),d=function(e,r){if(V(),s=g("INP",0,e,r),o=c(n,s,G,t.reportAllChanges),i=!1,"soft-navigation"===e){var u=p(r);a=u&&u.startTime?u.startTime:0}},f=function(n){_((function(){var e;n.forEach(U),(e=W())&&(e.latency!==s.value||t&&t.reportAllChanges)&&(s.value=e.latency,s.entries=e.entries),o()}))},l=h("event",f,{durationThreshold:null!==(r=t.durationThreshold)&&void 0!==r?r:40,opts:t});if(o=c(n,s,G,t.reportAllChanges),l){l.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),T((function(){f(l.takeRecords()),o(!0)})),v((function(){V(),d("back-forward-cache",s.navigationId),u((function(){return o()}))}));e&&h("soft-navigation",(function(e){e.forEach((function(e){var r=p(e.navigationId),u=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==s.navigationId&&u>a&&(!i&&s.value>0&&o(!0),d("soft-navigation",e.navigationId),o=c(n,s,G,t.reportAllChanges))}))}),t)}}))}},K=[],Q=[],X=new WeakMap,Y=new Map,Z=-1,$=function(n){K=K.concat(n),nn()},nn=function(){Z<0&&(Z=_(tn))},tn=function(){Y.size>10&&Y.forEach((function(n,t){q.has(t)||Y.delete(t)}));var n=j.map((function(n){return X.get(n.entries[0])})),t=Q.length-50;Q=Q.filter((function(e,i){return i>=t||n.includes(e)}));for(var e=new Set,a=0;a<Q.length;a++){var r=Q[a];sn(r.startTime,r.processingEnd).forEach((function(n){e.add(n)}))}for(var o=0;o<50;o++){var s=K[K.length-1-o];if(!s||s.startTime<i)break;e.add(s)}K=Array.from(e),Z=-1};z.push((function(n){n.interactionId&&n.target&&!Y.has(n.interactionId)&&Y.set(n.interactionId,n.target)}),(function(n){var t,e=n.startTime+n.duration;i=Math.max(i,n.processingEnd);for(var a=Q.length-1;a>=0;a--){var r=Q[a];if(Math.abs(e-r.renderTime)<=8){(t=r).startTime=Math.min(n.startTime,t.startTime),t.processingStart=Math.min(n.processingStart,t.processingStart),t.processingEnd=Math.max(n.processingEnd,t.processingEnd),t.entries.push(n);break}}t||(t={startTime:n.startTime,processingStart:n.processingStart,processingEnd:n.processingEnd,renderTime:e,entries:[n]},Q.push(t)),(n.interactionId||"first-input"===n.entryType)&&X.set(n,t),nn()}));var en,an,rn,on,sn=function(n,t){for(var e,i=[],a=0;e=K[a];a++)if(!(e.startTime+e.duration<n)){if(e.startTime>t)break;i.push(e)}return i},cn=[2500,4e3],un=[800,1800],dn=function n(t){document.prerendering?w((function(){return n(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return n(t)}),!0):setTimeout(t,0)},fn=function(n,t){var e=m(t=t||{}),i=g("TTFB"),r=c(n,i,un,t.reportAllChanges);dn((function(){var o=a();if(o){var s=o.responseStart;i.value=Math.max(s-l(),0),i.entries=[o],r(!0),v((function(){i=g("TTFB",0,"back-forward-cache",i.navigationId),(r=c(n,i,un,t.reportAllChanges))(!0)}));e&&h("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=g("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(r=c(n,i,un,t.reportAllChanges))(!0))}))}),t)}}))},vn={passive:!0,capture:!0},ln=new Date,gn=function(n,t){en||(en=t,an=n,rn=new Date,hn(removeEventListener),mn())},mn=function(){if(an>=0&&an<rn-ln){var n={entryType:"first-input",name:en.type,target:en.target,cancelable:en.cancelable,startTime:en.timeStamp,processingStart:en.timeStamp+an};on.forEach((function(t){t([n])})),on=[]}},pn=function(n){if(n.cancelable){var t=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,t){var e=function(){gn(n,t),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,vn),removeEventListener("pointercancel",i,vn)};addEventListener("pointerup",e,vn),addEventListener("pointercancel",i,vn)}(t,n):gn(t,n)}},hn=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return n(t,pn,vn)}))},Tn=[100,300],In=function(n,t){var e,i=m(t=t||{}),r=(null===(e=a())||void 0===e?void 0:e.navigationId)||"1";w((function(){var e,a=L(),o=g("FID"),s=function(s){s.forEach((function(s){var d,f;i?s.navigationId&&s.navigationId!==o.navigationId&&(d="soft-navigation",f=s.navigationId,"soft-navigation"===d&&(a=L(!0)),o=g("FID",0,d,f),e=c(n,o,Tn,t.reportAllChanges)):u.disconnect(),s.startTime<a.firstHiddenTime&&(o.value=s.processingStart-s.startTime,o.entries.push(s),o.navigationId=s.navigationId||r,e(!0))}))},u=h("first-input",s,t);e=c(n,o,Tn,t.reportAllChanges),u&&(T((function(){s(u.takeRecords()),i||u.disconnect()})),v((function(){var i;o=g("FID",0,"back-forward-cache",o.navigationId),e=c(n,o,Tn,t.reportAllChanges),on=[],an=-1,en=null,hn(addEventListener),i=s,on.push(i),mn()})))}))};return n.CLSThresholds=k,n.FCPThresholds=M,n.FIDThresholds=Tn,n.INPThresholds=G,n.LCPThresholds=cn,n.TTFBThresholds=un,n.onCLS=function(n,t){!function(n,t){var e=m(t=t||{}),i=!1,a=0;D(I((function(){var r,o=g("CLS",0),s=0,d=[],f=function(e,u){if(o=g("CLS",0,e,u),r=c(n,o,k,t.reportAllChanges),s=0,i=!1,"soft-navigation"===e){var d=p(u);a=d&&d.startTime||0}},l=function(n){n.forEach((function(n){if(e&&n.navigationId&&n.navigationId!==o.navigationId&&(s>o.value&&(o.value=s,o.entries=d),r(!0),f("soft-navigation",n.navigationId)),!n.hadRecentInput){var t=d[0],i=d[d.length-1];s&&n.startTime-i.startTime<1e3&&n.startTime-t.startTime<5e3?(s+=n.value,d.push(n)):(s=n.value,d=[n])}})),s>o.value&&(o.value=s,o.entries=d,r())},m=h("layout-shift",l,t);m&&(r=c(n,o,k,t.reportAllChanges),T((function(){l(m.takeRecords()),r(!0),i=!0})),v((function(){f("back-forward-cache",o.navigationId),u((function(){return r()}))})),e&&h("soft-navigation",(function(e){e.forEach((function(e){var s=e.navigationId,u=s?p(s):null;s&&s!==o.navigationId&&u&&(u.startTime||0)>a&&(i||r(!0),f("soft-navigation",e.navigationId),r=c(n,o,k,t.reportAllChanges))}))}),t),setTimeout(r,0))})))}((function(t){var e=function(n){var t,e={};if(n.entries.length){var i=n.entries.reduce((function(n,t){return n&&n.value>t.value?n:t}));if(i&&i.sources&&i.sources.length){var a=(t=i.sources).find((function(n){return n.node&&1===n.node.nodeType}))||t[0];a&&(e={largestShiftTarget:s(a.node),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:a,largestShiftEntry:i,loadState:r(i.startTime)})}}return Object.assign(n,{attribution:e})}(t);n(e)}),t)},n.onFCP=function(n,t){D((function(t){var e=function(n){var t,e=(null===(t=a())||void 0===t?void 0:t.navigationId)||"1",i={timeToFirstByte:0,firstByteToFCP:n.value,loadState:r(f())};if(n.entries.length){var o,s=n.entries[n.entries.length-1],c=0;if(n.navigationId&&n.navigationId!==e)c=(o=p(n.navigationId))?o.startTime:0;else if(o=a()){var u=o.responseStart,d=o.activationStart||0;c=Math.max(0,u-d)}o&&(i={timeToFirstByte:c,firstByteToFCP:n.value-c,loadState:r(n.entries[0].startTime),navigationEntry:o,fcpEntry:s})}return Object.assign(n,{attribution:i})}(t);n(e)}),t)},n.onFID=function(n,t){In((function(t){var e=function(n){var t=n.entries[0],e={eventTarget:s(t.target),eventType:t.name,eventTime:t.startTime,eventEntry:t,loadState:r(t.startTime)};return Object.assign(n,{attribution:e})}(t);n(e)}),t)},n.onINP=function(n,t){e||(e=h("long-animation-frame",$)),J((function(t){var e=function(n){var t=n.entries[0],e=X.get(t),i=t.processingStart,a=e.processingEnd,o=e.entries.sort((function(n,t){return n.processingStart-t.processingStart})),c=sn(t.startTime,a),u=n.entries.find((function(n){return n.target})),d=u&&u.target||Y.get(t.interactionId),f=[t.startTime+t.duration,a].concat(c.map((function(n){return n.startTime+n.duration}))),v=Math.max.apply(Math,f),l={interactionTarget:s(d),interactionTargetElement:d,interactionType:t.name.startsWith("key")?"keyboard":"pointer",interactionTime:t.startTime,nextPaintTime:v,processedEventEntries:o,longAnimationFrameEntries:c,inputDelay:i-t.startTime,processingDuration:a-i,presentationDelay:Math.max(v-a,0),loadState:r(t.startTime)};return Object.assign(n,{attribution:l})}(t);n(e)}),t)},n.onLCP=function(n,t){!function(n,t){var e,i=!1,r=m(t=t||{}),o=0,s=(null===(e=a())||void 0===e?void 0:e.navigationId)||"1",d="";w((function(){var e,a=L(),f=g("LCP"),m=function(r,s){if(f=g("LCP",0,r,s),e=c(n,f,cn,t.reportAllChanges),i=!1,"soft-navigation"===r){a=L(!0);var u=p(s);o=u&&u.startTime?u.startTime:0}E()},I=function(n){n.forEach((function(n){if(n){r&&n.navigationId&&n.navigationId!==f.navigationId&&(i||e(!0),m("soft-navigation",n.navigationId));var t=0;if(n.navigationId&&n.navigationId!==s){var o=p(n.navigationId),c=o&&o.startTime?o.startTime:0;t=Math.max(n.startTime-c,0)}else t=Math.max(n.startTime-l(),0);n.startTime<a.firstHiddenTime&&(f.value=t,f.entries=[n],f.navigationId=n.navigationId||s,e())}}))},y=function(){S(),i||(I(C.takeRecords()),r||C.disconnect(),f.navigationId===d&&(i=!0,e(!0)))},E=function(){["keydown","click"].forEach((function(n){addEventListener(n,(function(){return b()}),!0)}))},S=function(){["keydown","click"].forEach((function(n){removeEventListener(n,(function(){return b()}),!0)}))},b=function(){d=f.navigationId,_(y)},C=h("largest-contentful-paint",I,t);C&&(e=c(n,f,cn,t.reportAllChanges),E(),T((function(){d=f.navigationId,y()})),v((function(n){m("back-forward-cache",f.navigationId),u((function(){f.value=performance.now()-n.timeStamp,i=!0,e(!0)}))})),r&&h("soft-navigation",(function(n){n.forEach((function(n){var t=n.navigationId?p(n.navigationId):null;n.navigationId&&n.navigationId!==f.navigationId&&t&&(t.startTime||0)>o&&(i||e(!0),m("soft-navigation",n.navigationId))}))}),t))}))}((function(t){var e=function(n){var t,e=(null===(t=a())||void 0===t?void 0:t.navigationId)||"1",i={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:n.value};if(n.entries.length){var r,o=0,c=0,u=0;if(n.navigationId&&n.navigationId!==e?o=u=(r=p(n.navigationId))?r.startTime:0:(o=(r=a())&&r.activationStart?r.activationStart:0,c=r&&r.responseStart?r.responseStart:0),r){var d=n.entries[n.entries.length-1],f=d.url&&performance.getEntriesByType("resource").filter((function(n){return n.name===d.url}))[0],v=Math.max(0,c-o),l=Math.max(v,f?(f.requestStart||f.startTime)-o:0),g=Math.max(l-u,f?f.responseEnd-o:0,0),m=Math.max(g-u,d?d.startTime-o:0,0);i={element:s(d.element),timeToFirstByte:v,resourceLoadDelay:l-v,resourceLoadDuration:g-l,elementRenderDelay:m-g,navigationEntry:r,lcpEntry:d},d.url&&(i.url=d.url),f&&(i.lcpResourceEntry=f)}}return Object.assign(n,{attribution:i})}(t);n(e)}),t)},n.onTTFB=function(n,t){fn((function(t){var e=function(n){var t={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(n.entries.length){var e=n.entries[0],i=e.activationStart||0,a=Math.max((e.workerStart||e.fetchStart)-i,0),r=Math.max(e.domainLookupStart-i||0,0),o=Math.max(e.connectStart-i||0,0),s=Math.max(e.connectEnd-i||0,0);t={waitingDuration:a,cacheDuration:r-a,dnsDuration:o-r,connectionDuration:s-o,requestDuration:n.value-s,navigationEntry:e}}return Object.assign(n,{attribution:t})}(t);n(e)}),t)},n}({});

@@ -1,1 +0,1 @@

var t,n,e,i,a=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},r=(null===(t=a())||void 0===t?void 0:t.navigationId)||"1",o=function(t){if("loading"===document.readyState)return"loading";var n=a();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},c=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},s=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:c(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},u=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},f=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},d=-1,v=function(){return d},g=function(t){addEventListener("pageshow",(function(n){n.persisted&&(d=n.timeStamp,t(n))}),!0)},l=function(){var t=a();return t&&t.activationStart||0},m=function(t,n,e,i){var o=a(),c="navigate";e?c=e:v()>=0?c="back-forward-cache":o&&(document.prerendering||l()>0?c="prerender":document.wasDiscarded?c="restore":o.type&&(c=o.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:c,navigationId:i||r}},p=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},h=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},T=function(t,n,e){var i=p(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},I=function(t){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t()}))},y=function(t){var n=!1;return function(){n||(t(),n=!0)}},E=-1,S=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},b=function(t){"hidden"===document.visibilityState&&E>-1&&(E="visibilitychange"===t.type?t.timeStamp:0,w())},C=function(){addEventListener("visibilitychange",b,!0),addEventListener("prerenderingchange",b,!0)},w=function(){removeEventListener("visibilitychange",b,!0),removeEventListener("prerenderingchange",b,!0)},L=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(E=-1),E<0&&(E=S(),C(),g((function(){setTimeout((function(){E=S(),C()}),0)}))),{get firstHiddenTime(){return E}}},M=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},D=[1800,3e3],k=function(t,n){var e=p(n=n||{}),i=0;M((function(){var a,o=L(),c=m("FCP"),s=T("paint",(function(f){f.forEach((function(f){if("first-contentful-paint"===f.name){e?f.navigationId&&f.navigationId!==c.navigationId&&function(e,r){if(c=m("FCP",0,e,r),a=u(t,c,D,n.reportAllChanges),"soft-navigation"===e){o=L(!0);var s=r?h(r):null;i=s&&s.startTime||0}}("soft-navigation",f.navigationId):s.disconnect();var d=0;if(f.navigationId&&f.navigationId!==r){var v=h(f.navigationId),g=v&&v.startTime?v.startTime:0;d=Math.max(f.startTime-g,0)}else d=Math.max(f.startTime-l(),0);var p=e&&f.navigationId?h(f.navigationId):null,T=p&&p.startTime?p.startTime:0;(f.startTime<o.firstHiddenTime||e&&f.navigationId&&f.navigationId!==c.navigationId&&f.navigationId!==r&&T>i)&&(c.value=d,c.entries.push(f),c.navigationId=f.navigationId||"1",a(!0))}}))}),n);s&&(a=u(t,c,D,n.reportAllChanges),g((function(e){c=m("FCP",0,"back-forward-cache",c.navigationId),a=u(t,c,D,n.reportAllChanges),f((function(){c.value=performance.now()-e.timeStamp,a(!0)}))})))}))},A=[.1,.25],x=function(t,n){!function(t,n){var e=p(n=n||{}),i=!1,a=0;k(y((function(){var r,o=m("CLS",0),c=0,s=[],d=function(e,s){if(o=m("CLS",0,e,s),r=u(t,o,A,n.reportAllChanges),c=0,i=!1,"soft-navigation"===e){var f=h(s);a=f&&f.startTime||0}},v=function(t){t.forEach((function(t){if(e&&t.navigationId&&t.navigationId!==o.navigationId&&(c>o.value&&(o.value=c,o.entries=s),r(!0),d("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=s[0],i=s[s.length-1];c&&t.startTime-i.startTime<1e3&&t.startTime-n.startTime<5e3?(c+=t.value,s.push(t)):(c=t.value,s=[t])}})),c>o.value&&(o.value=c,o.entries=s,r())},l=T("layout-shift",v,n);l&&(r=u(t,o,A,n.reportAllChanges),I((function(){v(l.takeRecords()),r(!0),i=!0})),g((function(){d("back-forward-cache",o.navigationId),f((function(){return r()}))})),e&&T("soft-navigation",(function(e){e.forEach((function(e){var c=e.navigationId,s=c?h(c):null;c&&c!==o.navigationId&&s&&(s.startTime||0)>a&&(i||r(!0),d("soft-navigation",e.navigationId),r=u(t,o,A,n.reportAllChanges))}))}),n),setTimeout(r,0))})))}((function(n){var e=function(t){var n,e={};if(t.entries.length){var i=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(i&&i.sources&&i.sources.length){var a=(n=i.sources).find((function(t){return t.node&&1===t.node.nodeType}))||n[0];a&&(e={largestShiftTarget:s(a.node),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:a,largestShiftEntry:i,loadState:o(i.startTime)})}}return Object.assign(t,{attribution:e})}(n);t(e)}),n)},F=function(t,n){k((function(n){var e=function(t){var n={timeToFirstByte:0,firstByteToFCP:t.value,loadState:o(v())};if(t.entries.length){var e,i=t.entries[t.entries.length-1],c=0;if(t.navigationId&&t.navigationId!==r)c=(e=h(t.navigationId))?e.startTime:0;else if(e=a()){var s=e.responseStart,u=e.activationStart||0;c=Math.max(0,s-u)}e&&(n={timeToFirstByte:c,firstByteToFCP:t.value-c,loadState:o(t.entries[0].startTime),navigationEntry:e,fcpEntry:i})}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},P=0,B=1/0,O=0,N=r,R=!1,j=function(t){t.forEach((function(t){t.interactionId&&(R&&t.navigationId&&t.navigationId!==N&&(N=t.navigationId,P=0,B=1/0,O=0),B=Math.min(B,t.interactionId),O=Math.max(O,t.interactionId),P=O?(O-B)/7+1:0)}))},q=function(){return n?P:performance.interactionCount||0},H=function(t){"interactionCount"in performance||n||(n=T("event",j,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:R=t||!1}))},W=[],z=new Map,U=0,V=function(){U=q(),W.length=0,z.clear()},_=function(){var t=Math.min(W.length-1,Math.floor((q()-U)/50));return W[t]},G=[],J=function(t){if(G.forEach((function(n){return n(t)})),t.interactionId||"first-input"===t.entryType){var n=W[W.length-1],e=z.get(t.interactionId);if(e||W.length<10||t.duration>n.latency){if(e)t.duration>e.latency?(e.entries=[t],e.latency=t.duration):t.duration===e.latency&&t.startTime===e.entries[0].startTime&&e.entries.push(t);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};z.set(i.id,i),W.push(i)}W.sort((function(t,n){return n.latency-t.latency})),W.length>10&&W.splice(10).forEach((function(t){return z.delete(t.id)}))}}},K=function(t){var n=self.requestIdleCallback||self.setTimeout,e=-1;return t=y(t),"hidden"===document.visibilityState?t():(e=n(t),I(t)),e},Q=[200,500],X=function(t,n){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var e=p(n=n||{}),i=!1,a=0;M((function(){var r;H(e);var o,c=m("INP"),s=function(e,r){if(V(),c=m("INP",0,e,r),o=u(t,c,Q,n.reportAllChanges),i=!1,"soft-navigation"===e){var s=h(r);a=s&&s.startTime?s.startTime:0}},d=function(t){K((function(){var e;t.forEach(J),(e=_())&&(e.latency!==c.value||n&&n.reportAllChanges)&&(c.value=e.latency,c.entries=e.entries),o()}))},v=T("event",d,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=u(t,c,Q,n.reportAllChanges),v){v.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),I((function(){d(v.takeRecords()),o(!0)})),g((function(){V(),s("back-forward-cache",c.navigationId),f((function(){return o()}))}));e&&T("soft-navigation",(function(e){e.forEach((function(e){var r=h(e.navigationId),f=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==c.navigationId&&f>a&&(!i&&c.value>0&&o(!0),s("soft-navigation",e.navigationId),o=u(t,c,Q,n.reportAllChanges))}))}),n)}}))}},Y=[],Z=[],$=new WeakMap,tt=new Map,nt=-1,et=function(t){Y=Y.concat(t),it()},it=function(){nt<0&&(nt=K(at))},at=function(){tt.size>10&&tt.forEach((function(t,n){z.has(n)||tt.delete(n)}));var t=W.map((function(t){return $.get(t.entries[0])})),n=Z.length-50;Z=Z.filter((function(e,i){return i>=n||t.includes(e)}));for(var e=new Set,a=0;a<Z.length;a++){var r=Z[a];ut(r.startTime,r.processingEnd).forEach((function(t){e.add(t)}))}for(var o=0;o<50;o++){var c=Y[Y.length-1-o];if(!c||c.startTime<i)break;e.add(c)}Y=Array.from(e),nt=-1};G.push((function(t){t.interactionId&&t.target&&!tt.has(t.interactionId)&&tt.set(t.interactionId,t.target)}),(function(t){var n,e=t.startTime+t.duration;i=Math.max(i,t.processingEnd);for(var a=Z.length-1;a>=0;a--){var r=Z[a];if(Math.abs(e-r.renderTime)<=8){(n=r).startTime=Math.min(t.startTime,n.startTime),n.processingStart=Math.min(t.processingStart,n.processingStart),n.processingEnd=Math.max(t.processingEnd,n.processingEnd),n.entries.push(t);break}}n||(n={startTime:t.startTime,processingStart:t.processingStart,processingEnd:t.processingEnd,renderTime:e,entries:[t]},Z.push(n)),(t.interactionId||"first-input"===t.entryType)&&$.set(t,n),it()}));var rt,ot,ct,st,ut=function(t,n){for(var e,i=[],a=0;e=Y[a];a++)if(!(e.startTime+e.duration<t)){if(e.startTime>n)break;i.push(e)}return i},ft=function(t,n){e||(e=T("long-animation-frame",et)),X((function(n){var e=function(t){var n=t.entries[0],e=$.get(n),i=n.processingStart,a=e.processingEnd,r=e.entries.sort((function(t,n){return t.processingStart-n.processingStart})),c=ut(n.startTime,a),u=t.entries.find((function(t){return t.target})),f=u&&u.target||tt.get(n.interactionId),d=[n.startTime+n.duration,a].concat(c.map((function(t){return t.startTime+t.duration}))),v=Math.max.apply(Math,d),g={interactionTarget:s(f),interactionTargetElement:f,interactionType:n.name.startsWith("key")?"keyboard":"pointer",interactionTime:n.startTime,nextPaintTime:v,processedEventEntries:r,longAnimationFrameEntries:c,inputDelay:i-n.startTime,processingDuration:a-i,presentationDelay:Math.max(v-a,0),loadState:o(n.startTime)};return Object.assign(t,{attribution:g})}(n);t(e)}),n)},dt=[2500,4e3],vt=function(t,n){!function(t,n){var e=!1,i=p(n=n||{}),a=0;M((function(){var o,c=L(),s=m("LCP"),d=function(i,r){if(s=m("LCP",0,i,r),o=u(t,s,dt,n.reportAllChanges),e=!1,"soft-navigation"===i){c=L(!0);var f=h(r);a=f&&f.startTime?f.startTime:0}["keydown","click"].forEach((function(t){addEventListener(t,(function(){return K(p)}),{once:!0})}))},v=function(t){t.forEach((function(t){if(t){i&&t.navigationId&&t.navigationId!==s.navigationId&&(e||o(!0),d("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==r){var a=h(t.navigationId),u=a&&a.startTime?a.startTime:0;n=Math.max(t.startTime-u,0)}else n=Math.max(t.startTime-l(),0);t.startTime<c.firstHiddenTime&&(s.value=n,s.entries=[t],s.navigationId=t.navigationId||r,o())}}))},p=function(){e||(v(y.takeRecords()),i||y.disconnect(),e=!0,o(!0))},y=T("largest-contentful-paint",v,n);y&&(o=u(t,s,dt,n.reportAllChanges),I(p),g((function(t){d("back-forward-cache",s.navigationId),f((function(){s.value=performance.now()-t.timeStamp,e=!0,o(!0)}))})),i&&T("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?h(t.navigationId):null;t.navigationId&&t.navigationId!==s.navigationId&&n&&(n.startTime||0)>a&&(e||o(!0),d("soft-navigation",t.navigationId))}))}),n))}))}((function(n){var e=function(t){var n={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:t.value};if(t.entries.length){var e,i=0,o=0,c=0;if(t.navigationId&&t.navigationId!==r?i=c=(e=h(t.navigationId))?e.startTime:0:(i=(e=a())&&e.activationStart?e.activationStart:0,o=e&&e.responseStart?e.responseStart:0),e){var u=t.entries[t.entries.length-1],f=u.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===u.url}))[0],d=Math.max(0,o-i),v=Math.max(d,f?(f.requestStart||f.startTime)-i:0),g=Math.max(v-c,f?f.responseEnd-i:0,0),l=Math.max(g-c,u?u.startTime-i:0,0);n={element:s(u.element),timeToFirstByte:d,resourceLoadDelay:v-d,resourceLoadDuration:g-v,elementRenderDelay:l-g,navigationEntry:e,lcpEntry:u},u.url&&(n.url=u.url),f&&(n.lcpResourceEntry=f)}}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},gt=[800,1800],lt=a(),mt=function t(n){document.prerendering?M((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},pt=function(t,n){var e=p(n=n||{}),i=m("TTFB"),a=u(t,i,gt,n.reportAllChanges);mt((function(){if(lt){var r=lt.responseStart;i.value=Math.max(r-l(),0),i.entries=[lt],a(!0),g((function(){i=m("TTFB",0,"back-forward-cache",i.navigationId),(a=u(t,i,gt,n.reportAllChanges))(!0)}));e&&T("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((i=m("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(a=u(t,i,gt,n.reportAllChanges))(!0))}))}),n)}}))},ht=function(t,n){pt((function(n){var e=function(t){var n={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(t.entries.length){var e=t.entries[0],i=e.activationStart||0,a=Math.max((e.workerStart||e.fetchStart)-i,0),r=Math.max(e.domainLookupStart-i||0,0),o=Math.max(e.connectStart-i||0,0),c=Math.max(e.connectEnd-i||0,0);n={waitingDuration:a,cacheDuration:r-a,dnsDuration:o-r,connectionDuration:c-o,requestDuration:t.value-c,navigationEntry:e}}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},Tt={passive:!0,capture:!0},It=new Date,yt=function(t,n){rt||(rt=n,ot=t,ct=new Date,bt(removeEventListener),Et())},Et=function(){if(ot>=0&&ot<ct-It){var t={entryType:"first-input",name:rt.type,target:rt.target,cancelable:rt.cancelable,startTime:rt.timeStamp,processingStart:rt.timeStamp+ot};st.forEach((function(n){n([t])})),st=[]}},St=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){yt(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,Tt),removeEventListener("pointercancel",i,Tt)};addEventListener("pointerup",e,Tt),addEventListener("pointercancel",i,Tt)}(n,t):yt(n,t)}},bt=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,St,Tt)}))},Ct=[100,300],wt=function(t,n){var e=p(n=n||{});M((function(){var i,a=L(),o=m("FID"),c=function(c){c.forEach((function(c){var f,d;e?c.navigationId&&c.navigationId!==o.navigationId&&(f="soft-navigation",d=c.navigationId,"soft-navigation"===f&&(a=L(!0)),o=m("FID",0,f,d),i=u(t,o,Ct,n.reportAllChanges)):s.disconnect(),c.startTime<a.firstHiddenTime&&(o.value=c.processingStart-c.startTime,o.entries.push(c),o.navigationId=c.navigationId||r,i(!0))}))},s=T("first-input",c,n);i=u(t,o,Ct,n.reportAllChanges),s&&(I((function(){c(s.takeRecords()),e||s.disconnect()})),g((function(){var e;o=m("FID",0,"back-forward-cache",o.navigationId),i=u(t,o,Ct,n.reportAllChanges),st=[],ot=-1,rt=null,bt(addEventListener),e=c,st.push(e),Et()})))}))},Lt=function(t,n){wt((function(n){var e=function(t){var n=t.entries[0],e={eventTarget:s(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:o(n.startTime)};return Object.assign(t,{attribution:e})}(n);t(e)}),n)};export{A as CLSThresholds,D as FCPThresholds,Ct as FIDThresholds,Q as INPThresholds,dt as LCPThresholds,gt as TTFBThresholds,x as onCLS,F as onFCP,Lt as onFID,ft as onINP,vt as onLCP,ht as onTTFB};
var t,n,e,i=function(){var t=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(t&&t.responseStart>0&&t.responseStart<performance.now())return t},a=function(t){if("loading"===document.readyState)return"loading";var n=i();if(n){if(t<n.domInteractive)return"loading";if(0===n.domContentLoadedEventStart||t<n.domContentLoadedEventStart)return"dom-interactive";if(0===n.domComplete||t<n.domComplete)return"dom-content-loaded"}return"complete"},r=function(t){var n=t.nodeName;return 1===t.nodeType?n.toLowerCase():n.toUpperCase().replace(/^#/,"")},o=function(t,n){var e="";try{for(;t&&9!==t.nodeType;){var i=t,a=i.id?"#"+i.id:r(i)+(i.classList&&i.classList.value&&i.classList.value.trim()&&i.classList.value.trim().length?"."+i.classList.value.trim().replace(/\s+/g,"."):"");if(e.length+a.length>(n||100)-1)return e||a;if(e=e?a+">"+e:a,i.id)break;t=i.parentNode}}catch(t){}return e},c=function(t,n,e,i){var a,r;return function(o){n.value>=0&&(o||i)&&((r=n.value-(a||0))||void 0===a)&&(a=n.value,n.delta=r,n.rating=function(t,n){return t>n[1]?"poor":t>n[0]?"needs-improvement":"good"}(n.value,e),t(n))}},s=function(t){requestAnimationFrame((function(){return requestAnimationFrame((function(){return t()}))}))},u=-1,f=function(){return u},v=function(t){addEventListener("pageshow",(function(n){n.persisted&&(u=n.timeStamp,t(n))}),!0)},d=function(){var t=i();return t&&t.activationStart||0},g=function(t,n,e,a){var r,o=(null===(r=i())||void 0===r?void 0:r.navigationId)||"1",c=i(),s="navigate";e?s=e:f()>=0?s="back-forward-cache":c&&(document.prerendering||d()>0?s="prerender":document.wasDiscarded?s="restore":c.type&&(s=c.type.replace(/_/g,"-")));return{name:t,value:void 0===n?-1:n,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:s,navigationId:a||o}},l=function(t){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&t&&t.reportSoftNavs},m=function(t){if(t){var n=window.performance.getEntriesByType("soft-navigation").filter((function(n){return n.navigationId===t}));return n?n[0]:void 0}},p=function(t,n,e){var i=l(e);try{if(PerformanceObserver.supportedEntryTypes.includes(t)){var a=new PerformanceObserver((function(t){Promise.resolve().then((function(){n(t.getEntries())}))}));return a.observe(Object.assign({type:t,buffered:!0,includeSoftNavigationObservations:i},e||{})),a}}catch(t){}},h=function(t){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&t()}))},T=function(t){var n=!1;return function(){n||(t(),n=!0)}},I=-1,y=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},E=function(t){"hidden"===document.visibilityState&&I>-1&&(I="visibilitychange"===t.type?t.timeStamp:0,b())},S=function(){addEventListener("visibilitychange",E,!0),addEventListener("prerenderingchange",E,!0)},b=function(){removeEventListener("visibilitychange",E,!0),removeEventListener("prerenderingchange",E,!0)},C=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(I=-1),I<0&&(I=y(),S(),v((function(){setTimeout((function(){I=y(),S()}),0)}))),{get firstHiddenTime(){return I}}},w=function(t){document.prerendering?addEventListener("prerenderingchange",(function(){return t()}),!0):t()},L=[1800,3e3],M=function(t,n){var e,a=l(n=n||{}),r=0,o=(null===(e=i())||void 0===e?void 0:e.navigationId)||"1";w((function(){var e,i=C(),u=g("FCP"),f=p("paint",(function(s){s.forEach((function(s){if("first-contentful-paint"===s.name){a?s.navigationId&&s.navigationId!==u.navigationId&&function(a,o){if(u=g("FCP",0,a,o),e=c(t,u,L,n.reportAllChanges),"soft-navigation"===a){i=C(!0);var s=o?m(o):null;r=s&&s.startTime||0}}("soft-navigation",s.navigationId):f.disconnect();var v=0;if(s.navigationId&&s.navigationId!==o){var l=m(s.navigationId),p=l&&l.startTime?l.startTime:0;v=Math.max(s.startTime-p,0)}else v=Math.max(s.startTime-d(),0);var h=a&&s.navigationId?m(s.navigationId):null,T=h&&h.startTime?h.startTime:0;(s.startTime<i.firstHiddenTime||a&&s.navigationId&&s.navigationId!==u.navigationId&&s.navigationId!==o&&T>r)&&(u.value=v,u.entries.push(s),u.navigationId=s.navigationId||"1",e(!0))}}))}),n);f&&(e=c(t,u,L,n.reportAllChanges),v((function(i){u=g("FCP",0,"back-forward-cache",u.navigationId),e=c(t,u,L,n.reportAllChanges),s((function(){u.value=performance.now()-i.timeStamp,e(!0)}))})))}))},D=[.1,.25],k=function(t,n){!function(t,n){var e=l(n=n||{}),i=!1,a=0;M(T((function(){var r,o=g("CLS",0),u=0,f=[],d=function(e,s){if(o=g("CLS",0,e,s),r=c(t,o,D,n.reportAllChanges),u=0,i=!1,"soft-navigation"===e){var f=m(s);a=f&&f.startTime||0}},l=function(t){t.forEach((function(t){if(e&&t.navigationId&&t.navigationId!==o.navigationId&&(u>o.value&&(o.value=u,o.entries=f),r(!0),d("soft-navigation",t.navigationId)),!t.hadRecentInput){var n=f[0],i=f[f.length-1];u&&t.startTime-i.startTime<1e3&&t.startTime-n.startTime<5e3?(u+=t.value,f.push(t)):(u=t.value,f=[t])}})),u>o.value&&(o.value=u,o.entries=f,r())},T=p("layout-shift",l,n);T&&(r=c(t,o,D,n.reportAllChanges),h((function(){l(T.takeRecords()),r(!0),i=!0})),v((function(){d("back-forward-cache",o.navigationId),s((function(){return r()}))})),e&&p("soft-navigation",(function(e){e.forEach((function(e){var s=e.navigationId,u=s?m(s):null;s&&s!==o.navigationId&&u&&(u.startTime||0)>a&&(i||r(!0),d("soft-navigation",e.navigationId),r=c(t,o,D,n.reportAllChanges))}))}),n),setTimeout(r,0))})))}((function(n){var e=function(t){var n,e={};if(t.entries.length){var i=t.entries.reduce((function(t,n){return t&&t.value>n.value?t:n}));if(i&&i.sources&&i.sources.length){var r=(n=i.sources).find((function(t){return t.node&&1===t.node.nodeType}))||n[0];r&&(e={largestShiftTarget:o(r.node),largestShiftTime:i.startTime,largestShiftValue:i.value,largestShiftSource:r,largestShiftEntry:i,loadState:a(i.startTime)})}}return Object.assign(t,{attribution:e})}(n);t(e)}),n)},A=function(t,n){M((function(n){var e=function(t){var n,e=(null===(n=i())||void 0===n?void 0:n.navigationId)||"1",r={timeToFirstByte:0,firstByteToFCP:t.value,loadState:a(f())};if(t.entries.length){var o,c=t.entries[t.entries.length-1],s=0;if(t.navigationId&&t.navigationId!==e)s=(o=m(t.navigationId))?o.startTime:0;else if(o=i()){var u=o.responseStart,v=o.activationStart||0;s=Math.max(0,u-v)}o&&(r={timeToFirstByte:s,firstByteToFCP:t.value-s,loadState:a(t.entries[0].startTime),navigationEntry:o,fcpEntry:c})}return Object.assign(t,{attribution:r})}(n);t(e)}),n)},x=0,F=1/0,P=0,B="",O=!1,N=function(t){var n;B||(B=(null===(n=i())||void 0===n?void 0:n.navigationId)||"1"),t.forEach((function(t){t.interactionId&&(O&&t.navigationId&&t.navigationId!==B&&(B=t.navigationId,x=0,F=1/0,P=0),F=Math.min(F,t.interactionId),P=Math.max(P,t.interactionId),x=P?(P-F)/7+1:0)}))},R=function(){return t?x:performance.interactionCount||0},j=function(n){"interactionCount"in performance||t||(t=p("event",N,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:O=n||!1}))},q=[],H=new Map,W=0,z=function(){W=R(),q.length=0,H.clear()},U=function(){var t=Math.min(q.length-1,Math.floor((R()-W)/50));return q[t]},V=[],_=function(t){if(V.forEach((function(n){return n(t)})),t.interactionId||"first-input"===t.entryType){var n=q[q.length-1],e=H.get(t.interactionId);if(e||q.length<10||t.duration>n.latency){if(e)t.duration>e.latency?(e.entries=[t],e.latency=t.duration):t.duration===e.latency&&t.startTime===e.entries[0].startTime&&e.entries.push(t);else{var i={id:t.interactionId,latency:t.duration,entries:[t]};H.set(i.id,i),q.push(i)}q.sort((function(t,n){return n.latency-t.latency})),q.length>10&&q.splice(10).forEach((function(t){return H.delete(t.id)}))}}},G=function(t){var n=self.requestIdleCallback||self.setTimeout,e=-1;return t=T(t),"hidden"===document.visibilityState?t():(e=n(t),h(t)),e},J=[200,500],K=function(t,n){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var e=l(n=n||{}),i=!1,a=0;w((function(){var r;j(e);var o,u=g("INP"),f=function(e,r){if(z(),u=g("INP",0,e,r),o=c(t,u,J,n.reportAllChanges),i=!1,"soft-navigation"===e){var s=m(r);a=s&&s.startTime?s.startTime:0}},d=function(t){G((function(){var e;t.forEach(_),(e=U())&&(e.latency!==u.value||n&&n.reportAllChanges)&&(u.value=e.latency,u.entries=e.entries),o()}))},l=p("event",d,{durationThreshold:null!==(r=n.durationThreshold)&&void 0!==r?r:40,opts:n});if(o=c(t,u,J,n.reportAllChanges),l){l.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:e}),h((function(){d(l.takeRecords()),o(!0)})),v((function(){z(),f("back-forward-cache",u.navigationId),s((function(){return o()}))}));e&&p("soft-navigation",(function(e){e.forEach((function(e){var r=m(e.navigationId),s=r&&r.startTime?r.startTime:0;e.navigationId&&e.navigationId!==u.navigationId&&s>a&&(!i&&u.value>0&&o(!0),f("soft-navigation",e.navigationId),o=c(t,u,J,n.reportAllChanges))}))}),n)}}))}},Q=[],X=[],Y=new WeakMap,Z=new Map,$=-1,tt=function(t){Q=Q.concat(t),nt()},nt=function(){$<0&&($=G(et))},et=function(){Z.size>10&&Z.forEach((function(t,n){H.has(n)||Z.delete(n)}));var t=q.map((function(t){return Y.get(t.entries[0])})),n=X.length-50;X=X.filter((function(e,i){return i>=n||t.includes(e)}));for(var i=new Set,a=0;a<X.length;a++){var r=X[a];ct(r.startTime,r.processingEnd).forEach((function(t){i.add(t)}))}for(var o=0;o<50;o++){var c=Q[Q.length-1-o];if(!c||c.startTime<e)break;i.add(c)}Q=Array.from(i),$=-1};V.push((function(t){t.interactionId&&t.target&&!Z.has(t.interactionId)&&Z.set(t.interactionId,t.target)}),(function(t){var n,i=t.startTime+t.duration;e=Math.max(e,t.processingEnd);for(var a=X.length-1;a>=0;a--){var r=X[a];if(Math.abs(i-r.renderTime)<=8){(n=r).startTime=Math.min(t.startTime,n.startTime),n.processingStart=Math.min(t.processingStart,n.processingStart),n.processingEnd=Math.max(t.processingEnd,n.processingEnd),n.entries.push(t);break}}n||(n={startTime:t.startTime,processingStart:t.processingStart,processingEnd:t.processingEnd,renderTime:i,entries:[t]},X.push(n)),(t.interactionId||"first-input"===t.entryType)&&Y.set(t,n),nt()}));var it,at,rt,ot,ct=function(t,n){for(var e,i=[],a=0;e=Q[a];a++)if(!(e.startTime+e.duration<t)){if(e.startTime>n)break;i.push(e)}return i},st=function(t,e){n||(n=p("long-animation-frame",tt)),K((function(n){var e=function(t){var n=t.entries[0],e=Y.get(n),i=n.processingStart,r=e.processingEnd,c=e.entries.sort((function(t,n){return t.processingStart-n.processingStart})),s=ct(n.startTime,r),u=t.entries.find((function(t){return t.target})),f=u&&u.target||Z.get(n.interactionId),v=[n.startTime+n.duration,r].concat(s.map((function(t){return t.startTime+t.duration}))),d=Math.max.apply(Math,v),g={interactionTarget:o(f),interactionTargetElement:f,interactionType:n.name.startsWith("key")?"keyboard":"pointer",interactionTime:n.startTime,nextPaintTime:d,processedEventEntries:c,longAnimationFrameEntries:s,inputDelay:i-n.startTime,processingDuration:r-i,presentationDelay:Math.max(d-r,0),loadState:a(n.startTime)};return Object.assign(t,{attribution:g})}(n);t(e)}),e)},ut=[2500,4e3],ft=function(t,n){!function(t,n){var e,a=!1,r=l(n=n||{}),o=0,u=(null===(e=i())||void 0===e?void 0:e.navigationId)||"1",f="";w((function(){var e,i=C(),l=g("LCP"),T=function(r,s){if(l=g("LCP",0,r,s),e=c(t,l,ut,n.reportAllChanges),a=!1,"soft-navigation"===r){i=C(!0);var u=m(s);o=u&&u.startTime?u.startTime:0}E()},I=function(t){t.forEach((function(t){if(t){r&&t.navigationId&&t.navigationId!==l.navigationId&&(a||e(!0),T("soft-navigation",t.navigationId));var n=0;if(t.navigationId&&t.navigationId!==u){var o=m(t.navigationId),c=o&&o.startTime?o.startTime:0;n=Math.max(t.startTime-c,0)}else n=Math.max(t.startTime-d(),0);t.startTime<i.firstHiddenTime&&(l.value=n,l.entries=[t],l.navigationId=t.navigationId||u,e())}}))},y=function(){S(),a||(I(w.takeRecords()),r||w.disconnect(),l.navigationId===f&&(a=!0,e(!0)))},E=function(){["keydown","click"].forEach((function(t){addEventListener(t,(function(){return b()}),!0)}))},S=function(){["keydown","click"].forEach((function(t){removeEventListener(t,(function(){return b()}),!0)}))},b=function(){f=l.navigationId,G(y)},w=p("largest-contentful-paint",I,n);w&&(e=c(t,l,ut,n.reportAllChanges),E(),h((function(){f=l.navigationId,y()})),v((function(t){T("back-forward-cache",l.navigationId),s((function(){l.value=performance.now()-t.timeStamp,a=!0,e(!0)}))})),r&&p("soft-navigation",(function(t){t.forEach((function(t){var n=t.navigationId?m(t.navigationId):null;t.navigationId&&t.navigationId!==l.navigationId&&n&&(n.startTime||0)>o&&(a||e(!0),T("soft-navigation",t.navigationId))}))}),n))}))}((function(n){var e=function(t){var n,e=(null===(n=i())||void 0===n?void 0:n.navigationId)||"1",a={timeToFirstByte:0,resourceLoadDelay:0,resourceLoadDuration:0,elementRenderDelay:t.value};if(t.entries.length){var r,c=0,s=0,u=0;if(t.navigationId&&t.navigationId!==e?c=u=(r=m(t.navigationId))?r.startTime:0:(c=(r=i())&&r.activationStart?r.activationStart:0,s=r&&r.responseStart?r.responseStart:0),r){var f=t.entries[t.entries.length-1],v=f.url&&performance.getEntriesByType("resource").filter((function(t){return t.name===f.url}))[0],d=Math.max(0,s-c),g=Math.max(d,v?(v.requestStart||v.startTime)-c:0),l=Math.max(g-u,v?v.responseEnd-c:0,0),p=Math.max(l-u,f?f.startTime-c:0,0);a={element:o(f.element),timeToFirstByte:d,resourceLoadDelay:g-d,resourceLoadDuration:l-g,elementRenderDelay:p-l,navigationEntry:r,lcpEntry:f},f.url&&(a.url=f.url),v&&(a.lcpResourceEntry=v)}}return Object.assign(t,{attribution:a})}(n);t(e)}),n)},vt=[800,1800],dt=function t(n){document.prerendering?w((function(){return t(n)})):"complete"!==document.readyState?addEventListener("load",(function(){return t(n)}),!0):setTimeout(n,0)},gt=function(t,n){var e=l(n=n||{}),a=g("TTFB"),r=c(t,a,vt,n.reportAllChanges);dt((function(){var o=i();if(o){var s=o.responseStart;a.value=Math.max(s-d(),0),a.entries=[o],r(!0),v((function(){a=g("TTFB",0,"back-forward-cache",a.navigationId),(r=c(t,a,vt,n.reportAllChanges))(!0)}));e&&p("soft-navigation",(function(e){e.forEach((function(e){e.navigationId&&((a=g("TTFB",0,"soft-navigation",e.navigationId)).entries=[e],(r=c(t,a,vt,n.reportAllChanges))(!0))}))}),n)}}))},lt=function(t,n){gt((function(n){var e=function(t){var n={waitingDuration:0,cacheDuration:0,dnsDuration:0,connectionDuration:0,requestDuration:0};if(t.entries.length){var e=t.entries[0],i=e.activationStart||0,a=Math.max((e.workerStart||e.fetchStart)-i,0),r=Math.max(e.domainLookupStart-i||0,0),o=Math.max(e.connectStart-i||0,0),c=Math.max(e.connectEnd-i||0,0);n={waitingDuration:a,cacheDuration:r-a,dnsDuration:o-r,connectionDuration:c-o,requestDuration:t.value-c,navigationEntry:e}}return Object.assign(t,{attribution:n})}(n);t(e)}),n)},mt={passive:!0,capture:!0},pt=new Date,ht=function(t,n){it||(it=n,at=t,rt=new Date,yt(removeEventListener),Tt())},Tt=function(){if(at>=0&&at<rt-pt){var t={entryType:"first-input",name:it.type,target:it.target,cancelable:it.cancelable,startTime:it.timeStamp,processingStart:it.timeStamp+at};ot.forEach((function(n){n([t])})),ot=[]}},It=function(t){if(t.cancelable){var n=(t.timeStamp>1e12?new Date:performance.now())-t.timeStamp;"pointerdown"==t.type?function(t,n){var e=function(){ht(t,n),a()},i=function(){a()},a=function(){removeEventListener("pointerup",e,mt),removeEventListener("pointercancel",i,mt)};addEventListener("pointerup",e,mt),addEventListener("pointercancel",i,mt)}(n,t):ht(n,t)}},yt=function(t){["mousedown","keydown","touchstart","pointerdown"].forEach((function(n){return t(n,It,mt)}))},Et=[100,300],St=function(t,n){var e,a=l(n=n||{}),r=(null===(e=i())||void 0===e?void 0:e.navigationId)||"1";w((function(){var e,i=C(),o=g("FID"),s=function(s){s.forEach((function(s){var f,v;a?s.navigationId&&s.navigationId!==o.navigationId&&(f="soft-navigation",v=s.navigationId,"soft-navigation"===f&&(i=C(!0)),o=g("FID",0,f,v),e=c(t,o,Et,n.reportAllChanges)):u.disconnect(),s.startTime<i.firstHiddenTime&&(o.value=s.processingStart-s.startTime,o.entries.push(s),o.navigationId=s.navigationId||r,e(!0))}))},u=p("first-input",s,n);e=c(t,o,Et,n.reportAllChanges),u&&(h((function(){s(u.takeRecords()),a||u.disconnect()})),v((function(){var i;o=g("FID",0,"back-forward-cache",o.navigationId),e=c(t,o,Et,n.reportAllChanges),ot=[],at=-1,it=null,yt(addEventListener),i=s,ot.push(i),Tt()})))}))},bt=function(t,n){St((function(n){var e=function(t){var n=t.entries[0],e={eventTarget:o(n.target),eventType:n.name,eventTime:n.startTime,eventEntry:n,loadState:a(n.startTime)};return Object.assign(t,{attribution:e})}(n);t(e)}),n)};export{D as CLSThresholds,L as FCPThresholds,Et as FIDThresholds,J as INPThresholds,ut as LCPThresholds,vt as TTFBThresholds,k as onCLS,A as onFCP,bt as onFID,st as onINP,ft as onLCP,lt as onTTFB};

@@ -1,1 +0,1 @@

var webVitals=function(n){"use strict";var t,i,e,a,o,r,c=function(n,t,i,e){var a,o;return function(r){t.value>=0&&(r||e)&&((o=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=o,t.rating=function(n,t){return n>t[1]?"poor":n>t[0]?"needs-improvement":"good"}(t.value,i),n(t))}},u=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},s=-1,f=function(n){addEventListener("pageshow",(function(t){t.persisted&&(s=t.timeStamp,n(t))}),!0)},v=function(){var n=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},d=(null===(t=v())||void 0===t?void 0:t.navigationId)||"1",g=function(){var n=v();return n&&n.activationStart||0},l=function(n,t,i,e){var a=v(),o="navigate";i?o=i:s>=0?o="back-forward-cache":a&&(document.prerendering||g()>0?o="prerender":document.wasDiscarded?o="restore":a.type&&(o=a.type.replace(/_/g,"-")));return{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o,navigationId:e||d}},m=function(n){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&n&&n.reportSoftNavs},p=function(n){if(n){var t=window.performance.getEntriesByType("soft-navigation").filter((function(t){return t.navigationId===n}));return t?t[0]:void 0}},h=function(n,t,i){var e=m(i);try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var a=new PerformanceObserver((function(n){Promise.resolve().then((function(){t(n.getEntries())}))}));return a.observe(Object.assign({type:n,buffered:!0,includeSoftNavigationObservations:e},i||{})),a}}catch(n){}},I=function(n){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&n()}))},T=function(n){var t=!1;return function(){t||(n(),t=!0)}},y=-1,E=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},C=function(n){"hidden"===document.visibilityState&&y>-1&&(y="visibilitychange"===n.type?n.timeStamp:0,w())},b=function(){addEventListener("visibilitychange",C,!0),addEventListener("prerenderingchange",C,!0)},w=function(){removeEventListener("visibilitychange",C,!0),removeEventListener("prerenderingchange",C,!0)},S=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(y=-1),y<0&&(y=E(),b(),f((function(){setTimeout((function(){y=E(),b()}),0)}))),{get firstHiddenTime(){return y}}},L=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},A=[1800,3e3],P=function(n,t){var i=m(t=t||{}),e=0;L((function(){var a,o=S(),r=l("FCP"),s=h("paint",(function(u){u.forEach((function(u){if("first-contentful-paint"===u.name){i?u.navigationId&&u.navigationId!==r.navigationId&&function(i,u){if(r=l("FCP",0,i,u),a=c(n,r,A,t.reportAllChanges),"soft-navigation"===i){o=S(!0);var s=u?p(u):null;e=s&&s.startTime||0}}("soft-navigation",u.navigationId):s.disconnect();var f=0;if(u.navigationId&&u.navigationId!==d){var v=p(u.navigationId),m=v&&v.startTime?v.startTime:0;f=Math.max(u.startTime-m,0)}else f=Math.max(u.startTime-g(),0);var h=i&&u.navigationId?p(u.navigationId):null,I=h&&h.startTime?h.startTime:0;(u.startTime<o.firstHiddenTime||i&&u.navigationId&&u.navigationId!==r.navigationId&&u.navigationId!==d&&I>e)&&(r.value=f,r.entries.push(u),r.navigationId=u.navigationId||"1",a(!0))}}))}),t);s&&(a=c(n,r,A,t.reportAllChanges),f((function(i){r=l("FCP",0,"back-forward-cache",r.navigationId),a=c(n,r,A,t.reportAllChanges),u((function(){r.value=performance.now()-i.timeStamp,a(!0)}))})))}))},F=[.1,.25],k=0,M=1/0,D=0,B=d,N=!1,O=function(n){n.forEach((function(n){n.interactionId&&(N&&n.navigationId&&n.navigationId!==B&&(B=n.navigationId,k=0,M=1/0,D=0),M=Math.min(M,n.interactionId),D=Math.max(D,n.interactionId),k=D?(D-M)/7+1:0)}))},x=function(){return i?k:performance.interactionCount||0},R=function(n){"interactionCount"in performance||i||(i=h("event",O,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:N=n||!1}))},H=[],q=new Map,j=0,V=function(){j=x(),H.length=0,q.clear()},_=function(){var n=Math.min(H.length-1,Math.floor((x()-j)/50));return H[n]},z=[],G=function(n){if(z.forEach((function(t){return t(n)})),n.interactionId||"first-input"===n.entryType){var t=H[H.length-1],i=q.get(n.interactionId);if(i||H.length<10||n.duration>t.latency){if(i)n.duration>i.latency?(i.entries=[n],i.latency=n.duration):n.duration===i.latency&&n.startTime===i.entries[0].startTime&&i.entries.push(n);else{var e={id:n.interactionId,latency:n.duration,entries:[n]};q.set(e.id,e),H.push(e)}H.sort((function(n,t){return t.latency-n.latency})),H.length>10&&H.splice(10).forEach((function(n){return q.delete(n.id)}))}}},J=function(n){var t=self.requestIdleCallback||self.setTimeout,i=-1;return n=T(n),"hidden"===document.visibilityState?n():(i=t(n),I(n)),i},K=[200,500],Q=[2500,4e3],U=[800,1800],W=v(),X=function n(t){document.prerendering?L((function(){return n(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return n(t)}),!0):setTimeout(t,0)},Y={passive:!0,capture:!0},Z=new Date,$=function(n,t){e||(e=t,a=n,o=new Date,en(removeEventListener),nn())},nn=function(){if(a>=0&&a<o-Z){var n={entryType:"first-input",name:e.type,target:e.target,cancelable:e.cancelable,startTime:e.timeStamp,processingStart:e.timeStamp+a};r.forEach((function(t){t([n])})),r=[]}},tn=function(n){if(n.cancelable){var t=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,t){var i=function(){$(n,t),a()},e=function(){a()},a=function(){removeEventListener("pointerup",i,Y),removeEventListener("pointercancel",e,Y)};addEventListener("pointerup",i,Y),addEventListener("pointercancel",e,Y)}(t,n):$(t,n)}},en=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return n(t,tn,Y)}))},an=[100,300];return n.CLSThresholds=F,n.FCPThresholds=A,n.FIDThresholds=an,n.INPThresholds=K,n.LCPThresholds=Q,n.TTFBThresholds=U,n.onCLS=function(n,t){var i=m(t=t||{}),e=!1,a=0;P(T((function(){var o,r=l("CLS",0),s=0,v=[],d=function(i,u){if(r=l("CLS",0,i,u),o=c(n,r,F,t.reportAllChanges),s=0,e=!1,"soft-navigation"===i){var f=p(u);a=f&&f.startTime||0}},g=function(n){n.forEach((function(n){if(i&&n.navigationId&&n.navigationId!==r.navigationId&&(s>r.value&&(r.value=s,r.entries=v),o(!0),d("soft-navigation",n.navigationId)),!n.hadRecentInput){var t=v[0],e=v[v.length-1];s&&n.startTime-e.startTime<1e3&&n.startTime-t.startTime<5e3?(s+=n.value,v.push(n)):(s=n.value,v=[n])}})),s>r.value&&(r.value=s,r.entries=v,o())},m=h("layout-shift",g,t);if(m){o=c(n,r,F,t.reportAllChanges),I((function(){g(m.takeRecords()),o(!0),e=!0})),f((function(){d("back-forward-cache",r.navigationId),u((function(){return o()}))}));i&&h("soft-navigation",(function(i){i.forEach((function(i){var u=i.navigationId,s=u?p(u):null;u&&u!==r.navigationId&&s&&(s.startTime||0)>a&&(e||o(!0),d("soft-navigation",i.navigationId),o=c(n,r,F,t.reportAllChanges))}))}),t),setTimeout(o,0)}})))},n.onFCP=P,n.onFID=function(n,t){var i=m(t=t||{});L((function(){var o,u=S(),s=l("FID"),v=function(e){e.forEach((function(e){var a,r;i?e.navigationId&&e.navigationId!==s.navigationId&&(a="soft-navigation",r=e.navigationId,"soft-navigation"===a&&(u=S(!0)),s=l("FID",0,a,r),o=c(n,s,an,t.reportAllChanges)):g.disconnect(),e.startTime<u.firstHiddenTime&&(s.value=e.processingStart-e.startTime,s.entries.push(e),s.navigationId=e.navigationId||d,o(!0))}))},g=h("first-input",v,t);o=c(n,s,an,t.reportAllChanges),g&&(I((function(){v(g.takeRecords()),i||g.disconnect()})),f((function(){var i;s=l("FID",0,"back-forward-cache",s.navigationId),o=c(n,s,an,t.reportAllChanges),r=[],a=-1,e=null,en(addEventListener),i=v,r.push(i),nn()})))}))},n.onINP=function(n,t){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var i=m(t=t||{}),e=!1,a=0;L((function(){var o;R(i);var r,s=l("INP"),v=function(i,o){if(V(),s=l("INP",0,i,o),r=c(n,s,K,t.reportAllChanges),e=!1,"soft-navigation"===i){var u=p(o);a=u&&u.startTime?u.startTime:0}},d=function(n){J((function(){var i;n.forEach(G),(i=_())&&(i.latency!==s.value||t&&t.reportAllChanges)&&(s.value=i.latency,s.entries=i.entries),r()}))},g=h("event",d,{durationThreshold:null!==(o=t.durationThreshold)&&void 0!==o?o:40,opts:t});if(r=c(n,s,K,t.reportAllChanges),g){g.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:i}),I((function(){d(g.takeRecords()),r(!0)})),f((function(){V(),v("back-forward-cache",s.navigationId),u((function(){return r()}))}));i&&h("soft-navigation",(function(i){i.forEach((function(i){var o=p(i.navigationId),u=o&&o.startTime?o.startTime:0;i.navigationId&&i.navigationId!==s.navigationId&&u>a&&(!e&&s.value>0&&r(!0),v("soft-navigation",i.navigationId),r=c(n,s,K,t.reportAllChanges))}))}),t)}}))}},n.onLCP=function(n,t){var i=!1,e=m(t=t||{}),a=0;L((function(){var o,r=S(),s=l("LCP"),v=function(e,u){if(s=l("LCP",0,e,u),o=c(n,s,Q,t.reportAllChanges),i=!1,"soft-navigation"===e){r=S(!0);var f=p(u);a=f&&f.startTime?f.startTime:0}["keydown","click"].forEach((function(n){addEventListener(n,(function(){return J(T)}),{once:!0})}))},m=function(n){n.forEach((function(n){if(n){e&&n.navigationId&&n.navigationId!==s.navigationId&&(i||o(!0),v("soft-navigation",n.navigationId));var t=0;if(n.navigationId&&n.navigationId!==d){var a=p(n.navigationId),c=a&&a.startTime?a.startTime:0;t=Math.max(n.startTime-c,0)}else t=Math.max(n.startTime-g(),0);n.startTime<r.firstHiddenTime&&(s.value=t,s.entries=[n],s.navigationId=n.navigationId||d,o())}}))},T=function(){i||(m(y.takeRecords()),e||y.disconnect(),i=!0,o(!0))},y=h("largest-contentful-paint",m,t);if(y){o=c(n,s,Q,t.reportAllChanges),I(T),f((function(n){v("back-forward-cache",s.navigationId),u((function(){s.value=performance.now()-n.timeStamp,i=!0,o(!0)}))}));e&&h("soft-navigation",(function(n){n.forEach((function(n){var t=n.navigationId?p(n.navigationId):null;n.navigationId&&n.navigationId!==s.navigationId&&t&&(t.startTime||0)>a&&(i||o(!0),v("soft-navigation",n.navigationId))}))}),t)}}))},n.onTTFB=function(n,t){var i=m(t=t||{}),e=l("TTFB"),a=c(n,e,U,t.reportAllChanges);X((function(){if(W){var o=W.responseStart;e.value=Math.max(o-g(),0),e.entries=[W],a(!0),f((function(){e=l("TTFB",0,"back-forward-cache",e.navigationId),(a=c(n,e,U,t.reportAllChanges))(!0)}));i&&h("soft-navigation",(function(i){i.forEach((function(i){i.navigationId&&((e=l("TTFB",0,"soft-navigation",i.navigationId)).entries=[i],(a=c(n,e,U,t.reportAllChanges))(!0))}))}),t)}}))},n}({});
var webVitals=function(n){"use strict";var t,i,e,a,o,r=function(n,t,i,e){var a,o;return function(r){t.value>=0&&(r||e)&&((o=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=o,t.rating=function(n,t){return n>t[1]?"poor":n>t[0]?"needs-improvement":"good"}(t.value,i),n(t))}},c=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},u=-1,v=function(n){addEventListener("pageshow",(function(t){t.persisted&&(u=t.timeStamp,n(t))}),!0)},f=function(){var n=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},s=function(){var n=f();return n&&n.activationStart||0},d=function(n,t,i,e){var a,o=(null===(a=f())||void 0===a?void 0:a.navigationId)||"1",r=f(),c="navigate";i?c=i:u>=0?c="back-forward-cache":r&&(document.prerendering||s()>0?c="prerender":document.wasDiscarded?c="restore":r.type&&(c=r.type.replace(/_/g,"-")));return{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:c,navigationId:e||o}},g=function(n){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&n&&n.reportSoftNavs},l=function(n){if(n){var t=window.performance.getEntriesByType("soft-navigation").filter((function(t){return t.navigationId===n}));return t?t[0]:void 0}},m=function(n,t,i){var e=g(i);try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var a=new PerformanceObserver((function(n){Promise.resolve().then((function(){t(n.getEntries())}))}));return a.observe(Object.assign({type:n,buffered:!0,includeSoftNavigationObservations:e},i||{})),a}}catch(n){}},p=function(n){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&n()}))},h=function(n){var t=!1;return function(){t||(n(),t=!0)}},I=-1,T=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},y=function(n){"hidden"===document.visibilityState&&I>-1&&(I="visibilitychange"===n.type?n.timeStamp:0,C())},E=function(){addEventListener("visibilitychange",y,!0),addEventListener("prerenderingchange",y,!0)},C=function(){removeEventListener("visibilitychange",y,!0),removeEventListener("prerenderingchange",y,!0)},b=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(I=-1),I<0&&(I=T(),E(),v((function(){setTimeout((function(){I=T(),E()}),0)}))),{get firstHiddenTime(){return I}}},w=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},S=[1800,3e3],L=function(n,t){var i,e=g(t=t||{}),a=0,o=(null===(i=f())||void 0===i?void 0:i.navigationId)||"1";w((function(){var i,u=b(),f=d("FCP"),g=m("paint",(function(c){c.forEach((function(c){if("first-contentful-paint"===c.name){e?c.navigationId&&c.navigationId!==f.navigationId&&function(e,o){if(f=d("FCP",0,e,o),i=r(n,f,S,t.reportAllChanges),"soft-navigation"===e){u=b(!0);var c=o?l(o):null;a=c&&c.startTime||0}}("soft-navigation",c.navigationId):g.disconnect();var v=0;if(c.navigationId&&c.navigationId!==o){var m=l(c.navigationId),p=m&&m.startTime?m.startTime:0;v=Math.max(c.startTime-p,0)}else v=Math.max(c.startTime-s(),0);var h=e&&c.navigationId?l(c.navigationId):null,I=h&&h.startTime?h.startTime:0;(c.startTime<u.firstHiddenTime||e&&c.navigationId&&c.navigationId!==f.navigationId&&c.navigationId!==o&&I>a)&&(f.value=v,f.entries.push(c),f.navigationId=c.navigationId||"1",i(!0))}}))}),t);g&&(i=r(n,f,S,t.reportAllChanges),v((function(e){f=d("FCP",0,"back-forward-cache",f.navigationId),i=r(n,f,S,t.reportAllChanges),c((function(){f.value=performance.now()-e.timeStamp,i(!0)}))})))}))},A=[.1,.25],P=0,k=1/0,F=0,M="",D=!1,B=function(n){var t;M||(M=(null===(t=f())||void 0===t?void 0:t.navigationId)||"1"),n.forEach((function(n){n.interactionId&&(D&&n.navigationId&&n.navigationId!==M&&(M=n.navigationId,P=0,k=1/0,F=0),k=Math.min(k,n.interactionId),F=Math.max(F,n.interactionId),P=F?(F-k)/7+1:0)}))},N=function(){return t?P:performance.interactionCount||0},O=function(n){"interactionCount"in performance||t||(t=m("event",B,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:D=n||!1}))},x=[],R=new Map,H=0,q=function(){H=N(),x.length=0,R.clear()},j=function(){var n=Math.min(x.length-1,Math.floor((N()-H)/50));return x[n]},V=[],_=function(n){if(V.forEach((function(t){return t(n)})),n.interactionId||"first-input"===n.entryType){var t=x[x.length-1],i=R.get(n.interactionId);if(i||x.length<10||n.duration>t.latency){if(i)n.duration>i.latency?(i.entries=[n],i.latency=n.duration):n.duration===i.latency&&n.startTime===i.entries[0].startTime&&i.entries.push(n);else{var e={id:n.interactionId,latency:n.duration,entries:[n]};R.set(e.id,e),x.push(e)}x.sort((function(n,t){return t.latency-n.latency})),x.length>10&&x.splice(10).forEach((function(n){return R.delete(n.id)}))}}},z=function(n){var t=self.requestIdleCallback||self.setTimeout,i=-1;return n=h(n),"hidden"===document.visibilityState?n():(i=t(n),p(n)),i},G=[200,500],J=[2500,4e3],K=[800,1800],Q=function n(t){document.prerendering?w((function(){return n(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return n(t)}),!0):setTimeout(t,0)},U={passive:!0,capture:!0},W=new Date,X=function(n,t){i||(i=t,e=n,a=new Date,$(removeEventListener),Y())},Y=function(){if(e>=0&&e<a-W){var n={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+e};o.forEach((function(t){t([n])})),o=[]}},Z=function(n){if(n.cancelable){var t=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,t){var i=function(){X(n,t),a()},e=function(){a()},a=function(){removeEventListener("pointerup",i,U),removeEventListener("pointercancel",e,U)};addEventListener("pointerup",i,U),addEventListener("pointercancel",e,U)}(t,n):X(t,n)}},$=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return n(t,Z,U)}))},nn=[100,300];return n.CLSThresholds=A,n.FCPThresholds=S,n.FIDThresholds=nn,n.INPThresholds=G,n.LCPThresholds=J,n.TTFBThresholds=K,n.onCLS=function(n,t){var i=g(t=t||{}),e=!1,a=0;L(h((function(){var o,u=d("CLS",0),f=0,s=[],g=function(i,c){if(u=d("CLS",0,i,c),o=r(n,u,A,t.reportAllChanges),f=0,e=!1,"soft-navigation"===i){var v=l(c);a=v&&v.startTime||0}},h=function(n){n.forEach((function(n){if(i&&n.navigationId&&n.navigationId!==u.navigationId&&(f>u.value&&(u.value=f,u.entries=s),o(!0),g("soft-navigation",n.navigationId)),!n.hadRecentInput){var t=s[0],e=s[s.length-1];f&&n.startTime-e.startTime<1e3&&n.startTime-t.startTime<5e3?(f+=n.value,s.push(n)):(f=n.value,s=[n])}})),f>u.value&&(u.value=f,u.entries=s,o())},I=m("layout-shift",h,t);if(I){o=r(n,u,A,t.reportAllChanges),p((function(){h(I.takeRecords()),o(!0),e=!0})),v((function(){g("back-forward-cache",u.navigationId),c((function(){return o()}))}));i&&m("soft-navigation",(function(i){i.forEach((function(i){var c=i.navigationId,v=c?l(c):null;c&&c!==u.navigationId&&v&&(v.startTime||0)>a&&(e||o(!0),g("soft-navigation",i.navigationId),o=r(n,u,A,t.reportAllChanges))}))}),t),setTimeout(o,0)}})))},n.onFCP=L,n.onFID=function(n,t){var a,c=g(t=t||{}),u=(null===(a=f())||void 0===a?void 0:a.navigationId)||"1";w((function(){var a,f=b(),s=d("FID"),g=function(i){i.forEach((function(i){var e,o;c?i.navigationId&&i.navigationId!==s.navigationId&&(e="soft-navigation",o=i.navigationId,"soft-navigation"===e&&(f=b(!0)),s=d("FID",0,e,o),a=r(n,s,nn,t.reportAllChanges)):l.disconnect(),i.startTime<f.firstHiddenTime&&(s.value=i.processingStart-i.startTime,s.entries.push(i),s.navigationId=i.navigationId||u,a(!0))}))},l=m("first-input",g,t);a=r(n,s,nn,t.reportAllChanges),l&&(p((function(){g(l.takeRecords()),c||l.disconnect()})),v((function(){var c;s=d("FID",0,"back-forward-cache",s.navigationId),a=r(n,s,nn,t.reportAllChanges),o=[],e=-1,i=null,$(addEventListener),c=g,o.push(c),Y()})))}))},n.onINP=function(n,t){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var i=g(t=t||{}),e=!1,a=0;w((function(){var o;O(i);var u,f=d("INP"),s=function(i,o){if(q(),f=d("INP",0,i,o),u=r(n,f,G,t.reportAllChanges),e=!1,"soft-navigation"===i){var c=l(o);a=c&&c.startTime?c.startTime:0}},g=function(n){z((function(){var i;n.forEach(_),(i=j())&&(i.latency!==f.value||t&&t.reportAllChanges)&&(f.value=i.latency,f.entries=i.entries),u()}))},h=m("event",g,{durationThreshold:null!==(o=t.durationThreshold)&&void 0!==o?o:40,opts:t});if(u=r(n,f,G,t.reportAllChanges),h){h.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:i}),p((function(){g(h.takeRecords()),u(!0)})),v((function(){q(),s("back-forward-cache",f.navigationId),c((function(){return u()}))}));i&&m("soft-navigation",(function(i){i.forEach((function(i){var o=l(i.navigationId),c=o&&o.startTime?o.startTime:0;i.navigationId&&i.navigationId!==f.navigationId&&c>a&&(!e&&f.value>0&&u(!0),s("soft-navigation",i.navigationId),u=r(n,f,G,t.reportAllChanges))}))}),t)}}))}},n.onLCP=function(n,t){var i,e=!1,a=g(t=t||{}),o=0,u=(null===(i=f())||void 0===i?void 0:i.navigationId)||"1",h="";w((function(){var i,f=b(),g=d("LCP"),I=function(a,c){if(g=d("LCP",0,a,c),i=r(n,g,J,t.reportAllChanges),e=!1,"soft-navigation"===a){f=b(!0);var u=l(c);o=u&&u.startTime?u.startTime:0}E()},T=function(n){n.forEach((function(n){if(n){a&&n.navigationId&&n.navigationId!==g.navigationId&&(e||i(!0),I("soft-navigation",n.navigationId));var t=0;if(n.navigationId&&n.navigationId!==u){var o=l(n.navigationId),r=o&&o.startTime?o.startTime:0;t=Math.max(n.startTime-r,0)}else t=Math.max(n.startTime-s(),0);n.startTime<f.firstHiddenTime&&(g.value=t,g.entries=[n],g.navigationId=n.navigationId||u,i())}}))},y=function(){C(),e||(T(S.takeRecords()),a||S.disconnect(),g.navigationId===h&&(e=!0,i(!0)))},E=function(){["keydown","click"].forEach((function(n){addEventListener(n,(function(){return w()}),!0)}))},C=function(){["keydown","click"].forEach((function(n){removeEventListener(n,(function(){return w()}),!0)}))},w=function(){h=g.navigationId,z(y)},S=m("largest-contentful-paint",T,t);if(S){i=r(n,g,J,t.reportAllChanges),E(),p((function(){h=g.navigationId,y()})),v((function(n){I("back-forward-cache",g.navigationId),c((function(){g.value=performance.now()-n.timeStamp,e=!0,i(!0)}))}));a&&m("soft-navigation",(function(n){n.forEach((function(n){var t=n.navigationId?l(n.navigationId):null;n.navigationId&&n.navigationId!==g.navigationId&&t&&(t.startTime||0)>o&&(e||i(!0),I("soft-navigation",n.navigationId))}))}),t)}}))},n.onTTFB=function(n,t){var i=g(t=t||{}),e=d("TTFB"),a=r(n,e,K,t.reportAllChanges);Q((function(){var o=f();if(o){var c=o.responseStart;e.value=Math.max(c-s(),0),e.entries=[o],a(!0),v((function(){e=d("TTFB",0,"back-forward-cache",e.navigationId),(a=r(n,e,K,t.reportAllChanges))(!0)}));i&&m("soft-navigation",(function(i){i.forEach((function(i){i.navigationId&&((e=d("TTFB",0,"soft-navigation",i.navigationId)).entries=[i],(a=r(n,e,K,t.reportAllChanges))(!0))}))}),t)}}))},n}({});

@@ -1,1 +0,1 @@

var n,t,i,e,a,r,o=function(n,t,i,e){var a,r;return function(o){t.value>=0&&(o||e)&&((r=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=r,t.rating=function(n,t){return n>t[1]?"poor":n>t[0]?"needs-improvement":"good"}(t.value,i),n(t))}},c=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},u=-1,f=function(n){addEventListener("pageshow",(function(t){t.persisted&&(u=t.timeStamp,n(t))}),!0)},v=function(){var n=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},s=(null===(n=v())||void 0===n?void 0:n.navigationId)||"1",d=function(){var n=v();return n&&n.activationStart||0},g=function(n,t,i,e){var a=v(),r="navigate";i?r=i:u>=0?r="back-forward-cache":a&&(document.prerendering||d()>0?r="prerender":document.wasDiscarded?r="restore":a.type&&(r=a.type.replace(/_/g,"-")));return{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:r,navigationId:e||s}},l=function(n){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&n&&n.reportSoftNavs},m=function(n){if(n){var t=window.performance.getEntriesByType("soft-navigation").filter((function(t){return t.navigationId===n}));return t?t[0]:void 0}},p=function(n,t,i){var e=l(i);try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var a=new PerformanceObserver((function(n){Promise.resolve().then((function(){t(n.getEntries())}))}));return a.observe(Object.assign({type:n,buffered:!0,includeSoftNavigationObservations:e},i||{})),a}}catch(n){}},h=function(n){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&n()}))},I=function(n){var t=!1;return function(){t||(n(),t=!0)}},T=-1,y=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},E=function(n){"hidden"===document.visibilityState&&T>-1&&(T="visibilitychange"===n.type?n.timeStamp:0,C())},b=function(){addEventListener("visibilitychange",E,!0),addEventListener("prerenderingchange",E,!0)},C=function(){removeEventListener("visibilitychange",E,!0),removeEventListener("prerenderingchange",E,!0)},w=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(T=-1),T<0&&(T=y(),b(),f((function(){setTimeout((function(){T=y(),b()}),0)}))),{get firstHiddenTime(){return T}}},S=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},A=[1800,3e3],L=function(n,t){var i=l(t=t||{}),e=0;S((function(){var a,r=w(),u=g("FCP"),v=p("paint",(function(c){c.forEach((function(c){if("first-contentful-paint"===c.name){i?c.navigationId&&c.navigationId!==u.navigationId&&function(i,c){if(u=g("FCP",0,i,c),a=o(n,u,A,t.reportAllChanges),"soft-navigation"===i){r=w(!0);var f=c?m(c):null;e=f&&f.startTime||0}}("soft-navigation",c.navigationId):v.disconnect();var f=0;if(c.navigationId&&c.navigationId!==s){var l=m(c.navigationId),p=l&&l.startTime?l.startTime:0;f=Math.max(c.startTime-p,0)}else f=Math.max(c.startTime-d(),0);var h=i&&c.navigationId?m(c.navigationId):null,I=h&&h.startTime?h.startTime:0;(c.startTime<r.firstHiddenTime||i&&c.navigationId&&c.navigationId!==u.navigationId&&c.navigationId!==s&&I>e)&&(u.value=f,u.entries.push(c),u.navigationId=c.navigationId||"1",a(!0))}}))}),t);v&&(a=o(n,u,A,t.reportAllChanges),f((function(i){u=g("FCP",0,"back-forward-cache",u.navigationId),a=o(n,u,A,t.reportAllChanges),c((function(){u.value=performance.now()-i.timeStamp,a(!0)}))})))}))},k=[.1,.25],P=function(n,t){var i=l(t=t||{}),e=!1,a=0;L(I((function(){var r,u=g("CLS",0),v=0,s=[],d=function(i,c){if(u=g("CLS",0,i,c),r=o(n,u,k,t.reportAllChanges),v=0,e=!1,"soft-navigation"===i){var f=m(c);a=f&&f.startTime||0}},l=function(n){n.forEach((function(n){if(i&&n.navigationId&&n.navigationId!==u.navigationId&&(v>u.value&&(u.value=v,u.entries=s),r(!0),d("soft-navigation",n.navigationId)),!n.hadRecentInput){var t=s[0],e=s[s.length-1];v&&n.startTime-e.startTime<1e3&&n.startTime-t.startTime<5e3?(v+=n.value,s.push(n)):(v=n.value,s=[n])}})),v>u.value&&(u.value=v,u.entries=s,r())},I=p("layout-shift",l,t);if(I){r=o(n,u,k,t.reportAllChanges),h((function(){l(I.takeRecords()),r(!0),e=!0})),f((function(){d("back-forward-cache",u.navigationId),c((function(){return r()}))}));i&&p("soft-navigation",(function(i){i.forEach((function(i){var c=i.navigationId,f=c?m(c):null;c&&c!==u.navigationId&&f&&(f.startTime||0)>a&&(e||r(!0),d("soft-navigation",i.navigationId),r=o(n,u,k,t.reportAllChanges))}))}),t),setTimeout(r,0)}})))},M=0,F=1/0,D=0,x=s,O=!1,B=function(n){n.forEach((function(n){n.interactionId&&(O&&n.navigationId&&n.navigationId!==x&&(x=n.navigationId,M=0,F=1/0,D=0),F=Math.min(F,n.interactionId),D=Math.max(D,n.interactionId),M=D?(D-F)/7+1:0)}))},N=function(){return t?M:performance.interactionCount||0},R=function(n){"interactionCount"in performance||t||(t=p("event",B,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:O=n||!1}))},H=[],q=new Map,j=0,_=function(){j=N(),H.length=0,q.clear()},z=function(){var n=Math.min(H.length-1,Math.floor((N()-j)/50));return H[n]},G=[],J=function(n){if(G.forEach((function(t){return t(n)})),n.interactionId||"first-input"===n.entryType){var t=H[H.length-1],i=q.get(n.interactionId);if(i||H.length<10||n.duration>t.latency){if(i)n.duration>i.latency?(i.entries=[n],i.latency=n.duration):n.duration===i.latency&&n.startTime===i.entries[0].startTime&&i.entries.push(n);else{var e={id:n.interactionId,latency:n.duration,entries:[n]};q.set(e.id,e),H.push(e)}H.sort((function(n,t){return t.latency-n.latency})),H.length>10&&H.splice(10).forEach((function(n){return q.delete(n.id)}))}}},K=function(n){var t=self.requestIdleCallback||self.setTimeout,i=-1;return n=I(n),"hidden"===document.visibilityState?n():(i=t(n),h(n)),i},Q=[200,500],U=function(n,t){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var i=l(t=t||{}),e=!1,a=0;S((function(){var r;R(i);var u,v=g("INP"),s=function(i,r){if(_(),v=g("INP",0,i,r),u=o(n,v,Q,t.reportAllChanges),e=!1,"soft-navigation"===i){var c=m(r);a=c&&c.startTime?c.startTime:0}},d=function(n){K((function(){var i;n.forEach(J),(i=z())&&(i.latency!==v.value||t&&t.reportAllChanges)&&(v.value=i.latency,v.entries=i.entries),u()}))},l=p("event",d,{durationThreshold:null!==(r=t.durationThreshold)&&void 0!==r?r:40,opts:t});if(u=o(n,v,Q,t.reportAllChanges),l){l.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:i}),h((function(){d(l.takeRecords()),u(!0)})),f((function(){_(),s("back-forward-cache",v.navigationId),c((function(){return u()}))}));i&&p("soft-navigation",(function(i){i.forEach((function(i){var r=m(i.navigationId),c=r&&r.startTime?r.startTime:0;i.navigationId&&i.navigationId!==v.navigationId&&c>a&&(!e&&v.value>0&&u(!0),s("soft-navigation",i.navigationId),u=o(n,v,Q,t.reportAllChanges))}))}),t)}}))}},V=[2500,4e3],W=function(n,t){var i=!1,e=l(t=t||{}),a=0;S((function(){var r,u=w(),v=g("LCP"),l=function(e,c){if(v=g("LCP",0,e,c),r=o(n,v,V,t.reportAllChanges),i=!1,"soft-navigation"===e){u=w(!0);var f=m(c);a=f&&f.startTime?f.startTime:0}["keydown","click"].forEach((function(n){addEventListener(n,(function(){return K(T)}),{once:!0})}))},I=function(n){n.forEach((function(n){if(n){e&&n.navigationId&&n.navigationId!==v.navigationId&&(i||r(!0),l("soft-navigation",n.navigationId));var t=0;if(n.navigationId&&n.navigationId!==s){var a=m(n.navigationId),o=a&&a.startTime?a.startTime:0;t=Math.max(n.startTime-o,0)}else t=Math.max(n.startTime-d(),0);n.startTime<u.firstHiddenTime&&(v.value=t,v.entries=[n],v.navigationId=n.navigationId||s,r())}}))},T=function(){i||(I(y.takeRecords()),e||y.disconnect(),i=!0,r(!0))},y=p("largest-contentful-paint",I,t);if(y){r=o(n,v,V,t.reportAllChanges),h(T),f((function(n){l("back-forward-cache",v.navigationId),c((function(){v.value=performance.now()-n.timeStamp,i=!0,r(!0)}))}));e&&p("soft-navigation",(function(n){n.forEach((function(n){var t=n.navigationId?m(n.navigationId):null;n.navigationId&&n.navigationId!==v.navigationId&&t&&(t.startTime||0)>a&&(i||r(!0),l("soft-navigation",n.navigationId))}))}),t)}}))},X=[800,1800],Y=v(),Z=function n(t){document.prerendering?S((function(){return n(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return n(t)}),!0):setTimeout(t,0)},$=function(n,t){var i=l(t=t||{}),e=g("TTFB"),a=o(n,e,X,t.reportAllChanges);Z((function(){if(Y){var r=Y.responseStart;e.value=Math.max(r-d(),0),e.entries=[Y],a(!0),f((function(){e=g("TTFB",0,"back-forward-cache",e.navigationId),(a=o(n,e,X,t.reportAllChanges))(!0)}));i&&p("soft-navigation",(function(i){i.forEach((function(i){i.navigationId&&((e=g("TTFB",0,"soft-navigation",i.navigationId)).entries=[i],(a=o(n,e,X,t.reportAllChanges))(!0))}))}),t)}}))},nn={passive:!0,capture:!0},tn=new Date,en=function(n,t){i||(i=t,e=n,a=new Date,on(removeEventListener),an())},an=function(){if(e>=0&&e<a-tn){var n={entryType:"first-input",name:i.type,target:i.target,cancelable:i.cancelable,startTime:i.timeStamp,processingStart:i.timeStamp+e};r.forEach((function(t){t([n])})),r=[]}},rn=function(n){if(n.cancelable){var t=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,t){var i=function(){en(n,t),a()},e=function(){a()},a=function(){removeEventListener("pointerup",i,nn),removeEventListener("pointercancel",e,nn)};addEventListener("pointerup",i,nn),addEventListener("pointercancel",e,nn)}(t,n):en(t,n)}},on=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return n(t,rn,nn)}))},cn=[100,300],un=function(n,t){var a=l(t=t||{});S((function(){var c,u=w(),v=g("FID"),d=function(i){i.forEach((function(i){var e,r;a?i.navigationId&&i.navigationId!==v.navigationId&&(e="soft-navigation",r=i.navigationId,"soft-navigation"===e&&(u=w(!0)),v=g("FID",0,e,r),c=o(n,v,cn,t.reportAllChanges)):l.disconnect(),i.startTime<u.firstHiddenTime&&(v.value=i.processingStart-i.startTime,v.entries.push(i),v.navigationId=i.navigationId||s,c(!0))}))},l=p("first-input",d,t);c=o(n,v,cn,t.reportAllChanges),l&&(h((function(){d(l.takeRecords()),a||l.disconnect()})),f((function(){var a;v=g("FID",0,"back-forward-cache",v.navigationId),c=o(n,v,cn,t.reportAllChanges),r=[],e=-1,i=null,on(addEventListener),a=d,r.push(a),an()})))}))};export{k as CLSThresholds,A as FCPThresholds,cn as FIDThresholds,Q as INPThresholds,V as LCPThresholds,X as TTFBThresholds,P as onCLS,L as onFCP,un as onFID,U as onINP,W as onLCP,$ as onTTFB};
var n,t,i,e,a,o=function(n,t,i,e){var a,o;return function(r){t.value>=0&&(r||e)&&((o=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=o,t.rating=function(n,t){return n>t[1]?"poor":n>t[0]?"needs-improvement":"good"}(t.value,i),n(t))}},r=function(n){requestAnimationFrame((function(){return requestAnimationFrame((function(){return n()}))}))},c=-1,u=function(n){addEventListener("pageshow",(function(t){t.persisted&&(c=t.timeStamp,n(t))}),!0)},v=function(){var n=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(n&&n.responseStart>0&&n.responseStart<performance.now())return n},f=function(){var n=v();return n&&n.activationStart||0},d=function(n,t,i,e){var a,o=(null===(a=v())||void 0===a?void 0:a.navigationId)||"1",r=v(),u="navigate";i?u=i:c>=0?u="back-forward-cache":r&&(document.prerendering||f()>0?u="prerender":document.wasDiscarded?u="restore":r.type&&(u=r.type.replace(/_/g,"-")));return{name:n,value:void 0===t?-1:t,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:u,navigationId:e||o}},s=function(n){return PerformanceObserver.supportedEntryTypes.includes("soft-navigation")&&n&&n.reportSoftNavs},g=function(n){if(n){var t=window.performance.getEntriesByType("soft-navigation").filter((function(t){return t.navigationId===n}));return t?t[0]:void 0}},l=function(n,t,i){var e=s(i);try{if(PerformanceObserver.supportedEntryTypes.includes(n)){var a=new PerformanceObserver((function(n){Promise.resolve().then((function(){t(n.getEntries())}))}));return a.observe(Object.assign({type:n,buffered:!0,includeSoftNavigationObservations:e},i||{})),a}}catch(n){}},m=function(n){document.addEventListener("visibilitychange",(function(){"hidden"===document.visibilityState&&n()}))},p=function(n){var t=!1;return function(){t||(n(),t=!0)}},h=-1,I=function(){return"hidden"!==document.visibilityState||document.prerendering?1/0:0},T=function(n){"hidden"===document.visibilityState&&h>-1&&(h="visibilitychange"===n.type?n.timeStamp:0,E())},y=function(){addEventListener("visibilitychange",T,!0),addEventListener("prerenderingchange",T,!0)},E=function(){removeEventListener("visibilitychange",T,!0),removeEventListener("prerenderingchange",T,!0)},b=function(){return arguments.length>0&&void 0!==arguments[0]&&arguments[0]&&(h=-1),h<0&&(h=I(),y(),u((function(){setTimeout((function(){h=I(),y()}),0)}))),{get firstHiddenTime(){return h}}},C=function(n){document.prerendering?addEventListener("prerenderingchange",(function(){return n()}),!0):n()},w=[1800,3e3],S=function(n,t){var i,e=s(t=t||{}),a=0,c=(null===(i=v())||void 0===i?void 0:i.navigationId)||"1";C((function(){var i,v=b(),s=d("FCP"),m=l("paint",(function(r){r.forEach((function(r){if("first-contentful-paint"===r.name){e?r.navigationId&&r.navigationId!==s.navigationId&&function(e,r){if(s=d("FCP",0,e,r),i=o(n,s,w,t.reportAllChanges),"soft-navigation"===e){v=b(!0);var c=r?g(r):null;a=c&&c.startTime||0}}("soft-navigation",r.navigationId):m.disconnect();var u=0;if(r.navigationId&&r.navigationId!==c){var l=g(r.navigationId),p=l&&l.startTime?l.startTime:0;u=Math.max(r.startTime-p,0)}else u=Math.max(r.startTime-f(),0);var h=e&&r.navigationId?g(r.navigationId):null,I=h&&h.startTime?h.startTime:0;(r.startTime<v.firstHiddenTime||e&&r.navigationId&&r.navigationId!==s.navigationId&&r.navigationId!==c&&I>a)&&(s.value=u,s.entries.push(r),s.navigationId=r.navigationId||"1",i(!0))}}))}),t);m&&(i=o(n,s,w,t.reportAllChanges),u((function(e){s=d("FCP",0,"back-forward-cache",s.navigationId),i=o(n,s,w,t.reportAllChanges),r((function(){s.value=performance.now()-e.timeStamp,i(!0)}))})))}))},A=[.1,.25],L=function(n,t){var i=s(t=t||{}),e=!1,a=0;S(p((function(){var c,v=d("CLS",0),f=0,s=[],p=function(i,r){if(v=d("CLS",0,i,r),c=o(n,v,A,t.reportAllChanges),f=0,e=!1,"soft-navigation"===i){var u=g(r);a=u&&u.startTime||0}},h=function(n){n.forEach((function(n){if(i&&n.navigationId&&n.navigationId!==v.navigationId&&(f>v.value&&(v.value=f,v.entries=s),c(!0),p("soft-navigation",n.navigationId)),!n.hadRecentInput){var t=s[0],e=s[s.length-1];f&&n.startTime-e.startTime<1e3&&n.startTime-t.startTime<5e3?(f+=n.value,s.push(n)):(f=n.value,s=[n])}})),f>v.value&&(v.value=f,v.entries=s,c())},I=l("layout-shift",h,t);if(I){c=o(n,v,A,t.reportAllChanges),m((function(){h(I.takeRecords()),c(!0),e=!0})),u((function(){p("back-forward-cache",v.navigationId),r((function(){return c()}))}));i&&l("soft-navigation",(function(i){i.forEach((function(i){var r=i.navigationId,u=r?g(r):null;r&&r!==v.navigationId&&u&&(u.startTime||0)>a&&(e||c(!0),p("soft-navigation",i.navigationId),c=o(n,v,A,t.reportAllChanges))}))}),t),setTimeout(c,0)}})))},k=0,P=1/0,M=0,F="",D=!1,x=function(n){var t;F||(F=(null===(t=v())||void 0===t?void 0:t.navigationId)||"1"),n.forEach((function(n){n.interactionId&&(D&&n.navigationId&&n.navigationId!==F&&(F=n.navigationId,k=0,P=1/0,M=0),P=Math.min(P,n.interactionId),M=Math.max(M,n.interactionId),k=M?(M-P)/7+1:0)}))},O=function(){return n?k:performance.interactionCount||0},B=function(t){"interactionCount"in performance||n||(n=l("event",x,{type:"event",buffered:!0,durationThreshold:0,includeSoftNavigationObservations:D=t||!1}))},N=[],R=new Map,H=0,q=function(){H=O(),N.length=0,R.clear()},j=function(){var n=Math.min(N.length-1,Math.floor((O()-H)/50));return N[n]},_=[],z=function(n){if(_.forEach((function(t){return t(n)})),n.interactionId||"first-input"===n.entryType){var t=N[N.length-1],i=R.get(n.interactionId);if(i||N.length<10||n.duration>t.latency){if(i)n.duration>i.latency?(i.entries=[n],i.latency=n.duration):n.duration===i.latency&&n.startTime===i.entries[0].startTime&&i.entries.push(n);else{var e={id:n.interactionId,latency:n.duration,entries:[n]};R.set(e.id,e),N.push(e)}N.sort((function(n,t){return t.latency-n.latency})),N.length>10&&N.splice(10).forEach((function(n){return R.delete(n.id)}))}}},G=function(n){var t=self.requestIdleCallback||self.setTimeout,i=-1;return n=p(n),"hidden"===document.visibilityState?n():(i=t(n),m(n)),i},J=[200,500],K=function(n,t){if("PerformanceEventTiming"in self&&"interactionId"in PerformanceEventTiming.prototype){var i=s(t=t||{}),e=!1,a=0;C((function(){var c;B(i);var v,f=d("INP"),s=function(i,r){if(q(),f=d("INP",0,i,r),v=o(n,f,J,t.reportAllChanges),e=!1,"soft-navigation"===i){var c=g(r);a=c&&c.startTime?c.startTime:0}},p=function(n){G((function(){var i;n.forEach(z),(i=j())&&(i.latency!==f.value||t&&t.reportAllChanges)&&(f.value=i.latency,f.entries=i.entries),v()}))},h=l("event",p,{durationThreshold:null!==(c=t.durationThreshold)&&void 0!==c?c:40,opts:t});if(v=o(n,f,J,t.reportAllChanges),h){h.observe({type:"first-input",buffered:!0,includeSoftNavigationObservations:i}),m((function(){p(h.takeRecords()),v(!0)})),u((function(){q(),s("back-forward-cache",f.navigationId),r((function(){return v()}))}));i&&l("soft-navigation",(function(i){i.forEach((function(i){var r=g(i.navigationId),c=r&&r.startTime?r.startTime:0;i.navigationId&&i.navigationId!==f.navigationId&&c>a&&(!e&&f.value>0&&v(!0),s("soft-navigation",i.navigationId),v=o(n,f,J,t.reportAllChanges))}))}),t)}}))}},Q=[2500,4e3],U=function(n,t){var i,e=!1,a=s(t=t||{}),c=0,p=(null===(i=v())||void 0===i?void 0:i.navigationId)||"1",h="";C((function(){var i,v=b(),s=d("LCP"),I=function(a,r){if(s=d("LCP",0,a,r),i=o(n,s,Q,t.reportAllChanges),e=!1,"soft-navigation"===a){v=b(!0);var u=g(r);c=u&&u.startTime?u.startTime:0}E()},T=function(n){n.forEach((function(n){if(n){a&&n.navigationId&&n.navigationId!==s.navigationId&&(e||i(!0),I("soft-navigation",n.navigationId));var t=0;if(n.navigationId&&n.navigationId!==p){var o=g(n.navigationId),r=o&&o.startTime?o.startTime:0;t=Math.max(n.startTime-r,0)}else t=Math.max(n.startTime-f(),0);n.startTime<v.firstHiddenTime&&(s.value=t,s.entries=[n],s.navigationId=n.navigationId||p,i())}}))},y=function(){C(),e||(T(S.takeRecords()),a||S.disconnect(),s.navigationId===h&&(e=!0,i(!0)))},E=function(){["keydown","click"].forEach((function(n){addEventListener(n,(function(){return w()}),!0)}))},C=function(){["keydown","click"].forEach((function(n){removeEventListener(n,(function(){return w()}),!0)}))},w=function(){h=s.navigationId,G(y)},S=l("largest-contentful-paint",T,t);if(S){i=o(n,s,Q,t.reportAllChanges),E(),m((function(){h=s.navigationId,y()})),u((function(n){I("back-forward-cache",s.navigationId),r((function(){s.value=performance.now()-n.timeStamp,e=!0,i(!0)}))}));a&&l("soft-navigation",(function(n){n.forEach((function(n){var t=n.navigationId?g(n.navigationId):null;n.navigationId&&n.navigationId!==s.navigationId&&t&&(t.startTime||0)>c&&(e||i(!0),I("soft-navigation",n.navigationId))}))}),t)}}))},V=[800,1800],W=function n(t){document.prerendering?C((function(){return n(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return n(t)}),!0):setTimeout(t,0)},X=function(n,t){var i=s(t=t||{}),e=d("TTFB"),a=o(n,e,V,t.reportAllChanges);W((function(){var r=v();if(r){var c=r.responseStart;e.value=Math.max(c-f(),0),e.entries=[r],a(!0),u((function(){e=d("TTFB",0,"back-forward-cache",e.navigationId),(a=o(n,e,V,t.reportAllChanges))(!0)}));i&&l("soft-navigation",(function(i){i.forEach((function(i){i.navigationId&&((e=d("TTFB",0,"soft-navigation",i.navigationId)).entries=[i],(a=o(n,e,V,t.reportAllChanges))(!0))}))}),t)}}))},Y={passive:!0,capture:!0},Z=new Date,$=function(n,a){t||(t=a,i=n,e=new Date,en(removeEventListener),nn())},nn=function(){if(i>=0&&i<e-Z){var n={entryType:"first-input",name:t.type,target:t.target,cancelable:t.cancelable,startTime:t.timeStamp,processingStart:t.timeStamp+i};a.forEach((function(t){t([n])})),a=[]}},tn=function(n){if(n.cancelable){var t=(n.timeStamp>1e12?new Date:performance.now())-n.timeStamp;"pointerdown"==n.type?function(n,t){var i=function(){$(n,t),a()},e=function(){a()},a=function(){removeEventListener("pointerup",i,Y),removeEventListener("pointercancel",e,Y)};addEventListener("pointerup",i,Y),addEventListener("pointercancel",e,Y)}(t,n):$(t,n)}},en=function(n){["mousedown","keydown","touchstart","pointerdown"].forEach((function(t){return n(t,tn,Y)}))},an=[100,300],on=function(n,e){var r,c=s(e=e||{}),f=(null===(r=v())||void 0===r?void 0:r.navigationId)||"1";C((function(){var r,v=b(),s=d("FID"),g=function(t){t.forEach((function(t){var i,a;c?t.navigationId&&t.navigationId!==s.navigationId&&(i="soft-navigation",a=t.navigationId,"soft-navigation"===i&&(v=b(!0)),s=d("FID",0,i,a),r=o(n,s,an,e.reportAllChanges)):p.disconnect(),t.startTime<v.firstHiddenTime&&(s.value=t.processingStart-t.startTime,s.entries.push(t),s.navigationId=t.navigationId||f,r(!0))}))},p=l("first-input",g,e);r=o(n,s,an,e.reportAllChanges),p&&(m((function(){g(p.takeRecords()),c||p.disconnect()})),u((function(){var c;s=d("FID",0,"back-forward-cache",s.navigationId),r=o(n,s,an,e.reportAllChanges),a=[],i=-1,t=null,en(addEventListener),c=g,a.push(c),nn()})))}))};export{A as CLSThresholds,w as FCPThresholds,an as FIDThresholds,J as INPThresholds,Q as LCPThresholds,V as TTFBThresholds,L as onCLS,S as onFCP,on as onFID,K as onINP,U as onLCP,X as onTTFB};
{
"name": "web-vitals",
"version": "4.2.2-soft-navs",
"version": "4.2.2-soft-navs-2",
"description": "Easily measure performance metrics in JavaScript",

@@ -5,0 +5,0 @@ "type": "module",

@@ -19,3 +19,3 @@ /*

import {getLoadState} from '../lib/getLoadState.js';
import {getNavigationEntry, hardNavId} from '../lib/getNavigationEntry.js';
import {getNavigationEntry} from '../lib/getNavigationEntry.js';
import {getSoftNavigationEntry} from '../lib/softNavs.js';

@@ -31,2 +31,3 @@ import {onFCP as unattributedOnFCP} from '../onFCP.js';

const attributeFCP = (metric: FCPMetric): FCPMetricWithAttribution => {
const hardNavId = getNavigationEntry()?.navigationId || '1';
// Use a default object if no other attribution has been set.

@@ -33,0 +34,0 @@ let attribution: FCPAttribution = {

@@ -17,3 +17,3 @@ /*

import {getNavigationEntry, hardNavId} from '../lib/getNavigationEntry.js';
import {getNavigationEntry} from '../lib/getNavigationEntry.js';
import {getSoftNavigationEntry} from '../lib/softNavs.js';

@@ -30,2 +30,3 @@ import {getSelector} from '../lib/getSelector.js';

const attributeLCP = (metric: LCPMetric): LCPMetricWithAttribution => {
const hardNavId = getNavigationEntry()?.navigationId || '1';
// Use a default object if no other attribution has been set.

@@ -32,0 +33,0 @@ let attribution: LCPAttribution = {

@@ -38,3 +38,1 @@ /*

};
export const hardNavId = getNavigationEntry()?.navigationId || '1';

@@ -20,3 +20,3 @@ /*

import {getActivationStart} from './getActivationStart.js';
import {getNavigationEntry, hardNavId} from './getNavigationEntry.js';
import {getNavigationEntry} from './getNavigationEntry.js';
import {MetricType} from '../types.js';

@@ -30,2 +30,3 @@

) => {
const hardNavId = getNavigationEntry()?.navigationId || '1';
const hardNavEntry = getNavigationEntry();

@@ -32,0 +33,0 @@ let navigationType: MetricType['navigationType'] = 'navigate';

@@ -17,3 +17,3 @@ /*

import {hardNavId} from '../getNavigationEntry.js';
import {getNavigationEntry} from '../getNavigationEntry.js';
import {observe} from '../observe.js';

@@ -30,6 +30,7 @@

let maxKnownInteractionId = 0;
let currentNavId = hardNavId;
let currentNavId = '';
let softNavsEnabled = false;
const updateEstimate = (entries: PerformanceEventTiming[]) => {
if (!currentNavId) currentNavId = getNavigationEntry()?.navigationId || '1';
entries.forEach((e) => {

@@ -36,0 +37,0 @@ if (e.interactionId) {

@@ -22,3 +22,3 @@ /*

import {getVisibilityWatcher} from './lib/getVisibilityWatcher.js';
import {hardNavId} from './lib/getNavigationEntry.js';
import {getNavigationEntry} from './lib/getNavigationEntry.js';
import {initMetric} from './lib/initMetric.js';

@@ -52,2 +52,3 @@ import {observe} from './lib/observe.js';

let metricNavStartTime = 0;
const hardNavId = getNavigationEntry()?.navigationId || '1';

@@ -54,0 +55,0 @@ whenActivated(() => {

@@ -20,3 +20,3 @@ /*

import {getVisibilityWatcher} from './lib/getVisibilityWatcher.js';
import {hardNavId} from './lib/getNavigationEntry.js';
import {getNavigationEntry} from './lib/getNavigationEntry.js';
import {initMetric} from './lib/initMetric.js';

@@ -58,2 +58,3 @@ import {observe} from './lib/observe.js';

const softNavsEnabled = softNavs(opts);
const hardNavId = getNavigationEntry()?.navigationId || '1';

@@ -60,0 +61,0 @@ whenActivated(() => {

@@ -22,3 +22,3 @@ /*

import {getVisibilityWatcher} from './lib/getVisibilityWatcher.js';
import {hardNavId} from './lib/getNavigationEntry.js';
import {getNavigationEntry} from './lib/getNavigationEntry.js';
import {initMetric} from './lib/initMetric.js';

@@ -60,2 +60,4 @@ import {observe} from './lib/observe.js';

let metricNavStartTime = 0;
const hardNavId = getNavigationEntry()?.navigationId || '1';
let finalizeNavId = '';

@@ -85,11 +87,3 @@ whenActivated(() => {

}
// Stop listening after input. Note: while scrolling is an input that
// stops LCP observation, it's unreliable since it can be programmatically
// generated. See: https://github.com/GoogleChrome/web-vitals/issues/75
['keydown', 'click'].forEach((type) => {
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
addEventListener(type, () => whenIdle(finalizeAllLCPs), {once: true});
});
addInputListeners();
};

@@ -143,11 +137,53 @@

const finalizeAllLCPs = () => {
const finalizeLCPs = () => {
removeInputListeners();
if (!reportedMetric) {
handleEntries(po!.takeRecords() as LCPMetric['entries']);
if (!softNavsEnabled) po!.disconnect();
reportedMetric = true;
report(true);
// As the clicks are handled when idle, check if the current metric was
// for the reported NavId and only if so, then report.
if (metric.navigationId === finalizeNavId) {
reportedMetric = true;
report(true);
}
}
};
const addInputListeners = () => {
['keydown', 'click'].forEach((type) => {
// Stop listening after input. Note: while scrolling is an input that
// stops LCP observation, it's unreliable since it can be programmatically
// generated. See: https://github.com/GoogleChrome/web-vitals/issues/75
addEventListener(type, () => handleInput(), true);
});
};
const removeInputListeners = () => {
['keydown', 'click'].forEach((type) => {
// Remove event listeners as no longer required
removeEventListener(type, () => handleInput(), true);
});
};
const handleInput = () => {
// Since we only finalize whenIdle, we only want to finalize the LCPs
// for the current navigationId at the time of the input and not any
// others that came after, and before it was idle. So note the current
// metric.navigationId.
finalizeNavId = metric.navigationId;
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
whenIdle(finalizeLCPs);
};
const handleHidden = () => {
// Finalise the current navigationId metric.
finalizeNavId = metric.navigationId;
// Wrap in a setTimeout so the callback is run in a separate task
// to avoid extending the keyboard/click handler to reduce INP impact
// https://github.com/GoogleChrome/web-vitals/issues/383
finalizeLCPs();
};
const po = observe('largest-contentful-paint', handleEntries, opts);

@@ -163,4 +199,6 @@

onHidden(finalizeAllLCPs);
addInputListeners();
onHidden(handleHidden);
// Only report after a bfcache restore if the `PerformanceObserver`

@@ -167,0 +205,0 @@ // successfully registered.

@@ -30,4 +30,2 @@ /*

const hardNavEntry = getNavigationEntry();
/**

@@ -80,2 +78,3 @@ * Runs in the next task after the page is done loading and/or prerendering.

whenReady(() => {
const hardNavEntry = getNavigationEntry();
if (hardNavEntry) {

@@ -82,0 +81,0 @@ const responseStart = hardNavEntry.responseStart;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc