PageSourceSearch

https://www.veed.io/marketing-pages-ap/_next/static/chunks/5302.620aa6c334395f39.js

js veed.io collected 2026-09-24 08:26:41 UTC 120,078 bytes, 1 lines download raw bytes

1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f9a0b9ef-ccf4-4cb9-9074-32606c04cc1d",e._sentryDebugIdIdentifier="sentry-dbid-f9a0b9ef-ccf4-4cb9-9074-32606c04cc1d")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5302],{15302:(e,t,n)=>{n.d(t,{sessionReplayPlugin:()=>tk});var r,i,s,o,a,l,c,u,d,h,g,f,v,p=n(80594);!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"}(r||(r={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(i||(i={}));var m=n(92509);!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(s||(s={}));var y=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var l=n(),c=l.logger,u=l.logLevel;if(u&&u<s.Debug||!u||!c)return e.apply(i,o);var d={type:"invoke public method",name:t,args:o,stacktrace:(Error().stack||"").split("\n").slice(3).map(function(e){return e.trim()}),time:{start:new Date().toISOString()},states:{}};r&&d.states&&(d.states.before=r());var h=e.apply(i,o);return h&&h.promise?h.promise.then(function(){r&&d.states&&(d.states.after=r()),d.time&&(d.time.end=new Date().toISOString()),c.debug(JSON.stringify(d,null,2))}):(r&&d.states&&(d.states.after=r()),d.time&&(d.time.end=new Date().toISOString()),c.debug(JSON.stringify(d,null,2))),h}},b="Amplitude Logger ",S=function(){function e(){this.logLevel=s.None}return e.prototype.disable=function(){this.logLevel=s.None},e.prototype.enable=function(e){void 0===e&&(e=s.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<s.Verbose||console.log("".concat(b,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<s.Warn||console.warn("".concat(b,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<s.Error||console.error("".concat(b,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<s.Debug||console.log("".concat(b,"[Debug]: ").concat(e.join(" ")))},e}();!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(o||(o={}));var I=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){if("object"!=typeof e)return null;var t,n,r,i,s,a,l,c,u,d,h,g,f,v,p,m,y,b,S,I,C,w,k=e.code||0,E=this.buildStatus(k);switch(E){case o.Success:return{status:E,statusCode:k,body:{eventsIngested:null!=(t=e.events_ingested)?t:0,payloadSizeBytes:null!=(n=e.payload_size_bytes)?n:0,serverUploadTime:null!=(r=e.server_upload_time)?r:0}};case o.Invalid:return{status:E,statusCode:k,body:{error:null!=(i=e.error)?i:"",missingField:null!=(s=e.missing_field)?s:"",eventsWithInvalidFields:null!=(a=e.events_with_invalid_fields)?a:{},eventsWithMissingFields:null!=(l=e.events_with_missing_fields)?l:{},eventsWithInvalidIdLengths:null!=(c=e.events_with_invalid_id_lengths)?c:{},epsThreshold:null!=(u=e.eps_threshold)?u:0,exceededDailyQuotaDevices:null!=(d=e.exceeded_daily_quota_devices)?d:{},silencedDevices:null!=(h=e.silenced_devices)?h:[],silencedEvents:null!=(g=e.silenced_events)?g:[],throttledDevices:null!=(f=e.throttled_devices)?f:{},throttledEvents:null!=(v=e.throttled_events)?v:[]}};case o.PayloadTooLarge:return{status:E,statusCode:k,body:{error:null!=(p=e.error)?p:""}};case o.RateLimit:return{status:E,statusCode:k,body:{error:null!=(m=e.error)?m:"",epsThreshold:null!=(y=e.eps_threshold)?y:0,throttledDevices:null!=(b=e.throttled_devices)?b:{},throttledUsers:null!=(S=e.throttled_users)?S:{},exceededDailyQuotaDevices:null!=(I=e.exceeded_daily_quota_devices)?I:{},exceededDailyQuotaUsers:null!=(C=e.exceeded_daily_quota_users)?C:{},throttledEvents:null!=(w=e.throttled_events)?w:[]}};case o.Timeout:default:return{status:E,statusCode:k}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?o.Success:429===e?o.RateLimit:413===e?o.PayloadTooLarge:408===e?o.Timeout:e>
1=400&&e<500?o.Invalid:e>=500?o.Failed:o.Unknown},e}(),C=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return(0,p.C6)(t,e),t.prototype.send=function(e,t){return(0,p.sH)(this,void 0,void 0,function(){var n,r;return(0,p.YH)(this,function(i){switch(i.label){case 0:if("undefined"==typeof fetch)throw Error("FetchTransport is not supported");return[4,fetch(e,{headers:(0,p.Cl)({"Content-Type":"application/json",Accept:"*/*"},this.customHeaders),body:JSON.stringify(t),method:"POST"})];case 1:return[4,(n=i.sent()).text()];case 2:r=i.sent();try{return[2,this.buildResponse(JSON.parse(r))]}catch(e){return[2,this.buildResponse({code:n.status})]}}})})},t}(I),w="$default_instance",k="https://api2.amplitude.com/2/httpapi",E=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:w,logLevel:s.Warn,loggerProvider:new S,offline:!1,optOut:!1,serverUrl:k,serverZone:"US",useBatch:!1}},P=function(){function e(e){this._optOut=!1;var t,n,r,i,s=E();this.apiKey=e.apiKey,this.flushIntervalMillis=null!=(t=e.flushIntervalMillis)?t:s.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||s.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||s.flushQueueSize,this.instanceName=e.instanceName||s.instanceName,this.loggerProvider=e.loggerProvider||s.loggerProvider,this.logLevel=null!=(n=e.logLevel)?n:s.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:s.offline,this.optOut=null!=(r=e.optOut)?r:s.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||s.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!=(i=e.useBatch)?i:s.useBatch,this.loggerProvider.enable(this.logLevel);var o=R(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=o.serverZone,this.serverUrl=o.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),R=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=E().serverZone),void 0===n&&(n=E().useBatch),e)return{serverUrl:e,serverZone:void 0};var r,i=["US","EU"].includes(t)?t:E().serverZone;return{serverZone:i,serverUrl:(r=n,"EU"===i?r?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":r?"https://api2.amplitude.com/batch":k)}};(function(){this.sdk={metrics:{histogram:{}}}}).prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(a||(a={}));var _="[Amplitude]",T="".concat(_," Session Replay ID"),x=a.US,M={enabled:!0},L="".concat(_," Session Replay Debug"),O="amp-mask",D="amp-unmask",H="https://api-sr.amplitude.com/sessions/v2/track",F="https://api-sr.eu.amplitude.com/sessions/v2/track",N="https://api-sr.stag2.amplitude.com/sessions/v2/track",A=/payload.*exceed/i,U="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"}(l||(l={}));var q=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){if(!this.logger)return function(){};var t,n=this.logger[e];return"function"==typeof n?(null!=(t=n.__rrweb_original__)?t:n).bind(this.logger):function(){}},e.prototype.enable=function(e){this.logger.enable(e)},e.prototype.disable=function(){this.logger.disable()},e}(),B="medium",W=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r,i,s=n?(i=(r=n).type,r.hasAttribute("data-rr-is-password")?"password":i?i.toLowerCase():null):"";if(!s)return!1;if(["password","hidden","email","tel"].includes(s)||n.autocomplete.startsWith("cc-"))return!0;return!1;case"medium":case"conservative":return!0;default:return W(e,B,n)}},z=function(e,t){if(e&&t.urlMaskLevels)try{for(var n,r,i,s=(0,p.Ju)(t.urlMaskLevels),o=s.next();!o.done;o=s.next()){var a=o.value;if(X(a.match).test(e))return a.maskLevel}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return null!=(i=t.defaultMaskLevel)?i:B},j=function(e,t,n,r){var i,s;if(void 0===t&&(t={defaultMaskLevel:B}),n){if(n.closest("."+O)||(null!=(i=t.maskSelector)?i:[]).some(function(e){return n.closest(e)}))return!0;
1if(n.closest("."+D)||(null!=(s=t.unmaskSelector)?s:[]).some(function(e){return n.closest(e)}))return!1}return W(e,z(r,t),n)},Y=function(e,t,n){return function(r,i){return j(e,t,i,null==n?void 0:n())?r.replace(/[^\s]/g,"*"):r}},J=function(){var e=(0,m.m)();return(null==e?void 0:e.location)?e.location.href:""},K=new Map,X=function(e){var t=K.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 K.set(e,l),l},Q=function(e){if(!e.every(function(e){return"string"==typeof e.selector&&"string"==typeof e.replacement}))throw Error("ugcFilterRules must be an array of objects with selector and replacement properties");if(!e.every(function(e){var t;return"string"==typeof(t=e.selector)&&""!==t.trim()&&!!/^\/|^https?:\/\/[^\s]+$/.test(t)}))throw Error("ugcFilterRules must be an array of objects with valid globs")},$=function(e,t){var n,r;try{for(var i=(0,p.Ju)(t),s=i.next();!s.done;s=i.next()){var o=s.value,a=X(o.selector);if(a.test(e))return e.replace(a,o.replacement)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},G=function(){return(0,p.sH)(void 0,void 0,void 0,function(){var e,t,n,r;return(0,p.YH)(this,function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(e=(0,m.m)()))return[3,2];return[4,e.navigator.storage.estimate()];case 1:return n=(t=i.sent()).usage,r=t.quota,[2,{totalStorageSize:n?Math.round(n/1024):0,percentOfQuota:n&&r?Math.round((n/r+Number.EPSILON)*1e3)/1e3:0,usageDetails:JSON.stringify(t.usageDetails)}];case 2:return[3,4];case 3:return i.sent(),[3,4];case 4:return[2,{totalStorageSize:0,percentOfQuota:0,usageDetails:""}]}})})},V=function(e){var t=(0,p.Cl)({},e),n=t.apiKey;return t.apiKey="****".concat(n.substring(n.length-4)),t},Z=function(){return{flushMaxRetries:2,logLevel:s.Warn,loggerProvider:new S,transportProvider:new C}},ee=function(e){function t(t,n){var r,i,s,o,a,l,c,u,d,h,g=this,f=Z();return(g=e.call(this,(0,p.Cl)((0,p.Cl)({transportProvider:f.transportProvider,loggerProvider:new q(n.loggerProvider||f.loggerProvider)},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=f.flushMaxRetries?n.flushMaxRetries:f.flushMaxRetries,g.apiKey=t,g.sampleRate=n.sampleRate||0,g.serverZone=n.serverZone||x,g.configServerUrl=n.configServerUrl,g.trackServerUrl=n.trackServerUrl,g.shouldInlineStylesheet=n.shouldInlineStylesheet,g.version=n.version,g.performanceConfig=n.performanceConfig||M,g.storeType=null!=(r=n.storeType)?r:"memory",g.applyBackgroundColorToBlockedElements=null!=(i=n.applyBackgroundColorToBlockedElements)&&i,g.enableUrlChangePolling=null!=(s=n.enableUrlChangePolling)&&s,g.urlChangePollingInterval=null!=(o=n.urlChangePollingInterval)?o:1e3,g.captureDocumentTitle=null!=(a=n.captureDocumentTitle)&&a,void 0!==n.fullSnapshotIntervalMs&&(g.fullSnapshotIntervalMs=n.fullSnapshotIntervalMs),g.privacyConfig=(0,p.Cl)((0,p.Cl)({},null!=(l=n.privacyConfig)?l:{}),{unmaskSelector:Array.from(new Set((0,p.fX)([".".concat(D)],(0,p.zs)(null!=(u=null==(c=n.privacyConfig)?void 0:c.unmaskSelector)?u:[]),!1)))}),n.interactionConfig&&(g.interactionConfig=n.interactionConfig,g.interactionConfig.ugcFilterRules&&Q(g.interactionConfig.ugcFilterRules)),n.debugMode&&(g.debugMode=n.debugMode),void 0!==n.useWebWorker?g.useWebWorker=n.useWebWorker:(null==(d=n.experimental)?void 0:d.useWebWorker)!==void 0&&(g.useWebWorker=n.experimental.useWebWorker),g.captureAdoptedStyleSheets=null==(h=n.captureAdoptedStyleSheets)||h,n.crossOriginIframes&&(g.crossOriginIframes=n.crossOriginIframes),g}return(0,p.C6)(t,e),t}(P),et=function(e){return{promise:e||Promise.resolve()}},en="https://app.amplitude.com",er={US:en,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"},ei="__AMPLITUDE_MESSENGER_INSTANCE__",es="__AMPLITUDE_MESSENGER__",eo=function(){function e(e){var t=(void 0===e?{}:e).origin;this[c]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=void 0===t?en:t}return e.prototype.notify=function(e){var t,n,r,i;null==(n=null==(t=this.logger)?void 0:t.debug)||n.call(t,"Message sent: ",JSON.stringify(e)),null==(i=null==(r=window.opener)?void 0:r.postMessage)||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),s={id:i,action:e,args:t};return new Promise(function(t,o){r.requestCallbacks[i]={resolve:t,reject:o},r.notify(s),n.timeout>0&&setTimeout(function(){o(Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]},n.timeout)})},e.prototype.handleResponse=function(e){var t;if(!this.requestCallbacks[e.id]){null==(t=this.logger)||t.warn("No callback found for request id: ".concat(e.id));return}this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]},e.prototype.registerActionHandler=function(e,t){this.actionHandlers.has(e)&&(null==(s=null==(i=this.logger)?void 0:i.warn)||s.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var n,r,i,s,o=this.pendingMessages.get(e);if(o){this.pendingMessages.delete(e);try{for(var a=(0,p.Ju)(o),l=a.next();!l.done;l=a.next()){var c=l.value;t(c)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return(0,p.sH)(this,void 0,void 0,function(){var t,n,r;return(0,p.YH)(this,function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=(document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise(function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",function(){t({status:!0})},{once:!0}),i.addEventListener("error",function(){n({status:!1,message:"Failed to load the script ".concat(e)})}),null==(r=document.head)||r.appendChild(i)}catch(e){n(e)}})).then(function(){}),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}})})},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,s=i.logger,o=i.endpoint;
1s&&(this.logger=s),o&&this.endpoint===en&&(this.endpoint=o),this.isSetup||(this.isSetup=!0,null==(n=null==(t=this.logger)?void 0:t.debug)||n.call(t,"Setting up messenger"),this.messageHandler=function(e){if(null==(n=null==(t=r.logger)?void 0:t.debug)||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var t,n,i,s,o,a=e.data,l=null==a?void 0:a.action;if(l)if("id"in a&&a.id)null==(s=null==(i=r.logger)?void 0:i.debug)||s.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(a);else{if("ping"===l)return void r.notify({action:"pong"});var c=r.actionHandlers.get(l);if(c)c(a.data);else{var u=null!=(o=r.pendingMessages.get(l))?o:[];u.push(a.data),r.pendingMessages.set(l,u)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=(0,m.m)();(null==e?void 0:e[es])===this&&delete e[es]},e}();c=ei;var ea="__AMPLITUDE_BACKGROUND_CAPTURE__",el=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t},ec=n(15847),eu=(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))(eu||{}),ed=(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))(ed||{}),eh=(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))(eh||{}),eg=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(eg||{}),ef=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ef||{}),ev=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(ev||{}),ep=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e.SeekStart="seek-start",e.SeekEnd="seek-end",e))(ep||{}),em=(e=>(e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment",e))(em||{}),ey=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),eb=(0,p.fX)([],(0,p.zs)(Array(256).keys()),!1).map(function(e){return e.toString(16).padStart(2,"0")}),eS=function(e){var t,n=(0,m.m)();if(!(null==(t=null==n?void 0:n.crypto)?void 0:t.getRandomValues))return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,eS);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(0,p.fX)([],(0,p.zs)(r.entries()),!1).map(function(e){var t=(0,p.zs)(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(eb[r]):eb[r]}).join("")}
1,eI={INVALID_API_KEY:401,FORBIDDEN:403,RATE_LIMIT:429},eC=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new ey(e,t)}return e.prototype.subscribe=function(e,t,n){var r=eS(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex(function(t){return t.id===e});return -1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return(0,p.sH)(this,void 0,void 0,function(){var e,t=this;return(0,p.YH)(this,function(n){switch(n.label){case 0:if(this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5)return this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2];return[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach(function(n){t.sendCallback(n,e,"remote")}),[2]}})})},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise||(this.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally(function(){e.fetchPromise=null})):this.fetchPromise=this.fetch().then(function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t}).finally(function(){e.fetchPromise=null})),this.fetchPromise},e.prototype.subscribeAll=function(e){return(0,p.sH)(this,void 0,void 0,function(){var t,n,r,i=this;return(0,p.YH)(this,function(s){switch(s.label){case 0:return t=this.getOrCreateFetchPromise().then(function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)}),n=this.storage.fetchConfig().then(function(e){return e}),[4,Promise.race([t,n])];case 1:return void 0!==(r=s.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending c
1allback because cache is empty (first time user).")),[4,t];case 2:return s.sent(),[2]}})})},e.prototype.subscribeWaitForRemote=function(e,t){return(0,p.sH)(this,void 0,void 0,function(){var n,r;return(0,p.YH)(this,function(i){switch(i.label){case 0:n=new Promise(function(e,n){setTimeout(function(){n("Timeout exceeded")},t)}),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}})})},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce(function(e,t){return null===e?e:t in e?e[t]:null},t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),(0,p.sH)(this,void 0,void 0,function(){var n,r,i,s,o,a,l=this;return(0,p.YH)(this,function(c){switch(c.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,o,a,c,u,d;return(0,p.YH)(this,function(h){switch(h.label){case 0:i=!0,o=new AbortController,a=setTimeout(function(){return o.abort()},t),h.label=1;case 1:return h.trys.push([1,7,8,9]),[4,fetch(s.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:o.signal})];case 2:if((c=h.sent()).ok)return[3,4];return[4,c.text()];case 3:return u=h.sent(),s.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(c.status,": ").concat(u)),c.status===eI.INVALID_API_KEY||c.status===eI.FORBIDDEN?(s.logger.error("Remote config client fetch failed with ".concat(c.status,". Invalid API key; future fetches will be skipped.")),s.isLastFetchInvalidApiKey=!0,i=!1):c.status>=400&&c.status<500&&c.status!==eI.RATE_LIMIT&&(i=!1),[3,6];case 4:return[4,c.json()];case 5:return[2,{value:{remoteConfig:h.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=h.sent())instanceof Error&&"AbortError"===d.name?s.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):s.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(a),[7];case 9:if(!i)return[2,"break"];if(!(r<e-1))return[3,11];return[4,new Promise(function(e){return setTimeout(e,l.getJitterDelay(n))})];case 10:h.sent(),h.label=11;case 11:return[2]}})},s=this,o=0,c.label=1;case 1:if(!(o<e))return[3,4];return[5,i(o)];case 2:if("object"==typeof(a=c.sent()))return[2,a.value];if("break"===a)return[3,4];c.label=3;case 3:return o++,[3,1];case 4:return[2,r]}})})},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),ew=function(e,t){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),0!==(e=e.filter(function(e){try{n.querySelector(e)}catch(n){return t.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})).length)return e};return e.blockSelector=r(e.blockSelector),e.maskSelector=r(e.maskSelector),e.unmaskSelector=r(e.unmaskSelector),e},ek=function(){function e(e,t){this.localConfig=t,this.remoteConfigClient=e}return e.prototype.generateJoinedConfig=function(){var e,t,n,r,i,s,o;return(0,p.sH)(this,void 0,void 0,function(){var a,l,c,u,d,h,g,f,v,m,y,b,S,I,C,w,k,E=this;return(0,p.YH)(this,function(P){switch(P.label){case 0:(a=(0,p.Cl)({},this.localConfig)).optOut=this.localConfig.optOut,a.captureEnabled=!0,P.label=1;case 1:return P.trys.push([1,3,,4]),[4,new Promise(function(e,t){E.remoteConfigClient.subscribe("configs.sessionReplay",{timeout:1500},function(n,r){if(E.localConfig.loggerProvider.debug("Session Replay remote configuration received from ".concat(r,":"),JSON.stringify(n,null,2)),!n)return void t(Error("No remote config received"));var i,s=n.sr_sampling_config,o=n.sr_privacy_config,c=n.sr_targeting_config,u=null==(i=a.interactionConfig)?void 0:i.ugcFilterRules;a.interactionConfig=n.sr_interaction_config,a.interactionConfig&&u&&(
1a.interactionConfig.ugcFilterRules=u),a.loggingConfig=n.sr_logging_config,(s||o||c)&&(l={},s&&(l.sr_sampling_config=s),o&&(l.sr_privacy_config=o),c&&(l.sr_targeting_config=c)),e()})})];case 2:return P.sent(),[3,4];case 3:return c=P.sent(),this.localConfig.loggerProvider.error("Failed to generate joined config: ",c),a.captureEnabled=!1,[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:void 0}];case 4:if(!l)return[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:l}];if(u=l.sr_sampling_config,d=l.sr_privacy_config,h=l.sr_targeting_config,u&&Object.keys(u).length>0?(Object.prototype.hasOwnProperty.call(u,"capture_enabled")?a.captureEnabled=u.capture_enabled:a.captureEnabled=!1,Object.prototype.hasOwnProperty.call(u,"sample_rate")&&(a.sampleRate=u.sample_rate)):(a.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),d){g=null!=(e=a.privacyConfig)?e:{},f={defaultMaskLevel:null!=(n=null!=(t=d.defaultMaskLevel)?t:g.defaultMaskLevel)?n:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[],maskAttributes:(0,p.fX)([],(0,p.zs)(new Set((0,p.fX)((0,p.fX)([],(0,p.zs)(null!=(r=g.maskAttributes)?r:[]),!1),(0,p.zs)(null!=(i=d.maskAttributes)?i:[]),!1))),!1),urlMaskLevels:(0,p.fX)((0,p.fX)([],(0,p.zs)(null!=(s=d.urlMaskLevels)?s:[]),!1),(0,p.zs)(null!=(o=g.urlMaskLevels)?o:[]),!1)},v=function(e){var t,n,r,i,s,o,a,l,c,u={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var d=(0,p.Ju)(null!=(a=e.blockSelector)?a:[]),h=d.next();!h.done;h=d.next()){var g=h.value;u[g]="block"}}catch(e){t={error:e}}finally{try{h&&!h.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}try{for(var f=(0,p.Ju)(null!=(l=e.maskSelector)?l:[]),v=f.next();!v.done;v=f.next()){var g=v.value;u[g]="mask"}}catch(e){r={error:e}}finally{try{v&&!v.done&&(i=f.return)&&i.call(f)}finally{if(r)throw r.error}}try{for(var m=(0,p.Ju)(null!=(c=e.unmaskSelector)?c:[]),y=m.next();!y.done;y=m.next()){var g=y.value;u[g]="unmask"}}catch(e){s={error:e}}finally{try{y&&!y.done&&(o=m.return)&&o.call(m)}finally{if(s)throw s.error}}return u},m=(0,p.Cl)((0,p.Cl)({},v(g)),v(d));try{for(b=(y=(0,p.Ju)(Object.entries(m))).next();!b.done;b=y.next())I=(S=(0,p.zs)(b.value,2))[0],C=S[1],"mask"===C?f.maskSelector.push(I):"block"===C?f.blockSelector.push(I):"unmask"===C&&f.unmaskSelector.push(I)}catch(e){w={error:e}}finally{try{b&&!b.done&&(k=y.return)&&k.call(y)}finally{if(w)throw w.error}}a.privacyConfig=ew(f,this.localConfig.loggerProvider)}return h&&Object.keys(h).length>0&&(a.targetingConfig=h),this.localConfig.loggerProvider.debug(JSON.stringify({name:"session replay joined config",config:V(a)},null,2)),[2,{localConfig:this.localConfig,joinedConfig:a,remoteConfig:l}]}})})},e}();function eE(e,t){return t||("STAGING"===e?N:"EU"===e?F:H)}function eP(e){if(e.type!==eu.IncrementalSnapshot)return!1;var t=e.data;return t.source===ed.Mutation&&!t.isAttachIframe}var eR=function(){function e(e,t,n,r,i){var s,o=this;this.taskQueue=[],this.pendingQueue=[],this.isProcessing=!1,this.compressEvent=function(e){var t=e.type,n=e.timestamp,r=e.delay,i=e.data;return null!=r?JSON.stringify({type:t,timestamp:n,delay:r,data:i}):JSON.stringify({type:t,timestamp:n,data:i})},this.addCompressedEventToManager=function(e,t){var n=new Blob([e]).size;if(n>9e6)return void o.config.loggerProvider.warn("Session replay event dropped: serialized size ".concat(Math.round(n/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."));o.eventsManager&&o.deviceId&&o.eventsManager.addEvent({event:{type:"replay",data:e},sessionId:t,deviceId:o.deviceId})},this.addCompressedEvent=function(e,t){if(o.worker)try{o.worker.postMessage({event:e,sessionId:t})}catch(n){"DataCloneError"===n.name?o.worker.postMessage(JSON.stringify({event:e,sessionId:t})):o.config.loggerProvider.warn("Unexpected error while posting message to worker:",n)}else{var n=o.compressEvent(e);o.addCompressedEventToManager(n,t)}},this.flushQueue=function(){var e;
1for(o.pendingQueue.length>0&&(e=o.taskQueue).push.apply(e,(0,p.fX)([],(0,p.zs)(o.mergeMutationTasks(o.pendingQueue.splice(0))),!1));o.taskQueue.length>0;){var t=o.taskQueue.shift();if(t){var n=t.event,r=t.sessionId,i=o.compressEvent(n);o.addCompressedEventToManager(i,r)}}o.isProcessing=!1},this.terminate=function(){var e;null==(e=o.worker)||e.terminate()};var a=(0,m.m)();if(this.canUseIdleCallback=a&&"requestIdleCallback"in a,this.eventsManager=e,this.config=t,this.deviceId=n,this.timeout=(null==(s=t.performanceConfig)?void 0:s.timeout)||2e3,this.onFullSnapshotProcessed=i,r){t.loggerProvider.log("Enabling web worker for compression");try{var l=new Blob([r],{type:"application/javascript"}),c=URL.createObjectURL(l),u=new Worker(c);u.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,")")),u.terminate(),o.worker=void 0},u.onmessage=function(e){var t=e.data,n=t.compressedEvent,r=t.sessionId;o.addCompressedEventToManager(n,r)},this.worker=u}catch(e){t.loggerProvider.error("Failed to create worker, falling back to non-worker compression:",e)}}}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){if(e.type===eu.FullSnapshot){if(this.config.loggerProvider.debug("Processing full snapshot immediately."),this.taskQueue.length>0||this.pendingQueue.length>0){var n,r,i,s,o=(0,p.fX)((0,p.fX)([],(0,p.zs)(this.taskQueue.splice(0)),!1),(0,p.zs)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1);try{for(var a=(0,p.Ju)(o),l=a.next();!l.done;l=a.next()){var c=l.value,u=this.compressEvent(c.event);this.addCompressedEventToManager(u,c.sessionId)}}catch(e){n={error:e}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}this.isProcessing=!1}var d=this.compressEvent(e);this.addCompressedEventToManager(d,t),null==(i=this.onFullSnapshotProcessed)||i.call(this);return}this.canUseIdleCallback&&(null==(s=this.config.performanceConfig)?void 0:s.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,p.fX)([],(0,p.zs)(this.mergeMutationTasks(this.pendingQueue.splice(0))),!1));this.taskQueue.length>0&&(e.timeRemaining()>0||e.didTimeout);){var r=this.taskQueue.shift();if(r){var i=r.event,s=r.sessionId;this.addCompressedEvent(i,s)}}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){if(!(null==(r=this.config.performanceConfig)?void 0:r.mergeMutations)||e.length<=1)return e;for(var t,n,r,i=[],s=0;s<e.length;){for(var o=e[s].sessionId,a=s+1;a<e.length&&e[a].sessionId===o;)a++;var l=function(e){if(e.length<=1)return e;for(var t=[],n=0;n<e.length;){if(!eP(e[n])){t.push(e[n]),n++;continue}for(var r=n+1;r<e.length&&eP(e[r]);)r++;t.push(r>n+1?function(e){var t,n,r,i,s=e[0],o=new Map,a=new Map,l=new Map,c=new Map,u=new Map;e.forEach(function(e,t){var n,r,i,s,d=e.data;try{for(var h=(0,p.Ju)(d.adds),g=h.next();!g.done;g=h.next()){var f=g.value;o.has(f.node.id)||o.set(f.node.id,t),a.set(f.node.id,t),u.set(f.node.id,f.parentId)}}catch(e){n={error:e}}finally{try{g&&!g.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}try{for(var v=(0,p.Ju)(d.removes),m=v.next();!m.done;m=v.next()){var y=m.value;l.has(y.id)||l.set(y.id,t),c.set(y.id,t)}}catch(e){i={error:e}}finally{try{m&&!m.done&&(s=v.return)&&s.call(v)}finally{if(i)throw i.error}}});var d=new Set,h=new Set;try{for(var g=(0,p.Ju)(o),f=g.next();!f.done;f=g.next()){var v=(0,p.zs)(f.value,2),m=v[0],y=v[1],b=l.get(m);
1if(void 0!==b){var S=a.get(m),I=c.get(m);!(S>=I)&&(y<b?d.add(m):b<y&&h.add(m))}}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=g.return)&&n.call(g)}finally{if(t)throw t.error}}var C=new Set;if(d.size>0||h.size>0)for(var w=!0;w;){w=!1;try{for(var k=(r=void 0,(0,p.Ju)(u)),E=k.next();!E.done;E=k.next()){var P=(0,p.zs)(E.value,2),R=P[0],_=P[1];if(!d.has(R)&&!h.has(R)&&!C.has(R)&&(d.has(_)||h.has(_)||C.has(_))){var T=l.get(R),x=o.get(R);void 0!==T&&void 0!==x&&T<x?h.add(R):void 0!==T&&void 0!==x&&T===x?C.add(R):d.add(R),w=!0}}}catch(e){r={error:e}}finally{try{E&&!E.done&&(i=k.return)&&i.call(k)}finally{if(r)throw r.error}}}var M=d.size>0||h.size>0||C.size>0,L=[];e.forEach(function(e,t){var n,r;try{for(var i=(0,p.Ju)(e.data.removes),s=i.next();!s.done;s=i.next()){var a=s.value;!(d.has(a.id)||h.has(a.id)&&t>=o.get(a.id))&&(C.has(a.id)&&(d.has(a.parentId)||h.has(a.parentId)||C.has(a.parentId))||L.push(a))}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}});var O=e.flatMap(function(e){return e.data.adds}),D=e.flatMap(function(e){return e.data.texts}),H=e.flatMap(function(e){return e.data.attributes}),F={source:ed.Mutation,removes:L,adds:M?O.filter(function(e){return!d.has(e.node.id)&&!h.has(e.node.id)&&!C.has(e.node.id)}):O,texts:M?D.filter(function(e){return!d.has(e.id)&&!h.has(e.id)&&!C.has(e.id)}):D,attributes:M?H.filter(function(e){return!d.has(e.id)&&!h.has(e.id)&&!C.has(e.id)}):H};return(0,p.Cl)((0,p.Cl)({},s),{data:F})}(e.slice(n,r)):e[n]),n=r}return t}(e.slice(s,a).map(function(e){return e.event}));try{for(var c=(t=void 0,(0,p.Ju)(l)),u=c.next();!u.done;u=c.next()){var d=u.value;i.push({event:d,sessionId:o})}}catch(e){t={error:e}}finally{try{u&&!u.done&&(n=c.return)&&n.call(c)}finally{if(t)throw t.error}}s=a}return i},e}(),e_="Session replay event batch rejected due to exceeded retry count",eT="Failed to store session replay events in IndexedDB",ex="Session replay event batch dropped: server signalled capture disabled or session out of valid range for this session",eM="1.42.3",eL=function(){function e(e){var t=e.trackServerUrl,n=e.loggerProvider,r=e.payloadBatcher,i=e.workerScript,s=this;if(this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.sendIdCounter=0,this.pendingWorkerRequests=new Map,this.flushPauseUntilMs=0,this.killedSessions=new Set,this.loggerProvider=n,this.payloadBatcher=r||function(e){return e},this.trackServerUrl=t,i)try{var o=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(o),l=new Worker(a);l.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,")")),l.terminate(),s.worker=void 0;try{for(var i=(0,p.Ju)(s.pendingWorkerRequests),o=i.next();!o.done;o=i.next()){var a=(0,p.zs)(o.value,2)[1];n.warn("Session replay event send failed due to worker crash: ".concat(e.message)),a.resolve()}}catch(e){t={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}s.pendingWorkerRequests.clear()},l.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=s.pendingWorkerRequests.get(t.id);r&&(s.handlePayloadTooLargeResponse(r.context,t.isWaf),r.resolve(),s.pendingWorkerRequests.delete(t.id))}else if("complete"===t.type){var i=s.pendingWorkerRequests.get(t.id);i&&(void 0!==t.skipCode&&s.applyServerDirective(i.context.sessionId,t.skipCode),s.completeRequest({context:i.context}),i.resolve(),s.pendingWorkerRequests.delete(t.id))}},this.worker=l}catch(e){n.error("Failed to create track destination worker, falling back to main-thread sending:",e)}}return e.prototype.sendEventsList=function(e){this.addToQueue((0,p.Cl)((0,p.Cl)({},e),{attempts:0,timeout:0}))},e.prototype.sendBeacon=function(e){var t,n,r=e.events,i=e.sessionId,s=e.deviceId,o=e.apiKey,a=e.serverZone,l=function(e){return new Blob([e]).size},c=r,u=JSON.stringify({version:2,events:c});if(l(u)>65536){for(var d=0,h=c.length;d<h;){var g=Math.floor((d+h+1)/2);65536>=l(JSON.stringify({version:2,events:c.slice(0,g)}))?d=g:h=g-1}u=JSON.stringify({version:2,events:c=c.slice(0,d)}),this.loggerProvider.warn("sendBeacon payload exceeded 64 KB limit, trimmed from ".concat(r.length," to ").concat(c.length," events"))}if(0!==c.length){var f=new URLSearchParams({device_id:s,session_id:String(i),type:"replay",api_key:o}),v="".concat(eE(a,this.trackServerUrl),"?").concat(f.toString()),p=(0,m.m)();try{var y=new Blob([u],{type:"application/json"}),b=null==(n=null==(t=null==p?void 0:p.navigator)?void 0:t.sendBeacon)?void 0:n.call(t,v,y);!1===b&&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:ex}),!1):t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:e_}),!1)}
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;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,p.sH)(this,void 0,void 0,function(){var t,n,r,i,s,o;return(0,p.YH)(this,function(a){switch(a.label){case 0:t=this.queue,this.queue=[],this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),a.label=1;case 1:a.trys.push([1,6,7,8]),r=(n=(0,p.Ju)(t)).next(),a.label=2;case 2:if(r.done)return[3,5];return i=r.value,[4,this.send(i,e)];case 3:a.sent(),a.label=4;case 4:return r=n.next(),[3,2];case 5:return[3,8];case 6:return s={error:a.sent()},[3,8];case 7:try{r&&!r.done&&(o=n.return)&&o.call(n)}finally{if(s)throw s.error}return[7];case 8:return[2]}})})},e.prototype.send=function(e,t){return void 0===t&&(t=!0),(0,p.sH)(this,void 0,void 0,function(){var n,r,i,s;return(0,p.YH)(this,function(o){return this.killedSessions.has(e.sessionId)?[2,this.completeRequest({context:e,err:ex})]:(n=e.apiKey)?(r=e.deviceId)?0===(i=this.payloadBatcher({version:1,events:e.events})).events.length?(this.completeRequest({context:e}),[2]):(s=this.worker)?[2,this.sendViaWorker(s,e,i,t)]:[2,this.sendOnMainThread(n,r,e,i,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,p.sH)(this,void 0,void 0,function(){var i,s=this;return(0,p.YH)(this,function(o){return i="".concat(++this.sendIdCounter),[2,new Promise(function(o){var a;s.pendingWorkerRequests.set(i,{context:t,resolve:o}),e.postMessage({type:"send",id:i,payload:n,useRetry:r,context:{apiKey:t.apiKey,deviceId:t.deviceId,sessionId:t.sessionId,events:t.events,eventType:t.type,flushMaxRetries:null!=(a=t.flushMaxRetries)?a:0,sampleRate:t.sampleRate,serverZone:t.serverZone,trackServerUrl:s.trackServerUrl,version:t.version,currentUrl:J(),sdkVersion:eM}})})]})})},e.prototype.sendOnMainThread=function(e,t,n,r,i){var s,o,a,l,c,u,d;return(0,p.sH)(this,void 0,void 0,function(){var h,g,f,v,y,b,S,I,C,w,k,E,P,R,_;return(0,p.YH)(this,function(T){switch(T.label){case 0:h=J(),g=eM,f=n.sampleRate,v=new URLSearchParams({device_id:t,session_id:"".concat(n.sessionId),type:"".concat(n.type)}),y="".concat(null!=(o=null==(s=n.version)?void 0:s.type)?o:"standalone","/").concat(null!=(l=null==(a=n.version)?void 0:a.version)?l:g),T.label=1;case 1:if(T.trys.push([1,13,,14]),b=JSON.stringify(r),!((S=(0,m.m)())&&"CompressionStream"in S))return[3,3];return[4,function(e,t){return(0,p.sH)(this,void 0,void 0,function(){var n,r,i,s,o,a,l,c,u,d,h,g,f=this;return(0,p.YH)(this,function(v){switch(v.label){case 0:return v.trys.push([0,4,,5]),r=(n=new t.CompressionStream("gzip")).writable.getWriter(),i=n.readable.getReader(),s=[],o=(0,p.sH)(f,void 0,void 0,function(){var e,t,n;return(0,p.YH)(this,function(r){switch(r.label){case 0:return[4,i.read()];case 1:if(t=(e=r.sent()).done,n=e.value,t)return[3,3];s.push(n),r.label=2;case 2:return[3,0];case 3:return[2]}})}),[4,r.write(new TextEncoder().encode(e))];case 1:return v.sent(),[4,r.close()];case 2:return v.sent(),[4,o];case 3:v.sent(),a=new Uint8Array(s.reduce(function(e,t){return e+t.length},0)),l=0;try{for(u=(c=(0,p.Ju)(s)).next();!u.done;u=c.next())d=u.value,a.set(d,l),l+=d.length}catch(e){h={error:e}}finally{try{u&&!u.done&&(g=c.return)&&g.call(c)}finally{if(h)throw h.error}}return[2,a];case 4:return v.sent(),[2,null];case 5:return[2]}})})}(b,S)];case 2:return C=T.sent(),[3,4];case 3:C=null,T.label=4;case 4:return w=(I=C)?I.byteLength:new Blob([b]).size,k={headers:(0,p.Cl)({"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(e),"X-Client-Version":g,"X-Client-Library":y,"X-Client-Url":h.substring(0,1e3),"X-Client-Sample-Rate":"".concat(f),"X-Sampling-Hash-Alg":"xxhash32"},I?{"Content-Encoding":"gzip"}:{}),body:null!=I?I:b,method:"POST",keepalive:w<=65536},[4,fetch("".concat(eE(n.serverZone,this.trackServerUrl),"?").concat(v.toString()),k)];case 5:if(null===(E=T.sent()))return this.completeRequest({context:n,err:"Unexpected error occurred"}),[2];if(E.status>=200&&E.status<300&&(P=null!=(d=null==(u=null==(c=E.headers)?void 0:c.get)?void 0:u.call(c,"X-Session-Replay-Event-Skipped"))?d:null,this.applyServerDirective(n.sessionId,P)),i)return[3,6];R="";try{R=JSON.stringify(E.body,null,2)}catch(e){}return this.completeRequest({context:n,success:"".concat(E.status,": ").concat(R)}),[3,12];case 6:if(R="",413!==E.status)return[3,10];T.label=7;case 7:return T.trys.push([7,9,,10]),[4,E.text()];case 8:return R=T.sent(),[3,10];
1case 9:return T.sent(),[3,10];case 10:return[4,this.handleReponse(E.status,n,R)];case 11:T.sent(),T.label=12;case 12:return[3,14];case 13:return _=T.sent(),this.completeRequest({context:n,err:_}),[3,14];case 14:return[2]}})})},e.prototype.handleReponse=function(e,t,n){return void 0===n&&(n=""),(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(r){switch(r.label){case 0:switch(new I().buildStatus(e)){case o.Success:return[3,1];case o.Failed:case o.Timeout:case o.RateLimit:return[3,2];case o.PayloadTooLarge:return[3,4]}return[3,5];case 1:return this.handleSuccessResponse(t),[3,8];case 2:return[4,this.handleOtherResponse(t)];case 3:case 6:return r.sent(),[3,8];case 4:return this.handlePayloadTooLargeResponse(t,A.test(n)),[3,8];case 5:if(499!==e)return[3,7];return[4,this.handleOtherResponse(t)];case 7:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"}),r.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)/1024);if(!t)return void 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")});if(1===e.events.length)return void this.completeRequest({context:e,err:"Session replay event dropped: single event (".concat(r," KB, 1 event) rejected by ").concat(n," — cannot split further")});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 i=function(){return Promise.resolve()},s=Math.floor(e.events.length/2);this.sendEventsList((0,p.Cl)((0,p.Cl)({},e),{events:e.events.slice(0,s),onComplete:i})),this.sendEventsList((0,p.Cl)((0,p.Cl)({},e),{events:e.events.slice(s),onComplete:i}))},e.prototype.handleSuccessResponse=function(e){var t=Math.round(new Blob(e.events).size/1024);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,p.sH)(this,void 0,void 0,function(){var t;return(0,p.YH)(this,function(n){switch(n.label){case 0:if(t=Math.random()*e.attempts*this.retryTimeout,e.attempts++,e.attempts>(e.flushMaxRetries||0))return this.completeRequest({context:e,err:e_}),[2];return[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){this.flushPauseUntilMs=0;return}if("429"===t){var n=this.flushPauseUntilMs>Date.now();this.flushPauseUntilMs=Date.now()+6e4,n||this.loggerProvider.log("Session replay throttled by server; pausing flush schedule for ".concat(60,"s"));return}("4005"===t||"4004"===t)&&this.killSession(e,t)},e.prototype.killSession=function(e,t){if(!this.killedSessions.has(e)){if(this.killedSessions.add(e),this.killedSessions.size>256)try{for(var n,r,i,s,o=(0,p.Ju)(this.killedSessions),a=o.next();!a.done;a=o.next()){var l=a.value;this.killedSessions.delete(l);break}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}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 c=[];try{for(var u=(0,p.Ju)(this.queue),d=u.next();!d.done;d=u.next()){var h=d.value;h.sessionId===e?this.completeRequest({context:h,err:ex}):c.push(h)}}catch(e){i={error:e}}finally{try{d&&!d.done&&(s=u.return)&&s.call(u)}finally{if(i)throw i.error}}this.queue=c}},e}(),eO=n(20635),eD=function(){function e(e){var t,n,r,i=this;this.minInterval=500,this.maxInterval=1e4,this.maxPersistedEventsSize=7e5,this.interval=this.minInterval,this._timeAtLastSplit=Date.now(),this.shouldSplitEventsList=function(e,t){var n=i.getStringSize(t);return i.getEventsArraySize(e)+n>
1=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)?t:this.minInterval,this.maxInterval=null!=(n=e.maxInterval)?n:this.maxInterval,this.maxPersistedEventsSize=null!=(r=e.maxPersistedEventsSize)?r:this.maxPersistedEventsSize}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 i=(0,p.Ju)(e),s=i.next();!s.done;s=i.next()){var o=s.value;r+=this.getStringSize(o)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}return r+(2+Math.max(0,e.length-1)+2*e.length)},e}(),eH=function(e,t,n){"object"==typeof n&&null!==n&&"AbortError"===n.name?e.debug(t):e.warn(t)},eF="sessionCurrentSequence",eN="sequencesToSend";function eA(e,t,n){var r=setTimeout(n,t);return e.then(function(){return clearTimeout(r)},function(){return clearTimeout(r)}),function(){return clearTimeout(r)}}var eU=function(e){var t,n;return e.objectStoreNames.contains(eF)||(n=e.createObjectStore(eF,{keyPath:"sessionId"})),e.objectStoreNames.contains(eN)||(t=e.createObjectStore(eN,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},eq=function(e){function t(t){var n,r=this;return(r=e.call(this,t)||this).consecutiveFailures=0,r.hasTriggeredFallback=!1,r.getSequencesToSend=function(){return(0,p.sH)(r,void 0,void 0,function(){var e,t,n,r,i,s,o,a,l,c,u=this;return(0,p.YH)(this,function(d){switch(d.label){case 0:e=!1,t=!1,d.label=1;case 1:return d.trys.push([1,6,,7]),n=[],(r=this.db.transaction("sequencesToSend")).done.catch(function(n){e||t||(eH(u.loggerProvider,"".concat(eT,": ").concat(n),n),u.recordFailure())}),i=eA(r.done,5e3,function(){e||t||(t=!0,eH(u.loggerProvider,"".concat(eT,": transaction timed out")),u.recordFailure())}),[4,r.store.openCursor()];case 2:s=d.sent(),d.label=3;case 3:if(!s)return[3,5];return a=(o=s.value).sessionId,l=o.events,n.push({events:l,sequenceId:s.key,sessionId:a}),[4,s.continue()];case 4:return s=d.sent(),[3,3];case 5:return this.recordSuccess(),i(),[2,n];case 6:return c=d.sent(),t||(e=!0,eH(this.loggerProvider,"".concat(eT,": ").concat(c),c),this.recordFailure()),[3,7];case 7:return[2,void 0]}})})},r.storeCurrentSequence=function(e){return(0,p.sH)(r,void 0,void 0,function(){var t,n,r,i,s,o,a,l,c=this;return(0,p.YH)(this,function(u){switch(u.label){case 0:t=!1,n=!1,u.label=1;case 1:return u.trys.push([1,5,,6]),(r=this.db.transaction([eF,eN],"readwrite")).done.catch(function(e){t||n||(eH(c.loggerProvider,"".concat(eT,": ").concat(e),e),c.recordFailure())}),i=eA(r.done,5e3,function(){t||n||(n=!0,eH(c.loggerProvider,"".concat(eT,": transaction timed out")),c.recordFailure())}),[4,r.objectStore(eF).get(e)];case 2:if(!(s=u.sent())||s.tabId&&s.tabId!==this.tabId||0===s.events.length)return i(),[2,void 0];return[4,r.objectStore(eN).put({sessionId:e,events:s.events,tabId:this.tabId})];case 3:return o=u.sent(),[4,r.objectStore(eF).put({sessionId:e,events:[],tabId:this.tabId})];case 4:return u.sent(),this.recordSuccess(),i(),s.tabId,a=(0,p.Tt)(s,["tabId"]),[2,(0,p.Cl)((0,p.Cl)({},a),{sessionId:e,sequenceId:o})];case 5:return l=u.sent(),n||(t=!0,eH(this.loggerProvider,"".concat(eT,": ").concat(l),l),this.recordFailure()),[3,6];case 6:return[2,void 0]}})})},r.addEventToCurrentSequence=function(e,t){return(0,p.sH)(r,void 0,void 0,function(){var n,r,i,s,o,a,l,c,u,d=this;return(0,p.YH)(this,function(h){switch(h.label){case 0:n=!1,r=!1,h.label=1;case 1:return h.trys.push([1,13,,14]),(i=this.db.transaction([eF,eN],"readwrite")).done.catch(function(e){n||r||(eH(d.loggerProvider,"".concat(eT,": ").concat(e),e),d.recordFailure())}),s=eA(i.done,5e3,function(){n||r||(r=!0,eH(d.loggerProvider,"".concat(eT,": transaction timed out")),d.recordFailure())}),[4,i.objectStore(eF).get(e)];case 2:if(!((null==(o=h.sent())?void 0:o.tabId)&&o.tabId!==this.tabId))return[3,6];if(!(o.events.length>0))return[3,4];return[4,i.objectStore(eN).put({sessionId:e,events:o.events,tabId:o.tabId})];case 3:h.sent(),h.label=4;case 4:return[4,i.objectStore(eF).put({sessionId:e,events:[t],tabId:this.tabId})];case 5:case 7:case 9:return h.sent(),this.recordSuccess(),s(),[2,void 0];case 6:if(a=o)return[3,8];return[4,i.objectStore(eF).put({sessionId:e,events:[t],tabId:this.tabId})];case 8:if(this.shouldSplitEventsList(a.events,t))return[3,10];return[4,i.objectStore(eF).put({sessionId:e,events:a.events.concat(t),tabId:this.tabId})];case 10:return l=a.events,[4,i.objectStore(eF).put({sessionId:e,events:[t],tabId:this.tabId})];case 11:return h.sent(),[4,i.objectStore(eN).put({sessionId:e,events:l,tabId:this.tabId})];case 12:return c=h.sent(),this.recordSuccess(),s(),[2,{events:l,sessionId:e,sequenceId:c}];case 13:return u=h.sent(),r||(n=!0,eH(this.loggerProvider,"".concat(eT,": ").concat(u),u),this.recordFailure()),[3,14];case 14:return[2,void 0]}})})},r.storeSendingEvents=function(e,t){return(0,p.sH)(r,void 0,void 0,function(){var n,r;return(0,p.YH)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.db.put(eN,{sessionId:e,events:t,tabId:this.tabId})];case 1:return n=i.sent(),this.recordSuccess(),[2,n];case 2:return r=i.sent(),eH(this.loggerProvider,"".concat(eT,": ").concat(r),r),this.recordFailure(),[3,3];case 3:return[2,void 0]}})})},r.cleanUpSessionEventsStore=function(e,t){return(0,p.sH)(r,void 0,void 0,function(){var e;return(0,p.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(eN,t)];case 2:return n.sent(),this.recordSuccess(),[3,4];case 3:return e=n.sent(),eH(this.loggerProvider,"".concat(eT,": ").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)?n:1,r}return(0,p.C6)(t,e),t.prototype.recordFailure=function(){var e;this.consecutiveFailures++,!this.hasTriggeredFallback&&this.consecutiveFailures>=this.consecutiveFailureThreshold&&(this.hasTriggeredFallback=!0,null==(e=this.onPersistentFailure)||e.call(this))},t.prototype.recordSuccess=function(){this.consecutiveFailures=0},t.new=function(e,n){var r;return(0,p.sH)(this,void 0,void 0,function(){var i,s,o,a;return(0,p.YH)(this,function(l){switch(l.label){case 0:var c;return l.trys.push([0,2,,3]),i="replay"===e?"":"_".concat(e),[4,(c="".concat(n.apiKey.substring(0,10),"_amp_session_replay_events").concat(i),(0,p.sH)(void 0,void 0,void 0,function(){return(0,p.YH)(this,function(e){switch(e.label){case 0:var t;return[4,(t=(0,eO.P2)(c,1,{upgrade:eU}),new Promise(function(e,n){var r=setTimeout(function(){return n(Error("".concat("IDB openDB timed out"," after ").concat(2e3,"ms")))},2e3);t.then(function(t){clearTimeout(r),e(t)},function(e){clearTimeout(r),n(e)})}))];case 1:return[2,e.sent()]}})}))];case 1:return s=l.sent(),o=null!=(r=n.tabId)?r:function(){try{return crypto.randomUUID()}catch(e){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,p.Cl)((0,p.Cl)({},n),{db:s,tabId:o}))];case 2:return a=l.sent(),eH(n.loggerProvider,"".concat(eT,": ").concat(a),a),[3,3];case 3:return[2]}})})},t.prototype.getCurrentSequenceEvents=function(e){return(0,p.sH)(this,void 0,void 0,function(){var t,n,r,i,s,o,a;return(0,p.YH)(this,function(l){switch(l.label){case 0:if(!e)return[3,2];return[4,this.db.get("sessionCurrentSequence",e)];case 1:if(!(t=l.sent())||t.tabId&&t.tabId!==this.tabId)return[2,void 0];return t.tabId,[2,[n=(0,p.Tt)(t,["tabId"])]];case 2:r=[],l.label=3;case 3:return l.trys.push([3,8,9,10]),[4,this.db.getAll("sessionCurrentSequence")];case 4:s=(i=p.Ju.apply(void 0,[l.sent()])).next(),l.label=5;case 5:if(s.done)return[3,7];if((t=s.value).tabId&&t.tabId!==this.tabId)return[3,6];t.tabId,n=(0,p.Tt)(t,["tabId"]),r.push(n),l.label=6;case 6:return s=i.next(),[3,5];case 7:return[3,10];case 8:return o={error:l.sent()},[3,10];case 9:try{s&&!s.done&&(a=i.return)&&a.call(i)}finally{if(o)throw o.error}
1return[7];case 10:return[2,r]}})})},t}(eD),eB=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.finalizedSequences={},t.sequences={},t.sequenceId=0,t}return(0,p.C6)(t,e),t.prototype.resetCurrentSequence=function(e){this.sequences[e]=[]},t.prototype.addSequence=function(e){var t=this.sequenceId++,n=(0,p.fX)([],(0,p.zs)(this.sequences[e]),!1);return this.finalizedSequences[t]={sessionId:e,events:n},this.resetCurrentSequence(e),{sequenceId:t,events:n,sessionId:e}},t.prototype.getSequencesToSend=function(){return(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(e){return[2,Object.entries(this.finalizedSequences).map(function(e){var t=(0,p.zs)(e,2),n=t[0],r=t[1],i=r.sessionId,s=r.events;return{sequenceId:Number(n),sessionId:i,events:s}})]})})},t.prototype.storeCurrentSequence=function(e){return(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(t){return this.sequences[e]?[2,this.addSequence(e)]:[2,void 0]})})},t.prototype.addEventToCurrentSequence=function(e,t){return(0,p.sH)(this,void 0,void 0,function(){var n;return(0,p.YH)(this,function(r){return this.sequences[e]||this.resetCurrentSequence(e),this.shouldSplitEventsList(this.sequences[e],t)&&(n=this.addSequence(e)),this.sequences[e].push(t),[2,n]})})},t.prototype.storeSendingEvents=function(e,t){return(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(n){return this.finalizedSequences[this.sequenceId]={sessionId:e,events:t},[2,this.sequenceId++]})})},t.prototype.cleanUpSessionEventsStore=function(e,t){return(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(e){return void 0!==t&&delete this.finalizedSequences[t],[2]})})},t}(eD),eW=function(e){var t=e.config,n=e.minInterval,r=e.maxInterval,i=e.type,s=e.payloadBatcher,o=e.storeType,a=e.trackDestinationWorkerScript;return(0,p.sH)(void 0,void 0,void 0,function(){var e,l,c,u,d,h,g,f,v,m;function y(t){return void 0===t&&(t=!1),(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(n){return[2,e.flush(t)]})})}return(0,p.YH)(this,function(b){switch(b.label){case 0:if(e=new eL((0,p.Cl)((0,p.Cl)({},t),{loggerProvider:t.loggerProvider,payloadBatcher:s,workerScript:a})),l=function(){return new eB({loggerProvider:t.loggerProvider,maxInterval:r,minInterval:n})},u=!1,"idb"!==o)return[3,2];return[4,(0,p.sH)(void 0,void 0,void 0,function(){var e;return(0,p.YH)(this,function(s){switch(s.label){case 0:return[4,eq.new(i,{loggerProvider:t.loggerProvider,minInterval:n,maxInterval:r,apiKey:t.apiKey,onPersistentFailure:function(){(0,p.sH)(void 0,void 0,void 0,function(){var e,n,r;return(0,p.YH)(this,function(i){switch(i.label){case 0:if(!u)return[2];if(u=!1,t.loggerProvider.warn("IDB store is experiencing repeated failures; falling back to in-memory event store."),!c)return[3,2];return[4,d.getSequencesToSend()];case 1:return n=i.sent(),[3,3];case 2:n=void 0,i.label=3;case 3:return e=n,d=l(),e&&c&&(r=c,e.forEach(function(e){m({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})),[2]}})})}})];case 1:if(!(e=s.sent()))return t.loggerProvider.log("Failed to initialize idb store, falling back to memory store."),[2,l()];return u=!0,[2,e]}})})];case 1:return h=b.sent(),[3,3];case 2:h=l(),b.label=3;case 3:return d=h,g=[],f=0,v=function(e){if(!(e<=f)){var t=Math.min(e-f,g.length);t>0&&(g.splice(0,t),f=e)}},m=function(n){var r=n.events,s=n.sessionId,o=n.deviceId,a=n.sequenceId,l=r.map(function(e){return{event:e,bytes:new Blob([e]).size}}),c=l.filter(function(e){return e.bytes>9e6});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<=9e6}).map(function(e){return e.event}):r;if(0===u.length)return void d.cleanUpSessionEventsStore(s,a).catch(function(e){t.loggerProvider.warn("Failed to clean up session replay events store:",e)});t.debugMode&&G().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(){}),e.sendEventsList({events:u,sessionId:s,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:o,sampleRate:t.sampleRate,serverZone:t.serverZone,version:t.version,type:i,onComplete:function(){return(0,p.sH)(void 0,void 0,void 0,function(){return(0,p.YH)(this,function(e){switch(e.label){case 0:return[4,d.cleanUpSessionEventsStore(s,a)];case 1:return e.sent(),[2]}})})}})},[2,{sendCurrentSequenceEvents:function(e){var n=e.sessionId,r=e.deviceId;c=r;var i=f+g.length;d.storeCurrentSequence(n).then(function(e){e&&(v(i),m({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)})},addEvent:function(e){var n=e.event,r=e.sessionId,i=e.deviceId;c=i;var s=f+g.length;g.push(n.data),d.addEventToCurrentSequence(r,n.data).then(function(e){e&&(v(s),m({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)})},sendStoredEvents:function(e){var n=e.deviceId;return(0,p.sH)(void 0,void 0,void 0,function(){var e;return(0,p.YH)(this,function(r){switch(r.label){case 0:return c=n,[4,d.getSequencesToSend()];case 1:if(!(null==(e=r.sent())?void 0:e.length))return[2];return t.loggerProvider.log("Draining ".concat(e.length," stored sequence(s) from previous session.")),e.forEach(function(e){m({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:n})}),[2]}})})},flush:y,getBeaconEvents:function(){return(0,p.fX)([],(0,p.zs)(g),!1)},trackDestination:e}]}})})},ez=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,p.sH)(this,void 0,void 0,function(){var t;return(0,p.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))||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,p.sH)(this,void 0,void 0,function(){var t;return(0,p.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 ej(e,t,n){for(var r=null,i=[],s=e,o=0;s&&"break"!==function(){var e,a,l,c,d=new Date().getTime()-h.getTime();if(void 0!==u.timeoutMs&&d>u.timeoutMs)throw Error("Timeout: Can't find a unique selector after ".concat(d,"ms"));var g=eV((e=s.getAttribute("id"))&&u.idName(e)?{name:"#"+CSS.escape(e),penalty:0}:null)||eV.apply(void 0,(0,p.fX)([],(0,p.zs)(Array.from(s.attributes).filter(function(e){return u.attr(e.name,e.value)}).map(function(e){return{name:"[".concat(CSS.escape(e.name),'="').concat(CSS.escape(e.value),'"]'),penalty:.5}})),!1))||eV.apply(void 0,(0,p.fX)([],(0,p.zs)(Array.from(s.classList).filter(u.className).map(function(e){return{name:"."+CSS.escape(e),penalty:1}})),!1))||eV((a=s.tagName.toLowerCase(),u.tagName(a)?{name:a,penalty:2}:null))||[eQ()],f=function(e){var t=e.parentNode;if(!t)return null;var n=t.firstChild;if(!n)return null;for(var r=0;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}(s);if("all"==t)f&&(g=g.concat(g.filter(eG).map(function(e){return e$(e,f)})));else if("two"==t)g=g.slice(0,1),f&&(g=g.concat(g.filter(eG).map(function(e){return e$(e,f)})));else if("one"==t){var v=(0,p.zs)(g=g.slice(0,1),1)[0];f&&eG(v)&&(g=[e$(v,f)])}else"none"==t&&(g=[eQ()],f&&(g=[e$(g[0],f)]));try{for(var m=(l=void 0,(0,p.Ju)(g)),y=m.next();!y.done;y=m.next()){var v=y.value;v.level=o}}catch(e){l={error:e}}finally{try{y&&!y.done&&(c=m.return)&&c.call(m)}finally{if(l)throw l.error}}if(i.push(g),i.length>=u.seedMinLength&&(r=eY(i,n)))return"break";s=s.parentElement,o++}(););return(r||(r=eY(i,n)),!r&&n)?n():r}function eY(e,t){var n,r,i=e0(function e(t,n){var r,i,s,o,a;return void 0===n&&(n=[]),(0,p.YH)(this,function(l){switch(l.label){case 0:if(!(t.length>0))return[3,9];l.label=1;case 1:l.trys.push([1,6,7,8]),i=(r=(0,p.Ju)(t[0])).next(),l.label=2;case 2:if(i.done)return[3,5];return s=i.value,[5,(0,p.Ju)(e(t.slice(1,t.length),n.concat(s)))];case 3:l.sent(),l.label=4;case 4:return i=r.next(),[3,2];case 5:return[3,8];case 6:return o={error:l.sent()},[3,8];case 7:try{i&&!i.done&&(a=r.return)&&a.call(r)}finally{if(o)throw o.error}return[7];case 8:return[3,11];case 9:return[4,n];case 10:l.sent(),l.label=11;case 11:return[2]}})}(e));if(i.length>u.threshold)return t?t():null;try{for(var s=(0,p.Ju)(i),o=s.next();!o.done;o=s.next()){var a=o.value;if(eX(a))return a}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return null}function eJ(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 eK(e){return e.map(function(e){return e.penalty}).reduce(function(e,t){return e+t},0)}function eX(e){var t=eJ(e);switch(d.querySelectorAll(t).length){case 0:throw Error("Can't select any node with this selector: ".concat(t));case 1:return!0;default:return!1}}function eQ(){return{name:"*",penalty:3}}function e$(e,t){return{name:e.name+":nth-child(".concat(t,")"),penalty:e.penalty+1}}function eG(e){return"html"!==e.name&&!e.name.startsWith("#")}function eV(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.filter(eZ);return n.length>0?n:null}function eZ(e){return null!=e}function e0(e){return(0,p.fX)([],(0,p.zs)(e),!1).sort(function(e,t){return eK(e)-eK(t)})}var e1=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}},e2=function(e){var t=e.version,n=e.events,r=[];
1return n.forEach(function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)}),{version:t,events:Object.values(r.reduce(function(e,t){var n=t.x,r=t.y,i=t.selector,s=t.timestamp,o=s-s%36e5,a="".concat(n,":").concat(r,":").concat(null!=i?i:"",":").concat(o);return e[a]?e[a].count+=1:e[a]=(0,p.Cl)((0,p.Cl)({},t),{timestamp:o,count:1}),e},{}))}},e3=function(e,t){var n=this;this.createHook=function(e){var t=e.eventsManager,r=e.sessionId,i=e.deviceIdFn,s=e.mirror,o=e.ugcFilterRules,a=e.performanceOptions;return function(e){if(e.type!==eh.Click)return;var l,c=(0,m.m)();if(c){var g=c.location,f=c.innerHeight,v=c.innerWidth;if(g){var y=e.x,b=e.y;if(void 0!==y&&void 0!==b){var S=s.getNode(e.id);if(S)try{l=function(e,t){if(h=new Date,e.nodeType!==Node.ELEMENT_NODE)throw Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";var n,r,i={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};n=(u=(0,p.Cl)((0,p.Cl)({},i),t)).root,r=i,d=n.nodeType===Node.DOCUMENT_NODE?n:n===r.root?n.ownerDocument:n;var s=ej(e,"all",function(){return ej(e,"two",function(){return ej(e,"one",function(){return ej(e,"none")})})});if(s){var o=e0(function e(t,n,r){var i,s,o;return void 0===r&&(r={counter:0,visited:new Map}),(0,p.YH)(this,function(a){switch(a.label){case 0:if(!(t.length>2&&t.length>u.optimizedMinLength))return[3,5];i=1,a.label=1;case 1:var l,c;if(!(i<t.length-1))return[3,5];if(r.counter>u.maxNumberOfTries||(r.counter+=1,(s=(0,p.fX)([],(0,p.zs)(t),!1)).splice(i,1),o=eJ(s),r.visited.has(o)))return[2];if(!(eX(s)&&(l=s,c=n,d.querySelector(eJ(l))===c)))return[3,4];return[4,s];case 2:return a.sent(),r.visited.set(o,!0),[5,(0,p.Ju)(e(s,n,r))];case 3:a.sent(),a.label=4;case 4:return i++,[3,1];case 5:return[2]}})}(s,e));return o.length>0&&(s=o[0]),eJ(s)}throw Error("Selector was not found.")}(S,a)}catch(e){n.logger.debug("error resolving selector from finder")}var I=$(g.href,o),C={x:y+n.scrollWatcher.currentScrollX,y:b+n.scrollWatcher.currentScrollY,selector:l,viewportHeight:f,viewportWidth:v,pageUrl:I,timestamp:Date.now(),type:"click"},w=i();w&&t.addEvent({sessionId:r,event:{type:"interaction",data:JSON.stringify(C)},deviceId:w})}}}}},this.logger=e,this.scrollWatcher=t};function e4(){var e=(0,m.m)();return(null==e?void 0:e.innerHeight)||document.documentElement&&document.documentElement.clientHeight||0}function e6(){var e=(0,m.m)();return(null==e?void 0:e.innerWidth)||document.documentElement&&document.documentElement.clientWidth||0}var e5=function(){function e(e,t){var n=(0,m.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(e){}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=eE(t.serverZone,t.trackServerUrl),this.apiKey=t.apiKey,this.context=e}return e.prototype.send=function(e,t){var n=this.context,r=n.sessionId,i=n.type,s=new URLSearchParams({device_id:e,session_id:String(r),type:String(i),api_key:this.apiKey}),o="".concat(this.basePageUrl,"?").concat(s.toString());this.sendBeacon(o,t)||this.sendXhr(o,t)},e}(),e7=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,o,a=e(),l=(0,m.m)();if(l&&a){var c=null!=(r=l.scrollX)?r:0,u=null!=(i=l.scrollY)?i:0;(c>0||u>0)&&n.update({id:1,x:c,y:u}),n.transport.send(a,{version:1,events:[{maxScrollX:n._maxScrollX,maxScrollY:n._maxScrollY,maxScrollWidth:n._maxScrollWidth,maxScrollHeight:n._maxScrollHeight,viewportHeight:e4(),viewportWidth:e6(),pageUrl:$(l.location.href,null!=(o=null==(s=n.config.interactionConfig)?void 0:s.ugcFilterRules)?o:[]),timestamp:n.timestamp,type:"scroll"}]})}}},this._maxScrollX=0,this._maxScrollY=0,this._currentScrollX=0,this._currentScrollY=0,this._maxScrollWidth=e6(),this._maxScrollHeight=e4(),this.config=t,this.transport=e}return e.default=function(t,n){return new e(new e5(t,n),n)},Object.defineProperty(e.prototype,"maxScrollX",{get:function(){return this._maxScrollX}
1,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=e6();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=e4();this._maxScrollY=e.y;var s=e.y+i;s>this._maxScrollHeight&&(this._maxScrollHeight=s),this.timestamp=t}},e}(),e8=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId="".concat(n,"/").concat(t))},e9=new function(){var e=this;this.dbs={},this.createStore=function(t){return(0,p.sH)(e,void 0,void 0,function(){return(0,p.YH)(this,function(e){switch(e.label){case 0:return[4,(0,eO.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,p.sH)(e,void 0,void 0,function(){var e,n;return(0,p.YH)(this,function(r){switch(r.label){case 0:if(this.dbs&&this.dbs[t])return[2,this.dbs[t]];return 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,i=t.sessionId;return(0,p.sH)(e,void 0,void 0,function(){var e,t,s,o;return(0,p.YH)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.get("sessionTargetingMatch",t)];case 2:return[2,null==(s=a.sent())?void 0:s.targetingMatch];case 3:return o=a.sent(),eH(n,"Failed to get targeting match for session id ".concat(i,": ").concat(o),o),[3,4];case 4:return[2,void 0]}})})},this.storeTargetingMatchForSession=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.sessionId,s=t.targetingMatch;return(0,p.sH)(e,void 0,void 0,function(){var e,t,o;return(0,p.YH)(this,function(a){switch(a.label){case 0:return a.trys.push([0,3,,4]),[4,this.openOrCreateDB(r)];case 1:return e=a.sent(),t=String(i),[4,e.put("sessionTargetingMatch",{targetingMatch:s,sessionId:t,lastUpdated:Date.now()})];case 2:return[2,a.sent()];case 3:return o=a.sent(),eH(n,"Failed to store targeting match for session id ".concat(i,": ").concat(o),o),[3,4];case 4:return[2,void 0]}})})},this.clearStoreOfOldSessions=function(t){var n=t.loggerProvider,r=t.apiKey,i=t.currentSessionId;return(0,p.sH)(e,void 0,void 0,function(){var e,t,s,o,a,l,c,u;return(0,p.YH)(this,function(d){switch(d.label){case 0:return d.trys.push([0,8,,9]),[4,this.openOrCreateDB(r)];case 1:return e=d.sent(),t=String(i),[4,(s=e.transaction("sessionTargetingMatch","readwrite")).store.getAll()];case 2:o=d.sent(),a=0,d.label=3;case 3:if(!(a<o.length))return[3,6];if(l=o[a],c=Date.now()-l.lastUpdated,!(l.sessionId!==t&&c>1728e5))return[3,5];return[4,s.store.delete(l.sessionId)];case 4:d.sent(),d.label=5;case 5:return a++,[3,3];case 6:return[4,s.done];case 7:return d.sent(),[3,9];case 8:return u=d.sent(),eH(n,"Failed to clear old targeting matches for sessions: ".concat(u),u),[3,9];case 9:return[2]}})})}},te=function(e){var t=e.sessionId,r=e.targetingConfig,i=e.loggerProvider,s=e.apiKey,o=e.targetingParams,a=e.urlChange,l=void 0!==a&&a;return(0,p.sH)(void 0,void 0,void 0,function(){var e,a,c;return(0,p.YH)(this,function(u){switch(u.label){case 0:return[4,e9.clearStoreOfOldSessions({loggerProvider:i,apiKey:s,currentSessionId:t})];case 1:return u.sent(),[4,e9.getTargetingMatchForSession({loggerProvider:i,apiKey:s,sessionId:t})];case 2:if(!0===u.sent()&&!l)return[2,!0];e=!0,u.label=3;case 3:return u.trys.push([3,6,,7]),[4,n.e(5953).then(n.bind(n,45953))];case 4:return[4,(0,u.sent().evaluateTargeting)((0,p.Cl)((0,p.Cl)({},o),{flag:r,sessionId:"string"==typeof t?parseInt(t,10):t,apiKey:s,loggerProvider:i}))];case 5:return(a=u.sent())&&a.sr_targeting_config&&(e="on"===a.sr_targeting_config.key),e9.storeTargetingMatchForSession({loggerProvider:i,apiKey:s,sessionId:t,targetingMatch:e}),[3,7];case 6:return c=u.sent(),i.warn(c.message),[3,7];case 7:return[2,e]}})})};function tt(e,t){return(e<<t|e>>>32-t)>>>0}function tn(e,t){return Math.imul(e=tt(e=e+Math.imul(t,0x85ebca77)>>>0,13),0x9e3779b1)>>>0}function tr(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0}
1var ti="__amplitude_url_tracking_patched__",ts=new WeakMap;function to(e,t,n){if(void 0===n&&(n={}),!(null==e?void 0:e.location))return function(){};var r=n.enablePolling,i=n.pollingInterval;if(void 0!==r&&r){var s=function(){var t;return null!=(t=e.location.href)?t:""},o=s(),a=e.setInterval(function(){var e=s();e!==o&&(o=e,t(e))},void 0===i?1e3:i);return function(){null!=a&&e.clearInterval(a)}}var l=ts.get(e);if(!l){var c=void 0,u=new Set,d=function(){var t;return null!=(t=e.location.href)?t:""},h=function(){var e=d();(void 0===c||e!==c)&&(c=e,u.forEach(function(t){return t(e)}))},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[ti]=!0,t},f=e.history;if(null==f?void 0:f.pushState){var v=Reflect.get(f,"pushState");v[ti]||(f.pushState=g(v))}if(null==f?void 0:f.replaceState){var p=Reflect.get(f,"replaceState");p[ti]||(f.replaceState=g(p))}l={callbacks:u,notify:h,onPopStateOrHashChange:function(){return h()},listenersAttached:!1},ts.set(e,l)}var m=l;return m.listenersAttached||(e.addEventListener("popstate",m.onPopStateOrHashChange),e.addEventListener("hashchange",m.onPopStateOrHashChange),m.listenersAttached=!0),m.callbacks.add(t),function(){m.callbacks.delete(t),0===m.callbacks.size&&m.listenersAttached&&(e.removeEventListener("popstate",m.onPopStateOrHashChange),e.removeEventListener("hashchange",m.onPopStateOrHashChange),m.listenersAttached=!1)}}function ta(e){return void 0===e&&(e={}),{name:"amplitude/url-tracking@1",observer:function(t,n,r){var i,s,o,a=(0,p.Cl)((0,p.Cl)({},e),r),l=a.ugcFilterRules||[],c=null!=(i=a.enablePolling)&&i,u=null!=(s=a.pollingInterval)?s:1e3,d=null!=(o=a.captureDocumentTitle)&&o;if(!n)return function(){};var h=void 0,g=function(){return n.location&&n.location.href||""},f=function(){var e=n.innerHeight,t=n.innerWidth,r=n.document,i=g(),s="";return d&&(s=(null==r?void 0:r.title)||""),{href:l.length>0?$(i,l):i,title:s,viewportHeight:e,viewportWidth:t,type:"url-change-event"}},v=function(){var e=g();(void 0===h||e!==h)&&(h=e,t(f()))},m=to(n,function(){return v()},c?{enablePolling:!0,pollingInterval:u}:{});return v(),function(){return m()}},options:e}}ta();var tl=function(){function e(){this.pendingLoadListeners=new Map}return e.prototype.start=function(){var e,t=this;null==(e=this.mutationObserver)||e.disconnect(),(0,m.m)()&&(this.sendToAllIframes({type:U,action:"start"}),this.mutationObserver=new MutationObserver(function(e){var n,r,i,s,o,a;try{for(var l=(0,p.Ju)(e),c=l.next();!c.done;c=l.next()){var u=c.value;try{for(var d=(i=void 0,(0,p.Ju)(Array.from(u.addedNodes))),h=d.next();!h.done;h=d.next()){var g=h.value;g instanceof HTMLIFrameElement?t.sendToIframeAfterLoad(g):g instanceof Element&&g.querySelectorAll("iframe").forEach(function(e){t.sendToIframeAfterLoad(e)})}}catch(e){i={error:e}}finally{try{h&&!h.done&&(s=d.return)&&s.call(d)}finally{if(i)throw i.error}}try{for(var f=(o=void 0,(0,p.Ju)(Array.from(u.removedNodes))),v=f.next();!v.done;v=f.next()){var g=v.value;if(g instanceof HTMLIFrameElement){var m=t.pendingLoadListeners.get(g);m&&(g.removeEventListener("load",m),t.pendingLoadListeners.delete(g))}}}catch(e){o={error:e}}finally{try{v&&!v.done&&(a=f.return)&&a.call(f)}finally{if(o)throw o.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=l.return)&&r.call(l)}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)||e.disconnect(),this.mutationObserver=void 0,this.pendingLoadListeners.forEach(function(e,t){t.removeEventListener("load",e)}),this.pendingLoadListeners.clear(),this.sendToAllIframes({type:U,action:"stop"})},e.prototype.sendToIframeAfterLoad=function(e){var t=this,n=function(){t.pendingLoadListeners.delete(e),t.sendToIframe(e,{type:U,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)||n.postMessage(t,"*")}catch(e){}},e}(),tc=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.eventCount=0,this.sessionTargetingMatch=!1,this.pageLeaveFns=[],this.recordFunction=null,this.recordEventsInFlight=!1,this.pendingEmitEvents=[],this.currentPageUrl="",this.recordEventsPendingShouldLogMetadata=null,this.urlChangeCleanup=null,this.crossOriginIframeC
1oordinator=null,this.crossOriginParentSignalCleanup=null,this.latestUrlChangeTargetingEvaluationId=0,this.teardownEventListeners=function(t){var n=(0,m.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(){if(e.recordCancelCallback&&e.recordFunction)try{e.recordFunction.takeFullSnapshot(!0)}catch(t){e.loggerProvider.warn("Failed to take full snapshot on focus:",t)}else e.recordEventsInFlight||e.recordEvents(!1)},this.pageLeaveListener=function(t){var n;null==(n=e.eventCompressor)||n.flushQueue(),e.sendEvents(),e.pageLeaveFns.forEach(function(e){e(t)})},this.evaluateTargetingAndCapture=function(t,n,r,s){return void 0===n&&(n=!1),void 0===r&&(r=!1),void 0===s&&(s=!1),(0,p.sH)(e,void 0,void 0,function(){var e,o,a,l,c,u,d,h,g,f,v,y;return(0,p.YH)(this,function(p){switch(p.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];else this.loggerProvider.log("Targeting config has not been set yet, cannot evaluate targeting.");if(this.lastTargetingParams=t,!((e=this.config.targetingConfig)&&!this.sessionTargetingMatch))return[3,2];return o=s?this.latestUrlChangeTargetingEvaluationId:void 0,(a=t.event)&&Object.values(i).includes(a.event_type)&&(a=void 0),l=null!=(v=null!=(h=null==(d=t.page)?void 0:d.url)?h:null==(f=null==(g=(0,m.m)())?void 0:g.location)?void 0:f.href)?v:"",c=null!=(y=t.page)?y:""!==l?{url:l}:void 0,[4,te({sessionId:this.identifiers.sessionId,targetingConfig:e,loggerProvider:this.loggerProvider,apiKey:this.config.apiKey,targetingParams:{userProperties:t.userProperties,event:a,page:c},urlChange:s})];case 1:if(u=p.sent(),s&&void 0!==o&&o!==this.latestUrlChangeTargetingEvaluationId)return this.loggerProvider.debug("Ignoring stale URL-change targeting result #".concat(o,"; latest is #").concat(this.latestUrlChangeTargetingEvaluationId,".")),[2];this.sessionTargetingMatch=this.sessionTargetingMatch||u,this.loggerProvider.debug(JSON.stringify({name:"targeted replay capture config",sessionTargetingMatch:this.sessionTargetingMatch,event:a,targetingParams:t},null,2)),p.label=2;case 2:if(!n)return[3,3];return this.initialize(!0),[3,5];case 3:if(!(r||!this.recordCancelCallback))return[3,5];return this.loggerProvider.log("Recording events for session due to forceRestart or no ongoing recording."),[4,this.recordEvents()];case 4:p.sent(),p.label=5;case 5:return[2]}})})},this.addCustomRRWebEvent=function(t,n,r){return void 0===n&&(n={}),void 0===r&&(r=!0),(0,p.sH)(e,void 0,void 0,function(){var e,i,s,o;return(0,p.YH)(this,function(a){switch(a.label){case 0:if(a.trys.push([0,3,,4]),e=void 0,!((i=this.config)&&t!==l.METADATA)||(e={config:V(i),version:eM},!r))return[3,2];return[4,G()];case 1:s=a.sent(),e=(0,p.Cl)((0,p.Cl)({},s),e),a.label=2;case 2:return this.recordCancelCallback&&this.recordFunction?this.recordFunction.addCustomEvent(t,(0,p.Cl)((0,p.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 o=a.sent(),this.loggerProvider.debug("Error while adding custom replay capture event: ",o),[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)||t.stop(),null==(n=e.crossOriginIframeC
1oordinator)||n.stop(),e.crossOriginIframeCoordinator=null,null==(r=e.crossOriginParentSignalCleanup)||r.call(e),e.crossOriginParentSignalCleanup=null}catch(t){e.loggerProvider.warn("Error occurred while stopping replay capture: ".concat(t.toString()))}},this.loggerProvider=new q(new S)}return e.prototype.init=function(e,t){return et(this._init(e,t))},e.prototype.setupUrlChangeListener=function(){var e,t,n=this;null==(e=this.urlChangeCleanup)||e.call(this);var r=(0,m.m)();if(null==r?void 0:r.location){var i=!!(null==(t=this.config)?void 0:t.targetingConfig),s=to(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.getCurrentPageForTargeting=function(){var e,t,n=null==(t=null==(e=(0,m.m)())?void 0:e.location)?void 0:t.href;return null!=n?{url:n}:void 0},e.prototype._init=function(e,t){var r,i,s,o,a,l,c,u,d,h,g;return(0,p.sH)(this,void 0,void 0,function(){var f,v,y,b,I,C,w,k,E,P,R,_,T,x,M,L,O,D,H,F,N,A,U,B,W,z,j,Y=this;return(0,p.YH)(this,function(K){switch(K.label){case 0:return null==(r=this.urlChangeCleanup)||r.call(this),this.loggerProvider=new q(t.loggerProvider||new S),Object.prototype.hasOwnProperty.call(t,"logLevel")&&this.loggerProvider.enable(t.logLevel),this.currentPageUrl=J(),this.identifiers=new e8({sessionId:t.sessionId,deviceId:t.deviceId}),f=this,[4,(0,p.sH)(void 0,void 0,void 0,function(){var n;return(0,p.YH)(this,function(r){return n=new ee(e,t),[2,new ek(new eC(e,n.loggerProvider,n.serverZone,t.configServerUrl),n)]})})];case 1:return f.joinedConfigGenerator=K.sent(),[4,this.joinedConfigGenerator.generateJoinedConfig()];case 2:if(y=(v=K.sent()).joinedConfig,b=v.localConfig,I=v.remoteConfig,this.config=y,this.setMetadata(t.sessionId,y,b,I,null==(i=t.version)?void 0:i.version,eM,null==(s=t.version)?void 0:s.type),this.pageLeaveFns=[],t.sessionId&&(null==(o=this.config.interactionConfig)?void 0:o.enabled)&&(C=e7.default({sessionId:t.sessionId,type:"interaction"},this.config),this.pageLeaveFns=[C.send(this.getDeviceId.bind(this)).bind(C)],this.scrollHook=C.hook.bind(C),this.clickHandler=new e3(this.loggerProvider,C)),w=[],"idb"!==(k=this.config.storeType)||(null==(a=(0,m.m)())?void 0:a.indexedDB)||(k="memory",this.loggerProvider.warn("Could not use preferred indexedDB storage, reverting to in memory option.")),this.loggerProvider.log("Using ".concat(k," for event storage.")),R=(0,m.m)(),!(this.config.useWebWorker&&R&&R.Worker))return[3,4];return[4,n.e(4481).then(n.bind(n,54481))];case 3:T=(_=K.sent()).compressionScript,x=_.trackDestinationScript,E=T,P=x,K.label=4;case 4:return K.trys.push([4,6,,7]),[4,eW({config:this.config,type:"replay",storeType:k,trackDestinationWorkerScript:P})];case 5:return M=K.sent(),w.push({name:"replay",manager:M}),[3,7];case 6:return L=K.sent(),this.loggerProvider.warn("Error occurred while creating replay events manager: ".concat(L.toString())),[3,7];case 7:if(!(null==(l=this.config.interactionConfig)?void 0:l.enabled))return[3,11];O=this.config.interactionConfig.batch?e2:e1,K.label=8;case 8:return K.trys.push([8,10,,11]),[4,eW({config:this.config,type:"interaction",minInterval:null!=(c=this.config.interactionConfig.trackEveryNms)?c:3e4,maxInterval:6e4,payloadBatcher:O,storeType:k,trackDestinationWorkerScript:P})];case 9:return D=K.sent(),w.push({name:"interaction",manager:D}),[3,11];case 10:return L=K.sent(),this.loggerProvider.warn("Error occurred while creating interaction events manager: ".concat(L.toString())),[3,11];case 11:if(this.eventsManager=new(ez.bind.apply(ez,(0,p.fX)([void 0],(0,p.zs)(w),!1))),this.eventCompressor&&this.eventCompressor.terminate(),this.eventCompressor=new eR(this.eventsManager,this.config,this.getDeviceId(),E,function(){return Y.sendEvents()}),this.pendingEmitEvents.length>0){H=this.pendingEmitEvents.splice(0);try{for(N=(F=(0,p.Ju)(H)).next();!N.done;N=F.next())U=(A=N.value).event,B=A.sessionId,this.eventCompressor.enqueueEvent(U,B)}catch(e){z={error:e}}finally{try{N&&!N.done&&(j=F.return)&&j.call(F)}finally{if(z)throw z.error}}}return this.pageLeaveFns=(0,p.fX)((0,p.fX)([],(0,p.zs)(this.pageLeaveFns),!1),[function(){if(Y.config&&(null==(e=Y.identifiers)?void 0:e.sessionId)&&M){var e,t=M.getBeaconEvents();if(t.length){var n=Y.getDeviceId();n&&M.trackDestination.sendBeacon({events:t,sessionId:Y.identifiers.sessionId,deviceId:n,apiKey:Y.config.apiKey,serverZone:Y.config.serverZone})}}}],!1),[4,this.initializeNetworkObservers()];case 12:return K.sent(),(null==(u=(0,m.m)())?void 0:u.opener)&&(!function(e,t){if(!0!==e[ea]){e[ea]=!0;var n="https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.3.js.gz",r=null,i=function(t,n){var r,i;"background-capture-complete"===t&&(null==(i=null==(r=e.logger)?void 0:r.debug)||i.call(r,"Backgroun
1d capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",function(){null==(s=null==(t=e.logger)?void 0:t.debug)||s.call(t,"Initializing background capture (external script)");var t,s,o=new URL(n,e.endpoint).toString();e.loadScriptOnce(o).then(function(){var t,n,s;null==(n=null==(t=e.logger)?void 0:t.debug)||n.call(t,"Background capture script loaded (external)"),r=null==(s=null==window?void 0:window.amplitudeBackgroundCapture)?void 0:s.call(window,{messenger:e,onBackgroundCapture:i}),e.notify({action:"background-capture-loaded"})}).catch(function(){var t;null==(t=e.logger)||t.warn("Failed to initialize background capture")})}),e.registerActionHandler("close-background-capture",function(){var e;null==(e=null==r?void 0:r.close)||e.call(r),r=null})}}(W=function(e){var t=(0,m.m)(),n=null==t?void 0:t[es];if("object"==typeof n&&null!==n&&ei in n&&!0===n[ei])return n;var r=new eo(void 0);return t&&(t[es]=r),r}()),W.setup((0,p.Cl)({logger:this.loggerProvider},this.config.serverZone&&{endpoint:er[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 K.sent(),(this.config.targetingConfig||(null!=(g=null==(h=null==(d=this.config.privacyConfig)?void 0:d.urlMaskLevels)?void 0:h.length)?g:0)>0)&&this.setupUrlChangeListener(),[2]}})})},e.prototype.setSessionId=function(e,t){return et(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t,n){var r;return(0,p.sH)(this,void 0,void 0,function(){var i,s,o;return(0,p.YH)(this,function(a){switch(a.label){case 0:if(this.latestUrlChangeTargetingEvaluationId++,this.sessionTargetingMatch=!1,this.lastShouldRecordDecision=void 0,(i=this.identifiers&&this.identifiers.sessionId)&&this.sendEvents(i),s=t||this.getDeviceId(),this.identifiers=new e8({sessionId:e,deviceId:s}),!(this.joinedConfigGenerator&&i))return[3,2];return[4,this.joinedConfigGenerator.generateJoinedConfig()];case 1:o=a.sent().joinedConfig,this.config=o,a.label=2;case 2:if(!(null==(r=this.config)?void 0:r.targetingConfig))return[3,4];return[4,this.evaluateTargetingAndCapture({userProperties:null==n?void 0:n.userProperties,page:this.getCurrentPageForTargeting()},!1,!0)];case 3:return a.sent(),[3,6];case 4:return[4,this.recordEvents()];case 5:a.sent(),a.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 r=this.getShouldRecord(),i={};return r&&((e={})[T]=n.sessionReplayId?n.sessionReplayId:null,i=e,t.debugMode&&(i[L]=JSON.stringify({appHash:el(t.apiKey).toString()}))),this.addCustomRRWebEvent(l.GET_SR_PROPS,{shouldRecord:r,eventProperties:i},10===this.eventCount),10===this.eventCount&&(this.eventCount=0),this.eventCount++,i},e.prototype.sendEvents=function(e){var t,n=e||(null==(t=this.identifiers)?void 0:t.sessionId),r=this.getDeviceId();this.eventsManager&&n&&r&&this.eventsManager.sendCurrentSequenceEvents({sessionId:n,deviceId:r})},e.prototype.initialize=function(e){var t;return void 0===e&&(e=!1),(0,p.sH)(this,void 0,void 0,function(){var n;return(0,p.YH)(this,function(r){return(null==(t=this.identifiers)?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(){if(null==(t=this.config)?void 0:t.instanceName){var e,t,n,r;r=(void 0===(e=this.config.instanceName)&&(e=w),ec.i.getInstance(e)).identityStore.getIdentity().optOut}return void 0!==r?r:null==(n=this.config)?void 0:n.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,r="",i=!1;return this.config.targetingConfig?this.sessionTargetingMatch?(r="Capturing replays for session ".concat(this.identifiers.sessionId," due to matching targeting conditions."),this.loggerProvider.log(r),n=!0,i=!0):(r="Not capturing replays for session ".concat(this.identifiers.sessionId," due to not matching targeting conditions."),this.loggerProvider.log(r),n=!1,i=!1):(e=this.identifiers.sessionId,t=this.config.sampleRate,function(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=(r-55296<<10)+(i-56320)+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+0x9e3779b1+0x85ebca77>>>0,a=t+0x85ebca77>>>0,l=t>>>0,c=t-0x9e3779b1>>>0;s<=i-16;)o=tn(o,tr(r,s)),s+=4,a=tn(a,tr(r,s)),s+=4,l=tn(l,tr(r,s)),s+=4,c=tn(c,tr(r,s)),s+=4;n=tt(o,1)+tt(a,7)+tt(l,12)+tt(c,18)>>>0}else n=t+0x165667b1>>>0;for(n=n+i>>>0;s<=i-4;)n=Math.imul(tt(n=n+Math.imul(tr(r,s),0xc2b2ae3d)>>>0,17),0x27d4eb2f)>>>0,s+=4;for(;s<i;)n=Math.imul(tt(n=n+Math.imul(r[s],0x165667b1)>>>0,11),0x9e3779b1)>>>0,s++;return n^=n>>>15,n=Math.imul(n,0x85ebca77)>>>0,n^=n>>>13,n=Math.imul(n,0xc2b2ae3d)>>>0,(n^=n>>>16)>>>0}(e.toString())%1e6/1e6<t)?(n=!0,i=!0):(r="Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate."),this.loggerProvider.log(r),n=!1,i=!1),this.lastShouldRecordDecision!==n&&this.config.targetingConfig&&(this.addCustomRRWebEvent(l.TARGETING_DECISION,{message:r,sessionId:this.identifiers.sessionId,matched:i,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.privacyConfig)?void 0:t.blockSelector)?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n=null==(e=this.config)?void 0:e.privacyConfig;if("conservative"===(n?z(this.currentPageUrl,n):void 0)||(null==(t=null==n?void 0:n.urlMaskLevels)?void 0:t.some(function(e){return"conservative"===e.maskLevel})))return"*";var r=null==n?void 0:n.urlMaskLevels;if((null==n?void 0:n.defaultMaskLevel)==="conservative"&&r&&r.length>0)return"*";var i=null==n?void 0:n.maskSelector;if(i)return i},e.prototype.getRecordingPlugins=function(e){var t,r,i,s,o,a;return(0,p.sH)(this,void 0,void 0,function(){var l,c,u,d;return(0,p.YH)(this,function(h){switch(h.label){case 0:l=[];try{c=ta({ugcFilterRules:(null==(r=null==(t=this.config)?void 0:t.interactionConfig)?void 0:r.ugcFilterRules)||[],enablePolling:(null==(i=this.config)?void 0:i.enableUrlChangePolling)||!1,pollingInterval:null==(s=this.config)?void 0:s.urlChangePollingInterval,captureDocumentTitle:null==(o=this.config)?void 0:o.captureDocumentTitle}),l.push(c)}catch(e){this.loggerProvider.warn("Failed to create URL tracking plugin:",e)}if(!(null==(a=null==e?void 0:e.console)?void 0:a.enabled))return[3,4];h.label=1;case 1:return h.trys.push([1,3,,4]),[4,n.e(2616).then(n.bind(n,54374))];case 2:return u=h.sent().getRecordConsolePlugin,l.push(u({level:e.console.levels})),[3,4];case 3:return d=h.sent(),this.loggerProvider.warn("Failed to load console plugin:",d),[3,4];case 4:return[2,l.length>0?l:void 0]}})})},e.prototype.getRecordFunction=function(){return(0,p.sH)(this,void 0,void 0,function(){var e,t;return(0,p.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(6863).then(n.bind(n,4348
10))];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,p.sH)(this,void 0,void 0,function(){var t;return(0,p.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:if(null===this.recordEventsPendingShouldLogMetadata)return[3,5];return 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,r,i,s,o,a,c;return void 0===e&&(e=!0),(0,p.sH)(this,void 0,void 0,function(){var u,d,h,g,f,v,y,b,S,I,C,w,k,E,P,R,_,T,x=this;return(0,p.YH)(this,function(M){switch(M.label){case 0:if(u=this.config,d=this.getShouldRecord(),h=null==(t=this.identifiers)?void 0:t.sessionId,!d||!h||!u)return[2];return this.stopRecordingEvents(),[4,this.getRecordFunction()];case 1:if(!(g=M.sent()))return[2];return[4,this.initializeNetworkObservers()];case 2:M.sent(),f=null==(n=u.loggingConfig)?void 0:n.network,v=[H,F,N,eE(u.serverZone,u.trackServerUrl)],null==(r=this.networkObservers)||r.start(function(e){v.some(function(t){return e.url.startsWith(t)})||x.addCustomRRWebEvent(l.FETCH_REQUEST,e)},f),y=u.interactionConfig,b=u.loggingConfig,S=(null==y?void 0:y.enabled)?{mouseInteraction:this.eventsManager&&(null==(i=this.clickHandler)?void 0:i.createHook({eventsManager:this.eventsManager,sessionId:h,deviceIdFn:this.getDeviceId.bind(this),mirror:g.mirror,ugcFilterRules:null!=(s=y.ugcFilterRules)?s:[],performanceOptions:null==(o=u.performanceConfig)?void 0:o.interaction})),scroll:this.scrollHook}:{},I=(null==y?void 0:y.enabled)&&y.ugcFilterRules?y.ugcFilterRules:[],this.loggerProvider.log("Session Replay capture beginning for ".concat(h,".")),M.label=3;case 3:if(M.trys.push([3,5,,6]),C=!!(null==(a=u.crossOriginIframes)?void 0:a.enabled),w=(null==(c=u.crossOriginIframes)?void 0:c.coordinateChildren)!==!1,(k=C&&function(){try{var e=(0,m.m)();if(!e)return!1;return e.parent!==e}catch(e){return!0}}())&&w)return this.crossOriginParentSignalCleanup=function(e){var t=(0,m.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)===U&&("start"===r.action?e.onStart():"stop"===r.action&&e.onStop())}}return t.addEventListener("message",r),function(){return t.removeEventListener("message",r)}}({onStart:function(){return x._recordEventsInChildMode(g,h,u,S)},onStop:function(){try{x.recordCancelCallback&&x.recordCancelCallback(),x.recordCancelCallback=null}catch(e){x.loggerProvider.warn("Error occurred while stopping child iframe replay capture: ".concat(e.toString()))}}}),[2];return E=this,P=g,R=[(0,p.Cl)({},this.buildRRWebRecordOptions(u,S,function(e){if(x.shouldOptOut()){x.loggerProvider.log("Opting session ".concat(h," out of recording due to optOut config.")),x.stopRecordingEvents(),x.sendEvents();return}e.type===eu.Meta&&(e.data.href=$(e.data.href,I)),x.eventCompressor?x.eventCompressor.enqueueEvent(e,h):x.pendingEmitEvents.push({event:e,sessionId:h})},"Error while capturing replay: "))],T={},[4,this.getRecordingPlugins(b)];case 4:return E.recordCancelCallback=P.apply(void 0,[p.Cl.apply(void 0,R.concat([(T.plugins=M.sent(),T.recordCrossOriginIframes=C,T)]))]),C&&!k&&w&&(this.crossOriginIframeCoordinator||(this.crossOriginIframeCoordinator=new tl),this.crossOriginIframeCoordinator.start()),this.addCustomRRWebEvent(l.DEBUG_INFO),e&&this.addCustomRRWebEvent(l.METADATA,this.metadata),[3,6];case 5:return _=M.sent(),this.loggerProvider.warn("Failed to initialize session replay:",_),[3,6];case 6:return[2]}})})},e.prototype.buildRRWebRecordOptions=function(e,t,n,r){var i,s=this,o=e.privacyConfig;return(0,p.Cl)((0,p.Cl)({emit:n,inlineStylesheet:e.shouldInlineStylesheet,hooks:t,maskAllInputs:!0,maskTextClass:O,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),applyBackgroun
1dColorToBlockedElements:e.applyBackgroundColorToBlockedElements,maskInputFn:Y("input",o,function(){return s.currentPageUrl}),maskTextFn:Y("text",o,function(){return s.currentPageUrl}),maskAttributeFn:(i=function(){return s.currentPageUrl},function(e,t,n){var r;return"style"!==e&&(null!=(r=null==o?void 0:o.maskAttributes)?r:[]).includes(e)&&j("text",o,n,null==i?void 0:i())?t.replace(/[^\s]/g,"*"):t}),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){if(e.message.includes("insertRule")&&e.message.includes("CSSStyleSheet")||e._external_)throw e;return s.loggerProvider.warn(r,e.toString()),!0}})},e.prototype._recordEventsInChildMode=function(e,t,n,r){try{this.recordCancelCallback&&this.recordCancelCallback(),this.recordCancelCallback=null,this.recordCancelCallback=e((0,p.Cl)((0,p.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(e){this.loggerProvider.warn("Failed to initialize session replay in child iframe mode:",e)}},e.prototype.getDeviceId=function(){var e;return null==(e=this.identifiers)?void 0:e.deviceId},e.prototype.getSessionId=function(){var e;return null==(e=this.identifiers)?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(n){return[2,null==(t=this.eventsManager)?void 0:t.flush(e)]})})},e.prototype.shutdown=function(){var e,t;null==(e=this.urlChangeCleanup)||e.call(this),null==(t=this.crossOriginParentSignalCleanup)||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())?el(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,p.sH)(this,void 0,void 0,function(){var i,s;return(0,p.YH)(this,function(o){switch(o.label){case 0:if(!((null==(r=null==(t=null==(e=this.config)?void 0:e.loggingConfig)?void 0:t.network)?void 0:r.enabled)&&!this.networkObservers))return[3,4];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.e(2167).then(n.bind(n,52167))];case 2:return i=o.sent().NetworkObservers,this.networkObservers=new i,[3,4];case 3:return s=o.sent(),this.loggerProvider.warn("Failed to import or instantiate NetworkObservers:",s),[3,4];case 4:return[2]}})})},e}(),tu=function(e){return function(){var t=e.config||Z();return{logger:t.loggerProvider,logLevel:t.logLevel}}};let td=function(){var e=new tc;return{init:y(e.init.bind(e),"init",tu(e)),evaluateTargetingAndCapture:y(e.evaluateTargetingAndCapture.bind(e),"evaluateTargetingAndRecord",tu(e)),setSessionId:y(e.setSessionId.bind(e),"setSessionId",tu(e)),getSessionId:y(e.getSessionId.bind(e),"getSessionId",tu(e)),getSessionReplayProperties:y(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",tu(e)),flush:y(e.flush.bind(e),"flush",tu(e)),shutdown:y(e.shutdown.bind(e),"shutdown",tu(e))}}();var th=td.init,tg=td.setSessionId,tf=td.getSessionId,tv=td.getSessionReplayProperties,tp=td.flush,tm=td.shutdown,ty=td.evaluateTargetingAndCapture;!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"}(g||(g={})),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"}(f||(f={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(v||(v={}));var tb=[g.SET,g.SET_ONCE,g.ADD,g.APPEND,g.PREPEND,g.POSTINSERT],tS=function(e){if(e.user_properties){var t={};
1return Object.keys(e.user_properties).forEach(function(n){if(tb.includes(n)){var r=e.user_properties&&e.user_properties[n];t=(0,p.Cl)((0,p.Cl)({},t),r)}}),t}},tI="1.30.3",tC="".concat("[Amplitude]"," Session Replay ID"),tw=function(){function e(t){this.name=e.pluginName,this.type="enrichment",this.config=null,this.sessionReplay={flush:tp,getSessionId:tf,getSessionReplayProperties:tv,init:th,setSessionId:tg,shutdown:tm,evaluateTargetingAndCapture:ty},this.options=(0,p.Cl)({forceSessionTracking:!1},t),this.srInitOptions=this.options}return e.prototype.setup=function(e,t){var n,r,i,s,o,a,l,c;return(0,p.sH)(this,void 0,void 0,function(){var t,u;return(0,p.YH)(this,function(d){switch(d.label){case 0:var h;return d.trys.push([0,2,,3]),null==e||e.loggerProvider.log("Installing @amplitude/plugin-session-replay, version ".concat(tI,".")),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,p.Cl)((0,p.Cl)({},e.defaultTracking),{sessions:!0})),t=(void 0===(h=this.config.instanceName)&&(h="$default_instance"),ec.i.getInstance(h)).identityStore.getIdentity().userProperties,this.srInitOptions={instanceName:this.config.instanceName,deviceId:null!=(n=this.options.deviceId)?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.serverUrl),trackServerUrl:this.options.trackServerUrl,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null==(i=this.options.privacyConfig)?void 0:i.blockSelector,maskSelector:null==(s=this.options.privacyConfig)?void 0:s.maskSelector,unmaskSelector:null==(o=this.options.privacyConfig)?void 0:o.unmaskSelector,defaultMaskLevel:null==(a=this.options.privacyConfig)?void 0:a.defaultMaskLevel},debugMode:this.options.debugMode,shouldInlineStylesheet:this.options.shouldInlineStylesheet,version:{type:"plugin",version:tI},performanceConfig:this.options.performanceConfig,storeType:this.options.storeType,useWebWorker:null!=(l=this.options.useWebWorker)?l:null==(c=this.options.experimental)?void 0:c.useWebWorker,userProperties:t,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},[4,this.sessionReplay.init(e.apiKey,this.srInitOptions).promise];case 1:return d.sent(),[3,3];case 2:return u=d.sent(),null==e||e.loggerProvider.error("Session Replay: Failed to initialize due to ".concat(u.message)),[3,3];case 3:return[2]}})})},e.prototype.onSessionIdChanged=function(e){var t;return(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(n){switch(n.label){case 0:return null==(t=this.config)||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,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(n){switch(n.label){case 0:if(null==(t=this.config)||t.loggerProvider.debug("optOut is changed to ".concat(String(e),", calling ").concat(e?"sessionReplay.shutdown()":"sessionReplay.init()",".")),!e)return[3,1];return this.sessionReplay.shutdown(),[3,4];case 1:if(null==this.config)return[3,3];return[4,this.sessionReplay.init(this.config.apiKey,this.srInitOptions).promise];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,p.sH)(this,void 0,void 0,function(){var s,o,a,l,c;return(0,p.YH)(this,function(u){switch(u.label){case 0:if(u.trys.push([0,9,,10]),!this.options.customSessionId)return[3,4];if(!(s=this.options.customSessionId(e)))return[3,3];if(s===this.sessionReplay.getSessionId())return[3,2];return[4,this.sessionReplay.setSessionId(s).promise];case 1:u.sent(),u.label=2;case 2:o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,p.Cl)((0,p.Cl)({},e.event_properties),o),u.label=3;case 3:return[3,8];case 4:if(!((s=null==(t=this.config)?void 0:t.sessionId)&&s!==this.sessionReplay.getSessionId()))return[3,6];return[4,this.sessionReplay.setSessionId(s).promise];case 5:u.sent(),u.label=6;case 6:if(!(s&&s===e.session_id))return[3,8];return a=void 0,e.event_type===i.IDENTIFY&&(a=tS(e)),l=(0,m.m)(),[4,this.sessionReplay.evaluateTargetingAndCapture({event:e,userProperties:a,page:(null==(n=null==l?void 0:l.location)?void 0:n.href)!=null?{url:l.location.href}:void 0})];case 7:u.sent(),o=this.sessionReplay.getSessionReplayProperties(),e.event_properties=(0,p.Cl)((0,p.Cl)({},e.event_properties),o),u.label=8;case 8:return e.event_type===i.IDENTIFY&&e.event_properties&&delete e.event_properties[tC],[2,Promise.resolve(e)];case 9:return c=u.sent(),null==(r=this.config)||r.loggerProvider.error("Session Replay: Failed to enrich event due to ".concat(c.message)),[2,Promise.resolve(e)];case 10:return[2]}})})},e.prototype.teardown=function(){var e;return(0,p.sH)(this,void 0,void 0,function(){return(0,p.YH)(this,function(t){try{this.sessionReplay.shutdown(),this.config=null}catch(t){null==(e=this.config)||e.loggerProvider.error("Session Replay: teardown failed due to ".concat(t.message))}return[2]})})},e.prototype.getSessionReplayProperties=function(){return this.sessionReplay.getSessionReplayProperties()},e.pluginName="@amplitude/plugin-session-replay-browser",e}(),tk=function(e){return new tw(e)}},20635:(e,t,n)=>{let r,i;n.d(t,{P2:()=>h});let s=(e,t)=>t.some(t=>e instanceof t),o=new WeakMap,a=new WeakMap,l=new WeakMap,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 u(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function u(e){if(e instanceof IDBRequest){let t=new Promise((t,n)=>{let r=()=>{e.removeEventListener("success",i),e.removeEventListener("error",s)},i=()=>{t(u(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",i),e.addEventListener("error",s)});return l.set(t,e),t}if(a.has(e))return a.get(e);let t=function(e){if("function"==typeof e)return(i||(i=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(d(this),t),u(this.request)}:function(...t){return u(e.apply(d(this),t))};return(e instanceof IDBTransaction&&function(e){if(o.has(e))return;let t=new Promise((t,n)=>{let 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),s(e,r||(r=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])))?new Proxy(e,c):e}(e);return t!==e&&(a.set(e,t),l.set(t,e)),t}let d=e=>l.get(e);function h(e,t,{blocked:n,upgrade:r,blocking:i,terminated:s}={}){let o=indexedDB.open(e,t),a=u(o);return r&&o.addEventListener("upgradeneeded",e=>{r(u(o.result),e.oldVersion,e.newVersion,u(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}let g=["get","getKey","getAll","getAllKeys","count"],f=["put","add","delete","clear"],v=new Map;function p(e,t){if(!(e instanceof IDBDatabase&&!(t in e)&&"string"==typeof t))return;if(v.get(t))return v.get(t);let n=t.replace(/FromIndex$/,""),r=t!==n,i=f.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!(i||g.includes(n)))return;let s=async function(e,...t){let s=this.transaction(e,i?"readwrite":"readonly"),o=s.store;
1return r&&(o=o.index(t.shift())),(await Promise.all([o[n](...t),i&&s.done]))[0]};return v.set(t,s),s}c=(e=>({...e,get:(t,n,r)=>p(t,n)||e.get(t,n,r),has:(t,n)=>!!p(t,n)||e.has(t,n)}))(c);let m=["continue","continuePrimaryKey","advance"],y={},b=new WeakMap,S=new WeakMap,I={get(e,t){if(!m.includes(t))return e[t];let n=y[t];return n||(n=y[t]=function(...e){b.set(this,S.get(this)[t](...e))}),n}};async function*C(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;let n=new Proxy(t,I);for(S.set(n,t),l.set(n,d(t));t;)yield n,t=await (b.get(n)||t.continue()),b.delete(n)}function w(e,t){return t===Symbol.asyncIterator&&s(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&s(e,[IDBIndex,IDBObjectStore])}c=(e=>({...e,get:(t,n,r)=>w(t,n)?C:e.get(t,n,r),has:(t,n)=>w(t,n)||e.has(t,n)}))(c)},92509:(e,t,n)=>{n.d(t,{m:()=>r});var r=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:void 0!==n.g?n.g:void 0}}}]);

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.