1import{a as H}from"./chunk-PRVPVJVL.js";import{a as T,b as B,d as y,f as a,g as D,h}from"./chunk-D2Q2FHMC.js";import{j as v}from"./chunk-3TNWI632.js";import{a as L}from"./chunk-UXA5ZQVP.js";import{b as l,c as C,d as s}from"./chunk-CD3GVT4K.js";import{a as M}from"./chunk-L3SA676J.js";import{b as w,e as z,f as P}from"./chunk-7UQKLI6I.js";import"./chunk-R43DT7GT.js";import{b as O,c as I}from"./chunk-FX5OPE3J.js";import{b as N}from"./chunk-MY3WTAZW.js";import{i as k}from"./chunk-TI4MZ3K4.js";import{P as _,Q as U,a as F,d as A,q as u}from"./chunk-QYHTTP6F.js";import{a as f,b}from"./chunk-IM5V7DCU.js";var G,K=new Promise(g=>{G=g}),W=Object.freeze({onReplayReady:G,sessionReplayInitialized:K});var de=(()=>{class g extends P{static featureName=T;mode=null;constructor(e,t){super(e,T),this.obfuscator=new z(e,M.SR),this.initialized=!1,this.blocked=!1,this.gzipper=void 0,this.u8=void 0,this.shouldCompress=!0,this.entitled=!1,this.timeKeeper=void 0,this.instrumentClass=t,this.recorder=this.instrumentClass?.recorder,this.harvestOpts.raw=!0,this.isSessionTrackingEnabled=L(e.init)&&!!e.runtime.session,this.reportSupportabilityMetric("Config/SessionReplay/Enabled"),this.ee.on(l.RESET,()=>{this.abort(a.RESET)}),this.ee.on(l.PAUSE,()=>{this.recorder?.stopRecording()}),this.ee.on(l.RESUME,()=>{this.recorder&&(this.mode=e.runtime.session.state.sessionReplayMode,!(!this.initialized||this.mode===s.OFF||!this.mode)&&this.recorder?.startRecording(h.RESUME,this.mode))}),this.ee.on(l.UPDATE,(o,n)=>{!this.recorder||!this.initialized||this.blocked||o!==C.CROSS_TAB||(this.mode!==s.OFF&&n.sessionReplayMode===s.OFF&&this.abort(a.CROSS_TAB),this.mode=n.sessionReplayMode)}),_(v,()=>{this.forceStop(this.mode===s.FULL)},this.featureName,this.ee),_(B,o=>{this.handleError(o)},this.featureName,this.ee);let{error_sampling_rate:i,sampling_rate:r,autoStart:d,block_selector:p,mask_text_selector:c,mask_all_inputs:R,inline_images:S,collect_fonts:m}=e.init.session_replay;this.waitForFlags(["srs","sr"]).then(([o,n])=>{if(this.entitled=!!n,!this.entitled){this.mode=s.OFF,this.#e({sessionReplayMode:this.mode}),this.deregisterDrain(),this.agentRef.runtime.isRecording&&(this.abort(a.ENTITLEMENTS),this.reportSupportabilityMetric("SessionReplay/EnabledNotEntitled/Detected"));return}this.initializeRecording(o).then(()=>{this.drain()})}).then(()=>{if(!this.mode)for(this.recorder?.stopRecording();this.recorder?.getEvents().events.length;)this.recorder?.clearBuffer?.();W.onReplayReady(this.mode)}),d||this.reportSupportabilityMetric("Config/SessionReplay/AutoStart/Modified"),m===!0&&this.reportSupportabilityMetric("Config/SessionReplay/CollectFonts/Modified"),S===!0&&this.reportSupportabilityMetric("Config/SessionReplay/InlineImages/Modifed"),R!==!0&&this.reportSupportabilityMetric("Config/SessionReplay/MaskAllInputs/Modified"),p!=="[data-nr-block]"&&this.reportSupportabilityMetric("Config/SessionReplay/BlockSelector/Modified"),c!=="*"&&this.reportSupportabilityMetric("Config/SessionReplay/MaskTextSelector/Modified"),this.reportSupportabilityMetric("Config/SessionReplay/SamplingRate/Value",r),this.reportSupportabilityMetric("Config/SessionReplay/ErrorSamplingRate/Value",i)}replayIsActive(){return!!(this.recorder&&this.mode===s.FULL&&!this.blocked&&this.entitled)}handleError(e){this.recorder&&(this.recorder.events.hasError=!0),this.mode===s.ERROR&&A?.document.visibilityState==="visible"&&this.switchToFull()}switchToFull(){!this.entitled||this.blocked||(this.mode=s.FULL,this.recorder&&this.initialized?(this.agentRef.runtime.isRecording||this.recorder.startRecording(h.SWITCH_TO_FULL,this.mode),this.#e({sessionReplayMode:this.mode})):this.initializeRecording(s.FULL,!0,h.SWITCH_TO_FULL))}async initializeRecording(e,t,i=h.INITIALIZE){if(this.initialized=!0,!this.entitled)return;let{session:r,timeKeeper:d}=this.agentRef.runtime;if(this.timeKeeper=d,this.recorder?.trigger===h.API&&this.agentRef.runtime.isRecording?this.mode=s.FULL:r.state.sessionReplayMode!==null&&!t?this.mode=r.state.sessionReplayMode:this.mode=e,this.mode!==s.OFF){try{this.recorder??=await this.instrumentClass.importRecorder()}catch(p){return this.abort(a.IMPORT,p)}this.mode===s.ERROR&&this.instrumentClass.errorNoticed&&(this.mode=s.FULL),await this.prepUtils(),this.agentRef.runtime.isRecording||this.recorder.startRecording(i,this.mode)}this.#e({sessionReplayMode:this.mode})}async prepUtils(){try{let{gzipSync:e,strToU8:t}=await import("./chunk-CHTG5YGB.js");this.gzipper=e,this.u8=t}catch{this.shouldCompress=!1}}makeHarvestPayload(){if(this.isRetrying)return this.recorder.retryPayload;if(this.mode!==s.FULL||this.blocked||this.shouldCompress&&!this.gzipper||!this.recorder||!this.timeKeeper?.ready||!(this.recorder.hasSeenSnapshot&&this.recorder.hasSeenMeta))return;let e=this.recorder.getEvents();if(!e.events.length)return;let t=this.getHarvestContents(e);if(!t.body.length){this.recorder.clearBuffer();return}this.reportSupportabilityMetric("SessionReplay/Harvest/Attempts");let i=0;if(this.gzipper&&this.u8)t.body=this.gzipper(this.u8("[".concat(t.body.map(({__serialized:r})=>r).join(","),"]"))),i=t.body.length;else{for(let r in t.body)delete t.body[r].__serialized;i=U(t.body).length}if(i>N){this.abort(a.TOO_BIG,i);return}return this.agentRef.runtime.session.state.sessionReplaySentFirstChunk||this.#e({sessionReplaySentFirstChunk:!0}),this.recorder.clearBuffer(),this.agentRef.runtime.session.state.traceHarvestStarted||u(59,JSON.stringify(this.agentRef.runtime.session.state)),this.recorder.retryPayload=t,t}getFirstAndLastNodes(e=[]){let t={firstEvent:e[0],lastEvent:e[e.length-1]};return e.forEach(i=>
1{let r=i?.timestamp;(!t.firstEvent?.timestamp||(r||1/0)<t.firstEvent.timestamp)&&(t.firstEvent=i),(!t.lastEvent?.timestamp||(r||-1/0)>t.lastEvent.timestamp)&&(t.lastEvent=i)}),t}getHarvestContents(e){e??=this.recorder.getEvents();let t=e.events,i=this.agentRef.runtime,r=this.agentRef.info.jsAttributes?.["enduser.id"];t?.[0]?.type===y.FullSnapshot&&this.recorder.lastMeta&&(e.hasMeta=!0,t.unshift(this.recorder.lastMeta),this.recorder.lastMeta=void 0),t[t.length-1]?.type===y.Meta&&(this.recorder.lastMeta=t[t.length-1],t=t.slice(0,t.length-1),e.hasMeta=!!t.find(E=>E.type===y.Meta));let c=F(),{firstEvent:R,lastEvent:S}=this.getFirstAndLastNodes(t),m=R?.timestamp||Math.floor(this.timeKeeper.correctAbsoluteTimestamp(e.cycleTimestamp)),o=S?.timestamp||Math.floor(this.timeKeeper.correctRelativeTimestamp(c)),n=i.appMetadata?.agents?.[0]||{};return{qs:{browser_monitoring_key:this.agentRef.info.licenseKey,type:M.SR,app_id:this.agentRef.info.applicationID,protocol_version:"0",timestamp:m,attributes:w(b(f(b(f(f({},!!this.gzipper&&!!this.u8&&{content_encoding:"gzip"}),n.entityGuid&&{entityGuid:n.entityGuid}),{harvestId:[i.session?.state.value,i.ptid,i.harvestCount].filter(E=>E).join("_"),"replay.firstTimestamp":m,"replay.lastTimestamp":o,"replay.nodes":t.length,"session.durationMs":i.session.getDuration(),agentVersion:i.version,session:i.session.state.value,rst:c,hasMeta:e.hasMeta||!1,hasSnapshot:e.hasSnapshot||!1,hasError:e.hasError||!1,isFirstChunk:i.session.state.sessionReplaySentFirstChunk===!1,decompressedBytes:e.payloadBytesEstimation,invalidStylesheetsDetected:H.invalidStylesheetsDetected,inlinedAllStylesheets:e.inlinedAllStylesheets,"rrweb.version":O+"@"+I,"payload.type":e.type}),r&&{"enduser.id":this.obfuscator.obfuscateString(r)}),{currentUrl:this.obfuscator.obfuscateString(k(""+location))}),D).substring(1)},body:t}}postHarvestCleanup(e){e.sent&&(e.retry?(u(70),this.isRetrying=!0,this.forceStop()):(this.recorder.retryPayload=void 0,this.isRetrying&&(this.isRetrying=!1,this.switchToFull())))}forceStop(e){e&&this.agentRef.runtime.harvester.triggerHarvestFor(this),this.mode=s.OFF,this.recorder?.stopRecording?.(),this.#e({sessionReplayMode:this.mode})}abort(e={},t){for(u(33,e.message),this.reportSupportabilityMetric("SessionReplay/Abort/".concat(e.sm),t),this.blocked=!0,this.mode=s.OFF,this.recorder?.stopRecording?.(),this.#e({sessionReplayMode:this.mode}),this.recorder?.clearTimestamps?.();this.recorder?.getEvents().events.length;)this.recorder?.clearBuffer?.()}#e(e={}){this.isSessionTrackingEnabled&&this.agentRef.runtime.session.write(e)}}return g})();export{de 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.