@amplitude/plugin-session-replay-browser 1.3.1 → 1.3.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,s,i=function(){return i=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},i.apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,a)}c((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)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 i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}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 u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;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"}(s||(s={}));var d="".concat("AMP","_unsent"),h="https://api2.amplitude.com/2/httpapi",p=function(e){return{promise:e||Promise.resolve()}},f="Amplitude Logger ",v=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(f,"[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(f,"[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(f,"[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(f,"[Debug]: ").concat(e.join(" ")))},e}(),m=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:r.Warn,loggerProvider:new v,optOut:!1,serverUrl:h,serverZone:o.US,useBatch:!1}},g=function(){function e(e){var t,n,r,o;this._optOut=!1;var s=m();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:s.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||s.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||s.flushQueueSize,this.instanceName=e.instanceName||s.instanceName,this.loggerProvider=e.loggerProvider||s.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:s.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:s.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||s.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:s.useBatch,this.loggerProvider.enable(this.logLevel);var i=S(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=i.serverZone,this.serverUrl=i.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),y=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":h},S=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=m().serverZone),void 0===n&&(n=m().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:m().serverZone;return{serverZone:r,serverUrl:y(r,n)}},b=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},I=function(e,t,n,o,s){return void 0===s&&(s=null),function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var c=n(),u=c.logger,l=c.logLevel;if(l&&l<r.Debug||!l||!u)return e.apply(s,i);var d={type:"invoke public method",name:t,args:i,stacktrace:b(1),time:{start:(new Date).toISOString()},states:{}};o&&d.states&&(d.states.before=o());var h=e.apply(s,i);return h&&h.promise?h.promise.then((function(){o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),u.debug(JSON.stringify(d,null,2))})):(o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),u.debug(JSON.stringify(d,null,2))),h}},w=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,i,a,c,u,l,d,h,p,f,v,m,g,y,S,b,I,w,C;if("object"!=typeof e)return null;var M=e.code||0,k=this.buildStatus(M);switch(k){case s.Success:return{status:k,statusCode:M,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 s.Invalid:return{status:k,statusCode:M,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",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!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(l=e.eps_threshold)&&void 0!==l?l: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 s.PayloadTooLarge:return{status:k,statusCode:M,body:{error:null!==(m=e.error)&&void 0!==m?m:""}};case s.RateLimit:return{status:k,statusCode:M,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 s.Timeout:default:return{status:k,statusCode:M}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?s.Success:429===e?s.RateLimit:413===e?s.PayloadTooLarge:408===e?s.Timeout:e>=400&&e<500?s.Invalid:e>=500?s.Failed:s.Unknown},e}(),C=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)||""},k=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}(),E=function(){return E=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},E.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 s=Array.isArray(e),i=Array.isArray(t);if(s!==i)return!1;if(!s||!i){var a=Object.keys(e).sort(),c=Object.keys(t).sort();if(!O(a,c))return!1;var u=!0;return Object.keys(e).forEach((function(n){O(e[n],t[n])||(u=!1)})),u}for(var l=0;l<e.length;l++)if(!O(e[l],t[l]))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 T,R=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=E({},this.identity.userProperties),n=E(E({},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 s=o[r],i=s[0],a=s[1];switch(i){case"$set":for(var c=0,u=Object.entries(a);c<u.length;c++){var l=u[c],d=l[0],h=l[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 E({},this.identity)},e.prototype.setIdentity=function(e){var t=E({},this.identity);this.identity=E({},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}(),x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,D=function(){function e(){this.identityStore=new R,this.eventBridge=new k,this.applicationContextProvider=new C}return e.getInstance=function(t){return x.analyticsConnectorInstances||(x.analyticsConnectorInstances={}),x.analyticsConnectorInstances[t]||(x.analyticsConnectorInstances[t]=new e),x.analyticsConnectorInstances[t]},e}(),N=function(e){return void 0===e&&(e="$default_instance"),D.getInstance(e)},L=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},_=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(s){switch(s.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=s.sent()).text()];case 2:o=s.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(w),P="[Amplitude]",A="".concat(P," Session Replay ID"),F=o.US,j="".concat(P," Session Replay Debug"),U=function(){return{flushMaxRetries:2,logLevel:r.Warn,loggerProvider:new v,transportProvider:new _}},q=function(e){function t(t,n){var r=this,o=U();return(r=e.call(this,i(i({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||F,r.configEndpointUrl=n.configEndpointUrl,n.privacyConfig&&(r.privacyConfig=n.privacyConfig),n.debugMode&&(r.debugMode=n.debugMode),r}return n(t,e),t}(g);function B(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function W(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function z(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t,G).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 G(e){var t,n,r;if(function(e){return"styleSheet"in e}(e))try{t=z(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"}(T||(T={}));var V=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 K(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,o=e.type,s=e.value,i=e.maskInputFn,a=s||"",c=o&&H(o);return(n[r.toLowerCase()]||c&&n[c])&&(a=i?i(a,t):"*".repeat(a.length)),a}function H(e){return e.toLowerCase()}var Z="__rrweb_original__";function J(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?H(t):null}var $,Y,X=1,Q=new RegExp("[^a-z0-9-_:]");function ee(){return X++}var te=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ne=/^(?:[a-z+]+:)?\/\//i,re=/^www\..*/i,oe=/^(data:)([^,]*),(.*)/i;function se(e,t){return(e||"").replace(te,(function(e,n,r,o,s,i){var a,c=r||s||i,u=n||o||"";if(!c)return e;if(ne.test(c)||re.test(c))return"url(".concat(u).concat(c).concat(u,")");if(oe.test(c))return"url(".concat(u).concat(c).concat(u,")");if("/"===c[0])return"url(".concat(u).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(u,")");var l=t.split("/"),d=c.split("/");l.pop();for(var h=0,p=d;h<p.length;h++){var f=p[h];"."!==f&&(".."===f?l.pop():l.push(f))}return"url(".concat(u).concat(l.join("/")).concat(u,")")}))}var ie=/^[^ \t\n\r\u000c]+/,ae=/^[, \t\n\r\u000c]+/;function ce(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function ue(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function le(){var e=document.createElement("a");return e.href="",e.href}function de(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?ce(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(ae),!(n>=t.length);){var s=r(ie);if(","===s.slice(-1))s=ce(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=ce(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n?se(r,le()):"object"===t&&"data"===n?ce(e,r):r:ce(e,r):r}function he(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function pe(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&pe(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&pe(e.parentNode,t,n)}function fe(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(pe(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}}catch(e){}return!1}function ve(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,u=t.maskInputOptions,l=void 0===u?{}:u,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:T.Document,childNodes:[],compatMode:e.compatMode}:{type:T.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:T.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,s=t.inlineStylesheet,i=t.maskInputOptions,a=void 0===i?{}:i,c=t.maskInputFn,u=t.dataURLOptions,l=void 0===u?{}:u,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=H(e.tagName);return Q.test(t)?"div":t}(e),S={},b=e.attributes.length,I=0;I<b;I++){var w=e.attributes[I];he(y,w.name,w.value)||(S[w.name]=de(n,y,H(w.name),w.value))}if("link"===y&&s){var C=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),M=null;C&&(M=z(C)),M&&(delete S.rel,delete S.href,S._cssText=se(M,C.href))}if("style"===y&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(M=z(e.sheet))&&(S._cssText=se(M,le()))}if("input"===y||"textarea"===y||"select"===y){var k=e.value,E=e.checked;if("radio"!==S.type&&"checkbox"!==S.type&&"submit"!==S.type&&"button"!==S.type&&k){var O=J(e);S.value=K({element:e,type:O,tagName:y,value:k,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,s=Z in o?o[Z]:o;if(new Uint32Array(s.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(l.type,l.quality));else if(!("__context"in e)){var R=e.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=e.width,x.height=e.height,R!==x.toDataURL(l.type,l.quality)&&(S.rr_dataURL=R)}if("img"===y&&d){$||($=n.createElement("canvas"),Y=$.getContext("2d"));var D=e,N=D.crossOrigin;D.crossOrigin="anonymous";var L=function(){D.removeEventListener("load",L);try{$.width=D.naturalWidth,$.height=D.naturalHeight,Y.drawImage(D,0,0),S.rr_dataURL=$.toDataURL(l.type,l.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:T.Element,tagName:y,attributes:S,childNodes:[],isSVG:ue(e)||void 0,needBlock:g,rootId:m}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:l,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,s=t.maskTextFn,i=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,u="STYLE"===a||void 0,l="SCRIPT"===a||void 0;if(u&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=z(e.parentNode.sheet))}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=se(c,le())}l&&(c="SCRIPT_PLACEHOLDER");!u&&!l&&c&&fe(e,r,o)&&(c=s?s(c,e.parentElement):c.replace(/[\S]/g,"*"));return{type:T.Text,textContent:c||"",isStyle:u,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:d,rootId:b});case e.CDATA_SECTION_NODE:return{type:T.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:T.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function me(e){return null==e?"":e.toLowerCase()}function ge(e,t){var n,r=t.doc,o=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,u=t.skipChild,l=void 0!==u&&u,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,M=t.onSerialize,k=t.onIframeLoad,E=t.iframeLoadTimeout,O=void 0===E?5e3:E,R=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=ve(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,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===T.Comment)return!0;if(e.type===T.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&&(me(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===me(e.attributes.name)||"icon"===me(e.attributes.rel)||"apple-touch-icon"===me(e.attributes.rel)||"shortcut icon"===me(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&me(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(me(e.attributes.property).match(/^(og|twitter|fb):/)||me(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===me(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===me(e.attributes.name)||"googlebot"===me(e.attributes.name)||"bingbot"===me(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===me(e.attributes.name)||"generator"===me(e.attributes.name)||"framework"===me(e.attributes.name)||"publisher"===me(e.attributes.name)||"progid"===me(e.attributes.name)||me(e.attributes.property).match(/^article:/)||me(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===me(e.attributes.name)||"yandex-verification"===me(e.attributes.name)||"csrf-token"===me(e.attributes.name)||"p:domain_verify"===me(e.attributes.name)||"verify-v1"===me(e.attributes.name)||"verification"===me(e.attributes.name)||"shopify-checkout-api-token"===me(e.attributes.name)))return!0}}return!1}(j,g)&&(F||j.type!==T.Text||j.isStyle||j.textContent.replace(/^\s+|\s+$/gm,"").length)?ee():-2;var U=Object.assign(j,{id:n});if(o.add(e,U),-2===n)return null;M&&M(e);var q=!l;if(U.type===T.Element){q=q&&!U.needBlock,delete U.needBlock;var z=e.shadowRoot;z&&W(z)&&(U.isShadowHost=!0)}if((U.type===T.Document||U.type===T.Element)&&q){g.headWhitespace&&U.type===T.Element&&"head"===U.tagName&&(F=!1);for(var G={doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:l,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:M,onIframeLoad:k,iframeLoadTimeout:O,onStylesheetLoad:R,stylesheetLoadTimeout:D,keepIframeSrcFn:L},V=0,K=Array.from(e.childNodes);V<K.length;V++){(J=ge(K[V],G))&&U.childNodes.push(J)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,Z=Array.from(e.shadowRoot.childNodes);H<Z.length;H++){var J;(J=ge(Z[H],G))&&(W(e.shadowRoot)&&(J.isShadow=!0),U.childNodes.push(J))}}return e.parentNode&&B(e.parentNode)&&W(e.parentNode)&&(U.isShadow=!0),U.type===T.Element&&"iframe"===U.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&k){var n=ge(t,{doc:t,mirror:o,blockClass:s,blockSelector:i,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:M,onIframeLoad:k,iframeLoadTimeout:O,onStylesheetLoad:R,stylesheetLoadTimeout:D,keepIframeSrcFn:L});n&&k(e,n)}}),O),U.type===T.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 s=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}(e,(function(){if(R){var t=ge(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,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:M,onIframeLoad:k,iframeLoadTimeout:O,onStylesheetLoad:R,stylesheetLoadTimeout:D,keepIframeSrcFn:L});t&&R(e,t)}}),D),U}var ye=(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))(ye||{}),Se=(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))(Se||{}),be=(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))(be||{}),Ie=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ie||{}),we=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(we||{});function Ce(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Me="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 ke={map:{},getId:()=>(console.error(Me),-1),getNode:()=>(console.error(Me),null),removeNodeFromMap(){console.error(Me)},has:()=>(console.error(Me),!1),reset(){console.error(Me)}};function Ee(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function Oe(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>Oe(e,t,s||{},!0)}function Te(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&&(ke=new Proxy(ke,{get:(e,t,n)=>("map"===t&&console.error(Me),Reflect.get(e,t,n))}));let Re,xe=Date.now;function De(e){var t,n,r,o,s,i;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===(s=null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.parentElement)||void 0===s?void 0:s.scrollTop)||(null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.scrollTop)||0}}function Ne(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Le(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function _e(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function Pe(e,t,n,r){if(!e)return!1;const o=_e(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(pe(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 Ae(e,t){return-2===t.getId(e)}function Fe(e,t){if(B(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Fe(e.parentNode,t))}function je(e){return Boolean(e.changedTouches)}function Ue(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function qe(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Be(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(xe=()=>(new Date).getTime());class We{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 ze(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 Ge(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=ze(n);)n=t;return n}(e);return t.contains(n)}function Ve(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||Ge(e))}function Ke(e){Re=e}function He(){Re=void 0}const Ze=e=>{if(!Re)return e;return(...t)=>{try{return e(...t)}catch(e){if(Re&&!0===Re(e))return;throw e}}};class Je{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}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 $e{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Je(ee),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Je(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 ye.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:ye.IncrementalSnapshot,data:{source:Se.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case ye.Meta:case ye.Load:case ye.DomContentLoaded:return!1;case ye.Plugin:return t;case ye.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case ye.IncrementalSnapshot:switch(t.data.source){case Se.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 Se.Drag:case Se.TouchMove:case Se.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Se.ViewportResize:return!1;case Se.MediaInteraction:case Se.MouseInteraction:case Se.Scroll:case Se.CanvasMutation:case Se.Input:return this.replaceIds(t.data,e,["id"]),t;case Se.StyleSheetRule:case Se.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Se.Font:return t;case Se.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Se.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===T.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach((e=>{this.patchRootIdOnNode(e,t)}))}}function Ye(e){return"__ln"in e}class Xe{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&&Ye(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&&Ye(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 Qe=(e,t)=>`${e}@${t}`;class et{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 Xe,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||!Ve(o))return;const s=B(o.parentNode)?this.mirror.getId(ze(o)):this.mirror.getId(o.parentNode),i=r(o);if(-1===s||-1===i)return n.addNode(o);const a=ge(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=>{Ue(e,this.mirror)&&this.iframeManager.addIframe(e),qe(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Be(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:s,nextId:i,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)nt(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of this.addedSet)ot(this.droppedSet,e)||nt(this.removes,e,this.mirror)?ot(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=r(s.value);-1!==t&&-1!==n&&(e=s)}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}s=e.previous,n.removeNode(e.value),o(e.value)}const i={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};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!Ae(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Pe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:fe(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t,_e(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=J(t);r=K({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(Pe(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"),!he(t.tagName,n)&&(o.attributes[n]=de(this.doc,H(t.tagName),H(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),s=t.style.getPropertyPriority(e);n!==r.style.getPropertyValue(e)||s!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===s?n:[n,s]:o._unchangedStyles[e]=[n,s]}for(const e of Array.from(r.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}break}case"childList":if(Pe(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=B(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Pe(e.target,this.blockClass,this.blockSelector,!1)||Ae(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(tt(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Fe(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Qe(n,r)]?tt(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!B(e.target)||!W(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(Ae(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[Qe(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Pe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach((e=>this.genAdds(e))),Be(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 tt(e,t){e.delete(t),t.childNodes.forEach((t=>tt(e,t)))}function nt(e,t,n){return 0!==e.length&&rt(e,t,n)}function rt(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||rt(e,r,n)}function ot(e,t){return 0!==e.size&&st(e,t)}function st(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||st(e,n))}const it=[];function at(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 ct(e,t){var n,r;const o=new et;it.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=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");i&&window[i]&&(s=window[i]);const a=new s(Ze(o.processMutations.bind(o)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ut({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];let c=null;return Object.keys(be).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{let i=H(s);const u=(t=>s=>{const i=at(s);if(Pe(i,r,o,!0))return;let a=null,u=t;if("pointerType"in s){switch(s.pointerType){case"mouse":a=Ie.Mouse;break;case"touch":a=Ie.Touch;break;case"pen":a=Ie.Pen}a===Ie.Touch?be[t]===be.MouseDown?u="TouchStart":be[t]===be.MouseUp&&(u="TouchEnd"):Ie.Pen}else je(s)&&(a=Ie.Touch);null!==a?(c=a,(u.startsWith("Touch")&&a===Ie.Touch||u.startsWith("Mouse")&&a===Ie.Mouse)&&(a=null)):be[t]===be.Click&&(a=c,c=null);const l=je(s)?s.changedTouches[0]:s;if(!l)return;const d=n.getId(i),{clientX:h,clientY:p}=l;Ze(e)(Object.assign({type:be[u],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(s);if(window.PointerEvent)switch(be[s]){case be.MouseDown:case be.MouseUp:i=i.replace("mouse","pointer");break;case be.TouchStart:case be.TouchEnd:return}a.push(Ce(i,u,t))})),Ze((()=>{a.forEach((e=>e()))}))}function lt({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return Ce("scroll",Ze(Ee(Ze((s=>{const i=at(s);if(!i||Pe(i,r,o,!0))return;const a=n.getId(i);if(i===t&&t.defaultView){const n=De(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})})),s.scroll||100)),t)}function dt(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ht=["INPUT","TEXTAREA","SELECT"],pt=new WeakMap;function ft(e){return function(e,t){if(yt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||yt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||yt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||yt("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 vt(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function mt({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#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===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==i&&-1!==i&&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!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),Ze((()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}))):()=>{}}function gt(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:u,styleDeclarationCb:l,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),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...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),u(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),l(...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=ct(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,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=Ee(Ze((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null})),s),u=Ze(Ee(Ze((e=>{const t=at(e),{clientX:n,clientY:o}=je(e)?e.changedTouches[0]:e;i||(i=xe()),a.push({x:n,y:o,id:r.getId(t),timeOffset:xe()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Se.Drag:e instanceof MouseEvent?Se.MouseMove:Se.TouchMove)})),o,{trailing:!1})),l=[Ce("mousemove",u,n),Ce("touchmove",u,n),Ce("drag",u,n)];return Ze((()=>{l.forEach((e=>e()))}))}(e),s=ut(e),i=lt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Ce("resize",Ze(Ee(Ze((()=>{const t=Ne(),o=Le();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:s,ignoreSelector:i,maskInputOptions:a,maskInputFn:c,sampling:u,userTriggeredOnInput:l}){function d(e){let n=at(e);const u=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=n.parentElement),!n||!d||ht.indexOf(d)<0||Pe(n,r,o,!0))return;if(n.classList.contains(s)||i&&n.matches(i))return;let p=n.value,f=!1;const v=J(n)||"";"radio"===v||"checkbox"===v?f=n.checked:(a[d.toLowerCase()]||a[v])&&(p=K({element:n,maskInputOptions:a,tagName:d,type:v,value:p,maskInputFn:c})),h(n,Ze(dt)({text:p,isChecked:f,userTriggered:u},l));const m=n.name;"radio"===v&&m&&f&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&h(e,Ze(dt)({text:e.value,isChecked:!f,userTriggered:!1},l))}))}function h(t,r){const o=pt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){pt.set(t,r);const o=n.getId(t);Ze(e)(Object.assign(Object.assign({},r),{id:o}))}}const p=("last"===u.input?["change"]:["input","change"]).map((e=>Ce(e,Ze(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=>Oe(e[0],e[1],{set(){Ze(d)({target:this,isTrusted:!1})}},!1,f)))),Ze((()=>{p.forEach((e=>e()))}))}(e),u=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:s}){const i=Ze((s=>Ee(Ze((o=>{const i=at(o);if(!i||Pe(i,t,n,!0))return;const{currentTime:a,volume:c,muted:u,playbackRate:l}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:u,playbackRate:l})})),o.media||500))),a=[Ce("play",i(0),s),Ce("pause",i(1),s),Ce("seeked",i(2),s),Ce("volumechange",i(3),s),Ce("ratechange",i(4),s)];return Ze((()=>{a.forEach((e=>e()))}))}(e);let l=()=>{},d=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(l=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:Ze(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=vt(o,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:a}]}),r.apply(o,s)}))});const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:i}]}),r.apply(o,s)}))}),r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:i}),r.apply(o,s)}))})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:i}),r.apply(o,s)}))}));const c={};St("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(St("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),St("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),St("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const u={};return Object.entries(c).forEach((([r,o])=>{u[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(u[r].insertRule,{apply:Ze(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=vt(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:[...ft(o),a||0]}]}),r.apply(o,s)}))}),o.prototype.deleteRule=new Proxy(u[r].deleteRule,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...ft(o),i]}]}),r.apply(o,s)}))})})),Ze((()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule}))}))}(e,{win:n}),d=mt(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:Ze(((o,i,a)=>{var c;const[u,l,d]=a;if(n.has(u))return s.apply(i,[u,l,d]);const{id:h,styleId:p}=vt(null===(c=i.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:u,value:l,priority:d},index:ft(i.parentRule)}),o.apply(i,a)}))});const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:Ze(((o,s,a)=>{var c;const[u]=a;if(n.has(u))return i.apply(s,[u]);const{id:l,styleId:d}=vt(null===(c=s.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,remove:{property:u},index:ft(s.parentRule)}),o.apply(s,a)}))}),Ze((()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}))}(e,{win:n}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(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 i=Te(t.fonts,"add",(function(t){return function(n){return setTimeout(Ze((()=>{const t=o.get(n);t&&(e(t),o.delete(n))})),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),Ze((()=>{r.forEach((e=>e()))}))}(e)));const f=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=Ze((()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:u,endOffset:l}=s;Pe(i,r,o,!0)||Pe(u,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(u),endOffset:l})}s({ranges:a})}));return a(),Ce("selectionchange",a)}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return Ze((()=>{it.forEach((e=>e.reset())),null==r||r.disconnect(),o(),s(),i(),a(),c(),u(),l(),d(),h(),p(),f(),v.forEach((e=>e()))}))}function yt(e){return void 0!==window[e]}function St(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function bt(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var It,wt,Ct,Mt=(It=function(){!function(){function e(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,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,s="";for(n=0;n<o;n+=3)s+=t[r[n]>>2],s+=t[(3&r[n])<<4|r[n+1]>>4],s+=t[(15&r[n+1])<<2|r[n+2]>>6],s+=t[63&r[n+2]];return o%3==2?s=s.substring(0,s.length-1)+"=":o%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const s=new Map,i=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:u,dataURLOptions:l}=t.data,d=function(t,n,r){return e(this,void 0,void 0,(function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(i.has(e))return i.get(e);const s=new OffscreenCanvas(t,n);s.getContext("2d");const a=yield s.convertToBlob(r),c=yield a.arrayBuffer(),u=o(c);return i.set(e,u),u}return""}))}(c,u,l),h=new OffscreenCanvas(c,u);h.getContext("2d").drawImage(r,0,0),r.close();const p=yield h.convertToBlob(l),f=p.type,v=yield p.arrayBuffer(),m=o(v);if(!s.has(n)&&(yield d)===m)return s.set(n,m),a.postMessage({id:n});if(s.get(n)===m)return a.postMessage({id:n});a.postMessage({id:n,type:f,base64:m,width:c,height:u}),s.set(n,m)}}))}}()},wt=null,function(e){return Ct=Ct||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/),s=/(['"])__worker_loader_strict__(['"])/g,i=0,a=r.length;i<a;++i)r[i]=r[i].substring(o).replace(s,"$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)}(It,wt),new Worker(Ct,e)}),kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ot=0;Ot<kt.length;Ot++)Et[kt.charCodeAt(Ot)]=Ot;const Tt=new Map;const Rt=(e,t,n)=>{if(!e||!Nt(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Tt.get(e);return n||(n=new Map,Tt.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 xt(e,t,n){if(e instanceof Array)return e.map((e=>xt(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+=kt[n[t]>>2],o+=kt[(3&n[t])<<4|n[t+1]>>4],o+=kt[(15&n[t+1])<<2|n[t+2]>>6],o+=kt[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:[xt(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:[xt(e.data,t,n),e.width,e.height]}}if(Nt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Rt(e,t,n)}}return e}const Dt=(e,t,n)=>[...e].map((e=>xt(e,t,n))),Nt=(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 Lt(e,t,n,r){const o=[];try{const s=Te(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...s){if(!Pe(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(s[0]&&"object"==typeof s[0]){const e=s[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else s.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...s])}}));o.push(s)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function _t(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Te(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Rt(c,i,this),"tagName"in this.canvas&&!Pe(this.canvas,r,o,!0)){const e=Dt([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=Oe(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}class Pt{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:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}initCanvasFPSObserver(e,t,n,r,o){const s=Lt(t,n,r,!0),i=new Map,a=new Mt;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:we["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{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 u,l=0;const d=e=>{l&&e-l<c||(l=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{Pe(t,n,r,!0)||e.push(t)})),e})().forEach((e=>bt(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.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])}))))),u=requestAnimationFrame(d)};u=requestAnimationFrame(d),this.resetObservers=()=>{s(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Lt(e,t,n,!1),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Te(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return Pe(this.canvas,n,r,!0)||setTimeout((()=>{const n=Dt([...s],t,this);e(this.canvas,{type:we["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=Oe(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:we["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(..._t(t.WebGLRenderingContext.prototype,we.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(..._t(t.WebGL2RenderingContext.prototype,we.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}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 At{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 Ft{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(!W(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=ct(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(lt(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(mt({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(Te(e.prototype,"attachShadow",(function(e){return function(r){const o=e.call(this,r);return this.shadowRoot&&Ve(this)&&n.addShadowRoot(this.shadowRoot,t),o}})))}reset(){this.restoreHandlers.forEach((e=>{try{e()}catch(e){}})),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}class jt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new We,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:G(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 Ut(e){return Object.assign(Object.assign({},e),{timestamp:xe()})}let qt,Bt,Wt,zt=!1;const Gt=new V;function Vt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:l=!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:M=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:k=!1,collectFonts:E=!1,inlineImages:O=!1,plugins:T,keepIframeSrcFn:R=(()=>!1),ignoreCSSAttributes:x=new Set([]),errorHandler:D}=e;Ke(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),Gt.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 T||[])t.eventProcessor&&(e=t.eventProcessor(e));return g&&!L&&(e=g(e)),e};qt=(e,o)=>{var s;if(!(null===(s=it[0])||void 0===s?void 0:s.isFrozen())||e.type===ye.FullSnapshot||e.type===ye.IncrementalSnapshot&&e.data.source===Se.Mutation||it.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===ye.FullSnapshot)A=e,F=0;else if(e.type===ye.IncrementalSnapshot){if(e.data.source===Se.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-A.timestamp>n;(t||o)&&Bt(!0)}};const U=e=>{qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Mutation},e)}))},q=e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Scroll},e)})),B=e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.CanvasMutation},e)})),W=new jt({mutationCb:U,adoptedStyleSheetCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.AdoptedStyleSheet},e)}))}),z=new $e({mirror:Gt,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:C,wrappedEmit:qt});for(const e of T||[])e.getMirror&&e.getMirror({nodeMirror:Gt,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const G=new At;Wt=new Pt({recordCanvas:w,mutationCb:B,win:window,blockClass:o,blockSelector:s,mirror:Gt,sampling:y.canvas,dataURLOptions:S});const K=new Ft({mutationCb:U,scrollCb:q,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskInputOptions:_,dataURLOptions:S,maskTextFn:v,maskInputFn:f,recordCanvas:w,inlineImages:O,sampling:y,slimDOMOptions:P,iframeManager:z,stylesheetManager:W,canvasManager:Wt,keepIframeSrcFn:R,processedNodeManager:G},mirror:Gt});Bt=(e=!1)=>{if(!I)return;qt(Ut({type:ye.Meta,data:{href:window.location.href,width:Le(),height:Ne()}}),e),W.reset(),K.init(),it.forEach((e=>e.lock()));const t=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new V:r,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,u=n.maskTextClass,l=void 0===u?"rr-mask":u,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,M=void 0!==C&&C,k=n.dataURLOptions,E=n.preserveWhiteSpace,O=n.onSerialize,T=n.onIframeLoad,R=n.iframeLoadTimeout,x=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,N=n.keepIframeSrcFn;return ge(e,{doc:e,mirror:o,blockClass:i,blockSelector:c,maskTextClass:l,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===M||"all"===M?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===M,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===M?{}:M,dataURLOptions:k,inlineImages:m,recordCanvas:y,preserveWhiteSpace:E,onSerialize:O,onIframeLoad:T,iframeLoadTimeout:R,onStylesheetLoad:x,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===N?function(){return!1}:N,newlyAddedElement:!1})}(document,{mirror:Gt,blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskAllInputs:_,maskTextFn:v,slimDOM:P,dataURLOptions:S,recordCanvas:w,inlineImages:O,onSerialize:e=>{Ue(e,Gt)&&z.addIframe(e),qe(e,Gt)&&W.trackLinkElement(e),Be(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),K.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:R});if(!t)return console.warn("Failed to snapshot the document");qt(Ut({type:ye.FullSnapshot,data:{node:t,initialOffset:De(window)}}),e),it.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Gt.getId(document))};try{const e=[],t=e=>{var t;return Ze(gt)({mutationCb:U,mousemoveCb:(e,t)=>qt(Ut({type:ye.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.MouseInteraction},e)})),scrollCb:q,viewportResizeCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.ViewportResize},e)})),inputCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Input},e)})),mediaInteractionCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.MediaInteraction},e)})),styleSheetRuleCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.StyleSheetRule},e)})),styleDeclarationCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.StyleDeclaration},e)})),canvasMutationCb:B,fontCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Font},e)})),selectionCb:e=>{qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Selection},e)}))},blockClass:o,ignoreClass:i,ignoreSelector:a,maskTextClass:c,maskTextSelector:u,maskInputOptions:_,inlineStylesheet:l,sampling:y,recordDOM:I,recordCanvas:w,inlineImages:O,userTriggeredOnInput:k,collectFonts:E,doc:e,maskInputFn:f,maskTextFn:v,keepIframeSrcFn:R,blockSelector:s,slimDOMOptions:P,dataURLOptions:S,mirror:Gt,iframeManager:z,stylesheetManager:W,shadowDomManager:K,processedNodeManager:G,canvasManager:Wt,ignoreCSSAttributes:x,plugins:(null===(t=null==T?void 0:T.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>qt(Ut({type:ye.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};z.addLoadListener((n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}}));const n=()=>{Bt(),e.push(t(document)),zt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(Ce("DOMContentLoaded",(()=>{qt(Ut({type:ye.DomContentLoaded,data:{}})),"DOMContentLoaded"===M&&n()}))),e.push(Ce("load",(()=>{qt(Ut({type:ye.Load,data:{}})),"load"===M&&n()}),window))),()=>{e.forEach((e=>e())),G.destroy(),zt=!1,He()}}catch(e){console.warn(e)}}var Kt,Ht;Vt.addCustomEvent=(e,t)=>{if(!zt)throw new Error("please add custom event after start recording");qt(Ut({type:ye.Custom,data:{tag:e,payload:t}}))},Vt.freezePage=()=>{it.forEach((e=>e.freeze()))},Vt.takeFullSnapshot=e=>{if(!zt)throw new Error("please take full snapshot after start recording");Bt(e)},Vt.mirror=Gt,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"}(Kt||(Kt={})),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"}(Ht||(Ht={}));var Zt=Uint8Array,Jt=Uint16Array,$t=Uint32Array,Yt=new Zt([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]),Xt=new Zt([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]),Qt=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),en=function(e,t){for(var n=new Jt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new $t(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},tn=en(Yt,2),nn=tn[0],rn=tn[1];nn[28]=258,rn[258]=28;for(var on=en(Xt,0)[1],sn=new Jt(32768),an=0;an<32768;++an){var cn=(43690&an)>>>1|(21845&an)<<1;cn=(61680&(cn=(52428&cn)>>>2|(13107&cn)<<2))>>>4|(3855&cn)<<4,sn[an]=((65280&cn)>>>8|(255&cn)<<8)>>>1}var un=function(e,t,n){for(var r=e.length,o=0,s=new Jt(t);o<r;++o)++s[e[o]-1];var i,a=new Jt(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new Jt(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var u=o<<4|e[o],l=t-e[o],d=a[e[o]-1]++<<l,h=d|(1<<l)-1;d<=h;++d)i[sn[d]>>>c]=u}else for(i=new Jt(r),o=0;o<r;++o)i[o]=sn[a[e[o]-1]++]>>>15-e[o];return i},ln=new Zt(288);for(an=0;an<144;++an)ln[an]=8;for(an=144;an<256;++an)ln[an]=9;for(an=256;an<280;++an)ln[an]=7;for(an=280;an<288;++an)ln[an]=8;var dn=new Zt(32);for(an=0;an<32;++an)dn[an]=5;var hn=un(ln,9,0),pn=un(dn,5,0),fn=function(e){return(e/8>>0)+(7&e&&1)},vn=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Jt?Jt:e instanceof $t?$t:Zt)(n-t);return r.set(e.subarray(t,n)),r},mn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},gn=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},yn=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,s=n.slice();if(!o)return[new Zt(0),0];if(1==o){var i=new Zt(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],u=0,l=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=o-1;)a=n[n[u].f<n[d].f?u++:d++],c=n[u!=l&&n[u].f<n[d].f?u++:d++],n[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var p=new Jt(h+1),f=Sn(n[l-1],p,0);if(f>t){r=0;var v=0,m=f-t,g=1<<m;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var y=s[r].s;if(!(p[y]>t))break;v+=g-(1<<f-p[y]),p[y]=t}for(v>>>=m;v>0;){var S=s[r].s;p[S]<t?v-=1<<t-p[S]++-1:++r}for(;r>=0&&v;--r){var b=s[r].s;p[b]==t&&(--p[b],++v)}f=t}return[new Zt(p),f]},Sn=function(e,t,n){return-1==e.s?Math.max(Sn(e.l,t,n+1),Sn(e.r,t,n+1)):t[e.s]=n},bn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Jt(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},In=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},wn=function(e,t,n){var r=n.length,o=fn(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 s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Cn=function(e,t,n,r,o,s,i,a,c,u,l){mn(t,l++,n),++o[256];for(var d=yn(o,15),h=d[0],p=d[1],f=yn(s,15),v=f[0],m=f[1],g=bn(h),y=g[0],S=g[1],b=bn(v),I=b[0],w=b[1],C=new Jt(19),M=0;M<y.length;++M)C[31&y[M]]++;for(M=0;M<I.length;++M)C[31&I[M]]++;for(var k=yn(C,7),E=k[0],O=k[1],T=19;T>4&&!E[Qt[T-1]];--T);var R,x,D,N,L=u+5<<3,_=In(o,ln)+In(s,dn)+i,P=In(o,h)+In(s,v)+i+14+3*T+In(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(L<=_&&L<=P)return wn(t,l,e.subarray(c,c+u));if(mn(t,l,1+(P<_)),l+=2,P<_){R=un(h,p,0),x=h,D=un(v,m,0),N=v;var A=un(E,O,0);mn(t,l,S-257),mn(t,l+5,w-1),mn(t,l+10,T-4),l+=14;for(M=0;M<T;++M)mn(t,l+3*M,E[Qt[M]]);l+=3*T;for(var F=[y,I],j=0;j<2;++j){var U=F[j];for(M=0;M<U.length;++M){var q=31&U[M];mn(t,l,A[q]),l+=E[q],q>15&&(mn(t,l,U[M]>>>5&127),l+=U[M]>>>12)}}}else R=hn,x=ln,D=pn,N=dn;for(M=0;M<a;++M)if(r[M]>255){q=r[M]>>>18&31;gn(t,l,R[q+257]),l+=x[q+257],q>7&&(mn(t,l,r[M]>>>23&31),l+=Yt[q]);var B=31&r[M];gn(t,l,D[B]),l+=N[B],B>3&&(gn(t,l,r[M]>>>5&8191),l+=Xt[B])}else gn(t,l,R[r[M]]),l+=x[r[M]];return gn(t,l,R[256]),l+x[256]},Mn=new $t([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kn=new Zt(0),En=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new Zt(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),u=0;if(!t||i<8)for(var l=0;l<=i;l+=65535){var d=l+65535;d<i?u=wn(c,u,e.subarray(l,d)):(c[l]=s,u=wn(c,u,e.subarray(l,i)))}else{for(var h=Mn[t-1],p=h>>>13,f=8191&h,v=(1<<n)-1,m=new Jt(32768),g=new Jt(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 $t(25e3),w=new Jt(288),C=new Jt(32),M=0,k=0,E=(l=0,0),O=0,T=0;l<i;++l){var R=b(l),x=32767&l,D=g[R];if(m[x]=D,g[R]=x,O<=l){var N=i-l;if((M>7e3||E>24576)&&N>423){u=Cn(e,c,0,I,w,C,k,E,T,l-T,u),E=M=k=0,T=l;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(l-F))for(var j=Math.min(p,N)-1,U=Math.min(32767,l),q=Math.min(258,N);F<=U&&--A&&x!=D;){if(e[l+_]==e[l+_-F]){for(var B=0;B<q&&e[l+B]==e[l+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=l-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|rn[_]<<18|on[P];var K=31&rn[_],H=31&on[P];k+=Yt[K]+Xt[H],++w[257+K],++C[H],O=l+_,++M}else I[E++]=e[l],++w[e[l]]}}u=Cn(e,c,s,I,w,C,k,E,T,l-T,u),s||(u=wn(c,u,kn))}return vn(a,0,r+fn(u)+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 On(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];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=En(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 Tn=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}(On(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Zt(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new Zt(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return vn(r,0,o)}(JSON.stringify(t))),!0)};var Rn,xn;(xn=Rn||(Rn={}))[xn.NotStarted=0]="NotStarted",xn[xn.Running=1]="Running",xn[xn.Stopped=2]="Stopped";const Dn=(e,t)=>t.some((t=>e instanceof t));let Nn,Ln;const _n=new WeakMap,Pn=new WeakMap,An=new WeakMap;let Fn={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return _n.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Bn(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function jn(e){Fn=e(Fn)}function Un(e){return(Ln||(Ln=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Wn(this),t),Bn(this.request)}:function(...t){return Bn(e.apply(Wn(this),t))}}function qn(e){return"function"==typeof e?Un(e):(e instanceof IDBTransaction&&function(e){if(_n.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)}));_n.set(e,t)}(e),Dn(e,Nn||(Nn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Fn):e)}function Bn(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t(Bn(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",s)}));return An.set(t,e),t}(e);if(Pn.has(e))return Pn.get(e);const t=qn(e);return t!==e&&(Pn.set(e,t),An.set(t,e)),t}const Wn=e=>An.get(e);function zn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Bn(i);return r&&i.addEventListener("upgradeneeded",(e=>{r(Bn(i.result),e.oldVersion,e.newVersion,Bn(i.transaction),e)})),n&&i.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{s&&e.addEventListener("close",(()=>s())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function Gn(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),Bn(n).then((()=>{}))}const Vn=["get","getKey","getAll","getAllKeys","count"],Kn=["put","add","delete","clear"],Hn=new Map;function Zn(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Hn.get(t))return Hn.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=Kn.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!Vn.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,o?"readwrite":"readonly");let i=s.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),o&&s.done]))[0]};return Hn.set(t,s),s}jn((e=>({...e,get:(t,n,r)=>Zn(t,n)||e.get(t,n,r),has:(t,n)=>!!Zn(t,n)||e.has(t,n)})));const Jn=["continue","continuePrimaryKey","advance"],$n={},Yn=new WeakMap,Xn=new WeakMap,Qn={get(e,t){if(!Jn.includes(t))return e[t];let n=$n[t];return n||(n=$n[t]=function(...e){Yn.set(this,Xn.get(this)[t](...e))}),n}};async function*er(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,Qn);for(Xn.set(n,t),An.set(n,Wn(t));t;)yield n,t=await(Yn.get(n)||t.continue()),Yn.delete(n)}function tr(e,t){return t===Symbol.asyncIterator&&Dn(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&Dn(e,[IDBIndex,IDBObjectStore])}jn((e=>({...e,get:(t,n,r)=>tr(t,n)?er:e.get(t,n,r),has:(t,n)=>tr(t,n)||e.has(t,n)})));var nr,rr=function(e,t){return a(void 0,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,zn(e,1,{upgrade:function(e){t.forEach((function(t){e.objectStoreNames.contains(t)||e.createObjectStore(t)}))}})];case 1:return[2,n.sent()]}}))}))},or=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.configKeys;return a(void 0,void 0,void 0,(function(){var e,o,s,d,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,rr(e,r)];case 1:return o=g.sent(),s="".concat(n.substring(0,10),"_amp_config_meta"),[4,(y=s,a(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,zn(y,1,{upgrade:function(e){e.objectStoreNames.contains("lastFetchedSessionId")||e.createObjectStore("lastFetchedSessionId")}})];case 1:return[2,e.sent()]}}))})))];case 2:d=g.sent(),g.label=3;case 3:return g.trys.push([3,8,,9]),[4,d.get("lastFetchedSessionId","sessionId")];case 4:return(h=g.sent())&&Date.now()-h>=2592e5?[4,Gn(e)]:[3,7];case 5:return g.sent(),[4,rr(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,s,a,h,p,f;return c(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),n?[4,d.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(s){switch(s.label){case 0:return n=e.configs[t],r=o.transaction(t,"readwrite"),[4,Promise.all(l(l([],u(Object.keys(n).map((function(e){return r.store.put(i({},n[e]),e)}))),!1),[r.done],!1))];case 1:return s.sent(),[2]}}))},s=e.configs,a=[],s)a.push(h);p=0,v.label=3;case 3:return p<a.length?(h=a[p])in s?[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,d.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(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,o.get(e,n)];case 1:return[2,s.sent()];case 2:return r=s.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}))}))},sr="Remote config fetch rejected due to timeout after 5 seconds",ir=function(){function e(e){var t=e.localConfig,n=e.configKeys,r=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.getRemoteConfig=function(e,t,n){return a(r,void 0,void 0,(function(){var r,o,s,i;return c(this,(function(a){switch(a.label){case 0:return this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.getRemoteConfig(e,t)]:[3,3];case 1:return r=a.sent(),[4,this.remoteConfigIDBStore.getLastFetchedSessionId()];case 2:if(o=a.sent(),r&&o===n)return[2,r];a.label=3;case 3:return[4,this.fetchWithTimeout(n)];case 4:return(s=a.sent())&&(i=s.configs&&s.configs[e])?[2,i[t]]:[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,u,l;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:sr})];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,i(i({},r),{signal:e}))];case 2:if(null===(a=c.sent()))return[2,this.completeRequest({err:"Unexpected error occurred"})];switch((new w).buildStatus(a.status)){case s.Success:return[2,this.parseAndStoreConfig(a,t)];case s.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return u=c.sent(),l=u,e.aborted?[2,this.completeRequest({err:sr})]:[2,this.completeRequest({err:l.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,or({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}(),ar=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 ir({localConfig:t,configKeys:n})).initialize()];case 1:return r.sent(),[2,e]}}))}))},cr=function(){function e(e,t){this.localConfig=new q(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,ar({localConfig:this.localConfig,configKeys:["sessionReplay"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(e){return a(this,void 0,void 0,(function(){var t,n,r,o,s,a,u,l,d,h;return c(this,(function(c){switch(c.label){case 0:(t=i({},this.localConfig)).optOut=this.localConfig.optOut,t.captureEnabled=!0,c.label=1;case 1:return c.trys.push([1,4,,5]),this.remoteConfigFetch?[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)]:[2,t];case 2:return r=c.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return o=c.sent(),(r||o)&&(n={},r&&(n.sr_sampling_config=r),o&&(n.sr_privacy_config=o)),[3,5];case 4:return s=c.sent(),a=s,this.localConfig.loggerProvider.warn(a.message),t.captureEnabled=!0,[3,5];case 5:if(!n)return[2,t];if(u=n.sr_sampling_config,l=n.sr_privacy_config,u&&Object.keys(u).length>0?(Object.prototype.hasOwnProperty.call(u,"capture_enabled")?t.captureEnabled=u.capture_enabled:t.captureEnabled=!1,u.sample_rate&&(t.sampleRate=u.sample_rate)):(t.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),l&&Object.keys(l).length>0)for(d in t.privacyConfig||(t.privacyConfig={}),l)h=d,t.privacyConfig[h]=l[h];return[2,t]}}))}))},e}(),ur=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 cr(e,t)).initialize()];case 1:return r.sent(),[2,n]}}))}))},lr=function(e,t){var n;return(null===(n=t.classList)||void 0===n?void 0:n.contains("amp-unmask"))?e:"*".repeat(e.length)},dr=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},hr="Session replay event batch rejected due to exceeded retry count",pr="Failed to store session replay events in IndexedDB",fr=function(){function e(e){var t=e.loggerProvider;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=t}return e.prototype.sendEventsList=function(e){this.addToQueue(i(i({},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(hr,", 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,s,i,a,u,l,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"})];v=L(),o=(null==v?void 0:v.location)?v.location.href:"",s="0.2.5",i=e.sampleRate,a=new URLSearchParams({device_id:r,session_id:"".concat(e.sessionId),seq_number:"".concat(e.sequenceId)}),u={version:1,events:e.events},c.label=1;case 1:return c.trys.push([1,3,,4]),l={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(n),"X-Client-Version":s,"X-Client-Url":o,"X-Client-Sample-Rate":"".concat(i)},body:JSON.stringify(u),method:"POST"},d="".concat(this.getServerUrl(e.serverZone),"?").concat(a.toString()),[4,fetch(d,l)];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 w).buildStatus(e)){case s.Success:this.handleSuccessResponse(t);break;case s.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(i(i({},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}();!function(e){e.RECORDING="recording",e.SENT="sent"}(nr||(nr={}));var vr="sessionCurrentSequence",mr="sequencesToSend",gr=function(){var e=L();return new Promise((function(t){if(e){var n=e.indexedDB.open("keyval-store");n.onupgradeneeded=function(){1===n.result.version&&(n.result.close(),n.transaction&&n.transaction.abort(),e.indexedDB.deleteDatabase("keyval-store"),t())},n.onsuccess=function(){t(n.result)}}}))},yr=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]}}))}))},Sr=function(e){var t,n;return e.objectStoreNames.contains(vr)||(n=e.createObjectStore(vr,{keyPath:"sessionId"})),e.objectStoreNames.contains(mr)||(t=e.createObjectStore(mr,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},br=function(e){return a(void 0,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,zn(e,1,{upgrade:Sr})];case 1:return[2,t.sent()]}}))}))},Ir=function(){function e(e){var t=e.loggerProvider,n=e.apiKey,r=this;this.storageKey="",this.maxPersistedEventsSize=1e6,this.interval=500,this.timeAtLastSplit=null,this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=r.maxPersistedEventsSize||!!(null!==r.timeAtLastSplit&&Date.now()-r.timeAtLastSplit>r.interval&&e.length)&&(r.interval=Math.min(1e4,r.interval+500),r.timeAtLastSplit=Date.now(),!0)},this.getSequencesToSend=function(){return a(r,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(mr)];case 1:return[2,n.sent()];case 2:return e=n.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},this.storeCurrentSequence=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 o.trys.push([0,4,,5]),this.db?[4,this.db.get(vr,e)]:[2,void 0];case 1:return(t=o.sent())?[4,this.db.put(mr,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=o.sent(),[4,this.db.put(vr,{sessionId:e,events:[]})];case 3:return o.sent(),[2,i(i({},t),{sessionId:e,sequenceId:n})];case 4:return r=o.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(r)),[3,5];case 5:return[2,void 0]}}))}))},this.addEventToCurrentSequence=function(e,t){return a(r,void 0,void 0,(function(){var n,r,o,s,i,a,u;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,10,,11]),(n=null===(u=this.db)||void 0===u?void 0:u.transaction(vr,"readwrite"))?[4,n.store.get(e)]:[2];case 1:return(r=c.sent())?[3,3]:[4,n.store.put({sessionId:e,events:[t]})];case 2:return c.sent(),[2];case 3:return o=void 0,this.shouldSplitEventsList(r.events,t)?(o=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,5];case 4:return c.sent(),[3,7];case 5:return s=r.events.concat(t),[4,n.store.put({sessionId:e,events:s})];case 6:c.sent(),c.label=7;case 7:return[4,n.done];case 8:return c.sent(),o?[4,this.storeSendingEvents(e,o)]:[2,void 0];case 9:return(i=c.sent())?[2,{events:o,sessionId:e,sequenceId:i}]:[2,void 0];case 10:return a=c.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(a)),[3,11];case 11:return[2,void 0]}}))}))},this.storeSendingEvents=function(e,t){return a(r,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(mr,{sessionId:e,events:t})];case 1:return[2,o.sent()];case 2:return n=o.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},this.cleanUpSessionEventsStore=function(e){return a(r,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(mr,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(t)),[3,3];case 3:return[2]}}))}))},this.transitionFromKeyValStore=function(e){return a(r,void 0,void 0,(function(){var t,n,r,o,s,i,u,l=this;return c(this,(function(h){switch(h.label){case 0:return[4,gr()];case 1:if(!(t=h.sent()))return[2];n=function(e,t){return a(l,void 0,void 0,(function(){var n,r,o=this;return c(this,(function(s){switch(s.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach((function(s){var i=parseInt(s,10),u=n[i];if(i===t.currentSequenceId){var l=u.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(l)}else u.status!==nr.SENT&&r.push(o.storeSendingEvents(e,u.events))})),[4,yr(r)];case 1:return s.sent(),[2]}}))}))},r="".concat(d,"_").concat(this.apiKey.substring(0,10)),h.label=2;case 2:return h.trys.push([2,4,,5]),o=t.transaction("keyval").objectStore("keyval").getAll(r),s=new Promise((function(t){o.onsuccess=function(r){return a(l,void 0,void 0,(function(){var o,s,i,a=this;return c(this,(function(c){switch(c.label){case 0:return o=r&&r.target.result,(s=o&&o[0])?(i=[],Object.keys(s).forEach((function(t){var r=parseInt(t,10),o=s[r];if(e===r)i.push(n(r,o));else{var c=o.sessionSequences;Object.keys(c).forEach((function(e){var t=parseInt(e,10);c[t].status!==nr.SENT&&i.push(a.storeSendingEvents(r,c[t].events))}))}})),[4,yr(i)]):[3,2];case 1:c.sent(),c.label=2;case 2:return t(),[2]}}))}))}})),[4,s];case 3:return h.sent(),(i=L())&&i.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return u=h.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(u)),[3,5];case 5:return[2]}}))}))},this.loggerProvider=t,this.apiKey=n}return e.prototype.initialize=function(e){return a(this,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return t="".concat(this.apiKey.substring(0,10),"_amp_session_replay_events"),n=this,[4,br(t)];case 1:return n.db=r.sent(),this.timeAtLastSplit=Date.now(),[4,this.transitionFromKeyValStore(e)];case 2:return r.sent(),[2]}}))}))},e}(),wr=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.sessionId;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(o){switch(o.label){case 0:return[4,(e=new Ir({loggerProvider:t,apiKey:n})).initialize(r)];case 1:return o.sent(),[2,e]}}))}))},Cr=function(e){var t=e.config,n=e.sessionId;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 r?[2,r.flush(e)]:[2]}))}))}var r,o,s,i,u,l;return c(this,(function(d){switch(d.label){case 0:return r=new fr({loggerProvider:t.loggerProvider}),[4,wr({loggerProvider:t.loggerProvider,apiKey:t.apiKey,sessionId:n})];case 1:return o=d.sent(),s=function(e){var n=e.events,s=e.sessionId,i=e.deviceId,a=e.sequenceId;r.sendEventsList({events:n,sequenceId:a,sessionId:s,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:i,sampleRate:t.sampleRate,serverZone:t.serverZone,onComplete:o.cleanUpSessionEventsStore.bind(o)})},i=function(e){var n=e.sessionId,r=e.deviceId;o.storeCurrentSequence(n).then((function(e){e&&s({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)}))},u=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,o.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){s({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},l=function(e){var n=e.event,r=e.sessionId,i=e.deviceId;o.addEventToCurrentSequence(r,n).then((function(e){return e&&s({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:i,addEvent:l,sendStoredEvents:u,flush:e}]}}))}))},Mr=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))},kr=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 v}return e.prototype.init=function(e,t){return p(this._init(e,t))},e.prototype._init=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o,s;return c(this,(function(i){switch(i.label){case 0:return this.loggerProvider=t.loggerProvider||new v,this.identifiers=new Mr({sessionId:t.sessionId,deviceId:t.deviceId}),n=this,[4,ur(e,t)];case 1:return n.joinedConfigGenerator=i.sent(),r=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:return r.config=i.sent(),o=this,[4,Cr({config:this.config,sessionId:this.identifiers.sessionId})];case 3:return o.eventsManager=i.sent(),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),(s=L())&&(s.removeEventListener("blur",this.blurListener),s.removeEventListener("focus",this.focusListener),s.addEventListener("blur",this.blurListener),s.addEventListener("focus",this.focusListener)),s&&s.document&&s.document.hasFocus()&&this.initialize(!0),[2]}}))}))},e.prototype.setSessionId=function(e,t){return p(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(s){switch(s.label){case 0:return(n=this.identifiers&&this.identifiers.sessionId)&&this.stopRecordingAndSendEvents(n),r=t||this.getDeviceId(),this.identifiers=new Mr({sessionId:e,deviceId:r}),this.joinedConfigGenerator&&n?(o=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]):[3,2];case 1:o.config=s.sent(),s.label=2;case 2:return this.recordEvents(),[2]}}))}))},e.prototype.getSessionReplayDebugPropertyValue=function(){var e="";return this.config&&(e=dr(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={})[A]=this.identifiers.sessionReplayId?this.identifiers.sessionReplayId:null,e);return this.config.debugMode&&(n[j]=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=N(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=L();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,s=(n=this.identifiers.sessionId,r=this.config.sampleRate,o=dr(n.toString()),31*Math.abs(o)%100/100<r);return s||this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate.")),s},e.prototype.getBlockSelectors=function(){var e,t;return null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector},e.prototype.recordEvents=function(){var e,t=this,n=this.getShouldRecord(),r=null===(e=this.identifiers)||void 0===e?void 0:e.sessionId;n&&r&&(this.stopRecordingEvents(),this.recordCancelCallback=Vt({emit:function(e){var n=L();if(n&&n.document&&!n.document.hasFocus()||!t.getShouldRecord())t.stopRecordingAndSendEvents();else{var o=JSON.stringify(e),s=t.getDeviceId();s&&t.eventsManager&&t.eventsManager.addEvent({event:o,sessionId:r,deviceId:s})}},packFn:Tn,maskAllInputs:!0,maskTextClass:"amp-mask",blockClass:"amp-block",blockSelector:this.getBlockSelectors(),maskInputFn:lr,recordCanvas:!1,errorHandler:function(e){var n=e;if(n.message.includes("insertRule")&&n.message.includes("CSSStyleSheet"))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=N(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){return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){return c(this,(function(t){return this.eventsManager?[2,this.eventsManager.flush(e)]:[2]}))}))},e.prototype.shutdown=function(){var e=L();e&&(e.removeEventListener("blur",this.blurListener),e.removeEventListener("focus",this.focusListener)),this.stopRecordingAndSendEvents()},e}(),Er=function(e){return function(){var t=e.config||U();return{logger:t.loggerProvider,logLevel:t.logLevel}}},Or=function(){var e=new kr;return{init:I(e.init.bind(e),"init",Er(e)),setSessionId:I(e.setSessionId.bind(e),"setSessionId",Er(e)),getSessionId:I(e.getSessionId.bind(e),"getSessionId",Er(e)),getSessionReplayProperties:I(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",Er(e)),flush:I(e.flush.bind(e),"flush",Er(e)),shutdown:I(e.shutdown.bind(e),"shutdown",Er(e))}}(),Tr=Or.init,Rr=Or.setSessionId,xr=Or.getSessionId,Dr=Or.getSessionReplayProperties,Nr=Or.flush,Lr=Or.shutdown,_r="@amplitude/plugin-session-replay-enrichment-browser",Pr=function(){function e(){this.name=_r,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!==xr()?[4,Rr(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=Dr(),e.event_properties=i(i({},e.event_properties),t)),[2,Promise.resolve(e)]}}))}))},e}(),Ar=function(){function e(e){this.name="@amplitude/plugin-session-replay-browser",this.type="destination",this.options=i({},e),!1!==this.options.forceSessionTracking&&(this.options.forceSessionTracking=!0)}return e.prototype.setup=function(e,t){var n;return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.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=i(i({},e.defaultTracking),{sessions:!0})),[4,Tr(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},debugMode:this.options.debugMode,configEndpointUrl:this.options.configEndpointUrl}).promise]):(e.loggerProvider.error("SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK."),[2]);case 1:return r.sent(),[4,t.add(new Pr).promise];case 2:return r.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,Nr(!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(_r).promise];case 1:return e.sent(),Lr(),this.config=null,this.clientRemove=null,[2]}}))}))},e.prototype.getSessionReplayProperties=function(){return Dr()},e}(),Fr=function(e){return new Ar(e)};return e.plugin=Fr,e.sessionReplayPlugin=Fr,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,s,i=function(){return i=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},i.apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,a)}c((r=r.apply(e,t||[])).next())}))}function c(e,t){var n,r,o,s,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)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 i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=i.trys,(o=o.length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}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 u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,o,s=n.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)i.push(r.value)}catch(e){o={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(o)throw o.error}}return i}function l(e,t,n){if(n||2===arguments.length)for(var r,o=0,s=t.length;o<s;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"}(s||(s={}));var d="".concat("AMP","_unsent"),h="https://api2.amplitude.com/2/httpapi",p=function(e){return{promise:e||Promise.resolve()}},f="Amplitude Logger ",v=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(f,"[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(f,"[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(f,"[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(f,"[Debug]: ").concat(e.join(" ")))},e}(),m=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:"$default_instance",logLevel:r.Warn,loggerProvider:new v,optOut:!1,serverUrl:h,serverZone:o.US,useBatch:!1}},g=function(){function e(e){var t,n,r,o;this._optOut=!1;var s=m();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:s.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||s.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||s.flushQueueSize,this.instanceName=e.instanceName||s.instanceName,this.loggerProvider=e.loggerProvider||s.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:s.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:s.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||s.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(o=e.useBatch)&&void 0!==o?o:s.useBatch,this.loggerProvider.enable(this.logLevel);var i=S(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=i.serverZone,this.serverUrl=i.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),y=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":h},S=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=m().serverZone),void 0===n&&(n=m().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:m().serverZone;return{serverZone:r,serverUrl:y(r,n)}},b=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},I=function(e,t,n,o,s){return void 0===s&&(s=null),function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var c=n(),u=c.logger,l=c.logLevel;if(l&&l<r.Debug||!l||!u)return e.apply(s,i);var d={type:"invoke public method",name:t,args:i,stacktrace:b(1),time:{start:(new Date).toISOString()},states:{}};o&&d.states&&(d.states.before=o());var h=e.apply(s,i);return h&&h.promise?h.promise.then((function(){o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),u.debug(JSON.stringify(d,null,2))})):(o&&d.states&&(d.states.after=o()),d.time&&(d.time.end=(new Date).toISOString()),u.debug(JSON.stringify(d,null,2))),h}},w=function(){function e(){}return e.prototype.send=function(e,t){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,o,i,a,c,u,l,d,h,p,f,v,m,g,y,S,b,I,w,C;if("object"!=typeof e)return null;var M=e.code||0,k=this.buildStatus(M);switch(k){case s.Success:return{status:k,statusCode:M,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 s.Invalid:return{status:k,statusCode:M,body:{error:null!==(o=e.error)&&void 0!==o?o:"",missingField:null!==(i=e.missing_field)&&void 0!==i?i:"",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!==(u=e.events_with_invalid_id_lengths)&&void 0!==u?u:{},epsThreshold:null!==(l=e.eps_threshold)&&void 0!==l?l: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 s.PayloadTooLarge:return{status:k,statusCode:M,body:{error:null!==(m=e.error)&&void 0!==m?m:""}};case s.RateLimit:return{status:k,statusCode:M,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 s.Timeout:default:return{status:k,statusCode:M}}},e.prototype.buildStatus=function(e){return e>=200&&e<300?s.Success:429===e?s.RateLimit:413===e?s.PayloadTooLarge:408===e?s.Timeout:e>=400&&e<500?s.Invalid:e>=500?s.Failed:s.Unknown},e}(),C=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)||""},k=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}(),E=function(){return E=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},E.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 s=Array.isArray(e),i=Array.isArray(t);if(s!==i)return!1;if(!s||!i){var a=Object.keys(e).sort(),c=Object.keys(t).sort();if(!O(a,c))return!1;var u=!0;return Object.keys(e).forEach((function(n){O(e[n],t[n])||(u=!1)})),u}for(var l=0;l<e.length;l++)if(!O(e[l],t[l]))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 T,R=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=E({},this.identity.userProperties),n=E(E({},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 s=o[r],i=s[0],a=s[1];switch(i){case"$set":for(var c=0,u=Object.entries(a);c<u.length;c++){var l=u[c],d=l[0],h=l[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 E({},this.identity)},e.prototype.setIdentity=function(e){var t=E({},this.identity);this.identity=E({},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}(),x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,D=function(){function e(){this.identityStore=new R,this.eventBridge=new k,this.applicationContextProvider=new C}return e.getInstance=function(t){return x.analyticsConnectorInstances||(x.analyticsConnectorInstances={}),x.analyticsConnectorInstances[t]||(x.analyticsConnectorInstances[t]=new e),x.analyticsConnectorInstances[t]},e}(),N=function(e){return void 0===e&&(e="$default_instance"),D.getInstance(e)},L=function(){return"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},_=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(s){switch(s.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=s.sent()).text()];case 2:o=s.sent();try{return[2,this.buildResponse(JSON.parse(o))]}catch(e){return[2,this.buildResponse({code:r.status})]}return[2]}}))}))},t}(w),P="[Amplitude]",A="".concat(P," Session Replay ID"),F=o.US,j="".concat(P," Session Replay Debug"),U=function(){return{flushMaxRetries:2,logLevel:r.Warn,loggerProvider:new v,transportProvider:new _}},q=function(e){function t(t,n){var r=this,o=U();return(r=e.call(this,i(i({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||F,r.configEndpointUrl=n.configEndpointUrl,n.privacyConfig&&(r.privacyConfig=n.privacyConfig),n.debugMode&&(r.debugMode=n.debugMode),r}return n(t,e),t}(g);function B(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function W(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function z(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t,G).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 G(e){var t,n,r;if(function(e){return"styleSheet"in e}(e))try{t=z(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"}(T||(T={}));var V=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 K(e){var t=e.element,n=e.maskInputOptions,r=e.tagName,o=e.type,s=e.value,i=e.maskInputFn,a=s||"",c=o&&H(o);return(n[r.toLowerCase()]||c&&n[c])&&(a=i?i(a,t):"*".repeat(a.length)),a}function H(e){return e.toLowerCase()}var Z="__rrweb_original__";function J(e){var t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?H(t):null}var $,Y,X=1,Q=new RegExp("[^a-z0-9-_:]");function ee(){return X++}var te=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ne=/^(?:[a-z+]+:)?\/\//i,re=/^www\..*/i,oe=/^(data:)([^,]*),(.*)/i;function se(e,t){return(e||"").replace(te,(function(e,n,r,o,s,i){var a,c=r||s||i,u=n||o||"";if(!c)return e;if(ne.test(c)||re.test(c))return"url(".concat(u).concat(c).concat(u,")");if(oe.test(c))return"url(".concat(u).concat(c).concat(u,")");if("/"===c[0])return"url(".concat(u).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(u,")");var l=t.split("/"),d=c.split("/");l.pop();for(var h=0,p=d;h<p.length;h++){var f=p[h];"."!==f&&(".."===f?l.pop():l.push(f))}return"url(".concat(u).concat(l.join("/")).concat(u,")")}))}var ie=/^[^ \t\n\r\u000c]+/,ae=/^[, \t\n\r\u000c]+/;function ce(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function ue(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function le(){var e=document.createElement("a");return e.href="",e.href}function de(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?ce(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(ae),!(n>=t.length);){var s=r(ie);if(","===s.slice(-1))s=ce(e,s.substring(0,s.length-1)),o.push(s);else{var i="";s=ce(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){o.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,o.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n?se(r,le()):"object"===t&&"data"===n?ce(e,r):r:ce(e,r):r}function he(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function pe(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&pe(e.parentNode,t,n);for(var r=e.classList.length;r--;){var o=e.classList[r];if(t.test(o))return!0}return!!n&&pe(e.parentNode,t,n)}function fe(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(pe(r,t,!0))return!0;if(n){if(r.matches(n))return!0;if(r.closest(n))return!0}}catch(e){}return!1}function ve(e,t){var n=t.doc,r=t.mirror,o=t.blockClass,s=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,c=t.inlineStylesheet,u=t.maskInputOptions,l=void 0===u?{}:u,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:T.Document,childNodes:[],compatMode:e.compatMode}:{type:T.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:T.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,s=t.inlineStylesheet,i=t.maskInputOptions,a=void 0===i?{}:i,c=t.maskInputFn,u=t.dataURLOptions,l=void 0===u?{}:u,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=H(e.tagName);return Q.test(t)?"div":t}(e),S={},b=e.attributes.length,I=0;I<b;I++){var w=e.attributes[I];he(y,w.name,w.value)||(S[w.name]=de(n,y,H(w.name),w.value))}if("link"===y&&s){var C=Array.from(n.styleSheets).find((function(t){return t.href===e.href})),M=null;C&&(M=z(C)),M&&(delete S.rel,delete S.href,S._cssText=se(M,C.href))}if("style"===y&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(M=z(e.sheet))&&(S._cssText=se(M,le()))}if("input"===y||"textarea"===y||"select"===y){var k=e.value,E=e.checked;if("radio"!==S.type&&"checkbox"!==S.type&&"submit"!==S.type&&"button"!==S.type&&k){var O=J(e);S.value=K({element:e,type:O,tagName:y,value:k,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,s=Z in o?o[Z]:o;if(new Uint32Array(s.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(l.type,l.quality));else if(!("__context"in e)){var R=e.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=e.width,x.height=e.height,R!==x.toDataURL(l.type,l.quality)&&(S.rr_dataURL=R)}if("img"===y&&d){$||($=n.createElement("canvas"),Y=$.getContext("2d"));var D=e,N=D.crossOrigin;D.crossOrigin="anonymous";var L=function(){D.removeEventListener("load",L);try{$.width=D.naturalWidth,$.height=D.naturalHeight,Y.drawImage(D,0,0),S.rr_dataURL=$.toDataURL(l.type,l.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:T.Element,tagName:y,attributes:S,childNodes:[],isSVG:ue(e)||void 0,needBlock:g,rootId:m}}(e,{doc:n,blockClass:o,blockSelector:s,inlineStylesheet:c,maskInputOptions:l,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,s=t.maskTextFn,i=t.rootId,a=e.parentNode&&e.parentNode.tagName,c=e.textContent,u="STYLE"===a||void 0,l="SCRIPT"===a||void 0;if(u&&c){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=z(e.parentNode.sheet))}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}c=se(c,le())}l&&(c="SCRIPT_PLACEHOLDER");!u&&!l&&c&&fe(e,r,o)&&(c=s?s(c,e.parentElement):c.replace(/[\S]/g,"*"));return{type:T.Text,textContent:c||"",isStyle:u,rootId:i}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:d,rootId:b});case e.CDATA_SECTION_NODE:return{type:T.CDATA,textContent:"",rootId:b};case e.COMMENT_NODE:return{type:T.Comment,textContent:e.textContent||"",rootId:b};default:return!1}}function me(e){return null==e?"":e.toLowerCase()}function ge(e,t){var n,r=t.doc,o=t.mirror,s=t.blockClass,i=t.blockSelector,a=t.maskTextClass,c=t.maskTextSelector,u=t.skipChild,l=void 0!==u&&u,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,M=t.onSerialize,k=t.onIframeLoad,E=t.iframeLoadTimeout,O=void 0===E?5e3:E,R=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=ve(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,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===T.Comment)return!0;if(e.type===T.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&&(me(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===me(e.attributes.name)||"icon"===me(e.attributes.rel)||"apple-touch-icon"===me(e.attributes.rel)||"shortcut icon"===me(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&me(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(me(e.attributes.property).match(/^(og|twitter|fb):/)||me(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===me(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===me(e.attributes.name)||"googlebot"===me(e.attributes.name)||"bingbot"===me(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===me(e.attributes.name)||"generator"===me(e.attributes.name)||"framework"===me(e.attributes.name)||"publisher"===me(e.attributes.name)||"progid"===me(e.attributes.name)||me(e.attributes.property).match(/^article:/)||me(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===me(e.attributes.name)||"yandex-verification"===me(e.attributes.name)||"csrf-token"===me(e.attributes.name)||"p:domain_verify"===me(e.attributes.name)||"verify-v1"===me(e.attributes.name)||"verification"===me(e.attributes.name)||"shopify-checkout-api-token"===me(e.attributes.name)))return!0}}return!1}(j,g)&&(F||j.type!==T.Text||j.isStyle||j.textContent.replace(/^\s+|\s+$/gm,"").length)?ee():-2;var U=Object.assign(j,{id:n});if(o.add(e,U),-2===n)return null;M&&M(e);var q=!l;if(U.type===T.Element){q=q&&!U.needBlock,delete U.needBlock;var z=e.shadowRoot;z&&W(z)&&(U.isShadowHost=!0)}if((U.type===T.Document||U.type===T.Element)&&q){g.headWhitespace&&U.type===T.Element&&"head"===U.tagName&&(F=!1);for(var G={doc:r,mirror:o,blockClass:s,blockSelector:i,maskTextClass:a,maskTextSelector:c,skipChild:l,inlineStylesheet:h,maskInputOptions:f,maskTextFn:v,maskInputFn:m,slimDOMOptions:g,dataURLOptions:S,inlineImages:I,recordCanvas:C,preserveWhiteSpace:F,onSerialize:M,onIframeLoad:k,iframeLoadTimeout:O,onStylesheetLoad:R,stylesheetLoadTimeout:D,keepIframeSrcFn:L},V=0,K=Array.from(e.childNodes);V<K.length;V++){(J=ge(K[V],G))&&U.childNodes.push(J)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var H=0,Z=Array.from(e.shadowRoot.childNodes);H<Z.length;H++){var J;(J=ge(Z[H],G))&&(W(e.shadowRoot)&&(J.isShadow=!0),U.childNodes.push(J))}}return e.parentNode&&B(e.parentNode)&&W(e.parentNode)&&(U.isShadow=!0),U.type===T.Element&&"iframe"===U.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var o,s=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var i="about:blank";if(r.location.href!==i||e.src===i||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout((function(){s||(t(),s=!0)}),n);e.addEventListener("load",(function(){clearTimeout(a),s=!0,t()}))}}}(e,(function(){var t=e.contentDocument;if(t&&k){var n=ge(t,{doc:t,mirror:o,blockClass:s,blockSelector:i,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:M,onIframeLoad:k,iframeLoadTimeout:O,onStylesheetLoad:R,stylesheetLoadTimeout:D,keepIframeSrcFn:L});n&&k(e,n)}}),O),U.type===T.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 s=setTimeout((function(){o||(t(),o=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),o=!0,t()}))}}(e,(function(){if(R){var t=ge(e,{doc:r,mirror:o,blockClass:s,blockSelector:i,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:M,onIframeLoad:k,iframeLoadTimeout:O,onStylesheetLoad:R,stylesheetLoadTimeout:D,keepIframeSrcFn:L});t&&R(e,t)}}),D),U}var ye=(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))(ye||{}),Se=(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))(Se||{}),be=(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))(be||{}),Ie=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Ie||{}),we=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(we||{});function Ce(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Me="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 ke={map:{},getId:()=>(console.error(Me),-1),getNode:()=>(console.error(Me),null),removeNodeFromMap(){console.error(Me)},has:()=>(console.error(Me),!1),reset(){console.error(Me)}};function Ee(e,t,n={}){let r=null,o=0;return function(...s){const i=Date.now();o||!1!==n.leading||(o=i);const a=t-(i-o),c=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),o=i,e.apply(c,s)):r||!1===n.trailing||(r=setTimeout((()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,s)}),a))}}function Oe(e,t,n,r,o=window){const s=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>Oe(e,t,s||{},!0)}function Te(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&&(ke=new Proxy(ke,{get:(e,t,n)=>("map"===t&&console.error(Me),Reflect.get(e,t,n))}));let Re,xe=Date.now;function De(e){var t,n,r,o,s,i;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===(s=null===(o=null==a?void 0:a.body)||void 0===o?void 0:o.parentElement)||void 0===s?void 0:s.scrollTop)||(null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.scrollTop)||0}}function Ne(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function Le(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function _e(e){if(!e)return null;return e.nodeType===e.ELEMENT_NODE?e:e.parentElement}function Pe(e,t,n,r){if(!e)return!1;const o=_e(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(pe(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 Ae(e,t){return-2===t.getId(e)}function Fe(e,t){if(B(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Fe(e.parentNode,t))}function je(e){return Boolean(e.changedTouches)}function Ue(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function qe(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Be(e){return Boolean(null==e?void 0:e.shadowRoot)}/[1-9][0-9]{12}/.test(Date.now().toString())||(xe=()=>(new Date).getTime());class We{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 ze(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 Ge(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=ze(n);)n=t;return n}(e);return t.contains(n)}function Ve(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||Ge(e))}function Ke(e){Re=e}function He(){Re=void 0}const Ze=e=>{if(!Re)return e;return(...t)=>{try{return e(...t)}catch(e){if(Re&&!0===Re(e))return;throw e}}};class Je{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),s=r||this.getRemoteIdToIdMap(e);let i=o.get(t);return i||(i=this.generateIdFn(),o.set(t,i),s.set(i,t)),i}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 $e{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new Je(ee),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new Je(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 ye.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:ye.IncrementalSnapshot,data:{source:Se.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case ye.Meta:case ye.Load:case ye.DomContentLoaded:return!1;case ye.Plugin:return t;case ye.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case ye.IncrementalSnapshot:switch(t.data.source){case Se.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 Se.Drag:case Se.TouchMove:case Se.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case Se.ViewportResize:return!1;case Se.MediaInteraction:case Se.MouseInteraction:case Se.Scroll:case Se.CanvasMutation:case Se.Input:return this.replaceIds(t.data,e,["id"]),t;case Se.StyleSheetRule:case Se.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case Se.Font:return t;case Se.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case Se.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===T.Document||e.rootId||(e.rootId=t),"childNodes"in e&&e.childNodes.forEach((e=>{this.patchRootIdOnNode(e,t)}))}}function Ye(e){return"__ln"in e}class Xe{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&&Ye(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&&Ye(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 Qe=(e,t)=>`${e}@${t}`;class et{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 Xe,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||!Ve(o))return;const s=B(o.parentNode)?this.mirror.getId(ze(o)):this.mirror.getId(o.parentNode),i=r(o);if(-1===s||-1===i)return n.addNode(o);const a=ge(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=>{Ue(e,this.mirror)&&this.iframeManager.addIframe(e),qe(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Be(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:s,nextId:i,node:a}),t.add(a.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)nt(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of this.addedSet)ot(this.droppedSet,e)||nt(this.removes,e,this.mirror)?ot(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let s=null;for(;n.length;){let e=null;if(s){const t=this.mirror.getId(s.value.parentNode),n=r(s.value);-1!==t&&-1!==n&&(e=s)}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}s=e.previous,n.removeNode(e.value),o(e.value)}const i={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};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!Ae(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Pe(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:fe(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t,_e(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=J(t);r=K({element:t,maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(Pe(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"),!he(t.tagName,n)&&(o.attributes[n]=de(this.doc,H(t.tagName),H(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),s=t.style.getPropertyPriority(e);n!==r.style.getPropertyValue(e)||s!==r.style.getPropertyPriority(e)?o.styleDiff[e]=""===s?n:[n,s]:o._unchangedStyles[e]=[n,s]}for(const e of Array.from(r.style))""===t.style.getPropertyValue(e)&&(o.styleDiff[e]=!1)}break}case"childList":if(Pe(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=B(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Pe(e.target,this.blockClass,this.blockSelector,!1)||Ae(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(tt(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Fe(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Qe(n,r)]?tt(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!B(e.target)||!W(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(Ae(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[Qe(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Pe(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach((e=>this.genAdds(e))),Be(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 tt(e,t){e.delete(t),t.childNodes.forEach((t=>tt(e,t)))}function nt(e,t,n){return 0!==e.length&&rt(e,t,n)}function rt(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some((e=>e.id===o))||rt(e,r,n)}function ot(e,t){return 0!==e.size&&st(e,t)}function st(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||st(e,n))}const it=[];function at(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 ct(e,t){var n,r;const o=new et;it.push(o),o.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=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");i&&window[i]&&(s=window[i]);const a=new s(Ze(o.processMutations.bind(o)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ut({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];let c=null;return Object.keys(be).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{let i=H(s);const u=(t=>s=>{const i=at(s);if(Pe(i,r,o,!0))return;let a=null,u=t;if("pointerType"in s){switch(s.pointerType){case"mouse":a=Ie.Mouse;break;case"touch":a=Ie.Touch;break;case"pen":a=Ie.Pen}a===Ie.Touch?be[t]===be.MouseDown?u="TouchStart":be[t]===be.MouseUp&&(u="TouchEnd"):Ie.Pen}else je(s)&&(a=Ie.Touch);null!==a?(c=a,(u.startsWith("Touch")&&a===Ie.Touch||u.startsWith("Mouse")&&a===Ie.Mouse)&&(a=null)):be[t]===be.Click&&(a=c,c=null);const l=je(s)?s.changedTouches[0]:s;if(!l)return;const d=n.getId(i),{clientX:h,clientY:p}=l;Ze(e)(Object.assign({type:be[u],id:d,x:h,y:p},null!==a&&{pointerType:a}))})(s);if(window.PointerEvent)switch(be[s]){case be.MouseDown:case be.MouseUp:i=i.replace("mouse","pointer");break;case be.TouchStart:case be.TouchEnd:return}a.push(Ce(i,u,t))})),Ze((()=>{a.forEach((e=>e()))}))}function lt({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:s}){return Ce("scroll",Ze(Ee(Ze((s=>{const i=at(s);if(!i||Pe(i,r,o,!0))return;const a=n.getId(i);if(i===t&&t.defaultView){const n=De(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})})),s.scroll||100)),t)}function dt(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const ht=["INPUT","TEXTAREA","SELECT"],pt=new WeakMap;function ft(e){return function(e,t){if(yt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||yt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||yt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||yt("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 vt(e,t,n){let r,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function mt({mirror:e,stylesheetManager:t},n){var r,o,s;let i=null;i="#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===(s=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===s?void 0:s.ShadowRoot,c=(null==a?void 0:a.prototype)?Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets"):void 0;return null!==i&&-1!==i&&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!==i&&-1!==i)try{t.adoptStyleSheets(e,i)}catch(e){}return r}}),Ze((()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}))):()=>{}}function gt(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};let r;!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:u,styleDeclarationCb:l,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),s(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),i(...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),u(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),l(...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=ct(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,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=Ee(Ze((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null})),s),u=Ze(Ee(Ze((e=>{const t=at(e),{clientX:n,clientY:o}=je(e)?e.changedTouches[0]:e;i||(i=xe()),a.push({x:n,y:o,id:r.getId(t),timeOffset:xe()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Se.Drag:e instanceof MouseEvent?Se.MouseMove:Se.TouchMove)})),o,{trailing:!1})),l=[Ce("mousemove",u,n),Ce("touchmove",u,n),Ce("drag",u,n)];return Ze((()=>{l.forEach((e=>e()))}))}(e),s=ut(e),i=lt(e),a=function({viewportResizeCb:e},{win:t}){let n=-1,r=-1;return Ce("resize",Ze(Ee(Ze((()=>{const t=Ne(),o=Le();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:s,ignoreSelector:i,maskInputOptions:a,maskInputFn:c,sampling:u,userTriggeredOnInput:l}){function d(e){let n=at(e);const u=e.isTrusted,d=n&&n.tagName;if(n&&"OPTION"===d&&(n=n.parentElement),!n||!d||ht.indexOf(d)<0||Pe(n,r,o,!0))return;if(n.classList.contains(s)||i&&n.matches(i))return;let p=n.value,f=!1;const v=J(n)||"";"radio"===v||"checkbox"===v?f=n.checked:(a[d.toLowerCase()]||a[v])&&(p=K({element:n,maskInputOptions:a,tagName:d,type:v,value:p,maskInputFn:c})),h(n,Ze(dt)({text:p,isChecked:f,userTriggered:u},l));const m=n.name;"radio"===v&&m&&f&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&h(e,Ze(dt)({text:e.value,isChecked:!f,userTriggered:!1},l))}))}function h(t,r){const o=pt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){pt.set(t,r);const o=n.getId(t);Ze(e)(Object.assign(Object.assign({},r),{id:o}))}}const p=("last"===u.input?["change"]:["input","change"]).map((e=>Ce(e,Ze(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=>Oe(e[0],e[1],{set(){Ze(d)({target:this,isTrusted:!1})}},!1,f)))),Ze((()=>{p.forEach((e=>e()))}))}(e),u=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o,doc:s}){const i=Ze((s=>Ee(Ze((o=>{const i=at(o);if(!i||Pe(i,t,n,!0))return;const{currentTime:a,volume:c,muted:u,playbackRate:l}=i;e({type:s,id:r.getId(i),currentTime:a,volume:c,muted:u,playbackRate:l})})),o.media||500))),a=[Ce("play",i(0),s),Ce("pause",i(1),s),Ce("seeked",i(2),s),Ce("volumechange",i(3),s),Ce("ratechange",i(4),s)];return Ze((()=>{a.forEach((e=>e()))}))}(e);let l=()=>{},d=()=>{},h=()=>{},p=()=>{};e.recordDOM&&(l=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:Ze(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=vt(o,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:a}]}),r.apply(o,s)}))});const s=r.CSSStyleSheet.prototype.deleteRule;let i,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(s,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:i}]}),r.apply(o,s)}))}),r.CSSStyleSheet.prototype.replace&&(i=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(i,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replace:i}),r.apply(o,s)}))})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,replaceSync:i}),r.apply(o,s)}))}));const c={};St("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(St("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),St("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),St("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const u={};return Object.entries(c).forEach((([r,o])=>{u[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(u[r].insertRule,{apply:Ze(((r,o,s)=>{const[i,a]=s,{id:c,styleId:u}=vt(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||u&&-1!==u)&&e({id:c,styleId:u,adds:[{rule:i,index:[...ft(o),a||0]}]}),r.apply(o,s)}))}),o.prototype.deleteRule=new Proxy(u[r].deleteRule,{apply:Ze(((r,o,s)=>{const[i]=s,{id:a,styleId:c}=vt(o.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,removes:[{index:[...ft(o),i]}]}),r.apply(o,s)}))})})),Ze((()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=s,i&&(r.CSSStyleSheet.prototype.replace=i),a&&(r.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=u[e].insertRule,t.prototype.deleteRule=u[e].deleteRule}))}))}(e,{win:n}),d=mt(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const s=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(s,{apply:Ze(((o,i,a)=>{var c;const[u,l,d]=a;if(n.has(u))return s.apply(i,[u,l,d]);const{id:h,styleId:p}=vt(null===(c=i.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:u,value:l,priority:d},index:ft(i.parentRule)}),o.apply(i,a)}))});const i=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(i,{apply:Ze(((o,s,a)=>{var c;const[u]=a;if(n.has(u))return i.apply(s,[u]);const{id:l,styleId:d}=vt(null===(c=s.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,remove:{property:u},index:ft(s.parentRule)}),o.apply(s,a)}))}),Ze((()=>{o.CSSStyleDeclaration.prototype.setProperty=s,o.CSSStyleDeclaration.prototype.removeProperty=i}))}(e,{win:n}),e.collectFonts&&(p=function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const r=new s(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 i=Te(t.fonts,"add",(function(t){return function(n){return setTimeout(Ze((()=>{const t=o.get(n);t&&(e(t),o.delete(n))})),0),t.apply(this,[n])}}));return r.push((()=>{n.FontFace=s})),r.push(i),Ze((()=>{r.forEach((e=>e()))}))}(e)));const f=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:s}=e;let i=!0;const a=Ze((()=>{const e=t.getSelection();if(!e||i&&(null==e?void 0:e.isCollapsed))return;i=e.isCollapsed||!1;const a=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const s=e.getRangeAt(t),{startContainer:i,startOffset:c,endContainer:u,endOffset:l}=s;Pe(i,r,o,!0)||Pe(u,r,o,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(u),endOffset:l})}s({ranges:a})}));return a(),Ce("selectionchange",a)}(e),v=[];for(const t of e.plugins)v.push(t.observer(t.callback,n,t.options));return Ze((()=>{it.forEach((e=>e.reset())),null==r||r.disconnect(),o(),s(),i(),a(),c(),u(),l(),d(),h(),p(),f(),v.forEach((e=>e()))}))}function yt(e){return void 0!==window[e]}function St(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}function bt(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,a)}c((r=r.apply(e,t||[])).next())}))}for(var It,wt,Ct,Mt=(It=function(){!function(){function e(e,t,n,r){return new(n||(n=Promise))((function(o,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(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(i,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,s="";for(n=0;n<o;n+=3)s+=t[r[n]>>2],s+=t[(3&r[n])<<4|r[n+1]>>4],s+=t[(15&r[n+1])<<2|r[n+2]>>6],s+=t[63&r[n+2]];return o%3==2?s=s.substring(0,s.length-1)+"=":o%3==1&&(s=s.substring(0,s.length-2)+"=="),s};const s=new Map,i=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:u,dataURLOptions:l}=t.data,d=function(t,n,r){return e(this,void 0,void 0,(function*(){const e=`${t}-${n}`;if("OffscreenCanvas"in globalThis){if(i.has(e))return i.get(e);const s=new OffscreenCanvas(t,n);s.getContext("2d");const a=yield s.convertToBlob(r),c=yield a.arrayBuffer(),u=o(c);return i.set(e,u),u}return""}))}(c,u,l),h=new OffscreenCanvas(c,u);h.getContext("2d").drawImage(r,0,0),r.close();const p=yield h.convertToBlob(l),f=p.type,v=yield p.arrayBuffer(),m=o(v);if(!s.has(n)&&(yield d)===m)return s.set(n,m),a.postMessage({id:n});if(s.get(n)===m)return a.postMessage({id:n});a.postMessage({id:n,type:f,base64:m,width:c,height:u}),s.set(n,m)}}))}}()},wt=null,function(e){return Ct=Ct||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/),s=/(['"])__worker_loader_strict__(['"])/g,i=0,a=r.length;i<a;++i)r[i]=r[i].substring(o).replace(s,"$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)}(It,wt),new Worker(Ct,e)}),kt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ot=0;Ot<kt.length;Ot++)Et[kt.charCodeAt(Ot)]=Ot;const Tt=new Map;const Rt=(e,t,n)=>{if(!e||!Nt(e,t)&&"object"!=typeof e)return;const r=function(e,t){let n=Tt.get(e);return n||(n=new Map,Tt.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 xt(e,t,n){if(e instanceof Array)return e.map((e=>xt(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+=kt[n[t]>>2],o+=kt[(3&n[t])<<4|n[t+1]>>4],o+=kt[(15&n[t+1])<<2|n[t+2]>>6],o+=kt[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:[xt(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:[xt(e.data,t,n),e.width,e.height]}}if(Nt(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Rt(e,t,n)}}return e}const Dt=(e,t,n)=>[...e].map((e=>xt(e,t,n))),Nt=(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 Lt(e,t,n,r){const o=[];try{const s=Te(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...s){if(!Pe(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(s[0]&&"object"==typeof s[0]){const e=s[0];e.preserveDrawingBuffer||(e.preserveDrawingBuffer=!0)}else s.splice(0,1,{preserveDrawingBuffer:!0})}return e.apply(this,[o,...s])}}));o.push(s)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function _t(e,t,n,r,o,s,i){const a=[],c=Object.getOwnPropertyNames(e);for(const s of c)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof e[s])continue;const c=Te(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Rt(c,i,this),"tagName"in this.canvas&&!Pe(this.canvas,r,o,!0)){const e=Dt([...a],i,this),r={type:t,property:s,args:e};n(this.canvas,r)}return c}}));a.push(c)}catch(r){const o=Oe(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(o)}return a}class Pt{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:s,dataURLOptions:i}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,s&&"all"===t&&this.initCanvasMutationObserver(n,r,o),s&&"number"==typeof t&&this.initCanvasFPSObserver(t,n,r,o,{dataURLOptions:i})}initCanvasFPSObserver(e,t,n,r,o){const s=Lt(t,n,r,!0),i=new Map,a=new Mt;a.onmessage=e=>{const{id:t}=e.data;if(i.set(t,!1),!("base64"in e.data))return;const{base64:n,type:r,width:o,height:s}=e.data;this.mutationCb({id:t,type:we["2D"],commands:[{property:"clearRect",args:[0,0,o,s]},{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 u,l=0;const d=e=>{l&&e-l<c||(l=e,(()=>{const e=[];return t.document.querySelectorAll("canvas").forEach((t=>{Pe(t,n,r,!0)||e.push(t)})),e})().forEach((e=>bt(this,void 0,void 0,(function*(){var t;const n=this.mirror.getId(e);if(i.get(n))return;if(i.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])}))))),u=requestAnimationFrame(d)};u=requestAnimationFrame(d),this.resetObservers=()=>{s(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const r=Lt(e,t,n,!1),o=function(e,t,n,r){const o=[],s=Object.getOwnPropertyNames(t.CanvasRenderingContext2D.prototype);for(const i of s)try{if("function"!=typeof t.CanvasRenderingContext2D.prototype[i])continue;const s=Te(t.CanvasRenderingContext2D.prototype,i,(function(o){return function(...s){return Pe(this.canvas,n,r,!0)||setTimeout((()=>{const n=Dt([...s],t,this);e(this.canvas,{type:we["2D"],property:i,args:n})}),0),o.apply(this,s)}}));o.push(s)}catch(n){const r=Oe(t.CanvasRenderingContext2D.prototype,i,{set(t){e(this.canvas,{type:we["2D"],property:i,args:[t],setter:!0})}});o.push(r)}return()=>{o.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n),s=function(e,t,n,r,o){const s=[];return s.push(..._t(t.WebGLRenderingContext.prototype,we.WebGL,e,n,r,0,t)),void 0!==t.WebGL2RenderingContext&&s.push(..._t(t.WebGL2RenderingContext.prototype,we.WebGL2,e,n,r,0,t)),()=>{s.forEach((e=>e()))}}(this.processMutation.bind(this),e,t,n,this.mirror);this.resetObservers=()=>{r(),o(),s()}}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 At{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 Ft{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(!W(e))return;if(this.shadowDoms.has(e))return;this.shadowDoms.add(e);const n=ct(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(lt(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(mt({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(Te(e.prototype,"attachShadow",(function(e){return function(r){const o=e.call(this,r);return this.shadowRoot&&Ve(this)&&n.addShadowRoot(this.shadowRoot,t),o}})))}reset(){this.restoreHandlers.forEach((e=>{try{e()}catch(e){}})),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}class jt{constructor(e){this.trackedLinkElements=new WeakSet,this.styleMirror=new We,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:G(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 Ut(e){return Object.assign(Object.assign({},e),{timestamp:xe()})}let qt,Bt,Wt,zt=!1;const Gt=new V;function Vt(e={}){const{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:o="rr-block",blockSelector:s=null,ignoreClass:i="rr-ignore",ignoreSelector:a=null,maskTextClass:c="rr-mask",maskTextSelector:u=null,inlineStylesheet:l=!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:M=("DOMContentLoaded"===e.recordAfter?e.recordAfter:"load"),userTriggeredOnInput:k=!1,collectFonts:E=!1,inlineImages:O=!1,plugins:T,keepIframeSrcFn:R=(()=>!1),ignoreCSSAttributes:x=new Set([]),errorHandler:D}=e;Ke(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),Gt.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 T||[])t.eventProcessor&&(e=t.eventProcessor(e));return g&&!L&&(e=g(e)),e};qt=(e,o)=>{var s;if(!(null===(s=it[0])||void 0===s?void 0:s.isFrozen())||e.type===ye.FullSnapshot||e.type===ye.IncrementalSnapshot&&e.data.source===Se.Mutation||it.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===ye.FullSnapshot)A=e,F=0;else if(e.type===ye.IncrementalSnapshot){if(e.data.source===Se.Mutation&&e.data.isAttachIframe)return;F++;const t=r&&F>=r,o=n&&e.timestamp-A.timestamp>n;(t||o)&&Bt(!0)}};const U=e=>{qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Mutation},e)}))},q=e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Scroll},e)})),B=e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.CanvasMutation},e)})),W=new jt({mutationCb:U,adoptedStyleSheetCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.AdoptedStyleSheet},e)}))}),z=new $e({mirror:Gt,mutationCb:U,stylesheetManager:W,recordCrossOriginIframes:C,wrappedEmit:qt});for(const e of T||[])e.getMirror&&e.getMirror({nodeMirror:Gt,crossOriginIframeMirror:z.crossOriginIframeMirror,crossOriginIframeStyleMirror:z.crossOriginIframeStyleMirror});const G=new At;Wt=new Pt({recordCanvas:w,mutationCb:B,win:window,blockClass:o,blockSelector:s,mirror:Gt,sampling:y.canvas,dataURLOptions:S});const K=new Ft({mutationCb:U,scrollCb:q,bypassOptions:{blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskInputOptions:_,dataURLOptions:S,maskTextFn:v,maskInputFn:f,recordCanvas:w,inlineImages:O,sampling:y,slimDOMOptions:P,iframeManager:z,stylesheetManager:W,canvasManager:Wt,keepIframeSrcFn:R,processedNodeManager:G},mirror:Gt});Bt=(e=!1)=>{if(!I)return;qt(Ut({type:ye.Meta,data:{href:window.location.href,width:Le(),height:Ne()}}),e),W.reset(),K.init(),it.forEach((e=>e.lock()));const t=function(e,t){var n=t||{},r=n.mirror,o=void 0===r?new V:r,s=n.blockClass,i=void 0===s?"rr-block":s,a=n.blockSelector,c=void 0===a?null:a,u=n.maskTextClass,l=void 0===u?"rr-mask":u,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,M=void 0!==C&&C,k=n.dataURLOptions,E=n.preserveWhiteSpace,O=n.onSerialize,T=n.onIframeLoad,R=n.iframeLoadTimeout,x=n.onStylesheetLoad,D=n.stylesheetLoadTimeout,N=n.keepIframeSrcFn;return ge(e,{doc:e,mirror:o,blockClass:i,blockSelector:c,maskTextClass:l,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===M||"all"===M?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===M,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===M?{}:M,dataURLOptions:k,inlineImages:m,recordCanvas:y,preserveWhiteSpace:E,onSerialize:O,onIframeLoad:T,iframeLoadTimeout:R,onStylesheetLoad:x,stylesheetLoadTimeout:D,keepIframeSrcFn:void 0===N?function(){return!1}:N,newlyAddedElement:!1})}(document,{mirror:Gt,blockClass:o,blockSelector:s,maskTextClass:c,maskTextSelector:u,inlineStylesheet:l,maskAllInputs:_,maskTextFn:v,slimDOM:P,dataURLOptions:S,recordCanvas:w,inlineImages:O,onSerialize:e=>{Ue(e,Gt)&&z.addIframe(e),qe(e,Gt)&&W.trackLinkElement(e),Be(e)&&K.addShadowRoot(e.shadowRoot,document)},onIframeLoad:(e,t)=>{z.attachIframe(e,t),K.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{W.attachLinkElement(e,t)},keepIframeSrcFn:R});if(!t)return console.warn("Failed to snapshot the document");qt(Ut({type:ye.FullSnapshot,data:{node:t,initialOffset:De(window)}}),e),it.forEach((e=>e.unlock())),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&W.adoptStyleSheets(document.adoptedStyleSheets,Gt.getId(document))};try{const e=[],t=e=>{var t;return Ze(gt)({mutationCb:U,mousemoveCb:(e,t)=>qt(Ut({type:ye.IncrementalSnapshot,data:{source:t,positions:e}})),mouseInteractionCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.MouseInteraction},e)})),scrollCb:q,viewportResizeCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.ViewportResize},e)})),inputCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Input},e)})),mediaInteractionCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.MediaInteraction},e)})),styleSheetRuleCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.StyleSheetRule},e)})),styleDeclarationCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.StyleDeclaration},e)})),canvasMutationCb:B,fontCb:e=>qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Font},e)})),selectionCb:e=>{qt(Ut({type:ye.IncrementalSnapshot,data:Object.assign({source:Se.Selection},e)}))},blockClass:o,ignoreClass:i,ignoreSelector:a,maskTextClass:c,maskTextSelector:u,maskInputOptions:_,inlineStylesheet:l,sampling:y,recordDOM:I,recordCanvas:w,inlineImages:O,userTriggeredOnInput:k,collectFonts:E,doc:e,maskInputFn:f,maskTextFn:v,keepIframeSrcFn:R,blockSelector:s,slimDOMOptions:P,dataURLOptions:S,mirror:Gt,iframeManager:z,stylesheetManager:W,shadowDomManager:K,processedNodeManager:G,canvasManager:Wt,ignoreCSSAttributes:x,plugins:(null===(t=null==T?void 0:T.filter((e=>e.observer)))||void 0===t?void 0:t.map((e=>({observer:e.observer,options:e.options,callback:t=>qt(Ut({type:ye.Plugin,data:{plugin:e.name,payload:t}}))}))))||[]},m)};z.addLoadListener((n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}}));const n=()=>{Bt(),e.push(t(document)),zt=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():(e.push(Ce("DOMContentLoaded",(()=>{qt(Ut({type:ye.DomContentLoaded,data:{}})),"DOMContentLoaded"===M&&n()}))),e.push(Ce("load",(()=>{qt(Ut({type:ye.Load,data:{}})),"load"===M&&n()}),window))),()=>{e.forEach((e=>e())),G.destroy(),zt=!1,He()}}catch(e){console.warn(e)}}var Kt,Ht;Vt.addCustomEvent=(e,t)=>{if(!zt)throw new Error("please add custom event after start recording");qt(Ut({type:ye.Custom,data:{tag:e,payload:t}}))},Vt.freezePage=()=>{it.forEach((e=>e.freeze()))},Vt.takeFullSnapshot=e=>{if(!zt)throw new Error("please take full snapshot after start recording");Bt(e)},Vt.mirror=Gt,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"}(Kt||(Kt={})),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"}(Ht||(Ht={}));var Zt=Uint8Array,Jt=Uint16Array,$t=Uint32Array,Yt=new Zt([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]),Xt=new Zt([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]),Qt=new Zt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),en=function(e,t){for(var n=new Jt(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var o=new $t(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)o[s]=s-n[r]<<5|r;return[n,o]},tn=en(Yt,2),nn=tn[0],rn=tn[1];nn[28]=258,rn[258]=28;for(var on=en(Xt,0)[1],sn=new Jt(32768),an=0;an<32768;++an){var cn=(43690&an)>>>1|(21845&an)<<1;cn=(61680&(cn=(52428&cn)>>>2|(13107&cn)<<2))>>>4|(3855&cn)<<4,sn[an]=((65280&cn)>>>8|(255&cn)<<8)>>>1}var un=function(e,t,n){for(var r=e.length,o=0,s=new Jt(t);o<r;++o)++s[e[o]-1];var i,a=new Jt(t);for(o=0;o<t;++o)a[o]=a[o-1]+s[o-1]<<1;if(n){i=new Jt(1<<t);var c=15-t;for(o=0;o<r;++o)if(e[o])for(var u=o<<4|e[o],l=t-e[o],d=a[e[o]-1]++<<l,h=d|(1<<l)-1;d<=h;++d)i[sn[d]>>>c]=u}else for(i=new Jt(r),o=0;o<r;++o)i[o]=sn[a[e[o]-1]++]>>>15-e[o];return i},ln=new Zt(288);for(an=0;an<144;++an)ln[an]=8;for(an=144;an<256;++an)ln[an]=9;for(an=256;an<280;++an)ln[an]=7;for(an=280;an<288;++an)ln[an]=8;var dn=new Zt(32);for(an=0;an<32;++an)dn[an]=5;var hn=un(ln,9,0),pn=un(dn,5,0),fn=function(e){return(e/8>>0)+(7&e&&1)},vn=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof Jt?Jt:e instanceof $t?$t:Zt)(n-t);return r.set(e.subarray(t,n)),r},mn=function(e,t,n){n<<=7&t;var r=t/8>>0;e[r]|=n,e[r+1]|=n>>>8},gn=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},yn=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,s=n.slice();if(!o)return[new Zt(0),0];if(1==o){var i=new Zt(n[0].s+1);return i[n[0].s]=1,[i,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],c=n[1],u=0,l=1,d=2;for(n[0]={s:-1,f:a.f+c.f,l:a,r:c};l!=o-1;)a=n[n[u].f<n[d].f?u++:d++],c=n[u!=l&&n[u].f<n[d].f?u++:d++],n[l++]={s:-1,f:a.f+c.f,l:a,r:c};var h=s[0].s;for(r=1;r<o;++r)s[r].s>h&&(h=s[r].s);var p=new Jt(h+1),f=Sn(n[l-1],p,0);if(f>t){r=0;var v=0,m=f-t,g=1<<m;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<o;++r){var y=s[r].s;if(!(p[y]>t))break;v+=g-(1<<f-p[y]),p[y]=t}for(v>>>=m;v>0;){var S=s[r].s;p[S]<t?v-=1<<t-p[S]++-1:++r}for(;r>=0&&v;--r){var b=s[r].s;p[b]==t&&(--p[b],++v)}f=t}return[new Zt(p),f]},Sn=function(e,t,n){return-1==e.s?Math.max(Sn(e.l,t,n+1),Sn(e.r,t,n+1)):t[e.s]=n},bn=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new Jt(++t),r=0,o=e[0],s=1,i=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==o&&a!=t)++s;else{if(!o&&s>2){for(;s>138;s-=138)i(32754);s>2&&(i(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(i(o),--s;s>6;s-=6)i(8304);s>2&&(i(s-3<<5|8208),s=0)}for(;s--;)i(o);s=1,o=e[a]}return[n.subarray(0,r),t]},In=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},wn=function(e,t,n){var r=n.length,o=fn(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 s=0;s<r;++s)e[o+s+4]=n[s];return 8*(o+4+r)},Cn=function(e,t,n,r,o,s,i,a,c,u,l){mn(t,l++,n),++o[256];for(var d=yn(o,15),h=d[0],p=d[1],f=yn(s,15),v=f[0],m=f[1],g=bn(h),y=g[0],S=g[1],b=bn(v),I=b[0],w=b[1],C=new Jt(19),M=0;M<y.length;++M)C[31&y[M]]++;for(M=0;M<I.length;++M)C[31&I[M]]++;for(var k=yn(C,7),E=k[0],O=k[1],T=19;T>4&&!E[Qt[T-1]];--T);var R,x,D,N,L=u+5<<3,_=In(o,ln)+In(s,dn)+i,P=In(o,h)+In(s,v)+i+14+3*T+In(C,E)+(2*C[16]+3*C[17]+7*C[18]);if(L<=_&&L<=P)return wn(t,l,e.subarray(c,c+u));if(mn(t,l,1+(P<_)),l+=2,P<_){R=un(h,p,0),x=h,D=un(v,m,0),N=v;var A=un(E,O,0);mn(t,l,S-257),mn(t,l+5,w-1),mn(t,l+10,T-4),l+=14;for(M=0;M<T;++M)mn(t,l+3*M,E[Qt[M]]);l+=3*T;for(var F=[y,I],j=0;j<2;++j){var U=F[j];for(M=0;M<U.length;++M){var q=31&U[M];mn(t,l,A[q]),l+=E[q],q>15&&(mn(t,l,U[M]>>>5&127),l+=U[M]>>>12)}}}else R=hn,x=ln,D=pn,N=dn;for(M=0;M<a;++M)if(r[M]>255){q=r[M]>>>18&31;gn(t,l,R[q+257]),l+=x[q+257],q>7&&(mn(t,l,r[M]>>>23&31),l+=Yt[q]);var B=31&r[M];gn(t,l,D[B]),l+=N[B],B>3&&(gn(t,l,r[M]>>>5&8191),l+=Xt[B])}else gn(t,l,R[r[M]]),l+=x[r[M]];return gn(t,l,R[256]),l+x[256]},Mn=new $t([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kn=new Zt(0),En=function(e,t,n,r,o){return function(e,t,n,r,o,s){var i=e.length,a=new Zt(r+i+5*(1+Math.floor(i/7e3))+o),c=a.subarray(r,a.length-o),u=0;if(!t||i<8)for(var l=0;l<=i;l+=65535){var d=l+65535;d<i?u=wn(c,u,e.subarray(l,d)):(c[l]=s,u=wn(c,u,e.subarray(l,i)))}else{for(var h=Mn[t-1],p=h>>>13,f=8191&h,v=(1<<n)-1,m=new Jt(32768),g=new Jt(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 $t(25e3),w=new Jt(288),C=new Jt(32),M=0,k=0,E=(l=0,0),O=0,T=0;l<i;++l){var R=b(l),x=32767&l,D=g[R];if(m[x]=D,g[R]=x,O<=l){var N=i-l;if((M>7e3||E>24576)&&N>423){u=Cn(e,c,0,I,w,C,k,E,T,l-T,u),E=M=k=0,T=l;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(l-F))for(var j=Math.min(p,N)-1,U=Math.min(32767,l),q=Math.min(258,N);F<=U&&--A&&x!=D;){if(e[l+_]==e[l+_-F]){for(var B=0;B<q&&e[l+B]==e[l+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=l-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|rn[_]<<18|on[P];var K=31&rn[_],H=31&on[P];k+=Yt[K]+Xt[H],++w[257+K],++C[H],O=l+_,++M}else I[E++]=e[l],++w[e[l]]}}u=Cn(e,c,s,I,w,C,k,E,T,l-T,u),s||(u=wn(c,u,kn))}return vn(a,0,r+fn(u)+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 On(e,t){void 0===t&&(t={});var n=function(){var e=1,t=0;return{p:function(n){for(var r=e,o=t,s=n.length,i=0;i!=s;){for(var a=Math.min(i+5552,s);i<a;++i)o+=r+=n[i];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=En(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 Tn=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}(On(function(e,t){var n=e.length;if(!t&&"undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Zt(e.length+(e.length>>>1)),o=0,s=function(e){r[o++]=e},i=0;i<n;++i){if(o+5>r.length){var a=new Zt(o+8+(n-i<<1));a.set(r),r=a}var c=e.charCodeAt(i);c<128||t?s(c):c<2048?(s(192|c>>>6),s(128|63&c)):c>55295&&c<57344?(s(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++i))>>>18),s(128|c>>>12&63),s(128|c>>>6&63),s(128|63&c)):(s(224|c>>>12),s(128|c>>>6&63),s(128|63&c))}return vn(r,0,o)}(JSON.stringify(t))),!0)};var Rn,xn;(xn=Rn||(Rn={}))[xn.NotStarted=0]="NotStarted",xn[xn.Running=1]="Running",xn[xn.Stopped=2]="Stopped";const Dn=(e,t)=>t.some((t=>e instanceof t));let Nn,Ln;const _n=new WeakMap,Pn=new WeakMap,An=new WeakMap;let Fn={get(e,t,n){if(e instanceof IDBTransaction){if("done"===t)return _n.get(e);if("store"===t)return n.objectStoreNames[1]?void 0:n.objectStore(n.objectStoreNames[0])}return Bn(e[t])},set:(e,t,n)=>(e[t]=n,!0),has:(e,t)=>e instanceof IDBTransaction&&("done"===t||"store"===t)||t in e};function jn(e){Fn=e(Fn)}function Un(e){return(Ln||(Ln=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])).includes(e)?function(...t){return e.apply(Wn(this),t),Bn(this.request)}:function(...t){return Bn(e.apply(Wn(this),t))}}function qn(e){return"function"==typeof e?Un(e):(e instanceof IDBTransaction&&function(e){if(_n.has(e))return;const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("complete",o),e.removeEventListener("error",s),e.removeEventListener("abort",s)},o=()=>{t(),r()},s=()=>{n(e.error||new DOMException("AbortError","AbortError")),r()};e.addEventListener("complete",o),e.addEventListener("error",s),e.addEventListener("abort",s)}));_n.set(e,t)}(e),Dn(e,Nn||(Nn=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction]))?new Proxy(e,Fn):e)}function Bn(e){if(e instanceof IDBRequest)return function(e){const t=new Promise(((t,n)=>{const r=()=>{e.removeEventListener("success",o),e.removeEventListener("error",s)},o=()=>{t(Bn(e.result)),r()},s=()=>{n(e.error),r()};e.addEventListener("success",o),e.addEventListener("error",s)}));return An.set(t,e),t}(e);if(Pn.has(e))return Pn.get(e);const t=qn(e);return t!==e&&(Pn.set(e,t),An.set(t,e)),t}const Wn=e=>An.get(e);function zn(e,t,{blocked:n,upgrade:r,blocking:o,terminated:s}={}){const i=indexedDB.open(e,t),a=Bn(i);return r&&i.addEventListener("upgradeneeded",(e=>{r(Bn(i.result),e.oldVersion,e.newVersion,Bn(i.transaction),e)})),n&&i.addEventListener("blocked",(e=>n(e.oldVersion,e.newVersion,e))),a.then((e=>{s&&e.addEventListener("close",(()=>s())),o&&e.addEventListener("versionchange",(e=>o(e.oldVersion,e.newVersion,e)))})).catch((()=>{})),a}function Gn(e,{blocked:t}={}){const n=indexedDB.deleteDatabase(e);return t&&n.addEventListener("blocked",(e=>t(e.oldVersion,e))),Bn(n).then((()=>{}))}const Vn=["get","getKey","getAll","getAllKeys","count"],Kn=["put","add","delete","clear"],Hn=new Map;function Zn(e,t){if(!(e instanceof IDBDatabase)||t in e||"string"!=typeof t)return;if(Hn.get(t))return Hn.get(t);const n=t.replace(/FromIndex$/,""),r=t!==n,o=Kn.includes(n);if(!(n in(r?IDBIndex:IDBObjectStore).prototype)||!o&&!Vn.includes(n))return;const s=async function(e,...t){const s=this.transaction(e,o?"readwrite":"readonly");let i=s.store;return r&&(i=i.index(t.shift())),(await Promise.all([i[n](...t),o&&s.done]))[0]};return Hn.set(t,s),s}jn((e=>({...e,get:(t,n,r)=>Zn(t,n)||e.get(t,n,r),has:(t,n)=>!!Zn(t,n)||e.has(t,n)})));const Jn=["continue","continuePrimaryKey","advance"],$n={},Yn=new WeakMap,Xn=new WeakMap,Qn={get(e,t){if(!Jn.includes(t))return e[t];let n=$n[t];return n||(n=$n[t]=function(...e){Yn.set(this,Xn.get(this)[t](...e))}),n}};async function*er(...e){let t=this;if(t instanceof IDBCursor||(t=await t.openCursor(...e)),!t)return;const n=new Proxy(t,Qn);for(Xn.set(n,t),An.set(n,Wn(t));t;)yield n,t=await(Yn.get(n)||t.continue()),Yn.delete(n)}function tr(e,t){return t===Symbol.asyncIterator&&Dn(e,[IDBIndex,IDBObjectStore,IDBCursor])||"iterate"===t&&Dn(e,[IDBIndex,IDBObjectStore])}jn((e=>({...e,get:(t,n,r)=>tr(t,n)?er:e.get(t,n,r),has:(t,n)=>tr(t,n)||e.has(t,n)})));var nr,rr=function(e,t){return a(void 0,void 0,void 0,(function(){return c(this,(function(n){switch(n.label){case 0:return[4,zn(e,1,{upgrade:function(e){t.forEach((function(t){e.objectStoreNames.contains(t)||e.createObjectStore(t)}))}})];case 1:return[2,n.sent()]}}))}))},or=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.configKeys;return a(void 0,void 0,void 0,(function(){var e,o,s,d,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,rr(e,r)];case 1:return o=g.sent(),s="".concat(n.substring(0,10),"_amp_config_meta"),[4,(y=s,a(void 0,void 0,void 0,(function(){return c(this,(function(e){switch(e.label){case 0:return[4,zn(y,1,{upgrade:function(e){e.objectStoreNames.contains("lastFetchedSessionId")||e.createObjectStore("lastFetchedSessionId")}})];case 1:return[2,e.sent()]}}))})))];case 2:d=g.sent(),g.label=3;case 3:return g.trys.push([3,8,,9]),[4,d.get("lastFetchedSessionId","sessionId")];case 4:return(h=g.sent())&&Date.now()-h>=2592e5?[4,Gn(e)]:[3,7];case 5:return g.sent(),[4,rr(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,s,a,h,p,f;return c(this,(function(v){switch(v.label){case 0:return v.trys.push([0,7,,8]),n?[4,d.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(s){switch(s.label){case 0:return n=e.configs[t],r=o.transaction(t,"readwrite"),[4,Promise.all(l(l([],u(Object.keys(n).map((function(e){return r.store.put(i({},n[e]),e)}))),!1),[r.done],!1))];case 1:return s.sent(),[2]}}))},s=e.configs,a=[],s)a.push(h);p=0,v.label=3;case 3:return p<a.length?(h=a[p])in s?[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,d.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(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,o.get(e,n)];case 1:return[2,s.sent()];case 2:return r=s.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}))}))},sr="Remote config fetch rejected due to timeout after 5 seconds",ir=function(){function e(e){var t=e.localConfig,n=e.configKeys,r=this;this.retryTimeout=1e3,this.attempts=0,this.sessionTargetingMatch=!1,this.getRemoteConfig=function(e,t,n){return a(r,void 0,void 0,(function(){var r,o,s,i;return c(this,(function(a){switch(a.label){case 0:return this.remoteConfigIDBStore?[4,this.remoteConfigIDBStore.getRemoteConfig(e,t)]:[3,3];case 1:return r=a.sent(),[4,this.remoteConfigIDBStore.getLastFetchedSessionId()];case 2:if(o=a.sent(),r&&o===n)return[2,r];a.label=3;case 3:return[4,this.fetchWithTimeout(n)];case 4:return(s=a.sent())&&(i=s.configs&&s.configs[e])?[2,i[t]]:[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,u,l;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:sr})];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,i(i({},r),{signal:e}))];case 2:if(null===(a=c.sent()))return[2,this.completeRequest({err:"Unexpected error occurred"})];switch((new w).buildStatus(a.status)){case s.Success:return[2,this.parseAndStoreConfig(a,t)];case s.Failed:return[2,this.retryFetch(e,t)];default:return[2,this.completeRequest({err:"Network error occurred, remote config fetch failed"})]}case 3:return u=c.sent(),l=u,e.aborted?[2,this.completeRequest({err:sr})]:[2,this.completeRequest({err:l.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,or({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}(),ar=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 ir({localConfig:t,configKeys:n})).initialize()];case 1:return r.sent(),[2,e]}}))}))},cr=function(){function e(e,t){this.localConfig=new q(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,ar({localConfig:this.localConfig,configKeys:["sessionReplay"]})];case 1:return e.remoteConfigFetch=t.sent(),[2]}}))}))},e.prototype.generateJoinedConfig=function(e){return a(this,void 0,void 0,(function(){var t,n,r,o,s,a,u,l,d,h;return c(this,(function(c){switch(c.label){case 0:(t=i({},this.localConfig)).optOut=this.localConfig.optOut,t.captureEnabled=!0,c.label=1;case 1:return c.trys.push([1,4,,5]),this.remoteConfigFetch?[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_sampling_config",e)]:[2,t];case 2:return r=c.sent(),[4,this.remoteConfigFetch.getRemoteConfig("sessionReplay","sr_privacy_config",e)];case 3:return o=c.sent(),(r||o)&&(n={},r&&(n.sr_sampling_config=r),o&&(n.sr_privacy_config=o)),[3,5];case 4:return s=c.sent(),a=s,this.localConfig.loggerProvider.warn(a.message),t.captureEnabled=!0,[3,5];case 5:if(!n)return[2,t];if(u=n.sr_sampling_config,l=n.sr_privacy_config,u&&Object.keys(u).length>0?(Object.prototype.hasOwnProperty.call(u,"capture_enabled")?t.captureEnabled=u.capture_enabled:t.captureEnabled=!1,u.sample_rate&&(t.sampleRate=u.sample_rate)):(t.captureEnabled=!0,this.localConfig.loggerProvider.debug("Remote config successfully fetched, but no values set for project, Session Replay capture enabled.")),l&&Object.keys(l).length>0)for(d in t.privacyConfig||(t.privacyConfig={}),l)h=d,t.privacyConfig[h]=l[h];return[2,t]}}))}))},e}(),ur=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 cr(e,t)).initialize()];case 1:return r.sent(),[2,n]}}))}))},lr=function(e,t){var n;return(null===(n=t.classList)||void 0===n?void 0:n.contains("amp-unmask"))?e:"*".repeat(e.length)},dr=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},hr="Session replay event batch rejected due to exceeded retry count",pr="Failed to store session replay events in IndexedDB",fr=function(){function e(e){var t=e.loggerProvider;this.storageKey="",this.retryTimeout=1e3,this.scheduled=null,this.queue=[],this.loggerProvider=t}return e.prototype.sendEventsList=function(e){this.addToQueue(i(i({},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(hr,", 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,s,i,a,u,l,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"})];v=L(),o=(null==v?void 0:v.location)?v.location.href:"",s="0.2.5",i=e.sampleRate,a=new URLSearchParams({device_id:r,session_id:"".concat(e.sessionId),seq_number:"".concat(e.sequenceId)}),u={version:1,events:e.events},c.label=1;case 1:return c.trys.push([1,3,,4]),l={headers:{"Content-Type":"application/json",Accept:"*/*",Authorization:"Bearer ".concat(n),"X-Client-Version":s,"X-Client-Url":o,"X-Client-Sample-Rate":"".concat(i)},body:JSON.stringify(u),method:"POST"},d="".concat(this.getServerUrl(e.serverZone),"?").concat(a.toString()),[4,fetch(d,l)];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 w).buildStatus(e)){case s.Success:this.handleSuccessResponse(t);break;case s.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(i(i({},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}();!function(e){e.RECORDING="recording",e.SENT="sent"}(nr||(nr={}));var vr="sessionCurrentSequence",mr="sequencesToSend",gr=function(){var e=L();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)}}))},yr=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]}}))}))},Sr=function(e){var t,n;return e.objectStoreNames.contains(vr)||(n=e.createObjectStore(vr,{keyPath:"sessionId"})),e.objectStoreNames.contains(mr)||(t=e.createObjectStore(mr,{keyPath:"sequenceId",autoIncrement:!0})).createIndex("sessionId","sessionId"),{sequencesStore:t,currentSequenceStore:n}},br=function(e){return a(void 0,void 0,void 0,(function(){return c(this,(function(t){switch(t.label){case 0:return[4,zn(e,1,{upgrade:Sr})];case 1:return[2,t.sent()]}}))}))},Ir=function(){function e(e){var t=e.loggerProvider,n=e.apiKey,r=this;this.storageKey="",this.maxPersistedEventsSize=1e6,this.interval=500,this.timeAtLastSplit=null,this.shouldSplitEventsList=function(e,t){var n=new Blob([t]).size;return new Blob(e).size+n>=r.maxPersistedEventsSize||!!(null!==r.timeAtLastSplit&&Date.now()-r.timeAtLastSplit>r.interval&&e.length)&&(r.interval=Math.min(1e4,r.interval+500),r.timeAtLastSplit=Date.now(),!0)},this.getSequencesToSend=function(){return a(r,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(mr)];case 1:return[2,n.sent()];case 2:return e=n.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(e)),[3,3];case 3:return[2,void 0]}}))}))},this.storeCurrentSequence=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 o.trys.push([0,4,,5]),this.db?[4,this.db.get(vr,e)]:[2,void 0];case 1:return(t=o.sent())?[4,this.db.put(mr,{sessionId:e,events:t.events})]:[2,void 0];case 2:return n=o.sent(),[4,this.db.put(vr,{sessionId:e,events:[]})];case 3:return o.sent(),[2,i(i({},t),{sessionId:e,sequenceId:n})];case 4:return r=o.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(r)),[3,5];case 5:return[2,void 0]}}))}))},this.addEventToCurrentSequence=function(e,t){return a(r,void 0,void 0,(function(){var n,r,o,s,i,a,u;return c(this,(function(c){switch(c.label){case 0:return c.trys.push([0,10,,11]),(n=null===(u=this.db)||void 0===u?void 0:u.transaction(vr,"readwrite"))?[4,n.store.get(e)]:[2];case 1:return(r=c.sent())?[3,3]:[4,n.store.put({sessionId:e,events:[t]})];case 2:return c.sent(),[2];case 3:return o=void 0,this.shouldSplitEventsList(r.events,t)?(o=r.events,[4,n.store.put({sessionId:e,events:[t]})]):[3,5];case 4:return c.sent(),[3,7];case 5:return s=r.events.concat(t),[4,n.store.put({sessionId:e,events:s})];case 6:c.sent(),c.label=7;case 7:return[4,n.done];case 8:return c.sent(),o?[4,this.storeSendingEvents(e,o)]:[2,void 0];case 9:return(i=c.sent())?[2,{events:o,sessionId:e,sequenceId:i}]:[2,void 0];case 10:return a=c.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(a)),[3,11];case 11:return[2,void 0]}}))}))},this.storeSendingEvents=function(e,t){return a(r,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(mr,{sessionId:e,events:t})];case 1:return[2,o.sent()];case 2:return n=o.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(n)),[3,3];case 3:return[2,void 0]}}))}))},this.cleanUpSessionEventsStore=function(e){return a(r,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(mr,e)];case 1:return r.sent(),[3,3];case 2:return t=r.sent(),this.loggerProvider.warn("".concat(pr,": ").concat(t)),[3,3];case 3:return[2]}}))}))},this.transitionFromKeyValStore=function(e){return a(r,void 0,void 0,(function(){var t,n,r,o,s,i,u,l,h=this;return c(this,(function(p){switch(p.label){case 0:return p.trys.push([0,6,,7]),[4,gr()];case 1:if(!(t=p.sent()))return[2];n=function(e,t){return a(h,void 0,void 0,(function(){var n,r,o=this;return c(this,(function(s){switch(s.label){case 0:return n=t.sessionSequences,r=[],Object.keys(n).forEach((function(s){var i=parseInt(s,10),u=n[i];if(i===t.currentSequenceId){var l=u.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(l)}else u.status!==nr.SENT&&r.push(o.storeSendingEvents(e,u.events))})),[4,yr(r)];case 1:return s.sent(),[2]}}))}))},r="".concat(d,"_").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),s=new Promise((function(t){o.onsuccess=function(r){return a(h,void 0,void 0,(function(){var o,s,i,a=this;return c(this,(function(c){switch(c.label){case 0:return o=r&&r.target.result,(s=o&&o[0])?(i=[],Object.keys(s).forEach((function(t){var r=parseInt(t,10),o=s[r];if(e===r)i.push(n(r,o));else{var c=o.sessionSequences;Object.keys(c).forEach((function(e){var t=parseInt(e,10);c[t].status!==nr.SENT&&i.push(a.storeSendingEvents(r,c[t].events))}))}})),[4,yr(i)]):[3,2];case 1:c.sent(),c.label=2;case 2:return t(),[2]}}))}))}})),[4,s];case 3:return p.sent(),(i=L())&&i.indexedDB.deleteDatabase("keyval-store"),[3,5];case 4:return u=p.sent(),this.loggerProvider.warn("Failed to transition session replay events from keyval to new store: ".concat(u)),[3,5];case 5:return[3,7];case 6:return l=p.sent(),this.loggerProvider.warn("Failed to access keyval store: ".concat(l,". 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}return e.prototype.initialize=function(e){return a(this,void 0,void 0,(function(){var t,n;return c(this,(function(r){switch(r.label){case 0:return t="".concat(this.apiKey.substring(0,10),"_amp_session_replay_events"),n=this,[4,br(t)];case 1:return n.db=r.sent(),this.timeAtLastSplit=Date.now(),[4,this.transitionFromKeyValStore(e)];case 2:return r.sent(),[2]}}))}))},e}(),wr=function(e){var t=e.loggerProvider,n=e.apiKey,r=e.sessionId;return a(void 0,void 0,void 0,(function(){var e;return c(this,(function(o){switch(o.label){case 0:return[4,(e=new Ir({loggerProvider:t,apiKey:n})).initialize(r)];case 1:return o.sent(),[2,e]}}))}))},Cr=function(e){var t=e.config,n=e.sessionId;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 r?[2,r.flush(e)]:[2]}))}))}var r,o,s,i,u,l;return c(this,(function(d){switch(d.label){case 0:return r=new fr({loggerProvider:t.loggerProvider}),[4,wr({loggerProvider:t.loggerProvider,apiKey:t.apiKey,sessionId:n})];case 1:return o=d.sent(),s=function(e){var n=e.events,s=e.sessionId,i=e.deviceId,a=e.sequenceId;r.sendEventsList({events:n,sequenceId:a,sessionId:s,flushMaxRetries:t.flushMaxRetries,apiKey:t.apiKey,deviceId:i,sampleRate:t.sampleRate,serverZone:t.serverZone,onComplete:o.cleanUpSessionEventsStore.bind(o)})},i=function(e){var n=e.sessionId,r=e.deviceId;o.storeCurrentSequence(n).then((function(e){e&&s({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)}))},u=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,o.getSequencesToSend()];case 1:return(e=n.sent())&&e.forEach((function(e){s({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:t})})),[2]}}))}))},l=function(e){var n=e.event,r=e.sessionId,i=e.deviceId;o.addEventToCurrentSequence(r,n).then((function(e){return e&&s({sequenceId:e.sequenceId,events:e.events,sessionId:e.sessionId,deviceId:i})})).catch((function(e){t.loggerProvider.warn("Failed to add event to session replay capture:",e)}))},[2,{sendCurrentSequenceEvents:i,addEvent:l,sendStoredEvents:u,flush:e}]}}))}))},Mr=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))},kr=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 v}return e.prototype.init=function(e,t){return p(this._init(e,t))},e.prototype._init=function(e,t){return a(this,void 0,void 0,(function(){var n,r,o,s;return c(this,(function(i){switch(i.label){case 0:return this.loggerProvider=t.loggerProvider||new v,this.identifiers=new Mr({sessionId:t.sessionId,deviceId:t.deviceId}),n=this,[4,ur(e,t)];case 1:return n.joinedConfigGenerator=i.sent(),r=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)];case 2:return r.config=i.sent(),o=this,[4,Cr({config:this.config,sessionId:this.identifiers.sessionId})];case 3:return o.eventsManager=i.sent(),this.loggerProvider.log("Installing @amplitude/session-replay-browser."),(s=L())&&(s.removeEventListener("blur",this.blurListener),s.removeEventListener("focus",this.focusListener),s.addEventListener("blur",this.blurListener),s.addEventListener("focus",this.focusListener)),s&&s.document&&s.document.hasFocus()&&this.initialize(!0),[2]}}))}))},e.prototype.setSessionId=function(e,t){return p(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(s){switch(s.label){case 0:return(n=this.identifiers&&this.identifiers.sessionId)&&this.stopRecordingAndSendEvents(n),r=t||this.getDeviceId(),this.identifiers=new Mr({sessionId:e,deviceId:r}),this.joinedConfigGenerator&&n?(o=this,[4,this.joinedConfigGenerator.generateJoinedConfig(this.identifiers.sessionId)]):[3,2];case 1:o.config=s.sent(),s.label=2;case 2:return this.recordEvents(),[2]}}))}))},e.prototype.getSessionReplayDebugPropertyValue=function(){var e="";return this.config&&(e=dr(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={})[A]=this.identifiers.sessionReplayId?this.identifiers.sessionReplayId:null,e);return this.config.debugMode&&(n[j]=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=N(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=L();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,s=(n=this.identifiers.sessionId,r=this.config.sampleRate,o=dr(n.toString()),31*Math.abs(o)%100/100<r);return s||this.loggerProvider.log("Opting session ".concat(this.identifiers.sessionId," out of recording due to sample rate.")),s},e.prototype.getBlockSelectors=function(){var e,t;return null===(t=null===(e=this.config)||void 0===e?void 0:e.privacyConfig)||void 0===t?void 0:t.blockSelector},e.prototype.recordEvents=function(){var e,t=this,n=this.getShouldRecord(),r=null===(e=this.identifiers)||void 0===e?void 0:e.sessionId;n&&r&&(this.stopRecordingEvents(),this.recordCancelCallback=Vt({emit:function(e){var n=L();if(n&&n.document&&!n.document.hasFocus()||!t.getShouldRecord())t.stopRecordingAndSendEvents();else{var o=JSON.stringify(e),s=t.getDeviceId();s&&t.eventsManager&&t.eventsManager.addEvent({event:o,sessionId:r,deviceId:s})}},packFn:Tn,maskAllInputs:!0,maskTextClass:"amp-mask",blockClass:"amp-block",blockSelector:this.getBlockSelectors(),maskInputFn:lr,recordCanvas:!1,errorHandler:function(e){var n=e;if(n.message.includes("insertRule")&&n.message.includes("CSSStyleSheet"))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=N(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){return void 0===e&&(e=!1),a(this,void 0,void 0,(function(){return c(this,(function(t){return this.eventsManager?[2,this.eventsManager.flush(e)]:[2]}))}))},e.prototype.shutdown=function(){var e=L();e&&(e.removeEventListener("blur",this.blurListener),e.removeEventListener("focus",this.focusListener)),this.stopRecordingAndSendEvents()},e}(),Er=function(e){return function(){var t=e.config||U();return{logger:t.loggerProvider,logLevel:t.logLevel}}},Or=function(){var e=new kr;return{init:I(e.init.bind(e),"init",Er(e)),setSessionId:I(e.setSessionId.bind(e),"setSessionId",Er(e)),getSessionId:I(e.getSessionId.bind(e),"getSessionId",Er(e)),getSessionReplayProperties:I(e.getSessionReplayProperties.bind(e),"getSessionReplayProperties",Er(e)),flush:I(e.flush.bind(e),"flush",Er(e)),shutdown:I(e.shutdown.bind(e),"shutdown",Er(e))}}(),Tr=Or.init,Rr=Or.setSessionId,xr=Or.getSessionId,Dr=Or.getSessionReplayProperties,Nr=Or.flush,Lr=Or.shutdown,_r="@amplitude/plugin-session-replay-enrichment-browser",Pr=function(){function e(){this.name=_r,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!==xr()?[4,Rr(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=Dr(),e.event_properties=i(i({},e.event_properties),t)),[2,Promise.resolve(e)]}}))}))},e}(),Ar=function(){function e(e){this.name="@amplitude/plugin-session-replay-browser",this.type="destination",this.options=i({},e),!1!==this.options.forceSessionTracking&&(this.options.forceSessionTracking=!0)}return e.prototype.setup=function(e,t){var n;return a(this,void 0,void 0,(function(){return c(this,(function(r){switch(r.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=i(i({},e.defaultTracking),{sessions:!0})),[4,Tr(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},debugMode:this.options.debugMode,configEndpointUrl:this.options.configEndpointUrl}).promise]):(e.loggerProvider.error("SessionReplayPlugin requires v1.9.1+ of the Amplitude SDK."),[2]);case 1:return r.sent(),[4,t.add(new Pr).promise];case 2:return r.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,Nr(!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(_r).promise];case 1:return e.sent(),Lr(),this.config=null,this.clientRemove=null,[2]}}))}))},e.prototype.getSessionReplayProperties=function(){return Dr()},e}(),Fr=function(e){return new Ar(e)};return e.plugin=Fr,e.sessionReplayPlugin=Fr,Object.defineProperty(e,"__esModule",{value:!0}),e}({});