(()=>{"use strict";class e{getPerformanceMetrics(){const e={};try{window.performance&&(e.timeOrigin=performance.timeOrigin)}catch(e){console.warn("Failed to collect performance metrics:",e)}return e}}var t=-1,n=function(){var e=self.performance&&performance.getEntriesByType&&performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart=0?o="back-forward-cache":i&&(document.prerendering||r()>0?o="prerender":document.wasDiscarded?o="restore":i.type&&(o=i.type.replace(/_/g,"-"))),{name:e,value:void 0===a?-1:a,rating:"good",delta:0,entries:[],id:"v4-".concat(Date.now(),"-").concat(Math.floor(8999999999999*Math.random())+1e12),navigationType:o}},i=function(e,t,n,r){var a,i;return function(o){t.value>=0&&(o||r)&&((i=t.value-(a||0))||void 0===a)&&(a=t.value,t.delta=i,t.rating=function(e,t){return e>t[1]?"poor":e>t[0]?"needs-improvement":"good"}(t.value,n),e(t))}},o=(new Map,[800,1800]),s=function e(t){document.prerendering?function(e){document.prerendering?addEventListener("prerenderingchange",(function(){return e()}),!0):e()}((function(){return e(t)})):"complete"!==document.readyState?addEventListener("load",(function(){return e(t)}),!0):setTimeout(t,0)},c=function(e,c){c=c||{};var u=a("TTFB"),d=i(e,u,o,c.reportAllChanges);s((function(){var s=n();s&&(u.value=Math.max(s.responseStart-r(),0),u.entries=[s],d(!0),function(e){addEventListener("pageshow",(function(n){n.persisted&&(t=n.timeStamp,e(n))}),!0)}((function(){u=a("TTFB",0),(d=i(e,u,o,c.reportAllChanges))(!0)})))}))};new Date;class u{metrics={};constructor(t){this.analyticsService=t,this.performanceService=new e,c(this.handleMetric.bind(this))}getRating=(e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good";parseTTFB(e){if(!e)return;const t=e.entries[0],n=t.responseStart,r=t.domainLookupStart,a=t.connectStart,i=t.connectEnd,s=t.workerStart||t.fetchStart,c=e.navigationType;return{value:n,rating:this.getRating(n,o),attribution:{cacheDuration:r-s,connectionDuration:i-a,dnsDuration:a-r,requestDuration:n-i,waitingDuration:s},navigationType:c}}handleMetric(e){if(e)if("TTFB"===e.name){const t=this.parseTTFB(e);if(!t)return;this.metrics.ttfb=t,this.analyticsService.handledMetric(e.name)}else console.warn(`Unknown metric: ${e.name}`)}getMetrics(){return this.metrics.performance=this.performanceService.getPerformanceMetrics(),this.metrics}}const d=(new class{scriptSelector="script.elementor-browser-metrics[data-request-info]";requestInfoAttribute="data-request-info";getRequestData(){try{const e=document.querySelector(this.scriptSelector);if(!e)return null;const t=e.getAttribute(this.requestInfoAttribute);return t?JSON.parse(t):null}catch(e){return console.warn("Failed to parse request data:",e),null}}}).getRequestData();d?new class{sentTTFB=!1;constructor(e){this.requestData=e,this.metricsCollector=new u(this)}handledMetric(e){"TTFB"===e&&this.sendTTFB()}sendTTFB(){if(this.sentTTFB)return;const e=this.getAnalyticsData();e?.metrics?.ttfb&&["navigate","reload","prerender"].includes(e.metrics.ttfb.navigationType)&&(this.sentTTFB=!0,this.sendMetrics(e))}getAnalyticsData(){return{metrics:this.metricsCollector.getMetrics(),timestamp:Date.now(),url:window.location.href,traceparent:this.requestData.traceparent,version:this.requestData.version}}sendMetrics(e){if(e)try{const t=JSON.stringify(e);if(navigator.sendBeacon){const e=new Blob([t],{type:"application/json"});navigator.sendBeacon(this.requestData.endpoint,e)||console.warn("Failed to send metrics via beacon")}else fetch(this.requestData.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:t,keepalive:!0}).catch((()=>{console.warn("Failed to send metrics via fetch")}))}catch(e){console.warn("Failed to send metrics:",e)}}}(d):console.warn("Request data not found")})();