UNPKG

rrweb

Version:
4 lines 141 kB
var rrweb=function(ee){"use strict";var D;(function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"})(D||(D={}));function Tt(t){return t.nodeType===t.ELEMENT_NODE}function Oe(t){var e=t?.host;return Boolean(e?.shadowRoot===t)}function Le(t){return Object.prototype.toString.call(t)==="[object ShadowRoot]"}function Kn(t){return t.includes(" background-clip: text;")&&!t.includes(" -webkit-background-clip: text;")&&(t=t.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),t}function Je(t){try{var e=t.rules||t.cssRules;return e?Kn(Array.from(e).map(Mt).join("")):null}catch{return null}}function Mt(t){var e=t.cssText;if(Qn(t))try{e=Je(t.styleSheet)||e}catch{}return e}function Qn(t){return"styleSheet"in t}var qe=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(e){var n;if(!e)return-1;var r=(n=this.getMeta(e))===null||n===void 0?void 0:n.id;return r??-1},t.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},t.prototype.removeNodeFromMap=function(e){var n=this,r=this.getId(e);this.idNodeMap.delete(r),e.childNodes&&e.childNodes.forEach(function(o){return n.removeNodeFromMap(o)})},t.prototype.has=function(e){return this.idNodeMap.has(e)},t.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},t.prototype.add=function(e,n){var r=n.id;this.idNodeMap.set(r,e),this.nodeMetaMap.set(e,n)},t.prototype.replace=function(e,n){var r=this.getNode(e);if(r){var o=this.nodeMetaMap.get(r);o&&this.nodeMetaMap.set(n,o)}this.idNodeMap.set(e,n)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function kt(){return new qe}function et(t){var e=t.maskInputOptions,n=t.tagName,r=t.type,o=t.value,a=t.maskInputFn,s=o||"";return(e[n.toLowerCase()]||e[r])&&(a?s=a(s):s="*".repeat(s.length)),s}var Dt="__rrweb_original__";function Jn(t){var e=t.getContext("2d");if(!e)return!0;for(var n=50,r=0;r<t.width;r+=n)for(var o=0;o<t.height;o+=n){var a=e.getImageData,s=Dt in a?a[Dt]:a,i=new Uint32Array(s.call(e,r,o,Math.min(n,t.width-r),Math.min(n,t.height-o)).data.buffer);if(i.some(function(l){return l!==0}))return!1}return!0}var qn=1,er=new RegExp("[^a-z0-9-_:]"),Ae=-2;function Rt(){return qn++}function tr(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return er.test(e)?"div":e}function nr(t){return t.cssRules?Array.from(t.cssRules).map(function(e){return e.cssText||""}).join(""):""}function rr(t){var e="";return t.indexOf("//")>-1?e=t.split("/").slice(0,3).join("/"):e=t.split("/")[0],e=e.split("?")[0],e}var we,xt,or=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,sr=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,ir=/^(data:)([^,]*),(.*)/i;function Ve(t,e){return(t||"").replace(or,function(n,r,o,a,s,i){var l=o||s||i,c=r||a||"";if(!l)return n;if(!sr.test(l)||ir.test(l))return"url(".concat(c).concat(l).concat(c,")");if(l[0]==="/")return"url(".concat(c).concat(rr(e)+l).concat(c,")");var u=e.split("/"),d=l.split("/");u.pop();for(var h=0,p=d;h<p.length;h++){var m=p[h];m!=="."&&(m===".."?u.pop():u.push(m))}return"url(".concat(c).concat(u.join("/")).concat(c,")")})}var ar=/^[^ \t\n\r\u000c]+/,lr=/^[, \t\n\r\u000c]+/;function cr(t,e){if(e.trim()==="")return e;var n=0;function r(c){var u,d=c.exec(e.substring(n));return d?(u=d[0],n+=u.length,u):""}for(var o=[];r(lr),!(n>=e.length);){var a=r(ar);if(a.slice(-1)===",")a=Be(t,a.substring(0,a.length-1)),o.push(a);else{var s="";a=Be(t,a);for(var i=!1;;){var l=e.charAt(n);if(l===""){o.push((a+s).trim());break}else if(i)l===")"&&(i=!1);else if(l===","){n+=1,o.push((a+s).trim());break}else l==="("&&(i=!0);s+=l,n+=1}}}return o.join(", ")}function Be(t,e){if(!e||e.trim()==="")return e;var n=t.createElement("a");return n.href=e,n.href}function ur(t){return Boolean(t.tagName==="svg"||t.ownerSVGElement)}function tt(){var t=document.createElement("a");return t.href="",t.href}function Ot(t,e,n,r){return n==="src"||n==="href"&&r&&!(e==="use"&&r[0]==="#")||n==="xlink:href"&&r&&r[0]!=="#"||n==="background"&&r&&(e==="table"||e==="td"||e==="th")?Be(t,r):n==="srcset"&&r?cr(t,r):n==="style"&&r?Ve(r,tt()):e==="object"&&n==="data"&&r?Be(t,r):r}function dr(t,e,n){if(typeof e=="string"){if(t.classList.contains(e))return!0}else for(var r=t.classList.length;r--;){var o=t.classList[r];if(e.test(o))return!0}return n?t.matches(n):!1}function Ge(t,e,n){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return n?Ge(t.parentNode,e,n):!1;for(var r=t.classList.length;r--;){var o=t.classList[r];if(e.test(o))return!0}return n?Ge(t.parentNode,e,n):!1}function Lt(t,e,n){var r=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(r===null)return!1;if(typeof e=="string"){if(r.classList.contains(e)||r.closest(".".concat(e)))return!0}else if(Ge(r,e,!0))return!0;return!!(n&&(r.matches(n)||r.closest(n)))}function hr(t,e,n){var r=t.contentWindow;if(r){var o=!1,a;try{a=r.document.readyState}catch{return}if(a!=="complete"){var s=setTimeout(function(){o||(e(),o=!0)},n);t.addEventListener("load",function(){clearTimeout(s),o=!0,e()});return}var i="about:blank";if(r.location.href!==i||t.src===i||t.src==="")return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}}function pr(t,e,n){var r=!1,o;try{o=t.sheet}catch{return}if(!o){var a=setTimeout(function(){r||(e(),r=!0)},n);t.addEventListener("load",function(){clearTimeout(a),r=!0,e()})}}function mr(t,e){var n=e.doc,r=e.mirror,o=e.blockClass,a=e.blockSelector,s=e.maskTextClass,i=e.maskTextSelector,l=e.inlineStylesheet,c=e.maskInputOptions,u=c===void 0?{}:c,d=e.maskTextFn,h=e.maskInputFn,p=e.dataURLOptions,m=p===void 0?{}:p,b=e.inlineImages,S=e.recordCanvas,f=e.keepIframeSrcFn,y=e.newlyAddedElement,g=y===void 0?!1:y,E=fr(n,r);switch(t.nodeType){case t.DOCUMENT_NODE:return t.compatMode!=="CSS1Compat"?{type:D.Document,childNodes:[],compatMode:t.compatMode}:{type:D.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:D.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:E};case t.ELEMENT_NODE:return gr(t,{doc:n,blockClass:o,blockSelector:a,inlineStylesheet:l,maskInputOptions:u,maskInputFn:h,dataURLOptions:m,inlineImages:b,recordCanvas:S,keepIframeSrcFn:f,newlyAddedElement:g,rootId:E});case t.TEXT_NODE:return yr(t,{maskTextClass:s,maskTextSelector:i,maskTextFn:d,rootId:E});case t.CDATA_SECTION_NODE:return{type:D.CDATA,textContent:"",rootId:E};case t.COMMENT_NODE:return{type:D.Comment,textContent:t.textContent||"",rootId:E};default:return!1}}function fr(t,e){if(e.hasNode(t)){var n=e.getId(t);return n===1?void 0:n}}function yr(t,e){var n,r=e.maskTextClass,o=e.maskTextSelector,a=e.maskTextFn,s=e.rootId,i=t.parentNode&&t.parentNode.tagName,l=t.textContent,c=i==="STYLE"?!0:void 0,u=i==="SCRIPT"?!0:void 0;if(c&&l){try{t.nextSibling||t.previousSibling||!((n=t.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(l=nr(t.parentNode.sheet))}catch(d){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(d),t)}l=Ve(l,tt())}return u&&(l="SCRIPT_PLACEHOLDER"),!c&&!u&&l&&Lt(t,r,o)&&(l=a?a(l):l.replace(/[\S]/g,"*")),{type:D.Text,textContent:l||"",isStyle:c,rootId:s}}function gr(t,e){for(var n=e.doc,r=e.blockClass,o=e.blockSelector,a=e.inlineStylesheet,s=e.maskInputOptions,i=s===void 0?{}:s,l=e.maskInputFn,c=e.dataURLOptions,u=c===void 0?{}:c,d=e.inlineImages,h=e.recordCanvas,p=e.keepIframeSrcFn,m=e.newlyAddedElement,b=m===void 0?!1:m,S=e.rootId,f=dr(t,r,o),y=tr(t),g={},E=t.attributes.length,k=0;k<E;k++){var x=t.attributes[k];g[x.name]=Ot(n,y,x.name,x.value)}if(y==="link"&&a){var F=Array.from(n.styleSheets).find(function(v){return v.href===t.href}),_=null;F&&(_=Je(F)),_&&(delete g.rel,delete g.href,g._cssText=Ve(_,F.href))}if(y==="style"&&t.sheet&&!(t.innerText||t.textContent||"").trim().length){var _=Je(t.sheet);_&&(g._cssText=Ve(_,tt()))}if(y==="input"||y==="textarea"||y==="select"){var J=t.value,Y=t.checked;g.type!=="radio"&&g.type!=="checkbox"&&g.type!=="submit"&&g.type!=="button"&&J?g.value=et({type:g.type,tagName:y,value:J,maskInputOptions:i,maskInputFn:l}):Y&&(g.checked=Y)}if(y==="option"&&(t.selected&&!i.select?g.selected=!0:delete g.selected),y==="canvas"&&h){if(t.__context==="2d")Jn(t)||(g.rr_dataURL=t.toDataURL(u.type,u.quality));else if(!("__context"in t)){var q=t.toDataURL(u.type,u.quality),z=document.createElement("canvas");z.width=t.width,z.height=t.height;var X=z.toDataURL(u.type,u.quality);q!==X&&(g.rr_dataURL=q)}}if(y==="img"&&d){we||(we=n.createElement("canvas"),xt=we.getContext("2d"));var $=t,Z=$.crossOrigin;$.crossOrigin="anonymous";var H=function(){try{we.width=$.naturalWidth,we.height=$.naturalHeight,xt.drawImage($,0,0),g.rr_dataURL=we.toDataURL(u.type,u.quality)}catch(v){console.warn("Cannot inline img src=".concat($.currentSrc,"! Error: ").concat(v))}Z?g.crossOrigin=Z:$.removeAttribute("crossorigin")};$.complete&&$.naturalWidth!==0?H():$.onload=H}if((y==="audio"||y==="video")&&(g.rr_mediaState=t.paused?"paused":"played",g.rr_mediaCurrentTime=t.currentTime),b||(t.scrollLeft&&(g.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(g.rr_scrollTop=t.scrollTop)),f){var L=t.getBoundingClientRect(),te=L.width,w=L.height;g={class:g.class,rr_width:"".concat(te,"px"),rr_height:"".concat(w,"px")}}return y==="iframe"&&!p(g.src)&&(t.contentDocument||(g.rr_src=g.src),delete g.src),{type:D.Element,tagName:y,attributes:g,childNodes:[],isSVG:ur(t)||void 0,needBlock:f,rootId:S}}function P(t){return t===void 0?"":t.toLowerCase()}function vr(t,e){return!!(e.comment&&t.type===D.Comment||t.type===D.Element&&(e.script&&(t.tagName==="script"||t.tagName==="link"&&t.attributes.rel==="preload"&&t.attributes.as==="script"||t.tagName==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&t.attributes.href.endsWith(".js"))||e.headFavicon&&(t.tagName==="link"&&t.attributes.rel==="shortcut icon"||t.tagName==="meta"&&(P(t.attributes.name).match(/^msapplication-tile(image|color)$/)||P(t.attributes.name)==="application-name"||P(t.attributes.rel)==="icon"||P(t.attributes.rel)==="apple-touch-icon"||P(t.attributes.rel)==="shortcut icon"))||t.tagName==="meta"&&(e.headMetaDescKeywords&&P(t.attributes.name).match(/^description|keywords$/)||e.headMetaSocial&&(P(t.attributes.property).match(/^(og|twitter|fb):/)||P(t.attributes.name).match(/^(og|twitter):/)||P(t.attributes.name)==="pinterest")||e.headMetaRobots&&(P(t.attributes.name)==="robots"||P(t.attributes.name)==="googlebot"||P(t.attributes.name)==="bingbot")||e.headMetaHttpEquiv&&t.attributes["http-equiv"]!==void 0||e.headMetaAuthorship&&(P(t.attributes.name)==="author"||P(t.attributes.name)==="generator"||P(t.attributes.name)==="framework"||P(t.attributes.name)==="publisher"||P(t.attributes.name)==="progid"||P(t.attributes.property).match(/^article:/)||P(t.attributes.property).match(/^product:/))||e.headMetaVerification&&(P(t.attributes.name)==="google-site-verification"||P(t.attributes.name)==="yandex-verification"||P(t.attributes.name)==="csrf-token"||P(t.attributes.name)==="p:domain_verify"||P(t.attributes.name)==="verify-v1"||P(t.attributes.name)==="verification"||P(t.attributes.name)==="shopify-checkout-api-token"))))}function Ee(t,e){var n=e.doc,r=e.mirror,o=e.blockClass,a=e.blockSelector,s=e.maskTextClass,i=e.maskTextSelector,l=e.skipChild,c=l===void 0?!1:l,u=e.inlineStylesheet,d=u===void 0?!0:u,h=e.maskInputOptions,p=h===void 0?{}:h,m=e.maskTextFn,b=e.maskInputFn,S=e.slimDOMOptions,f=e.dataURLOptions,y=f===void 0?{}:f,g=e.inlineImages,E=g===void 0?!1:g,k=e.recordCanvas,x=k===void 0?!1:k,F=e.onSerialize,_=e.onIframeLoad,J=e.iframeLoadTimeout,Y=J===void 0?5e3:J,q=e.onStylesheetLoad,z=e.stylesheetLoadTimeout,X=z===void 0?5e3:z,$=e.keepIframeSrcFn,Z=$===void 0?function(){return!1}:$,H=e.newlyAddedElement,L=H===void 0?!1:H,te=e.preserveWhiteSpace,w=te===void 0?!0:te,v=mr(t,{doc:n,mirror:r,blockClass:o,blockSelector:a,maskTextClass:s,maskTextSelector:i,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:b,dataURLOptions:y,inlineImages:E,recordCanvas:x,keepIframeSrcFn:Z,newlyAddedElement:L});if(!v)return console.warn(t,"not serialized"),null;var M;r.hasNode(t)?M=r.getId(t):vr(v,S)||!w&&v.type===D.Text&&!v.isStyle&&!v.textContent.replace(/^\s+|\s+$/gm,"").length?M=Ae:M=Rt();var T=Object.assign(v,{id:M});if(r.add(t,T),M===Ae)return null;F&&F(t);var W=!c;if(T.type===D.Element){W=W&&!T.needBlock,delete T.needBlock;var ne=t.shadowRoot;ne&&Le(ne)&&(T.isShadowHost=!0)}if((T.type===D.Document||T.type===D.Element)&&W){S.headWhitespace&&T.type===D.Element&&T.tagName==="head"&&(w=!1);for(var xe={doc:n,mirror:r,blockClass:o,blockSelector:a,maskTextClass:s,maskTextSelector:i,skipChild:c,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:b,slimDOMOptions:S,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:w,onSerialize:F,onIframeLoad:_,iframeLoadTimeout:Y,onStylesheetLoad:q,stylesheetLoadTimeout:X,keepIframeSrcFn:Z},I=0,oe=Array.from(t.childNodes);I<oe.length;I++){var ae=oe[I],B=Ee(ae,xe);B&&T.childNodes.push(B)}if(Tt(t)&&t.shadowRoot)for(var ue=0,A=Array.from(t.shadowRoot.childNodes);ue<A.length;ue++){var ae=A[ue],B=Ee(ae,xe);B&&(Le(t.shadowRoot)&&(B.isShadow=!0),T.childNodes.push(B))}}return t.parentNode&&Oe(t.parentNode)&&Le(t.parentNode)&&(T.isShadow=!0),T.type===D.Element&&T.tagName==="iframe"&&hr(t,function(){var ie=t.contentDocument;if(ie&&_){var Ue=Ee(ie,{doc:ie,mirror:r,blockClass:o,blockSelector:a,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:b,slimDOMOptions:S,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:w,onSerialize:F,onIframeLoad:_,iframeLoadTimeout:Y,onStylesheetLoad:q,stylesheetLoadTimeout:X,keepIframeSrcFn:Z});Ue&&_(t,Ue)}},Y),T.type===D.Element&&T.tagName==="link"&&T.attributes.rel==="stylesheet"&&pr(t,function(){if(q){var ie=Ee(t,{doc:n,mirror:r,blockClass:o,blockSelector:a,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:d,maskInputOptions:p,maskTextFn:m,maskInputFn:b,slimDOMOptions:S,dataURLOptions:y,inlineImages:E,recordCanvas:x,preserveWhiteSpace:w,onSerialize:F,onIframeLoad:_,iframeLoadTimeout:Y,onStylesheetLoad:q,stylesheetLoadTimeout:X,keepIframeSrcFn:Z});ie&&q(t,ie)}},X),T}function Sr(t,e){var n=e||{},r=n.mirror,o=r===void 0?new qe:r,a=n.blockClass,s=a===void 0?"rr-block":a,i=n.blockSelector,l=i===void 0?null:i,c=n.maskTextClass,u=c===void 0?"rr-mask":c,d=n.maskTextSelector,h=d===void 0?null:d,p=n.inlineStylesheet,m=p===void 0?!0:p,b=n.inlineImages,S=b===void 0?!1:b,f=n.recordCanvas,y=f===void 0?!1:f,g=n.maskAllInputs,E=g===void 0?!1:g,k=n.maskTextFn,x=n.maskInputFn,F=n.slimDOM,_=F===void 0?!1:F,J=n.dataURLOptions,Y=n.preserveWhiteSpace,q=n.onSerialize,z=n.onIframeLoad,X=n.iframeLoadTimeout,$=n.onStylesheetLoad,Z=n.stylesheetLoadTimeout,H=n.keepIframeSrcFn,L=H===void 0?function(){return!1}:H,te=E===!0?{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}:E===!1?{password:!0}:E,w=_===!0||_==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:_==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:_===!1?{}:_;return Ee(t,{doc:t,mirror:o,blockClass:s,blockSelector:l,maskTextClass:u,maskTextSelector:h,skipChild:!1,inlineStylesheet:m,maskInputOptions:te,maskTextFn:k,maskInputFn:x,slimDOMOptions:w,dataURLOptions:J,inlineImages:S,recordCanvas:y,preserveWhiteSpace:Y,onSerialize:q,onIframeLoad:z,iframeLoadTimeout:X,onStylesheetLoad:$,stylesheetLoadTimeout:Z,keepIframeSrcFn:L,newlyAddedElement:!1})}var At=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function br(t,e){e===void 0&&(e={});var n=1,r=1;function o(w){var v=w.match(/\n/g);v&&(n+=v.length);var M=w.lastIndexOf(` `);r=M===-1?r+w.length:w.length-M}function a(){var w={line:n,column:r};return function(v){return v.position=new s(w),m(),v}}var s=function(){function w(v){this.start=v,this.end={line:n,column:r},this.source=e.source}return w}();s.prototype.content=t;var i=[];function l(w){var v=new Error("".concat(e.source||"",":").concat(n,":").concat(r,": ").concat(w));if(v.reason=w,v.filename=e.source,v.line=n,v.column=r,v.source=t,e.silent)i.push(v);else throw v}function c(){var w=h();return{type:"stylesheet",stylesheet:{source:e.source,rules:w,parsingErrors:i}}}function u(){return p(/^{\s*/)}function d(){return p(/^}/)}function h(){var w,v=[];for(m(),b(v);t.length&&t.charAt(0)!=="}"&&(w=L()||te());)w!==!1&&(v.push(w),b(v));return v}function p(w){var v=w.exec(t);if(v){var M=v[0];return o(M),t=t.slice(M.length),v}}function m(){p(/^\s*/)}function b(w){w===void 0&&(w=[]);for(var v;v=S();)v!==!1&&w.push(v),v=S();return w}function S(){var w=a();if(!(t.charAt(0)!=="/"||t.charAt(1)!=="*")){for(var v=2;t.charAt(v)!==""&&(t.charAt(v)!=="*"||t.charAt(v+1)!=="/");)++v;if(v+=2,t.charAt(v-1)==="")return l("End of comment missing");var M=t.slice(2,v-2);return r+=2,o(M),t=t.slice(v),r+=2,w({type:"comment",comment:M})}}function f(){var w=p(/^([^{]+)/);if(w)return he(w[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(v){return v.replace(/,/g,"\u200C")}).split(/\s*(?![^(]*\)),\s*/).map(function(v){return v.replace(/\u200C/g,",")})}function y(){var w=a(),v=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(v){var M=he(v[0]);if(!p(/^:\s*/))return l("property missing ':'");var T=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),W=w({type:"declaration",property:M.replace(At,""),value:T?he(T[0]).replace(At,""):""});return p(/^[;\s]*/),W}}function g(){var w=[];if(!u())return l("missing '{'");b(w);for(var v;v=y();)v!==!1&&(w.push(v),b(w)),v=y();return d()?w:l("missing '}'")}function E(){for(var w,v=[],M=a();w=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)v.push(w[1]),p(/^,\s*/);if(v.length)return M({type:"keyframe",values:v,declarations:g()})}function k(){var w=a(),v=p(/^@([-\w]+)?keyframes\s*/);if(v){var M=v[1];if(v=p(/^([-\w]+)\s*/),!v)return l("@keyframes missing name");var T=v[1];if(!u())return l("@keyframes missing '{'");for(var W,ne=b();W=E();)ne.push(W),ne=ne.concat(b());return d()?w({type:"keyframes",name:T,vendor:M,keyframes:ne}):l("@keyframes missing '}'")}}function x(){var w=a(),v=p(/^@supports *([^{]+)/);if(v){var M=he(v[1]);if(!u())return l("@supports missing '{'");var T=b().concat(h());return d()?w({type:"supports",supports:M,rules:T}):l("@supports missing '}'")}}function F(){var w=a(),v=p(/^@host\s*/);if(v){if(!u())return l("@host missing '{'");var M=b().concat(h());return d()?w({type:"host",rules:M}):l("@host missing '}'")}}function _(){var w=a(),v=p(/^@media *([^{]+)/);if(v){var M=he(v[1]);if(!u())return l("@media missing '{'");var T=b().concat(h());return d()?w({type:"media",media:M,rules:T}):l("@media missing '}'")}}function J(){var w=a(),v=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(v)return w({type:"custom-media",name:he(v[1]),media:he(v[2])})}function Y(){var w=a(),v=p(/^@page */);if(v){var M=f()||[];if(!u())return l("@page missing '{'");for(var T=b(),W;W=y();)T.push(W),T=T.concat(b());return d()?w({type:"page",selectors:M,declarations:T}):l("@page missing '}'")}}function q(){var w=a(),v=p(/^@([-\w]+)?document *([^{]+)/);if(v){var M=he(v[1]),T=he(v[2]);if(!u())return l("@document missing '{'");var W=b().concat(h());return d()?w({type:"document",document:T,vendor:M,rules:W}):l("@document missing '}'")}}function z(){var w=a(),v=p(/^@font-face\s*/);if(v){if(!u())return l("@font-face missing '{'");for(var M=b(),T;T=y();)M.push(T),M=M.concat(b());return d()?w({type:"font-face",declarations:M}):l("@font-face missing '}'")}}var X=H("import"),$=H("charset"),Z=H("namespace");function H(w){var v=new RegExp("^@"+w+"\\s*([^;]+);");return function(){var M=a(),T=p(v);if(T){var W={type:w};return W[w]=T[1].trim(),M(W)}}}function L(){if(t[0]==="@")return k()||_()||J()||x()||X()||$()||Z()||q()||Y()||F()||z()}function te(){var w=a(),v=f();return v?(b(),w({type:"rule",selectors:v,declarations:g()})):l("selector missing")}return nt(c())}function he(t){return t?t.replace(/^\s+|\s+$/g,""):""}function nt(t,e){for(var n=t&&typeof t.type=="string",r=n?t:e,o=0,a=Object.keys(t);o<a.length;o++){var s=a[o],i=t[s];Array.isArray(i)?i.forEach(function(l){nt(l,r)}):i&&typeof i=="object"&&nt(i,r)}return n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:e||null}),t}var _t={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};function wr(t){var e=_t[t.tagName]?_t[t.tagName]:t.tagName;return e==="link"&&t.attributes._cssText&&(e="style"),e}function Er(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ft=/([^\\]):hover/,Nr=new RegExp(Ft.source,"g");function Pt(t,e){var n=e?.stylesWithHoverClass.get(t);if(n)return n;var r=br(t,{silent:!0});if(!r.stylesheet)return t;var o=[];if(r.stylesheet.rules.forEach(function(i){"selectors"in i&&(i.selectors||[]).forEach(function(l){Ft.test(l)&&o.push(l)})}),o.length===0)return t;var a=new RegExp(o.filter(function(i,l){return o.indexOf(i)===l}).sort(function(i,l){return l.length-i.length}).map(function(i){return Er(i)}).join("|"),"g"),s=t.replace(a,function(i){var l=i.replace(Nr,"$1.\\:hover");return"".concat(i,", ").concat(l)});return e?.stylesWithHoverClass.set(t,s),s}function Wt(){var t=new Map;return{stylesWithHoverClass:t}}function Cr(t,e){var n=e.doc,r=e.hackCss,o=e.cache;switch(t.type){case D.Document:return n.implementation.createDocument(null,"",null);case D.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case D.Element:{var a=wr(t),s;t.isSVG?s=n.createElementNS("http://www.w3.org/2000/svg",a):s=n.createElement(a);var i={};for(var l in t.attributes)if(Object.prototype.hasOwnProperty.call(t.attributes,l)){var c=t.attributes[l];if(!(a==="option"&&l==="selected"&&c===!1)){if(c===!0&&(c=""),l.startsWith("rr_")){i[l]=c;continue}var u=a==="textarea"&&l==="value",d=a==="style"&&l==="_cssText";if(d&&r&&typeof c=="string"&&(c=Pt(c,o)),(u||d)&&typeof c=="string"){for(var h=n.createTextNode(c),p=0,m=Array.from(s.childNodes);p<m.length;p++){var b=m[p];b.nodeType===s.TEXT_NODE&&s.removeChild(b)}s.appendChild(h);continue}try{if(t.isSVG&&l==="xlink:href")s.setAttributeNS("http://www.w3.org/1999/xlink",l,c.toString());else if(l==="onload"||l==="onclick"||l.substring(0,7)==="onmouse")s.setAttribute("_"+l,c.toString());else if(a==="meta"&&t.attributes["http-equiv"]==="Content-Security-Policy"&&l==="content"){s.setAttribute("csp-content",c.toString());continue}else a==="link"&&t.attributes.rel==="preload"&&t.attributes.as==="script"||a==="link"&&t.attributes.rel==="prefetch"&&typeof t.attributes.href=="string"&&t.attributes.href.endsWith(".js")||(a==="img"&&t.attributes.srcset&&t.attributes.rr_dataURL?s.setAttribute("rrweb-original-srcset",t.attributes.srcset):s.setAttribute(l,c.toString()))}catch{}}}var S=function(y){var g=i[y];if(a==="canvas"&&y==="rr_dataURL"){var E=document.createElement("img");E.onload=function(){var x=s.getContext("2d");x&&x.drawImage(E,0,0,E.width,E.height)},E.src=g.toString(),s.RRNodeType&&(s.rr_dataURL=g.toString())}else if(a==="img"&&y==="rr_dataURL"){var k=s;k.currentSrc.startsWith("data:")||(k.setAttribute("rrweb-original-src",t.attributes.src),k.src=g.toString())}if(y==="rr_width")s.style.width=g.toString();else if(y==="rr_height")s.style.height=g.toString();else if(y==="rr_mediaCurrentTime"&&typeof g=="number")s.currentTime=g;else if(y==="rr_mediaState")switch(g){case"played":s.play().catch(function(x){return console.warn("media playback error",x)});break;case"paused":s.pause();break}};for(var f in i)S(f);if(t.isShadowHost)if(!s.shadowRoot)s.attachShadow({mode:"open"});else for(;s.shadowRoot.firstChild;)s.shadowRoot.removeChild(s.shadowRoot.firstChild);return s}case D.Text:return n.createTextNode(t.isStyle&&r?Pt(t.textContent,o):t.textContent);case D.CDATA:return n.createCDATASection(t.textContent);case D.Comment:return n.createComment(t.textContent);default:return null}}function _e(t,e){var n=e.doc,r=e.mirror,o=e.skipChild,a=o===void 0?!1:o,s=e.hackCss,i=s===void 0?!0:s,l=e.afterAppend,c=e.cache,u=Cr(t,{doc:n,hackCss:i,cache:c});if(!u)return null;if(t.rootId&&r.getNode(t.rootId)!==n&&r.replace(t.rootId,n),t.type===D.Document&&(n.close(),n.open(),t.compatMode==="BackCompat"&&t.childNodes&&t.childNodes[0].type!==D.DocumentType&&(t.childNodes[0].type===D.Element&&"xmlns"in t.childNodes[0].attributes&&t.childNodes[0].attributes.xmlns==="http://www.w3.org/1999/xhtml"?n.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):n.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),u=n),r.add(u,t),(t.type===D.Document||t.type===D.Element)&&!a)for(var d=0,h=t.childNodes;d<h.length;d++){var p=h[d],m=_e(p,{doc:n,mirror:r,skipChild:!1,hackCss:i,afterAppend:l,cache:c});if(!m){console.warn("Failed to rebuild",p);continue}p.isShadow&&Tt(u)&&u.shadowRoot?u.shadowRoot.appendChild(m):u.appendChild(m),l&&l(m,p.id)}return u}function Ir(t,e){function n(s){e(s)}for(var r=0,o=t.getIds();r<o.length;r++){var a=o[r];t.has(a)&&n(t.getNode(a))}}function Tr(t,e){var n=e.getMeta(t);if(n?.type===D.Element){var r=t;for(var o in n.attributes)if(Object.prototype.hasOwnProperty.call(n.attributes,o)&&o.startsWith("rr_")){var a=n.attributes[o];o==="rr_scrollLeft"&&(r.scrollLeft=a),o==="rr_scrollTop"&&(r.scrollTop=a)}}}function Mr(t,e){var n=e.doc,r=e.onVisit,o=e.hackCss,a=o===void 0?!0:o,s=e.afterAppend,i=e.cache,l=e.mirror,c=l===void 0?new qe:l,u=_e(t,{doc:n,mirror:c,skipChild:!1,hackCss:a,afterAppend:s,cache:i});return Ir(c,function(d){r&&r(d),Tr(d,c)}),u}function K(t,e,n=document){const r={capture:!0,passive:!0};return n.addEventListener(t,e,r),()=>n.removeEventListener(t,e,r)}const Ne=`Please stop import mirror directly. Instead of that,\r now you can use replayer.getMirror() to access the mirror instance of a replayer,\r or you can use record.mirror to access the mirror instance during recording.`;ee.mirror={map:{},getId(){return console.error(Ne),-1},getNode(){return console.error(Ne),null},removeNodeFromMap(){console.error(Ne)},has(){return console.error(Ne),!1},reset(){console.error(Ne)}},typeof window<"u"&&window.Proxy&&window.Reflect&&(ee.mirror=new Proxy(ee.mirror,{get(t,e,n){return e==="map"&&console.error(Ne),Reflect.get(t,e,n)}}));function Ce(t,e,n={}){let r=null,o=0;return function(...a){const s=Date.now();!o&&n.leading===!1&&(o=s);const i=e-(s-o),l=this;i<=0||i>e?(r&&(clearTimeout(r),r=null),o=s,t.apply(l,a)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{o=n.leading===!1?0:Date.now(),r=null,t.apply(l,a)},i))}}function Fe(t,e,n,r,o=window){const a=o.Object.getOwnPropertyDescriptor(t,e);return o.Object.defineProperty(t,e,r?n:{set(s){setTimeout(()=>{n.set.call(this,s)},0),a&&a.set&&a.set.call(this,s)}}),()=>Fe(t,e,a||{},!0)}function ge(t,e,n){try{if(!(e in t))return()=>{};const r=t[e],o=n(r);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),t[e]=o,()=>{t[e]=r}}catch{return()=>{}}}function rt(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function ot(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Q(t,e,n,r){if(!t)return!1;const o=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(!o)return!1;if(typeof e=="string"){if(o.classList.contains(e)||r&&o.closest("."+e)!==null)return!0}else if(Ge(o,e,r))return!0;return!!(n&&(t.matches(n)||r&&o.closest(n)!==null))}function $t(t,e){return e.getId(t)!==-1}function je(t,e){return e.getId(t)===Ae}function st(t,e){if(Oe(t))return!1;const n=e.getId(t);return e.has(n)?t.parentNode&&t.parentNode.nodeType===t.DOCUMENT_NODE?!1:t.parentNode?st(t.parentNode,e):!0:!0}function it(t){return Boolean(t.changedTouches)}function at(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...e)=>{let n=e[0];if(!(0 in e))throw new TypeError("1 argument is required");do if(this===n)return!0;while(n=n&&n.parentNode);return!1})}function Ut(t){const e={},n=(o,a)=>{const s={value:o,parent:a,children:[]};return e[o.node.id]=s,s},r=[];for(const o of t){const{nextId:a,parentId:s}=o;if(a&&a in e){const i=e[a];if(i.parent){const l=i.parent.children.indexOf(i);i.parent.children.splice(l,0,n(o,i.parent))}else{const l=r.indexOf(i);r.splice(l,0,n(o,null))}continue}if(s in e){const i=e[s];i.children.push(n(o,i));continue}r.push(n(o,null))}return r}function lt(t,e){e(t.value);for(let n=t.children.length-1;n>=0;n--)lt(t.children[n],e)}function Ie(t,e){return Boolean(t.nodeName==="IFRAME"&&e.getMeta(t))}function ct(t,e){return Boolean(t.nodeName==="LINK"&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&t.getAttribute("rel")==="stylesheet"&&e.getMeta(t))}function ut(t,e){var n,r;const o=(r=(n=t.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!o||o===e)return{x:0,y:0,relativeScale:1,absoluteScale:1};const a=o.getBoundingClientRect(),s=ut(o,e),i=a.height/o.clientHeight;return{x:a.x*s.relativeScale+s.x,y:a.y*s.relativeScale+s.y,relativeScale:i,absoluteScale:s.absoluteScale*i}}function ve(t){return Boolean(t?.shadowRoot)}function Te(t,e){const n=t[e[0]];return e.length===1?n:Te(n.cssRules[e[1]].cssRules,e.slice(2))}function dt(t){const e=[...t],n=e.pop();return{positions:e,index:n}}function Vt(t){const e=new Set,n=[];for(let r=t.length;r--;){const o=t[r];e.has(o.id)||(n.push(o),e.add(o.id))}return n}class ht{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var n;return(n=this.styleIDMap.get(e))!=null?n:-1}has(e){return this.styleIDMap.has(e)}add(e,n){if(this.has(e))return this.getId(e);let r;return n===void 0?r=this.id++:r=n,this.styleIDMap.set(e,r),this.idStyleMap.set(r,e),r}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 kr=Object.freeze({__proto__:null,on:K,get _mirror(){return ee.mirror},throttle:Ce,hookSetter:Fe,patch:ge,getWindowHeight:rt,getWindowWidth:ot,isBlocked:Q,isSerialized:$t,isIgnored:je,isAncestorRemoved:st,isTouchEvent:it,polyfill:at,queueToResolveTrees:Ut,iterateResolveTree:lt,isSerializedIframe:Ie,isSerializedStylesheet:ct,getBaseDimension:ut,hasShadowRoot:ve,getNestedRule:Te,getPositionsAndIndex:dt,uniqueTextMutations:Vt,StyleSheetMirror:ht}),C=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(C||{}),N=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t))(N||{}),j=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(j||{}),pe=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(pe||{}),me=(t=>(t[t.Play=0]="Play",t[t.Pause=1]="Pause",t[t.Seeked=2]="Seeked",t[t.VolumeChange=3]="VolumeChange",t[t.RateChange=4]="RateChange",t))(me||{}),O=(t=>(t.Start="start",t.Pause="pause",t.Resume="resume",t.Resize="resize",t.Finish="finish",t.FullsnapshotRebuilded="fullsnapshot-rebuilded",t.LoadStylesheetStart="load-stylesheet-start",t.LoadStylesheetEnd="load-stylesheet-end",t.SkipStart="skip-start",t.SkipEnd="skip-end",t.MouseInteraction="mouse-interaction",t.EventCast="event-cast",t.CustomEvent="custom-event",t.Flush="flush",t.StateChange="state-change",t.PlayBack="play-back",t.Destroy="destroy",t))(O||{});function Bt(t){return"__ln"in t}class Dr{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let n=this.head;for(let r=0;r<e;r++)n=n?.next||null;return n}addNode(e){const n={value:e,previous:null,next:null};if(e.__ln=n,e.previousSibling&&Bt(e.previousSibling)){const r=e.previousSibling.__ln.next;n.next=r,n.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(e.nextSibling&&Bt(e.nextSibling)&&e.nextSibling.__ln.previous){const r=e.nextSibling.__ln.previous;n.previous=r,n.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;this.length++}removeNode(e){const n=e.__ln;!this.head||(n.previous?(n.previous.next=n.next,n.next&&(n.next.previous=n.previous)):(this.head=n.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const Gt=(t,e)=>`${t}@${e}`;class Rr{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=[],n=new Dr,r=i=>{let l=i,c=Ae;for(;c===Ae;)l=l&&l.nextSibling,c=l&&this.mirror.getId(l);return c},o=i=>{var l,c,u,d;let h=null;((c=(l=i.getRootNode)==null?void 0:l.call(i))==null?void 0:c.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&i.getRootNode().host&&(h=i.getRootNode().host);let p=h;for(;((d=(u=p?.getRootNode)==null?void 0:u.call(p))==null?void 0:d.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&p.getRootNode().host;)p=p.getRootNode().host;const m=!this.doc.contains(i)&&(!p||!this.doc.contains(p));if(!i.parentNode||m)return;const b=Oe(i.parentNode)?this.mirror.getId(h):this.mirror.getId(i.parentNode),S=r(i);if(b===-1||S===-1)return n.addNode(i);const f=Ee(i,{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:y=>{Ie(y,this.mirror)&&this.iframeManager.addIframe(y),ct(y,this.mirror)&&this.stylesheetManager.trackLinkElement(y),ve(i)&&this.shadowDomManager.addShadowRoot(i.shadowRoot,this.doc)},onIframeLoad:(y,g)=>{this.iframeManager.attachIframe(y,g),this.shadowDomManager.observeAttachShadow(y)},onStylesheetLoad:(y,g)=>{this.stylesheetManager.attachLinkElement(y,g)}});f&&e.push({parentId:b,nextId:S,node:f})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const i of Array.from(this.movedSet.values()))jt(this.removes,i,this.mirror)&&!this.movedSet.has(i.parentNode)||o(i);for(const i of Array.from(this.addedSet.values()))!Ht(this.droppedSet,i)&&!jt(this.removes,i,this.mirror)||Ht(this.movedSet,i)?o(i):this.droppedSet.add(i);let a=null;for(;n.length;){let i=null;if(a){const l=this.mirror.getId(a.value.parentNode),c=r(a.value);l!==-1&&c!==-1&&(i=a)}if(!i)for(let l=n.length-1;l>=0;l--){const c=n.get(l);if(c){const u=this.mirror.getId(c.value.parentNode);if(r(c.value)===-1)continue;if(u!==-1){i=c;break}else{const d=c.value;if(d.parentNode&&d.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const h=d.parentNode.host;if(this.mirror.getId(h)!==-1){i=c;break}}}}}if(!i){for(;n.head;)n.removeNode(n.head.value);break}a=i.previous,n.removeNode(i.value),o(i.value)}const s={texts:this.texts.map(i=>({id:this.mirror.getId(i.node),value:i.value})).filter(i=>this.mirror.has(i.id)),attributes:this.attributes.map(i=>({id:this.mirror.getId(i.node),attributes:i.attributes})).filter(i=>this.mirror.has(i.id)),removes:this.removes,adds:e};!s.texts.length&&!s.attributes.length&&!s.removes.length&&!s.adds.length||(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=e=>{if(!je(e.target,this.mirror))switch(e.type){case"characterData":{const n=e.target.textContent;!Q(e.target,this.blockClass,this.blockSelector,!1)&&n!==e.oldValue&&this.texts.push({value:Lt(e.target,this.maskTextClass,this.maskTextSelector)&&n?this.maskTextFn?this.maskTextFn(n):n.replace(/[\S]/g,"*"):n,node:e.target});break}case"attributes":{const n=e.target;let r=e.target.getAttribute(e.attributeName);if(e.attributeName==="value"&&(r=et({maskInputOptions:this.maskInputOptions,tagName:e.target.tagName,type:e.target.getAttribute("type"),value:r,maskInputFn:this.maskInputFn})),Q(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=this.attributes.find(a=>a.node===e.target);if(n.tagName==="IFRAME"&&e.attributeName==="src"&&!this.keepIframeSrcFn(r))if(!n.contentDocument)e.attributeName="rr_src";else return;if(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),e.attributeName==="style"){const a=this.doc.createElement("span");e.oldValue&&a.setAttribute("style",e.oldValue),(o.attributes.style===void 0||o.attributes.style===null)&&(o.attributes.style={});const s=o.attributes.style;for(const i of Array.from(n.style)){const l=n.style.getPropertyValue(i),c=n.style.getPropertyPriority(i);(l!==a.style.getPropertyValue(i)||c!==a.style.getPropertyPriority(i))&&(c===""?s[i]=l:s[i]=[l,c])}for(const i of Array.from(a.style))n.style.getPropertyValue(i)===""&&(s[i]=!1)}else o.attributes[e.attributeName]=Ot(this.doc,n.tagName,e.attributeName,r);break}case"childList":{if(Q(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(n=>this.genAdds(n,e.target)),e.removedNodes.forEach(n=>{const r=this.mirror.getId(n),o=Oe(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Q(e.target,this.blockClass,this.blockSelector,!1)||je(n,this.mirror)||!$t(n,this.mirror)||(this.addedSet.has(n)?(pt(this.addedSet,n),this.droppedSet.add(n)):this.addedSet.has(e.target)&&r===-1||st(e.target,this.mirror)||(this.movedSet.has(n)&&this.movedMap[Gt(r,o)]?pt(this.movedSet,n):this.removes.push({parentId:o,id:r,isShadow:Oe(e.target)&&Le(e.target)?!0:void 0})),this.mapRemoves.push(n))});break}}},this.genAdds=(e,n)=>{if(this.mirror.hasNode(e)){if(je(e,this.mirror))return;this.movedSet.add(e);let r=null;n&&this.mirror.hasNode(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[Gt(this.mirror.getId(e),r)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Q(e,this.blockClass,this.blockSelector,!1)||e.childNodes.forEach(r=>this.genAdds(r))}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(n=>{this[n]=e[n]})}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 pt(t,e){t.delete(e),e.childNodes.forEach(n=>pt(t,n))}function jt(t,e,n){return t.length===0?!1:zt(t,e,n)}function zt(t,e,n){const{parentNode:r}=e;if(!r)return!1;const o=n.getId(r);return t.some(a=>a.id===o)?!0:zt(t,r,n)}function Ht(t,e){return t.size===0?!1:Yt(t,e)}function Yt(t,e){const{parentNode:n}=e;return n?t.has(n)?!0:Yt(t,n):!1}var xr=Object.defineProperty,Or=Object.defineProperties,Lr=Object.getOwnPropertyDescriptors,Xt=Object.getOwnPropertySymbols,Ar=Object.prototype.hasOwnProperty,_r=Object.prototype.propertyIsEnumerable,Zt=(t,e,n)=>e in t?xr(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,Kt=(t,e)=>{for(var n in e||(e={}))Ar.call(e,n)&&Zt(t,n,e[n]);if(Xt)for(var n of Xt(e))_r.call(e,n)&&Zt(t,n,e[n]);return t},Fr=(t,e)=>Or(t,Lr(e));const Se=[],Qt=typeof CSSGroupingRule<"u",Jt=typeof CSSMediaRule<"u",qt=typeof CSSSupportsRule<"u",en=typeof CSSConditionRule<"u";function Pe(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch{return t.target}}function tn(t,e){var n,r;const o=new Rr;Se.push(o),o.init(t);let a=window.MutationObserver||window.__rrMutationObserver;const s=(r=(n=window?.Zone)==null?void 0:n.__symbol__)==null?void 0:r.call(n,"MutationObserver");s&&window[s]&&(a=window[s]);const i=new a(o.processMutations.bind(o));return i.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),i}function Pr({mousemoveCb:t,sampling:e,doc:n,mirror:r}){if(e.mousemove===!1)return()=>{};const o=typeof e.mousemove=="number"?e.mousemove:50,a=typeof e.mousemoveCallback=="number"?e.mousemoveCallback:500;let s=[],i;const l=Ce(d=>{const h=Date.now()-i;t(s.map(p=>(p.timeOffset-=h,p)),d),s=[],i=null},a),c=Ce(d=>{const h=Pe(d),{clientX:p,clientY:m}=it(d)?d.changedTouches[0]:d;i||(i=Date.now()),s.push({x:p,y:m,id:r.getId(h),timeOffset:Date.now()-i}),l(typeof DragEvent<"u"&&d instanceof DragEvent?N.Drag:d instanceof MouseEvent?N.MouseMove:N.TouchMove)},o,{trailing:!1}),u=[K("mousemove",c,n),K("touchmove",c,n),K("drag",c,n)];return()=>{u.forEach(d=>d())}}function Wr({mouseInteractionCb:t,doc:e,mirror:n,blockClass:r,blockSelector:o,sampling:a}){if(a.mouseInteraction===!1)return()=>{};const s=a.mouseInteraction===!0||a.mouseInteraction===void 0?{}:a.mouseInteraction,i=[],l=c=>u=>{const d=Pe(u);if(Q(d,r,o,!0))return;const h=it(u)?u.changedTouches[0]:u;if(!h)return;const p=n.getId(d),{clientX:m,clientY:b}=h;t({type:j[c],id:p,x:m,y:b})};return Object.keys(j).filter(c=>Number.isNaN(Number(c))&&!c.endsWith("_Departed")&&s[c]!==!1).forEach(c=>{const u=c.toLowerCase(),d=l(c);i.push(K(u,d,e))}),()=>{i.forEach(c=>c())}}function nn({scrollCb:t,doc:e,mirror:n,blockClass:r,blockSelector:o,sampling:a}){const s=Ce(i=>{const l=Pe(i);if(!l||Q(l,r,o,!0))return;const c=n.getId(l);if(l===e){const u=e.scrollingElement||e.documentElement;t({id:c,x:u.scrollLeft,y:u.scrollTop})}else t({id:c,x:l.scrollLeft,y:l.scrollTop})},a.scroll||100);return K("scroll",s,e)}function $r({viewportResizeCb:t}){let e=-1,n=-1;const r=Ce(()=>{const o=rt(),a=ot();(e!==o||n!==a)&&(t({width:Number(a),height:Number(o)}),e=o,n=a)},200);return K("resize",r,window)}function rn(t,e){const n=Kt({},t);return e||delete n.userTriggered,n}const Ur=["INPUT","TEXTAREA","SELECT"],on=new WeakMap;function Vr({inputCb:t,doc:e,mirror:n,blockClass:r,blockSelector:o,ignoreClass:a,maskInputOptions:s,maskInputFn:i,sampling:l,userTriggeredOnInput:c}){function u(S){let f=Pe(S);const y=S.isTrusted;if(f&&f.tagName==="OPTION"&&(f=f.parentElement),!f||!f.tagName||Ur.indexOf(f.tagName)<0||Q(f,r,o,!0))return;const g=f.type;if(f.classList.contains(a))return;let E=f.value,k=!1;g==="radio"||g==="checkbox"?k=f.checked:(s[f.tagName.toLowerCase()]||s[g])&&(E=et({maskInputOptions:s,tagName:f.tagName,type:g,value:E,maskInputFn:i})),d(f,rn({text:E,isChecked:k,userTriggered:y},c));const x=f.name;g==="radio"&&x&&k&&e.querySelectorAll(`input[type="radio"][name="${x}"]`).forEach(F=>{F!==f&&d(F,rn({text:F.value,isChecked:!k,userTriggered:!1},c))})}function d(S,f){const y=on.get(S);if(!y||y.text!==f.text||y.isChecked!==f.isChecked){on.set(S,f);const g=n.getId(S);t(Fr(Kt({},f),{id:g}))}}const h=(l.input==="last"?["change"]:["input","change"]).map(S=>K(S,u,e)),p=e.defaultView;if(!p)return()=>{h.forEach(S=>S())};const m=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),b=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return m&&m.set&&h.push(...b.map(S=>Fe(S[0],S[1],{set(){u({target:this})}},!1,p))),()=>{h.forEach(S=>S())}}function ze(t){const e=[];function n(r,o){if(Qt&&r.parentRule instanceof CSSGroupingRule||Jt&&r.parentRule instanceof CSSMediaRule||qt&&r.parentRule instanceof CSSSupportsRule||en&&r.parentRule instanceof CSSConditionRule){const a=Array.from(r.parentRule.cssRules).indexOf(r);o.unshift(a)}else if(r.parentStyleSheet){const a=Array.from(r.parentStyleSheet.cssRules).indexOf(r);o.unshift(a)}return o}return n(t,e)}function fe(t,e,n){let r,o;return t?(t.ownerNode?r=e.getId(t.ownerNode):o=n.getId(t),{styleId:o,id:r}):{}}function Br({styleSheetRuleCb:t,mirror:e,stylesheetManager:n},{win:r}){const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=function(u,d){const{id:h,styleId:p}=fe(this,e,n.styleMirror);return(h&&h!==-1||p&&p!==-1)&&t({id:h,styleId:p,adds:[{rule:u,index:d}]}),o.apply(this,[u,d])};const a=r.CSSStyleSheet.prototype.deleteRule;r.CSSStyleSheet.prototype.deleteRule=function(u){const{id:d,styleId:h}=fe(this,e,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,removes:[{index:u}]}),a.apply(this,[u])};let s;r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=function(u){const{id:d,styleId:h}=fe(this,e,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,replace:u}),s.apply(this,[u])});let i;r.CSSStyleSheet.prototype.replaceSync&&(i=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=function(u){const{id:d,styleId:h}=fe(this,e,n.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,replaceSync:u}),i.apply(this,[u])});const l={};Qt?l.CSSGroupingRule=r.CSSGroupingRule:(Jt&&(l.CSSMediaRule=r.CSSMediaRule),en&&(l.CSSConditionRule=r.CSSConditionRule),qt&&(l.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(l).forEach(([u,d])=>{c[u]={insertRule:d.prototype.insertRule,deleteRule:d.prototype.deleteRule},d.prototype.insertRule=function(h,p){const{id:m,styleId:b}=fe(this.parentStyleSheet,e,n.styleMirror);return(m&&m!==-1||b&&b!==-1)&&t({id:m,styleId:b,adds:[{rule:h,index:[...ze(this),p||0]}]}),c[u].insertRule.apply(this,[h,p])},d.prototype.deleteRule=function(h){const{id:p,styleId:m}=fe(this.parentStyleSheet,e,n.styleMirror);return(p&&p!==-1||m&&m!==-1)&&t({id:p,styleId:m,removes:[{index:[...ze(this),h]}]}),c[u].deleteRule.apply(this,[h])}}),()=>{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=a,s&&(r.CSSStyleSheet.prototype.replace=s),i&&(r.CSSStyleSheet.prototype.replaceSync=i),Object.entries(l).forEach(([u,d])=>{d.prototype.insertRule=c[u].insertRule,d.prototype.deleteRule=c[u].deleteRule})}}function sn({mirror:t,stylesheetManager:e},n){var r,o,a;let s=null;n.nodeName==="#document"?s=t.getId(n):s=t.getId(n.host);const i=n.nodeName==="#document"?(r=n.defaultView)==null?void 0:r.Document:(a=(o=n.ownerDocument)==null?void 0:o.defaultView)==null?void 0:a.ShadowRoot,l=Object.getOwnPropertyDescriptor(i?.prototype,"adoptedStyleSheets");return s===null||s===-1||!i||!l?()=>{}:(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var c;return(c=l.get)==null?void 0:c.call(this)},set(c){var u;const d=(u=l.set)==null?void 0:u.call(this,c);if(s!==null&&s!==-1)try{e.adoptStyleSheets(c,s)}catch{}return d}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})}function Gr({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const a=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=function(i,l,c){var u;if(n.has(i))return a.apply(this,[i,l,c]);const{id:d,styleId:h}=fe((u=this.parentRule)==null?void 0:u.parentStyleSheet,e,r.styleMirror);return(d&&d!==-1||h&&h!==-1)&&t({id:d,styleId:h,set:{property:i,value:l,priority:c},index:ze(this.parentRule)}),a.apply(this,[i,l,c])};const s=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=function(i){var l;if(n.has(i))return s.apply(this,[i]);const{id:c,styleId:u}=fe((l=this.parentRule)==null?void 0:l.parentStyleSheet,e,r.styleMirror);return(c&&c!==-1||u&&u!==-1)&&t({