1import{V as a,n as A,$ as w,c as S,k as g,ay as h,a0 as M,w as O}from"./CFSA_5PF.js";import{M as T,p as F,E as _,c as R,A as f}from"./CuVGAwjA.js";import{A as I}from"./is8M2rte.js";import{e as v}from"./Bb7irpQQ.js";import{o as k}from"./CgPBdOVY.js";import{O as L}from"./BAxuS1bJ.js";import"./CIfLVooy.js";import"./DjAzorbH.js";import"./BoTmtloK.js";import"./EI5dMSXd.js";class c{constructor(e,i,s,t,r){this.n=e,this.s=i,this.e=s,this.o=t,this.t=r}}function H(u){switch(u){case"keydown":case"keyup":case"keypress":return"typing";case"mousemove":case"mouseenter":case"mouseleave":case"mouseover":case"mouseout":return"mousing";case"touchstart":case"touchmove":case"touchend":case"touchcancel":case"touchenter":case"touchleave":return"touching";case"scroll":case"scrollend":return"scrolling";default:return u}}const p={global:{mouseup:!0,mousedown:!0},window:{load:!0,pagehide:!0},xhrOriginMissing:{ignoreAll:!0}},n={typing:"typing",scrolling:"scrolling",mousing:"mousing",touching:"touching"},x={[n.typing]:1e3,[n.scrolling]:100,[n.mousing]:1e3,[n.touching]:1e3},B={[n.typing]:2e3,[n.scrolling]:1e3,[n.mousing]:2e3,[n.touching]:2e3};class D{prevStoredEvents=new Set;constructor(e){this.parent=e}#s(e){return e.n in n}#i(e){const i=t=>!(t.o!==e.o||t.n!==e.n||e.s-t.s<B[e.o]||t.e>e.s-x[e.o]),s={e:e.e};return this.parent.events.merge(i,s)}#r(e){if(e.n in p.global)return!0;const i=e.o;return p[i]?.ignoreAll||p[i]?.[e.n]?!0:i==="xhrOriginMissing"&&e.n==="Ajax"}#t(){if(this.parent.blocked)return!1;if(this.parent.events.length>=T){if(this.parent.mode!==a.ERROR)return!1;this.trimSTNsByTime(),this.parent.events.length>=T&&this.trimSTNsByIndex(1)}return!0}#e(e){return this.#r(e)||!this.#t()?!1:((!this.#s(e)||!this.#i(e))&&this.parent.events.add(e),!0)}storeNode(e){return this.#e(e)}processPVT(e,i,s){return this.storeTiming({[e]:i})}storeTiming(e,i=!1){if(!e)return!1;let s=!0;for(let t in e){let r=e[t];const o=t.toLowerCase();o.indexOf("size")>=0||o.indexOf("status")>=0||typeof r=="number"&&r>=0&&(r=Math.round(r),i&&this.parent.timeKeeper?.ready&&(r=this.parent.timeKeeper.convertAbsoluteTimestamp(Math.floor(this.parent.timeKeeper.correctAbsoluteTimestamp(r)))),this.#e(new c(t,r,r,"document","timing"))||(s=!1))}return s}storeEvent(e,i,s,t){if(this.prevStoredEvents.has(e)||!this.#t())return!1;this.prevStoredEvents.add(e);const r=new c(H(e.type),s,t,void 0,"event");try{r.o=v(e.target,i,this.parent.ee)}catch{r.o=v(null,i,this.parent.ee)}return this.#e(r)}storeHist(e,i,s){return this.#e(new c("history.pushState",s,s,e,i))}storeResources(e){if(!e||e.length===0)return!1;let i=!0;for(let s=0;s<e.length;s++){const t=e[s];if(!this.#t())break;const{initiatorType:r,fetchStart:o,responseEnd:d,entryType:m}=t,{protocol:l,hostname:E,port:b,pathname:y}=F(t.name),N=new c(r,o|0,d|0,"".concat(l,"://").concat(E,":").concat(b).concat(y),m);this.#e(N)||(i=!1)}return i}storeErrorAgg(e,i,s,t){return e!=="err"?!1:this.#e(new c("error",t.time,t.time,s.message,s.stackHash))}storeXhrAgg(e,i,s,t){return e!=="xhr"?!1:this.#e(new c("Ajax",t.time,t.time+t.duration,"".concat(s.status," ").concat(s.method,": ").concat(s.host).concat(s.pathname),"ajax"))}trimSTNsByTime(e=_){this.parent.events.clear({clearBeforeTime:Math.max(A-e,0),timestampKey:"e"})}trimSTNsByIndex(e=0){this.parent.events.clear({clearBeforeIndex:e})}clear(){this.prevStoredEvents.clear()}}const U=5e3;class q extends I{static featureName=R;constructor(e){super(e,R),this.harvestOpts.raw=!0,this.obfuscator=new L(e,w.ST),this.entitled=void 0,this.everHarvested=!1,this.harvesting=!1,this.traceStorage=new D(this),this.waitForFlags(["sts","st"]).then(([i,s])=>this.initialize(i,s))}initialize(e,i,s){if(this.entitled??=i,!this.entitled)return this.abort(f.ENTITLEMENTS),this.deregisterDrain();this.timeKeeper??=this.agentRef.runtime.timeKeeper,this.initialized||(this.initialized=!0,this.ptid=this.agentRef.runtime.ptid,this.sessionId=this.agentRef.runtime.session?.state.value,this.ee.on(S.RESET,()=>{this.blocked||this.abort(f.RESET)}),this.ee.on(S.UPDATE,(t,r)=>{this.blocked||(this.mode!==a.FULL&&(r.sessionReplayMode===a.FULL||r.sessionTraceMode===a.FULL)&&this.switchToFull(),(this.sessionId!==r.value||t==="cross-tab"&&r.sessionTraceMode===a.OFF)&&this.abort(f.CROSS_TAB))}),typeof PerformanceNavigationTiming<"u"&&g.performance?.getEntriesByType("navigation")?.length>0?this.traceStorage.storeTiming(g.performance.getEntriesByType("navigation")[0]):this.traceStorage.storeTiming(g.performance?.timing,!0)),this.agentRef.runtime.session.state.sessionTraceMode!==null&&!s?this.mode=this.agentRef.runtime.session.state.sessionTraceMode:this.mode=e,this.mode!==a.OFF&&(h("bst",(...t)=>this.traceStorage.storeEvent(...t),this.featureName,this.ee),h("bstResource",(...t)=>this.traceStorage.storeResources(...t),this.featureName,this.ee),h("bstHist",(...t)=>this.traceStorage.storeHist(...t),this.featureName,this.ee),h("bstXhrAgg",(...t)=>this.traceStorage.storeXhrAgg(...t),this.featureName,this.ee),h("bstApi",(...t)=>this.traceStorage.storeNode(...t),this.featureName,this.ee),h("trace-jserror",(...t)=>this.traceStorage.storeErrorAgg(...t),this.featureName,this.ee),h("pvtAdded",(...t)=>this.traceStorage.processPVT(...t),this.featureName,this.ee),this.mode===a.ERROR&&h("trace-jserror",()=>{this.mode===a.ERROR&&this.switchToFull()},this.featureName,this.ee)),this.agentRef.runtime.session.write({sessionTraceMode:this.mode}),this.mode===a.OFF?this.deregisterDrain():this.drain()}preHarvestChecks(){if(!(this.blocked||this.mode!==a.FULL)&&this.timeKeeper?.ready&&this.agentRef.runtime.session){if(this.sessionId!==this.agentRef.runtime.session.state.value||this.ptid!==this.agentRef.runtime.ptid){this.abort(f.SESSION_CHANGED);return}return!0}}serializer(e){if(e.length)return this.everHarvested=!0,this.obfuscator.traverseAndObfuscateEvents(e)}queryStringsBuilder(e){const i=!this.agentRef.runtime.session.state.traceHarvestStarted;i&&this.agentRef.runtime.session.write({traceHarvestStarted:!0});const s=this.agentRef.runtime.session.state.sessionReplayMode===1,t=this.agentRef.info.jsAttributes["enduser.id"],r=this.agentRef.runtime.appMetadata.agents?.[0]?.entityGuid,o=e.reduce((m,l)=>Math.min(m,l.s),1/0),d=e.reduce((m,l)=>Math.max(m,l.s),-1/0);return{browser_monitoring_key:this.agentRef.info.licenseKey,type:"BrowserSessionChunk",app_id:this.agentRef.info.applicationID,protocol_version:"0",timestamp:Math.floor(this.timeKeeper.correctRelativeTimestamp(o)),attributes:k({...r&&{entityGuid:r},harvestId:"".concat(this.agentRef.runtime.session.state.value,"_").concat(this.agentRef.runtime.ptid,"_").concat(this.agentRef.runtime.harvestCount),"trace.firstTimestamp":Math.floor(this.timeKeeper.correctRelativeTimestamp(o)),"trace.lastTimestamp":Math.floor(this.timeKeeper.correctRelativeTimestamp(d)),"trace.nodes":e.length,"trace.originTimestamp":this.timeKeeper.correctedOriginTime,agentVersion:this.agentRef.runtime.version,...i&&{firstSessionHarvest:i},...s&&{hasReplay:s},ptid:"".concat(this.ptid),session:"".concat(this.sessionId),...t&&{"enduser.id":this.obfuscator.obfuscateString(t)},currentUrl:this.obfuscator.obfuscateString(M(""+location))},U).substring(1)}}switchToFull(){if(this.mode===a.FULL||!this.entitled||this.blocked)return;const e=this.mode;if(this.mode=a.FULL,this.agentRef.runtime.session.write({sessionTraceMode:this.mode}),e===a.OFF||!this.initialized)return this.initialize(this.mode,this.entitled);this.initialized&&(this.traceStorage.trimSTNsByTime(),this.agentRef.runtime.harvester.triggerHarvestFor(this))}abort(e={}){O(60,e.message),this.blocked=!0,this.mode=a.OFF,this.agentRef.runtime.session.write({sessionTraceMode:this.mode}),this.events.clear()}postHarvestCleanup(e){this.traceStorage.clear(),super.postHarvestCleanup(e)}}export{q as Aggregate};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.