@amplitude/plugin-session-replay-browser 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- var sessionReplay=function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,i,s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function d(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}!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"}(r||(r={})),function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(o||(o={})),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"}(i||(i={}));var h="".concat("AMP","_unsent"),p="https://api2.amplitude.com/2/httpapi",f=function(e){return{promise:e||Promise.resolve()}},v="Amplitude Logger ",m=function(){function e(){this.logLevel=r.None}return e.prototype.disable=function(){this.logLevel=r.None},e.prototype.enable=function(e){void 0===e&&(e=r.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Verbose||console.log("".concat(v,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Warn||console.warn("".concat(v,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Error||console.error("".concat(v,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Debug||console.log("".concat(v,"[Debug]: ").concat(e.join(" ")))},e}(),g=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:r.Warn,loggerProvider:new m,optOut:!1,serverUrl:p,serverZone:o.US,useBatch:!1}},y=function(){function e(e){var t,n,r,o;this._optOut=!1;var i=g();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:i.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||i.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||i.flushQueueSize,this.instanceName=e.instanceName||i.instanceName,this.loggerProvider=e.loggerProvider||i.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:i.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:i.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||i.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:i.useBatch,this.loggerProvider.enable(this.logLevel);var s=b(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),S=function(e,t){return e===o.EU?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":p},b=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=g().serverZone),void 0===n&&(n=g().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:g().serverZone;return{serverZone:r,serverUrl:S(r,n)}},I=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},w=function(e,t,n,o,i){return void 0===i&&(i=null),function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];var c=n(),l=c.logger,u=c.logLevel;if(u&&u<r.Debug||!u||!l)return e.apply(i,s);var d={type:"invoke public method",name:t,args:s,stacktrace:I(1),time:{start:(new Date).toISOString()},states:{}};o&&d.states&&(d.states.before=o());var h=e.apply(i,s);return h&&h.promise?h.promise.then((function(){o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),l.debug(JSON.stringify(d,null,2))})):(o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),l.debug(JSON.stringify(d,null,2))),h}},C=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,s,a,c,l,u,d,h,p,f,v,m,g,y,S,b,I,w,C;if("object"!=typeof e)return null;var k=e.code||0,M=this.buildStatus(k);switch(M){case i.Success:return{status:M,statusCode:k,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case i.Invalid:return{status:M,statusCode:k,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(s=e.missing_field)&&void 0!==s?s:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(c=e.events_with_missing_fields)&&void 0!==c?c:{},eventsWithInvalidIdLengths:null!==(l=e.events_with_invalid_id_lengths)&&void 0!==l?l:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(d=e.exceeded_daily_quota_devices)&&void 0!==d?d:{},silencedDevices:null!==(h=e.silenced_devices)&&void 0!==h?h:[],silencedEvents:null!==(p=e.silenced_events)&&void 0!==p?p:[],throttledDevices:null!==(f=e.throttled_devices)&&void 0!==f?f:{},throttledEvents:null!==(v=e.throttled_events)&&void 0!==v?v:[]}};case i.PayloadTooLarge:return{status:M,statusCode:k,body:{error:null!==(m=e.error)&&void 0!==m?m:""}};case i.RateLimit:return{status:M,statusCode:k,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(y=e.eps_threshold)&&void 0!==y?y:0,throttledDevices:null!==(S=e.throttled_devices)&&void 0!==S?S:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(I=e.exceeded_daily_quota_devices)&&void 0!==I?I:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case i.Timeout:default:return{status:M,statusCode:k}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?i.Success:429===e?i.RateLimit:413===e?i.PayloadTooLarge:408===e?i.Timeout:e>=400&&e<500?i.Invalid:e>=500?i.Failed:i.Unknown},e}(),k=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:M(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),M=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},E=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),T=function(){return T=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},T.apply(this,arguments)},O=function(e,t){var n=typeof e;if(n!==typeof t)return!1;for(var r=0,o=["string","number","boolean","undefined"];r<o.length;r++){if(o[r]===n)return e===t}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var i=Array.isArray(e),s=Array.isArray(t);if(i!==s)return!1;if(!i||!s){var a=Object.keys(e).sort(),c=Object.keys(t).sort();if(!O(a,c))return!1;var l=!0;return Object.keys(e).forEach((function(n){O(e[n],t[n])||(l=!1)})),l}for(var u=0;u<e.length;u++)if(!O(e[u],t[u]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var R,x=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=T({},this.identity.userProperties),n=T(T({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){for(var t=n.userProperties||{},r=0,o=Object.entries(e);r<o.length;r++){var i=o[r],s=i[0],a=i[1];switch(s){case"$set":for(var c=0,l=Object.entries(a);c<l.length;c++){var u=l[c],d=u[0],h=u[1];t[d]=h}break;case"$unset":for(var p=0,f=Object.keys(a);p<f.length;p++){delete t[d=f[p]]}break;case"$clearAll":t={}}}return n.userProperties=t,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return T({},this.identity)},e.prototype.setIdentity=function(e){var t=T({},this.identity);this.identity=T({},e),O(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,N=function(){function e(){this.identityStore=new x,this.eventBridge=new E,this.applicationContextProvider=new k}return e.getInstance=function(t){return D.analyticsConnectorInstances||(D.analyticsConnectorInstances={}),D.analyticsConnectorInstances[t]||(D.analyticsConnectorInstances[t]=new e),D.analyticsConnectorInstances[t]},e}(),L=function(e){return void 0===e&&(e="$default_instance"),N.getInstance(e)},_=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.send=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=i.sent()).text()];case 2:o=i.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(C),A="[Amplitude]",F="".concat(A," Session Replay ID"),j=o.US,U="".concat(A," Session Replay Debug"),q="amp-mask",B=function(){return{flushMaxRetries:2,logLevel:r.Warn,loggerProvider:new m,transportProvider:new P}},W=function(e){function t(t,n){var r=this,o=B();return(r=e.call(this,s(s({transportProvider:o.transportProvider},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=o.flushMaxRetries?n.flushMaxRetries:o.flushMaxRetries,r.apiKey=t,r.sampleRate=n.sampleRate||0,r.serverZone=n.serverZone||j,r.configEndpointUrl=n.configEndpointUrl,r.shouldInlineStylesheet=n.shouldInlineStylesheet,n.privacyConfig&&(r.privacyConfig=n.privacyConfig),n.debugMode&&(r.debugMode=n.debugMode),r}return n(t,e),t}(y);function z(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function G(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function V(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t,K).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function K(e){var t,n,r;if(function(e){return"styleSheet"in e}(e))try{t=V(e.styleSheet)||function(e){var t=e.cssText;if(t.split('"').length<3)return t;var n=["@import","url(".concat(JSON.stringify(e.href),")")];return""===e.layerName?n.push("layer"):e.layerName&&n.push("layer(".concat(e.layerName,")")),e.supportsText&&n.push("supports(".concat(e.supportsText,")")),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(e){}else if(function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":"))return n=e.cssText,r=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,n.replace(r,"$1\\$2");return t||e.cssText}!function(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"}(R||(R={}));var H=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function $(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,o=e.type,i=e.value,s=e.maskInputFn,a=i||"",c=o&&Z(o);return(n[r.toLowerCase()]||c&&n[c])&&(a=s?s(a,t):"*".repeat(a.length)),a}function Z(e){return e.toLowerCase()}var J="__rrweb_original__";function Y(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Z(t):null}var X,Q,ee=1,te=new RegExp("[^a-z0-9-_:]");function ne(){return ee++}var re=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,oe=/^(?:[a-z+]+:)?\/\//i,ie=/^www\..*/i,se=/^(data:)([^,]*),(.*)/i;function ae(e,t){return(e||"").replace(re,(function(e,n,r,o,i,s){var a,c=r||i||s,l=n||o||"";if(!c)return e;if(oe.test(c)||ie.test(c))return"url(".concat(l).concat(c).concat(l,")");if(se.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var u=t.split("/"),d=c.split("/");u.pop();for(var h=0,p=d;h<p.length;h++){var f=p[h];"."!==f&&(".."===f?u.pop():u.push(f))}return"url(".concat(l).concat(u.join("/")).concat(l,")")}))}var ce=/^[^ \t\n\r\u000c]+/,le=/^[, \t\n\r\u000c]+/;function ue(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function de(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function he(){var e=document.createElement("a");return e.href="",e.href}function pe(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?ue(e,r):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(le),!(n>=t.length);){var i=r(ce);if(","===i.slice(-1))i=ue(e,i.substring(0,i.length-1)),o.push(i);else{var s="";i=ue(e,i);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((i+s).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((i+s).trim());break}"("===c&&(a=!0)}s+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n?ae(r,he()):"object"===t&&"data"===n?ue(e,r):r:ue(e,r):r}function fe(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function ve(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ve(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&ve(e.parentNode,t,n)}function me(e,t,n){try{var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(ve(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}}catch(e){}return!1}function ge(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,i=t.blockSelector,s=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,u=void 0===l?{}:l,d=t.maskTextFn,h=t.maskInputFn,p=t.dataURLOptions,f=void 0===p?{}:p,v=t.inlineImages,m=t.recordCanvas,g=t.keepIframeSrcFn,y=t.newlyAddedElement,S=void 0!==y&&y,b=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:R.Document,childNodes:[],compatMode:e.compatMode}:{type:R.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:R.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,i=t.inlineStylesheet,s=t.maskInputOptions,a=void 0===s?{}:s,c=t.maskInputFn,l=t.dataURLOptions,u=void 0===l?{}:l,d=t.inlineImages,h=t.recordCanvas,p=t.keepIframeSrcFn,f=t.newlyAddedElement,v=void 0!==f&&f,m=t.rootId,g=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,r,o),y=function(e){if(e instanceof HTMLFormElement)return"form";var t=Z(e.tagName);return te.test(t)?"div":t}(e),S={},b=e.attributes.length,I=0;I<b;I++){var w=e.attributes[I];fe(y,w.name,w.value)||(S[w.name]=pe(n,y,Z(w.name),w.value))}if("link"===y&&i){var C=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),k=null;C&&(k=V(C)),k&&(delete S.rel,delete S.href,S._cssText=ae(k,C.href))}if("style"===y&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(k=V(e.sheet))&&(S._cssText=ae(k,he()))}if("input"===y||"textarea"===y||"select"===y){var M=e.value,E=e.checked;if("radio"!==S.type&&"checkbox"!==S.type&&"submit"!==S.type&&"button"!==S.type&&M){var T=Y(e);S.value=$({element:e,type:T,tagName:y,value:M,maskInputOptions:a,maskInputFn:c})}else E&&(S.checked=E)}"option"===y&&(e.selected&&!a.select?S.selected=!0:delete S.selected);if("canvas"===y&&h)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,i=J in o?o[J]:o;if(new Uint32Array(i.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(S.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var O=e.toDataURL(u.type,u.quality),x=document.createElement("canvas");x.width=e.width,x.height=e.height,O!==x.toDataURL(u.type,u.quality)&&(S.rr_dataURL=O)}if("img"===y&&d){X||(X=n.createElement("canvas"),Q=X.getContext("2d"));var D=e,N=D.crossOrigin;D.crossOrigin="anonymous";var L=function(){D.removeEventListener("load",L);try{X.width=D.naturalWidth,X.height=D.naturalHeight,Q.drawImage(D,0,0),S.rr_dataURL=X.toDataURL(u.type,u.quality)}catch(e){console.warn("Cannot inline img src=".concat(D.currentSrc,"! Error: ").concat(e))}N?S.crossOrigin=N:D.removeAttribute("crossorigin")};D.complete&&0!==D.naturalWidth?L():D.addEventListener("load",L)}"audio"!==y&&"video"!==y||(S.rr_mediaState=e.paused?"paused":"played",S.rr_mediaCurrentTime=e.currentTime);v||(e.scrollLeft&&(S.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(S.rr_scrollTop=e.scrollTop));if(g){var _=e.getBoundingClientRect(),P=_.width,A=_.height;S={class:S.class,rr_width:"".concat(P,"px"),rr_height:"".concat(A,"px")}}"iframe"!==y||p(S.src)||(e.contentDocument||(S.rr_src=S.src),delete S.src);return{type:R.Element,tagName:y,attributes:S,childNodes:[],isSVG:de(e)||void 0,needBlock:g,rootId:m}}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:c,maskInputOptions:u,maskInputFn:h,dataURLOptions:f,inlineImages:v,recordCanvas:m,keepIframeSrcFn:g,newlyAddedElement:S,rootId:b});case e.TEXT_NODE:return function(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,i=t.maskTextFn,s=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,l="STYLE"===a||void 0,u="SCRIPT"===a||void 0;if(l&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=V(e.parentNode.sheet))}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=ae(c,he())}u&&(c="SCRIPT_PLACEHOLDER");!l&&!u&&c&&me(e,r,o)&&(c=i?i(c,e.parentElement):c.replace(/[\S]/g,"*"));return{type:R.Text,textContent:c||"",isStyle:l,rootId:s}}(e,{maskTextClass:s,maskTextSelector:a,maskTextFn:d,rootId:b});case e.CDATA_SECTION_NODE:return{type:R.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:R.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function ye(e){return null==e?"":e.toLowerCase()}function Se(e,t){var n,r=t.doc,o=t.mirror,i=t.blockClass,s=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,u=void 0!==l&&l,d=t.inlineStylesheet,h=void 0===d||d,p=t.maskInputOptions,f=void 0===p?{}:p,v=t.maskTextFn,m=t.maskInputFn,g=t.slimDOMOptions,y=t.dataURLOptions,S=void 0===y?{}:y,b=t.inlineImages,I=void 0!==b&&b,w=t.recordCanvas,C=void 0!==w&&w,k=t.onSerialize,M=t.onIframeLoad,E=t.iframeLoadTimeout,T=void 0===E?5e3:E,O=t.onStylesheetLoad,x=t.stylesheetLoadTimeout,D=void 0===x?5e3:x,N=t.keepIframeSrcFn,L=void 0===N?function(){return!1}:N,_=t.newlyAddedElement,P=void 0!==_&&_,A=t.preserveWhiteSpace,F=void 0===A||A,j=ge(e,{doc:r,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,dataURLOptions:S,inlineImages:I,recordCanvas:C,keepIframeSrcFn:L,newlyAddedElement:P});if(!j)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===R.Comment)return!0;if(e.type===R.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(ye(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===ye(e.attributes.name)||"icon"===ye(e.attributes.rel)||"apple-touch-icon"===ye(e.attributes.rel)||"shortcut icon"===ye(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&ye(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(ye(e.attributes.property).match(/^(og|twitter|fb):/)||ye(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===ye(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===ye(e.attributes.name)||"googlebot"===ye(e.attributes.name)||"bingbot"===ye(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===ye(e.attributes.name)||"generator"===ye(e.attributes.name)||"framework"===ye(e.attributes.name)||"publisher"===ye(e.attributes.name)||"progid"===ye(e.attributes.name)||ye(e.attributes.property).match(/^article:/)||ye(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===ye(e.attributes.name)||"yandex-verification"===ye(e.attributes.name)||"csrf-token"===ye(e.attributes.name)||"p:domain_verify"===ye(e.attributes.name)||"verify-v1"===ye(e.attributes.name)||"verification"===ye(e.attributes.name)||"shopify-checkout-api-token"===ye(e.attributes.name)))return!0}}return!1}(j,g)&&(F||j.type!==R.Text||j.isStyle||j.textContent.replace(/^\s+|\s+$/gm,"").length)?ne():-2;var U=Object.assign(j,{id:n});if(o.add(e,U),-2===n)return null;k&&k(e);var q=!u;if(U.type===R.Element){q=q&&!U.needBlock,delete U.needBlock;var B=e.shadowRoot;B&&G(B)&&(U.isShadowHost=!0)}if((U.type===R.Document||U.type===R.Element)&&q){g.headWhitespace&&U.type===R.Element&&"head"===U.tagName&&(F=!1);for(var W={doc:r,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:u,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:k,onIframeLoad:M,iframeLoadTimeout:T,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:L},V=0,K=Array.from(e.childNodes);V<K.length;V++){(Z=Se(K[V],W))&&U.childNodes.push(Z)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,$=Array.from(e.shadowRoot.childNodes);H<$.length;H++){var Z;(Z=Se($[H],W))&&(G(e.shadowRoot)&&(Z.isShadow=!0),U.childNodes.push(Z))}}return e.parentNode&&z(e.parentNode)&&G(e.parentNode)&&(U.isShadow=!0),U.type===R.Element&&"iframe"===U.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,i=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){i||(t(),i=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),i=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&M){var n=Se(t,{doc:t,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:k,onIframeLoad:M,iframeLoadTimeout:T,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:L});n&&M(e,n)}}),T),U.type===R.Element&&"link"===U.tagName&&"stylesheet"===U.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var i=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(i),o=!0,t()}))}}(e,(function(){if(O){var t=Se(e,{doc:r,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:k,onIframeLoad:M,iframeLoadTimeout:T,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:L});t&&O(e,t)}}),D),U}var be=(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))(be||{}),Ie=(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))(Ie||{}),we=(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))(we||{}),Ce=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ce||{}),ke=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ke||{});function Me(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Ee="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Te={map:{},getId:()=>(console.error(Ee),-1),getNode:()=>(console.error(Ee),null),removeNodeFromMap(){console.error(Ee)},has:()=>(console.error(Ee),!1),reset(){console.error(Ee)}};function Oe(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)}),a))}}function Re(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),i&&i.set&&i.set.call(this,e)}}),()=>Re(e,t,i||{},!0)}function xe(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Te=new Proxy(Te,{get:(e,t,n)=>("map"===t&&console.error(Ee),Reflect.get(e,t,n))}));let De,Ne=Date.now;function Le(e){var t,n,r,o,i,s;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(i=null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.parentElement)||void 0===i?void 0:i.scrollTop)||(null===(s=null==a?void 0:a.body)||void 0===s?void 0:s.scrollTop)||0}}function _e(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Pe(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Ae(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function Fe(e,t,n,r){if(!e)return!1;const o=Ae(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(ve(o,t,r))return!0}catch(e){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function je(e,t){return-2===t.getId(e)}function Ue(e,t){if(z(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Ue(e.parentNode,t))}function qe(e){return Boolean(e.changedTouches)}function Be(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function We(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ze(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(Ne=()=>(new Date).getTime());class Ge{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Ve(e){var t,n;let r=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function Ke(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=Ve(n);)n=t;return n}(e);return t.contains(n)}function He(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||Ke(e))}function $e(e){De=e}function Ze(){De=void 0}const Je=e=>{if(!De)return e;return(...t)=>{try{return e(...t)}catch(e){if(De&&!0===De(e))return;throw e}}};function Ye(e){return(...t)=>{try{return e(...t)}catch(e){try{e._external_=!0}catch(e){}throw e}}}class Xe{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Qe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Xe(ne),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Xe(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case be.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:be.IncrementalSnapshot,data:{source:Ie.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case be.Meta:case be.Load:case be.DomContentLoaded:return!1;case be.Plugin:return t;case be.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case be.IncrementalSnapshot:switch(t.data.source){case Ie.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Ie.Drag:case Ie.TouchMove:case Ie.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Ie.ViewportResize:return!1;case Ie.MediaInteraction:case Ie.MouseInteraction:case Ie.Scroll:case Ie.CanvasMutation:case Ie.Input:return this.replaceIds(t.data,e,["id"]),t;case Ie.StyleSheetRule:case Ie.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Ie.Font:return t;case Ie.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Ie.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}patchRootIdOnNode(e,t){e.type===R.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach((e=>{this.patchRootIdOnNode(e,t)}))}}function et(e){return"__ln"in e}class tt{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&et(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&et(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const nt=(e,t)=>`${e}@${t}`;class rt{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new tt,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{if(!o.parentNode||!He(o))return;const i=z(o.parentNode)?this.mirror.getId(Ve(o)):this.mirror.getId(o.parentNode),s=r(o);if(-1===i||-1===s)return n.addNode(o);const a=Se(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Be(e,this.mirror)&&this.iframeManager.addIframe(e),We(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ze(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});a&&(e.push({parentId:i,nextId:s,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)it(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of this.addedSet)at(this.droppedSet,e)||it(this.removes,e,this.mirror)?at(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(i.value.parentNode),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(n.value.parentNode);if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const r=t.parentNode.host;if(-1!==this.mirror.getId(r)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}})).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!je(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Fe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:me(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t,Ae(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,r=e.target.getAttribute(n);if("value"===n){const e=Y(t);r=$({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(Fe(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(t.contentDocument)return;n="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!fe(t.tagName,n)&&(o.attributes[n]=pe(this.doc,Z(t.tagName),Z(n),r),"style"===n)){let n;try{n=document.implementation.createHTMLDocument()}catch(e){n=this.doc}const r=n.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const n=t.style.getPropertyValue(e),i=t.style.getPropertyPriority(e);n!==r.style.getPropertyValue(e)||i!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===i?n:[n,i]:o._unchangedStyles[e]=[n,i]}for(const e of Array.from(r.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}break}case"childList":if(Fe(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=z(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Fe(e.target,this.blockClass,this.blockSelector,!1)||je(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(ot(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Ue(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[nt(n,r)]?ot(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!z(e.target)||!G(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(je(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[nt(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Fe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach((e=>this.genAdds(e))),ze(e)&&e.shadowRoot.childNodes.forEach((t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)})))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function ot(e,t){e.delete(t),t.childNodes.forEach((t=>ot(e,t)))}function it(e,t,n){return 0!==e.length&&st(e,t,n)}function st(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||st(e,r,n)}function at(e,t){return 0!==e.size&&ct(e,t)}function ct(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ct(e,n))}const lt=[];function ut(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function dt(e,t){var n,r;const o=new rt;lt.push(o),o.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const s=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");s&&window[s]&&(i=window[s]);const a=new i(Je(o.processMutations.bind(o)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ht({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];let c=null;return Object.keys(we).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e])).forEach((i=>{let s=Z(i);const l=(t=>i=>{const s=ut(i);if(Fe(s,r,o,!0))return;let a=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":a=Ce.Mouse;break;case"touch":a=Ce.Touch;break;case"pen":a=Ce.Pen}a===Ce.Touch?we[t]===we.MouseDown?l="TouchStart":we[t]===we.MouseUp&&(l="TouchEnd"):Ce.Pen}else qe(i)&&(a=Ce.Touch);null!==a?(c=a,(l.startsWith("Touch")&&a===Ce.Touch||l.startsWith("Mouse")&&a===Ce.Mouse)&&(a=null)):we[t]===we.Click&&(a=c,c=null);const u=qe(i)?i.changedTouches[0]:i;if(!u)return;const d=n.getId(s),{clientX:h,clientY:p}=u;Je(e)(Object.assign({type:we[l],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(i);if(window.PointerEvent)switch(we[i]){case we.MouseDown:case we.MouseUp:s=s.replace("mouse","pointer");break;case we.TouchStart:case we.TouchEnd:return}a.push(Me(s,l,t))})),Je((()=>{a.forEach((e=>e()))}))}function pt({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){const s=Je(Oe(Je((i=>{const s=ut(i);if(!s||Fe(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=Le(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})})),i.scroll||100));return Me("scroll",s,t)}function ft(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const vt=["INPUT","TEXTAREA","SELECT"],mt=new WeakMap;function gt(e){return function(e,t){if(It("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||It("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||It("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||It("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function yt(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function St({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(i=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===i?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(e){}return r}}),Je((()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}))):()=>{}}function bt(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t),e.recordDOM&&(r=dt(e,e.doc));const o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=Oe(Je((t=>{const n=Date.now()-s;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],s=null})),i),l=Je(Oe(Je((e=>{const t=ut(e),{clientX:n,clientY:o}=qe(e)?e.changedTouches[0]:e;s||(s=Ne()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Ne()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Ie.Drag:e instanceof MouseEvent?Ie.MouseMove:Ie.TouchMove)})),o,{trailing:!1})),u=[Me("mousemove",l,n),Me("touchmove",l,n),Me("drag",l,n)];return Je((()=>{u.forEach((e=>e()))}))}(e),i=ht(e),s=pt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Me("resize",Je(Oe(Je((()=>{const t=_e(),o=Pe();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)})),200)),t)}(e,{win:n}),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:u}){function d(e){let n=ut(e);const l=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=n.parentElement),!n||!d||vt.indexOf(d)<0||Fe(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let p=n.value,f=!1;const v=Y(n)||"";"radio"===v||"checkbox"===v?f=n.checked:(a[d.toLowerCase()]||a[v])&&(p=$({element:n,maskInputOptions:a,tagName:d,type:v,value:p,maskInputFn:c})),h(n,Je(ft)({text:p,isChecked:f,userTriggered:l},u));const m=n.name;"radio"===v&&m&&f&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&h(e,Je(ft)({text:e.value,isChecked:!f,userTriggered:!1},u))}))}function h(t,r){const o=mt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){mt.set(t,r);const o=n.getId(t);Je(e)(Object.assign(Object.assign({},r),{id:o}))}}const p=("last"===l.input?["change"]:["input","change"]).map((e=>Me(e,Je(d),t))),f=t.defaultView;if(!f)return()=>{p.forEach((e=>e()))};const v=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value"),m=[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]];return v&&v.set&&p.push(...m.map((e=>Re(e[0],e[1],{set(){Je(d)({target:this,isTrusted:!1})}},!1,f)))),Je((()=>{p.forEach((e=>e()))}))}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=Je((i=>Oe(Je((o=>{const s=ut(o);if(!s||Fe(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:u}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:u})})),o.media||500))),a=[Me("play",s(0),i),Me("pause",s(1),i),Me("seeked",s(2),i),Me("volumechange",s(3),i),Me("ratechange",s(4),i)];return Je((()=>{a.forEach((e=>e()))}))}(e);let u=()=>{},d=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Je(((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=yt(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),Ye((()=>r.apply(o,i)))()}))});const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),Ye((()=>r.apply(o,i)))()}))}),r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)}))})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)}))}));const c={};wt("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(wt("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),wt("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),wt("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach((([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:Je(((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=yt(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...gt(o),a||0]}]}),r.apply(o,i)}))}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...gt(o),s]}]}),r.apply(o,i)}))})})),Je((()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}))}(e,{win:n}),d=St(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Je(((o,s,a)=>{var c;const[l,u,d]=a;if(n.has(l))return i.apply(s,[l,u,d]);const{id:h,styleId:p}=yt(null===(c=s.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(h&&-1!==h||p&&-1!==p)&&e({id:h,styleId:p,set:{property:l,value:u,priority:d},index:gt(s.parentRule)}),o.apply(s,a)}))});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:Je(((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.apply(i,[l]);const{id:u,styleId:d}=yt(null===(c=i.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(u&&-1!==u||d&&-1!==d)&&e({id:u,styleId:d,remove:{property:l},index:gt(i.parentRule)}),o.apply(i,a)}))}),Je((()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s}))}(e,{win:n}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=xe(t.fonts,"add",(function(t){return function(n){return setTimeout(Je((()=>{const t=o.get(n);t&&(e(t),o.delete(n))})),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=i})),r.push(s),Je((()=>{r.forEach((e=>e()))}))}(e)));const f=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=Je((()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const i=e.getRangeAt(t),{startContainer:s,startOffset:c,endContainer:l,endOffset:u}=i;Fe(s,r,o,!0)||Fe(l,r,o,!0)||a.push({start:n.getId(s),startOffset:c,end:n.getId(l),endOffset:u})}i({ranges:a})}));return a(),Me("selectionchange",a)}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return Je((()=>{lt.forEach((e=>e.reset())),null==r||r.disconnect(),o(),i(),s(),a(),c(),l(),u(),d(),h(),p(),f(),v.forEach((e=>e()))}))}function It(e){return void 0!==window[e]}function wt(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Ct(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}for(var kt,Mt,Et,Tt=(kt=function(){!function(){function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),r=0;r<t.length;r++)n[t.charCodeAt(r)]=r;var o=function(e){var n,r=new Uint8Array(e),o=r.length,i="";for(n=0;n<o;n+=3)i+=t[r[n]>>2],i+=t[(3&r[n])<<4|r[n+1]>>4],i+=t[(15&r[n+1])<<2|r[n+2]>>6],i+=t[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i};const i=new Map,s=new Map,a=self;a.onmessage=function(t){return e(this,void 0,void 0,(function*(){if(!("OffscreenCanvas"in globalThis))return a.postMessage({id:t.data.id});{const{id:n,bitmap:r,width:c,height:l,dataURLOptions:u}=t.data,d=function(t,n,r){return e(this,void 0,void 0,(function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(s.has(e))return s.get(e);const i=new OffscreenCanvas(t,n);i.getContext("2d");const a=yield i.convertToBlob(r),c=yield a.arrayBuffer(),l=o(c);return s.set(e,l),l}return""}))}(c,l,u),h=new OffscreenCanvas(c,l);h.getContext("2d").drawImage(r,0,0),r.close();const p=yield h.convertToBlob(u),f=p.type,v=yield p.arrayBuffer(),m=o(v);if(!i.has(n)&&(yield d)===m)return i.set(n,m),a.postMessage({id:n});if(i.get(n)===m)return a.postMessage({id:n});a.postMessage({id:n,type:f,base64:m,width:c,height:l}),i.set(n,m)}}))}}()},Mt=null,function(e){return Et=Et||function(e,t){var n=function(e,t){var n=void 0===t?null:t,r=e.toString().split("\n");r.pop(),r.shift();for(var o=r[0].search(/\S/),i=/(['"])__worker_loader_strict__(['"])/g,s=0,a=r.length;s<a;++s)r[s]=r[s].substring(o).replace(i,"$1use strict$2")+"\n";return n&&r.push("//# sourceMappingURL="+n+"\n"),r}(e,t),r=new Blob(n,{type:"application/javascript"});return URL.createObjectURL(r)}(kt,Mt),new Worker(Et,e)}),Ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rt="undefined"==typeof Uint8Array?[]:new Uint8Array(256),xt=0;xt<Ot.length;xt++)Rt[Ot.charCodeAt(xt)]=xt;const Dt=new Map;const Nt=(e,t,n)=>{if(!e||!Pt(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Dt.get(e);return n||(n=new Map,Dt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Lt(e,t,n){if(e instanceof Array)return e.map((e=>Lt(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Ot[n[t]>>2],o+=Ot[(3&n[t])<<4|n[t+1]>>4],o+=Ot[(15&n[t+1])<<2|n[t+2]>>6],o+=Ot[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Lt(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Lt(e.data,t,n),e.width,e.height]}}if(Pt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Nt(e,t,n)}}return e}const _t=(e,t,n)=>[...e].map((e=>Lt(e,t,n))),Pt=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function At(e,t,n,r){const o=[];try{const i=xe(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...i){if(!Fe(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(i[0]&&"object"==typeof i[0]){const e=i[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...i])}}));o.push(i)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function Ft(e,t,n,r,o,i,s){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=xe(e,i,(function(e){return function(...a){const c=e.apply(this,a);if(Nt(c,s,this),"tagName"in this.canvas&&!Fe(this.canvas,r,o,!0)){const e=_t([...a],s,this),r={type:t,property:i,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=Re(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(o)}return a}class jt{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:s})}initCanvasFPSObserver(e,t,n,r,o){const i=At(t,n,r,!0),s=new Map,a=new Tt;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:ke["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,u=0;const d=e=>{u&&e-u<c||(u=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{Fe(t,n,r,!0)||e.push(t)})),e})().forEach((e=>Ct(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(s.get(n))return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),l=requestAnimationFrame(d)};l=requestAnimationFrame(d),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=At(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=xe(t.CanvasRenderingContext2D.prototype,s,(function(o){return function(...i){return Fe(this.canvas,n,r,!0)||setTimeout((()=>{const n=_t([...i],t,this);e(this.canvas,{type:ke["2D"],property:s,args:n})}),0),o.apply(this,i)}}));o.push(i)}catch(n){const r=Re(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:ke["2D"],property:s,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r,o){const i=[];return i.push(...Ft(t.WebGLRenderingContext.prototype,ke.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&i.push(...Ft(t.WebGL2RenderingContext.prototype,ke.WebGL2,e,n,r,0,t)),()=>{i.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ut{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame((()=>{this.clear(),this.loop&&this.periodicallyClear()}))}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some((e=>e!==t))}add(e,t){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}class qt{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!G(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=dt(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push((()=>n.disconnect())),this.restoreHandlers.push(pt(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(St({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))}),0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(xe(e.prototype,"attachShadow",(function(e){return function(r){const o=e.call(this,r);return this.shadowRoot&&He(this)&&n.addShadowRoot(this.shadowRoot,t),o}})))}reset(){this.restoreHandlers.forEach((e=>{try{e()}catch(e){}})),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}class Bt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new Ge,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,((e,t)=>({rule:K(e),index:t})))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Wt(e){return Object.assign(Object.assign({},e),{timestamp:Ne()})}let zt,Gt,Vt,Kt=!1;const Ht=new H;function $t(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:p,maskInputFn:f,maskTextFn:v,hooks:m,packFn:g,sampling:y={},dataURLOptions:S={},mousemoveWait:b,recordDOM:I=!0,recordCanvas:w=!1,recordCrossOriginIframes:C=!1,recordAfter:k=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:M=!1,collectFonts:E=!1,inlineImages:T=!1,plugins:O,keepIframeSrcFn:R=(()=>!1),ignoreCSSAttributes:x=new Set([]),errorHandler:D}=e;$e(D);const N=!C||window.parent===window;let L=!1;if(!N)try{window.parent.document&&(L=!1)}catch(e){L=!0}if(N&&!t)throw new Error("emit function is required");void 0!==b&&void 0===y.mousemove&&(y.mousemove=b),Ht.reset();const _=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},P=!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===p,headMetaDescKeywords:"all"===p}:p||{};let A;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const j=e=>{for(const t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return g&&!L&&(e=g(e)),e};zt=(e,o)=>{var i;if(!(null===(i=lt[0])||void 0===i?void 0:i.isFrozen())||e.type===be.FullSnapshot||e.type===be.IncrementalSnapshot&&e.data.source===Ie.Mutation||lt.forEach((e=>e.unfreeze())),N)null==t||t(j(e),o);else if(L){const t={type:"rrweb",event:j(e),origin:window.location.origin,isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===be.FullSnapshot)A=e,F=0;else if(e.type===be.IncrementalSnapshot){if(e.data.source===Ie.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-A.timestamp>n;(t||o)&&Gt(!0)}};const U=e=>{zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Mutation},e)}))},q=e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Scroll},e)})),B=e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.CanvasMutation},e)})),W=new Bt({mutationCb:U,adoptedStyleSheetCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.AdoptedStyleSheet},e)}))}),z=new Qe({mirror:Ht,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:C,wrappedEmit:zt});for(const e of O||[])e.getMirror&&e.getMirror({nodeMirror:Ht,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const G=new Ut;Vt=new jt({recordCanvas:w,mutationCb:B,win:window,blockClass:o,blockSelector:i,mirror:Ht,sampling:y.canvas,dataURLOptions:S});const V=new qt({mutationCb:U,scrollCb:q,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:_,dataURLOptions:S,maskTextFn:v,maskInputFn:f,recordCanvas:w,inlineImages:T,sampling:y,slimDOMOptions:P,iframeManager:z,stylesheetManager:W,canvasManager:Vt,keepIframeSrcFn:R,processedNodeManager:G},mirror:Ht});Gt=(e=!1)=>{if(!I)return;zt(Wt({type:be.Meta,data:{href:window.location.href,width:Pe(),height:_e()}}),e),W.reset(),V.init(),lt.forEach((e=>e.lock()));const t=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new H:r,i=n.blockClass,s=void 0===i?"rr-block":i,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,u=void 0===l?"rr-mask":l,d=n.maskTextSelector,h=void 0===d?null:d,p=n.inlineStylesheet,f=void 0===p||p,v=n.inlineImages,m=void 0!==v&&v,g=n.recordCanvas,y=void 0!==g&&g,S=n.maskAllInputs,b=void 0!==S&&S,I=n.maskTextFn,w=n.maskInputFn,C=n.slimDOM,k=void 0!==C&&C,M=n.dataURLOptions,E=n.preserveWhiteSpace,T=n.onSerialize,O=n.onIframeLoad,R=n.iframeLoadTimeout,x=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,N=n.keepIframeSrcFn;return Se(e,{doc:e,mirror:o,blockClass:s,blockSelector:c,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:!0===b?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===b?{password:!0}:b,maskTextFn:I,maskInputFn:w,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:m,recordCanvas:y,preserveWhiteSpace:E,onSerialize:T,onIframeLoad:O,iframeLoadTimeout:R,onStylesheetLoad:x,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===N?function(){return!1}:N,newlyAddedElement:!1})}(document,{mirror:Ht,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:_,maskTextFn:v,maskInputFn:f,slimDOM:P,dataURLOptions:S,recordCanvas:w,inlineImages:T,onSerialize:e=>{Be(e,Ht)&&z.addIframe(e),We(e,Ht)&&W.trackLinkElement(e),ze(e)&&V.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),V.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:R});if(!t)return console.warn("Failed to snapshot the document");zt(Wt({type:be.FullSnapshot,data:{node:t,initialOffset:Le(window)}}),e),lt.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Ht.getId(document))};try{const e=[],t=e=>{var t;return Je(bt)({mutationCb:U,mousemoveCb:(e,t)=>zt(Wt({type:be.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.MouseInteraction},e)})),scrollCb:q,viewportResizeCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.ViewportResize},e)})),inputCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Input},e)})),mediaInteractionCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.MediaInteraction},e)})),styleSheetRuleCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.StyleSheetRule},e)})),styleDeclarationCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.StyleDeclaration},e)})),canvasMutationCb:B,fontCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Font},e)})),selectionCb:e=>{zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Selection},e)}))},blockClass:o,ignoreClass:s,ignoreSelector:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:_,inlineStylesheet:u,sampling:y,recordDOM:I,recordCanvas:w,inlineImages:T,userTriggeredOnInput:M,collectFonts:E,doc:e,maskInputFn:f,maskTextFn:v,keepIframeSrcFn:R,blockSelector:i,slimDOMOptions:P,dataURLOptions:S,mirror:Ht,iframeManager:z,stylesheetManager:W,shadowDomManager:V,processedNodeManager:G,canvasManager:Vt,ignoreCSSAttributes:x,plugins:(null===(t=null==O?void 0:O.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>zt(Wt({type:be.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};z.addLoadListener((n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}}));const n=()=>{Gt(),e.push(t(document)),Kt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(Me("DOMContentLoaded",(()=>{zt(Wt({type:be.DomContentLoaded,data:{}})),"DOMContentLoaded"===k&&n()}))),e.push(Me("load",(()=>{zt(Wt({type:be.Load,data:{}})),"load"===k&&n()}),window))),()=>{e.forEach((e=>e())),G.destroy(),Kt=!1,Ze()}}catch(e){console.warn(e)}}var Zt,Jt;$t.addCustomEvent=(e,t)=>{if(!Kt)throw new Error("please add custom event after start recording");zt(Wt({type:be.Custom,data:{tag:e,payload:t}}))},$t.freezePage=()=>{lt.forEach((e=>e.freeze()))},$t.takeFullSnapshot=e=>{if(!Kt)throw new Error("please take full snapshot after start recording");Gt(e)},$t.mirror=Ht,function(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"}(Zt||(Zt={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(Jt||(Jt={}));var Yt=Uint8Array,Xt=Uint16Array,Qt=Uint32Array,en=new Yt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),tn=new Yt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nn=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rn=function(e,t){for(var n=new Xt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Qt(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},on=rn(en,2),sn=on[0],an=on[1];sn[28]=258,an[258]=28;for(var cn=rn(tn,0)[1],ln=new Xt(32768),un=0;un<32768;++un){var dn=(43690&un)>>>1|(21845&un)<<1;dn=(61680&(dn=(52428&dn)>>>2|(13107&dn)<<2))>>>4|(3855&dn)<<4,ln[un]=((65280&dn)>>>8|(255&dn)<<8)>>>1}var hn=function(e,t,n){for(var r=e.length,o=0,i=new Xt(t);o<r;++o)++i[e[o]-1];var s,a=new Xt(t);for(o=0;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;if(n){s=new Xt(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],u=t-e[o],d=a[e[o]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)s[ln[d]>>>c]=l}else for(s=new Xt(r),o=0;o<r;++o)s[o]=ln[a[e[o]-1]++]>>>15-e[o];return s},pn=new Yt(288);for(un=0;un<144;++un)pn[un]=8;for(un=144;un<256;++un)pn[un]=9;for(un=256;un<280;++un)pn[un]=7;for(un=280;un<288;++un)pn[un]=8;var fn=new Yt(32);for(un=0;un<32;++un)fn[un]=5;var vn=hn(pn,9,0),mn=hn(fn,5,0),gn=function(e){return(e/8>>0)+(7&e&&1)},yn=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Xt?Xt:e instanceof Qt?Qt:Yt)(n-t);return r.set(e.subarray(t,n)),r},Sn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},bn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},In=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return[new Yt(0),0];if(1==o){var s=new Yt(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};u!=o-1;)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=i[0].s;for(r=1;r<o;++r)i[r].s>h&&(h=i[r].s);var p=new Xt(h+1),f=wn(n[u-1],p,0);if(f>t){r=0;var v=0,m=f-t,g=1<<m;for(i.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var y=i[r].s;if(!(p[y]>t))break;v+=g-(1<<f-p[y]),p[y]=t}for(v>>>=m;v>0;){var S=i[r].s;p[S]<t?v-=1<<t-p[S]++-1:++r}for(;r>=0&&v;--r){var b=i[r].s;p[b]==t&&(--p[b],++v)}f=t}return[new Yt(p),f]},wn=function(e,t,n){return-1==e.s?Math.max(wn(e.l,t,n+1),wn(e.r,t,n+1)):t[e.s]=n},Cn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Xt(++t),r=0,o=e[0],i=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(o),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(o);i=1,o=e[a]}return[n.subarray(0,r),t]},kn=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Mn=function(e,t,n){var r=n.length,o=gn(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var i=0;i<r;++i)e[o+i+4]=n[i];return 8*(o+4+r)},En=function(e,t,n,r,o,i,s,a,c,l,u){Sn(t,u++,n),++o[256];for(var d=In(o,15),h=d[0],p=d[1],f=In(i,15),v=f[0],m=f[1],g=Cn(h),y=g[0],S=g[1],b=Cn(v),I=b[0],w=b[1],C=new Xt(19),k=0;k<y.length;++k)C[31&y[k]]++;for(k=0;k<I.length;++k)C[31&I[k]]++;for(var M=In(C,7),E=M[0],T=M[1],O=19;O>4&&!E[nn[O-1]];--O);var R,x,D,N,L=l+5<<3,_=kn(o,pn)+kn(i,fn)+s,P=kn(o,h)+kn(i,v)+s+14+3*O+kn(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(L<=_&&L<=P)return Mn(t,u,e.subarray(c,c+l));if(Sn(t,u,1+(P<_)),u+=2,P<_){R=hn(h,p,0),x=h,D=hn(v,m,0),N=v;var A=hn(E,T,0);Sn(t,u,S-257),Sn(t,u+5,w-1),Sn(t,u+10,O-4),u+=14;for(k=0;k<O;++k)Sn(t,u+3*k,E[nn[k]]);u+=3*O;for(var F=[y,I],j=0;j<2;++j){var U=F[j];for(k=0;k<U.length;++k){var q=31&U[k];Sn(t,u,A[q]),u+=E[q],q>15&&(Sn(t,u,U[k]>>>5&127),u+=U[k]>>>12)}}}else R=vn,x=pn,D=mn,N=fn;for(k=0;k<a;++k)if(r[k]>255){q=r[k]>>>18&31;bn(t,u,R[q+257]),u+=x[q+257],q>7&&(Sn(t,u,r[k]>>>23&31),u+=en[q]);var B=31&r[k];bn(t,u,D[B]),u+=N[B],B>3&&(bn(t,u,r[k]>>>5&8191),u+=tn[B])}else bn(t,u,R[r[k]]),u+=x[r[k]];return bn(t,u,R[256]),u+x[256]},Tn=new Qt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),On=new Yt(0),Rn=function(e,t,n,r,o){return function(e,t,n,r,o,i){var s=e.length,a=new Yt(r+s+5*(1+Math.floor(s/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||s<8)for(var u=0;u<=s;u+=65535){var d=u+65535;d<s?l=Mn(c,l,e.subarray(u,d)):(c[u]=i,l=Mn(c,l,e.subarray(u,s)))}else{for(var h=Tn[t-1],p=h>>>13,f=8191&h,v=(1<<n)-1,m=new Xt(32768),g=new Xt(v+1),y=Math.ceil(n/3),S=2*y,b=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<S)&v},I=new Qt(25e3),w=new Xt(288),C=new Xt(32),k=0,M=0,E=(u=0,0),T=0,O=0;u<s;++u){var R=b(u),x=32767&u,D=g[R];if(m[x]=D,g[R]=x,T<=u){var N=s-u;if((k>7e3||E>24576)&&N>423){l=En(e,c,0,I,w,C,M,E,O,u-O,l),E=k=M=0,O=u;for(var L=0;L<286;++L)w[L]=0;for(L=0;L<30;++L)C[L]=0}var _=2,P=0,A=f,F=x-D&32767;if(N>2&&R==b(u-F))for(var j=Math.min(p,N)-1,U=Math.min(32767,u),q=Math.min(258,N);F<=U&&--A&&x!=D;){if(e[u+_]==e[u+_-F]){for(var B=0;B<q&&e[u+B]==e[u+B-F];++B);if(B>_){if(_=B,P=F,B>j)break;var W=Math.min(F,B-2),z=0;for(L=0;L<W;++L){var G=u-F+L+32768&32767,V=G-m[G]+32768&32767;V>z&&(z=V,D=G)}}}F+=(x=D)-(D=m[x])+32768&32767}if(P){I[E++]=268435456|an[_]<<18|cn[P];var K=31&an[_],H=31&cn[P];M+=en[K]+tn[H],++w[257+K],++C[H],T=u+_,++k}else I[E++]=e[u],++w[e[u]]}}l=En(e,c,i,I,w,C,M,E,O,u-O,l),i||(l=Mn(c,l,On))}return yn(a,0,r+gn(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function xn(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length,s=0;s!=i;){for(var a=Math.min(s+5552,i);s<a;++s)o+=r+=n[s];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=Rn(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Dn=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(xn(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Yt(e.length+(e.length>>>1)),o=0,i=function(e){r[o++]=e},s=0;s<n;++s){if(o+5>r.length){var a=new Yt(o+8+(n-s<<1));a.set(r),r=a}var c=e.charCodeAt(s);c<128||t?i(c):c<2048?(i(192|c>>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++s))>>>18),i(128|c>>>12&63),i(128|c>>>6&63),i(128|63&c)):(i(224|c>>>12),i(128|c>>>6&63),i(128|63&c))}return yn(r,0,o)}(JSON.stringify(t))),!0)};var Nn,Ln;(Ln=Nn||(Nn={}))[Ln.NotStarted=0]="NotStarted",Ln[Ln.Running=1]="Running",Ln[Ln.Stopped=2]="Stopped";const _n=(e,t)=>t.some((t=>e instanceof t));let Pn,An;const Fn=new WeakMap,jn=new WeakMap,Un=new WeakMap;let qn={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Fn.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Gn(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Bn(e){qn=e(qn)}function Wn(e){return(An||(An=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Vn(this),t),Gn(this.request)}:function(...t){return Gn(e.apply(Vn(this),t))}}function zn(e){return"function"==typeof e?Wn(e):(e instanceof IDBTransaction&&function(e){if(Fn.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{t(),r()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));Fn.set(e,t)}(e),_n(e,Pn||(Pn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,qn):e)}function Gn(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{t(Gn(e.result)),r()},i=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",i)}));return Un.set(t,e),t}(e);if(jn.has(e))return jn.get(e);const t=zn(e);return t!==e&&(jn.set(e,t),Un.set(t,e)),t}const Vn=e=>Un.get(e);function Kn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:i}={}){const s=indexedDB.open(e,t),a=Gn(s);return r&&s.addEventListener("upgradeneeded",(e=>{r(Gn(s.result),e.oldVersion,e.newVersion,Gn(s.transaction),e)})),n&&s.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{i&&e.addEventListener("close",(()=>i())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function Hn(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),Gn(n).then((()=>{}))}const $n=["get","getKey","getAll","getAllKeys","count"],Zn=["put","add","delete","clear"],Jn=new Map;function Yn(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Jn.get(t))return Jn.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=Zn.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!$n.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,o?"readwrite":"readonly");let s=i.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),o&&i.done]))[0]};return Jn.set(t,i),i}Bn((e=>({...e,get:(t,n,r)=>Yn(t,n)||e.get(t,n,r),has:(t,n)=>!!Yn(t,n)||e.has(t,n)})));const Xn=["continue","continuePrimaryKey","advance"],Qn={},er=new WeakMap,tr=new WeakMap,nr={get(e,t){if(!Xn.includes(t))return e[t];let n=Qn[t];return n||(n=Qn[t]=function(...e){er.set(this,tr.get(this)[t](...e))}),n}};async function*rr(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,nr);for(tr.set(n,t),Un.set(n,Vn(t));t;)yield n,t=await(er.get(n)||t.continue()),er.delete(n)}function or(e,t){return t===Symbol.asyncIterator&&_n(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&_n(e,[IDBIndex,IDBObjectStore])}Bn((e=>({...e,get:(t,n,r)=>or(t,n)?rr:e.get(t,n,r),has:(t,n)=>or(t,n)||e.has(t,n)})));var ir,sr=function(e,t){return a(void 0,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,Kn(e,1,{upgrade:function(e){t.forEach((function(t){e.objectStoreNames.contains(t)||e.createObjectStore(t)}))}})];case 1:return[2,n.sent()]}}))}))},ar=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.configKeys;return a(void 0,void 0,void 0,(function(){var e,o,i,l,h,p,f,v,m;return c(this,(function(g){switch(g.label){case 0:return e="".concat(n.substring(0,10),"_amp_config"),[4,sr(e,r)];case 1:return o=g.sent(),i="".concat(n.substring(0,10),"_amp_config_meta"),[4,(y=i,a(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,Kn(y,1,{upgrade:function(e){e.objectStoreNames.contains("lastFetchedSessionId")||e.createObjectStore("lastFetchedSessionId")}})];case 1:return[2,e.sent()]}}))})))];case 2:l=g.sent(),g.label=3;case 3:return g.trys.push([3,8,,9]),[4,l.get("lastFetchedSessionId","sessionId")];case 4:return(h=g.sent())&&Date.now()-h>=2592e5?(o.close(),[4,Hn(e)]):[3,7];case 5:return g.sent(),[4,sr(n,r)];case 6:o=g.sent(),g.label=7;case 7:return[3,9];case 8:return p=g.sent(),t.warn("Failed to reset store: ".concat(p)),[3,9];case 9:return f=function(e,n){return a(void 0,void 0,void 0,(function(){var r,i,a,h,p,f;return c(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),n?[4,l.put("lastFetchedSessionId",n,"sessionId")]:[3,2];case 1:v.sent(),v.label=2;case 2:for(h in r=function(t){var n,r;return c(this,(function(i){switch(i.label){case 0:return n=e.configs[t],r=o.transaction(t,"readwrite"),[4,Promise.all(d(d([],u(Object.keys(n).map((function(e){return r.store.put(s({},n[e]),e)}))),!1),[r.done],!1))];case 1:return i.sent(),[2]}}))},i=e.configs,a=[],i)a.push(h);p=0,v.label=3;case 3:return p<a.length?(h=a[p])in i?[5,r(h)]:[3,5]:[3,6];case 4:v.sent(),v.label=5;case 5:return p++,[3,3];case 6:return[3,8];case 7:return f=v.sent(),t.warn("Failed to store remote config: ".concat(f)),[3,8];case 8:return[2]}}))}))},v=function(){return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.get("lastFetchedSessionId","sessionId")];case 1:return[2,n.sent()];case 2:return e=n.sent(),t.warn("Failed to fetch lastFetchedSessionId: ".concat(e)),[3,3];case 3:return[2,void 0]}}))}))},m=function(e,n){return a(void 0,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,o.get(e,n)];case 1:return[2,i.sent()];case 2:return r=i.sent(),t.warn("Failed to fetch remote config: ".concat(r)),[3,3];case 3:return[2,void 0]}}))}))},[2,{storeRemoteConfig:f,getRemoteConfig:m,getLastFetchedSessionId:v}]}var y}))}))},cr="Remote config fetch rejected due to timeout after 5 seconds",lr=function(){function e(e){var t=e.localConfig,n=e.configKeys,r=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.fetchTime=0,this.getRemoteConfig=function(e,t,n){return a(r,void 0,void 0,(function(){var r,o,i,s,a;return c(this,(function(c){switch(c.label){case 0:return r=Date.now(),this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.getRemoteConfig(e,t)]:[3,3];case 1:return o=c.sent(),[4,this.remoteConfigIDBStore.getLastFetchedSessionId()];case 2:if(i=c.sent(),o&&i===n)return this.fetchTime=Date.now()-r,[2,o];c.label=3;case 3:return[4,this.fetchWithTimeout(n)];case 4:return(s=c.sent())&&(a=s.configs&&s.configs[e])?(this.fetchTime=Date.now()-r,[2,a[t]]):(this.fetchTime=Date.now()-r,[2,void 0])}}))}))},this.fetchWithTimeout=function(e){return a(r,void 0,void 0,(function(){var t,n,r;return c(this,(function(o){switch(o.label){case 0:return t=new AbortController,n=setTimeout((function(){return t.abort()}),5e3),[4,this.fetchRemoteConfig(t.signal,e)];case 1:return r=o.sent(),clearTimeout(n),[2,r]}}))}))},this.fetchRemoteConfig=function(e,t){return a(r,void 0,void 0,(function(){var n,r,o,a,l,u;return c(this,(function(c){switch(c.label){case 0:if(t===this.lastFetchedSessionId&&this.attempts>=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:cr})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),c.label=1;case 1:return c.trys.push([1,3,,4]),n=new URLSearchParams({api_key:this.localConfig.apiKey,config_keys:this.configKeys.join(",")}),r={headers:{"Content-Type":"application/json",Accept:"*/*"},method:"GET"},o="".concat(this.getServerUrl(),"?").concat(n.toString()),this.attempts+=1,[4,fetch(o,s(s({},r),{signal:e}))];case 2:if(null===(a=c.sent()))return[2,this.completeRequest({err:"Unexpected error occurred"})];switch((new C).buildStatus(a.status)){case i.Success:return[2,this.parseAndStoreConfig(a,t)];case i.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return l=c.sent(),u=l,e.aborted?[2,this.completeRequest({err:cr})]:[2,this.completeRequest({err:u.message})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return a(r,void 0,void 0,(function(){var n=this;return c(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e,t){return a(r,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return n=r.sent(),this.completeRequest({success:"Remote config successfully fetched"}),this.remoteConfigIDBStore&&this.remoteConfigIDBStore.storeRemoteConfig(n,t),[2,n]}}))}))},this.localConfig=t,this.configKeys=n}return e.prototype.initialize=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return e=this,[4,ar({apiKey:this.localConfig.apiKey,loggerProvider:this.localConfig.loggerProvider,configKeys:this.configKeys})];case 1:return e.remoteConfigIDBStore=t.sent(),[2]}}))}))},e.prototype.getServerUrl=function(){return this.localConfig.serverZone===o.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===o.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),ur=function(e){var t=e.localConfig,n=e.configKeys;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(r){switch(r.label){case 0:return[4,(e=new lr({localConfig:t,configKeys:n})).initialize()];case 1:return r.sent(),[2,e]}}))}))},dr=function(){function e(e,t){this.localConfig=new W(e,t)}return e.prototype.initialize=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return e=this,[4,ur({localConfig:this.localConfig,configKeys:["sessionReplay"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(e){var t,n,r;return a(this,void 0,void 0,(function(){var o,i,a,d,h,p,f,v,m,g,y,S,b,I,w,C,k,M,E,T;return c(this,(function(c){switch(c.label){case 0:(o=s({},this.localConfig)).optOut=this.localConfig.optOut,o.captureEnabled=!0,c.label=1;case 1:return c.trys.push([1,5,,6]),this.remoteConfigFetch?[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)]:[2,o];case 2:return a=c.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return d=c.sent(),h=o,[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_interaction_config",e)];case 4:return h.interactionConfig=c.sent(),(a||d)&&(i={},a&&(i.sr_sampling_config=a),d&&(i.sr_privacy_config=d)),[3,6];case 5:return p=c.sent(),f=p,this.localConfig.loggerProvider.warn(f.message),o.captureEnabled=!0,[3,6];case 6:if(!i)return[2,o];if(v=i.sr_sampling_config,m=i.sr_privacy_config,v&&Object.keys(v).length>0?(Object.prototype.hasOwnProperty.call(v,"capture_enabled")?o.captureEnabled=v.capture_enabled:o.captureEnabled=!1,v.sample_rate&&(o.sampleRate=v.sample_rate)):(o.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),m){g=null!==(t=o.privacyConfig)&&void 0!==t?t:{},y={defaultMaskLevel:null!==(r=null!==(n=m.defaultMaskLevel)&&void 0!==n?n:g.defaultMaskLevel)&&void 0!==r?r:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},S=function(e){var t,n,r,o,i,s,a,c,u,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var h=l(null!==(a=e.blockSelector)&&void 0!==a?a:[]),p=h.next();!p.done;p=h.next()){d[p.value]="block"}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var f=l(null!==(c=e.maskSelector)&&void 0!==c?c:[]),v=f.next();!v.done;v=f.next()){d[v.value]="mask"}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}try{for(var m=l(null!==(u=e.unmaskSelector)&&void 0!==u?u:[]),g=m.next();!g.done;g=m.next()){d[g.value]="unmask"}}catch(e){i={error:e}}finally{try{g&&!g.done&&(s=m.return)&&s.call(m)}finally{if(i)throw i.error}}return d},b=s(s({},S(g)),S(m));try{for(I=l(Object.entries(b)),w=I.next();!w.done;w=I.next())C=u(w.value,2),k=C[0],"mask"===(M=C[1])?y.maskSelector.push(k):"block"===M?y.blockSelector.push(k):"unmask"===M&&y.unmaskSelector.push(k)}catch(e){E={error:e}}finally{try{w&&!w.done&&(T=I.return)&&T.call(I)}finally{if(E)throw E.error}}o.privacyConfig=y}return[2,o]}}))}))},e}(),hr=function(e,t){return a(void 0,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:return[4,(n=new dr(e,t)).initialize()];case 1:return r.sent(),[2,n]}}))}))},pr="Session replay event batch rejected due to exceeded retry count",fr="Failed to store session replay events in IndexedDB";!function(e){e.RECORDING="recording",e.SENT="sent"}(ir||(ir={}));var vr,mr="sessionCurrentSequence",gr="sequencesToSend",yr=function(){var e=_();return new Promise((function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)}}catch(e){n(e)}}))},Sr=function(e){return a(void 0,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return e.length>0?(10,t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}}))}))},br=function(e){var t,n;return e.objectStoreNames.contains(mr)||(n=e.createObjectStore(mr,{keyPath:"sessionId"})),e.objectStoreNames.contains(gr)||(t=e.createObjectStore(gr,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Ir=function(e){return a(void 0,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,Kn(e,1,{upgrade:br})];case 1:return[2,t.sent()]}}))}))},wr=function(){function e(e){var t=e.loggerProvider,n=e.apiKey,r=e.minInterval,o=e.maxInterval,i=this;this.storageKey="",this.maxPersistedEventsSize=1e6,this.timeAtLastSplit=null,this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=i.maxPersistedEventsSize||!!(null!==i.timeAtLastSplit&&i.interval&&Date.now()-i.timeAtLastSplit>i.interval&&e.length)&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i.timeAtLastSplit=Date.now(),!0)},this.getSequencesToSend=function(){return a(i,void 0,void 0,(function(){var e,t;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,null===(t=this.db)||void 0===t?void 0:t.getAll(gr)];case 1:return[2,n.sent()];case 2:return e=n.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},this.storeCurrentSequence=function(e){return a(i,void 0,void 0,(function(){var t,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.db?[4,this.db.get(mr,e)]:[2,void 0];case 1:return(t=o.sent())?[4,this.db.put(gr,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=o.sent(),[4,this.db.put(mr,{sessionId:e,events:[]})];case 3:return o.sent(),[2,s(s({},t),{sessionId:e,sequenceId:n})];case 4:return r=o.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(r)),[3,5];case 5:return[2,void 0]}}))}))},this.addEventToCurrentSequence=function(e,t){return a(i,void 0,void 0,(function(){var n,r,o,i,s,a,l;return c(this,(function(c){switch(c.label){case 0:0===this.interval&&(this.interval=this.minInterval),c.label=1;case 1:return c.trys.push([1,11,,12]),(n=null===(l=this.db)||void 0===l?void 0:l.transaction(mr,"readwrite"))?[4,n.store.get(e)]:[2];case 2:return(r=c.sent())?[3,4]:[4,n.store.put({sessionId:e,events:[t]})];case 3:return c.sent(),[2];case 4:return o=void 0,this.shouldSplitEventsList(r.events,t)?(o=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,6];case 5:return c.sent(),[3,8];case 6:return i=r.events.concat(t),[4,n.store.put({sessionId:e,events:i})];case 7:c.sent(),c.label=8;case 8:return[4,n.done];case 9:return c.sent(),o?[4,this.storeSendingEvents(e,o)]:[2,void 0];case 10:return(s=c.sent())?[2,{events:o,sessionId:e,sequenceId:s}]:[2,void 0];case 11:return a=c.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(a)),[3,12];case 12:return[2,void 0]}}))}))},this.storeSendingEvents=function(e,t){return a(i,void 0,void 0,(function(){var n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(r=this.db)||void 0===r?void 0:r.put(gr,{sessionId:e,events:t})];case 1:return[2,o.sent()];case 2:return n=o.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},this.cleanUpSessionEventsStore=function(e){return a(i,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,null===(n=this.db)||void 0===n?void 0:n.delete(gr,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(t)),[3,3];case 3:return[2]}}))}))},this.transitionFromKeyValStore=function(e){return a(i,void 0,void 0,(function(){var t,n,r,o,i,s,l,u,d=this;return c(this,(function(p){switch(p.label){case 0:return p.trys.push([0,6,,7]),[4,yr()];case 1:if(!(t=p.sent()))return[2];n=function(e,t){return a(d,void 0,void 0,(function(){var n,r,o=this;return c(this,(function(i){switch(i.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach((function(i){var s=parseInt(i,10),l=n[s];if(s===t.currentSequenceId){var u=l.events.map((function(t){return a(o,void 0,void 0,(function(){return c(this,(function(n){return[2,this.addEventToCurrentSequence(e,t)]}))}))}));r.concat(u)}else l.status!==ir.SENT&&r.push(o.storeSendingEvents(e,l.events))})),[4,Sr(r)];case 1:return i.sent(),[2]}}))}))},r="".concat(h,"_").concat(this.apiKey.substring(0,10)),p.label=2;case 2:return p.trys.push([2,4,,5]),o=t.transaction("keyval").objectStore("keyval").getAll(r),i=new Promise((function(t){o.onsuccess=function(r){return a(d,void 0,void 0,(function(){var o,i,s,a=this;return c(this,(function(c){switch(c.label){case 0:return o=r&&r.target.result,(i=o&&o[0])?(s=[],Object.keys(i).forEach((function(t){var r=parseInt(t,10),o=i[r];if(e===r)s.push(n(r,o));else{var c=o.sessionSequences;Object.keys(c).forEach((function(e){var t=parseInt(e,10);c[t].status!==ir.SENT&&s.push(a.storeSendingEvents(r,c[t].events))}))}})),[4,Sr(s)]):[3,2];case 1:c.sent(),c.label=2;case 2:return t(),[2]}}))}))}})),[4,i];case 3:return p.sent(),(s=_())&&s.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return l=p.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(l)),[3,5];case 5:return[3,7];case 6:return u=p.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(u,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}}))}))},this.loggerProvider=t,this.apiKey=n,this.maxInterval=null!=o?o:1e4,this.minInterval=null!=r?r:500,this.interval=0}return e.prototype.initialize=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return n="replay"===e?"":"_".concat(e),r="".concat(this.apiKey.substring(0,10),"_amp_session_replay_events").concat(n),o=this,[4,Ir(r)];case 1:return o.db=i.sent(),this.timeAtLastSplit=Date.now(),[4,this.transitionFromKeyValStore(t)];case 2:return i.sent(),[2]}}))}))},e}(),Cr=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.sessionId,o=e.type,i=e.minInterval,s=e.maxInterval;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(a){switch(a.label){case 0:return[4,(e=new wr({loggerProvider:t,apiKey:n,minInterval:i,maxInterval:s})).initialize(o,r)];case 1:return a.sent(),[2,e]}}))}))},kr="medium";!function(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"}(vr||(vr={}));var Mr=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":case"conservative":return!0;default:return Mr(e,kr,n)}},Er=function(e,t){return function(n,r){return function(e,t,n){var r,o,i;if(void 0===t&&(t={defaultMaskLevel:kr}),n){if(n.closest("."+q))return!0;var s=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some((function(e){return n.closest(e)}));if(s)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some((function(e){return n.closest(e)}));if(a)return!1}return Mr(e,null!==(i=t.defaultMaskLevel)&&void 0!==i?i:kr,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Tr=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),t|=0}return t},Or=function(){function e(e){var t=e.loggerProvider,n=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=t,this.payloadBatcher=n||function(e){return e}}return e.prototype.sendEventsList=function(e){this.addToQueue(s(s({},e),{attempts:0,timeout:0}))},e.prototype.getServerUrl=function(e){return e===o.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===o.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track"},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(pr,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){var t,n,r=this;return c(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),a(this,void 0,void 0,(function(){var n,r,o,i,s,a,l,u,d,h,p,f;return c(this,(function(c){switch(c.label){case 0:if(!(n=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(r=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(v=_(),o=(null==v?void 0:v.location)?v.location.href:"",i="0.2.5",s=e.sampleRate,a=new URLSearchParams({device_id:r,session_id:"".concat(e.sessionId),seq_number:"".concat(e.sequenceId),type:"".concat(e.type)}),0===(l=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];c.label=1;case 1:return c.trys.push([1,3,,4]),u={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(n),"X-Client-Version":i,"X-Client-Url":o,"X-Client-Sample-Rate":"".concat(s)},body:JSON.stringify(l),method:"POST"},d="".concat(this.getServerUrl(e.serverZone),"?").concat(a.toString()),[4,fetch(d,u)];case 2:if(null===(h=c.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(h.status,e);else{p="";try{p=JSON.stringify(h.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(h.status,": ").concat(p)})}return[3,4];case 3:return f=c.sent(),this.completeRequest({context:e,err:f}),[3,4];case 4:return[2]}var v}))}))},e.prototype.handleReponse=function(e,t){switch((new C).buildStatus(e)){case i.Success:this.handleSuccessResponse(t);break;case i.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t;this.completeRequest({context:e,success:(t=e.sessionId,"Session replay event batch tracked successfully for session id ".concat(t))})},e.prototype.handleOtherResponse=function(e){this.addToQueue(s(s({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(t.sequenceId),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}(),Rr=function(e){var t=e.config,n=e.sessionId,r=e.minInterval,o=e.maxInterval,i=e.type,s=e.payloadBatcher;return a(void 0,void 0,void 0,(function(){function e(e){return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){return c(this,(function(t){return[2,l.flush(e)]}))}))}var l,u,d,h,p,f;return c(this,(function(v){switch(v.label){case 0:return l=new Or({loggerProvider:t.loggerProvider,payloadBatcher:s}),[4,Cr({loggerProvider:t.loggerProvider,apiKey:t.apiKey,sessionId:n,minInterval:r,maxInterval:o,type:i})];case 1:return u=v.sent(),d=function(e){var n=e.events,r=e.sessionId,o=e.deviceId,s=e.sequenceId;l.sendEventsList({events:n,sequenceId:s,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:o,sampleRate:t.sampleRate,serverZone:t.serverZone,type:i,onComplete:u.cleanUpSessionEventsStore.bind(u)})},h=function(e){var n=e.sessionId,r=e.deviceId;u.storeCurrentSequence(n).then((function(e){e&&d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})).catch((function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)}))},p=function(e){var t=e.deviceId;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,u.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},f=function(e){var n=e.event,r=e.sessionId,o=e.deviceId;u.addEventToCurrentSequence(r,n.data).then((function(e){return e&&d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:o})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:h,addEvent:f,sendStoredEvents:p,flush:e}]}}))}))},xr=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},Dr=(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))(Dr||{});let Nr,Lr,_r;function Pr(e,t){if(_r=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";const n={root:document.body,idName:e=>!0,className:e=>!0,tagName:e=>!0,attr:(e,t)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};Nr={...n,...t},Lr=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(Nr.root,n);let r=Ar(e,"all",(()=>Ar(e,"two",(()=>Ar(e,"one",(()=>Ar(e,"none")))))));if(r){const t=Yr(Xr(r,e));return t.length>0&&(r=t[0]),jr(r)}throw new Error("Selector was not found.")}function Ar(e,t,n){let r=null,o=[],i=e,s=0;for(;i;){const e=(new Date).getTime()-_r.getTime();if(void 0!==Nr.timeoutMs&&e>Nr.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${e}ms`);let a=$r(Br(i))||$r(...Wr(i))||$r(...zr(i))||$r(Gr(i))||[{name:"*",penalty:3}];const c=Vr(i);if("all"==t)c&&(a=a.concat(a.filter(Hr).map((e=>Kr(e,c)))));else if("two"==t)a=a.slice(0,1),c&&(a=a.concat(a.filter(Hr).map((e=>Kr(e,c)))));else if("one"==t){const[e]=a=a.slice(0,1);c&&Hr(e)&&(a=[Kr(e,c)])}else"none"==t&&(a=[{name:"*",penalty:3}],c&&(a=[Kr(a[0],c)]));for(let e of a)e.level=s;if(o.push(a),o.length>=Nr.seedMinLength&&(r=Fr(o,n),r))break;i=i.parentElement,s++}return r||(r=Fr(o,n)),!r&&n?n():r}function Fr(e,t){const n=Yr(Jr(e));if(n.length>Nr.threshold)return t?t():null;for(let e of n)if(qr(e))return e;return null}function jr(e){let t=e[0],n=t.name;for(let r=1;r<e.length;r++){const o=e[r].level||0;n=t.level===o-1?`${e[r].name} > ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function Ur(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function qr(e){const t=jr(e);switch(Lr.querySelectorAll(t).length){case 0:throw new Error(`Can't select any node with this selector: ${t}`);case 1:return!0;default:return!1}}function Br(e){const t=e.getAttribute("id");return t&&Nr.idName(t)?{name:"#"+CSS.escape(t),penalty:0}:null}function Wr(e){const t=Array.from(e.attributes).filter((e=>Nr.attr(e.name,e.value)));return t.map((e=>({name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5})))}function zr(e){return Array.from(e.classList).filter(Nr.className).map((e=>({name:"."+CSS.escape(e),penalty:1})))}function Gr(e){const t=e.tagName.toLowerCase();return Nr.tagName(t)?{name:t,penalty:2}:null}function Vr(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function Kr(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function Hr(e){return"html"!==e.name&&!e.name.startsWith("#")}function $r(...e){const t=e.filter(Zr);return t.length>0?t:null}function Zr(e){return null!=e}function*Jr(e,t=[]){if(e.length>0)for(let n of e[0])yield*Jr(e.slice(1,e.length),t.concat(n));else yield t}function Yr(e){return[...e].sort(((e,t)=>Ur(e)-Ur(t)))}function*Xr(e,t,n={counter:0,visited:new Map}){if(e.length>2&&e.length>Nr.optimizedMinLength)for(let r=1;r<e.length-1;r++){if(n.counter>Nr.maxNumberOfTries)return;n.counter+=1;const o=[...e];o.splice(r,1);const i=jr(o);if(n.visited.has(i))return;qr(o)&&Qr(o,t)&&(yield o,n.visited.set(i,!0),yield*Xr(o,t,n))}}function Qr(e,t){return Lr.querySelector(jr(e))===t}var eo=function(e){var t=e.version,n=e.events,r=[];n.forEach((function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)}));var o=r.reduce((function(e,t){var n=t.x,r=t.y,o=t.selector,i=t.timestamp,a=i-i%36e5,c="".concat(n,":").concat(r,":").concat(null!=o?o:"",":").concat(a);return e[c]?e[c].count+=1:e[c]=s(s({},t),{timestamp:a,count:1}),e}),{});return{version:t,events:Object.values(o)}},to=function(e){var t=e.eventsManager,n=e.sessionId,r=e.deviceIdFn;return function(e){if(e.type===Dr.Click){var o=_();if(o){var i=o.location,s=o.innerHeight,a=o.innerWidth;if(i){var c,l=e.x,u=e.y,d=$t.mirror.getNode(e.id);d&&(c=Pr(d));var h={x:l,y:u,selector:c,viewportHeight:s,viewportWidth:a,pageUrl:i.href,timestamp:Date.now(),type:"click"},p=r();p&&t.addEvent({sessionId:n,event:{type:"interaction",data:JSON.stringify(h)},deviceId:p})}}}}},no=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 a(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return t=[],this.managers.forEach((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,o=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:o})},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 a(this,void 0,void 0,(function(){var t;return c(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}(),ro=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.blurListener=function(){e.stopRecordingAndSendEvents()},this.focusListener=function(){e.initialize()},this.stopRecordingEvents=function(){try{e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null}catch(n){var t=n;e.loggerProvider.warn("Error occurred while stopping recording: ".concat(t.toString()))}},this.loggerProvider=new m}return e.prototype.init=function(e,t){return f(this._init(e,t))},e.prototype.removeInvalidSelectors=function(){var e,t=this;if(null===(e=this.config)||void 0===e?void 0:e.privacyConfig){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter((function(e){try{n.querySelector(e)}catch(n){return t.loggerProvider.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})),0!==e.length)return e};this.config.privacyConfig.blockSelector=r(this.config.privacyConfig.blockSelector),this.config.privacyConfig.maskSelector=r(this.config.privacyConfig.maskSelector),this.config.privacyConfig.unmaskSelector=r(this.config.privacyConfig.unmaskSelector)}},e.prototype._init=function(e,t){var n,r;return a(this,void 0,void 0,(function(){var o,i,s,a,l,h;return c(this,(function(c){switch(c.label){case 0:return this.loggerProvider=t.loggerProvider||new m,this.identifiers=new xr({sessionId:t.sessionId,deviceId:t.deviceId}),o=this,[4,hr(e,t)];case 1:return o.joinedConfigGenerator=c.sent(),i=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:return i.config=c.sent(),this.loggerProvider.debug(JSON.stringify({name:"session replay joined privacy config",privacyConfig:this.config.privacyConfig},null,2)),this.removeInvalidSelectors(),s=[],[4,Rr({config:this.config,sessionId:this.identifiers.sessionId,type:"replay"})];case 3:return a=c.sent(),s.push({name:"replay",manager:a}),(null===(n=this.config.interactionConfig)||void 0===n?void 0:n.enabled)?[4,Rr({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(r=this.config.interactionConfig.trackEveryNms)&&void 0!==r?r:3e4,maxInterval:6e4,payloadBatcher:eo})]:[3,5];case 4:l=c.sent(),s.push({name:"interaction",manager:l}),c.label=5;case 5:return this.eventsManager=new(no.bind.apply(no,d([void 0],u(s),!1))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),(h=_())&&(h.removeEventListener("blur",this.blurListener),h.removeEventListener("focus",this.focusListener),h.addEventListener("blur",this.blurListener),h.addEventListener("focus",this.focusListener)),h&&h.document&&h.document.hasFocus()&&this.initialize(!0),[2]}}))}))},e.prototype.setSessionId=function(e,t){return f(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return(n=this.identifiers&&this.identifiers.sessionId)&&this.stopRecordingAndSendEvents(n),r=t||this.getDeviceId(),this.identifiers=new xr({sessionId:e,deviceId:r}),this.joinedConfigGenerator&&n?(o=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]):[3,2];case 1:o.config=i.sent(),i.label=2;case 2:return this.recordEvents(),[2]}}))}))},e.prototype.getSessionReplayDebugPropertyValue=function(){var e="";return this.config&&(e=Tr(this.config.apiKey).toString()),JSON.stringify({appHash:e})},e.prototype.getSessionReplayProperties=function(){var e;if(!this.config||!this.identifiers)return this.loggerProvider.error("Session replay init has not been called, cannot get session recording properties."),{};var t=!!this.config.debugMode;if(this.getShouldRecord(t)){var n=((e={})[F]=this.identifiers.sessionReplayId?this.identifiers.sessionReplayId:null,e);return this.config.debugMode&&(n[U]=this.getSessionReplayDebugPropertyValue()),n}return{}},e.prototype.stopRecordingAndSendEvents=function(e){var t;this.stopRecordingEvents();var n=e||(null===(t=this.identifiers)||void 0===t?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;if(void 0===e&&(e=!1),null===(t=this.identifiers)||void 0===t?void 0:t.sessionId){var n=this.getDeviceId();n?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),this.recordEvents()):this.loggerProvider.log("Session is not being recorded due to lack of device id.")}else this.loggerProvider.log("Session is not being recorded due to lack of session id.")},e.prototype.shouldOptOut=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=L(this.config.instanceName).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(e){if(void 0===e&&(e=!1),!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.error("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.")),!1;var t=_();if(!e&&t&&t.document&&!t.document.hasFocus())return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," temporarily not recording due to lack of browser focus.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var n,r,o,i=(n=this.identifiers.sessionId,r=this.config.sampleRate,o=Tr(n.toString()),31*Math.abs(o)%100/100<r);return i||this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate.")),i},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var o=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return o||void 0},e.prototype.recordEvents=function(){var e,t=this,n=this.getShouldRecord(),r=null===(e=this.identifiers)||void 0===e?void 0:e.sessionId;if(n&&r&&this.config){this.stopRecordingEvents();var o=this.config.privacyConfig;this.recordCancelCallback=$t({emit:function(e){var n=_();if(n&&n.document&&!n.document.hasFocus()||!t.getShouldRecord())t.stopRecordingAndSendEvents();else{var o=JSON.stringify(e),i=t.getDeviceId();t.eventsManager&&i&&t.eventsManager.addEvent({event:{type:"replay",data:o},sessionId:r,deviceId:i})}},packFn:Dn,inlineStylesheet:this.config.shouldInlineStylesheet,hooks:{mouseInteraction:this.eventsManager&&to({eventsManager:this.eventsManager,sessionId:r,deviceIdFn:this.getDeviceId.bind(this)})},maskAllInputs:!0,maskTextClass:q,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),maskInputFn:Er("input",o),maskTextFn:Er("text",o),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,errorHandler:function(e){var n=e;if(n.message.includes("insertRule")&&n.message.includes("CSSStyleSheet"))throw n;if(n._external_)throw n;return t.loggerProvider.warn("Error while recording: ",n.toString()),!0}})}},e.prototype.getDeviceId=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=L(this.config.instanceName).identityStore.getIdentity().deviceId);return n||(null===(t=this.identifiers)||void 0===t?void 0:t.deviceId)},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){return c(this,(function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]}))}))},e.prototype.shutdown=function(){var e=_();e&&(e.removeEventListener("blur",this.blurListener),e.removeEventListener("focus",this.focusListener)),this.stopRecordingAndSendEvents()},e}(),oo=function(e){return function(){var t=e.config||B();return{logger:t.loggerProvider,logLevel:t.logLevel}}},io=function(){var e=new ro;return{init:w(e.init.bind(e),"init",oo(e)),setSessionId:w(e.setSessionId.bind(e),"setSessionId",oo(e)),getSessionId:w(e.getSessionId.bind(e),"getSessionId",oo(e)),getSessionReplayProperties:w(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",oo(e)),flush:w(e.flush.bind(e),"flush",oo(e)),shutdown:w(e.shutdown.bind(e),"shutdown",oo(e))}}(),so=io.init,ao=io.setSessionId,co=io.getSessionId,lo=io.getSessionReplayProperties,uo=io.flush,ho=io.shutdown,po="@amplitude/plugin-session-replay-enrichment-browser",fo=function(){function e(){this.name=po,this.type="enrichment"}return e.prototype.setup=function(e,t){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.config=e,[2]}))}))},e.prototype.execute=function(e){return a(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return this.config.sessionId&&this.config.sessionId!==co()?[4,ao(this.config.sessionId).promise]:[3,2];case 1:n.sent(),n.label=2;case 2:return this.config.sessionId&&this.config.sessionId===e.session_id&&(t=lo(),e.event_properties=s(s({},e.event_properties),t)),[2,Promise.resolve(e)]}}))}))},e}(),vo=function(){function e(e){this.name="@amplitude/plugin-session-replay-browser",this.type="destination",this.options=s({},e),!1!==this.options.forceSessionTracking&&(this.options.forceSessionTracking=!0)}return e.prototype.setup=function(e,t){var n,r,o,i;return a(this,void 0,void 0,(function(){return c(this,(function(a){switch(a.label){case 0:return t?(e.loggerProvider.log("Installing @amplitude/plugin-session-replay."),this.clientRemove=t.remove.bind(t),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=s(s({},e.defaultTracking),{sessions:!0})),[4,so(e.apiKey,{instanceName:this.config.instanceName,deviceId:this.config.deviceId,optOut:this.config.optOut,sessionId:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(n=this.options.privacyConfig)||void 0===n?void 0:n.blockSelector,maskSelector:null===(r=this.options.privacyConfig)||void 0===r?void 0:r.maskSelector,unmaskSelector:null===(o=this.options.privacyConfig)||void 0===o?void 0:o.unmaskSelector,defaultMaskLevel:null===(i=this.options.privacyConfig)||void 0===i?void 0:i.defaultMaskLevel},debugMode:this.options.debugMode,configEndpointUrl:this.options.configEndpointUrl,shouldInlineStylesheet:this.options.shouldInlineStylesheet}).promise]):(e.loggerProvider.error("SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK."),[2]);case 1:return a.sent(),[4,t.add(new fo).promise];case 2:return a.sent(),[2]}}))}))},e.prototype.execute=function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){return[2,Promise.resolve({event:e,code:200,message:"success"})]}))}))},e.prototype.flush=function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,uo(!1)];case 1:return e.sent(),[2]}}))}))},e.prototype.teardown=function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.clientRemove(po).promise];case 1:return e.sent(),ho(),this.config=null,this.clientRemove=null,[2]}}))}))},e.prototype.getSessionReplayProperties=function(){return lo()},e}(),mo=function(e){return new vo(e)};return e.plugin=mo,e.sessionReplayPlugin=mo,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
1
+ var sessionReplay=function(e){"use strict";var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},t(e,n)};function n(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r,o,i,s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},s.apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,r=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){s.label=a[1];break}if(6===a[0]&&s.label<o[1]){s.label=o[1],o=a;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(a);break}o[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function l(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,i=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=i.next()).done;)s.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return s}function d(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}!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"}(r||(r={})),function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(o||(o={})),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"}(i||(i={}));var h="".concat("AMP","_unsent"),p="https://api2.amplitude.com/2/httpapi",f=function(e){return{promise:e||Promise.resolve()}},v="Amplitude Logger ",m=function(){function e(){this.logLevel=r.None}return e.prototype.disable=function(){this.logLevel=r.None},e.prototype.enable=function(e){void 0===e&&(e=r.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Verbose||console.log("".concat(v,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Warn||console.warn("".concat(v,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Error||console.error("".concat(v,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<r.Debug||console.log("".concat(v,"[Debug]: ").concat(e.join(" ")))},e}(),g=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:r.Warn,loggerProvider:new m,optOut:!1,serverUrl:p,serverZone:o.US,useBatch:!1}},y=function(){function e(e){var t,n,r,o;this._optOut=!1;var i=g();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:i.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||i.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||i.flushQueueSize,this.instanceName=e.instanceName||i.instanceName,this.loggerProvider=e.loggerProvider||i.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:i.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:i.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||i.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:i.useBatch,this.loggerProvider.enable(this.logLevel);var s=b(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),S=function(e,t){return e===o.EU?t?"https://api.eu.amplitude.com/batch":"https://api.eu.amplitude.com/2/httpapi":t?"https://api2.amplitude.com/batch":p},b=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=g().serverZone),void 0===n&&(n=g().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:g().serverZone;return{serverZone:r,serverUrl:S(r,n)}},I=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},w=function(e,t,n,o,i){return void 0===i&&(i=null),function(){for(var s=[],a=0;a<arguments.length;a++)s[a]=arguments[a];var c=n(),l=c.logger,u=c.logLevel;if(u&&u<r.Debug||!u||!l)return e.apply(i,s);var d={type:"invoke public method",name:t,args:s,stacktrace:I(1),time:{start:(new Date).toISOString()},states:{}};o&&d.states&&(d.states.before=o());var h=e.apply(i,s);return h&&h.promise?h.promise.then((function(){o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),l.debug(JSON.stringify(d,null,2))})):(o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),l.debug(JSON.stringify(d,null,2))),h}},C=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,s,a,c,l,u,d,h,p,f,v,m,g,y,S,b,I,w,C;if("object"!=typeof e)return null;var k=e.code||0,M=this.buildStatus(k);switch(M){case i.Success:return{status:M,statusCode:k,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case i.Invalid:return{status:M,statusCode:k,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(s=e.missing_field)&&void 0!==s?s:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(c=e.events_with_missing_fields)&&void 0!==c?c:{},eventsWithInvalidIdLengths:null!==(l=e.events_with_invalid_id_lengths)&&void 0!==l?l:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(d=e.exceeded_daily_quota_devices)&&void 0!==d?d:{},silencedDevices:null!==(h=e.silenced_devices)&&void 0!==h?h:[],silencedEvents:null!==(p=e.silenced_events)&&void 0!==p?p:[],throttledDevices:null!==(f=e.throttled_devices)&&void 0!==f?f:{},throttledEvents:null!==(v=e.throttled_events)&&void 0!==v?v:[]}};case i.PayloadTooLarge:return{status:M,statusCode:k,body:{error:null!==(m=e.error)&&void 0!==m?m:""}};case i.RateLimit:return{status:M,statusCode:k,body:{error:null!==(g=e.error)&&void 0!==g?g:"",epsThreshold:null!==(y=e.eps_threshold)&&void 0!==y?y:0,throttledDevices:null!==(S=e.throttled_devices)&&void 0!==S?S:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(I=e.exceeded_daily_quota_devices)&&void 0!==I?I:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(C=e.throttled_events)&&void 0!==C?C:[]}};case i.Timeout:default:return{status:M,statusCode:k}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?i.Success:429===e?i.RateLimit:413===e?i.PayloadTooLarge:408===e?i.Timeout:e>=400&&e<500?i.Invalid:e>=500?i.Failed:i.Unknown},e}(),k=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:M(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),M=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},E=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),T=function(){return T=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},T.apply(this,arguments)},O=function(e,t){var n=typeof e;if(n!==typeof t)return!1;for(var r=0,o=["string","number","boolean","undefined"];r<o.length;r++){if(o[r]===n)return e===t}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var i=Array.isArray(e),s=Array.isArray(t);if(i!==s)return!1;if(!i||!s){var a=Object.keys(e).sort(),c=Object.keys(t).sort();if(!O(a,c))return!1;var l=!0;return Object.keys(e).forEach((function(n){O(e[n],t[n])||(l=!1)})),l}for(var u=0;u<e.length;u++)if(!O(e[u],t[u]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var R,x=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=T({},this.identity.userProperties),n=T(T({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){for(var t=n.userProperties||{},r=0,o=Object.entries(e);r<o.length;r++){var i=o[r],s=i[0],a=i[1];switch(s){case"$set":for(var c=0,l=Object.entries(a);c<l.length;c++){var u=l[c],d=u[0],h=u[1];t[d]=h}break;case"$unset":for(var p=0,f=Object.keys(a);p<f.length;p++){delete t[d=f[p]]}break;case"$clearAll":t={}}}return n.userProperties=t,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return T({},this.identity)},e.prototype.setIdentity=function(e){var t=T({},this.identity);this.identity=T({},e),O(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,N=function(){function e(){this.identityStore=new x,this.eventBridge=new E,this.applicationContextProvider=new k}return e.getInstance=function(t){return D.analyticsConnectorInstances||(D.analyticsConnectorInstances={}),D.analyticsConnectorInstances[t]||(D.analyticsConnectorInstances[t]=new e),D.analyticsConnectorInstances[t]},e}(),L=function(e){return void 0===e&&(e="$default_instance"),N.getInstance(e)},_=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},P=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.send=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return n={headers:{"Content-Type":"application/json",Accept:"*/*"},body:JSON.stringify(t),method:"POST"},[4,fetch(e,n)];case 1:return[4,(r=i.sent()).text()];case 2:o=i.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(C),A="[Amplitude]",F="".concat(A," Session Replay ID"),j=o.US,U="".concat(A," Session Replay Debug"),q="amp-mask",B=function(){return{flushMaxRetries:2,logLevel:r.Warn,loggerProvider:new m,transportProvider:new P}},W=function(e){function t(t,n){var r=this,o=B();return(r=e.call(this,s(s({transportProvider:o.transportProvider},n),{apiKey:t}))||this).flushMaxRetries=void 0!==n.flushMaxRetries&&n.flushMaxRetries<=o.flushMaxRetries?n.flushMaxRetries:o.flushMaxRetries,r.apiKey=t,r.sampleRate=n.sampleRate||0,r.serverZone=n.serverZone||j,r.configEndpointUrl=n.configEndpointUrl,r.shouldInlineStylesheet=n.shouldInlineStylesheet,n.privacyConfig&&(r.privacyConfig=n.privacyConfig),n.debugMode&&(r.debugMode=n.debugMode),r}return n(t,e),t}(y);function z(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function G(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function V(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t,K).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function K(e){var t,n,r;if(function(e){return"styleSheet"in e}(e))try{t=V(e.styleSheet)||function(e){var t=e.cssText;if(t.split('"').length<3)return t;var n=["@import","url(".concat(JSON.stringify(e.href),")")];return""===e.layerName?n.push("layer"):e.layerName&&n.push("layer(".concat(e.layerName,")")),e.supportsText&&n.push("supports(".concat(e.supportsText,")")),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}(e)}catch(e){}else if(function(e){return"selectorText"in e}(e)&&e.selectorText.includes(":"))return n=e.cssText,r=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm,n.replace(r,"$1\\$2");return t||e.cssText}!function(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"}(R||(R={}));var H=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach((function(e){return t.removeNodeFromMap(e)}))},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){var n=t.id;this.idNodeMap.set(n,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function $(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,o=e.type,i=e.value,s=e.maskInputFn,a=i||"",c=o&&Z(o);return(n[r.toLowerCase()]||c&&n[c])&&(a=s?s(a,t):"*".repeat(a.length)),a}function Z(e){return e.toLowerCase()}var J="__rrweb_original__";function Y(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Z(t):null}var X,Q,ee=1,te=new RegExp("[^a-z0-9-_:]");function ne(){return ee++}var re=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,oe=/^(?:[a-z+]+:)?\/\//i,ie=/^www\..*/i,se=/^(data:)([^,]*),(.*)/i;function ae(e,t){return(e||"").replace(re,(function(e,n,r,o,i,s){var a,c=r||i||s,l=n||o||"";if(!c)return e;if(oe.test(c)||ie.test(c))return"url(".concat(l).concat(c).concat(l,")");if(se.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var u=t.split("/"),d=c.split("/");u.pop();for(var h=0,p=d;h<p.length;h++){var f=p[h];"."!==f&&(".."===f?u.pop():u.push(f))}return"url(".concat(l).concat(u.join("/")).concat(l,")")}))}var ce=/^[^ \t\n\r\u000c]+/,le=/^[, \t\n\r\u000c]+/;function ue(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function de(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function he(){var e=document.createElement("a");return e.href="",e.href}function pe(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?ue(e,r):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,o=e.exec(t.substring(n));return o?(r=o[0],n+=r.length,r):""}for(var o=[];r(le),!(n>=t.length);){var i=r(ce);if(","===i.slice(-1))i=ue(e,i.substring(0,i.length-1)),o.push(i);else{var s="";i=ue(e,i);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((i+s).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((i+s).trim());break}"("===c&&(a=!0)}s+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n?ae(r,he()):"object"===t&&"data"===n?ue(e,r):r:ue(e,r):r}function fe(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function ve(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ve(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&ve(e.parentNode,t,n)}function me(e,t,n){try{var r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(r.closest(".".concat(t)))return!0}else if(ve(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}}catch(e){}return!1}function ge(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,i=t.blockSelector,s=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,l=t.maskInputOptions,u=void 0===l?{}:l,d=t.maskTextFn,h=t.maskInputFn,p=t.dataURLOptions,f=void 0===p?{}:p,v=t.inlineImages,m=t.recordCanvas,g=t.keepIframeSrcFn,y=t.newlyAddedElement,S=void 0!==y&&y,b=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:R.Document,childNodes:[],compatMode:e.compatMode}:{type:R.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:R.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:b};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.blockClass,o=t.blockSelector,i=t.inlineStylesheet,s=t.maskInputOptions,a=void 0===s?{}:s,c=t.maskInputFn,l=t.dataURLOptions,u=void 0===l?{}:l,d=t.inlineImages,h=t.recordCanvas,p=t.keepIframeSrcFn,f=t.newlyAddedElement,v=void 0!==f&&f,m=t.rootId,g=function(e,t,n){try{if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}if(n)return e.matches(n)}catch(e){}return!1}(e,r,o),y=function(e){if(e instanceof HTMLFormElement)return"form";var t=Z(e.tagName);return te.test(t)?"div":t}(e),S={},b=e.attributes.length,I=0;I<b;I++){var w=e.attributes[I];fe(y,w.name,w.value)||(S[w.name]=pe(n,y,Z(w.name),w.value))}if("link"===y&&i){var C=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),k=null;C&&(k=V(C)),k&&(delete S.rel,delete S.href,S._cssText=ae(k,C.href))}if("style"===y&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(k=V(e.sheet))&&(S._cssText=ae(k,he()))}if("input"===y||"textarea"===y||"select"===y){var M=e.value,E=e.checked;if("radio"!==S.type&&"checkbox"!==S.type&&"submit"!==S.type&&"button"!==S.type&&M){var T=Y(e);S.value=$({element:e,type:T,tagName:y,value:M,maskInputOptions:a,maskInputFn:c})}else E&&(S.checked=E)}"option"===y&&(e.selected&&!a.select?S.selected=!0:delete S.selected);if("canvas"===y&&h)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var o=t.getImageData,i=J in o?o[J]:o;if(new Uint32Array(i.call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(S.rr_dataURL=e.toDataURL(u.type,u.quality));else if(!("__context"in e)){var O=e.toDataURL(u.type,u.quality),x=document.createElement("canvas");x.width=e.width,x.height=e.height,O!==x.toDataURL(u.type,u.quality)&&(S.rr_dataURL=O)}if("img"===y&&d){X||(X=n.createElement("canvas"),Q=X.getContext("2d"));var D=e,N=D.crossOrigin;D.crossOrigin="anonymous";var L=function(){D.removeEventListener("load",L);try{X.width=D.naturalWidth,X.height=D.naturalHeight,Q.drawImage(D,0,0),S.rr_dataURL=X.toDataURL(u.type,u.quality)}catch(e){console.warn("Cannot inline img src=".concat(D.currentSrc,"! Error: ").concat(e))}N?S.crossOrigin=N:D.removeAttribute("crossorigin")};D.complete&&0!==D.naturalWidth?L():D.addEventListener("load",L)}"audio"!==y&&"video"!==y||(S.rr_mediaState=e.paused?"paused":"played",S.rr_mediaCurrentTime=e.currentTime);v||(e.scrollLeft&&(S.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(S.rr_scrollTop=e.scrollTop));if(g){var _=e.getBoundingClientRect(),P=_.width,A=_.height;S={class:S.class,rr_width:"".concat(P,"px"),rr_height:"".concat(A,"px")}}"iframe"!==y||p(S.src)||(e.contentDocument||(S.rr_src=S.src),delete S.src);return{type:R.Element,tagName:y,attributes:S,childNodes:[],isSVG:de(e)||void 0,needBlock:g,rootId:m}}(e,{doc:n,blockClass:o,blockSelector:i,inlineStylesheet:c,maskInputOptions:u,maskInputFn:h,dataURLOptions:f,inlineImages:v,recordCanvas:m,keepIframeSrcFn:g,newlyAddedElement:S,rootId:b});case e.TEXT_NODE:return function(e,t){var n,r=t.maskTextClass,o=t.maskTextSelector,i=t.maskTextFn,s=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,l="STYLE"===a||void 0,u="SCRIPT"===a||void 0;if(l&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=V(e.parentNode.sheet))}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=ae(c,he())}u&&(c="SCRIPT_PLACEHOLDER");!l&&!u&&c&&me(e,r,o)&&(c=i?i(c,e.parentElement):c.replace(/[\S]/g,"*"));return{type:R.Text,textContent:c||"",isStyle:l,rootId:s}}(e,{maskTextClass:s,maskTextSelector:a,maskTextFn:d,rootId:b});case e.CDATA_SECTION_NODE:return{type:R.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:R.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function ye(e){return null==e?"":e.toLowerCase()}function Se(e,t){var n,r=t.doc,o=t.mirror,i=t.blockClass,s=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,u=void 0!==l&&l,d=t.inlineStylesheet,h=void 0===d||d,p=t.maskInputOptions,f=void 0===p?{}:p,v=t.maskTextFn,m=t.maskInputFn,g=t.slimDOMOptions,y=t.dataURLOptions,S=void 0===y?{}:y,b=t.inlineImages,I=void 0!==b&&b,w=t.recordCanvas,C=void 0!==w&&w,k=t.onSerialize,M=t.onIframeLoad,E=t.iframeLoadTimeout,T=void 0===E?5e3:E,O=t.onStylesheetLoad,x=t.stylesheetLoadTimeout,D=void 0===x?5e3:x,N=t.keepIframeSrcFn,L=void 0===N?function(){return!1}:N,_=t.newlyAddedElement,P=void 0!==_&&_,A=t.preserveWhiteSpace,F=void 0===A||A,j=ge(e,{doc:r,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,dataURLOptions:S,inlineImages:I,recordCanvas:C,keepIframeSrcFn:L,newlyAddedElement:P});if(!j)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.getId(e):!function(e,t){if(t.comment&&e.type===R.Comment)return!0;if(e.type===R.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(ye(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===ye(e.attributes.name)||"icon"===ye(e.attributes.rel)||"apple-touch-icon"===ye(e.attributes.rel)||"shortcut icon"===ye(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&ye(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(ye(e.attributes.property).match(/^(og|twitter|fb):/)||ye(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===ye(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===ye(e.attributes.name)||"googlebot"===ye(e.attributes.name)||"bingbot"===ye(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===ye(e.attributes.name)||"generator"===ye(e.attributes.name)||"framework"===ye(e.attributes.name)||"publisher"===ye(e.attributes.name)||"progid"===ye(e.attributes.name)||ye(e.attributes.property).match(/^article:/)||ye(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===ye(e.attributes.name)||"yandex-verification"===ye(e.attributes.name)||"csrf-token"===ye(e.attributes.name)||"p:domain_verify"===ye(e.attributes.name)||"verify-v1"===ye(e.attributes.name)||"verification"===ye(e.attributes.name)||"shopify-checkout-api-token"===ye(e.attributes.name)))return!0}}return!1}(j,g)&&(F||j.type!==R.Text||j.isStyle||j.textContent.replace(/^\s+|\s+$/gm,"").length)?ne():-2;var U=Object.assign(j,{id:n});if(o.add(e,U),-2===n)return null;k&&k(e);var q=!u;if(U.type===R.Element){q=q&&!U.needBlock,delete U.needBlock;var B=e.shadowRoot;B&&G(B)&&(U.isShadowHost=!0)}if((U.type===R.Document||U.type===R.Element)&&q){g.headWhitespace&&U.type===R.Element&&"head"===U.tagName&&(F=!1);for(var W={doc:r,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:u,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:k,onIframeLoad:M,iframeLoadTimeout:T,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:L},V=0,K=Array.from(e.childNodes);V<K.length;V++){(Z=Se(K[V],W))&&U.childNodes.push(Z)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,$=Array.from(e.shadowRoot.childNodes);H<$.length;H++){var Z;(Z=Se($[H],W))&&(G(e.shadowRoot)&&(Z.isShadow=!0),U.childNodes.push(Z))}}return e.parentNode&&z(e.parentNode)&&G(e.parentNode)&&(U.isShadow=!0),U.type===R.Element&&"iframe"===U.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,i=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){i||(t(),i=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),i=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&M){var n=Se(t,{doc:t,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:k,onIframeLoad:M,iframeLoadTimeout:T,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:L});n&&M(e,n)}}),T),U.type===R.Element&&"link"===U.tagName&&"stylesheet"===U.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var i=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(i),o=!0,t()}))}}(e,(function(){if(O){var t=Se(e,{doc:r,mirror:o,blockClass:i,blockSelector:s,maskTextClass:a,maskTextSelector:c,skipChild:!1,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:k,onIframeLoad:M,iframeLoadTimeout:T,onStylesheetLoad:O,stylesheetLoadTimeout:D,keepIframeSrcFn:L});t&&O(e,t)}}),D),U}var be=(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))(be||{}),Ie=(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))(Ie||{}),we=(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))(we||{}),Ce=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ce||{}),ke=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ke||{});function Me(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Ee="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Te={map:{},getId:()=>(console.error(Ee),-1),getNode:()=>(console.error(Ee),null),removeNodeFromMap(){console.error(Ee)},has:()=>(console.error(Ee),!1),reset(){console.error(Ee)}};function Oe(e,t,n={}){let r=null,o=0;return function(...i){const s=Date.now();o||!1!==n.leading||(o=s);const a=t-(s-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)}),a))}}function Re(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),i&&i.set&&i.set.call(this,e)}}),()=>Re(e,t,i||{},!0)}function xe(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Te=new Proxy(Te,{get:(e,t,n)=>("map"===t&&console.error(Ee),Reflect.get(e,t,n))}));let De,Ne=Date.now;function Le(e){var t,n,r,o,i,s;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(i=null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.parentElement)||void 0===i?void 0:i.scrollTop)||(null===(s=null==a?void 0:a.body)||void 0===s?void 0:s.scrollTop)||0}}function _e(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Pe(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Ae(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function Fe(e,t,n,r){if(!e)return!1;const o=Ae(e);if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(ve(o,t,r))return!0}catch(e){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function je(e,t){return-2===t.getId(e)}function Ue(e,t){if(z(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Ue(e.parentNode,t))}function qe(e){return Boolean(e.changedTouches)}function Be(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function We(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function ze(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(Ne=()=>(new Date).getTime());class Ge{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Ve(e){var t,n;let r=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function Ke(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=Ve(n);)n=t;return n}(e);return t.contains(n)}function He(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||Ke(e))}function $e(e){De=e}function Ze(){De=void 0}const Je=e=>{if(!De)return e;return(...t)=>{try{return e(...t)}catch(e){if(De&&!0===De(e))return;throw e}}};function Ye(e){return(...t)=>{try{return e(...t)}catch(e){try{e._external_=!0}catch(e){}throw e}}}class Xe{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let s=o.get(t);return s||(s=this.generateIdFn(),o.set(t,s),i.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,r)))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const o=r.get(t);return o||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map((t=>this.getRemoteId(e,t,n)))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class Qe{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Xe(ne),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Xe(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case be.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e);const n=t.data.node.id;return this.crossOriginIframeRootIdMap.set(e,n),this.patchRootIdOnNode(t.data.node,n),{timestamp:t.timestamp,type:be.IncrementalSnapshot,data:{source:Ie.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case be.Meta:case be.Load:case be.DomContentLoaded:return!1;case be.Plugin:return t;case be.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case be.IncrementalSnapshot:switch(t.data.source){case Ie.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e);const n=this.crossOriginIframeRootIdMap.get(e);n&&this.patchRootIdOnNode(t.node,n)})),t.data.removes.forEach((t=>{this.replaceIds(t,e,["parentId","id"])})),t.data.attributes.forEach((t=>{this.replaceIds(t,e,["id"])})),t.data.texts.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Ie.Drag:case Ie.TouchMove:case Ie.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Ie.ViewportResize:return!1;case Ie.MediaInteraction:case Ie.MouseInteraction:case Ie.Scroll:case Ie.CanvasMutation:case Ie.Input:return this.replaceIds(t.data,e,["id"]),t;case Ie.StyleSheetRule:case Ie.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Ie.Font:return t;case Ie.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Ie.AdoptedStyleSheet:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleIds"]),null===(n=t.data.styles)||void 0===n||n.forEach((t=>{this.replaceStyleIds(t,e,["styleId"])})),t}}}replace(e,t,n,r){for(const o of r)(Array.isArray(t[o])||"number"==typeof t[o])&&(Array.isArray(t[o])?t[o]=e.getIds(n,t[o]):t[o]=e.getId(n,t[o]));return t}replaceIds(e,t,n){return this.replace(this.crossOriginIframeMirror,e,t,n)}replaceStyleIds(e,t,n){return this.replace(this.crossOriginIframeStyleMirror,e,t,n)}replaceIdOnNode(e,t){this.replaceIds(e,t,["id","rootId"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}patchRootIdOnNode(e,t){e.type===R.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach((e=>{this.patchRootIdOnNode(e,t)}))}}function et(e){return"__ln"in e}class tt{constructor(){this.length=0,this.head=null,this.tail=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&et(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&et(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;null===t.next&&(this.tail=t),this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next?t.next.previous=t.previous:this.tail=t.previous):(this.head=t.next,this.head?this.head.previous=null:this.tail=null),e.__ln&&delete e.__ln,this.length--)}}const nt=(e,t)=>`${e}@${t}`;class rt{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Set,n=new tt,r=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{if(!o.parentNode||!He(o))return;const i=z(o.parentNode)?this.mirror.getId(Ve(o)):this.mirror.getId(o.parentNode),s=r(o);if(-1===i||-1===s)return n.addNode(o);const a=Se(o,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:e=>{Be(e,this.mirror)&&this.iframeManager.addIframe(e),We(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),ze(o)&&this.shadowDomManager.addShadowRoot(o.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});a&&(e.push({parentId:i,nextId:s,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)it(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of this.addedSet)at(this.droppedSet,e)||it(this.removes,e,this.mirror)?at(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let i=null;for(;n.length;){let e=null;if(i){const t=this.mirror.getId(i.value.parentNode),n=r(i.value);-1!==t&&-1!==n&&(e=i)}if(!e){let t=n.tail;for(;t;){const n=t;if(t=t.previous,n){const t=this.mirror.getId(n.value.parentNode);if(-1===r(n.value))continue;if(-1!==t){e=n;break}{const t=n.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const r=t.parentNode.host;if(-1!==this.mirror.getId(r)){e=n;break}}}}}}if(!e){for(;n.head;)n.removeNode(n.head.value);break}i=e.previous,n.removeNode(e.value),o(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>{const{attributes:t}=e;if("string"==typeof t.style){const n=JSON.stringify(e.styleDiff),r=JSON.stringify(e._unchangedStyles);n.length<t.style.length&&(n+r).split("var(").length===t.style.split("var(").length&&(t.style=e.styleDiff)}return{id:this.mirror.getId(e.node),attributes:t}})).filter((e=>!t.has(e.id))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!je(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Fe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:me(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t,Ae(e.target)):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,r=e.target.getAttribute(n);if("value"===n){const e=Y(t);r=$({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(Fe(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(t.contentDocument)return;n="rr_src"}if(o||(o={node:e.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(o)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),!fe(t.tagName,n)&&(o.attributes[n]=pe(this.doc,Z(t.tagName),Z(n),r),"style"===n)){let n;try{n=document.implementation.createHTMLDocument()}catch(e){n=this.doc}const r=n.createElement("span");e.oldValue&&r.setAttribute("style",e.oldValue);for(const e of Array.from(t.style)){const n=t.style.getPropertyValue(e),i=t.style.getPropertyPriority(e);n!==r.style.getPropertyValue(e)||i!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===i?n:[n,i]:o._unchangedStyles[e]=[n,i]}for(const e of Array.from(r.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}break}case"childList":if(Fe(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach((t=>this.genAdds(t,e.target))),e.removedNodes.forEach((t=>{const n=this.mirror.getId(t),r=z(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Fe(e.target,this.blockClass,this.blockSelector,!1)||je(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(ot(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Ue(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[nt(n,r)]?ot(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!z(e.target)||!G(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)&&!this.addedSet.has(e)&&!this.movedSet.has(e)){if(this.mirror.hasNode(e)){if(je(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[nt(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Fe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach((e=>this.genAdds(e))),ze(e)&&e.shadowRoot.childNodes.forEach((t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)})))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach((t=>{this[t]=e[t]}))}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function ot(e,t){e.delete(t),t.childNodes.forEach((t=>ot(e,t)))}function it(e,t,n){return 0!==e.length&&st(e,t,n)}function st(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||st(e,r,n)}function at(e,t){return 0!==e.size&&ct(e,t)}function ct(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ct(e,n))}const lt=[];function ut(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch(e){}return e&&e.target}function dt(e,t){var n,r;const o=new rt;lt.push(o),o.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const s=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");s&&window[s]&&(i=window[s]);const a=new i(Je(o.processMutations.bind(o)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ht({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,a=[];let c=null;return Object.keys(we).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e])).forEach((i=>{let s=Z(i);const l=(t=>i=>{const s=ut(i);if(Fe(s,r,o,!0))return;let a=null,l=t;if("pointerType"in i){switch(i.pointerType){case"mouse":a=Ce.Mouse;break;case"touch":a=Ce.Touch;break;case"pen":a=Ce.Pen}a===Ce.Touch?we[t]===we.MouseDown?l="TouchStart":we[t]===we.MouseUp&&(l="TouchEnd"):Ce.Pen}else qe(i)&&(a=Ce.Touch);null!==a?(c=a,(l.startsWith("Touch")&&a===Ce.Touch||l.startsWith("Mouse")&&a===Ce.Mouse)&&(a=null)):we[t]===we.Click&&(a=c,c=null);const u=qe(i)?i.changedTouches[0]:i;if(!u)return;const d=n.getId(s),{clientX:h,clientY:p}=u;Je(e)(Object.assign({type:we[l],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(i);if(window.PointerEvent)switch(we[i]){case we.MouseDown:case we.MouseUp:s=s.replace("mouse","pointer");break;case we.TouchStart:case we.TouchEnd:return}a.push(Me(s,l,t))})),Je((()=>{a.forEach((e=>e()))}))}function pt({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){const s=Je(Oe(Je((i=>{const s=ut(i);if(!s||Fe(s,r,o,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=Le(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})})),i.scroll||100));return Me("scroll",s,t)}function ft(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const vt=["INPUT","TEXTAREA","SELECT"],mt=new WeakMap;function gt(e){return function(e,t){if(It("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||It("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||It("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||It("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function yt(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function St({mirror:e,stylesheetManager:t},n){var r,o,i;let s=null;s="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(i=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===i?void 0:i.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==s&&-1!==s&&a&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(e){}return r}}),Je((()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}))):()=>{}}function bt(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:s,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:h,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),h(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t),e.recordDOM&&(r=dt(e,e.doc));const o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const c=Oe(Je((t=>{const n=Date.now()-s;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],s=null})),i),l=Je(Oe(Je((e=>{const t=ut(e),{clientX:n,clientY:o}=qe(e)?e.changedTouches[0]:e;s||(s=Ne()),a.push({x:n,y:o,id:r.getId(t),timeOffset:Ne()-s}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Ie.Drag:e instanceof MouseEvent?Ie.MouseMove:Ie.TouchMove)})),o,{trailing:!1})),u=[Me("mousemove",l,n),Me("touchmove",l,n),Me("drag",l,n)];return Je((()=>{u.forEach((e=>e()))}))}(e),i=ht(e),s=pt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Me("resize",Je(Oe(Je((()=>{const t=_e(),o=Pe();n===t&&r===o||(e({width:Number(o),height:Number(t)}),n=t,r=o)})),200)),t)}(e,{win:n}),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,ignoreSelector:s,maskInputOptions:a,maskInputFn:c,sampling:l,userTriggeredOnInput:u}){function d(e){let n=ut(e);const l=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=n.parentElement),!n||!d||vt.indexOf(d)<0||Fe(n,r,o,!0))return;if(n.classList.contains(i)||s&&n.matches(s))return;let p=n.value,f=!1;const v=Y(n)||"";"radio"===v||"checkbox"===v?f=n.checked:(a[d.toLowerCase()]||a[v])&&(p=$({element:n,maskInputOptions:a,tagName:d,type:v,value:p,maskInputFn:c})),h(n,Je(ft)({text:p,isChecked:f,userTriggered:l},u));const m=n.name;"radio"===v&&m&&f&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&h(e,Je(ft)({text:e.value,isChecked:!f,userTriggered:!1},u))}))}function h(t,r){const o=mt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){mt.set(t,r);const o=n.getId(t);Je(e)(Object.assign(Object.assign({},r),{id:o}))}}const p=("last"===l.input?["change"]:["input","change"]).map((e=>Me(e,Je(d),t))),f=t.defaultView;if(!f)return()=>{p.forEach((e=>e()))};const v=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value"),m=[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]];return v&&v.set&&p.push(...m.map((e=>Re(e[0],e[1],{set(){Je(d)({target:this,isTrusted:!1})}},!1,f)))),Je((()=>{p.forEach((e=>e()))}))}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:i}){const s=Je((i=>Oe(Je((o=>{const s=ut(o);if(!s||Fe(s,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:u}=s;e({type:i,id:r.getId(s),currentTime:a,volume:c,muted:l,playbackRate:u})})),o.media||500))),a=[Me("play",s(0),i),Me("pause",s(1),i),Me("seeked",s(2),i),Me("volumechange",s(3),i),Me("ratechange",s(4),i)];return Je((()=>{a.forEach((e=>e()))}))}(e);let u=()=>{},d=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Je(((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=yt(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:a}]}),Ye((()=>r.apply(o,i)))()}))});const i=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:s}]}),Ye((()=>r.apply(o,i)))()}))}),r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:s}),r.apply(o,i)}))})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:s}),r.apply(o,i)}))}));const c={};wt("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(wt("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),wt("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),wt("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach((([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:Je(((r,o,i)=>{const[s,a]=i,{id:c,styleId:l}=yt(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:s,index:[...gt(o),a||0]}]}),r.apply(o,i)}))}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Je(((r,o,i)=>{const[s]=i,{id:a,styleId:c}=yt(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...gt(o),s]}]}),r.apply(o,i)}))})})),Je((()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}))}(e,{win:n}),d=St(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Je(((o,s,a)=>{var c;const[l,u,d]=a;if(n.has(l))return i.apply(s,[l,u,d]);const{id:h,styleId:p}=yt(null===(c=s.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(h&&-1!==h||p&&-1!==p)&&e({id:h,styleId:p,set:{property:l,value:u,priority:d},index:gt(s.parentRule)}),o.apply(s,a)}))});const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:Je(((o,i,a)=>{var c;const[l]=a;if(n.has(l))return s.apply(i,[l]);const{id:u,styleId:d}=yt(null===(c=i.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(u&&-1!==u||d&&-1!==d)&&e({id:u,styleId:d,remove:{property:l},index:gt(i.parentRule)}),o.apply(i,a)}))}),Je((()=>{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=s}))}(e,{win:n}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=xe(t.fonts,"add",(function(t){return function(n){return setTimeout(Je((()=>{const t=o.get(n);t&&(e(t),o.delete(n))})),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=i})),r.push(s),Je((()=>{r.forEach((e=>e()))}))}(e)));const f=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let s=!0;const a=Je((()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const i=e.getRangeAt(t),{startContainer:s,startOffset:c,endContainer:l,endOffset:u}=i;Fe(s,r,o,!0)||Fe(l,r,o,!0)||a.push({start:n.getId(s),startOffset:c,end:n.getId(l),endOffset:u})}i({ranges:a})}));return a(),Me("selectionchange",a)}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return Je((()=>{lt.forEach((e=>e.reset())),null==r||r.disconnect(),o(),i(),s(),a(),c(),l(),u(),d(),h(),p(),f(),v.forEach((e=>e()))}))}function It(e){return void 0!==window[e]}function wt(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function Ct(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}for(var kt,Mt,Et,Tt=(kt=function(){!function(){function e(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),r=0;r<t.length;r++)n[t.charCodeAt(r)]=r;var o=function(e){var n,r=new Uint8Array(e),o=r.length,i="";for(n=0;n<o;n+=3)i+=t[r[n]>>2],i+=t[(3&r[n])<<4|r[n+1]>>4],i+=t[(15&r[n+1])<<2|r[n+2]>>6],i+=t[63&r[n+2]];return o%3==2?i=i.substring(0,i.length-1)+"=":o%3==1&&(i=i.substring(0,i.length-2)+"=="),i};const i=new Map,s=new Map,a=self;a.onmessage=function(t){return e(this,void 0,void 0,(function*(){if(!("OffscreenCanvas"in globalThis))return a.postMessage({id:t.data.id});{const{id:n,bitmap:r,width:c,height:l,dataURLOptions:u}=t.data,d=function(t,n,r){return e(this,void 0,void 0,(function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(s.has(e))return s.get(e);const i=new OffscreenCanvas(t,n);i.getContext("2d");const a=yield i.convertToBlob(r),c=yield a.arrayBuffer(),l=o(c);return s.set(e,l),l}return""}))}(c,l,u),h=new OffscreenCanvas(c,l);h.getContext("2d").drawImage(r,0,0),r.close();const p=yield h.convertToBlob(u),f=p.type,v=yield p.arrayBuffer(),m=o(v);if(!i.has(n)&&(yield d)===m)return i.set(n,m),a.postMessage({id:n});if(i.get(n)===m)return a.postMessage({id:n});a.postMessage({id:n,type:f,base64:m,width:c,height:l}),i.set(n,m)}}))}}()},Mt=null,function(e){return Et=Et||function(e,t){var n=function(e,t){var n=void 0===t?null:t,r=e.toString().split("\n");r.pop(),r.shift();for(var o=r[0].search(/\S/),i=/(['"])__worker_loader_strict__(['"])/g,s=0,a=r.length;s<a;++s)r[s]=r[s].substring(o).replace(i,"$1use strict$2")+"\n";return n&&r.push("//# sourceMappingURL="+n+"\n"),r}(e,t),r=new Blob(n,{type:"application/javascript"});return URL.createObjectURL(r)}(kt,Mt),new Worker(Et,e)}),Ot="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rt="undefined"==typeof Uint8Array?[]:new Uint8Array(256),xt=0;xt<Ot.length;xt++)Rt[Ot.charCodeAt(xt)]=xt;const Dt=new Map;const Nt=(e,t,n)=>{if(!e||!Pt(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Dt.get(e);return n||(n=new Map,Dt.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let o=r.indexOf(e);return-1===o&&(o=r.length,r.push(e)),o};function Lt(e,t,n){if(e instanceof Array)return e.map((e=>Lt(e,t,n)));if(null===e)return e;if(e instanceof Float32Array||e instanceof Float64Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Uint8Array||e instanceof Uint16Array||e instanceof Int16Array||e instanceof Int8Array||e instanceof Uint8ClampedArray){return{rr_type:e.constructor.name,args:[Object.values(e)]}}if(e instanceof ArrayBuffer){const t=e.constructor.name,n=function(e){var t,n=new Uint8Array(e),r=n.length,o="";for(t=0;t<r;t+=3)o+=Ot[n[t]>>2],o+=Ot[(3&n[t])<<4|n[t+1]>>4],o+=Ot[(15&n[t+1])<<2|n[t+2]>>6],o+=Ot[63&n[t+2]];return r%3==2?o=o.substring(0,o.length-1)+"=":r%3==1&&(o=o.substring(0,o.length-2)+"=="),o}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[Lt(e.buffer,t,n),e.byteOffset,e.byteLength]}}if(e instanceof HTMLImageElement){const t=e.constructor.name,{src:n}=e;return{rr_type:t,src:n}}if(e instanceof HTMLCanvasElement){return{rr_type:"HTMLImageElement",src:e.toDataURL()}}if(e instanceof ImageData){return{rr_type:e.constructor.name,args:[Lt(e.data,t,n),e.width,e.height]}}if(Pt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Nt(e,t,n)}}return e}const _t=(e,t,n)=>[...e].map((e=>Lt(e,t,n))),Pt=(e,t)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((e=>"function"==typeof t[e]));return Boolean(n.find((n=>e instanceof t[n])))};function At(e,t,n,r){const o=[];try{const i=xe(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...i){if(!Fe(this,t,n,!0)){const e=function(e){return"experimental-webgl"===e?"webgl":e}(o);if("__context"in this||(this.__context=e),r&&["webgl","webgl2"].includes(e))if(i[0]&&"object"==typeof i[0]){const e=i[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else i.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...i])}}));o.push(i)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function Ft(e,t,n,r,o,i,s){const a=[],c=Object.getOwnPropertyNames(e);for(const i of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(i))try{if("function"!=typeof e[i])continue;const c=xe(e,i,(function(e){return function(...a){const c=e.apply(this,a);if(Nt(c,s,this),"tagName"in this.canvas&&!Fe(this.canvas,r,o,!0)){const e=_t([...a],s,this),r={type:t,property:i,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=Re(e,i,{set(e){n(this.canvas,{type:t,property:i,args:[e],setter:!0})}});a.push(o)}return a}class jt{reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}constructor(e){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(e,t)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)};const{sampling:t="all",win:n,blockClass:r,blockSelector:o,recordCanvas:i,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,i&&"all"===t&&this.initCanvasMutationObserver(n,r,o),i&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:s})}initCanvasFPSObserver(e,t,n,r,o){const i=At(t,n,r,!0),s=new Map,a=new Tt;a.onmessage=e=>{const{id:t}=e.data;if(s.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:i}=e.data;this.mutationCb({id:t,type:ke["2D"],commands:[{property:"clearRect",args:[0,0,o,i]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:r}]},0,0]}]})};const c=1e3/e;let l,u=0;const d=e=>{u&&e-u<c||(u=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{Fe(t,n,r,!0)||e.push(t)})),e})().forEach((e=>Ct(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(s.get(n))return;if(s.set(n,!0),["webgl","webgl2"].includes(e.__context)){const n=e.getContext(e.__context);!1===(null===(t=null==n?void 0:n.getContextAttributes())||void 0===t?void 0:t.preserveDrawingBuffer)&&n.clear(n.COLOR_BUFFER_BIT)}const r=yield createImageBitmap(e);a.postMessage({id:n,bitmap:r,width:e.width,height:e.height,dataURLOptions:o.dataURLOptions},[r])}))))),l=requestAnimationFrame(d)};l=requestAnimationFrame(d),this.resetObservers=()=>{i(),cancelAnimationFrame(l)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=At(e,t,n,!1),o=function(e,t,n,r){const o=[],i=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const s of i)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[s])continue;const i=xe(t.CanvasRenderingContext2D.prototype,s,(function(o){return function(...i){return Fe(this.canvas,n,r,!0)||setTimeout((()=>{const n=_t([...i],t,this);e(this.canvas,{type:ke["2D"],property:s,args:n})}),0),o.apply(this,i)}}));o.push(i)}catch(n){const r=Re(t.CanvasRenderingContext2D.prototype,s,{set(t){e(this.canvas,{type:ke["2D"],property:s,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),i=function(e,t,n,r,o){const i=[];return i.push(...Ft(t.WebGLRenderingContext.prototype,ke.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&i.push(...Ft(t.WebGL2RenderingContext.prototype,ke.WebGL2,e,n,r,0,t)),()=>{i.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),i()}}startPendingCanvasMutationFlusher(){requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}startRAFTimestamping(){const e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach(((e,t)=>{const n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)})),requestAnimationFrame((()=>this.flushPendingCanvasMutations()))}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(e);if(!n||-1===t)return;const r=n.map((e=>{const t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["type"]);return t})),{type:o}=n[0];this.mutationCb({id:t,type:o,commands:r}),this.pendingCanvasMutations.delete(e)}}class Ut{constructor(){this.nodeMap=new WeakMap,this.loop=!0,this.periodicallyClear()}periodicallyClear(){requestAnimationFrame((()=>{this.clear(),this.loop&&this.periodicallyClear()}))}inOtherBuffer(e,t){const n=this.nodeMap.get(e);return n&&Array.from(n).some((e=>e!==t))}add(e,t){this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}clear(){this.nodeMap=new WeakMap}destroy(){this.loop=!1}}class qt{constructor(e){this.shadowDoms=new WeakSet,this.restoreHandlers=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(e,t){if(!G(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=dt(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e);this.restoreHandlers.push((()=>n.disconnect())),this.restoreHandlers.push(pt(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:e,mirror:this.mirror}))),setTimeout((()=>{e.adoptedStyleSheets&&e.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(e.adoptedStyleSheets,this.mirror.getId(e.host)),this.restoreHandlers.push(St({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e))}),0)}observeAttachShadow(e){e.contentWindow&&e.contentDocument&&this.patchAttachShadow(e.contentWindow.Element,e.contentDocument)}patchAttachShadow(e,t){const n=this;this.restoreHandlers.push(xe(e.prototype,"attachShadow",(function(e){return function(r){const o=e.call(this,r);return this.shadowRoot&&He(this)&&n.addShadowRoot(this.shadowRoot,t),o}})))}reset(){this.restoreHandlers.forEach((e=>{try{e()}catch(e){}})),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}class Bt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new Ge,this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){"_cssText"in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(0===e.length)return;const n={id:t,styleIds:[]},r=[];for(const t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,((e,t)=>({rule:K(e),index:t})))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}}function Wt(e){return Object.assign(Object.assign({},e),{timestamp:Ne()})}let zt,Gt,Vt,Kt=!1;const Ht=new H;function $t(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:i=null,ignoreClass:s="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:p,maskInputFn:f,maskTextFn:v,hooks:m,packFn:g,sampling:y={},dataURLOptions:S={},mousemoveWait:b,recordDOM:I=!0,recordCanvas:w=!1,recordCrossOriginIframes:C=!1,recordAfter:k=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:M=!1,collectFonts:E=!1,inlineImages:T=!1,plugins:O,keepIframeSrcFn:R=(()=>!1),ignoreCSSAttributes:x=new Set([]),errorHandler:D}=e;$e(D);const N=!C||window.parent===window;let L=!1;if(!N)try{window.parent.document&&(L=!1)}catch(e){L=!0}if(N&&!t)throw new Error("emit function is required");void 0!==b&&void 0===y.mousemove&&(y.mousemove=b),Ht.reset();const _=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},P=!0===p||"all"===p?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===p,headMetaDescKeywords:"all"===p}:p||{};let A;!function(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let t=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do{if(this===t)return!0}while(t=t&&t.parentNode);return!1})}();let F=0;const j=e=>{for(const t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return g&&!L&&(e=g(e)),e};zt=(e,o)=>{var i;if(!(null===(i=lt[0])||void 0===i?void 0:i.isFrozen())||e.type===be.FullSnapshot||e.type===be.IncrementalSnapshot&&e.data.source===Ie.Mutation||lt.forEach((e=>e.unfreeze())),N)null==t||t(j(e),o);else if(L){const t={type:"rrweb",event:j(e),origin:window.location.origin,isCheckout:o};window.parent.postMessage(t,"*")}if(e.type===be.FullSnapshot)A=e,F=0;else if(e.type===be.IncrementalSnapshot){if(e.data.source===Ie.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-A.timestamp>n;(t||o)&&Gt(!0)}};const U=e=>{zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Mutation},e)}))},q=e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Scroll},e)})),B=e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.CanvasMutation},e)})),W=new Bt({mutationCb:U,adoptedStyleSheetCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.AdoptedStyleSheet},e)}))}),z=new Qe({mirror:Ht,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:C,wrappedEmit:zt});for(const e of O||[])e.getMirror&&e.getMirror({nodeMirror:Ht,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const G=new Ut;Vt=new jt({recordCanvas:w,mutationCb:B,win:window,blockClass:o,blockSelector:i,mirror:Ht,sampling:y.canvas,dataURLOptions:S});const V=new qt({mutationCb:U,scrollCb:q,bypassOptions:{blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:_,dataURLOptions:S,maskTextFn:v,maskInputFn:f,recordCanvas:w,inlineImages:T,sampling:y,slimDOMOptions:P,iframeManager:z,stylesheetManager:W,canvasManager:Vt,keepIframeSrcFn:R,processedNodeManager:G},mirror:Ht});Gt=(e=!1)=>{if(!I)return;zt(Wt({type:be.Meta,data:{href:window.location.href,width:Pe(),height:_e()}}),e),W.reset(),V.init(),lt.forEach((e=>e.lock()));const t=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new H:r,i=n.blockClass,s=void 0===i?"rr-block":i,a=n.blockSelector,c=void 0===a?null:a,l=n.maskTextClass,u=void 0===l?"rr-mask":l,d=n.maskTextSelector,h=void 0===d?null:d,p=n.inlineStylesheet,f=void 0===p||p,v=n.inlineImages,m=void 0!==v&&v,g=n.recordCanvas,y=void 0!==g&&g,S=n.maskAllInputs,b=void 0!==S&&S,I=n.maskTextFn,w=n.maskInputFn,C=n.slimDOM,k=void 0!==C&&C,M=n.dataURLOptions,E=n.preserveWhiteSpace,T=n.onSerialize,O=n.onIframeLoad,R=n.iframeLoadTimeout,x=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,N=n.keepIframeSrcFn;return Se(e,{doc:e,mirror:o,blockClass:s,blockSelector:c,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:f,maskInputOptions:!0===b?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===b?{password:!0}:b,maskTextFn:I,maskInputFn:w,slimDOMOptions:!0===k||"all"===k?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===k,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===k?{}:k,dataURLOptions:M,inlineImages:m,recordCanvas:y,preserveWhiteSpace:E,onSerialize:T,onIframeLoad:O,iframeLoadTimeout:R,onStylesheetLoad:x,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===N?function(){return!1}:N,newlyAddedElement:!1})}(document,{mirror:Ht,blockClass:o,blockSelector:i,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:_,maskTextFn:v,maskInputFn:f,slimDOM:P,dataURLOptions:S,recordCanvas:w,inlineImages:T,onSerialize:e=>{Be(e,Ht)&&z.addIframe(e),We(e,Ht)&&W.trackLinkElement(e),ze(e)&&V.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),V.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:R});if(!t)return console.warn("Failed to snapshot the document");zt(Wt({type:be.FullSnapshot,data:{node:t,initialOffset:Le(window)}}),e),lt.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Ht.getId(document))};try{const e=[],t=e=>{var t;return Je(bt)({mutationCb:U,mousemoveCb:(e,t)=>zt(Wt({type:be.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.MouseInteraction},e)})),scrollCb:q,viewportResizeCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.ViewportResize},e)})),inputCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Input},e)})),mediaInteractionCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.MediaInteraction},e)})),styleSheetRuleCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.StyleSheetRule},e)})),styleDeclarationCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.StyleDeclaration},e)})),canvasMutationCb:B,fontCb:e=>zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Font},e)})),selectionCb:e=>{zt(Wt({type:be.IncrementalSnapshot,data:Object.assign({source:Ie.Selection},e)}))},blockClass:o,ignoreClass:s,ignoreSelector:a,maskTextClass:c,maskTextSelector:l,maskInputOptions:_,inlineStylesheet:u,sampling:y,recordDOM:I,recordCanvas:w,inlineImages:T,userTriggeredOnInput:M,collectFonts:E,doc:e,maskInputFn:f,maskTextFn:v,keepIframeSrcFn:R,blockSelector:i,slimDOMOptions:P,dataURLOptions:S,mirror:Ht,iframeManager:z,stylesheetManager:W,shadowDomManager:V,processedNodeManager:G,canvasManager:Vt,ignoreCSSAttributes:x,plugins:(null===(t=null==O?void 0:O.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>zt(Wt({type:be.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};z.addLoadListener((n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}}));const n=()=>{Gt(),e.push(t(document)),Kt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(Me("DOMContentLoaded",(()=>{zt(Wt({type:be.DomContentLoaded,data:{}})),"DOMContentLoaded"===k&&n()}))),e.push(Me("load",(()=>{zt(Wt({type:be.Load,data:{}})),"load"===k&&n()}),window))),()=>{e.forEach((e=>e())),G.destroy(),Kt=!1,Ze()}}catch(e){console.warn(e)}}var Zt,Jt;$t.addCustomEvent=(e,t)=>{if(!Kt)throw new Error("please add custom event after start recording");zt(Wt({type:be.Custom,data:{tag:e,payload:t}}))},$t.freezePage=()=>{lt.forEach((e=>e.freeze()))},$t.takeFullSnapshot=e=>{if(!Kt)throw new Error("please take full snapshot after start recording");Gt(e)},$t.mirror=Ht,function(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"}(Zt||(Zt={})),function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"}(Jt||(Jt={}));var Yt=Uint8Array,Xt=Uint16Array,Qt=Uint32Array,en=new Yt([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),tn=new Yt([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),nn=new Yt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),rn=function(e,t){for(var n=new Xt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new Qt(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)o[i]=i-n[r]<<5|r;return[n,o]},on=rn(en,2),sn=on[0],an=on[1];sn[28]=258,an[258]=28;for(var cn=rn(tn,0)[1],ln=new Xt(32768),un=0;un<32768;++un){var dn=(43690&un)>>>1|(21845&un)<<1;dn=(61680&(dn=(52428&dn)>>>2|(13107&dn)<<2))>>>4|(3855&dn)<<4,ln[un]=((65280&dn)>>>8|(255&dn)<<8)>>>1}var hn=function(e,t,n){for(var r=e.length,o=0,i=new Xt(t);o<r;++o)++i[e[o]-1];var s,a=new Xt(t);for(o=0;o<t;++o)a[o]=a[o-1]+i[o-1]<<1;if(n){s=new Xt(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var l=o<<4|e[o],u=t-e[o],d=a[e[o]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)s[ln[d]>>>c]=l}else for(s=new Xt(r),o=0;o<r;++o)s[o]=ln[a[e[o]-1]++]>>>15-e[o];return s},pn=new Yt(288);for(un=0;un<144;++un)pn[un]=8;for(un=144;un<256;++un)pn[un]=9;for(un=256;un<280;++un)pn[un]=7;for(un=280;un<288;++un)pn[un]=8;var fn=new Yt(32);for(un=0;un<32;++un)fn[un]=5;var vn=hn(pn,9,0),mn=hn(fn,5,0),gn=function(e){return(e/8>>0)+(7&e&&1)},yn=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Xt?Xt:e instanceof Qt?Qt:Yt)(n-t);return r.set(e.subarray(t,n)),r},Sn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},bn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},In=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var o=n.length,i=n.slice();if(!o)return[new Yt(0),0];if(1==o){var s=new Yt(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};u!=o-1;)a=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:a.f+c.f,l:a,r:c};var h=i[0].s;for(r=1;r<o;++r)i[r].s>h&&(h=i[r].s);var p=new Xt(h+1),f=wn(n[u-1],p,0);if(f>t){r=0;var v=0,m=f-t,g=1<<m;for(i.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var y=i[r].s;if(!(p[y]>t))break;v+=g-(1<<f-p[y]),p[y]=t}for(v>>>=m;v>0;){var S=i[r].s;p[S]<t?v-=1<<t-p[S]++-1:++r}for(;r>=0&&v;--r){var b=i[r].s;p[b]==t&&(--p[b],++v)}f=t}return[new Yt(p),f]},wn=function(e,t,n){return-1==e.s?Math.max(wn(e.l,t,n+1),wn(e.r,t,n+1)):t[e.s]=n},Cn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Xt(++t),r=0,o=e[0],i=1,s=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++i;else{if(!o&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(o),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(o);i=1,o=e[a]}return[n.subarray(0,r),t]},kn=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},Mn=function(e,t,n){var r=n.length,o=gn(t+2);e[o]=255&r,e[o+1]=r>>>8,e[o+2]=255^e[o],e[o+3]=255^e[o+1];for(var i=0;i<r;++i)e[o+i+4]=n[i];return 8*(o+4+r)},En=function(e,t,n,r,o,i,s,a,c,l,u){Sn(t,u++,n),++o[256];for(var d=In(o,15),h=d[0],p=d[1],f=In(i,15),v=f[0],m=f[1],g=Cn(h),y=g[0],S=g[1],b=Cn(v),I=b[0],w=b[1],C=new Xt(19),k=0;k<y.length;++k)C[31&y[k]]++;for(k=0;k<I.length;++k)C[31&I[k]]++;for(var M=In(C,7),E=M[0],T=M[1],O=19;O>4&&!E[nn[O-1]];--O);var R,x,D,N,L=l+5<<3,_=kn(o,pn)+kn(i,fn)+s,P=kn(o,h)+kn(i,v)+s+14+3*O+kn(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(L<=_&&L<=P)return Mn(t,u,e.subarray(c,c+l));if(Sn(t,u,1+(P<_)),u+=2,P<_){R=hn(h,p,0),x=h,D=hn(v,m,0),N=v;var A=hn(E,T,0);Sn(t,u,S-257),Sn(t,u+5,w-1),Sn(t,u+10,O-4),u+=14;for(k=0;k<O;++k)Sn(t,u+3*k,E[nn[k]]);u+=3*O;for(var F=[y,I],j=0;j<2;++j){var U=F[j];for(k=0;k<U.length;++k){var q=31&U[k];Sn(t,u,A[q]),u+=E[q],q>15&&(Sn(t,u,U[k]>>>5&127),u+=U[k]>>>12)}}}else R=vn,x=pn,D=mn,N=fn;for(k=0;k<a;++k)if(r[k]>255){q=r[k]>>>18&31;bn(t,u,R[q+257]),u+=x[q+257],q>7&&(Sn(t,u,r[k]>>>23&31),u+=en[q]);var B=31&r[k];bn(t,u,D[B]),u+=N[B],B>3&&(bn(t,u,r[k]>>>5&8191),u+=tn[B])}else bn(t,u,R[r[k]]),u+=x[r[k]];return bn(t,u,R[256]),u+x[256]},Tn=new Qt([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),On=new Yt(0),Rn=function(e,t,n,r,o){return function(e,t,n,r,o,i){var s=e.length,a=new Yt(r+s+5*(1+Math.floor(s/7e3))+o),c=a.subarray(r,a.length-o),l=0;if(!t||s<8)for(var u=0;u<=s;u+=65535){var d=u+65535;d<s?l=Mn(c,l,e.subarray(u,d)):(c[u]=i,l=Mn(c,l,e.subarray(u,s)))}else{for(var h=Tn[t-1],p=h>>>13,f=8191&h,v=(1<<n)-1,m=new Xt(32768),g=new Xt(v+1),y=Math.ceil(n/3),S=2*y,b=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<S)&v},I=new Qt(25e3),w=new Xt(288),C=new Xt(32),k=0,M=0,E=(u=0,0),T=0,O=0;u<s;++u){var R=b(u),x=32767&u,D=g[R];if(m[x]=D,g[R]=x,T<=u){var N=s-u;if((k>7e3||E>24576)&&N>423){l=En(e,c,0,I,w,C,M,E,O,u-O,l),E=k=M=0,O=u;for(var L=0;L<286;++L)w[L]=0;for(L=0;L<30;++L)C[L]=0}var _=2,P=0,A=f,F=x-D&32767;if(N>2&&R==b(u-F))for(var j=Math.min(p,N)-1,U=Math.min(32767,u),q=Math.min(258,N);F<=U&&--A&&x!=D;){if(e[u+_]==e[u+_-F]){for(var B=0;B<q&&e[u+B]==e[u+B-F];++B);if(B>_){if(_=B,P=F,B>j)break;var W=Math.min(F,B-2),z=0;for(L=0;L<W;++L){var G=u-F+L+32768&32767,V=G-m[G]+32768&32767;V>z&&(z=V,D=G)}}}F+=(x=D)-(D=m[x])+32768&32767}if(P){I[E++]=268435456|an[_]<<18|cn[P];var K=31&an[_],H=31&cn[P];M+=en[K]+tn[H],++w[257+K],++C[H],T=u+_,++k}else I[E++]=e[u],++w[e[u]]}}l=En(e,c,i,I,w,C,M,E,O,u-O,l),i||(l=Mn(c,l,On))}return yn(a,0,r+gn(l)+o)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!o)};function xn(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,i=n.length,s=0;s!=i;){for(var a=Math.min(s+5552,i);s<a;++s)o+=r+=n[s];r%=65521,o%=65521}e=r,t=o},d:function(){return(e>>>8<<16|(255&t)<<8|t>>>8)+2*((255&e)<<23)}}}();n.p(e);var r=Rn(e,t,2,4);return function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)}(r,t),function(e,t,n){for(;n;++t)e[t]=n,n>>>=8}(r,r.length-4,n.d()),r}const Dn=e=>{const t=Object.assign(Object.assign({},e),{v:"v1"});return function(e,t){var n="";if(!t&&"undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var r=0;r<e.length;){var o=e[r++];o<128||t?n+=String.fromCharCode(o):o<224?n+=String.fromCharCode((31&o)<<6|63&e[r++]):o<240?n+=String.fromCharCode((15&o)<<12|(63&e[r++])<<6|63&e[r++]):(o=((15&o)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536,n+=String.fromCharCode(55296|o>>10,56320|1023&o))}return n}(xn(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Yt(e.length+(e.length>>>1)),o=0,i=function(e){r[o++]=e},s=0;s<n;++s){if(o+5>r.length){var a=new Yt(o+8+(n-s<<1));a.set(r),r=a}var c=e.charCodeAt(s);c<128||t?i(c):c<2048?(i(192|c>>>6),i(128|63&c)):c>55295&&c<57344?(i(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++s))>>>18),i(128|c>>>12&63),i(128|c>>>6&63),i(128|63&c)):(i(224|c>>>12),i(128|c>>>6&63),i(128|63&c))}return yn(r,0,o)}(JSON.stringify(t))),!0)};var Nn,Ln;(Ln=Nn||(Nn={}))[Ln.NotStarted=0]="NotStarted",Ln[Ln.Running=1]="Running",Ln[Ln.Stopped=2]="Stopped";const _n=(e,t)=>t.some((t=>e instanceof t));let Pn,An;const Fn=new WeakMap,jn=new WeakMap,Un=new WeakMap;let qn={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return Fn.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Gn(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function Bn(e){qn=e(qn)}function Wn(e){return(An||(An=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Vn(this),t),Gn(this.request)}:function(...t){return Gn(e.apply(Vn(this),t))}}function zn(e){return"function"==typeof e?Wn(e):(e instanceof IDBTransaction&&function(e){if(Fn.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",i),e.removeEventListener("abort",i)},o=()=>{t(),r()},i=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",i),e.addEventListener("abort",i)}));Fn.set(e,t)}(e),_n(e,Pn||(Pn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,qn):e)}function Gn(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",i)},o=()=>{t(Gn(e.result)),r()},i=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",i)}));return Un.set(t,e),t}(e);if(jn.has(e))return jn.get(e);const t=zn(e);return t!==e&&(jn.set(e,t),Un.set(t,e)),t}const Vn=e=>Un.get(e);function Kn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:i}={}){const s=indexedDB.open(e,t),a=Gn(s);return r&&s.addEventListener("upgradeneeded",(e=>{r(Gn(s.result),e.oldVersion,e.newVersion,Gn(s.transaction),e)})),n&&s.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{i&&e.addEventListener("close",(()=>i())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function Hn(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),Gn(n).then((()=>{}))}const $n=["get","getKey","getAll","getAllKeys","count"],Zn=["put","add","delete","clear"],Jn=new Map;function Yn(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Jn.get(t))return Jn.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=Zn.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!$n.includes(n))return;const i=async function(e,...t){const i=this.transaction(e,o?"readwrite":"readonly");let s=i.store;return r&&(s=s.index(t.shift())),(await Promise.all([s[n](...t),o&&i.done]))[0]};return Jn.set(t,i),i}Bn((e=>({...e,get:(t,n,r)=>Yn(t,n)||e.get(t,n,r),has:(t,n)=>!!Yn(t,n)||e.has(t,n)})));const Xn=["continue","continuePrimaryKey","advance"],Qn={},er=new WeakMap,tr=new WeakMap,nr={get(e,t){if(!Xn.includes(t))return e[t];let n=Qn[t];return n||(n=Qn[t]=function(...e){er.set(this,tr.get(this)[t](...e))}),n}};async function*rr(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,nr);for(tr.set(n,t),Un.set(n,Vn(t));t;)yield n,t=await(er.get(n)||t.continue()),er.delete(n)}function or(e,t){return t===Symbol.asyncIterator&&_n(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&_n(e,[IDBIndex,IDBObjectStore])}Bn((e=>({...e,get:(t,n,r)=>or(t,n)?rr:e.get(t,n,r),has:(t,n)=>or(t,n)||e.has(t,n)})));var ir,sr=function(e,t){return a(void 0,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,Kn(e,1,{upgrade:function(e){t.forEach((function(t){e.objectStoreNames.contains(t)||e.createObjectStore(t)}))}})];case 1:return[2,n.sent()]}}))}))},ar=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.configKeys;return a(void 0,void 0,void 0,(function(){var e,o,i,l,h,p,f,v,m;return c(this,(function(g){switch(g.label){case 0:return e="".concat(n.substring(0,10),"_amp_config"),[4,sr(e,r)];case 1:return o=g.sent(),i="".concat(n.substring(0,10),"_amp_config_meta"),[4,(y=i,a(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,Kn(y,1,{upgrade:function(e){e.objectStoreNames.contains("lastFetchedSessionId")||e.createObjectStore("lastFetchedSessionId")}})];case 1:return[2,e.sent()]}}))})))];case 2:l=g.sent(),g.label=3;case 3:return g.trys.push([3,8,,9]),[4,l.get("lastFetchedSessionId","sessionId")];case 4:return(h=g.sent())&&Date.now()-h>=2592e5?(o.close(),[4,Hn(e)]):[3,7];case 5:return g.sent(),[4,sr(n,r)];case 6:o=g.sent(),g.label=7;case 7:return[3,9];case 8:return p=g.sent(),t.warn("Failed to reset store: ".concat(p)),[3,9];case 9:return f=function(e,n){return a(void 0,void 0,void 0,(function(){var r,i,a,h,p,f;return c(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),n?[4,l.put("lastFetchedSessionId",n,"sessionId")]:[3,2];case 1:v.sent(),v.label=2;case 2:for(h in r=function(t){var n,r;return c(this,(function(i){switch(i.label){case 0:return n=e.configs[t],r=o.transaction(t,"readwrite"),[4,Promise.all(d(d([],u(Object.keys(n).map((function(e){return r.store.put(s({},n[e]),e)}))),!1),[r.done],!1))];case 1:return i.sent(),[2]}}))},i=e.configs,a=[],i)a.push(h);p=0,v.label=3;case 3:return p<a.length?(h=a[p])in i?[5,r(h)]:[3,5]:[3,6];case 4:v.sent(),v.label=5;case 5:return p++,[3,3];case 6:return[3,8];case 7:return f=v.sent(),t.warn("Failed to store remote config: ".concat(f)),[3,8];case 8:return[2]}}))}))},v=function(){return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,l.get("lastFetchedSessionId","sessionId")];case 1:return[2,n.sent()];case 2:return e=n.sent(),t.warn("Failed to fetch lastFetchedSessionId: ".concat(e)),[3,3];case 3:return[2,void 0]}}))}))},m=function(e,n){return a(void 0,void 0,void 0,(function(){var r;return c(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,o.get(e,n)];case 1:return[2,i.sent()];case 2:return r=i.sent(),t.warn("Failed to fetch remote config: ".concat(r)),[3,3];case 3:return[2,void 0]}}))}))},[2,{storeRemoteConfig:f,getRemoteConfig:m,getLastFetchedSessionId:v}]}var y}))}))},cr="Remote config fetch rejected due to timeout after 5 seconds",lr=function(){function e(e){var t=e.localConfig,n=e.configKeys,r=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.fetchTime=0,this.getRemoteConfig=function(e,t,n){return a(r,void 0,void 0,(function(){var r,o,i,s,a;return c(this,(function(c){switch(c.label){case 0:return r=Date.now(),this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.getRemoteConfig(e,t)]:[3,3];case 1:return o=c.sent(),[4,this.remoteConfigIDBStore.getLastFetchedSessionId()];case 2:if(i=c.sent(),o&&i===n)return this.fetchTime=Date.now()-r,[2,o];c.label=3;case 3:return[4,this.fetchWithTimeout(n)];case 4:return(s=c.sent())&&(a=s.configs&&s.configs[e])?(this.fetchTime=Date.now()-r,[2,a[t]]):(this.fetchTime=Date.now()-r,[2,void 0])}}))}))},this.fetchWithTimeout=function(e){return a(r,void 0,void 0,(function(){var t,n,r;return c(this,(function(o){switch(o.label){case 0:return t=new AbortController,n=setTimeout((function(){return t.abort()}),5e3),[4,this.fetchRemoteConfig(t.signal,e)];case 1:return r=o.sent(),clearTimeout(n),[2,r]}}))}))},this.fetchRemoteConfig=function(e,t){return a(r,void 0,void 0,(function(){var n,r,o,a,l,u;return c(this,(function(c){switch(c.label){case 0:if(t===this.lastFetchedSessionId&&this.attempts>=this.localConfig.flushMaxRetries)return[2,this.completeRequest({err:"Remote config fetch rejected due to exceeded retry count"})];if(e.aborted)return[2,this.completeRequest({err:cr})];t!==this.lastFetchedSessionId&&(this.lastFetchedSessionId=t,this.attempts=0),c.label=1;case 1:return c.trys.push([1,3,,4]),n=new URLSearchParams({api_key:this.localConfig.apiKey,config_keys:this.configKeys.join(",")}),r={headers:{"Content-Type":"application/json",Accept:"*/*"},method:"GET"},o="".concat(this.getServerUrl(),"?").concat(n.toString()),this.attempts+=1,[4,fetch(o,s(s({},r),{signal:e}))];case 2:if(null===(a=c.sent()))return[2,this.completeRequest({err:"Unexpected error occurred"})];switch((new C).buildStatus(a.status)){case i.Success:return[2,this.parseAndStoreConfig(a,t)];case i.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return l=c.sent(),u=l,e.aborted?[2,this.completeRequest({err:cr})]:[2,this.completeRequest({err:u.message})];case 4:return[2]}}))}))},this.retryFetch=function(e,t){return a(r,void 0,void 0,(function(){var n=this;return c(this,(function(r){switch(r.label){case 0:return[4,new Promise((function(e){return setTimeout(e,n.attempts*n.retryTimeout)}))];case 1:return r.sent(),[2,this.fetchRemoteConfig(e,t)]}}))}))},this.parseAndStoreConfig=function(e,t){return a(r,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:return[4,e.json()];case 1:return n=r.sent(),this.completeRequest({success:"Remote config successfully fetched"}),this.remoteConfigIDBStore&&this.remoteConfigIDBStore.storeRemoteConfig(n,t),[2,n]}}))}))},this.localConfig=t,this.configKeys=n}return e.prototype.initialize=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return e=this,[4,ar({apiKey:this.localConfig.apiKey,loggerProvider:this.localConfig.loggerProvider,configKeys:this.configKeys})];case 1:return e.remoteConfigIDBStore=t.sent(),[2]}}))}))},e.prototype.getServerUrl=function(){return this.localConfig.serverZone===o.STAGING?"https://sr-client-cfg.stag2.amplitude.com/config":this.localConfig.serverZone===o.EU?"https://sr-client-cfg.eu.amplitude.com/config":"https://sr-client-cfg.amplitude.com/config"},e.prototype.completeRequest=function(e){var t=e.err,n=e.success;if(t)throw new Error(t);n&&this.localConfig.loggerProvider.log(n)},e}(),ur=function(e){var t=e.localConfig,n=e.configKeys;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(r){switch(r.label){case 0:return[4,(e=new lr({localConfig:t,configKeys:n})).initialize()];case 1:return r.sent(),[2,e]}}))}))},dr=function(){function e(e,t){this.localConfig=new W(e,t)}return e.prototype.initialize=function(){return a(this,void 0,void 0,(function(){var e;return c(this,(function(t){switch(t.label){case 0:return e=this,[4,ur({localConfig:this.localConfig,configKeys:["sessionReplay"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(e){var t,n,r;return a(this,void 0,void 0,(function(){var o,i,a,d,h,p,f,v,m,g,y,S,b,I,w,C,k,M,E,T;return c(this,(function(c){switch(c.label){case 0:(o=s({},this.localConfig)).optOut=this.localConfig.optOut,o.captureEnabled=!0,c.label=1;case 1:return c.trys.push([1,5,,6]),this.remoteConfigFetch?[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)]:[2,o];case 2:return a=c.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return d=c.sent(),h=o,[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_interaction_config",e)];case 4:return h.interactionConfig=c.sent(),(a||d)&&(i={},a&&(i.sr_sampling_config=a),d&&(i.sr_privacy_config=d)),[3,6];case 5:return p=c.sent(),f=p,this.localConfig.loggerProvider.warn(f.message),o.captureEnabled=!0,[3,6];case 6:if(!i)return[2,o];if(v=i.sr_sampling_config,m=i.sr_privacy_config,v&&Object.keys(v).length>0?(Object.prototype.hasOwnProperty.call(v,"capture_enabled")?o.captureEnabled=v.capture_enabled:o.captureEnabled=!1,v.sample_rate&&(o.sampleRate=v.sample_rate)):(o.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),m){g=null!==(t=o.privacyConfig)&&void 0!==t?t:{},y={defaultMaskLevel:null!==(r=null!==(n=m.defaultMaskLevel)&&void 0!==n?n:g.defaultMaskLevel)&&void 0!==r?r:"medium",blockSelector:[],maskSelector:[],unmaskSelector:[]},S=function(e){var t,n,r,o,i,s,a,c,u,d={};"string"==typeof e.blockSelector&&(e.blockSelector=[e.blockSelector]);try{for(var h=l(null!==(a=e.blockSelector)&&void 0!==a?a:[]),p=h.next();!p.done;p=h.next()){d[p.value]="block"}}catch(e){t={error:e}}finally{try{p&&!p.done&&(n=h.return)&&n.call(h)}finally{if(t)throw t.error}}try{for(var f=l(null!==(c=e.maskSelector)&&void 0!==c?c:[]),v=f.next();!v.done;v=f.next()){d[v.value]="mask"}}catch(e){r={error:e}}finally{try{v&&!v.done&&(o=f.return)&&o.call(f)}finally{if(r)throw r.error}}try{for(var m=l(null!==(u=e.unmaskSelector)&&void 0!==u?u:[]),g=m.next();!g.done;g=m.next()){d[g.value]="unmask"}}catch(e){i={error:e}}finally{try{g&&!g.done&&(s=m.return)&&s.call(m)}finally{if(i)throw i.error}}return d},b=s(s({},S(g)),S(m));try{for(I=l(Object.entries(b)),w=I.next();!w.done;w=I.next())C=u(w.value,2),k=C[0],"mask"===(M=C[1])?y.maskSelector.push(k):"block"===M?y.blockSelector.push(k):"unmask"===M&&y.unmaskSelector.push(k)}catch(e){E={error:e}}finally{try{w&&!w.done&&(T=I.return)&&T.call(I)}finally{if(E)throw E.error}}o.privacyConfig=y}return[2,o]}}))}))},e}(),hr=function(e,t){return a(void 0,void 0,void 0,(function(){var n;return c(this,(function(r){switch(r.label){case 0:return[4,(n=new dr(e,t)).initialize()];case 1:return r.sent(),[2,n]}}))}))},pr="Session replay event batch rejected due to exceeded retry count",fr="Failed to store session replay events in IndexedDB";!function(e){e.RECORDING="recording",e.SENT="sent"}(ir||(ir={}));var vr,mr="sessionCurrentSequence",gr="sequencesToSend",yr=function(){var e=_();return new Promise((function(t,n){if(!e)return n(new Error("Global scope not found"));if(!e.indexedDB)return n(new Error("Session Replay: cannot find indexedDB"));try{var r=e.indexedDB.open("keyval-store");r.onupgradeneeded=function(){1===r.result.version&&(r.result.close(),r.transaction&&r.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},r.onsuccess=function(){t(r.result)}}catch(e){n(e)}}))},Sr=function(e){return a(void 0,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return e.length>0?(10,t=e.splice(0,10),[4,Promise.all(t)]):[3,2];case 1:return n.sent(),[3,0];case 2:return[2]}}))}))},br=function(e){var t,n;return e.objectStoreNames.contains(mr)||(n=e.createObjectStore(mr,{keyPath:"sessionId"})),e.objectStoreNames.contains(gr)||(t=e.createObjectStore(gr,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},Ir=function(e){return a(void 0,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,Kn(e,1,{upgrade:br})];case 1:return[2,t.sent()]}}))}))},wr=function(){function e(e){var t=e.loggerProvider,n=e.apiKey,r=e.minInterval,o=e.maxInterval,i=this;this.storageKey="",this.maxPersistedEventsSize=1e6,this.timeAtLastSplit=null,this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=i.maxPersistedEventsSize||!!(null!==i.timeAtLastSplit&&i.interval&&Date.now()-i.timeAtLastSplit>i.interval&&e.length)&&(i.interval=Math.min(i.maxInterval,i.interval+i.minInterval),i.timeAtLastSplit=Date.now(),!0)},this.getSequencesToSend=function(){return a(i,void 0,void 0,(function(){var e,t;return c(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,null===(t=this.db)||void 0===t?void 0:t.getAll(gr)];case 1:return[2,n.sent()];case 2:return e=n.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},this.storeCurrentSequence=function(e){return a(i,void 0,void 0,(function(){var t,n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,4,,5]),this.db?[4,this.db.get(mr,e)]:[2,void 0];case 1:return(t=o.sent())?[4,this.db.put(gr,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=o.sent(),[4,this.db.put(mr,{sessionId:e,events:[]})];case 3:return o.sent(),[2,s(s({},t),{sessionId:e,sequenceId:n})];case 4:return r=o.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(r)),[3,5];case 5:return[2,void 0]}}))}))},this.addEventToCurrentSequence=function(e,t){return a(i,void 0,void 0,(function(){var n,r,o,i,s,a,l;return c(this,(function(c){switch(c.label){case 0:0===this.interval&&(this.interval=this.minInterval),c.label=1;case 1:return c.trys.push([1,11,,12]),(n=null===(l=this.db)||void 0===l?void 0:l.transaction(mr,"readwrite"))?[4,n.store.get(e)]:[2];case 2:return(r=c.sent())?[3,4]:[4,n.store.put({sessionId:e,events:[t]})];case 3:return c.sent(),[2];case 4:return o=void 0,this.shouldSplitEventsList(r.events,t)?(o=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,6];case 5:return c.sent(),[3,8];case 6:return i=r.events.concat(t),[4,n.store.put({sessionId:e,events:i})];case 7:c.sent(),c.label=8;case 8:return[4,n.done];case 9:return c.sent(),o?[4,this.storeSendingEvents(e,o)]:[2,void 0];case 10:return(s=c.sent())?[2,{events:o,sessionId:e,sequenceId:s}]:[2,void 0];case 11:return a=c.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(a)),[3,12];case 12:return[2,void 0]}}))}))},this.storeSendingEvents=function(e,t){return a(i,void 0,void 0,(function(){var n,r;return c(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,null===(r=this.db)||void 0===r?void 0:r.put(gr,{sessionId:e,events:t})];case 1:return[2,o.sent()];case 2:return n=o.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},this.cleanUpSessionEventsStore=function(e){return a(i,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,null===(n=this.db)||void 0===n?void 0:n.delete(gr,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.loggerProvider.warn("".concat(fr,": ").concat(t)),[3,3];case 3:return[2]}}))}))},this.transitionFromKeyValStore=function(e){return a(i,void 0,void 0,(function(){var t,n,r,o,i,s,l,u,d=this;return c(this,(function(p){switch(p.label){case 0:return p.trys.push([0,6,,7]),[4,yr()];case 1:if(!(t=p.sent()))return[2];n=function(e,t){return a(d,void 0,void 0,(function(){var n,r,o=this;return c(this,(function(i){switch(i.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach((function(i){var s=parseInt(i,10),l=n[s];if(s===t.currentSequenceId){var u=l.events.map((function(t){return a(o,void 0,void 0,(function(){return c(this,(function(n){return[2,this.addEventToCurrentSequence(e,t)]}))}))}));r.concat(u)}else l.status!==ir.SENT&&r.push(o.storeSendingEvents(e,l.events))})),[4,Sr(r)];case 1:return i.sent(),[2]}}))}))},r="".concat(h,"_").concat(this.apiKey.substring(0,10)),p.label=2;case 2:return p.trys.push([2,4,,5]),o=t.transaction("keyval").objectStore("keyval").getAll(r),i=new Promise((function(t){o.onsuccess=function(r){return a(d,void 0,void 0,(function(){var o,i,s,a=this;return c(this,(function(c){switch(c.label){case 0:return o=r&&r.target.result,(i=o&&o[0])?(s=[],Object.keys(i).forEach((function(t){var r=parseInt(t,10),o=i[r];if(e===r)s.push(n(r,o));else{var c=o.sessionSequences;Object.keys(c).forEach((function(e){var t=parseInt(e,10);c[t].status!==ir.SENT&&s.push(a.storeSendingEvents(r,c[t].events))}))}})),[4,Sr(s)]):[3,2];case 1:c.sent(),c.label=2;case 2:return t(),[2]}}))}))}})),[4,i];case 3:return p.sent(),(s=_())&&s.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return l=p.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(l)),[3,5];case 5:return[3,7];case 6:return u=p.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(u,". For more information, visit: https://www.docs.developers.amplitude.com/session-replay/sdks/standalone/#indexeddb-best-practices")),[3,7];case 7:return[2]}}))}))},this.loggerProvider=t,this.apiKey=n,this.maxInterval=null!=o?o:1e4,this.minInterval=null!=r?r:500,this.interval=0}return e.prototype.initialize=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return n="replay"===e?"":"_".concat(e),r="".concat(this.apiKey.substring(0,10),"_amp_session_replay_events").concat(n),o=this,[4,Ir(r)];case 1:return o.db=i.sent(),this.timeAtLastSplit=Date.now(),[4,this.transitionFromKeyValStore(t)];case 2:return i.sent(),[2]}}))}))},e}(),Cr=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.sessionId,o=e.type,i=e.minInterval,s=e.maxInterval;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(a){switch(a.label){case 0:return[4,(e=new wr({loggerProvider:t,apiKey:n,minInterval:i,maxInterval:s})).initialize(o,r)];case 1:return a.sent(),[2,e]}}))}))},kr="medium";!function(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"}(vr||(vr={}));var Mr=function(e,t,n){switch(t){case"light":if("input"!==e)return!0;var r=n?function(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?t.toLowerCase():null}(n):"";return!!r&&(!!["password","hidden","email","tel"].includes(r)||!!n.autocomplete.startsWith("cc-"));case"medium":case"conservative":return!0;default:return Mr(e,kr,n)}},Er=function(e,t){return function(n,r){return function(e,t,n){var r,o,i;if(void 0===t&&(t={defaultMaskLevel:kr}),n){if(n.closest("."+q))return!0;var s=(null!==(r=t.maskSelector)&&void 0!==r?r:[]).some((function(e){return n.closest(e)}));if(s)return!0;if(n.closest(".amp-unmask"))return!1;var a=(null!==(o=t.unmaskSelector)&&void 0!==o?o:[]).some((function(e){return n.closest(e)}));if(a)return!1}return Mr(e,null!==(i=t.defaultMaskLevel)&&void 0!==i?i:kr,n)}(e,t,r)?n.replace(/[^\s]/g,"*"):n}},Tr=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),t|=0}return t},Or=function(){function e(e){var t=e.loggerProvider,n=e.payloadBatcher;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=t,this.payloadBatcher=n||function(e){return e}}return e.prototype.sendEventsList=function(e){this.addToQueue(s(s({},e),{attempts:0,timeout:0}))},e.prototype.getServerUrl=function(e){return e===o.STAGING?"https://api-sr.stag2.amplitude.com/sessions/v2/track":e===o.EU?"https://api-sr.eu.amplitude.com/sessions/v2/track":"https://api-sr.amplitude.com/sessions/v2/track"},e.prototype.addToQueue=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var r=t.filter((function(t){return t.attempts<(t.flushMaxRetries||0)?(t.attempts+=1,!0):(e.completeRequest({context:t,err:"".concat(pr,", batch sequence id, ").concat(t.sequenceId)}),!1)}));r.forEach((function(t){e.queue=e.queue.concat(t),0!==t.timeout?setTimeout((function(){t.timeout=0,e.schedule(0)}),t.timeout):e.schedule(0)}))},e.prototype.schedule=function(e){var t=this;this.scheduled||(this.scheduled=setTimeout((function(){t.flush(!0).then((function(){t.queue.length>0&&t.schedule(e)}))}),e))},e.prototype.flush=function(e){return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){var t,n,r=this;return c(this,(function(o){switch(o.label){case 0:return t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),this.queue=n,this.scheduled&&(clearTimeout(this.scheduled),this.scheduled=null),[4,Promise.all(t.map((function(t){return r.send(t,e)})))];case 1:return o.sent(),[2]}}))}))},e.prototype.send=function(e,t){return void 0===t&&(t=!0),a(this,void 0,void 0,(function(){var n,r,o,i,s,a,l,u,d,h,p,f;return c(this,(function(c){switch(c.label){case 0:if(!(n=e.apiKey))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing api key"})];if(!(r=e.deviceId))return[2,this.completeRequest({context:e,err:"Session replay event batch not sent due to missing device ID"})];if(v=_(),o=(null==v?void 0:v.location)?v.location.href:"",i="0.2.5",s=e.sampleRate,a=new URLSearchParams({device_id:r,session_id:"".concat(e.sessionId),seq_number:"".concat(e.sequenceId),type:"".concat(e.type)}),0===(l=this.payloadBatcher({version:1,events:e.events})).events.length)return this.completeRequest({context:e}),[2];c.label=1;case 1:return c.trys.push([1,3,,4]),u={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(n),"X-Client-Version":i,"X-Client-Url":o,"X-Client-Sample-Rate":"".concat(s)},body:JSON.stringify(l),method:"POST"},d="".concat(this.getServerUrl(e.serverZone),"?").concat(a.toString()),[4,fetch(d,u)];case 2:if(null===(h=c.sent()))return this.completeRequest({context:e,err:"Unexpected error occurred"}),[2];if(t)this.handleReponse(h.status,e);else{p="";try{p=JSON.stringify(h.body,null,2)}catch(e){}this.completeRequest({context:e,success:"".concat(h.status,": ").concat(p)})}return[3,4];case 3:return f=c.sent(),this.completeRequest({context:e,err:f}),[3,4];case 4:return[2]}var v}))}))},e.prototype.handleReponse=function(e,t){switch((new C).buildStatus(e)){case i.Success:this.handleSuccessResponse(t);break;case i.Failed:this.handleOtherResponse(t);break;default:this.completeRequest({context:t,err:"Network error occurred, event batch rejected"})}},e.prototype.handleSuccessResponse=function(e){var t;this.completeRequest({context:e,success:(t=e.sessionId,"Session replay event batch tracked successfully for session id ".concat(t))})},e.prototype.handleOtherResponse=function(e){this.addToQueue(s(s({},e),{timeout:e.attempts*this.retryTimeout}))},e.prototype.completeRequest=function(e){var t=e.context,n=e.err,r=e.success;t.onComplete(t.sequenceId),n?this.loggerProvider.warn(n):r&&this.loggerProvider.log(r)},e}(),Rr=function(e){var t=e.config,n=e.sessionId,r=e.minInterval,o=e.maxInterval,i=e.type,s=e.payloadBatcher;return a(void 0,void 0,void 0,(function(){function e(e){return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){return c(this,(function(t){return[2,l.flush(e)]}))}))}var l,u,d,h,p,f;return c(this,(function(v){switch(v.label){case 0:return l=new Or({loggerProvider:t.loggerProvider,payloadBatcher:s}),[4,Cr({loggerProvider:t.loggerProvider,apiKey:t.apiKey,sessionId:n,minInterval:r,maxInterval:o,type:i})];case 1:return u=v.sent(),d=function(e){var n=e.events,r=e.sessionId,o=e.deviceId,s=e.sequenceId;l.sendEventsList({events:n,sequenceId:s,sessionId:r,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:o,sampleRate:t.sampleRate,serverZone:t.serverZone,type:i,onComplete:u.cleanUpSessionEventsStore.bind(u)})},h=function(e){var n=e.sessionId,r=e.deviceId;u.storeCurrentSequence(n).then((function(e){e&&d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:r})})).catch((function(e){t.loggerProvider.warn("Failed to get current sequence of session replay events for session:",e)}))},p=function(e){var t=e.deviceId;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(n){switch(n.label){case 0:return[4,u.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},f=function(e){var n=e.event,r=e.sessionId,o=e.deviceId;u.addEventToCurrentSequence(r,n.data).then((function(e){return e&&d({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:o})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:h,addEvent:f,sendStoredEvents:p,flush:e}]}}))}))},xr=function(e){var t=e.sessionId,n=e.deviceId;this.deviceId=n,this.sessionId=t,t&&n&&(this.sessionReplayId=function(e,t){return"".concat(t,"/").concat(e)}(t,n))},Dr=(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))(Dr||{});let Nr,Lr,_r;function Pr(e,t){if(_r=new Date,e.nodeType!==Node.ELEMENT_NODE)throw new Error("Can't generate CSS selector for non-element node type.");if("html"===e.tagName.toLowerCase())return"html";const n={root:document.body,idName:e=>!0,className:e=>!0,tagName:e=>!0,attr:(e,t)=>!1,seedMinLength:1,optimizedMinLength:2,threshold:1e3,maxNumberOfTries:1e4,timeoutMs:void 0};Nr={...n,...t},Lr=function(e,t){if(e.nodeType===Node.DOCUMENT_NODE)return e;if(e===t.root)return e.ownerDocument;return e}(Nr.root,n);let r=Ar(e,"all",(()=>Ar(e,"two",(()=>Ar(e,"one",(()=>Ar(e,"none")))))));if(r){const t=Yr(Xr(r,e));return t.length>0&&(r=t[0]),jr(r)}throw new Error("Selector was not found.")}function Ar(e,t,n){let r=null,o=[],i=e,s=0;for(;i;){const e=(new Date).getTime()-_r.getTime();if(void 0!==Nr.timeoutMs&&e>Nr.timeoutMs)throw new Error(`Timeout: Can't find a unique selector after ${e}ms`);let a=$r(Br(i))||$r(...Wr(i))||$r(...zr(i))||$r(Gr(i))||[{name:"*",penalty:3}];const c=Vr(i);if("all"==t)c&&(a=a.concat(a.filter(Hr).map((e=>Kr(e,c)))));else if("two"==t)a=a.slice(0,1),c&&(a=a.concat(a.filter(Hr).map((e=>Kr(e,c)))));else if("one"==t){const[e]=a=a.slice(0,1);c&&Hr(e)&&(a=[Kr(e,c)])}else"none"==t&&(a=[{name:"*",penalty:3}],c&&(a=[Kr(a[0],c)]));for(let e of a)e.level=s;if(o.push(a),o.length>=Nr.seedMinLength&&(r=Fr(o,n),r))break;i=i.parentElement,s++}return r||(r=Fr(o,n)),!r&&n?n():r}function Fr(e,t){const n=Yr(Jr(e));if(n.length>Nr.threshold)return t?t():null;for(let e of n)if(qr(e))return e;return null}function jr(e){let t=e[0],n=t.name;for(let r=1;r<e.length;r++){const o=e[r].level||0;n=t.level===o-1?`${e[r].name} > ${n}`:`${e[r].name} ${n}`,t=e[r]}return n}function Ur(e){return e.map((e=>e.penalty)).reduce(((e,t)=>e+t),0)}function qr(e){const t=jr(e);switch(Lr.querySelectorAll(t).length){case 0:throw new Error(`Can't select any node with this selector: ${t}`);case 1:return!0;default:return!1}}function Br(e){const t=e.getAttribute("id");return t&&Nr.idName(t)?{name:"#"+CSS.escape(t),penalty:0}:null}function Wr(e){const t=Array.from(e.attributes).filter((e=>Nr.attr(e.name,e.value)));return t.map((e=>({name:`[${CSS.escape(e.name)}="${CSS.escape(e.value)}"]`,penalty:.5})))}function zr(e){return Array.from(e.classList).filter(Nr.className).map((e=>({name:"."+CSS.escape(e),penalty:1})))}function Gr(e){const t=e.tagName.toLowerCase();return Nr.tagName(t)?{name:t,penalty:2}:null}function Vr(e){const t=e.parentNode;if(!t)return null;let n=t.firstChild;if(!n)return null;let r=0;for(;n&&(n.nodeType===Node.ELEMENT_NODE&&r++,n!==e);)n=n.nextSibling;return r}function Kr(e,t){return{name:e.name+`:nth-child(${t})`,penalty:e.penalty+1}}function Hr(e){return"html"!==e.name&&!e.name.startsWith("#")}function $r(...e){const t=e.filter(Zr);return t.length>0?t:null}function Zr(e){return null!=e}function*Jr(e,t=[]){if(e.length>0)for(let n of e[0])yield*Jr(e.slice(1,e.length),t.concat(n));else yield t}function Yr(e){return[...e].sort(((e,t)=>Ur(e)-Ur(t)))}function*Xr(e,t,n={counter:0,visited:new Map}){if(e.length>2&&e.length>Nr.optimizedMinLength)for(let r=1;r<e.length-1;r++){if(n.counter>Nr.maxNumberOfTries)return;n.counter+=1;const o=[...e];o.splice(r,1);const i=jr(o);if(n.visited.has(i))return;qr(o)&&Qr(o,t)&&(yield o,n.visited.set(i,!0),yield*Xr(o,t,n))}}function Qr(e,t){return Lr.querySelector(jr(e))===t}var eo=function(e){var t=e.version,n=e.events,r=[];n.forEach((function(e){var t=JSON.parse(e);"click"===t.type&&r.push(t)}));var o=r.reduce((function(e,t){var n=t.x,r=t.y,o=t.selector,i=t.timestamp,a=i-i%36e5,c="".concat(n,":").concat(r,":").concat(null!=o?o:"",":").concat(a);return e[c]?e[c].count+=1:e[c]=s(s({},t),{timestamp:a,count:1}),e}),{});return{version:t,events:Object.values(o)}},to=function(e){var t=e.eventsManager,n=e.sessionId,r=e.deviceIdFn;return function(e){if(e.type===Dr.Click){var o=_();if(o){var i=o.location,s=o.innerHeight,a=o.innerWidth;if(i){var c,l=e.x,u=e.y,d=$t.mirror.getNode(e.id);d&&(c=Pr(d));var h=Le(o),p={x:l+h.left,y:u+h.top,selector:c,viewportHeight:s,viewportWidth:a,pageUrl:i.href,timestamp:Date.now(),type:"click"},f=r();f&&t.addEvent({sessionId:n,event:{type:"interaction",data:JSON.stringify(p)},deviceId:f})}}}}},no=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 a(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return t=[],this.managers.forEach((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,o=e.deviceId;null===(t=this.managers.get(r.type))||void 0===t||t.addEvent({sessionId:n,event:r,deviceId:o})},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 a(this,void 0,void 0,(function(){var t;return c(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}(),ro=function(){function e(){var e=this;this.name="@amplitude/session-replay-browser",this.recordCancelCallback=null,this.blurListener=function(){e.stopRecordingAndSendEvents()},this.focusListener=function(){e.initialize()},this.stopRecordingEvents=function(){try{e.recordCancelCallback&&e.recordCancelCallback(),e.recordCancelCallback=null}catch(n){var t=n;e.loggerProvider.warn("Error occurred while stopping recording: ".concat(t.toString()))}},this.loggerProvider=new m}return e.prototype.init=function(e,t){return f(this._init(e,t))},e.prototype.removeInvalidSelectors=function(){var e,t=this;if(null===(e=this.config)||void 0===e?void 0:e.privacyConfig){var n=document.createDocumentFragment(),r=function(e){if(void 0===e&&(e=[]),"string"==typeof e&&(e=[e]),e=e.filter((function(e){try{n.querySelector(e)}catch(n){return t.loggerProvider.warn('[session-replay-browser] omitting selector "'.concat(e,'" because it is invalid')),!1}return!0})),0!==e.length)return e};this.config.privacyConfig.blockSelector=r(this.config.privacyConfig.blockSelector),this.config.privacyConfig.maskSelector=r(this.config.privacyConfig.maskSelector),this.config.privacyConfig.unmaskSelector=r(this.config.privacyConfig.unmaskSelector)}},e.prototype._init=function(e,t){var n,r;return a(this,void 0,void 0,(function(){var o,i,s,a,l,h;return c(this,(function(c){switch(c.label){case 0:return this.loggerProvider=t.loggerProvider||new m,this.identifiers=new xr({sessionId:t.sessionId,deviceId:t.deviceId}),o=this,[4,hr(e,t)];case 1:return o.joinedConfigGenerator=c.sent(),i=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:return i.config=c.sent(),this.loggerProvider.debug(JSON.stringify({name:"session replay joined privacy config",privacyConfig:this.config.privacyConfig},null,2)),this.removeInvalidSelectors(),s=[],[4,Rr({config:this.config,sessionId:this.identifiers.sessionId,type:"replay"})];case 3:return a=c.sent(),s.push({name:"replay",manager:a}),(null===(n=this.config.interactionConfig)||void 0===n?void 0:n.enabled)?[4,Rr({config:this.config,sessionId:this.identifiers.sessionId,type:"interaction",minInterval:null!==(r=this.config.interactionConfig.trackEveryNms)&&void 0!==r?r:3e4,maxInterval:6e4,payloadBatcher:eo})]:[3,5];case 4:l=c.sent(),s.push({name:"interaction",manager:l}),c.label=5;case 5:return this.eventsManager=new(no.bind.apply(no,d([void 0],u(s),!1))),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),(h=_())&&(h.removeEventListener("blur",this.blurListener),h.removeEventListener("focus",this.focusListener),h.addEventListener("blur",this.blurListener),h.addEventListener("focus",this.focusListener)),h&&h.document&&h.document.hasFocus()&&this.initialize(!0),[2]}}))}))},e.prototype.setSessionId=function(e,t){return f(this.asyncSetSessionId(e,t))},e.prototype.asyncSetSessionId=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o;return c(this,(function(i){switch(i.label){case 0:return(n=this.identifiers&&this.identifiers.sessionId)&&this.stopRecordingAndSendEvents(n),r=t||this.getDeviceId(),this.identifiers=new xr({sessionId:e,deviceId:r}),this.joinedConfigGenerator&&n?(o=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]):[3,2];case 1:o.config=i.sent(),i.label=2;case 2:return this.recordEvents(),[2]}}))}))},e.prototype.getSessionReplayDebugPropertyValue=function(){var e="";return this.config&&(e=Tr(this.config.apiKey).toString()),JSON.stringify({appHash:e})},e.prototype.getSessionReplayProperties=function(){var e;if(!this.config||!this.identifiers)return this.loggerProvider.error("Session replay init has not been called, cannot get session recording properties."),{};var t=!!this.config.debugMode;if(this.getShouldRecord(t)){var n=((e={})[F]=this.identifiers.sessionReplayId?this.identifiers.sessionReplayId:null,e);return this.config.debugMode&&(n[U]=this.getSessionReplayDebugPropertyValue()),n}return{}},e.prototype.stopRecordingAndSendEvents=function(e){var t;this.stopRecordingEvents();var n=e||(null===(t=this.identifiers)||void 0===t?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;if(void 0===e&&(e=!1),null===(t=this.identifiers)||void 0===t?void 0:t.sessionId){var n=this.getDeviceId();n?(this.eventsManager&&e&&this.eventsManager.sendStoredEvents({deviceId:n}),this.recordEvents()):this.loggerProvider.log("Session is not being recorded due to lack of device id.")}else this.loggerProvider.log("Session is not being recorded due to lack of session id.")},e.prototype.shouldOptOut=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=L(this.config.instanceName).identityStore.getIdentity().optOut);return void 0!==n?n:null===(t=this.config)||void 0===t?void 0:t.optOut},e.prototype.getShouldRecord=function(e){if(void 0===e&&(e=!1),!this.identifiers||!this.config||!this.identifiers.sessionId)return this.loggerProvider.error("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.")),!1;var t=_();if(!e&&t&&t.document&&!t.document.hasFocus())return this.loggerProvider.log("Session ".concat(this.identifiers.sessionId," temporarily not recording due to lack of browser focus.")),!1;if(this.shouldOptOut())return this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to optOut config.")),!1;var n,r,o,i=(n=this.identifiers.sessionId,r=this.config.sampleRate,o=Tr(n.toString()),31*Math.abs(o)%100/100<r);return i||this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate.")),i},e.prototype.getBlockSelectors=function(){var e,t,n,r=null!==(n=null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector)&&void 0!==n?n:[];if(0!==r.length)return r},e.prototype.getMaskTextSelectors=function(){var e,t,n,r;if("conservative"===(null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.defaultMaskLevel))return"*";var o=null===(r=null===(n=this.config)||void 0===n?void 0:n.privacyConfig)||void 0===r?void 0:r.maskSelector;return o||void 0},e.prototype.recordEvents=function(){var e,t=this,n=this.getShouldRecord(),r=null===(e=this.identifiers)||void 0===e?void 0:e.sessionId;if(n&&r&&this.config){this.stopRecordingEvents();var o=this.config.privacyConfig;this.recordCancelCallback=$t({emit:function(e){var n=_();if(n&&n.document&&!n.document.hasFocus()||!t.getShouldRecord())t.stopRecordingAndSendEvents();else{var o=JSON.stringify(e),i=t.getDeviceId();t.eventsManager&&i&&t.eventsManager.addEvent({event:{type:"replay",data:o},sessionId:r,deviceId:i})}},packFn:Dn,inlineStylesheet:this.config.shouldInlineStylesheet,hooks:{mouseInteraction:this.eventsManager&&to({eventsManager:this.eventsManager,sessionId:r,deviceIdFn:this.getDeviceId.bind(this)})},maskAllInputs:!0,maskTextClass:q,blockClass:"amp-block",blockSelector:this.getBlockSelectors(),maskInputFn:Er("input",o),maskTextFn:Er("text",o),maskTextSelector:this.getMaskTextSelectors(),recordCanvas:!1,errorHandler:function(e){var n=e;if(n.message.includes("insertRule")&&n.message.includes("CSSStyleSheet"))throw n;if(n._external_)throw n;return t.loggerProvider.warn("Error while recording: ",n.toString()),!0}})}},e.prototype.getDeviceId=function(){var e,t,n;(null===(e=this.config)||void 0===e?void 0:e.instanceName)&&(n=L(this.config.instanceName).identityStore.getIdentity().deviceId);return n||(null===(t=this.identifiers)||void 0===t?void 0:t.deviceId)},e.prototype.getSessionId=function(){var e;return null===(e=this.identifiers)||void 0===e?void 0:e.sessionId},e.prototype.flush=function(e){var t;return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){return c(this,(function(n){return[2,null===(t=this.eventsManager)||void 0===t?void 0:t.flush(e)]}))}))},e.prototype.shutdown=function(){var e=_();e&&(e.removeEventListener("blur",this.blurListener),e.removeEventListener("focus",this.focusListener)),this.stopRecordingAndSendEvents()},e}(),oo=function(e){return function(){var t=e.config||B();return{logger:t.loggerProvider,logLevel:t.logLevel}}},io=function(){var e=new ro;return{init:w(e.init.bind(e),"init",oo(e)),setSessionId:w(e.setSessionId.bind(e),"setSessionId",oo(e)),getSessionId:w(e.getSessionId.bind(e),"getSessionId",oo(e)),getSessionReplayProperties:w(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",oo(e)),flush:w(e.flush.bind(e),"flush",oo(e)),shutdown:w(e.shutdown.bind(e),"shutdown",oo(e))}}(),so=io.init,ao=io.setSessionId,co=io.getSessionId,lo=io.getSessionReplayProperties,uo=io.flush,ho=io.shutdown,po="@amplitude/plugin-session-replay-enrichment-browser",fo=function(){function e(){this.name=po,this.type="enrichment"}return e.prototype.setup=function(e,t){return a(this,void 0,void 0,(function(){return c(this,(function(t){return this.config=e,[2]}))}))},e.prototype.execute=function(e){return a(this,void 0,void 0,(function(){var t;return c(this,(function(n){switch(n.label){case 0:return this.config.sessionId&&this.config.sessionId!==co()?[4,ao(this.config.sessionId).promise]:[3,2];case 1:n.sent(),n.label=2;case 2:return this.config.sessionId&&this.config.sessionId===e.session_id&&(t=lo(),e.event_properties=s(s({},e.event_properties),t)),[2,Promise.resolve(e)]}}))}))},e}(),vo=function(){function e(e){this.name="@amplitude/plugin-session-replay-browser",this.type="destination",this.options=s({},e),!1!==this.options.forceSessionTracking&&(this.options.forceSessionTracking=!0)}return e.prototype.setup=function(e,t){var n,r,o,i;return a(this,void 0,void 0,(function(){return c(this,(function(a){switch(a.label){case 0:return t?(e.loggerProvider.log("Installing @amplitude/plugin-session-replay."),this.clientRemove=t.remove.bind(t),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=s(s({},e.defaultTracking),{sessions:!0})),[4,so(e.apiKey,{instanceName:this.config.instanceName,deviceId:this.config.deviceId,optOut:this.config.optOut,sessionId:this.config.sessionId,loggerProvider:this.config.loggerProvider,logLevel:this.config.logLevel,flushMaxRetries:this.config.flushMaxRetries,serverZone:this.config.serverZone,sampleRate:this.options.sampleRate,privacyConfig:{blockSelector:null===(n=this.options.privacyConfig)||void 0===n?void 0:n.blockSelector,maskSelector:null===(r=this.options.privacyConfig)||void 0===r?void 0:r.maskSelector,unmaskSelector:null===(o=this.options.privacyConfig)||void 0===o?void 0:o.unmaskSelector,defaultMaskLevel:null===(i=this.options.privacyConfig)||void 0===i?void 0:i.defaultMaskLevel},debugMode:this.options.debugMode,configEndpointUrl:this.options.configEndpointUrl,shouldInlineStylesheet:this.options.shouldInlineStylesheet}).promise]):(e.loggerProvider.error("SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK."),[2]);case 1:return a.sent(),[4,t.add(new fo).promise];case 2:return a.sent(),[2]}}))}))},e.prototype.execute=function(e){return a(this,void 0,void 0,(function(){return c(this,(function(t){return[2,Promise.resolve({event:e,code:200,message:"success"})]}))}))},e.prototype.flush=function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,uo(!1)];case 1:return e.sent(),[2]}}))}))},e.prototype.teardown=function(){return a(this,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,this.clientRemove(po).promise];case 1:return e.sent(),ho(),this.config=null,this.clientRemove=null,[2]}}))}))},e.prototype.getSessionReplayProperties=function(){return lo()},e}(),mo=function(e){return new vo(e)};return e.plugin=mo,e.sessionReplayPlugin=mo,Object.defineProperty(e,"__esModule",{value:!0}),e}({});