PageSourceSearch

https://www.davidlloyd.nl/4011-115fdaa0caadeca27d87.js

js davidlloyd.nl collected 2026-10-04 13:30:58 UTC 120,711 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkgatsby_starter_website_future=self.webpackChunkgatsby_starter_website_future||[]).push([[4011],{34011:function(e,t,n){n.r(t),n.d(t,{SessionReplayPlugin:function(){return Jt},plugin:function(){return Kt},sessionReplayPlugin:function(){return Kt}});var r,i=n(31635),s=n(97184),o=n(65107),a=n(43964),l=n(48003),c=n(40225),u=n(67395),d=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return(0,i.C6)(t,e),t.prototype.send=function(e,t){return(0,i.sH)(this,void 0,void 0,function(){var n,r,s;return(0,i.YH)(this,function(o){switch(o.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:(0,i.Cl)({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=o.sent()).text()];case 2:s=o.sent();try{return[2,this.buildResponse(JSON.parse(s))]}catch(a){return[2,this.buildResponse({code:r.status})]}return[2]}})})},t}(u.j),v=n(1555),h=n(39207),g=n(41962),f="[Amplitude]",p="".concat(f," Session Replay ID"),m=h.e.US,y={enabled:!0},S=1e3,b="".concat(f," Session Replay Debug"),I="amp-mask",C="amp-unmask",w="https://api-sr.amplitude.com/sessions/v2/track",E="https://api-sr.eu.amplitude.com/sessions/v2/track",P="https://api-sr.stag2.amplitude.com/sessions/v2/track",k=("".concat(g.r,"_replay_unsent"),9e6),x=/payload.*exceed/i,M=500,T=1e4,R=1024,O="X-Session-Replay-Event-Skipped",F="amplitude-sr-iframe";!function(e){e.GET_SR_PROPS="get-sr-props",e.DEBUG_INFO="debug-info",e.FETCH_REQUEST="fetch-request",e.METADATA="metadata",e.TARGETING_DECISION="targeting-decision",e.REPLAY_GATE_DECISION="replay-gate-decision"}(r||(r={}));var L=function(){function e(e){this.logger=e,this.log=this.getSafeMethod("log"),this.warn=this.getSafeMethod("warn"),this.error=this.getSafeMethod("error"),this.debug=this.getSafeMethod("debug")}return e.prototype.getSafeMethod=function(e){var t;if(!this.logger)return function(){};var n=this.logger[e];return"function"==typeof n?(null!==(t=n.__rrweb_original__)&&void 0!==t?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),_="medium";var D=function(e,t,n){switch(t){case"light":if("input"!==e)return!1;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":return"input"===e;case"conservative":return!0;default:return D(e,_,n)}},H=function(e,t){var n,r,s;if(e&&t.urlMaskLevels)try{for(var o=(0,i.Ju)(t.urlMaskLevels),a=o.next();!a.done;a=o.next()){var l=a.value;if(U(l.match).test(e))return l.maskLevel}}catch(c){n={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null!==(s=t.defaultMaskLevel)&&void 0!==s?s:_},q=function(e,t,n,r){var i,s;if(void 0===t&&(t={defaultMaskLevel:_}),n){if(n.closest("."+I))return!0;var o=(null!==(i=t.maskSelector)&&void 0!==i?i:[]).some(function(e){return n.closest(e)});if(o)return!0;if(n.closest("."+C))return!1;var a=(null!==(s=t.unmaskSelector)&&void 0!==s?s:[]).some(function(e){return n.closest(e)});if(a)return!1}return D(e,H(r,t),n)},N=function(e,t,n){return function(r,i){return q(e,t,i,null==n?void 0:n())?r.replace(/[^\s]/g,"*"):r}},A=function(e,t){return function(n,r,i){var s;if("style"===n)return r;if(!(null!==(s=null==e?void 0:e.maskAttributes)&&void 0!==s?s:[]).includes(n))return r;var o=["INPUT","SELECT","TEXTAREA"].includes(i.tagName)?"input":"text";return q(o,e,i,null==t?void 0:t())?r.replace(/[^\s]/g,"*"):r}},B=function(){var e=(0,o.m)();return(null==e?void 0:e.location)?e.location.href:""},z=new Map,U=function(e){var t=z.get(e);if(t)return t;var n="\0TRAIL\0",r="\0MID\0",i="\0DS\0",s="\0ST\0",o="\0QU\0",a=e;a=(a=(a=(a=(a=(a=(a=(a=(a=(a=(a=a.replace(/\/\*\*$/,n)).replace(/\/\*\*\//g,r)).replace(/\*\*/g,i)).replace(/\*/g,s)).replace(/\?/g,o)).replace(/[.+^${}()|[\]\\]/g,"\\$&")).split(n).join("(/.*)?")).split(r).join("/(.*\\/)?")).split(i).join(".*")).split(s).join(".*")).split(o).join(".");var l=new RegExp("^".concat(a,"$"));return z.set(e,l),l},W=function(e,t){var n,r;try{for(var s=(0,i.Ju)(t),o=s.next();!o.done;o=s.next()){var a=o.value,l=U(a.selector);if(l.test(e))return e.replace(l,a.replacement)}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return e},j=function(){return(0,i.sH)(void 0,void 0,void 0,function(){var e,t,n,r,s,a,l;return(0,i.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),(e=(0,o.m)())?[4,e.navigator.storage.estimate()]:[3,2];case 1:return t=i.sent(),n=t.usage,r=t.quota,s=t.usageDetails,a=n?Math.round(n/R):0,l=n&&r?Math.round(1e3*(n/r+Number.EPSILON))/1e3:0,[2,{totalStorageSize:a,percentOfQuota:l,usageDetails:JSON.stringify(s)}];case 2:return[3,4];case 3:return i.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},Y=function(e){var t=(0,i.Cl)({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},J=function(){return{flushMaxRetries:2,logLevel:l.$.Warn,loggerProvider:new c.V,transportProvider:new d}},K=function(e){function t(t,n){var r,s,o,a,l,c,u,d,v,h,g,f,p,b,I=this,w=J();(I=e.call(this,(0,i.Cl)((0,i.Cl)({transportProvider:w.transportProvider,loggerProvider:new L(n.loggerProvider||w.loggerProvider)},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=w.flushMaxRetries?n.flushMaxRetries:w.flushMaxRetries,I.apiKey=t,I.sampleRate=n.sampleRate||0,I.serverZone=n.serverZone||m,I.configServerUrl=n.configServerUrl,I.trackServerUrl=n.trackServerUrl,I.shouldInlineStylesheet=n.shouldInlineStylesheet,I.version=n.version,I.performanceConfig=n.performanceConfig||y,I.storeType=null!==(r=n.storeType)&&void 0!==r?r:"memory",I.applyBackgroun
1dColorToBlockedElements=null!==(s=n.applyBackgroundColorToBlockedElements)&&void 0!==s&&s,I.enableUrlChangePolling=null!==(o=n.enableUrlChangePolling)&&void 0!==o&&o,I.urlChangePollingInterval=null!==(a=n.urlChangePollingInterval)&&void 0!==a?a:S,I.captureDocumentTitle=null!==(l=n.captureDocumentTitle)&&void 0!==l&&l,void 0!==n.fullSnapshotIntervalMs&&(I.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),void 0!==n.eagerFullSnapshotSend&&(I.eagerFullSnapshotSend=n.eagerFullSnapshotSend),I.captureFullSnapshotOnFocus=null!==(c=n.captureFullSnapshotOnFocus)&&void 0!==c&&c,void 0!==n.maxPersistedEventsSizeBytes&&(I.maxPersistedEventsSizeBytes=G(n.maxPersistedEventsSizeBytes,Q,V,"maxPersistedEventsSizeBytes",I.loggerProvider)),void 0!==n.maxSingleEventSizeBytes&&(I.maxSingleEventSizeBytes=G(n.maxSingleEventSizeBytes,Q,$,"maxSingleEventSizeBytes",I.loggerProvider)),I.privacyConfig=(0,i.Cl)((0,i.Cl)({},null!==(u=n.privacyConfig)&&void 0!==u?u:{}),{unmaskSelector:Array.from(new Set((0,i.fX)([".".concat(C)],(0,i.zs)(null!==(v=null===(d=n.privacyConfig)||void 0===d?void 0:d.unmaskSelector)&&void 0!==v?v:[]),!1)))}),n.interactionConfig&&(I.interactionConfig=n.interactionConfig,I.interactionConfig.ugcFilterRules&&function(e){if(!e.every(function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement}))throw new Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every(function(e){return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t);var t}))throw new Error("ugcFilterRules must be an array of objects with valid globs")}(I.interactionConfig.ugcFilterRules)),n.debugMode&&(I.debugMode=n.debugMode);var E=n;return I.useWebWorker=null===(f=null!==(h=n.useWebWorker)&&void 0!==h?h:null===(g=E.experimental)||void 0===g?void 0:g.useWebWorker)||void 0===f||f,I.enableTransportCompression=null===(p=n.enableTransportCompression)||void 0===p||p,I.sendTimeoutMs=n.sendTimeoutMs,I.captureAdoptedStyleSheets=null===(b=n.captureAdoptedStyleSheets)||void 0===b||b,n.crossOriginIframes&&(I.crossOriginIframes=n.crossOriginIframes),n.flushIntervalConfig?I.flushIntervalConfig=function(e,t){var n,r,i={};void 0!==e.minIntervalMs&&(!Number.isFinite(e.minIntervalMs)||e.minIntervalMs<X?(t.warn("flushIntervalConfig.minIntervalMs ".concat(e.minIntervalMs," is below floor ").concat(X,"ms; clamping.")),i.minIntervalMs=X):i.minIntervalMs=e.minIntervalMs);void 0!==e.maxIntervalMs&&(Number.isNaN(e.maxIntervalMs)||e.maxIntervalMs<X?(t.warn("flushIntervalConfig.maxIntervalMs ".concat(e.maxIntervalMs," is below floor ").concat(X,"ms; clamping.")),i.maxIntervalMs=X):i.maxIntervalMs=e.maxIntervalMs);if(void 0!==i.minIntervalMs||void 0!==i.maxIntervalMs){var s=null!==(n=i.minIntervalMs)&&void 0!==n?n:M,o=null!==(r=i.maxIntervalMs)&&void 0!==r?r:T;o<s&&(void 0===i.maxIntervalMs?(t.warn("flushIntervalConfig.minIntervalMs (".concat(s,") exceeds the default maxIntervalMs (").concat(T,"); raising max to match min.")),i.maxIntervalMs=s):void 0===i.minIntervalMs?(t.warn("flushIntervalConfig.maxIntervalMs (".concat(o,") is below the default minIntervalMs (").concat(M,"); lowering min to match max.")),i.minIntervalMs=o):(t.warn("flushIntervalConfig.maxIntervalMs (".concat(i.maxIntervalMs,") is less than minIntervalMs (").concat(i.minIntervalMs,"); raising max to match min.")),i.maxIntervalMs=i.minIntervalMs))}return i}(n.flushIntervalConfig,I.loggerProvider):I.flushIntervalConfig={minIntervalMs:1e3,maxIntervalMs:1e4},I.handleSendEvents=n.handleSendEvents,I.handleFetchConfig=n.handleFetchConfig,I}return(0,i.C6)(t,e),t}(v.TS),X=100,Q=1e3,V=8e6,$=1e7;function G(e,t,n,r,i){if(Number.isFinite(e))return e<t?(i.warn("".concat(r," ").concat(e," is below floor ").concat(t,"; clamping.")),t):e>n?(i.warn("".concat(r," ").concat(e," exceeds ceiling ").concat(n,"; clamping.")),n):e;i.warn("".concat(r," value is not a finite number (got ").concat(String(e),"); ignoring."))}var Z=n(2511),ee=n(92056),te=n(39258),ne=n(92872),re=n(94342),ie=n(66295),se=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(se||{}),oe=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(oe||{}),ae=(e=>(e[e.MouseUp=0]="MouseUp",e[e.MouseDown=1]="MouseDown",e[e.Click=2]="Click",e[e.ContextMenu=3]="ContextMenu",e[e.DblClick=4]="DblClick",e[e.Focus=5]="Focus",e[e.Blur=6]="Blur",e[e.TouchStart=7]="TouchStart",e[e.TouchMove_Departed=8]="TouchMove_Departed",e[e.TouchEnd=9]="TouchEnd",e[e.TouchCancel=10]="TouchCancel",e))(ae||{}),le=n(95626),ce=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){var e,t,n,r,s,o,a;return(0,i.sH)(this,void 0,void 0,function(){var l,c,u,d,v,h,g,f,p,m,y,S,b,I,C,w,E,P=this;return(0,i.YH)(this,function(k){switch(k.label){case 0:(l=(0,i.Cl)({},this.localConfig)).optOut=this.localConfig.optOut,l.captureEnabled=!0,k.label=1;case 1:return k.trys.push([1,3,,4]),[4,new Promise(function(e,t){P.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:1500},function(n,r){var i;if(P.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(r,":"),JSON.stringify(n,null,2)),n){var s=n,o=s.sr_sampling_config,a=s.sr_privacy_config,u=s.sr_targeting_config,d=null===(i=l.interactionConfig)||void 0===i?void 0:i.ugcFilterRules;l.interactionConfig=s.sr_interaction_config,l.interactionConfig&&d&&(l.interactionConfig.ugcFilterRules=d),l.loggingConfig=s.sr_logging_config,(o||a||u)&&(c={},o&&(c.sr_sampling_config=o),a&&(c.sr_privacy_config=a),u&&(c.sr_targeting_config=u)),e()}else t(new Error("No remote config received"))})})];case 2:return k.sent(),[3,4];case 3:return u=k.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",u),l.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:l,remoteConfig:void 0}];case 4:if(!c)return[2,{localConfig:this.localConfig,joinedConfig:l,remoteConfig:c}];if(d=c.sr_sampling_config,v=c.sr_privacy_config,h=c.sr_targeting_config,d&&Object.keys(d).length>0?(Object.prototype.hasOwnProperty.call(d,"capture_enabled")?l.captureEnabled=d.capture_enabled:l.captureEnabled=!1,Object.prototype.hasOwnProperty.call(d,"sample_rate")&&(l.sampleRate=d.sample_rate),Object.prototype.hasOwnProperty.call(d,"min_session_duration_ms")&&(l.minSessionDurationMs=this.sanitizeMinSessionDurationMs(d.min_session_duration_ms))):(l.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),v){g=null!==(e=l.privacyConfig)&&void 0!==e?e:{},f={defaultMaskLevel:null!==(n=null!==(t=v.defaultMaskLevel)&&void 0!==t?t:g.defaultMaskLevel)&&void 0!==n?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:(0,i.fX)([],(0,i.zs)(new Set((0,i.fX)((0,i.fX)([],(0,i.zs)(null!==(r=g.maskAttributes)&&void 0!==r?r:[]),!1),(0,i.zs)(null!==(s=v.maskAttributes)&&void 0!==s?s:[]),!1))),!1),urlMaskLevels:(0,i.fX)((0,i.fX)([],(0,i.zs)(null!==(o=v.urlMaskLevels)&&void 0!==o?o:[]),!1),(0,i.zs)(null!==(a=g.urlMaskLevels)&&void 0!==a?a:[]),!1)},p=function(e){var t,n,r,s,o,a,l,c,u,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var v=(0,i.Ju)(null!==(l=e.blockSelector)&&void 0!==l?l:[]),h=v.next();!h.done;h=v.next()){d[h.value]="block"}}catch(y){t={error:y}}finally{try{h&&!h.done&&(n=v.return)&&n.call(v)}finally{if(t)throw t.error}}try{for(var g=(0,i.Ju)(null!==(c=e.maskSelector)&&void 0!==c?c:[]),f=g.next();!f.done;f=g.next()){d[f.value]="mask"}}catch(S){r={error:S}}finally{try{f&&!f.done&&(s=g.return)&&s.call(g)}finally{if(r)throw r.error}}try{for(var p=(0,i.Ju)(null!==(u=e.unmaskSelector)&&void 0!==u?u:[]),m=p.next();!m.done;m=p.next()){d[m.value]="unmask"}}catch(b){o={error:b}}finally{try{m&&!m.done&&(a=p.return)&&a.call(p)}finally{if(o)throw o.error}}return d},m=(0,i.Cl)((0,i.Cl)({},p(g)),p(v));try{for(y=(0,i.Ju)(Object.entries(m)),S=y.next();!S.done;S=y.next())b=(0,i.zs)(S.value,2),I=b[0],"mask"===(C=b[1])?f.maskSelector.push(I):"block"===C?f.blockSelector.push(I):"unmask"===C&&f.unmaskSelector.push(I)}catch(O){w={error:O}}finally{try{S&&!S.done&&(E=y.return)&&E.call(y)}finally{if(w)throw w.error}}l.privacyConfig=(x=f,M=this.localConfig.loggerProvider,T=document.createDocumentFragment(),R=function(t){if(void 0===t&&(t=[]),"string"==typeof t&&(t=[t]),t=t.filter(function(t){try{T.querySelector(t)}catch(e){return M.warn('[session-replay-browser] omitting selector "'.concat(t,'" because it is invali
1d')),!1}return!0}),0!==t.length)return t},x.blockSelector=R(x.blockSelector),x.maskSelector=R(x.maskSelector),x.unmaskSelector=R(x.unmaskSelector),x)}return h&&Object.keys(h).length>0&&(l.targetingConfig=h),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:Y(l)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:l,remoteConfig:c}]}var x,M,T,R})})},e.prototype.sanitizeMinSessionDurationMs=function(e){if("number"==typeof e&&Number.isFinite(e)){if(!(e<0))return e>ue?(this.localConfig.loggerProvider.warn("min_session_duration_ms remote value ".concat(e," exceeds ").concat(ue,"ms ceiling; clamping.")),ue):e;this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is negative (".concat(e,"); ignoring."))}else this.localConfig.loggerProvider.warn("min_session_duration_ms remote value is not a finite number (got ".concat(String(e),"); ignoring."))},e}(),ue=6e4,de=function(e,t){return(0,i.sH)(void 0,void 0,void 0,function(){var n,r;return(0,i.YH)(this,function(i){return n=new K(e,t),r=new le.IQ(e,n.loggerProvider,n.serverZone,t.configServerUrl,t.handleFetchConfig),[2,new ce(r,n)]})})};function ve(e,t){return t||("STAGING"===e?P:"EU"===e?E:w)}function he(e){if(e.type!==se.IncrementalSnapshot)return!1;var t=e.data;return t.source===oe.Mutation&&!t.isAttachIframe}function ge(e){var t,n,r=new Map;if(e.forEach(function(e,t){if(e.attributes&&"style"in e.attributes){var n=r.get(e.id);n?n.push(t):r.set(e.id,[t])}}),0===r.size)return e;var s=function(t){return e[t].attributes.style},o=new Set,a=new Map,l=function(e){if(1===e.length)return"continue";var t=-1;e.forEach(function(e,n){var r;("object"!=typeof(r=s(e))||null===r)&&(t=n)});var n=[];if(e.forEach(function(e,r){r!==t&&(o.add(e),r>t&&n.push(e))}),n.length>0){var r=n[n.length-1],l=function(e){var t,n,r,s,o={};try{for(var a=(0,i.Ju)(e),l=a.next();!l.done;l=a.next()){var c=l.value;try{for(var u=(r=void 0,(0,i.Ju)(Object.keys(c))),d=u.next();!d.done;d=u.next()){var v=d.value;o[v]=c[v]}}catch(h){r={error:h}}finally{try{d&&!d.done&&(s=u.return)&&s.call(u)}finally{if(r)throw r.error}}}}catch(g){t={error:g}}finally{try{l&&!l.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o}(n.map(function(e){return s(e)}));o.delete(r),a.set(r,l)}};try{for(var c=(0,i.Ju)(r.values()),u=c.next();!u.done;u=c.next()){l(u.value)}}catch(v){t={error:v}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}if(0===o.size&&0===a.size)return e;var d=[];return e.forEach(function(e,t){var n=a.get(t);if(void 0===n)if(o.has(t)){var r=(0,i.Cl)({},e.attributes);delete r.style,Object.keys(r).length>0&&d.push((0,i.Cl)((0,i.Cl)({},e),{attributes:r}))}else d.push(e);else d.push((0,i.Cl)((0,i.Cl)({},e),{attributes:(0,i.Cl)((0,i.Cl)({},e.attributes),{style:n})}))}),d}function fe(e){var t,n,r,s,o=e[0],a=new Map,l=new Map,c=new Map,u=new Map,d=new Map;e.forEach(function(e,t){var n,r,s,o,v=e.data;try{for(var h=(0,i.Ju)(v.adds),g=h.next();!g.done;g=h.next()){var f=g.value;a.has(f.node.id)||a.set(f.node.id,t),l.set(f.node.id,t),d.set(f.node.id,f.parentId)}}catch(S){n={error:S}}finally{try{g&&!g.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}try{for(var p=(0,i.Ju)(v.removes),m=p.next();!m.done;m=p.next()){var y=m.value;c.has(y.id)||c.set(y.id,t),u.set(y.id,t)}}catch(b){s={error:b}}finally{try{m&&!m.done&&(o=p.return)&&o.call(p)}finally{if(s)throw s.error}}});var v=new Set,h=new Set;try{for(var g=(0,i.Ju)(a),f=g.next();!f.done;f=g.next()){var p=(0,i.zs)(f.value,2),m=p[0],y=p[1],S=c.get(m);if(void 0!==S)l.get(m)>=u.get(m)||(y<S?v.add(m):S<y&&h.add(m))}}catch(H){t={error:H}}finally{try{f&&!f.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}var b=new Set;if(v.size>0||h.size>0)for(var I=!0;I;){I=!1;try{for(var C=(r=void 0,(0,i.Ju)(d)),w=C.next();!w.done;w=C.next()){var E=(0,i.zs)(w.value,2),P=E[0],k=E[1];if(!v.has(P)&&!h.has(P)&&!b.has(P)&&(v.has(k)||h.has(k)||b.has(k))){var x=c.get(P),M=a.get(P);void 0!==x&&void 0!==M&&x<M?h.add(P):void 0!==x&&void 0!==M&&x===M?b.add(P):v.add(P),I=!0}}}catch(q){r={error:q}}finally{try{w&&!w.done&&(s=C.return)&&s.call(C)}finally{if(r)throw r.error}}}var T=v.size>0||h.size>0||b.size>0,R=[];e.forEach(function(e,t){var n,r;try{for(var s=(0,i.Ju)(e.data.removes),o=s.next();!o.done;o=s.next()){var l=o.value;v.has(l.id)||(h.has(l.id)&&t>=a.get(l.id)||b.has(l.id)&&(v.has(l.parentId)||h.has(l.parentId)||b.has(l.parentId))||R.push(l))}}catch(c){n={error:c}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}});var O=e.flatMap(function(e){return e.data.adds}),F=e.flatMap(function(e){return e.data.texts}),L=e.flatMap(function(e){return e.data.attributes}),_=T?L.filter(function(e){return!v.has(e.id)&&!h.has(e.id)&&!b.has(e.id)}
1):L,D={source:oe.Mutation,removes:R,adds:T?O.filter(function(e){return!v.has(e.node.id)&&!h.has(e.node.id)&&!b.has(e.node.id)}):O,texts:T?F.filter(function(e){return!v.has(e.id)&&!h.has(e.id)&&!b.has(e.id)}):F,attributes:ge(_)};return(0,i.Cl)((0,i.Cl)({},o),{data:D})}function pe(e){if(e.length<=1)return e;for(var t=[],n=0;n<e.length;)if(he(e[n])){for(var r=n+1;r<e.length&&he(e[r]);)r++;t.push(r>n+1?fe(e.slice(n,r)):e[n]),n=r}else t.push(e[n]),n++;return t}var me=function(){function e(e,t,n,r,s){var a,l=this;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=e,n=t.type,r=t.timestamp,i=t.delay,s=t.data;return null!=i?JSON.stringify({type:n,timestamp:r,delay:i,data:s}):JSON.stringify({type:n,timestamp:r,data:s})},this.addCompressedEventToManager=function(e,t){var n,r=new Blob([e]).size;r>(null!==(n=l.config.maxSingleEventSizeBytes)&&void 0!==n?n:k)?l.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(r/1024)," KB exceeds maximum allowed event size. If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support.")):l.eventsManager&&l.deviceId&&l.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:l.deviceId})},this.addCompressedEvent=function(e,t){if(l.worker)try{l.worker.postMessage({event:e,sessionId:t})}catch(r){"DataCloneError"===r.name?l.worker.postMessage(JSON.stringify({event:e,sessionId:t})):l.config.loggerProvider.warn("Unexpected error while posting message to worker:",r)}else{var n=l.compressEvent(e);l.addCompressedEventToManager(n,t)}},this.flushQueue=function(){var e;for(l.pendingQueue.length>0&&(e=l.taskQueue).push.apply(e,(0,i.fX)([],(0,i.zs)(l.mergeMutationTasks(l.pendingQueue.splice(0))),!1));l.taskQueue.length>0;){var t=l.taskQueue.shift();if(t){var n=t.event,r=t.sessionId,s=l.compressEvent(n);l.addCompressedEventToManager(s,r)}}l.isProcessing=!1},this.terminate=function(){var e;null===(e=l.worker)||void 0===e||e.terminate()};var c=(0,o.m)();if(this.canUseIdleCallback=c&&"requestIdleCallback"in c,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null===(a=t.performanceConfig)||void 0===a?void 0:a.timeout)||2e3,this.onFullSnapshotProcessed=s,r){t.loggerProvider.log("Enabling web worker for compression");try{var u=new Blob([r],{type:"application/javascript"}),d=URL.createObjectURL(u),v=new Worker(d);v.onerror=function(e){e.preventDefault(),t.loggerProvider.error("Worker failed, falling back to non-worker compression: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),v.terminate(),l.worker=void 0},v.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;l.addCompressedEventToManager(n,r)},this.worker=v}catch(h){t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",h)}}}return e.prototype.scheduleIdleProcessing=function(){var e=this;this.isProcessing||(this.isProcessing=!0,requestIdleCallback(function(t){e.processQueue(t)},{timeout:this.timeout}))},e.prototype.enqueueEvent=function(e,t){var n,r,s,o;if(e.type===se.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var a=(0,i.fX)((0,i.fX)([],(0,i.zs)(this.taskQueue.splice(0)),!1),(0,i.zs)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var l=(0,i.Ju)(a),c=l.next();!c.done;c=l.next()){var u=c.value,d=this.compressEvent(u.event);this.addCompressedEventToManager(d,u.sessionId)}}catch(h){n={error:h}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}finally{if(n)throw n.error}}this.isProcessing=!1}var v=this.compressEvent(e);return this.addCompressedEventToManager(v,t),void(null===(s=this.onFullSnapshotProcessed)||void 0===s||s.call(this))}this.canUseIdleCallback&&(null===(o=this.config.performanceConfig)||void 0===o?void 0:o.enabled)?(this.config.loggerProvider.debug("Enqueuing event for processing during idle time."),this.pendingQueue.push({event:e,sessionId:t}),this.scheduleIdleProcessing()):(this.config.loggerProvider.debug("Processing event without idle callback."),this.addCompressedEvent(e,t))},e.prototype.processQueue=function(e){var t,n=this;for(this.pendingQueue.length>0&&(t=this.taskQueue).push.apply(t,(0,i.fX)([],(0,i.zs)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var r=this.taskQueue.shift();
1if(r){var s=r.event,o=r.sessionId;this.addCompressedEvent(s,o)}}this.taskQueue.length>0||this.pendingQueue.length>0?requestIdleCallback(function(e){n.processQueue(e)},{timeout:this.timeout}):this.isProcessing=!1},e.prototype.mergeMutationTasks=function(e){var t,n,r;if(!1===(null===(r=this.config.performanceConfig)||void 0===r?void 0:r.mergeMutations))return e;if(e.length<=1)return e;for(var s=[],o=0;o<e.length;){for(var a=e[o].sessionId,l=o+1;l<e.length&&e[l].sessionId===a;)l++;var c=pe(e.slice(o,l).map(function(e){return e.event}));try{for(var u=(t=void 0,(0,i.Ju)(c)),d=u.next();!d.done;d=u.next()){var v=d.value;s.push({event:v,sessionId:a})}}catch(h){t={error:h}}finally{try{d&&!d.done&&(n=u.return)&&n.call(u)}finally{if(t)throw t.error}}o=l}return s},e}(),ye=n(68553),Se="Session replay event batch rejected due to exceeded retry count",be="Failed to store session replay events in IndexedDB",Ie="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",Ce="1.48.1";function we(e,t){return(0,i.sH)(this,void 0,void 0,function(){var n,r,s,o,a,l,c,u,d,v,h,g,f,p,m=this;return(0,i.YH)(this,function(y){switch(y.label){case 0:return y.trys.push([0,4,,5]),n=t.CompressionStream,r=new n("gzip"),s=r.writable.getWriter(),o=r.readable.getReader(),a=[],l=(0,i.sH)(m,void 0,void 0,function(){var e,t,n;return(0,i.YH)(this,function(r){switch(r.label){case 0:return[4,o.read()];case 1:if(e=r.sent(),t=e.done,n=e.value,t)return[3,3];a.push(n),r.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,s.write((new TextEncoder).encode(e))];case 1:return y.sent(),[4,s.close()];case 2:return y.sent(),[4,l];case 3:y.sent(),c=a.reduce(function(e,t){return e+t.length},0),u=new Uint8Array(c),d=0;try{for(v=(0,i.Ju)(a),h=v.next();!h.done;h=v.next())g=h.value,u.set(g,d),d+=g.length}catch(S){f={error:S}}finally{try{h&&!h.done&&(p=v.return)&&p.call(v)}finally{if(f)throw f.error}}return[2,u];case 4:return y.sent(),[2,null];case 5:return[2]}})})}var Ee=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher,s=e.workerScript,o=e.enableTransportCompression,a=e.sendTimeoutMs,l=e.handleSendEvents,c=this;if(this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.timedOutWorkerRequests=new Map,this.flushPauseUntilMs=0,this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,this.mergeLogFiredThisPause=!1,this.killedSessions=new Set,this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t,this.enableTransportCompression=null==o||o,this.sendTimeoutMs=null!=a?a:1e4,this.handleSendEvents=l,s)try{var u=new Blob([s],{type:"application/javascript"}),d=URL.createObjectURL(u),v=new Worker(d);v.onerror=function(e){var t,r;e.preventDefault(),n.error("Track destination worker failed, falling back to main-thread sending: ".concat(e.message," (").concat(e.filename,":").concat(e.lineno,")")),v.terminate(),c.worker=void 0;try{for(var s=(0,i.Ju)(c.pendingWorkerRequests),o=s.next();!o.done;o=s.next()){var a=(0,i.zs)(o.value,2)[1];a.timeout&&clearTimeout(a.timeout),n.warn("Session replay event send failed due to worker crash: ".concat(e.message)),a.resolve()}}
1catch(l){t={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(t)throw t.error}}c.pendingWorkerRequests.clear(),c.timedOutWorkerRequests.clear()},v.onmessage=function(e){var t=e.data;if("log"===t.type)n.log(t.message);else if("warn"===t.type)n.warn(t.message);else if("payload_too_large"===t.type){var r=c.pendingWorkerRequests.get(t.id);if(r)r.timeout&&clearTimeout(r.timeout),c.handlePayloadTooLargeResponse(r.context,t.isWaf),r.resolve(),c.pendingWorkerRequests.delete(t.id);else(i=c.timedOutWorkerRequests.get(t.id))&&(c.timedOutWorkerRequests.delete(t.id),c.handlePayloadTooLargeResponse(i,t.isWaf))}else if("complete"===t.type){var i,s=c.pendingWorkerRequests.get(t.id);if(s)s.timeout&&clearTimeout(s.timeout),void 0!==t.skipCode&&c.applyServerDirective(s.context.sessionId,t.skipCode),c.completeRequest({context:s.context}),s.resolve(),c.pendingWorkerRequests.delete(t.id);else(i=c.timedOutWorkerRequests.get(t.id))&&(c.timedOutWorkerRequests.delete(t.id),void 0!==t.skipCode&&c.applyServerDirective(i.sessionId,t.skipCode),c.completeRequest({context:i}))}else"fetch-request"===t.type&&c.handleDelegatedFetch(v,t).catch(function(e){n.warn("Failed to handle delegated session replay fetch:",e)})},this.worker=v}catch(h){n.error("Failed to create track destination worker, falling back to main-thread sending:",h)}}return e.prototype.sendEventsList=function(e){this.addToQueue((0,i.Cl)((0,i.Cl)({},e),{attempts:0,timeout:0}))},e.prototype.markCoalesceNextFlush=function(){this.coalesceNextFlush=!0,this.schedule(0)},e.prototype.sendBeacon=function(e){var t,n,r=this,i=e.events,s=e.sessionId,a=e.deviceId,l=e.apiKey,c=e.serverZone,u=function(e){return new Blob([e]).size},d=i,v=JSON.stringify({version:2,events:d});if(u(v)>65536){for(var h=0,g=d.length;h<g;){var f=Math.floor((h+g+1)/2);u(JSON.stringify({version:2,events:d.slice(0,f)}))<=65536?h=f:g=f-1}d=d.slice(0,h),v=JSON.stringify({version:2,events:d}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(i.length," to ").concat(d.length," events"))}if(0!==d.length)if(this.handleSendEvents){var p=new URLSearchParams({device_id:a,session_id:String(s),type:"replay"}),m="".concat(ve(c,this.trackServerUrl),"?").concat(p.toString()),y={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(l)};this.loggerProvider.debug("Routing session replay exit batch (".concat(d.length," events) through custom transport for session id ").concat(s,"."));try{this.handleSendEvents({url:m,method:"POST",headers:y,body:v,keepalive:!0}).catch(function(e){r.loggerProvider.warn("Custom transport failed to send session replay exit batch:",e)})}catch(w){this.loggerProvider.warn("Custom transport threw while sending session replay exit batch:",w)}}else{var S=new URLSearchParams({device_id:a,session_id:String(s),type:"replay",api_key:l}),b="".concat(ve(c,this.trackServerUrl),"?").concat(S.toString()),I=(0,o.m)();try{var C=new Blob([v],{type:"application/json"});!1===(null===(n=null===(t=null==I?void 0:I.navigator)||void 0===t?void 0:t.sendBeacon)||void 0===n?void 0:n.call(t,b,C))&&this.loggerProvider.warn("sendBeacon failed to queue session replay payload")}catch(E){}}},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];t.filter(function(t){return e.killedSessions.has(t.sessionId)?(e.completeRequest({context:t,err:Ie}),!1):t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:Se}),!1)}).forEach(function(t){e.queue=e.queue.concat(t),e.schedule(0)})},e.prototype.schedule=function(e){var t=this;if(!this.scheduled){var n=this.flushPauseUntilMs-Date.now(),r=n>e?n:e;n>0&&(this.mergeOnNextFlush=!0),this.scheduled=setTimeout(function(){t.flush(!0).then(function(){t.queue.length>0&&t.schedule(e)})},r)}},e.prototype.flush=function(e){return void 0===e&&(e=!1),(0,i.sH)(this,void 0,void 0,function(){var t,n,r,s,o,a,l;return(0,i.YH)(this,function(c){switch(c.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),this.mergeOnNextFlush?(this.mergeOnNextFlush=!1,this.coalesceNextFlush=!1,t=this.mergeQueueAfterThrottle(t)):this.coalesceNextFlush&&(this.coalesceNextFlush=!1,t=this.mergeDrainBacklog(t)),c.label=1;case 1:c.trys.push([1,6,7,8]),n=(0,i.Ju)(t),r=n.next(),c.label=2;case 2:return r.done?[3,5]:(s=r.value,[4,this.send(s,e)]);case 3:c.sent(),c.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),a={error:o},[3,8];case 7:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(a)throw a.error}
1return[7];case 8:return[2]}})})},e.prototype.mergeQueueAfterThrottle=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&!this.mergeLogFiredThisPause&&(this.mergeLogFiredThisPause=!0,this.loggerProvider.log("Session replay throttle pause ended; merged ".concat(e.length," queued batches into ").concat(t.length," request(s)"))),t},e.prototype.mergeDrainBacklog=function(e){var t=this.coalesceByIdentity(e);return t.length<e.length&&this.loggerProvider.log("Session replay coalesced ".concat(e.length," persisted page-load backlog batches into ").concat(t.length," request(s)")),t},e.prototype.coalesceByIdentity=function(e){var t,n,r,s,o,a,l,c,u,d,v,h=this;if(e.length<=1)return e;var g=new Map;try{for(var f=(0,i.Ju)(e),p=f.next();!p.done;p=f.next()){var m=p.value,y=[m.sessionId,null!==(o=m.deviceId)&&void 0!==o?o:"",null!==(a=m.apiKey)&&void 0!==a?a:"",m.type,null!==(l=m.serverZone)&&void 0!==l?l:"",m.sampleRate,null!==(u=null===(c=m.version)||void 0===c?void 0:c.type)&&void 0!==u?u:"",null!==(v=null===(d=m.version)||void 0===d?void 0:d.version)&&void 0!==v?v:""].join("|"),S=g.get(y);S?S.push(m):g.set(y,[m])}}catch(E){t={error:E}}finally{try{p&&!p.done&&(n=f.return)&&n.call(f)}finally{if(t)throw t.error}}var b=[],I=function(e){var t,n;if(1===e.length)return b.push(e[0]),"continue";var r=null,s=0,o=function(){r&&b.push(r),r=null,s=0},a=function(e){var t=e.events.reduce(function(e,t){return e+new Blob([t]).size},0);if(null===r)return r=(0,i.Cl)((0,i.Cl)({},e),{events:(0,i.fX)([],(0,i.zs)(e.events),!1),attempts:0}),s=t,"continue";if(s+t>4e6)return o(),r=(0,i.Cl)((0,i.Cl)({},e),{events:(0,i.fX)([],(0,i.zs)(e.events),!1),attempts:0}),s=t,"continue";var n=r.onComplete,a=e.onComplete;r.events=r.events.concat(e.events),s+=t,r.onComplete=function(){return(0,i.sH)(h,void 0,void 0,function(){return(0,i.YH)(this,function(e){switch(e.label){case 0:return[4,Promise.allSettled([n(),a()])];case 1:return e.sent(),[2]}})})}};try{for(var l=(t=void 0,(0,i.Ju)(e)),c=l.next();!c.done;c=l.next()){a(c.value)}}catch(u){t={error:u}}finally{try{c&&!c.done&&(n=l.return)&&n.call(l)}finally{if(t)throw t.error}}o()};try{for(var C=(0,i.Ju)(g.values()),w=C.next();!w.done;w=C.next()){I(w.value)}}catch(P){r={error:P}}finally{try{w&&!w.done&&(s=C.return)&&s.call(C)}finally{if(r)throw r.error}}return b},e.prototype.send=function(e,t){return void 0===t&&(t=!0),(0,i.sH)(this,void 0,void 0,function(){var n,r,s,o;return(0,i.YH)(this,function(i){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:Ie})]:(n=e.apiKey)?(r=e.deviceId)?0===(s=this.payloadBatcher({version:1,events:e.events})).events.length?(this.completeRequest({context:e}),[2]):(o=this.worker)?[2,this.sendViaWorker(o,e,s,t)]:[2,this.sendOnMainThread(n,r,e,s,t)]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})]:[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})]})})},e.prototype.sendViaWorker=function(e,t,n,r){return(0,i.sH)(this,void 0,void 0,function(){var s,o=this;return(0,i.YH)(this,function(i){return s="".concat(++this.sendIdCounter),[2,new Promise(function(i){var a,l=o.sendTimeoutMs>0?setTimeout(function(){var e=o.pendingWorkerRequests.get(s);e&&(o.pendingWorkerRequests.delete(s),o.rememberTimedOutRequest(s,e.context),o.loggerProvider.warn("Session replay worker send timed out after ".concat(o.sendTimeoutMs,"ms; leaving events for retry")),e.resolve())},o.sendTimeoutMs):void 0;o.pendingWorkerRequests.set(s,{context:t,resolve:i,timeout:l}),e.postMessage({type:"send",id:s,payload:n,useRetry:r,useCustomTransport:!!o.handleSendEvents,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:null!==(a=t.flushMaxRetries)&&void 0!==a?a:0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:o.trackServerUrl,version:t.version,currentUrl:B(),sdkVersion:Ce,enableTransportCompression:o.enableTransportCompression,sendTimeoutMs:o.sendTimeoutMs}})})]})})},e.prototype.rememberTimedOutRequest=function(e,t){var n,r;if(this.timedOutWorkerRequests.set(e,t),this.timedOutWorkerRequests.size>256)try{for(var s=(0,i.Ju)(this.timedOutWorkerRequests.keys()),o=s.next();!o.done;o=s.next()){var a=o.value;this.timedOutWorkerRequests.delete(a);break}}catch(l){n={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}},e.prototype.handleDelegatedFetch=function(e,t){var n,r,s;return(0,i.sH)(this,void 0,void 0,function(){var o,a,l,c,u,d,v,h,g,f,p;return(0,i.YH)(this,function(i){switch(i.label){case 0:o=t.requestId,a=t.url,l=t.method,c=t.headers,u=t.body,d=t.keepalive,i.label=1;case 1:return i.trys.push([1,10,,11]),v=void 0,this.handleSendEvents?[4,this.handleSendEvents({url:a,method:l,headers:c,body:u,keepalive:d})]:[3,3];case 2:return v=i.sent(),[3,5];case 3:return this.loggerProvider.warn("Delegated session replay fetch received without a custom transport configured; falling back to built-in fetch."),[4,fetch(a,{method:l,headers:c,body:u,keepalive:d})];case 4:v=i.sent(),i.label=5;case 5:if(h=v.status,g=null,f="",h>=200&&h<300&&(g=null!==(s=null===(r=null===(n=v.headers)||void 0===n?void 0:n.get)||void 0===r?void 0:r.call(n,O))&&void 0!==s?s:null),413!==h)return[3,9];i.label=6;case 6:return i.trys.push([6,8,,9]),[4,v.text()];case 7:return f=i.sent(),[3,9];case 8:return i.sent(),[3,9];case 9:return this.loggerProvider.debug("Delegated session replay fetch (request ".concat(o,") returned status ").concat(h,".")),e.postMessage({type:"fetch-response",requestId:o,status:h,skipHeader:g,body:f}),[3,11];case 10:return p=i.sent(),this.loggerProvider.debug("Delegated session replay fetch (request ".concat(o,") failed:"),p),e.postMessage({type:"fetch-response",requestId:o,status:0,skipHeader:null,body:String(p),error:!0}),[3,11];case 11:return[2]}})})}
1,e.prototype.sendOnMainThread=function(e,t,n,r,s){var a,l,c,u,d,v,h;return(0,i.sH)(this,void 0,void 0,function(){var g,f,p,m,y,S,b,I,C,w,E,P,k,x,M,T,R,F,L,_,D,H;return(0,i.YH)(this,function(q){switch(q.label){case 0:g=B(),f=Ce,p=n.sampleRate,m=new URLSearchParams({device_id:t,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),y="".concat(null!==(l=null===(a=n.version)||void 0===a?void 0:a.type)&&void 0!==l?l:"standalone","/").concat(null!==(u=null===(c=n.version)||void 0===c?void 0:c.version)&&void 0!==u?u:f),q.label=1;case 1:return q.trys.push([1,19,,23]),S=JSON.stringify(r),b=(0,o.m)(),this.enableTransportCompression&&b&&"CompressionStream"in b?[4,we(S,b)]:[3,3];case 2:return C=q.sent(),[3,4];case 3:C=null,q.label=4;case 4:if(w=(I=C)?I.byteLength:new Blob([S]).size,E=new AbortController,P=(0,i.Cl)({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":f,"X-Client-Library":y,"X-Client-Url":g.substring(0,1e3),"X-Client-Sample-Rate":"".concat(p),"X-Sampling-Hash-Alg":"xxhash32"},I?{"Content-Encoding":"gzip"}:{}),M={headers:P,body:k=null!=I?I:S,method:"POST",keepalive:x=w<=65536,signal:E.signal},T="".concat(ve(n.serverZone,this.trackServerUrl),"?").concat(m.toString()),0===r.events.length)return this.completeRequest({context:n}),[2];R=this.sendTimeoutMs>0?setTimeout(function(){E.abort()},this.sendTimeoutMs):void 0,F=void 0,q.label=5;case 5:return q.trys.push([5,,10,11]),this.handleSendEvents?[4,(N=this.handleSendEvents({url:T,method:"POST",headers:P,body:k,keepalive:x}),A=E.signal,new Promise(function(e,t){var n=function(){var e=new Error("Custom session replay transport aborted by send timeout");e.name="AbortError",t(e)};A.addEventListener("abort",n,{once:!0}),N.then(function(t){A.removeEventListener("abort",n),e(t)},function(e){A.removeEventListener("abort",n),t(e)})}))]:[3,7];case 6:return L=q.sent(),[3,9];case 7:return[4,fetch(T,M)];case 8:L=q.sent(),q.label=9;case 9:return F=L,[3,11];case 10:return R&&clearTimeout(R),[7];case 11:if(null===F)return this.completeRequest({context:n,err:"Unexpected error occurred"}),[2];if(F.status>=200&&F.status<300&&(_=null!==(h=null===(v=null===(d=F.headers)||void 0===d?void 0:d.get)||void 0===v?void 0:v.call(d,O))&&void 0!==h?h:null,this.applyServerDirective(n.sessionId,_)),s)return[3,12];D="";try{D=JSON.stringify(F.body,null,2)}catch(z){}return this.completeRequest({context:n,success:"".concat(F.status,": ").concat(D)}),[3,18];case 12:if(D="",413!==F.status)return[3,16];q.label=13;case 13:return q.trys.push([13,15,,16]),[4,F.text()];case 14:return D=q.sent(),[3,16];case 15:return q.sent(),[3,16];case 16:return[4,this.handleReponse(F.status,n,D)];case 17:q.sent(),q.label=18;case 18:return[3,23];case 19:return H=q.sent(),!!H&&"object"==typeof H&&"AbortError"===H.name&&s?[4,this.handleOtherResponse(n)]:[3,21];case 20:return q.sent(),[3,22];case 21:this.completeRequest({context:n,err:H}),q.label=22;case 22:return[3,23];case 23:return[2]}var N,A})})},e.prototype.handleReponse=function(e,t,n){return void 0===n&&(n=""),(0,i.sH)(this,void 0,void 0,function(){var r;return(0,i.YH)(this,function(i){switch(i.label){case 0:switch(r=(new u.j).buildStatus(e),r){case ye.n.Success:return[3,1];case ye.n.Failed:case ye.n.Timeout:case ye.n.RateLimit:return[3,2];case ye.n.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:return i.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,x.test(n)),[3,8];case 5:return 499!==e?[3,7]:[4,this.handleOtherResponse(t)];case 6:return i.sent(),[3,8];case 7:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"}),i.label=8;case 8:return[2]}})})},e.prototype.handlePayloadTooLargeResponse=function(e,t){var n=t?"WAF (compressed payload too large)":"server (event too large)",r=Math.round(e.events.reduce(function(e,t){return e+t.length},0)/R);if(t)if(1!==e.events.length){this.loggerProvider.warn("Session replay event batch rejected by ".concat(n," (").concat(e.events.length," events, ").concat(r," KB total) — splitting and retrying")),e.onComplete();var s=function(){return Promise.resolve()},o=Math.floor(e.events.length/2);this.sendEventsList((0,i.Cl)((0,i.Cl)({},e),{events:e.events.slice(0,o),onComplete:s})),this.sendEventsList((0,i.Cl)((0,i.Cl)({},e),{events:e.events.slice(o),onComplete:s}))}else this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(r," KB, 1 event) rejected by ").concat(n," — cannot split further")});else this.completeRequest({context:e,err:"Session replay event batch dropped: ".concat(n," rejected payload (").concat(e.events.length," events, ").concat(r," KB) — not retrying non-WAF 413")})},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/R);this.completeRequest({context:e,success:"Session replay event batch tracked successfully for session id ".concat(e.sessionId,", size of events: ").concat(t," KB")})},e.prototype.handleOtherResponse=function(e){return(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.YH)(this,function(n){switch(n.label){case 0:return t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0)?(this.completeRequest({context:e,err:Se}),[2]):[4,new Promise(function(e){return setTimeout(e,t)})];case 1:return n.sent(),[4,this.send(e,!0)];case 2:return n.sent(),[2]}})})},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e.prototype.applyServerDirective=function(e,t){if(null===t)return this.flushPauseUntilMs=0,void(this.mergeLogFiredThisPause=!1);if("429"===t){var n=this.flushPauseUntilMs>Date.now();return this.flushPauseUntilMs=Date.now()+6e4,void(n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(60,"s")))}"4005"!==t&&"4004"!==t||this.killSession(e,t)},e.prototype.killSession=function(e,t){var n,r,s,o;
1if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>256)try{for(var a=(0,i.Ju)(this.killedSessions),l=a.next();!l.done;l=a.next()){var c=l.value;this.killedSessions.delete(c);break}}catch(g){n={error:g}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.loggerProvider.log("Session replay capture stopped for session ".concat(e," by server directive ").concat(t,"; remaining events will be dropped"));var u=[];try{for(var d=(0,i.Ju)(this.queue),v=d.next();!v.done;v=d.next()){var h=v.value;h.sessionId===e?this.completeRequest({context:h,err:Ie}):u.push(h)}}catch(f){s={error:f}}finally{try{v&&!v.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}this.queue=u}},e}(),Pe=n(60602),ke=function(){function e(e){var t,n,r,i=this;this.minInterval=M,this.maxInterval=T,this.maxPersistedEventsSize=6e6,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=i.getStringSize(t);return i.getEventsArraySize(e)+n>=i.maxPersistedEventsSize||!!(Date.now()-i.timeAtLastSplit>i.interval&&e.length)&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i._timeAtLastSplit=Date.now(),!0)},this.loggerProvider=e.loggerProvider,this.minInterval=null!==(t=e.minInterval)&&void 0!==t?t:this.minInterval,this.maxInterval=null!==(n=e.maxInterval)&&void 0!==n?n:this.maxInterval,this.maxPersistedEventsSize=null!==(r=e.maxPersistedEventsSize)&&void 0!==r?r:this.maxPersistedEventsSize,this.interval=this.minInterval}return Object.defineProperty(e.prototype,"timeAtLastSplit",{get:function(){return this._timeAtLastSplit},enumerable:!1,configurable:!0}),e.prototype.getStringSize=function(e){for(var t=0,n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r<=127)t++;else if(r<=2047)t+=2;else if(r>=55296&&r<=56319){var i=n+1<e.length?e.charCodeAt(n+1):NaN;i>=56320&&i<=57343?(t+=4,n++):t+=3}else t+=3}return t},e.prototype.getEventsArraySize=function(e){var t,n,r=0;try{for(var s=(0,i.Ju)(e),o=s.next();!o.done;o=s.next()){var a=o.value;r+=this.getStringSize(a)}}
1catch(l){t={error:l}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return r+(2+Math.max(0,e.length-1)+2*e.length)},e}(),xe=function(e,t,n){var r;"object"==typeof(r=n)&&null!==r&&"AbortError"===r.name?e.debug(t):e.warn(t)};var Me="sessionCurrentSequence",Te="sequencesToSend",Re=5e3;function Oe(e,t,n){var r=setTimeout(n,t);return e.then(function(){return clearTimeout(r)},function(){return clearTimeout(r)}),function(){return clearTimeout(r)}}var Fe,Le,_e,De=function(e){var t,n;return e.objectStoreNames.contains(Me)||(n=e.createObjectStore(Me,{keyPath:"sessionId"})),e.objectStoreNames.contains(Te)||(t=e.createObjectStore(Te,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},He=function(e){return(0,i.sH)(void 0,void 0,void 0,function(){return(0,i.YH)(this,function(t){switch(t.label){case 0:return[4,(n=(0,Pe.P2)(e,1,{upgrade:De}),r=2e3,i="IDB openDB timed out",void 0===i&&(i="IDB operation timed out"),new Promise(function(e,t){var s=setTimeout(function(){return t(new Error("".concat(i," after ").concat(r,"ms")))},r);n.then(function(t){clearTimeout(s),e(t)},function(e){clearTimeout(s),t(e)})}))];case 1:return[2,t.sent()]}var n,r,i})})},qe=function(e){function t(t){var n,r=this;return(r=e.call(this,t)||this).consecutiveFailures=0,r.hasTriggeredFallback=!1,r.emptyFilteredCount=0,r.getSequencesToSend=function(){return(0,i.sH)(r,void 0,void 0,function(){var e,t,n,r,s,o,a,l,c,u,d=this;return(0,i.YH)(this,function(i){switch(i.label){case 0:e=!1,t=!1,i.label=1;case 1:return i.trys.push([1,9,,10]),n=[],(r=this.db.transaction("sequencesToSend","readwrite")).done.catch(function(n){e||t||(xe(d.loggerProvider,"".concat(be,": ").concat(n),n),d.recordFailure())}),s=Oe(r.done,Re,function(){e||t||(t=!0,xe(d.loggerProvider,"".concat(be,": transaction timed out")),d.recordFailure())}),[4,r.store.openCursor()];case 2:o=i.sent(),i.label=3;case 3:return o?(a=o.value,l=a.sessionId,0!==(c=a.events).length?[3,5]:(this.maybeLogEmptyFiltered("getSequencesToSend"),[4,o.delete()])):[3,8];case 4:return i.sent(),[3,6];case 5:n.push({events:c,sequenceId:o.key,sessionId:l}),i.label=6;case 6:return[4,o.continue()];case 7:return o=i.sent(),[3,3];case 8:return this.recordSuccess(),s(),[2,n];case 9:return u=i.sent(),t||(e=!0,xe(this.loggerProvider,"".concat(be,": ").concat(u),u),this.recordFailure()),[3,10];case 10:return[2,void 0]}})})},r.storeCurrentSequence=function(e){return(0,i.sH)(r,void 0,void 0,function(){var t,n,r,s,o,a,l,c,u=this;return(0,i.YH)(this,function(d){switch(d.label){case 0:t=!1,n=!1,d.label=1;case 1:return d.trys.push([1,5,,6]),(r=this.db.transaction([Me,Te],"readwrite")).done.catch(function(e){t||n||(xe(u.loggerProvider,"".concat(be,": ").concat(e),e),u.recordFailure())}),s=Oe(r.done,Re,function(){t||n||(n=!0,xe(u.loggerProvider,"".concat(be,": transaction timed out")),u.recordFailure())}),[4,r.objectStore(Me).get(e)];case 2:return!(o=d.sent())||o.tabId&&o.tabId!==this.tabId?(s(),[2,void 0]):0===o.events.length?(this.maybeLogEmptyFiltered("storeCurrentSequence"),s(),[2,void 0]):[4,r.objectStore(Te).put({sessionId:e,events:o.events,tabId:this.tabId})];case 3:return a=d.sent(),[4,r.objectStore(Me).put({sessionId:e,events:[],tabId:this.tabId})];case 4:return d.sent(),this.recordSuccess(),s(),o.tabId,l=(0,i.Tt)(o,["tabId"]),[2,(0,i.Cl)((0,i.Cl)({},l),{sessionId:e,sequenceId:a})];case 5:return c=d.sent(),n||(t=!0,xe(this.loggerProvider,"".concat(be,": ").concat(c),c),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},r.addEventToCurrentSequence=function(e,t){return(0,i.sH)(r,void 0,void 0,function(){var n,r,s,o,a,l,c,u,d,v=this;return(0,i.YH)(this,function(i){switch(i.label){case 0:n=!1,r=!1,i.label=1;case 1:return i.trys.push([1,15,,16]),(s=this.db.transaction([Me,Te],"readwrite")).done.catch(function(e){n||r||(xe(v.loggerProvider,"".concat(be,": ").concat(e),e),v.recordFailure())}),o=Oe(s.done,Re,function(){n||r||(r=!0,xe(v.loggerProvider,"".concat(be,": transaction timed out")),v.recordFailure())}),[4,s.objectStore(Me).get(e)];case 2:return(null==(a=i.sent())?void 0:a.tabId)&&a.tabId!==this.tabId?a.events.length>0?[4,s.objectStore(Te).put({sessionId:e,events:a.events,tabId:a.tabId})]:[3,4]:[3,6];case 3:i.sent(),i.label=4;case 4:return[4,s.objectStore(Me).put({sessionId:e,events:[t],tabId:this.tabId})];case 5:return i.sent(),this.recordSuccess(),o(),[2,void 0];case 6:return(l=a)?[3,8]:[4,s.objectStore(Me).put({sessionId:e,events:[t],tabId:this.tabId})];case 7:return i.sent(),this.recordSuccess(),o(),[2,void 0];case 8:return this.shouldSplitEventsList(l.events,t)?[3,10]:[4,s.objectStore(Me).put({sessionId:e,events:l.events.concat(t),tabId:this.tabId})];case 9:return i.sent(),this.recordSuccess(),o(),[2,void 0];case 10:return 0!==(c=l.events).length?[3,12]:(this.maybeLogEmptyFiltered("addEventToCurrentSequence"),[4,s.objectStore(Me).put({sessionId:e,events:[t],tabId:this.tabId})]);case 11:return i.sent(),this.recordSuccess(),o(),[2,void 0];case 12:return[4,s.objectStore(Me).put({sessionId:e,events:[t],tabId:this.tabId})];case 13:return i.sent(),[4,s.objectStore(Te).put({sessionId:e,events:c,tabId:this.tabId})];case 14:return u=i.sent(),this.recordSuccess(),o(),[2,{events:c,sessionId:e,sequenceId:u}];case 15:return d=i.sent(),r||(n=!0,xe(this.loggerProvider,"".concat(be,": ").concat(d),d),this.recordFailure()),[3,16];case 16:return[2,void 0]}})})},r.storeSendingEvents=function(e,t){return(0,i.sH)(r,void 0,void 0,function(){var n,r;return(0,i.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.db.put(Te,{sessionId:e,events:t,tabId:this.tabId})];case 1:return n=i.sent(),this.recordSuccess(),[2,n];case 2:return r=i.sent(),xe(this.loggerProvider,"".concat(be,": ").concat(r),r),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},r.cleanUpSessionEventsStore=function(e,t){return(0,i.sH)(r,void 0,void 0,function(){var e;return(0,i.YH)(this,function(n){switch(n.label){case 0:if(!t)return[2];n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.db.delete(Te,t)];case 2:return n.sent(),this.recordSuccess(),[3,4];case 3:return e=n.sent(),xe(this.loggerProvider,"".concat(be,": ").concat(e),e),this.recordFailure(),[3,4];case 4:return[2]}})})},r.db=t.db,r.tabId=t.tabId,r.onPersistentFailure=t.onPersistentFailure,r.consecutiveFailureThreshold=null!==(n=t.consecutiveFailureThreshold)&&void 0!==n?n:1,r}return(0,i.C6)(t,e),t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(e," (idb store)"))},t.prototype.recordFailure=function(){var e;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,null===(e=this.onPersistentFailure)||void 0===e||e.call(this))},t.prototype.recordSuccess=function(){this.consecutiveFailures=0},t.new=function(e,n){var r;return(0,i.sH)(this,void 0,void 0,function(){var s,o,a,l,c;return(0,i.YH)(this,function(u){switch(u.label){case 0:return u.trys.push([0,2,,3]),s="replay"===e?"":"_".concat(e),o="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(s),[4,He(o
1)];case 1:return a=u.sent(),l=null!==(r=n.tabId)&&void 0!==r?r:function(){try{return crypto.randomUUID()}catch(r){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}}(),[2,new t((0,i.Cl)((0,i.Cl)({},n),{db:a,tabId:l}))];case 2:return c=u.sent(),xe(n.loggerProvider,"".concat(be,": ").concat(c),c),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return(0,i.sH)(this,void 0,void 0,function(){var t,n,r,s,o,a,l,c;return(0,i.YH)(this,function(u){switch(u.label){case 0:return e?[4,this.db.get("sessionCurrentSequence",e)]:[3,2];case 1:return(s=u.sent())?s.tabId&&s.tabId!==this.tabId?[2,void 0]:(s.tabId,[2,[o=(0,i.Tt)(s,["tabId"])]]):[2,void 0];case 2:t=[],u.label=3;case 3:return u.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:n=i.Ju.apply(void 0,[u.sent()]),r=n.next(),u.label=5;case 5:if(r.done)return[3,7];if((s=r.value).tabId&&s.tabId!==this.tabId)return[3,6];s.tabId,o=(0,i.Tt)(s,["tabId"]),t.push(o),u.label=6;case 6:return r=n.next(),[3,5];case 7:return[3,10];case 8:return a=u.sent(),l={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(l)throw l.error}return[7];case 10:return[2,t]}})})},t}(ke),Ne=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t.emptyFilteredCount=0,t}return(0,i.C6)(t,e),t.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},t.prototype.addSequence=function(e){var t=this.sequenceId++,n=(0,i.fX)([],(0,i.zs)(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},t.prototype.maybeLogEmptyFiltered=function(e){this.emptyFilteredCount++%100==0&&this.loggerProvider.debug("Filtered empty session replay sequence at ".concat(e," (in-memory store)"))},t.prototype.getSequencesToSend=function(){return(0,i.sH)(this,void 0,void 0,function(){var e,t,n,r,s,o,a,l,c,u;return(0,i.YH)(this,function(d){e=[];try{for(t=(0,i.Ju)(Object.entries(this.finalizedSequences)),n=t.next();!n.done;n=t.next())r=(0,i.zs)(n.value,2),s=r[0],o=r[1],a=o.sessionId,0!==(l=o.events).length?e.push({sequenceId:Number(s),sessionId:a,events:l}):(this.maybeLogEmptyFiltered("getSequencesToSend"),delete this.finalizedSequences[Number(s)])}catch(v){c={error:v}}finally{try{n&&!n.done&&(u=t.return)&&u.call(t)}finally{if(c)throw c.error}}return[2,e]})})},t.prototype.storeCurrentSequence=function(e){return(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.YH)(this,function(n){return(t=this.sequences[e])?0===t.length?(this.maybeLogEmptyFiltered("storeCurrentSequence"),[2,void 0]):[2,this.addSequence(e)]:[2,void 0]})})},t.prototype.addEventToCurrentSequence=function(e,t){return(0,i.sH)(this,void 0,void 0,function(){var n;return(0,i.YH)(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(0===this.sequences[e].length?this.maybeLogEmptyFiltered("addEventToCurrentSequence"):n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},t.prototype.storeSendingEvents=function(e,t){return(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},t.prototype.cleanUpSessionEventsStore=function(e,t){return(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},t}(ke),Ae=function(e){var t=e.config,n=e.minInterval,r=e.maxInterval,s=e.maxPersistedEventsSize,o=e.type,a=e.payloadBatcher,l=e.storeType,c=e.trackDestinationWorkerScript,u=e.shouldSend;return(0,i.sH)(void 0,void 0,void 0,function(){function e(e){return void 0===e&&(e=!1),(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(t){return[2,v.flush(e)]})})}var d,v,h,g,f,p,m,y,S,b,I,C,w,E,P,x,M;return(0,i.YH)(this,function(T){switch(T.label){case 0:return d=null!==(M=t.maxSingleEventSizeBytes)&&void 0!==M?M:k,v=new Ee((0,i.Cl)((0,i.Cl)({},t),{loggerProvider:t.loggerProvider,payloadBatcher:a,workerScript:c})),h=function(){return new Ne({loggerProvider:t.loggerProvider,maxInterval:r,minInterval:n,maxPer
1sistedEventsSize:s})},f=!1,m=function(){return(0,i.sH)(void 0,void 0,void 0,function(){var e,n,r;return(0,i.YH)(this,function(i){switch(i.label){case 0:return f?(f=!1,t.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),g?[4,p.getSequencesToSend()]:[3,2]):[2];case 1:return n=i.sent(),[3,3];case 2:n=void 0,i.label=3;case 3:return e=n,p=h(),e&&g&&(r=g,e.forEach(function(e){w({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})),[2]}})})},y=function(){return(0,i.sH)(void 0,void 0,void 0,function(){var e;return(0,i.YH)(this,function(i){switch(i.label){case 0:return[4,qe.new(o,{loggerProvider:t.loggerProvider,minInterval:n,maxInterval:r,maxPersistedEventsSize:s,apiKey:t.apiKey,onPersistentFailure:function(){m()}})];case 1:return(e=i.sent())?(f=!0,[2,e]):(t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,h()])}})})},"idb"!==l?[3,2]:[4,y()];case 1:return S=T.sent(),[3,3];case 2:S=h(),T.label=3;case 3:return p=S,b=[],I=0,C=function(e){if(!(e<=I)){var t=Math.min(e-I,b.length);t>0&&(b.splice(0,t),I=e)}},w=function(e){var n=e.events,r=e.sessionId,s=e.deviceId,a=e.sequenceId,l=n.map(function(e){return{event:e,bytes:new Blob([e]).size}}),c=l.filter(function(e){return e.bytes>d});c.length>0&&t.loggerProvider.warn("Dropping ".concat(c.length," oversized event(s) from session replay sequence before send. Sizes: ").concat(c.map(function(e){return"".concat(Math.round(e.bytes/1024)," KB")}).join(", "),". If this recurs, please open a GitHub issue at https://github.com/amplitude/Amplitude-TypeScript/issues or contact Amplitude support."));var u=c.length>0?l.filter(function(e){return e.bytes<=d}).map(function(e){return e.event}):n;0!==u.length?(t.debugMode&&j().then(function(e){var n=e.totalStorageSize,r=e.percentOfQuota,i=e.usageDetails;t.loggerProvider.debug("Total storage size: ".concat(n," KB, percentage of quota: ").concat(r,"%, usage details: ").concat(i))}).catch(function(){}),v.sendEventsList({events:u,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:s,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:o,onComplete:function(){return(0,i.sH)(void 0,void 0,void 0,function(){return(0,i.YH)(this,function(e){switch(e.label){case 0:return[4,p.cleanUpSessionEventsStore(r,a)];case 1:return e.sent(),[2]}})})}})):p.cleanUpSessionEventsStore(r,a).catch(function(e){t.loggerProvider.warn("Failed to clean up session replay events store:",e)})},E=function(e){var n=e.sessionId,r=e.deviceId;if(g=r,!u||u()){var i=I+b.length;p.storeCurrentSequence(n).then(function(e){e&&(C(i),w({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r}))}).catch(function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)})}},P=function(e){var n=e.deviceId;return(0,i.sH)(void 0,void 0,void 0,function(){var e;return(0,i.YH)(this,function(r){switch(r.label){case 0:return g=n,[4,p.getSequencesToSend()];case 1:return(null==(e=r.sent())?void 0:e.length)?(t.loggerProvider.log("Draining ".concat(e.length," stored sequence(s) from previous session.")),e.length>1&&v.markCoalesceNextFlush(),e.forEach(function(e){w({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:n})}),[2]):[2]}})})},x=function(e){var n=e.event,r=e.sessionId,i=e.deviceId;g=i;var s=!u||u(),o=I+b.length;b.push(n.data),p.addEventToCurrentSequence(r,n.data).then(function(e){if(e){if(!s)return p.cleanUpSessionEventsStore(e.sessionId,e.sequenceId).catch(function(e){t.loggerProvider.warn("Failed to clean up dropped session replay sequence:",e)}),void C(o);C(o),w({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})}}).catch(function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)})},[2,{sendCurrentSequenceEvents:E,addEvent:x,sendStoredEvents:P,flush:e,getBeaconEvents:function(){return(0,i.fX)([],(0,i.zs)(b),!1)},dropPendingBeaconEvents:function(){C(I+b.length)},trackDestination:v}]}})})},Be=function(){function e(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=new Map;e.forEach(function(e){n.set(e.name,e.manager)}),this.managers=n}return e.prototype.sendStoredEvents=function(e){return(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.YH)(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEac
1h(function(n){t.push(n.sendStoredEvents(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e.prototype.addEvent=function(e){var t,n=e.sessionId,r=e.event,i=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:i})},e.prototype.sendCurrentSequenceEvents=function(e){var t=e.sessionId,n=e.deviceId;this.managers.forEach(function(e){e.sendCurrentSequenceEvents({sessionId:t,deviceId:n})})},e.prototype.flush=function(e){return(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.YH)(this,function(n){switch(n.label){case 0:return t=[],this.managers.forEach(function(n){t.push(n.flush(e))}),[4,Promise.all(t)];case 1:return n.sent(),[2]}})})},e}();function ze(e,t){if(_e=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var n={root:document.body,idName:function(e){return!0},className:function(e){return!0},tagName:function(e){return!0},attr:function(e,t){return!1},seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};Fe=(0,i.Cl)((0,i.Cl)({},n),t),Le=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(Fe.root,n);var r=Ue(e,"all",function(){return Ue(e,"two",function(){return Ue(e,"one",function(){return Ue(e,"none")})})});if(r){var s=Ge(Ze(r,e));return s.length>0&&(r=s[0]),je(r)}throw new Error("Selector was not found.")}function Ue(e,t,n){for(var r=null,s=[],o=e,a=0,l=function(){var e,l,c=(new Date).getTime()-_e.getTime();if(void 0!==Fe.timeoutMs&&c>Fe.timeoutMs)throw new Error("Timeout: Can't find a unique selector after ".concat(c,"ms"));var u=Qe(function(e){var t=e.getAttribute("id");if(t&&Fe.idName(t))return{name:"#"+CSS.escape(t),penalty:0};return null}(o))||Qe.apply(void 0,(0,i.fX)([],(0,i.zs)(function(e){var t=Array.from(e.attributes).filter(function(e){return Fe.attr(e.name,e.value)});return t.map(function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}})}(o)),!1))||Qe.apply(void 0,(0,i.fX)([],(0,i.zs)(function(e){var t=Array.from(e.classList).filter(Fe.className);return t.map(function(e){return{name:"."+CSS.escape(e),penalty:1}})}(o)),!1))||Qe(function(e){var t=e.tagName.toLowerCase();if(Fe.tagName(t))return{name:t,penalty:2};return null}(o))||[{name:"*",penalty:3}],d=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;var r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(o);if("all"==t)d&&(u=u.concat(u.filter(Xe).map(function(e){return Ke(e,d)})));
1else if("two"==t)u=u.slice(0,1),d&&(u=u.concat(u.filter(Xe).map(function(e){return Ke(e,d)})));else if("one"==t){var v=(0,i.zs)(u=u.slice(0,1),1)[0];d&&Xe(v)&&(u=[Ke(v,d)])}else"none"==t&&(u=[{name:"*",penalty:3}],d&&(u=[Ke(u[0],d)]));try{for(var h=(e=void 0,(0,i.Ju)(u)),g=h.next();!g.done;g=h.next()){(v=g.value).level=a}}catch(f){e={error:f}}finally{try{g&&!g.done&&(l=h.return)&&l.call(h)}finally{if(e)throw e.error}}if(s.push(u),s.length>=Fe.seedMinLength&&(r=We(s,n)))return"break";o=o.parentElement,a++};o;){if("break"===l())break}return r||(r=We(s,n)),!r&&n?n():r}function We(e,t){var n,r,s=Ge($e(e));if(s.length>Fe.threshold)return t?t():null;try{for(var o=(0,i.Ju)(s),a=o.next();!a.done;a=o.next()){var l=a.value;if(Je(l))return l}}catch(c){n={error:c}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return null}function je(e){for(var t=e[0],n=t.name,r=1;r<e.length;r++){var i=e[r].level||0;n=t.level===i-1?"".concat(e[r].name," > ").concat(n):"".concat(e[r].name," ").concat(n),t=e[r]}return n}function Ye(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function Je(e){var t=je(e);switch(Le.querySelectorAll(t).length){case 0:throw new Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function Ke(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function Xe(e){return"html"!==e.name&&!e.name.startsWith("#")}function Qe(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(Ve);return n.length>0?n:null}function Ve(e){return null!=e}function $e(e,t){var n,r,s,o,a,l;return void 0===t&&(t=[]),(0,i.YH)(this,function(c){switch(c.label){case 0:if(!(e.length>0))return[3,9];c.label=1;case 1:c.trys.push([1,6,7,8]),n=(0,i.Ju)(e[0]),r=n.next(),c.label=2;case 2:return r.done?[3,5]:(s=r.value,[5,(0,i.Ju)($e(e.slice(1,e.length),t.concat(s)))]);case 3:c.sent(),c.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return o=c.sent(),a={error:o},[3,8];case 7:try{r&&!r.done&&(l=n.return)&&l.call(n)}finally{if(a)throw a.error}return[7];case 8:return[3,11];case 9:return[4,t];case 10:c.sent(),c.label=11;case 11:return[2]}})}function Ge(e){return(0,i.fX)([],(0,i.zs)(e),!1).sort(function(e,t){return Ye(e)-Ye(t)})}function Ze(e,t,n){var r,s,o;return void 0===n&&(n={counter:0,visited:new Map}),(0,i.YH)(this,function(a){switch(a.label){case 0:if(!(e.length>2&&e.length>Fe.optimizedMinLength))return[3,5];r=1,a.label=1;case 1:return r<e.length-1?n.counter>Fe.maxNumberOfTries?[2]:(n.counter+=1,(s=(0,i.fX)([],(0,i.zs)(e),!1)).splice(r,1),o=je(s),n.visited.has(o)?[2]:Je(s)&&function(e,t){return Le.querySelector(je(e))===t}(s,t)?[4,s]:[3,4]):[3,5];case 2:return a.sent(),n.visited.set(o,!0),[5,(0,i.Ju)(Ze(s,t,n))];case 3:a.sent(),a.label=4;case 4:return r++,[3,1];case 5:return[2]}})}var et=function(e){var t=e.version,n=e.events,r=[];return n.forEach(function(e){var t=JSON.parse(e);t.count=1,"click"===t.type&&r.push(t)}),{version:t,events:r}},tt=function(e){var t=e.version,n=e.events,r=[];n.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)});var s=r.reduce(function(e,t){var n=t.x,r=t.y,s=t.selector,o=t.timestamp,a=o-o%36e5,l="".concat(n,":").concat(r,":").concat(null!=s?s:"",":").concat(a);return e[l]?e[l].count+=1:e[l]=(0,i.Cl)((0,i.Cl)({},t),{timestamp:a,count:1}),e},{});return{version:t,events:Object.values(s)}},nt=function(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,s=e.mirror,a=e.ugcFilterRules,l=e.performanceOptions;return function(e){if(e.type===ae.Click){var c=(0,o.m)();if(c){var u=c.location,d=c.innerHeight,v=c.innerWidth;if(u){var h=e.x,g=e.y;if(void 0!==h&&void 0!==g){var f,p=s.getNode(e.id);if(p)try{f=ze(p,l)}catch(b){n.logger.debug("error resolving selector from finder")}var m=W(u.href,a),y={x:h+n.scrollWatcher.currentScrollX,y:g+n.scrollWatcher.currentScrollY,selector:f,viewportHeight:d,viewportWidth:v,pageUrl:m,timestamp:Date.now(),type:"click"},S=i();S&&t.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(y)},deviceId:S})}}}}}},this.logger=e,this.scrollWatcher=t};function rt(){var e=(0,o.m)();
1return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||0}function it(){var e=(0,o.m)();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||0}var st=function(){function e(e,t){var n=(0,o.m)();n&&n.navigator&&"function"==typeof n.navigator.sendBeacon?this.sendBeacon=function(e,t){try{if(n.navigator.sendBeacon(e,JSON.stringify(t)))return!0}catch(r){}return!1}:this.sendBeacon=function(){return!1},this.sendXhr=function(e,t){var n=new XMLHttpRequest;return n.open("POST",e,!0),n.setRequestHeader("Accept","*/*"),n.send(JSON.stringify(t)),!0},this.basePageUrl=ve(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e,this.handleSendEvents=t.handleSendEvents,this.loggerProvider=t.loggerProvider}return e.prototype.send=function(e,t){var n,r=this,i=this.context,s=i.sessionId,o=i.type;if(this.handleSendEvents){var a=new URLSearchParams({device_id:e,session_id:String(s),type:String(o)}),l="".concat(this.basePageUrl,"?").concat(a.toString()),c={"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(this.apiKey)};try{this.handleSendEvents({url:l,method:"POST",headers:c,body:JSON.stringify(t),keepalive:!0}).catch(function(e){var t;null===(t=r.loggerProvider)||void 0===t||t.warn("Custom transport failed to send session replay interaction beacon:",e)})}catch(v){null===(n=this.loggerProvider)||void 0===n||n.warn("Custom transport threw while sending session replay interaction beacon:",v)}}else{var u=new URLSearchParams({device_id:e,session_id:String(s),type:String(o),api_key:this.apiKey}),d="".concat(this.basePageUrl,"?").concat(u.toString());this.sendBeacon(d,t)||this.sendXhr(d,t)}},e}(),ot=function(){function e(e,t){var n=this;this.timestamp=Date.now(),this.hook=function(e){n.update(e)},this.send=function(e){return function(t){var r,i,s,a,l=e(),c=(0,o.m)();if(c&&l){var u=null!==(r=c.scrollX)&&void 0!==r?r:0,d=null!==(i=c.scrollY)&&void 0!==i?i:0;(u>0||d>0)&&n.update({id:1,x:u,y:d}),n.transport.send(l,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:rt(),viewportWidth:it(),pageUrl:W(c.location.href,null!==(a=null===(s=n.config.interactionConfig)||void 0===s?void 0:s.ugcFilterRules)&&void 0!==a?a:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=it(),this._maxScrollHeight=rt(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new st(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollY",{get:function(){return this._maxScrollY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollWidth",{get:function(){return this._maxScrollWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxScrollHeight",{get:function(){return this._maxScrollHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollX",{get:function(){return this._currentScrollX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentScrollY",{get:function(){return this._currentScrollY},enumerable:!1,configurable:!0}),e.prototype.update=function(e){var t=Date.now();if(this._currentScrollX=e.x,this._currentScrollY=e.y,e.x>this._maxScrollX){var n=it();this._maxScrollX=e.x;var r=e.x+n;r>this._maxScrollWidth&&(this._maxScrollWidth=r),this.timestamp=t}if(e.y>this._maxScrollY){var i=rt();this._maxScrollY=e.y;var s=e.y+i;s>this._maxScrollHeight&&(this._maxScrollHeight=s),this.timestamp=t}},e}(),at=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},lt=864e5,ct=function(e){return"".concat("AMP_SR_START_").concat(e.substring(0,10),"_")},ut=function(e,t){return"".concat(ct(e)).concat(t)},dt=function(){try{var e=(0,o.m)();return null==e?void 0:e.localStorage}catch(t){return}},vt=new function(){var e=this;this.dbs={},this.createStore=function(t){return(0,i.sH)(e,void 0,void 0,function(){return(0,i.YH)(this,function(e){switch(e.label){case 0:return[4,(0,Pe.P2)(t,1,{upgrade:function(e){e.objectStoreNames.contains("sessionTargetingMatch")||e.createObjectStore("sessionTargetingMatch",{keyPath:"sessionId"})}})];case 1:return[2,e.sent()]}})})},this.openOrCreateDB=function(t){return(0,i.sH)(e,void 0,void 0,function(){var e,n;return(0,i.YH)(this,function(r){switch(r.label){case 0:return this.dbs&&this.dbs[t]?[2,this.dbs[t]]:(e="".concat(t.substring(0,10),"_amp_session_replay_targeting"),[4,this.createStore(e)]);case 1:return n=r.sent(),this.dbs[t]=n,[2,n]}})})},this.getTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,s=t.sessionId;return(0,i.sH)(e,void 0,void 0,function(){var e,t,o,a;return(0,i.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=i.sent(),t=String(s),[4,e.get("sessionTargetingMatch",t)];case 2:return[2,null==(o=i.sent())?void 0:o.targetingMatch];case 3:return a=i.sent(),xe(n,"Failed to get targeting match for session id ".concat(s,": ").concat(a),a),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,s=t.sessionId,o=t.targetingMatch;return(0,i.sH)(e,void 0,void 0,function(){var e,t,a;return(0,i.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=i.sent(),t=String(s),[4,e.put("sessionTargetingMatch",{targetingMatch:o,sessionId:t,lastUpdated:Date.now()})];case 2:return[2,i.sent()];case 3:return a=i.sent(),xe(n,"Failed to store targeting match for session id ".concat(s,": ").concat(a),a),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,s=t.currentSessionId;return(0,i.sH)(e,void 0,void 0,function(){var e,t,o,a,l,c,u,d;return(0,i.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=i.sent(),t=String(s),[4,(o=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:a=i.sent(),l=0,i.label=3;case 3:return l<a.length?(c=a[l],u=Date.now()-c.lastUpdated,c.sessionId!==t&&u>1728e5?[4,o.store.delete(c.sessionId)]:[3,5]):[3,6];case 4:i.sent(),i.label=5;case 5:return l++,[3,3];case 6:return[4,o.done];case 7:return i.sent(),[3,9];case 8:return d=i.sent(),xe(n,"Failed to clear old targeting matches for sessions: ".concat(d),d),[3,9];case 9:return[2]}})})}},ht=function(e){var t=e.sessionId,r=e.targetingConfig,s=e.loggerProvider,o=e.apiKey,a=e.targetingParams,l=e.urlChange,c=void 0!==l&&l;return(0,i.sH)(void 0,void 0,void 0,function(){var e,l,u,d,v,h;return(0,i.YH)(this,function(g){switch(g.label){case 0:return[4,vt.clearStoreOfOldSessions({loggerProvider:s,apiKey:o,currentSessionId:t})];case 1:return g.sent(),[4,vt.getTargetingMatchForSession({loggerProvider:s,apiKey:o,sessionId:t})];case 2:if(!0===g.sent()&&!c)return[2,!0];e=!0,g.label=3;case 3:return g.trys.push([3,6,,7]),[4,n.e(5556).then(n.bind(n,55556))];case 4:return l=g.sent().evaluateTargeting,u=(0,i.Cl)((0,i.Cl)({},a),{flag:r,sessionId:"string"==typeof t?parseInt(t,10):t,apiKey:o,loggerProvider:s}),[4,l(u)];case 5:return(d=g.sent())&&d.sr_targeting_config&&(e="on"===d.sr_targeting_config.key),vt.storeTargetingMatchForSession({loggerProvider:s,apiKey:o,sessionId:t,targetingMatch:e}),[3,7];case 6:return v=g.sent(),h=v,s.warn(h.message),[3,7];case 7:return[2,e]}})})},gt=2654435761,ft=2246822519,pt=3266489917,mt=374761393;function yt(e,t){return(e<<t|e>>>32-t)>>>0}function St(e,t){return e=yt(e=e+Math.imul(t,ft)>>>0,13),e=Math.imul(e,gt)>>>0}function bt(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}function It(e,t){void 0===t&&(t=0);var n,r=function(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(r>=55296&&r<=56319&&n+1<e.length){var i=e.charCodeAt(n+1);i>=56320&&i<=57343&&(r=i-56320+(r-55296<<10)+65536,n++)}r<128?t.push(r):r<2048?t.push(192|r>>6,128|63&r):r<65536?t.push(224|r>>12,128|r>>6&63,128|63&r):t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|63&r)}return new Uint8Array(t)}(e),i=r.length,s=0;if(i>=16){for(var o=t+gt+ft>>>0,a=t+ft>>>0,l=t>>>0,c=t-gt>>>0;s<=i-16;)o=St(o,bt(r,s)),a=St(a,bt(r,s+=4)),l=St(l,bt(r,s+=4)),c=St(c,bt(r,s+=4)),s+=4;n=yt(o,1)+yt(a,7)+yt(l,12)+yt(c,18)>>>0}else n=t+mt>>>0;for(n=n+i>>>0;s<=i-4;)n=n+Math.imul(bt(r,s),pt)>>>0,n=Math.imul(yt(n,17),668265263)>>>0,s+=4;for(;s<i;)n=n+Math.imul(r[s],mt)>>>0,n=Math.imul(yt(n,11),gt)>>>0,s++;return n^=n>>>15,n=Math.imul(n,ft)>>>0,n^=n>>>13,n=Math.imul(n,pt)>>>0,(n^=n>>>16)>>>0}var Ct="__amplitude_url_tracking_patched__",wt=new WeakMap;function Et(e,t,n){if(void 0===n&&(n={}),!(null==e?void 0:e.location))return function(){};var r=n.enablePolling,i=void 0!==r&&r,s=n.pollingInterval,o=void 0===s?S:s;if(i){var a=function(){var t;return null!==(t=e.location.href)&&void 0!==t?t:""},l=a(),c=e.setInterval(function(){var e=a();e!==l&&(l=e,t(e))},o);return function(){null!=c&&e.clearInterval(c)}}var u=wt.get(e);if(!u){var d=void 0,v=new Set,h=function(){var t=function(){var t;return null!==(t=e.location.href)&&void 0!==t?t:""}();void 0!==d&&t===d||(d=t,v.forEach(function(e){return e(t)}))},g=function(e){var t=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=e.apply(this,t);return h(),r};return t[Ct]=!0,t},f=e.history;if(null==f?void 0:f.pushState){var p=Reflect.get(f,"pushState");p[Ct]||(f.pushState=g(p))}if(null==f?void 0:f.replaceState){var m=Reflect.get(f,"replaceState");m[Ct]||(f.replaceState=g(m))}u={callbacks:v,notify:h,onPopStateOrHashChange:function(){return h()},listenersAttached:!1},wt.set(e,u)}var y=u;return y.listenersAttached||(e.addEventListener("popstate",y.onPopStateOrHashChange),e.addEventListener("hashchange",y.onPopStateOrHashChange),y.listenersAttached=!0),y.callbacks.add(t),function(){y.callbacks.delete(t),0===y.callbacks.size&&y.listenersAttached&&(e.removeEventListener("popstate",y.onPopStateOrHashChange),e.removeEventListener("hashchange",y.onPopStateOrHashChange),y.listenersAttached=!1)}}function Pt(e){return void 0===e&&(e={}),{name:"amplitude/url-tracking@1",observer:function(t,n,r){var s,o,a,l=(0,i.Cl)((0,i.Cl)({},e),r),c=l.ugcFilterRules||[],u=null!==(s=l.enablePolling)&&void 0!==s&&s,d=null!==(o=l.pollingInterval)&&void 0!==o?o:S,v=null!==(a=l.captureDocumentTitle)&&void 0!==a&&a;if(!n)return function(){};var h=void 0,g=function(){return n.location&&n.location.href||""},f=function(){var e=g();if(void 0===h||e!==h){h=e;var r=function(){var e=n.innerHeight,t=n.innerWidth,r=n.document,i=g(),s="";return v&&(s=(null==r?void 0:r.title)||""),{href:c.length>
10?W(i,c):i,title:s,viewportHeight:e,viewportWidth:t,type:"url-change-event"}}();t(r)}},p=Et(n,function(){return f()},u?{enablePolling:!0,pollingInterval:d}:{});return f(),function(){return p()}},options:e}}Pt();var kt=function(){function e(){this.pendingLoadListeners=new Map}return e.prototype.start=function(){var e,t=this;null===(e=this.mutationObserver)||void 0===e||e.disconnect(),(0,o.m)()&&(this.sendToAllIframes({type:F,action:"start"}),this.mutationObserver=new MutationObserver(function(e){var n,r,s,o,a,l;try{for(var c=(0,i.Ju)(e),u=c.next();!u.done;u=c.next()){var d=u.value;try{for(var v=(s=void 0,(0,i.Ju)(Array.from(d.addedNodes))),h=v.next();!h.done;h=v.next()){(p=h.value)instanceof HTMLIFrameElement?t.sendToIframeAfterLoad(p):p instanceof Element&&p.querySelectorAll("iframe").forEach(function(e){t.sendToIframeAfterLoad(e)})}}catch(y){s={error:y}}finally{try{h&&!h.done&&(o=v.return)&&o.call(v)}finally{if(s)throw s.error}}try{for(var g=(a=void 0,(0,i.Ju)(Array.from(d.removedNodes))),f=g.next();!f.done;f=g.next()){var p;if((p=f.value)instanceof HTMLIFrameElement){var m=t.pendingLoadListeners.get(p);m&&(p.removeEventListener("load",m),t.pendingLoadListeners.delete(p))}}}catch(S){a={error:S}}finally{try{f&&!f.done&&(l=g.return)&&l.call(g)}finally{if(a)throw a.error}}}}catch(b){n={error:b}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}}),this.mutationObserver.observe(document.documentElement,{childList:!0,subtree:!0}))},e.prototype.stop=function(){var e;null===(e=this.mutationObserver)||void 0===e||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(e,t){t.removeEventListener("load",e)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:F,action:"stop"})},e.prototype.sendToIframeAfterLoad=function(e){var t=this,n=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:F,action:"start"})};this.pendingLoadListeners.set(e,n),e.addEventListener("load",n,{once:!0})},e.prototype.sendToAllIframes=function(e){var t=this;document.querySelectorAll("iframe").forEach(function(n){return t.sendToIframe(n,e)})},e.prototype.sendToIframe=function(e,t){var n;try{null===(n=e.contentWindow)||void 0===n||n.postMessage(t,"*")}catch(r){}},e}();var xt,Mt,Tt,Rt,Ot=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,this.recordFunction=null,this.recordEventsInFlight=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeCoordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var n=(0,o.m)();n&&(n.removeEventListener("blur",e.blurListener),n.removeEventListener("focus",e.focusListener),!t&&n.addEventListener("blur",e.blurListener),!t&&n.addEventListener("focus",e.focusListener),n.self&&"onpagehide"in n.self?(n.removeEventListener("pagehide",e.pageLeaveListener),!t&&n.addEventListener("pagehide",e.pageLeaveListener)):(n.removeEventListener("beforeunload",e.pageLeaveListener),!t&&n.addEventListener("beforeunload",e.pageLeaveListener)))},this.blurListener=function(){e.sendEvents()},this.focusListener=function(){var t;if(e.recordCancelCallback&&e.recordFunction){if(!1===(null===(t=e.config)||void 0===t?void 0:t.captureFullSnapshotOnFocus))return;try{e.recordFunction.takeFullSnapshot(!0)}catch(n){e.loggerProvider.warn("Failed to take full snapshot on focus:",n)}}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(t){var n;null===(n=e.eventCompressor)||void 0===n||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,r,a){return void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===a&&(a=!1),(0,i.sH)(e,void 0,void 0,function(){var e,l,c,u,d,v,h,g,f,p,m,y;return(0,i.YH)(this,function(i){switch(i.label){case 0:if(!this.identifiers||!this.identifiers.sessionId||!this.config)return this.identifiers&&!this.identifiers.sessionId?this.loggerProvider.log("Session ID has not been set yet, cannot evaluate targeting for Session Replay."):this.loggerProvider.warn("Session replay init has not been called, cannot evaluate targeting."),[2];if(!this.config.targetingConfig){if(!n)return this.loggerProvider.log("No targeting config set, skipping initialization/recording for event."),[2];this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.")}return this.lastTargetingParams=t,e=this.config.targetingConfig,e&&!this.sessionTargetingMatch?(l=a?this.latestUrlChangeTargetingEvaluationId:void 0,(c=t.event)&&Object.values(s.S).includes(c.event_type)&&(c=void 0),u=null!==(m=null!==(g=null===(h=t.page)||void 0===h?void 0:h.url)&&void 0!==g?g:null===(p=null===(f=(0,o.m)())||void 0===f?void 0:f.location)||void 0===p?void 0:p.href)&&void 0!==m?m:"",d=null!==(y=t.page)&&void 0!==y?y:""!==u?{url:u}:void 0,[4,ht({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:c,page:d},urlChange:a})]):[3,2];case 1:if(v=i.sent(),a&&void 0!==l&&l!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(l,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||v,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:c,targetingParams:t},null,2)),i.label=2;case 2:return n?(this.initialize(!0),[3,5]):[3,3];case 3:return!r&&this.recordCancelCallback?[3,5]:(this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()]);case 4:i.sent(),i.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,s){return void 0===n&&(n={}),void 0===s&&(s=!0),(0,i.sH)(e,void 0,void 0,function(){var e,o,a,l;return(0,i.YH)(this,function(c){switch(c.label){case 0:return c.trys.push([0,3,,4]),e=void 0,(o=this.config)&&t!==r.METADATA?(e={config:Y(o),version:Ce},s?[4,j()]:[3,2]):[3,2];case 1:a=c.sent(),e=(0,i.Cl)((0,i.Cl)({},a),e),c.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,(0,i.Cl)((0,i.Cl)({},n),e)):this.loggerProvider.debug("Not able to add custom replay capture event ".concat(t," due to no ongoing recording.")),[3,4];case 3:return l=c.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",l),[3,4];case 4:return[2]}})})},this.stopRecordingEvents=function(){var t,n,r;try{e.loggerProvider.log("Session Replay capture stopping."),e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null,null===(t=e.networkObservers)||void 0===t||t.stop(),null===(n=e.crossOriginIframeC
1oordinator)||void 0===n||n.stop(),e.crossOriginIframeCoordinator=null,null===(r=e.crossOriginParentSignalCleanup)||void 0===r||r.call(e),e.crossOriginParentSignalCleanup=null}catch(s){var i=s;e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(i.toString()))}},this.loggerProvider=new L(new c.V)}return e.prototype.init=function(e,t){return(0,Z.m)(this._init(e,t))},e.prototype.setupUrlChangeListener=function(){var e,t,n=this;null===(e=this.urlChangeCleanup)||void 0===e||e.call(this);var r=(0,o.m)();if(null==r?void 0:r.location){var i=!!(null===(t=this.config)||void 0===t?void 0:t.targetingConfig),s=Et(r,function(e){if(n.currentPageUrl=e,i){var t=++n.latestUrlChangeTargetingEvaluationId;n.evaluateTargetingAndCapture({userProperties:{},event:void 0,page:{url:e}},!1,!1,!0),n.loggerProvider.debug("Queued URL-change targeting re-evaluation #".concat(t," for ").concat(e,"."))}});this.urlChangeCleanup=function(){s(),n.urlChangeCleanup=null}}},e.prototype.isBelowMinSessionDuration=function(){var e,t=null===(e=this.config)||void 0===e?void 0:e.minSessionDurationMs;return void 0!==t&&void 0!==this.sessionStartTime&&Date.now()-this.sessionStartTime<t},e.prototype.getCurrentPageForTargeting=function(){var e,t,n=null===(t=null===(e=(0,o.m)())||void 0===e?void 0:e.location)||void 0===t?void 0:t.href;return null!=n?{url:n}:void 0},e.prototype._init=function(e,t){var r,s,a,l,u,d,v,h,g,f,p,m,y,S;return(0,i.sH)(this,void 0,void 0,function(){var b,I,C,w,E,P,k,x,M,T,R,O,F,_,D,H,q,N,A,z,U,W,j,Y,J,K,X,Q,V,$,G,Z=this;return(0,i.YH)(this,function(re){switch(re.label){case 0:return null===(r=this.urlChangeCleanup)||void 0===r||r.call(this),this.loggerProvider=new L(t.loggerProvider||new c.V),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.currentPageUrl=B(),this.identifiers=new at({sessionId:t.sessionId,deviceId:t.deviceId}),b=Date.now(),function(e,t,n){var r,s,o=dt();if(o){var a=ct(e);try{for(var l=[],c=0;c<o.length;c++)if((g=o.key(c))&&g.startsWith(a)){var u=o.getItem(g);if(null!==u){var d=Number(u);(!Number.isFinite(d)||d<=0||t-d>=lt)&&l.push(g)}}try{for(var v=(0,i.Ju)(l),h=v.next();!h.done;h=v.next()){var g=h.value;o.removeItem(g)}}catch(f){r={error:f}}finally{try{h&&!h.done&&(s=v.return)&&s.call(v)}finally{if(r)throw r.error}}}catch(p){null==n||n.debug("Failed to prune stale replay start times: ".concat(String(p)))}}}(e,b,this.loggerProvider),this.sessionStartTime=void 0!==t.sessionId&&null!==(s=function(e,t,n,r){var i=dt();if(i){var s=ut(e,t);try{var o=i.getItem(s);if(null!==o){var a=Number(o);if(Number.isFinite(a)&&a>0&&a<=n&&n-a<lt)return a}return i.setItem(s,String(n)),n}catch(l){return void(null==r||r.debug("Failed to read/write replay start time from storage: ".concat(String(l))))}}}(e,t.sessionId,b,this.loggerProvider))&&void 0!==s?s:b,I=this,[4,de(e,t)];case 1:return I.joinedConfigGenerator=re.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:return C=re.sent(),w=C.joinedConfig,E=C.localConfig,P=C.remoteConfig,this.config=w,this.setMetadata(t.sessionId,w,E,P,null===(a=t.version)||void 0===a?void 0:a.version,Ce,null===(l=t.version)||void 0===l?void 0:l.type),this.pageLeaveFns=[],t.sessionId&&(null===(u=this.config.interactionConfig)||void 0===u?void 0:u.enabled)&&(k=ot.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[k.send(this.getDeviceId.bind(this)).bind(k)],this.scrollHook=k.hook.bind(k),this.clickHandler=new nt(this.loggerProvider,k)),x=[],"idb"!==(M=this.config.storeType)||(null===(d=(0,o.m)())||void 0===d?void 0:d.indexedDB)||(M="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(M," for event storage.")),O=(0,o.m)(),this.config.useWebWorker&&O&&O.Worker?[4,n.e(7207).then(n.bind(n,87207))]:[3,4];case 3:F=re.sent(),_=F.compressionScript,D=F.trackDestinationScript,T=_,R=D,re.label=4;case 4:return re.trys.push([4,6,,7]),[4,Ae({config:this.config,type:"replay",minInterval:null===(v=this.config.flushIntervalConfig)||void 0===v?void 0:v.minIntervalMs,maxInterval:null===(h=this.config.flushIntervalConfig)||void 0===h?void 0:h.maxIntervalMs,maxPer
1sistedEventsSize:this.config.maxPersistedEventsSizeBytes,storeType:M,trackDestinationWorkerScript:R,shouldSend:function(){return!Z.isBelowMinSessionDuration()}})];case 5:return H=re.sent(),this.rrwebEventManager=H,x.push({name:"replay",manager:H}),[3,7];case 6:return q=re.sent(),U=q,this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(U.toString())),[3,7];case 7:if(!(null===(g=this.config.interactionConfig)||void 0===g?void 0:g.enabled))return[3,11];N=this.config.interactionConfig.batch?tt:et,re.label=8;case 8:return re.trys.push([8,10,,11]),[4,Ae({config:this.config,type:"interaction",minInterval:null!==(f=this.config.interactionConfig.trackEveryNms)&&void 0!==f?f:3e4,maxInterval:6e4,maxPersistedEventsSize:this.config.maxPersistedEventsSizeBytes,payloadBatcher:N,storeType:M,trackDestinationWorkerScript:R})];case 9:return A=re.sent(),x.push({name:"interaction",manager:A}),[3,11];case 10:return z=re.sent(),U=z,this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(U.toString())),[3,11];case 11:if(this.eventsManager=new(Be.bind.apply(Be,(0,i.fX)([void 0],(0,i.zs)(x),!1))),this.eventCompressor&&this.eventCompressor.terminate(),W=!0===this.config.eagerFullSnapshotSend?function(){return Z.sendEvents()}:void 0,this.eventCompressor=new me(this.eventsManager,this.config,this.getDeviceId(),T,W),this.pendingEmitEvents.length>0){j=this.pendingEmitEvents.splice(0);try{for(Y=(0,i.Ju)(j),J=Y.next();!J.done;J=Y.next())K=J.value,X=K.event,Q=K.sessionId,this.eventCompressor.enqueueEvent(X,Q)}catch(ie){$={error:ie}}finally{try{J&&!J.done&&(G=Y.return)&&G.call(Y)}finally{if($)throw $.error}}}return this.pageLeaveFns=(0,i.fX)((0,i.fX)([],(0,i.zs)(this.pageLeaveFns),!1),[function(){var e;if(Z.config&&(null===(e=Z.identifiers)||void 0===e?void 0:e.sessionId)&&H){var t=H.getBeaconEvents();if(t.length){var n=Z.getDeviceId();n&&(Z.isBelowMinSessionDuration()||H.trackDestination.sendBeacon({events:t,sessionId:Z.identifiers.sessionId,deviceId:n,apiKey:Z.config.apiKey,serverZone:Z.config.serverZone}))}}}],!1),[4,this.initializeNetworkObservers()];case 12:return re.sent(),(null===(p=(0,o.m)())||void 0===p?void 0:p.opener)&&(V=(0,ee.Z)(),(0,te.E)(V),V.setup((0,i.Cl)({logger:this.loggerProvider},this.config.serverZone&&{endpoint:ne.ht[this.config.serverZone]}))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),this.teardownEventListeners(!1),[4,this.evaluateTargetingAndCapture({userProperties:t.userProperties,page:this.getCurrentPageForTargeting()},!0)];case 13:return re.sent(),(this.config.targetingConfig||(null!==(S=null===(y=null===(m=this.config.privacyConfig)||void 0===m?void 0:m.urlMaskLevels)||void 0===y?void 0:y.length)&&void 0!==S?S:0)>0)&&this.setupUrlChangeListener(),[2]}})})},e.prototype.setSessionId=function(e,t){return(0,Z.m)(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t,n){var r,s,o,a;return(0,i.sH)(this,void 0,void 0,function(){var l,c,u,d,v;return(0,i.YH)(this,function(i){switch(i.label){case 0:return l=null===(r=this.identifiers)||void 0===r?void 0:r.sessionId,c=this.getDeviceId(),void 0===l||l!==e||void 0!==t&&t!==c||void 0!==(null==n?void 0:n.userProperties)&&0!==Object.keys(n.userProperties).length?(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,l&&this.sendEvents(l),(u=l!==e)&&(null===(s=this.rrwebEventManager)||void 0===s||s.dropPendingBeaconEvents()),d=t||this.getDeviceId(),this.identifiers=new at({sessionId:e,deviceId:d}),u&&(this.sessionStartTime=Date.now(),this.suppressedSendCount=0,this.hasEmittedGateDecision=!1,(null===(o=this.config)||void 0===o?void 0:o.apiKey)&&(function(e,t,n,r){var i=dt();if(i)try{i.setItem(ut(e,t),String(n))}catch(s){null==r||r.debug("Failed to write replay start time to storage: ".concat(String(s)))}}(this.config.apiKey,e,this.sessionStartTime,this.loggerProvider),void 0!==l&&function(e,t,n){var r=dt();if(r)try{r.removeItem(ut(e,t))}catch(i){null==n||n.debug("Failed to remove replay start time from storage: ".concat(String(i)))}}(this.config.apiKey,l,this.loggerProvider))),this.joinedConfigGenerator&&l?[4,this.joinedConfigGenerator.generateJoinedConfig()]:[3,2]):[2];case 1:v=i.sent().joinedConfig,this.config=v,i.label=2;case 2:return(null===(a=this.config)||void 0===a?void 0:a.targetingConfig)?[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)]:[3,4];case 3:return i.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:i.sent(),i.label=6;case 6:return[2]}})})},e.prototype.getSessionReplayProperties=function(){var e,t=this.config,n=this.identifiers;if(!t||!n)return this.loggerProvider.warn("Session replay init has not been called, cannot get session replay properties."),{};var i=this.getShouldRecord(),s={};return i&&((e={}
1)[p]=n.sessionReplayId?n.sessionReplayId:null,s=e,t.debugMode&&(s[b]=JSON.stringify({appHash:(0,re.fI)(t.apiKey).toString()}))),this.addCustomRRWebEvent(r.GET_SR_PROPS,{shouldRecord:i,eventProperties:s},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,s},e.prototype.sendEvents=function(e){var t,n,i=e||(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId),s=this.getDeviceId();if(this.eventsManager&&i&&s){if(this.isBelowMinSessionDuration()){var o=this.sessionStartTime,a=this.config.minSessionDurationMs;return this.loggerProvider.log("Session ".concat(i," not sent: duration ").concat(Date.now()-o,"ms is below minimum ").concat(a,"ms.")),void this.suppressedSendCount++}if(!this.hasEmittedGateDecision&&void 0!==(null===(n=this.config)||void 0===n?void 0:n.minSessionDurationMs)&&this.recordCancelCallback&&this.recordFunction){this.hasEmittedGateDecision=!0;var l=void 0!==this.sessionStartTime?Date.now()-this.sessionStartTime:void 0;this.addCustomRRWebEvent(r.REPLAY_GATE_DECISION,{sessionId:i,suppressedSendCount:this.suppressedSendCount,elapsedMs:l,minSessionDurationMs:this.config.minSessionDurationMs},!1)}this.eventsManager.sendCurrentSequenceEvents({sessionId:i,deviceId:s})}},e.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),(0,i.sH)(this,void 0,void 0,function(){var n;return(0,i.YH)(this,function(r){return(null===(t=this.identifiers)||void 0===t?void 0:t.sessionId)?(n=this.getDeviceId())?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),[2,this.recordEvents()]):(this.loggerProvider.log("Session is not being recorded due to lack of device id."),[2,Promise.resolve()]):(this.loggerProvider.log("Session is not being recorded due to lack of session id."),[2,Promise.resolve()])})})},e.prototype.shouldOptOut=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=(0,ie.w$)(this.config.instanceName).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(){if(!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.warn("Session is not being recorded due to lack of config, please call sessionReplay.init."),!1;if(!this.config.captureEnabled)return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," not being captured due to capture being disabled for project or because the remote config could not be fetched.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var e,t,n=!1,i="",s=!1;this.config.targetingConfig?this.sessionTargetingMatch?(i="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(i),n=!0,s=!0):(i="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(i),n=!1,s=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,It(e.toString())%1e6/1e6<t)?(n=!0,s=!0):(i="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(i),n=!1,s=!1);return this.lastShouldRecordDecision!==n&&this.config.targetingConfig&&(this.addCustomRRWebEvent(r.TARGETING_DECISION,{message:i,sessionId:this.identifiers.sessionId,matched:s,targetingParams:this.lastTargetingParams}),this.lastShouldRecordDecision=n),n},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n=null===(e=this.config)||void 0===e?void 0:e.privacyConfig;if("conservative"===(n?H(this.currentPageUrl,n):void 0))return"*";if(null===(t=null==n?void 0:n.urlMaskLevels)||void 0===t?void 0:t.some(function(e){return"conservative"===e.maskLevel}))return"*";var r=null==n?void 0:n.urlMaskLevels;if("conservative"===(null==n?void 0:n.defaultMaskLevel)&&r&&r.length>0)return"*";var i=null==n?void 0:n.maskSelector;return i||void 0},e.prototype.getRecordingPlugins=function(e){var t,r,s,o,a,l;return(0,i.sH)(this,void 0,void 0,function(){var c,u,d,v;return(0,i.YH)(this,function(i){switch(i.label){case 0:c=[];try{u=Pt({ugcFilterRules:(null===(r=null===(t=this.config)||void 0===t?void 0:t.interactionConfig)||void 0===r?void 0:r.ugcFilterRules)||[],enablePolling:(null===(s=this.config)||void 0===s?void 0:s.enableUrlChangePolling)||!1,pollingInterval:null===(o=this.config)||void 0===o?void 0:o.urlChangePollingInterval,captureDocumentTitle:null===(a=this.config)||void 0===a?void 0:a.captureDocumentTitle}),c.push(u)}catch(h){this.loggerProvider.warn("Failed to create URL tracking plugin:",h)}if(!(null===(l=null==e?void 0:e.console)||void 0===l?void 0:l.enabled))return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n.e(4559).then(n.bind(n,82923))];case 2:return d=i.sent().getRecordConsolePlugin,c.push(d({level:e.console.levels})),[3,4];case 3:return v=i.sent(),this.loggerProvider.warn("Failed to load console plugin:",v),[3,4];case 4:return[2,c.length>0?c:void 0]}})})},e.prototype.getRecordFunction=function(){return(0,i.sH)(this,void 0,void 0,function(){var e,t;return(0,i.YH)(this,function(r){switch(r.label){case 0:if(this.recordFunction)return[2,this.recordFunction];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,n.e(3362).then(n.bind(n,53123))];case 2:return e=r.sent().record,this.recordFunction=e,[2,e];case 3:return t=r.sent(),this.loggerProvider.warn("Failed to load rrweb-record module:",t),[2,null];case 4:return[2]}})})},e.prototype.recordEvents=function(e){return void 0===e&&(e=!0),(0,i.sH)(this,void 0,void 0,function(){var t;return(0,i.YH)(this,function(n){switch(n.label){case 0:if(this.recordEventsInFlight)return this.recordEventsPendingShouldLogMetadata=e,[2];this.recordEventsInFlight=!0,n.label=1;case 1:return n.trys.push([1,,6,7]),[4,this._recordEvents(e)];case 2:n.sent(),n.label=3;case 3:return null===this.recordEventsPendingShouldLogMetadata?[3,5]:(t=this.recordEventsPendingShouldLogMetadata,this.recordEventsPendingShouldLogMetadata=null,[4,this._recordEvents(t)]);case 4:return n.sent(),[3,3];case 5:return[3,7];case 6:return this.recordEventsInFlight=!1,this.recordEventsPendingShouldLogMetadata=null,[7];case 7:return[2]}})})},e.prototype._recordEvents=function(e){var t,n,s,a,l,c,u,d;return void 0===e&&(e=!0),(0,i.sH)(this,void 0,void 0,function(){var v,h,g,f,p,m,y,S,b,I,C,k,x,M,T,R,O,L,_,D=this;return(0,i.YH)(this,function(H){switch(H.label){case 0:return v=this.config,h=this.getShouldRecord(),g=null===(t=this.identifiers)||void 0===t?void 0:t.sessionId,h&&g&&v?(this.stopRecordingEvents(),[4,this.getRecordFunction()]):[2];case 1:return(f=H.sent())?[4,this.initializeNetworkObservers()]:[2];case 2:H.sent(),p=null===(n=v.loggingConfig)||void 0===n?void 0:n.network,m=ve(v.serverZone,v.trackServerUrl),y=[w,E,P,m],null===(s=this.networkObservers)||void 0===s||s.start(function(e){y.some(function(t){return e.url.
1startsWith(t)})||D.addCustomRRWebEvent(r.FETCH_REQUEST,e)},p),S=v.interactionConfig,b=v.loggingConfig,I=(null==S?void 0:S.enabled)?{mouseInteraction:this.eventsManager&&(null===(a=this.clickHandler)||void 0===a?void 0:a.createHook({eventsManager:this.eventsManager,sessionId:g,deviceIdFn:this.getDeviceId.bind(this),mirror:f.mirror,ugcFilterRules:null!==(l=S.ugcFilterRules)&&void 0!==l?l:[],performanceOptions:null===(c=v.performanceConfig)||void 0===c?void 0:c.interaction})),scroll:this.scrollHook}:{},C=(null==S?void 0:S.enabled)&&S.ugcFilterRules?S.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(g,".")),H.label=3;case 3:return H.trys.push([3,5,,6]),k=!!(null===(u=v.crossOriginIframes)||void 0===u?void 0:u.enabled),x=!1!==(null===(d=v.crossOriginIframes)||void 0===d?void 0:d.coordinateChildren),(M=k&&function(){try{var e=(0,o.m)();return!!e&&e.parent!==e}catch(t){return!0}}())&&x?(this.crossOriginParentSignalCleanup=function(e){var t=(0,o.m)();if(!t)return function(){};var n=t.parent;function r(t){if(t.source===n){var r=t.data;(null==r?void 0:r.type)===F&&("start"===r.action?e.onStart():"stop"===r.action&&e.onStop())}}return t.addEventListener("message",r),function(){return t.removeEventListener("message",r)}}({onStart:function(){return D._recordEventsInChildMode(f,g,v,I)},onStop:function(){try{D.recordCancelCallback&&D.recordCancelCallback(),D.recordCancelCallback=null}catch(t){var e=t;D.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(e.toString()))}}}),[2]):(T=this,R=f,O=[(0,i.Cl)({},this.buildRRWebRecordOptions(v,I,function(e){if(D.shouldOptOut())return D.loggerProvider.log("Opting session ".concat(g," out of recording due to optOut config.")),D.stopRecordingEvents(),void D.sendEvents();e.type===se.Meta&&(e.data.href=W(e.data.href,C)),D.eventCompressor?D.eventCompressor.enqueueEvent(e,g):D.pendingEmitEvents.push({event:e,sessionId:g})},"Error while capturing replay: "))],_={},[4,this.getRecordingPlugins(b)]);case 4:return T.recordCancelCallback=R.apply(void 0,[i.Cl.apply(void 0,O.concat([(_.plugins=H.sent(),_.recordCrossOriginIframes=k,_)]))]),k&&!M&&x&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new kt),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(r.DEBUG_INFO),e&&this.addCustomRRWebEvent(r.METADATA,this.metadata),[3,6];case 5:return L=H.sent(),this.loggerProvider.warn("Failed to initialize session replay:",L),[3,6];case 6:return[2]}})})},e.prototype.buildRRWebRecordOptions=function(e,t,n,r){var s=this,o=e.privacyConfig;return(0,i.Cl)((0,i.Cl)({emit:n,inlineStylesheet:e.shouldInlineStylesheet,hooks:t,maskAllInputs:!0,maskTextClass:I,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroundColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:N("input",o,function(){return s.currentPageUrl}),maskTextFn:N("text",o,function(){return s.currentPageUrl}),maskAttributeFn:A(o,function(){return s.currentPageUrl}),maskTextSelector:this.getMaskTextSelectors()},void 0!==e.fullSnapshotIntervalMs&&{checkoutEveryNms:e.fullSnapshotIntervalMs}),{recordCanvas:!1,captureAdoptedStyleSheets:e.captureAdoptedStyleSheets,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},errorHandler:function(e){var t=e;if(t.message.includes("insertRule")&&t.message.includes("CSSStyleSheet"))throw t;if(t._external_)throw t;return s.loggerProvider.warn(r,t.toString()),!0}})},e.prototype._recordEventsInChildMode=function(e,t,n,r){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e((0,i.Cl)((0,i.Cl)({},this.buildRRWebRecordOptions(n,r,function(){},"Error while capturing replay (child iframe): ")),{recordCrossOriginIframes:!0})),this.loggerProvider.log("Session Replay child iframe capture beginning for session ".concat(t,"."))}catch(s){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",s)}},e.prototype.getDeviceId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.deviceId},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]})})},e.prototype.shutdown=function(){var e,t;null===(e=this.urlChangeCleanup)||void 0===e||e.call(this),null===(t=this.crossOriginParentSignalCleanup)||void 0===t||t.call(this),this.crossOriginParentSignalCleanup=null,this.teardownEventListeners(!0),this.stopRecordingEvents(),this.sendEvents()},e.prototype.mapSDKType=function(e){return"plugin"===e?"@amplitude/plugin-session-replay-browser":"segment"===e?"@amplitude/segment-session-replay-plugin":null},e.prototype.setMetadata=function(e,t,n,r,i,s,o){var a=(null==e?void 0:e.toString())?(0,re.fI)(e.toString()):void 0;this.metadata={joinedConfig:t,localConfig:n,remoteConfig:r,sessionId:e,hashValue:a,sampleRate:t.sampleRate,replaySDKType:this.mapSDKType(o),replaySDKVersion:i,standaloneSDKType:"@amplitude/session-replay-browser",standaloneSDKVersion:s}},e.prototype.initializeNetworkObservers=function(){var e,t,r;return(0,i.sH)(this,void 0,void 0,function(){var s,o;return(0,i.YH)(this,function(i){switch(i.label){case 0:if(!(null===(r=null===(t=null===(e=this.config)||void 0===e?void 0:e.loggingConfig)||void 0===t?void 0:t.network)||void 0===r?void 0:r.enabled)||this.networkObservers)return[3,4];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,Promise.all([n.e(906),n.e(2774)]).then(n.bind(n,62774))];case 2:return s=i.sent().NetworkObservers,this.networkObservers=new s,[3,4];case 3:return o=i.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",o),[3,4];case 4:return[2]}})})},e}(),Ft=function(e){return function(){var t=e.config||J();return{logger:t.loggerProvider,logLevel:t.logLevel}}}
1,Lt=(xt=new Ot,{init:(0,a.nA)(xt.init.bind(xt),"init",Ft(xt)),evaluateTargetingAndCapture:(0,a.nA)(xt.evaluateTargetingAndCapture.bind(xt),"evaluateTargetingAndRecord",Ft(xt)),setSessionId:(0,a.nA)(xt.setSessionId.bind(xt),"setSessionId",Ft(xt)),getSessionId:(0,a.nA)(xt.getSessionId.bind(xt),"getSessionId",Ft(xt)),getSessionReplayProperties:(0,a.nA)(xt.getSessionReplayProperties.bind(xt),"getSessionReplayProperties",Ft(xt)),flush:(0,a.nA)(xt.flush.bind(xt),"flush",Ft(xt)),shutdown:(0,a.nA)(xt.shutdown.bind(xt),"shutdown",Ft(xt))}),_t=Lt.init,Dt=Lt.setSessionId,Ht=Lt.getSessionId,qt=Lt.getSessionReplayProperties,Nt=Lt.flush,At=Lt.shutdown,Bt=Lt.evaluateTargetingAndCapture,zt=n(68697),Ut=function(e){return void 0===e&&(e="$default_instance"),zt.i.getInstance(e)};!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(Mt||(Mt={})),function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue"}(Tt||(Tt={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(Rt||(Rt={}));var Wt=[Mt.SET,Mt.SET_ONCE,Mt.ADD,Mt.APPEND,Mt.PREPEND,Mt.POSTINSERT],jt="1.33.7",Yt="".concat("[Amplitude]"," Session Replay ID"),Jt=function(){function e(t){this.name=e.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:Nt,getSessionId:Ht,getSessionReplayProperties:qt,init:_t,setSessionId:Dt,shutdown:At,evaluateTargetingAndCapture:Bt},this.options=(0,i.Cl)({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){var n,r,s,o,a,l,c,u;return(0,i.sH)(this,void 0,void 0,function(){var t,d,v;return(0,i.YH)(this,function(h){switch(h.label){case 0:return h.trys.push([0,2,,3]),null==e||e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(jt,".")),this.config=e,this.options.forceSessionTracking&&("boolean"==typeof e.defaultTracking?!1===e.defaultTracking&&(e.defaultTracking={pageViews:!1,formInteractions:!1,fileDownloads:!1,sessions:!0}):e.defaultTracking=(0,i.Cl)((0,i.Cl)({},e.defaultTracking),{sessions:!0})),t=Ut(this.config.instanceName).identityStore,d=t.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!==(n=this.options.deviceId)&&void 0!==n?n:this.config.deviceId,optOut:this.config.optOut,sessionId:this.options.customSessionId?void 0:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,configServerUrl:this.options.configServerUrl||(null===(r=this.config.remoteConfig)||void 0===r?void 0:r.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(s=this.options.privacyConfig)||void 0===s?void 0:s.blockSelector,maskSelector:null===(o=this.options.privacyConfig)||void 0===o?void 0:o.maskSelector,unmaskSelector:null===(a=this.options.privacyConfig)||void 0===a?void 0:a.unmaskSelector,defaultMaskLevel:null===(l=this.options.privacyConfig)||void 0===l?void 0:l.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:jt},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:null!==(c=this.options.useWebWorker)&&void 0!==c?c:null===(u=this.options.experimental)||void 0===u?void 0:u.useWebWorker,userProperties:d,applyBackgroundColorToBlockedElements:this.options.applyBackgroundColorToBlockedElements,interactionConfig:this.options.interactionConfig,captureDocumentTitle:this.options.captureDocumentTitle,enableUrlChangePolling:this.options.enableUrlChangePolling,urlChangePollingInterval:this.options.urlChangePollingInterval,captureAdoptedStyleSheets:this.options.captureAdoptedStyleSheets,crossOriginIframes:this.options.crossOriginIframes,flushIntervalConfig:this.options.flushIntervalConfig,eagerFullSnapshotSend:this.options.eagerFullSnapshotSend,captureFullSnapshotOnFocus:this.options.captureFullSnapshotOnFocus,maxPersistedEventsSizeBytes:this.options.maxPer
1sistedEventsSizeBytes,maxSingleEventSizeBytes:this.options.maxSingleEventSizeBytes,sendTimeoutMs:this.options.sendTimeoutMs,handleSendEvents:this.options.handleSendEvents,handleFetchConfig:this.options.handleFetchConfig},[4,this.sessionReplay.init(e.apiKey,this.srInitOptions).promise];case 1:return h.sent(),[3,3];case 2:return v=h.sent(),null==e||e.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(v.message)),[3,3];case 3:return[2]}})})},e.prototype.onSessionIdChanged=function(e){var t;return(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(n){switch(n.label){case 0:return null===(t=this.config)||void 0===t||t.loggerProvider.debug("Analytics session id is changed to ".concat(e,", SR session id is ").concat(String(this.sessionReplay.getSessionId()),".")),[4,this.sessionReplay.setSessionId(e).promise];case 1:return n.sent(),[2]}})})},e.prototype.onOptOutChanged=function(e){var t;return(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(n){switch(n.label){case 0:return null===(t=this.config)||void 0===t||t.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),e?(this.sessionReplay.shutdown(),[3,4]):[3,1];case 1:return null!=this.config?[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise]:[3,3];case 2:n.sent(),n.label=3;case 3:n.label=4;case 4:return[2]}})})},e.prototype.execute=function(e){var t,n,r;return(0,i.sH)(this,void 0,void 0,function(){var a,l,c,u,d;return(0,i.YH)(this,function(v){switch(v.label){case 0:return v.trys.push([0,9,,10]),this.options.customSessionId?(a=this.options.customSessionId(e))?a===this.sessionReplay.getSessionId()?[3,2]:[4,this.sessionReplay.setSessionId(a).promise]:[3,3]:[3,4];case 1:v.sent(),v.label=2;case 2:u=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,i.Cl)((0,i.Cl)({},e.event_properties),u),v.label=3;case 3:return[3,8];case 4:return(a=null===(t=this.config)||void 0===t?void 0:t.sessionId)&&a!==this.sessionReplay.getSessionId()?[4,this.sessionReplay.setSessionId(a).promise]:[3,6];case 5:v.sent(),v.label=6;case 6:return a&&a===e.session_id?(l=void 0,e.event_type===s.S.IDENTIFY&&(l=function(e){if(e.user_properties){var t={};return Object.keys(e.user_properties).forEach(function(n){if(Wt.includes(n)){var r=e.user_properties&&e.user_properties[n];t=(0,i.Cl)((0,i.Cl)({},t),r)}}),t}}(e)),c=(0,o.m)(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:l,page:null!=(null===(n=null==c?void 0:c.location)||void 0===n?void 0:n.href)?{url:c.location.href}:void 0})]):[3,8];case 7:v.sent(),u=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,i.Cl)((0,i.Cl)({},e.event_properties),u),v.label=8;case 8:return e.event_type===s.S.IDENTIFY&&e.event_properties&&delete e.event_properties[Yt],[2,Promise.resolve(e)];case 9:return d=v.sent(),null===(r=this.config)||void 0===r||r.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(d.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return(0,i.sH)(this,void 0,void 0,function(){return(0,i.YH)(this,function(t){try{this.sessionReplay.shutdown(),this.config=null}catch(n){null===(e=this.config)||void 0===e||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(n.message))}return[2]})})},e.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},e.pluginName="@amplitude/plugin-session-replay-browser",e}(),Kt=function(e){return new Jt(e)}},60602:function(e,t,n){n.d(t,{P2:function(){return f}});const r=(e,t)=>t.some(t=>e instanceof t);let i,s;const o=new WeakMap,a=new WeakMap,l=new WeakMap;let c={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return o.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return h(e[t])},set(e,t,n){return e[t]=n,!0},has(e,t){return e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e}};function u(e){c=e(c)}function d(e){return(s||(s=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(g(this),t),h(this.request)}:function(...t){return h(e.apply(g(this),t))}}function v(e){return"function"==typeof e?d(e):(e instanceof IDBTransaction&&function(e){if(o.has(e))return;const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",s),e.removeEventListener("abort",s)},i=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",i),e.addEventListener("error",s),e.addEventListener("abort",s)});o.set(e,t)}(e),r(e,i||(i=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,c):e)}function h(e){if(e instanceof IDBRequest)return function(e){const t=new Promise((t,n)=>{const r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(h(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)});return l.set(t,e),t}(e);if(a.has(e))return a.get(e);const t=v(e);return t!==e&&(a.set(e,t),l.set(t,e)),t}const g=e=>l.get(e);function f(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){const o=indexedDB.open(e,t),a=h(o);return r&&o.addEventListener("upgradeneeded",e=>{r(h(o.result),e.oldVersion,e.newVersion,h(o.transaction),e)}),n&&o.addEventListener("blocked",e=>n(e.oldVersion,e.newVersion,e)),a.then(e=>{s&&e.addEventListener("close",()=>s()),i&&e.addEventListener("versionchange",e=>i(e.oldVersion,e.newVersion,e))}).catch(()=>{}),a}const p=["get","getKey","getAll","getAllKeys","count"],m=["put","add","delete","clear"],y=new Map;function S(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(y.get(t))return y.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,i=m.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!i&&!p.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,i?"readwrite":"readonly");let o=s.store;
vendor: 886 bytes, lines 1-2
1return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&s.done]))[0]};return y.set(t,s),s}u(e=>({...e,get:(t,n,r)=>S(t,n)||e.get(t,n,r),has:(t,n)=>!!S(t,n)||e.has(t,n)}));const b=["continue","continuePrimaryKey","advance"],I={},C=new WeakMap,w=new WeakMap,E={get(e,t){if(!b.includes(t))return e[t];let n=I[t];return n||(n=I[t]=function(...e){C.set(this,w.get(this)[t](...e))}),n}};async function*P(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,E);for(w.set(n,t),l.set(n,g(t));t;)yield n,t=await(C.get(n)||t.continue()),C.delete(n)}function k(e,t){return t===Symbol.asyncIterator&&r(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&r(e,[IDBIndex,IDBObjectStore])}u(e=>({...e,get(t,n,r){return k(t,n)?P:e.get(t,n,r)},has(t,n){return k(t,n)||e.has(t,n)}}))}}]);
2//# sourceMappingURL=4011-115fdaa0caadeca27d87.js.map

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.