koalaware-js
Version:
SDK for Koalaware session and event recording
15 lines (13 loc) • 83.8 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).KoalawareTracker={})}(this,(function(e){"use strict";var t,n=function(){return n=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},n.apply(this,arguments)};function o(e,t,n,o){return new(n||(n=Promise))((function(r,s){function i(e){try{c(o.next(e))}catch(e){s(e)}}function a(e){try{c(o.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,a)}c((o=o.apply(e,t||[])).next())}))}function r(e,t){var n,o,r,s={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(s=0)),s;)try{if(n=1,o&&(r=2&a[0]?o.return:a[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,a[1])).done)return r;switch(o=0,r&&(a=[2&a[0],r.value]),a[0]){case 0:case 1:r=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,o=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(r=s.trys,(r=r.length>0&&r[r.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!r||a[1]>r[0]&&a[1]<r[3])){s.label=a[1];break}if(6===a[0]&&s.label<r[1]){s.label=r[1],r=a;break}if(r&&s.label<r[2]){s.label=r[2],s.ops.push(a);break}r[2]&&s.ops.pop(),s.trys.pop();continue}a=t.call(e,s)}catch(e){a=[6,e],o=0}finally{n=r=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function s(e,t,n){if(n||2===arguments.length)for(var o,r=0,s=t.length;r<s;r++)!o&&r in t||(o||(o=Array.prototype.slice.call(t,0,r)),o[r]=t[r]);return e.concat(o||Array.prototype.slice.call(t))}function i(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function a(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function c(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(l).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 l(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{t=c(e.styleSheet)||t}catch(e){}return t}"function"==typeof SuppressedError&&SuppressedError,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 d=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 o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(t,o)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function u(e){var t=e.maskInputOptions,n=e.tagName,o=e.type,r=e.value,s=e.maskInputFn,i=r||"";return(t[n.toLowerCase()]||t[o])&&(i=s?s(i):"*".repeat(i.length)),i}var p="__rrweb_original__";var h,g,m=1,I=new RegExp("[^a-z0-9-_:]");function f(){return m++}var C=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,y=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,v=/^(data:)([^,]*),(.*)/i;function S(e,t){return(e||"").replace(C,(function(e,n,o,r,s,i){var a,c=o||s||i,l=n||r||"";if(!c)return e;if(!y.test(c))return"url(".concat(l).concat(c).concat(l,")");if(v.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+c)).concat(l,")");var d=t.split("/"),u=c.split("/");d.pop();for(var p=0,h=u;p<h.length;p++){var g=h[p];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(l).concat(d.join("/")).concat(l,")")}))}var b=/^[^ \t\n\r\u000c]+/,A=/^[, \t\n\r\u000c]+/;function w(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function k(e){return Boolean("svg"===e.tagName||e.ownerSVGElement)}function M(){var e=document.createElement("a");return e.href="",e.href}function T(e,t,n,o){return"src"===n||"href"===n&&o&&("use"!==t||"#"!==o[0])||"xlink:href"===n&&o&&"#"!==o[0]?w(e,o):"background"!==n||!o||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n&&o?function(e,t){if(""===t.trim())return t;var n=0;function o(e){var o,r=e.exec(t.substring(n));return r?(o=r[0],n+=o.length,o):""}for(var r=[];o(A),!(n>=t.length);){var s=o(b);if(","===s.slice(-1))s=w(e,s.substring(0,s.length-1)),r.push(s);else{var i="";s=w(e,s);for(var a=!1;;){var c=t.charAt(n);if(""===c){r.push((s+i).trim());break}if(a)")"===c&&(a=!1);else{if(","===c){n+=1,r.push((s+i).trim());break}"("===c&&(a=!0)}i+=c,n+=1}}}return r.join(", ")}(e,o):"style"===n&&o?S(o,M()):"object"===t&&"data"===n&&o?w(e,o):o:w(e,o)}function E(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&E(e.parentNode,t,n);for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&E(e.parentNode,t,n)}function R(e,t,n){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(E(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function N(e,n){var o=n.doc,r=n.mirror,s=n.blockClass,i=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,d=n.inlineStylesheet,m=n.maskInputOptions,f=void 0===m?{}:m,C=n.maskTextFn,y=n.maskInputFn,v=n.dataURLOptions,b=void 0===v?{}:v,A=n.inlineImages,w=n.recordCanvas,E=n.keepIframeSrcFn,N=n.newlyAddedElement,O=void 0!==N&&N,F=function(e,t){if(!t.hasNode(e))return;var n=t.getId(e);return 1===n?void 0:n}(o,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:F};case e.ELEMENT_NODE:return function(e,n){for(var o=n.doc,r=n.blockClass,s=n.blockSelector,i=n.inlineStylesheet,a=n.maskInputOptions,l=void 0===a?{}:a,d=n.maskInputFn,m=n.dataURLOptions,f=void 0===m?{}:m,C=n.inlineImages,y=n.recordCanvas,v=n.keepIframeSrcFn,b=n.newlyAddedElement,A=void 0!==b&&b,w=n.rootId,E=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var o=e.classList.length;o--;){var r=e.classList[o];if(t.test(r))return!0}return!!n&&e.matches(n)}(e,r,s),R=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return I.test(t)?"div":t}(e),N={},O=e.attributes.length,F=0;F<O;F++){var x=e.attributes[F];N[x.name]=T(o,R,x.name,x.value)}if("link"===R&&i){var L=Array.from(o.styleSheets).find((function(t){return t.href===e.href})),D=null;L&&(D=c(L)),D&&(delete N.rel,delete N.href,N._cssText=S(D,L.href))}if("style"===R&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){(D=c(e.sheet))&&(N._cssText=S(D,M()))}if("input"===R||"textarea"===R||"select"===R){var B=e.value,U=e.checked;"radio"!==N.type&&"checkbox"!==N.type&&"submit"!==N.type&&"button"!==N.type&&B?N.value=u({type:N.type,tagName:R,value:B,maskInputOptions:l,maskInputFn:d}):U&&(N.checked=U)}"option"===R&&(e.selected&&!l.select?N.selected=!0:delete N.selected);if("canvas"===R&&y)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 o=0;o<e.height;o+=50){var r=t.getImageData,s=p in r?r[p]:r;if(new Uint32Array(s.call(t,n,o,Math.min(50,e.width-n),Math.min(50,e.height-o)).data.buffer).some((function(e){return 0!==e})))return!1}return!0})(e)||(N.rr_dataURL=e.toDataURL(f.type,f.quality));else if(!("__context"in e)){var W=e.toDataURL(f.type,f.quality),Z=document.createElement("canvas");Z.width=e.width,Z.height=e.height,W!==Z.toDataURL(f.type,f.quality)&&(N.rr_dataURL=W)}if("img"===R&&C){h||(h=o.createElement("canvas"),g=h.getContext("2d"));var V=e,G=V.crossOrigin;V.crossOrigin="anonymous";var K=function(){try{h.width=V.naturalWidth,h.height=V.naturalHeight,g.drawImage(V,0,0),N.rr_dataURL=h.toDataURL(f.type,f.quality)}catch(e){console.warn("Cannot inline img src=".concat(V.currentSrc,"! Error: ").concat(e))}G?N.crossOrigin=G:V.removeAttribute("crossorigin")};V.complete&&0!==V.naturalWidth?K():V.onload=K}"audio"!==R&&"video"!==R||(N.rr_mediaState=e.paused?"paused":"played",N.rr_mediaCurrentTime=e.currentTime);A||(e.scrollLeft&&(N.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(N.rr_scrollTop=e.scrollTop));if(E){var _=e.getBoundingClientRect(),J=_.width,z=_.height;N={class:N.class,rr_width:"".concat(J,"px"),rr_height:"".concat(z,"px")}}"iframe"!==R||v(N.src)||(e.contentDocument||(N.rr_src=N.src),delete N.src);return{type:t.Element,tagName:R,attributes:N,childNodes:[],isSVG:k(e)||void 0,needBlock:E,rootId:w}}(e,{doc:o,blockClass:s,blockSelector:i,inlineStylesheet:d,maskInputOptions:f,maskInputFn:y,dataURLOptions:b,inlineImages:A,recordCanvas:w,keepIframeSrcFn:E,newlyAddedElement:O,rootId:F});case e.TEXT_NODE:return function(e,n){var o,r=n.maskTextClass,s=n.maskTextSelector,i=n.maskTextFn,a=n.rootId,c=e.parentNode&&e.parentNode.tagName,l=e.textContent,d="STYLE"===c||void 0,u="SCRIPT"===c||void 0;if(d&&l){try{e.nextSibling||e.previousSibling||(null===(o=e.parentNode.sheet)||void 0===o?void 0:o.cssRules)&&(l=(p=e.parentNode.sheet).cssRules?Array.from(p.cssRules).map((function(e){return e.cssText||""})).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}l=S(l,M())}var p;u&&(l="SCRIPT_PLACEHOLDER");!d&&!u&&l&&R(e,r,s)&&(l=i?i(l):l.replace(/[\S]/g,"*"));return{type:t.Text,textContent:l||"",isStyle:d,rootId:a}}(e,{maskTextClass:a,maskTextSelector:l,maskTextFn:C,rootId:F});case e.CDATA_SECTION_NODE:return{type:t.CDATA,textContent:"",rootId:F};case e.COMMENT_NODE:return{type:t.Comment,textContent:e.textContent||"",rootId:F};default:return!1}}function O(e){return void 0===e?"":e.toLowerCase()}function F(e,n){var o,r=n.doc,s=n.mirror,c=n.blockClass,l=n.blockSelector,d=n.maskTextClass,u=n.maskTextSelector,p=n.skipChild,h=void 0!==p&&p,g=n.inlineStylesheet,m=void 0===g||g,I=n.maskInputOptions,C=void 0===I?{}:I,y=n.maskTextFn,v=n.maskInputFn,S=n.slimDOMOptions,b=n.dataURLOptions,A=void 0===b?{}:b,w=n.inlineImages,k=void 0!==w&&w,M=n.recordCanvas,T=void 0!==M&&M,E=n.onSerialize,R=n.onIframeLoad,x=n.iframeLoadTimeout,L=void 0===x?5e3:x,D=n.onStylesheetLoad,B=n.stylesheetLoadTimeout,U=void 0===B?5e3:B,W=n.keepIframeSrcFn,Z=void 0===W?function(){return!1}:W,V=n.newlyAddedElement,G=void 0!==V&&V,K=n.preserveWhiteSpace,_=void 0===K||K,J=N(e,{doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,inlineStylesheet:m,maskInputOptions:C,maskTextFn:y,maskInputFn:v,dataURLOptions:A,inlineImages:k,recordCanvas:T,keepIframeSrcFn:Z,newlyAddedElement:G});if(!J)return console.warn(e,"not serialized"),null;o=s.hasNode(e)?s.getId(e):!function(e,n){if(n.comment&&e.type===t.Comment)return!0;if(e.type===t.Element){if(n.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===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(n.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(O(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===O(e.attributes.name)||"icon"===O(e.attributes.rel)||"apple-touch-icon"===O(e.attributes.rel)||"shortcut icon"===O(e.attributes.rel))))return!0;if("meta"===e.tagName){if(n.headMetaDescKeywords&&O(e.attributes.name).match(/^description|keywords$/))return!0;if(n.headMetaSocial&&(O(e.attributes.property).match(/^(og|twitter|fb):/)||O(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===O(e.attributes.name)))return!0;if(n.headMetaRobots&&("robots"===O(e.attributes.name)||"googlebot"===O(e.attributes.name)||"bingbot"===O(e.attributes.name)))return!0;if(n.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(n.headMetaAuthorship&&("author"===O(e.attributes.name)||"generator"===O(e.attributes.name)||"framework"===O(e.attributes.name)||"publisher"===O(e.attributes.name)||"progid"===O(e.attributes.name)||O(e.attributes.property).match(/^article:/)||O(e.attributes.property).match(/^product:/)))return!0;if(n.headMetaVerification&&("google-site-verification"===O(e.attributes.name)||"yandex-verification"===O(e.attributes.name)||"csrf-token"===O(e.attributes.name)||"p:domain_verify"===O(e.attributes.name)||"verify-v1"===O(e.attributes.name)||"verification"===O(e.attributes.name)||"shopify-checkout-api-token"===O(e.attributes.name)))return!0}}return!1}(J,S)&&(_||J.type!==t.Text||J.isStyle||J.textContent.replace(/^\s+|\s+$/gm,"").length)?f():-2;var z=Object.assign(J,{id:o});if(s.add(e,z),-2===o)return null;E&&E(e);var Y=!h;if(z.type===t.Element){Y=Y&&!z.needBlock,delete z.needBlock;var j=e.shadowRoot;j&&a(j)&&(z.isShadowHost=!0)}if((z.type===t.Document||z.type===t.Element)&&Y){S.headWhitespace&&z.type===t.Element&&"head"===z.tagName&&(_=!1);for(var P={doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:h,inlineStylesheet:m,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z},Q=0,H=Array.from(e.childNodes);Q<H.length;Q++){($=F(H[Q],P))&&z.childNodes.push($)}if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var X=0,q=Array.from(e.shadowRoot.childNodes);X<q.length;X++){var $;($=F(q[X],P))&&(a(e.shadowRoot)&&($.isShadow=!0),z.childNodes.push($))}}return e.parentNode&&i(e.parentNode)&&a(e.parentNode)&&(z.isShadow=!0),z.type===t.Element&&"iframe"===z.tagName&&function(e,t,n){var o=e.contentWindow;if(o){var r,s=!1;try{r=o.document.readyState}catch(e){return}if("complete"===r){var i="about:blank";if(o.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&&R){var n=F(t,{doc:t,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:!1,inlineStylesheet:m,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});n&&R(e,n)}}),L),z.type===t.Element&&"link"===z.tagName&&"stylesheet"===z.attributes.rel&&function(e,t,n){var o,r=!1;try{o=e.sheet}catch(e){return}if(!o){var s=setTimeout((function(){r||(t(),r=!0)}),n);e.addEventListener("load",(function(){clearTimeout(s),r=!0,t()}))}}(e,(function(){if(D){var t=F(e,{doc:r,mirror:s,blockClass:c,blockSelector:l,maskTextClass:d,maskTextSelector:u,skipChild:!1,inlineStylesheet:m,maskInputOptions:C,maskTextFn:y,maskInputFn:v,slimDOMOptions:S,dataURLOptions:A,inlineImages:k,recordCanvas:T,preserveWhiteSpace:_,onSerialize:E,onIframeLoad:R,iframeLoadTimeout:L,onStylesheetLoad:D,stylesheetLoadTimeout:U,keepIframeSrcFn:Z});t&&D(e,t)}}),U),z}function x(e,t,n=document){const o={capture:!0,passive:!0};return n.addEventListener(e,t,o),()=>n.removeEventListener(e,t,o)}const L="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 D={map:{},getId:()=>(console.error(L),-1),getNode:()=>(console.error(L),null),removeNodeFromMap(){console.error(L)},has:()=>(console.error(L),!1),reset(){console.error(L)}};function B(e,t,n={}){let o=null,r=0;return function(...s){const i=Date.now();r||!1!==n.leading||(r=i);const a=t-(i-r),c=this;a<=0||a>t?(o&&(clearTimeout(o),o=null),r=i,e.apply(c,s)):o||!1===n.trailing||(o=setTimeout((()=>{r=!1===n.leading?0:Date.now(),o=null,e.apply(c,s)}),a))}}function U(e,t,n,o,r=window){const s=r.Object.getOwnPropertyDescriptor(e,t);return r.Object.defineProperty(e,t,o?n:{set(e){setTimeout((()=>{n.set.call(this,e)}),0),s&&s.set&&s.set.call(this,e)}}),()=>U(e,t,s||{},!0)}function W(e,t,n){try{if(!(t in e))return()=>{};const o=e[t],r=n(o);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:o}})),e[t]=r,()=>{e[t]=o}}catch(e){return()=>{}}}function Z(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function V(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function G(e,t,n,o){if(!e)return!1;const r=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!r)return!1;if("string"==typeof t){if(r.classList.contains(t))return!0;if(o&&null!==r.closest("."+t))return!0}else if(E(r,t,o))return!0;if(n){if(e.matches(n))return!0;if(o&&null!==r.closest(n))return!0}return!1}function K(e,t){return-2===t.getId(e)}function _(e,t){if(i(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||_(e.parentNode,t))}function J(e){return Boolean(e.changedTouches)}function z(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function Y(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function j(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(D=new Proxy(D,{get:(e,t,n)=>("map"===t&&console.error(L),Reflect.get(e,t,n))}));class P{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++}}var Q=(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))(Q||{}),H=(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))(H||{}),X=(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))(X||{}),q=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(q||{});function $(e){return"__ln"in e}class ee{constructor(){this.length=0,this.head=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&&$(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&&$(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;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.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const te=(e,t)=>`${e}@${t}`;class ne{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 ee,n=e=>{let t=e,n=-2;for(;-2===n;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},o=o=>{var r,s,a,c;let l=null;(null===(s=null===(r=o.getRootNode)||void 0===r?void 0:r.call(o))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&o.getRootNode().host&&(l=o.getRootNode().host);let d=l;for(;(null===(c=null===(a=null==d?void 0:d.getRootNode)||void 0===a?void 0:a.call(d))||void 0===c?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&d.getRootNode().host;)d=d.getRootNode().host;const u=!(this.doc.contains(o)||d&&this.doc.contains(d));if(!o.parentNode||u)return;const p=i(o.parentNode)?this.mirror.getId(l):this.mirror.getId(o.parentNode),h=n(o);if(-1===p||-1===h)return t.addNode(o);const g=F(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=>{z(e,this.mirror)&&this.iframeManager.addIframe(e),Y(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),j(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)}});g&&e.push({parentId:p,nextId:h,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of Array.from(this.movedSet.values()))re(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||o(e);for(const e of Array.from(this.addedSet.values()))ie(this.droppedSet,e)||re(this.removes,e,this.mirror)?ie(this.movedSet,e)?o(e):this.droppedSet.add(e):o(e);let r=null;for(;t.length;){let e=null;if(r){const t=this.mirror.getId(r.value.parentNode),o=n(r.value);-1!==t&&-1!==o&&(e=r)}if(!e)for(let o=t.length-1;o>=0;o--){const r=t.get(o);if(r){const t=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==t){e=r;break}{const t=r.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=t.parentNode.host;if(-1!==this.mirror.getId(n)){e=r;break}}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}r=e.previous,t.removeNode(e.value),o(e.value)}const s={texts:this.texts.map((e=>({id:this.mirror.getId(e.node),value:e.value}))).filter((e=>this.mirror.has(e.id))),attributes:this.attributes.map((e=>({id:this.mirror.getId(e.node),attributes:e.attributes}))).filter((e=>this.mirror.has(e.id))),removes:this.removes,adds:e};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!K(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;G(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:R(e.target,this.maskTextClass,this.maskTextSelector)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.target.getAttribute(e.attributeName);if("value"===e.attributeName&&(n=u({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),G(e.target,this.blockClass,this.blockSelector,!1)||n===e.oldValue)return;let o=this.attributes.find((t=>t.node===e.target));if("IFRAME"===t.tagName&&"src"===e.attributeName&&!this.keepIframeSrcFn(n)){if(t.contentDocument)return;e.attributeName="rr_src"}if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"style"===e.attributeName){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),void 0!==o.attributes.style&&null!==o.attributes.style||(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),s=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&s===n.style.getPropertyPriority(e)||(r[e]=""===s?o:[o,s])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else o.attributes[e.attributeName]=T(this.doc,t.tagName,e.attributeName,n);break}case"childList":if(G(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),o=i(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);G(e.target,this.blockClass,this.blockSelector,!1)||K(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(oe(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||_(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[te(n,o)]?oe(this.movedSet,t):this.removes.push({parentId:o,id:n,isShadow:!(!i(e.target)||!a(e.target))||void 0})),this.mapRemoves.push(t))}))}},this.genAdds=(e,t)=>{if(this.mirror.hasNode(e)){if(K(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[te(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);G(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach((e=>this.genAdds(e)))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].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 oe(e,t){e.delete(t),t.childNodes.forEach((t=>oe(e,t)))}function re(e,t,n){return 0!==e.length&&se(e,t,n)}function se(e,t,n){const{parentNode:o}=t;if(!o)return!1;const r=n.getId(o);return!!e.some((e=>e.id===r))||se(e,o,n)}function ie(e,t){return 0!==e.size&&ae(e,t)}function ae(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||ae(e,n))}const ce=[],le="undefined"!=typeof CSSGroupingRule,de="undefined"!=typeof CSSMediaRule,ue="undefined"!=typeof CSSSupportsRule,pe="undefined"!=typeof CSSConditionRule;function he(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];return e.target}catch(t){return e.target}}function ge(e,t){var n,o;const r=new ne;ce.push(r),r.init(e);let s=window.MutationObserver||window.__rrMutationObserver;const i=null===(o=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===o?void 0:o.call(n,"MutationObserver");i&&window[i]&&(s=window[i]);const a=new s(r.processMutations.bind(r));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function me({mouseInteractionCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const i=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(X).filter((e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==i[e])).forEach((s=>{const i=s.toLowerCase(),c=(t=>s=>{const i=he(s);if(G(i,o,r,!0))return;const a=J(s)?s.changedTouches[0]:s;if(!a)return;const c=n.getId(i),{clientX:l,clientY:d}=a;e({type:X[t],id:c,x:l,y:d})})(s);a.push(x(i,c,t))})),()=>{a.forEach((e=>e()))}}function Ie({scrollCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,sampling:s}){return x("scroll",B((s=>{const i=he(s);if(!i||G(i,o,r,!0))return;const a=n.getId(i);if(i===t){const n=t.scrollingElement||t.documentElement;e({id:a,x:n.scrollLeft,y:n.scrollTop})}else e({id:a,x:i.scrollLeft,y:i.scrollTop})}),s.scroll||100),t)}function fe(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const Ce=["INPUT","TEXTAREA","SELECT"],ye=new WeakMap;function ve(e){return function(e,t){if(le&&e.parentRule instanceof CSSGroupingRule||de&&e.parentRule instanceof CSSMediaRule||ue&&e.parentRule instanceof CSSSupportsRule||pe&&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 Se(e,t,n){let o,r;return e?(e.ownerNode?o=t.getId(e.ownerNode):r=n.getId(e),{styleId:r,id:o}):{}}function be({mirror:e,stylesheetManager:t},n){var o,r,s;let i=null;i="#document"===n.nodeName?e.getId(n):e.getId(n.host);const a="#document"===n.nodeName?null===(o=n.defaultView)||void 0===o?void 0:o.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");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 o=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 o}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})}):()=>{}}function Ae(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:o,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:i,inputCb:a,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:d,canvasMutationCb:u,fontCb:p,selectionCb:h}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),o(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),r(...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),l(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),d(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),u(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),h(...e)}}(e,t);const o=ge(e,e.doc),r=function({mousemoveCb:e,sampling:t,doc:n,mirror:o}){if(!1===t.mousemove)return()=>{};const r="number"==typeof t.mousemove?t.mousemove:50,s="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let i,a=[];const c=B((t=>{const n=Date.now()-i;e(a.map((e=>(e.timeOffset-=n,e))),t),a=[],i=null}),s),l=B((e=>{const t=he(e),{clientX:n,clientY:r}=J(e)?e.changedTouches[0]:e;i||(i=Date.now()),a.push({x:n,y:r,id:o.getId(t),timeOffset:Date.now()-i}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?H.Drag:e instanceof MouseEvent?H.MouseMove:H.TouchMove)}),r,{trailing:!1}),d=[x("mousemove",l,n),x("touchmove",l,n),x("drag",l,n)];return()=>{d.forEach((e=>e()))}}(e),s=me(e),i=Ie(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return x("resize",B((()=>{const o=Z(),r=V();t===o&&n===r||(e({width:Number(r),height:Number(o)}),t=o,n=r)}),200),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:o,blockSelector:r,ignoreClass:s,maskInputOptions:i,maskInputFn:a,sampling:c,userTriggeredOnInput:l}){function d(e){let n=he(e);const c=e.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||Ce.indexOf(n.tagName)<0||G(n,o,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let h=n.value,g=!1;"radio"===d||"checkbox"===d?g=n.checked:(i[n.tagName.toLowerCase()]||i[d])&&(h=u({maskInputOptions:i,tagName:n.tagName,type:d,value:h,maskInputFn:a})),p(n,fe({text:h,isChecked:g,userTriggered:c},l));const m=n.name;"radio"===d&&m&&g&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach((e=>{e!==n&&p(e,fe({text:e.value,isChecked:!g,userTriggered:!1},l))}))}function p(t,o){const r=ye.get(t);if(!r||r.text!==o.text||r.isChecked!==o.isChecked){ye.set(t,o);const r=n.getId(t);e(Object.assign(Object.assign({},o),{id:r}))}}const h=("last"===c.input?["change"]:["input","change"]).map((e=>x(e,d,t))),g=t.defaultView;if(!g)return()=>{h.forEach((e=>e()))};const m=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),I=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...I.map((e=>U(e[0],e[1],{set(){d({target:this})}},!1,g)))),()=>{h.forEach((e=>e()))}}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:o,sampling:r}){const s=s=>B((r=>{const i=he(r);if(!i||G(i,t,n,!0))return;const{currentTime:a,volume:c,muted:l,playbackRate:d}=i;e({type:s,id:o.getId(i),currentTime:a,volume:c,muted:l,playbackRate:d})}),r.media||500),i=[x("play",s(0)),x("pause",s(1)),x("seeked",s(2)),x("volumechange",s(3)),x("ratechange",s(4))];return()=>{i.forEach((e=>e()))}}(e),d=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:o}){const r=o.CSSStyleSheet.prototype.insertRule;o.CSSStyleSheet.prototype.insertRule=function(o,s){const{id:i,styleId:a}=Se(this,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:o,index:s}]}),r.apply(this,[o,s])};const s=o.CSSStyleSheet.prototype.deleteRule;let i,a;o.CSSStyleSheet.prototype.deleteRule=function(o){const{id:r,styleId:i}=Se(this,t,n.styleMirror);return(r&&-1!==r||i&&-1!==i)&&e({id:r,styleId:i,removes:[{index:o}]}),s.apply(this,[o])},o.CSSStyleSheet.prototype.replace&&(i=o.CSSStyleSheet.prototype.replace,o.CSSStyleSheet.prototype.replace=function(o){const{id:r,styleId:s}=Se(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replace:o}),i.apply(this,[o])}),o.CSSStyleSheet.prototype.replaceSync&&(a=o.CSSStyleSheet.prototype.replaceSync,o.CSSStyleSheet.prototype.replaceSync=function(o){const{id:r,styleId:s}=Se(this,t,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&e({id:r,styleId:s,replaceSync:o}),a.apply(this,[o])});const c={};le?c.CSSGroupingRule=o.CSSGroupingRule:(de&&(c.CSSMediaRule=o.CSSMediaRule),pe&&(c.CSSConditionRule=o.CSSConditionRule),ue&&(c.CSSSupportsRule=o.CSSSupportsRule));const l={};return Object.entries(c).forEach((([o,r])=>{l[o]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:i,styleId:a}=Se(this.parentStyleSheet,t,n.styleMirror);return(i&&-1!==i||a&&-1!==a)&&e({id:i,styleId:a,adds:[{rule:r,index:[...ve(this),s||0]}]}),l[o].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:i}=Se(this.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||i&&-1!==i)&&e({id:s,styleId:i,removes:[{index:[...ve(this),r]}]}),l[o].deleteRule.apply(this,[r])}})),()=>{o.CSSStyleSheet.prototype.insertRule=r,o.CSSStyleSheet.prototype.deleteRule=s,i&&(o.CSSStyleSheet.prototype.replace=i),a&&(o.CSSStyleSheet.prototype.replaceSync=a),Object.entries(c).forEach((([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule}))}}(e,{win:n}),p=be(e,e.doc),h=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:o},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,i,a){var c;if(n.has(r))return s.apply(this,[r,i,a]);const{id:l,styleId:d}=Se(null===(c=this.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,o.styleMirror);return(l&&-1!==l||d&&-1!==d)&&e({id:l,styleId:d,set:{property:r,value:i,priority:a},index:ve(this.parentRule)}),s.apply(this,[r,i,a])};const i=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return i.apply(this,[r]);const{id:a,styleId:c}=Se(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,t,o.styleMirror);return(a&&-1!==a||c&&-1!==c)&&e({id:a,styleId:c,remove:{property:r},index:ve(this.parentRule)}),i.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=i}}(e,{win:n}),g=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const o=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(e,t,n){const o=new s(e,t,n);return r.set(o,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),o};const i=W(t.fonts,"add",(function(t){return function(n){return setTimeout((()=>{const t=r.get(n);t&&(e(t),r.delete(n))}),0),t.apply(this,[n])}}));return o.push((()=>{n.FontFace=s})),o.push(i),()=>{o.forEach((e=>e()))}}(e):()=>{},m=function(e){const{doc:t,mirror:n,blockClass:o,blockSelector:r,selectionCb:s}=e;let i=!0;const a=()=>{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:l,endOffset:d}=s;G(i,o,r,!0)||G(l,o,r,!0)||a.push({start:n.getId(i),startOffset:c,end:n.getId(l),endOffset:d})}s({ranges:a})};return a(),x("selectionchange",a)}(e),I=[];for(const t of e.plugins)I.push(t.observer(t.callback,n,t.options));return()=>{ce.forEach((e=>e.reset())),o.disconnect(),r(),s(),i(),a(),c(),l(),d(),p(),h(),g(),m(),I.forEach((e=>e()))}}class we{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,o){const r=n||this.getIdToRemoteIdMap(e),s=o||this.getRemoteIdToIdMap(e);let i=r.get(t);return i||(i=this.generateIdFn(),r.set(t,i),s.set(i,t)),i}getIds(e,t){const n=this.getIdToRemoteIdMap(e),o=this.getRemoteIdToIdMap(e);return t.map((t=>this.getId(e,t,n,o)))}getRemoteId(e,t,n){const o=n||this.getRemoteIdToIdMap(e);if("number"!=typeof t)return t;const r=o.get(t);return r||-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 ke{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new we(f),this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new we(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){if("rrweb"===e.data.type){if(!e.source)return;const t=this.crossOriginIframeMap.get(e.source);if(!t)return;const n=this.transformCrossOriginEvent(t,e.data.event);n&&this.wrappedEmit(n,e.data.isCheckout)}}transformCrossOriginEvent(e,t){var n;switch(t.type){case Q.FullSnapshot:return this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(e),this.replaceIdOnNode(t.data.node,e),{timestamp:t.timestamp,type:Q.IncrementalSnapshot,data:{source:H.Mutation,adds:[{parentId:this.mirror.getId(e),nextId:null,node:t.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Q.Meta:case Q.Load:case Q.DomContentLoaded:return!1;case Q.Plugin:return t;case Q.Custom:return this.replaceIds(t.data.payload,e,["id","parentId","previousId","nextId"]),t;case Q.IncrementalSnapshot:switch(t.data.source){case H.Mutation:return t.data.adds.forEach((t=>{this.replaceIds(t,e,["parentId","nextId","previousId"]),this.replaceIdOnNode(t.node,e)})),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 H.Drag:case H.TouchMove:case H.MouseMove:return t.data.positions.forEach((t=>{this.replaceIds(t,e,["id"])})),t;case H.ViewportResize:return!1;case H.MediaInteraction:case H.MouseInteraction:case H.Scroll:case H.CanvasMutation:case H.Input:return this.replaceIds(t.data,e,["id"]),t;case H.StyleSheetRule:case H.StyleDeclaration:return this.replaceIds(t.data,e,["id"]),this.replaceStyleIds(t.data,e,["styleId"]),t;case H.Font:return t;case H.Selection:return t.data.ranges.forEach((t=>{this.replaceIds(t,e,["start","end"])})),t;case H.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,o){for(const r of o)(Array.isArray(t[r])||"number"==typeof t[r])&&(Array.isArray(t[r])?t[r]=e.getIds(n,t[r]):t[r]=e.getId(n,t[r]));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"]),"childNodes"in e&&e.childNodes.forEach((e=>{this.replaceIdOnNode(e,t)}))}}class Me{constructor(e){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=e.mutationCb,this.scrollCb=e.scrollCb,this.bypassOptions=e.bypassOptions,this.mirror=e.mirror;const t=this;this.restorePatches.push(W(Element.prototype,"attachShadow",(function(e){return function(n){const o=e.call(this,n);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,this.ownerDocument),o}})))}addShadowRoot(e,t){a(e)&&(this.shadowDoms.has(e)||(this.shadowDoms.add(e),ge(Object.assign(Object.assign({},this.bypassOptions),{doc:t,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),e),Ie(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)),be({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},e)}),0)))}observeAttachShadow(e){if(e.contentWindow){const t=this;this.restorePatches.push(W(e.contentWindow.HTMLElement.prototype,"attachShadow",(function(n){return function(o){const r=n.call(this,o);return this.shadowRoot&&t.addShadowRoot(this.shadowRoot,e.contentDocument),r}})))}}reset(){this.restorePatches.forEach((e=>e())),this.shadowDoms=new WeakSet}}
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */function Te(e,t,n,o){return new(n||(n=Promise))((function(t,r){function s(e){try{a(o.next(e))}catch(e){r(e)}}function i(e){try{a(o.throw(e))}catch(e){r(e)}}function a(e){var o;e.done?t(e.value):(o=e.value,o instanceof n?o:new n((function(e){e(o)}))).then(s,i)}a((o=o.apply(e,[])).next())}))}for(var Ee="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Re="undefined"==typeof Uint8Array?[]:new Uint8Array(256),Ne=0;Ne<64;Ne++)Re[Ee.charCodeAt(Ne)]=Ne;const Oe=new Map;const Fe=(e,t,n)=>{if(!e||!De(e,t)&&"object"!=typeof e)return;const o=function(e,t){let n=Oe.get(e);return n||(n=new Map,Oe.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}(n,e.constructor.name);let r=o.indexOf(e);return-1===r&&(r=o.length,o.push(e)),r};function xe(e,t,n){if(e instanceof Array)return e.map((e=>xe(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),o=n.length,r="";for(t=0;t<o;t+=3)r+=Ee[n[t]>>2],r+=Ee[(3&n[t])<<4|n[t+1]>>4],r+=Ee[(15&n[t+1])<<2|n[t+2]>>6],r+=Ee[63&n[t+2]];return o%3==2?r=r.substring(0,r.length-1)+"=":o%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(e);return{rr_type:t,base64:n}}if(e instanceof DataView){return{rr_type:e.constructor.name,args:[xe(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:[xe(e.data,t,n),e.width,e.height]}}if(De(e,t)||"object"==typeof e){return{rr_type:e.constructor.name,index:Fe(e,t,n)}}return e}const Le=(e,t,n)=>[...e].map((e=>xe(e,t,n))),De=(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 Be(e,t,n){const o=[];try{const r=W(e.HTMLCanvasElement.prototype,"getContext",(function(e){return function(o,...r){return G(this,t,n,!0)||"__context"in this||(this.__context=o),e.apply(this,[o,...r])}}));o.push(r)}catch(e){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{o.forEach((e=>e()))}}function Ue(e,t,n,o,r,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=W(e,s,(function(e){return function(...a){const c=e.apply(this,a);if(Fe(c,i,this),!G(this.canvas,o,r,!0)){const e=Le([...a],i,this),o={type:t,property:s,args:e};n(this.canvas,o)}return c}}));a.push(c)}catch(o){const r=U(e,s,{set(e){n(this.canvas,{type:t,property:s,args:[e],setter:!0})}});a.push(r)}return a}var We=null;try{var Ze="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof __non_webpack_require__&&__non_webpack_require__("worker_threads")||"function"==typeo