rrweb
Version:
record and replay the web
4 lines • 148 kB
JavaScript
var rrweb=function(Y){"use strict";var T;(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={}));function jt(e){return e.nodeType===e.ELEMENT_NODE}function _e(e){const t=e?.host;return Boolean(t?.shadowRoot===e)}function Fe(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function gr(e){return e.includes(" background-clip: text;")&&!e.includes(" -webkit-background-clip: text;")&&(e=e.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),e}function vr(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const n=["@import",`url(${JSON.stringify(e.href)})`];return e.layerName===""?n.push("layer"):e.layerName&&n.push(`layer(${e.layerName})`),e.supportsText&&n.push(`supports(${e.supportsText})`),e.media.length&&n.push(e.media.mediaText),n.join(" ")+";"}function He(e){try{const t=e.rules||e.cssRules;return t?gr(Array.from(t,Vt).join("")):null}catch{return null}}function Vt(e){let t;if(br(e))try{t=He(e.styleSheet)||vr(e)}catch{}else if(wr(e)&&e.selectorText.includes(":"))return Sr(e.cssText);return t||e.cssText}function Sr(e){const t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}function br(e){return"styleSheet"in e}function wr(e){return"selectorText"in e}class ct{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(t){var n;if(!t)return-1;const r=(n=this.getMeta(t))===null||n===void 0?void 0:n.id;return r??-1}getNode(t){return this.idNodeMap.get(t)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(t){return this.nodeMetaMap.get(t)||null}removeNodeFromMap(t){const n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(r=>this.removeNodeFromMap(r))}has(t){return this.idNodeMap.has(t)}hasNode(t){return this.nodeMetaMap.has(t)}add(t,n){const r=n.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,n)}replace(t,n){const r=this.getNode(t);if(r){const o=this.nodeMetaMap.get(r);o&&this.nodeMetaMap.set(n,o)}this.idNodeMap.set(t,n)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function zt(){return new ct}function ut({element:e,maskInputOptions:t,tagName:n,type:r,value:o,maskInputFn:a}){let s=o||"";const i=r&&pe(r);return(t[n.toLowerCase()]||i&&t[i])&&(a?s=a(s,e):s="*".repeat(s.length)),s}function pe(e){return e.toLowerCase()}const Ht="__rrweb_original__";function Er(e){const t=e.getContext("2d");if(!t)return!0;const n=50;for(let r=0;r<e.width;r+=n)for(let o=0;o<e.height;o+=n){const a=t.getImageData,s=Ht in a?a[Ht]:a;if(new Uint32Array(s.call(t,r,o,Math.min(n,e.width-r),Math.min(n,e.height-o)).data.buffer).some(i=>i!==0))return!1}return!0}function Cr(e,t){return!e||!t||e.type!==t.type?!1:e.type===T.Document?e.compatMode===t.compatMode:e.type===T.DocumentType?e.name===t.name&&e.publicId===t.publicId&&e.systemId===t.systemId:e.type===T.Comment||e.type===T.Text||e.type===T.CDATA?e.textContent===t.textContent:e.type===T.Element?e.tagName===t.tagName&&JSON.stringify(e.attributes)===JSON.stringify(t.attributes)&&e.isSVG===t.isSVG&&e.needBlock===t.needBlock:!1}function dt(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?pe(t):null}function Gt(e,t){var n;let r;try{r=new URL(e,t??window.location.href)}catch{return null}const o=/\.([0-9a-z]+)(?:$)/i,a=r.pathname.match(o);return(n=a?.[1])!==null&&n!==void 0?n:null}let Mr=1;const Tr=new RegExp("[^a-z0-9-_:]"),Pe=-2;function Yt(){return Mr++}function Nr(e){if(e instanceof HTMLFormElement)return"form";const t=pe(e.tagName);return Tr.test(t)?"div":t}function Ir(e){let t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}let Ce,Xt;const Dr=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,kr=/^(?:[a-z+]+:)?\/\//i,Rr=/^www\..*/i,xr=/^(data:)([^,]*),(.*)/i;function Ge(e,t){return(e||"").replace(Dr,(n,r,o,a,s,i)=>{const l=o||s||i,c=r||a||"";if(!l)return n;if(kr.test(l)||Rr.test(l))return`url(${c}${l}${c})`;if(xr.test(l))return`url(${c}${l}${c})`;if(l[0]==="/")return`url(${c}${Ir(t)+l}${c})`;const u=t.split("/"),d=l.split("/");u.pop();for(const h of d)h!=="."&&(h===".."?u.pop():u.push(h));return`url(${c}${u.join("/")}${c})`})}const Or=/^[^ \t\n\r\u000c]+/,Ar=/^[, \t\n\r\u000c]+/;function Lr(e,t){if(t.trim()==="")return t;let n=0;function r(a){let s;const i=a.exec(t.substring(n));return i?(s=i[0],n+=s.length,s):""}const o=[];for(;r(Ar),!(n>=t.length);){let a=r(Or);if(a.slice(-1)===",")a=Ye(e,a.substring(0,a.length-1)),o.push(a);else{let s="";a=Ye(e,a);let i=!1;for(;;){const l=t.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 Ye(e,t){if(!t||t.trim()==="")return t;const n=e.createElement("a");return n.href=t,n.href}function _r(e){return Boolean(e.tagName==="svg"||e.ownerSVGElement)}function ht(){const e=document.createElement("a");return e.href="",e.href}function qt(e,t,n,r){return r&&(n==="src"||n==="href"&&!(t==="use"&&r[0]==="#")||n==="xlink:href"&&r[0]!=="#"||n==="background"&&(t==="table"||t==="td"||t==="th")?Ye(e,r):n==="srcset"?Lr(e,r):n==="style"?Ge(r,ht()):t==="object"&&n==="data"?Ye(e,r):r)}function Qt(e,t,n){return(e==="video"||e==="audio")&&t==="autoplay"}function Fr(e,t,n){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(let r=e.classList.length;r--;){const o=e.classList[r];if(t.test(o))return!0}if(n)return e.matches(n)}catch{}return!1}function Xe(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return n?Xe(e.parentNode,t,n):!1;for(let r=e.classList.length;r--;){const o=e.classList[r];if(t.test(o))return!0}return n?Xe(e.parentNode,t,n):!1}function Jt(e,t,n,r){try{const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(o===null)return!1;if(typeof t=="string"){if(r){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(Xe(o,t,r))return!0;if(n){if(r){if(o.closest(n))return!0}else if(o.matches(n))return!0}}catch{}return!1}function Pr(e,t,n){const r=e.contentWindow;if(!r)return;let o=!1,a;try{a=r.document.readyState}catch{return}if(a!=="complete"){const i=setTimeout(()=>{o||(t(),o=!0)},n);e.addEventListener("load",()=>{clearTimeout(i),o=!0,t()});return}const s="about:blank";if(r.location.href!==s||e.src===s||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}function $r(e,t,n){let r=!1,o;try{o=e.sheet}catch{return}if(o)return;const a=setTimeout(()=>{r||(t(),r=!0)},n);e.addEventListener("load",()=>{clearTimeout(a),r=!0,t()})}function Ur(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:a,needsMask:s,inlineStylesheet:i,maskInputOptions:l={},maskTextFn:c,maskInputFn:u,dataURLOptions:d={},inlineImages:h,recordCanvas:m,keepIframeSrcFn:y,newlyAddedElement:p=!1}=t,v=Wr(n,r);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{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:v};case e.ELEMENT_NODE:return jr(e,{doc:n,blockClass:o,blockSelector:a,inlineStylesheet:i,maskInputOptions:l,maskInputFn:u,dataURLOptions:d,inlineImages:h,recordCanvas:m,keepIframeSrcFn:y,newlyAddedElement:p,rootId:v});case e.TEXT_NODE:return Br(e,{needsMask:s,maskTextFn:c,rootId:v});case e.CDATA_SECTION_NODE:return{type:T.CDATA,textContent:"",rootId:v};case e.COMMENT_NODE:return{type:T.Comment,textContent:e.textContent||"",rootId:v};default:return!1}}function Wr(e,t){if(!t.hasNode(e))return;const n=t.getId(e);return n===1?void 0:n}function Br(e,t){var n;const{needsMask:r,maskTextFn:o,rootId:a}=t,s=e.parentNode&&e.parentNode.tagName;let i=e.textContent;const l=s==="STYLE"?!0:void 0,c=s==="SCRIPT"?!0:void 0;if(l&&i){try{e.nextSibling||e.previousSibling||!((n=e.parentNode.sheet)===null||n===void 0)&&n.cssRules&&(i=He(e.parentNode.sheet))}catch(u){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${u}`,e)}i=Ge(i,ht())}return c&&(i="SCRIPT_PLACEHOLDER"),!l&&!c&&i&&r&&(i=o?o(i,e.parentElement):i.replace(/[\S]/g,"*")),{type:T.Text,textContent:i||"",isStyle:l,rootId:a}}function jr(e,t){const{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:a,maskInputOptions:s={},maskInputFn:i,dataURLOptions:l={},inlineImages:c,recordCanvas:u,keepIframeSrcFn:d,newlyAddedElement:h=!1,rootId:m}=t,y=Fr(e,r,o),p=Nr(e);let v={};const f=e.attributes.length;for(let g=0;g<f;g++){const w=e.attributes[g];Qt(p,w.name,w.value)||(v[w.name]=qt(n,p,pe(w.name),w.value))}if(p==="link"&&a){const g=Array.from(n.styleSheets).find(N=>N.href===e.href);let w=null;g&&(w=He(g)),w&&(delete v.rel,delete v.href,v._cssText=Ge(w,g.href))}if(p==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){const g=He(e.sheet);g&&(v._cssText=Ge(g,ht()))}if(p==="input"||p==="textarea"||p==="select"){const g=e.value,w=e.checked;v.type!=="radio"&&v.type!=="checkbox"&&v.type!=="submit"&&v.type!=="button"&&g?v.value=ut({element:e,type:dt(e),tagName:p,value:g,maskInputOptions:s,maskInputFn:i}):w&&(v.checked=w)}if(p==="option"&&(e.selected&&!s.select?v.selected=!0:delete v.selected),p==="canvas"&&u){if(e.__context==="2d")Er(e)||(v.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){const g=e.toDataURL(l.type,l.quality),w=document.createElement("canvas");w.width=e.width,w.height=e.height;const N=w.toDataURL(l.type,l.quality);g!==N&&(v.rr_dataURL=g)}}if(p==="img"&&c){Ce||(Ce=n.createElement("canvas"),Xt=Ce.getContext("2d"));const g=e,w=g.crossOrigin;g.crossOrigin="anonymous";const N=()=>{g.removeEventListener("load",N);try{Ce.width=g.naturalWidth,Ce.height=g.naturalHeight,Xt.drawImage(g,0,0),v.rr_dataURL=Ce.toDataURL(l.type,l.quality)}catch(A){console.warn(`Cannot inline img src=${g.currentSrc}! Error: ${A}`)}w?v.crossOrigin=w:g.removeAttribute("crossorigin")};g.complete&&g.naturalWidth!==0?N():g.addEventListener("load",N)}if((p==="audio"||p==="video")&&(v.rr_mediaState=e.paused?"paused":"played",v.rr_mediaCurrentTime=e.currentTime),h||(e.scrollLeft&&(v.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(v.rr_scrollTop=e.scrollTop)),y){const{width:g,height:w}=e.getBoundingClientRect();v={class:v.class,rr_width:`${g}px`,rr_height:`${w}px`}}p==="iframe"&&!d(v.src)&&(e.contentDocument||(v.rr_src=v.src),delete v.src);let S;try{customElements.get(p)&&(S=!0)}catch{}return{type:T.Element,tagName:p,attributes:v,childNodes:[],isSVG:_r(e)||void 0,needBlock:y,rootId:m,isCustom:S}}function _(e){return e==null?"":e.toLowerCase()}function Vr(e,t){return!!(t.comment&&e.type===T.Comment||e.type===T.Element&&(t.script&&(e.tagName==="script"||e.tagName==="link"&&(e.attributes.rel==="preload"||e.attributes.rel==="modulepreload")&&e.attributes.as==="script"||e.tagName==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&Gt(e.attributes.href)==="js")||t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(_(e.attributes.name).match(/^msapplication-tile(image|color)$/)||_(e.attributes.name)==="application-name"||_(e.attributes.rel)==="icon"||_(e.attributes.rel)==="apple-touch-icon"||_(e.attributes.rel)==="shortcut icon"))||e.tagName==="meta"&&(t.headMetaDescKeywords&&_(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(_(e.attributes.property).match(/^(og|twitter|fb):/)||_(e.attributes.name).match(/^(og|twitter):/)||_(e.attributes.name)==="pinterest")||t.headMetaRobots&&(_(e.attributes.name)==="robots"||_(e.attributes.name)==="googlebot"||_(e.attributes.name)==="bingbot")||t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0||t.headMetaAuthorship&&(_(e.attributes.name)==="author"||_(e.attributes.name)==="generator"||_(e.attributes.name)==="framework"||_(e.attributes.name)==="publisher"||_(e.attributes.name)==="progid"||_(e.attributes.property).match(/^article:/)||_(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(_(e.attributes.name)==="google-site-verification"||_(e.attributes.name)==="yandex-verification"||_(e.attributes.name)==="csrf-token"||_(e.attributes.name)==="p:domain_verify"||_(e.attributes.name)==="verify-v1"||_(e.attributes.name)==="verification"||_(e.attributes.name)==="shopify-checkout-api-token"))))}function Me(e,t){const{doc:n,mirror:r,blockClass:o,blockSelector:a,maskTextClass:s,maskTextSelector:i,skipChild:l=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:y={},inlineImages:p=!1,recordCanvas:v=!1,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:g=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:N=5e3,keepIframeSrcFn:A=()=>!1,newlyAddedElement:j=!1}=t;let{needsMask:V}=t,{preserveWhiteSpace:Q=!0}=t;!V&&e.childNodes&&(V=Jt(e,s,i,V===void 0));const J=Ur(e,{doc:n,mirror:r,blockClass:o,blockSelector:a,needsMask:V,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,dataURLOptions:y,inlineImages:p,recordCanvas:v,keepIframeSrcFn:A,newlyAddedElement:j});if(!J)return console.warn(e,"not serialized"),null;let ne;r.hasNode(e)?ne=r.getId(e):Vr(J,m)||!Q&&J.type===T.Text&&!J.isStyle&&!J.textContent.replace(/^\s+|\s+$/gm,"").length?ne=Pe:ne=Yt();const k=Object.assign(J,{id:ne});if(r.add(e,k),ne===Pe)return null;f&&f(e);let re=!l;if(k.type===T.Element){re=re&&!k.needBlock,delete k.needBlock;const H=e.shadowRoot;H&&Fe(H)&&(k.isShadowHost=!0)}if((k.type===T.Document||k.type===T.Element)&&re){m.headWhitespace&&k.type===T.Element&&k.tagName==="head"&&(Q=!1);const H={doc:n,mirror:r,blockClass:o,blockSelector:a,needsMask:V,maskTextClass:s,maskTextSelector:i,skipChild:l,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:y,inlineImages:p,recordCanvas:v,preserveWhiteSpace:Q,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:g,onStylesheetLoad:w,stylesheetLoadTimeout:N,keepIframeSrcFn:A};if(!(k.type===T.Element&&k.tagName==="textarea"&&k.attributes.value!==void 0))for(const oe of Array.from(e.childNodes)){const G=Me(oe,H);G&&k.childNodes.push(G)}if(jt(e)&&e.shadowRoot)for(const oe of Array.from(e.shadowRoot.childNodes)){const G=Me(oe,H);G&&(Fe(e.shadowRoot)&&(G.isShadow=!0),k.childNodes.push(G))}}return e.parentNode&&_e(e.parentNode)&&Fe(e.parentNode)&&(k.isShadow=!0),k.type===T.Element&&k.tagName==="iframe"&&Pr(e,()=>{const H=e.contentDocument;if(H&&S){const oe=Me(H,{doc:H,mirror:r,blockClass:o,blockSelector:a,needsMask:V,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:y,inlineImages:p,recordCanvas:v,preserveWhiteSpace:Q,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:g,onStylesheetLoad:w,stylesheetLoadTimeout:N,keepIframeSrcFn:A});oe&&S(e,oe)}},g),k.type===T.Element&&k.tagName==="link"&&typeof k.attributes.rel=="string"&&(k.attributes.rel==="stylesheet"||k.attributes.rel==="preload"&&typeof k.attributes.href=="string"&&Gt(k.attributes.href)==="css")&&$r(e,()=>{if(w){const H=Me(e,{doc:n,mirror:r,blockClass:o,blockSelector:a,needsMask:V,maskTextClass:s,maskTextSelector:i,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:y,inlineImages:p,recordCanvas:v,preserveWhiteSpace:Q,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:g,onStylesheetLoad:w,stylesheetLoadTimeout:N,keepIframeSrcFn:A});H&&w(e,H)}},N),k}function zr(e,t){const{mirror:n=new ct,blockClass:r="rr-block",blockSelector:o=null,maskTextClass:a="rr-mask",maskTextSelector:s=null,inlineStylesheet:i=!0,inlineImages:l=!1,recordCanvas:c=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:h,slimDOM:m=!1,dataURLOptions:y,preserveWhiteSpace:p,onSerialize:v,onIframeLoad:f,iframeLoadTimeout:S,onStylesheetLoad:g,stylesheetLoadTimeout:w,keepIframeSrcFn:N=()=>!1}=t||{};return Me(e,{doc:e,mirror:n,blockClass:r,blockSelector:o,maskTextClass:a,maskTextSelector:s,skipChild:!1,inlineStylesheet:i,maskInputOptions:u===!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}:u===!1?{password:!0}:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m===!0||m==="all"?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:m==="all",headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:m===!1?{}:m,dataURLOptions:y,inlineImages:l,recordCanvas:c,preserveWhiteSpace:p,onSerialize:v,onIframeLoad:f,iframeLoadTimeout:S,onStylesheetLoad:g,stylesheetLoadTimeout:w,keepIframeSrcFn:N,newlyAddedElement:!1})}const Kt=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function Hr(e,t={}){let n=1,r=1;function o(C){const b=C.match(/\n/g);b&&(n+=b.length);const x=C.lastIndexOf(`
`);r=x===-1?r+C.length:C.length-x}function a(){const C={line:n,column:r};return b=>(b.position=new s(C),y(),b)}class s{constructor(b){this.start=b,this.end={line:n,column:r},this.source=t.source}}s.prototype.content=e;const i=[];function l(C){const b=new Error(`${t.source||""}:${n}:${r}: ${C}`);if(b.reason=C,b.filename=t.source,b.line=n,b.column=r,b.source=e,t.silent)i.push(b);else throw b}function c(){const C=h();return{type:"stylesheet",stylesheet:{source:t.source,rules:C,parsingErrors:i}}}function u(){return m(/^{\s*/)}function d(){return m(/^}/)}function h(){let C;const b=[];for(y(),p(b);e.length&&e.charAt(0)!=="}"&&(C=P()||he());)C&&(b.push(C),p(b));return b}function m(C){const b=C.exec(e);if(!b)return;const x=b[0];return o(x),e=e.slice(x.length),b}function y(){m(/^\s*/)}function p(C=[]){let b;for(;b=v();)b&&C.push(b),b=v();return C}function v(){const C=a();if(e.charAt(0)!=="/"||e.charAt(1)!=="*")return;let b=2;for(;e.charAt(b)!==""&&(e.charAt(b)!=="*"||e.charAt(b+1)!=="/");)++b;if(b+=2,e.charAt(b-1)==="")return l("End of comment missing");const x=e.slice(2,b-2);return r+=2,o(x),e=e.slice(b),r+=2,C({type:"comment",comment:x})}function f(){const C=m(/^([^{]+)/);if(C)return le(C[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,b=>b.replace(/,/g,"\u200C")).split(/\s*(?![^(]*\)),\s*/).map(b=>b.replace(/\u200C/g,","))}function S(){const C=a(),b=m(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!b)return;const x=le(b[0]);if(!m(/^:\s*/))return l("property missing ':'");const z=m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),ee=C({type:"declaration",property:x.replace(Kt,""),value:z?le(z[0]).replace(Kt,""):""});return m(/^[;\s]*/),ee}function g(){const C=[];if(!u())return l("missing '{'");p(C);let b;for(;b=S();)b!==!1&&(C.push(b),p(C)),b=S();return d()?C:l("missing '}'")}function w(){let C;const b=[],x=a();for(;C=m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)b.push(C[1]),m(/^,\s*/);if(b.length)return x({type:"keyframe",values:b,declarations:g()})}function N(){const C=a();let b=m(/^@([-\w]+)?keyframes\s*/);if(!b)return;const x=b[1];if(b=m(/^([-\w]+)\s*/),!b)return l("@keyframes missing name");const z=b[1];if(!u())return l("@keyframes missing '{'");let ee,be=p();for(;ee=w();)be.push(ee),be=be.concat(p());return d()?C({type:"keyframes",name:z,vendor:x,keyframes:be}):l("@keyframes missing '}'")}function A(){const C=a(),b=m(/^@supports *([^{]+)/);if(!b)return;const x=le(b[1]);if(!u())return l("@supports missing '{'");const z=p().concat(h());return d()?C({type:"supports",supports:x,rules:z}):l("@supports missing '}'")}function j(){const C=a();if(!m(/^@host\s*/))return;if(!u())return l("@host missing '{'");const b=p().concat(h());return d()?C({type:"host",rules:b}):l("@host missing '}'")}function V(){const C=a(),b=m(/^@media *([^{]+)/);if(!b)return;const x=le(b[1]);if(!u())return l("@media missing '{'");const z=p().concat(h());return d()?C({type:"media",media:x,rules:z}):l("@media missing '}'")}function Q(){const C=a(),b=m(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(b)return C({type:"custom-media",name:le(b[1]),media:le(b[2])})}function J(){const C=a();if(!m(/^@page */))return;const b=f()||[];if(!u())return l("@page missing '{'");let x=p(),z;for(;z=S();)x.push(z),x=x.concat(p());return d()?C({type:"page",selectors:b,declarations:x}):l("@page missing '}'")}function ne(){const C=a(),b=m(/^@([-\w]+)?document *([^{]+)/);if(!b)return;const x=le(b[1]),z=le(b[2]);if(!u())return l("@document missing '{'");const ee=p().concat(h());return d()?C({type:"document",document:z,vendor:x,rules:ee}):l("@document missing '}'")}function k(){const C=a();if(!m(/^@font-face\s*/))return;if(!u())return l("@font-face missing '{'");let b=p(),x;for(;x=S();)b.push(x),b=b.concat(p());return d()?C({type:"font-face",declarations:b}):l("@font-face missing '}'")}const re=G("import"),H=G("charset"),oe=G("namespace");function G(C){const b=new RegExp("^@"+C+"\\s*([^;]+);");return()=>{const x=a(),z=m(b);if(!z)return;const ee={type:C};return ee[C]=z[1].trim(),x(ee)}}function P(){if(e[0]==="@")return N()||V()||Q()||A()||re()||H()||oe()||ne()||J()||j()||k()}function he(){const C=a(),b=f();return b?(p(),C({type:"rule",selectors:b,declarations:g()})):l("selector missing")}return pt(c())}function le(e){return e?e.replace(/^\s+|\s+$/g,""):""}function pt(e,t){const n=e&&typeof e.type=="string",r=n?e:t;for(const o of Object.keys(e)){const a=e[o];Array.isArray(a)?a.forEach(s=>{pt(s,r)}):a&&typeof a=="object"&&pt(a,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}const Zt={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 Gr(e){let t=Zt[e.tagName]?Zt[e.tagName]:e.tagName;return t==="link"&&e.attributes._cssText&&(t="style"),t}function en(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const tn=/(max|min)-device-(width|height)/,Yr=new RegExp(tn.source,"g"),nn=/([^\\]):hover/,Xr=new RegExp(nn.source,"g");function rn(e,t){const n=t?.stylesWithHoverClass.get(e);if(n)return n;const r=Hr(e,{silent:!0});if(!r.stylesheet)return e;const o=[],a=[];function s(l){"selectors"in l&&l.selectors&&l.selectors.forEach(c=>{nn.test(c)&&o.push(c)}),"media"in l&&l.media&&tn.test(l.media)&&a.push(l.media),"rules"in l&&l.rules&&l.rules.forEach(s)}s(r.stylesheet);let i=e;if(o.length>0){const l=new RegExp(o.filter((c,u)=>o.indexOf(c)===u).sort((c,u)=>u.length-c.length).map(c=>en(c)).join("|"),"g");i=i.replace(l,c=>{const u=c.replace(Xr,"$1.\\:hover");return`${c}, ${u}`})}if(a.length>0){const l=new RegExp(a.filter((c,u)=>a.indexOf(c)===u).sort((c,u)=>u.length-c.length).map(c=>en(c)).join("|"),"g");i=i.replace(l,c=>c.replace(Yr,"$1-$2"))}return t?.stylesWithHoverClass.set(e,i),i}function on(){return{stylesWithHoverClass:new Map}}function qr(e,t){var n;const{doc:r,hackCss:o,cache:a}=t;switch(e.type){case T.Document:return r.implementation.createDocument(null,"",null);case T.DocumentType:return r.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case T.Element:{const s=Gr(e);let i;e.isSVG?i=r.createElementNS("http://www.w3.org/2000/svg",s):(e.isCustom&&((n=r.defaultView)===null||n===void 0?void 0:n.customElements)&&!r.defaultView.customElements.get(e.tagName)&&r.defaultView.customElements.define(e.tagName,class extends r.defaultView.HTMLElement{}),i=r.createElement(s));const l={};for(const c in e.attributes){if(!Object.prototype.hasOwnProperty.call(e.attributes,c))continue;let u=e.attributes[c];if(s==="option"&&c==="selected"&&u===!1||u===null)continue;if(u===!0&&(u=""),c.startsWith("rr_")){l[c]=u;continue}const d=s==="textarea"&&c==="value",h=s==="style"&&c==="_cssText";if(h&&o&&typeof u=="string"&&(u=rn(u,a)),(d||h)&&typeof u=="string"){i.appendChild(r.createTextNode(u)),e.childNodes=[];continue}try{if(e.isSVG&&c==="xlink:href")i.setAttributeNS("http://www.w3.org/1999/xlink",c,u.toString());else if(c==="onload"||c==="onclick"||c.substring(0,7)==="onmouse")i.setAttribute("_"+c,u.toString());else if(s==="meta"&&e.attributes["http-equiv"]==="Content-Security-Policy"&&c==="content"){i.setAttribute("csp-content",u.toString());continue}else s==="link"&&(e.attributes.rel==="preload"||e.attributes.rel==="modulepreload")&&e.attributes.as==="script"||s==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js")||(s==="img"&&e.attributes.srcset&&e.attributes.rr_dataURL?i.setAttribute("rrweb-original-srcset",e.attributes.srcset):i.setAttribute(c,u.toString()))}catch{}}for(const c in l){const u=l[c];if(s==="canvas"&&c==="rr_dataURL"){const d=document.createElement("img");d.onload=()=>{const h=i.getContext("2d");h&&h.drawImage(d,0,0,d.width,d.height)},d.src=u.toString(),i.RRNodeType&&(i.rr_dataURL=u.toString())}else if(s==="img"&&c==="rr_dataURL"){const d=i;d.currentSrc.startsWith("data:")||(d.setAttribute("rrweb-original-src",e.attributes.src),d.src=u.toString())}if(c==="rr_width")i.style.width=u.toString();else if(c==="rr_height")i.style.height=u.toString();else if(c==="rr_mediaCurrentTime"&&typeof u=="number")i.currentTime=u;else if(c==="rr_mediaState")switch(u){case"played":i.play().catch(d=>console.warn("media playback error",d));break;case"paused":i.pause();break}}if(e.isShadowHost)if(!i.shadowRoot)i.attachShadow({mode:"open"});else for(;i.shadowRoot.firstChild;)i.shadowRoot.removeChild(i.shadowRoot.firstChild);return i}case T.Text:return r.createTextNode(e.isStyle&&o?rn(e.textContent,a):e.textContent);case T.CDATA:return r.createCDATASection(e.textContent);case T.Comment:return r.createComment(e.textContent);default:return null}}function $e(e,t){const{doc:n,mirror:r,skipChild:o=!1,hackCss:a=!0,afterAppend:s,cache:i}=t;if(r.has(e.id)){const c=r.getNode(e.id),u=r.getMeta(c);if(Cr(u,e))return r.getNode(e.id)}let l=qr(e,{doc:n,hackCss:a,cache:i});if(!l)return null;if(e.rootId&&r.getNode(e.rootId)!==n&&r.replace(e.rootId,n),e.type===T.Document&&(n.close(),n.open(),e.compatMode==="BackCompat"&&e.childNodes&&e.childNodes[0].type!==T.DocumentType&&(e.childNodes[0].type===T.Element&&"xmlns"in e.childNodes[0].attributes&&e.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" "">')),l=n),r.add(l,e),(e.type===T.Document||e.type===T.Element)&&!o)for(const c of e.childNodes){const u=$e(c,{doc:n,mirror:r,skipChild:!1,hackCss:a,afterAppend:s,cache:i});if(!u){console.warn("Failed to rebuild",c);continue}if(c.isShadow&&jt(l)&&l.shadowRoot)l.shadowRoot.appendChild(u);else if(e.type===T.Document&&c.type==T.Element){const d=u;let h=null;d.childNodes.forEach(m=>{m.nodeName==="BODY"&&(h=m)}),h?(d.removeChild(h),l.appendChild(u),d.appendChild(h)):l.appendChild(u)}else l.appendChild(u);s&&s(u,c.id)}return l}function Qr(e,t){function n(r){t(r)}for(const r of e.getIds())e.has(r)&&n(e.getNode(r))}function Jr(e,t){const n=t.getMeta(e);if(n?.type!==T.Element)return;const r=e;for(const o in n.attributes){if(!(Object.prototype.hasOwnProperty.call(n.attributes,o)&&o.startsWith("rr_")))continue;const a=n.attributes[o];o==="rr_scrollLeft"&&(r.scrollLeft=a),o==="rr_scrollTop"&&(r.scrollTop=a)}}function Kr(e,t){const{doc:n,onVisit:r,hackCss:o=!0,afterAppend:a,cache:s,mirror:i=new ct}=t,l=$e(e,{doc:n,mirror:i,skipChild:!1,hackCss:o,afterAppend:a,cache:s});return Qr(i,c=>{r&&r(c),Jr(c,i)}),l}function X(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const Te=`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.`;Y.mirror={map:{},getId(){return console.error(Te),-1},getNode(){return console.error(Te),null},removeNodeFromMap(){console.error(Te)},has(){return console.error(Te),!1},reset(){console.error(Te)}},typeof window<"u"&&window.Proxy&&window.Reflect&&(Y.mirror=new Proxy(Y.mirror,{get(e,t,n){return t==="map"&&console.error(Te),Reflect.get(e,t,n)}}));function Ne(e,t,n={}){let r=null,o=0;return function(...a){const s=Date.now();!o&&n.leading===!1&&(o=s);const i=t-(s-o),l=this;i<=0||i>t?(r&&(clearTimeout(r),r=null),o=s,e.apply(l,a)):!r&&n.trailing!==!1&&(r=setTimeout(()=>{o=n.leading===!1?0:Date.now(),r=null,e.apply(l,a)},i))}}function Ue(e,t,n,r,o=window){const a=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(s){setTimeout(()=>{n.set.call(this,s)},0),a&&a.set&&a.set.call(this,s)}}),()=>Ue(e,t,a||{},!0)}function ge(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch{return()=>{}}}let We=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(We=()=>new Date().getTime());function mt(e){var t,n,r,o,a,s;const i=e.document;return{left:i.scrollingElement?i.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:i?.documentElement.scrollLeft||((n=(t=i?.body)==null?void 0:t.parentElement)==null?void 0:n.scrollLeft)||((r=i?.body)==null?void 0:r.scrollLeft)||0,top:i.scrollingElement?i.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:i?.documentElement.scrollTop||((a=(o=i?.body)==null?void 0:o.parentElement)==null?void 0:a.scrollTop)||((s=i?.body)==null?void 0:s.scrollTop)||0}}function ft(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function yt(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function gt(e){return e?e.nodeType===e.ELEMENT_NODE?e:e.parentElement:null}function q(e,t,n,r){if(!e)return!1;const o=gt(e);if(!o)return!1;try{if(typeof t=="string"){if(o.classList.contains(t)||r&&o.closest("."+t)!==null)return!0}else if(Xe(o,t,r))return!0}catch{}return!!(n&&(o.matches(n)||r&&o.closest(n)!==null))}function sn(e,t){return t.getId(e)!==-1}function qe(e,t){return t.getId(e)===Pe}function vt(e,t){if(_e(e))return!1;const n=t.getId(e);return t.has(n)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?vt(e.parentNode,t):!0:!0}function Qe(e){return Boolean(e.changedTouches)}function St(e=window){"NodeList"in e&&!e.NodeList.prototype.forEach&&(e.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in e&&!e.DOMTokenList.prototype.forEach&&(e.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let n=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===n)return!0;while(n=n&&n.parentNode);return!1})}function an(e){const t={},n=(o,a)=>{const s={value:o,parent:a,children:[]};return t[o.node.id]=s,s},r=[];for(const o of e){const{nextId:a,parentId:s}=o;if(a&&a in t){const i=t[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 t){const i=t[s];i.children.push(n(o,i));continue}r.push(n(o,null))}return r}function bt(e,t){t(e.value);for(let n=e.children.length-1;n>=0;n--)bt(e.children[n],t)}function Ie(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function wt(e,t){return Boolean(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Et(e,t){var n,r;const o=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!o||o===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const a=o.getBoundingClientRect(),s=Et(o,t),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 me(e){return Boolean(e?.shadowRoot)}function De(e,t){const n=e[t[0]];return t.length===1?n:De(n.cssRules[t[1]].cssRules,t.slice(2))}function Ct(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function ln(e){const t=new Set,n=[];for(let r=e.length;r--;){const o=e[r];t.has(o.id)||(n.push(o),t.add(o.id))}return n}class Mt{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var n;return(n=this.styleIDMap.get(t))!=null?n:-1}has(t){return this.styleIDMap.has(t)}add(t,n){if(this.has(t))return this.getId(t);let r;return n===void 0?r=this.id++:r=n,this.styleIDMap.set(t,r),this.idStyleMap.set(r,t),r}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Tt(e){var t,n;let r=null;return((n=(t=e.getRootNode)==null?void 0:t.call(e))==null?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function cn(e){let t=e,n;for(;n=Tt(t);)t=n;return t}function un(e){const t=e.ownerDocument;if(!t)return!1;const n=cn(e);return t.contains(n)}function Nt(e){const t=e.ownerDocument;return t?t.contains(e)||un(e):!1}var Zr=Object.freeze({__proto__:null,on:X,get _mirror(){return Y.mirror},throttle:Ne,hookSetter:Ue,patch:ge,get nowTimestamp(){return We},getWindowScroll:mt,getWindowHeight:ft,getWindowWidth:yt,closestElementOfNode:gt,isBlocked:q,isSerialized:sn,isIgnored:qe,isAncestorRemoved:vt,legacy_isTouchEvent:Qe,polyfill:St,queueToResolveTrees:an,iterateResolveTree:bt,isSerializedIframe:Ie,isSerializedStylesheet:wt,getBaseDimension:Et,hasShadowRoot:me,getNestedRule:De,getPositionsAndIndex:Ct,uniqueTextMutations:ln,StyleSheetMirror:Mt,getShadowHost:Tt,getRootShadowHost:cn,shadowHostInDom:un,inDom:Nt}),M=(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))(M||{}),E=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(E||{}),O=(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))(O||{}),ce=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(ce||{}),ue=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(ue||{}),de=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e[e.RateChange=4]="RateChange",e))(de||{}),L=(e=>(e.Start="start",e.Pause="pause",e.Resume="resume",e.Resize="resize",e.Finish="finish",e.FullsnapshotRebuilded="fullsnapshot-rebuilded",e.LoadStylesheetStart="load-stylesheet-start",e.LoadStylesheetEnd="load-stylesheet-end",e.SkipStart="skip-start",e.SkipEnd="skip-end",e.MouseInteraction="mouse-interaction",e.EventCast="event-cast",e.CustomEvent="custom-event",e.Flush="flush",e.StateChange="state-change",e.PlayBack="play-back",e.Destroy="destroy",e))(L||{});function dn(e){return"__ln"in e}class eo{constructor(){this.length=0,this.head=null,this.tail=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let n=this.head;for(let r=0;r<t;r++)n=n?.next||null;return n}addNode(t){const n={value:t,previous:null,next:null};if(t.__ln=n,t.previousSibling&&dn(t.previousSibling)){const r=t.previousSibling.__ln.next;n.next=r,n.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=n,r&&(r.previous=n)}else if(t.nextSibling&&dn(t.nextSibling)&&t.nextSibling.__ln.previous){const r=t.nextSibling.__ln.previous;n.previous=r,n.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=n,r&&(r.next=n)}else this.head&&(this.head.previous=n),n.next=this.head,this.head=n;n.next===null&&(this.tail=n),this.length++}removeNode(t){const n=t.__ln;!this.head||(n.previous?(n.previous.next=n.next,n.next?n.next.previous=n.previous:this.tail=n.previous):(this.head=n.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const hn=(e,t)=>`${e}@${t}`;class to{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],n=new Set,r=new eo,o=l=>{let c=l,u=Pe;for(;u===Pe;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},a=l=>{if(!l.parentNode||!Nt(l)||l.parentNode.tagName==="TEXTAREA")return;const c=_e(l.parentNode)?this.mirror.getId(Tt(l)):this.mirror.getId(l.parentNode),u=o(l);if(c===-1||u===-1)return r.addNode(l);const d=Me(l,{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:h=>{Ie(h,this.mirror)&&this.iframeManager.addIframe(h),wt(h,this.mirror)&&this.stylesheetManager.trackLinkElement(h),me(l)&&this.shadowDomManager.addShadowRoot(l.shadowRoot,this.doc)},onIframeLoad:(h,m)=>{this.iframeManager.attachIframe(h,m),this.shadowDomManager.observeAttachShadow(h)},onStylesheetLoad:(h,m)=>{this.stylesheetManager.attachLinkElement(h,m)}});d&&(t.push({parentId:c,nextId:u,node:d}),n.add(d.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const l of this.movedSet)pn(this.removes,l,this.mirror)&&!this.movedSet.has(l.parentNode)||a(l);for(const l of this.addedSet)!fn(this.droppedSet,l)&&!pn(this.removes,l,this.mirror)||fn(this.movedSet,l)?a(l):this.droppedSet.add(l);let s=null;for(;r.length;){let l=null;if(s){const c=this.mirror.getId(s.value.parentNode),u=o(s.value);c!==-1&&u!==-1&&(l=s)}if(!l){let c=r.tail;for(;c;){const u=c;if(c=c.previous,u){const d=this.mirror.getId(u.value.parentNode);if(o(u.value)===-1)continue;if(d!==-1){l=u;break}else{const h=u.value;if(h.parentNode&&h.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const m=h.parentNode.host;if(this.mirror.getId(m)!==-1){l=u;break}}}}}}if(!l){for(;r.head;)r.removeNode(r.head.value);break}s=l.previous,r.removeNode(l.value),a(l.value)}const i={texts:this.texts.map(l=>{const c=l.node;return c.parentNode.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(c.parentNode),{id:this.mirror.getId(c),value:l.value}}).filter(l=>!n.has(l.id)).filter(l=>this.mirror.has(l.id)),attributes:this.attributes.map(l=>{const{attributes:c}=l;if(typeof c.style=="string"){const u=JSON.stringify(l.styleDiff),d=JSON.stringify(l._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=l.styleDiff)}return{id:this.mirror.getId(l.node),attributes:c}}).filter(l=>!n.has(l.id)).filter(l=>this.mirror.has(l.id)),removes:this.removes,adds:t};!i.texts.length&&!i.attributes.length&&!i.removes.length&&!i.adds.length||(this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.genTextAreaValueMutation=t=>{let n=this.attributeMap.get(t);n||(n={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(n),this.attributeMap.set(t,n)),n.attributes.value=Array.from(t.childNodes,r=>r.textContent||"").join("")},this.processMutation=t=>{if(!qe(t.target,this.mirror))switch(t.type){case"characterData":{const n=t.target.textContent;!q(t.target,this.blockClass,this.blockSelector,!1)&&n!==t.oldValue&&this.texts.push({value:Jt(t.target,this.maskTextClass,this.maskTextSelector,!0)&&n?this.maskTextFn?this.maskTextFn(n,gt(t.target)):n.replace(/[\S]/g,"*"):n,node:t.target});break}case"attributes":{const n=t.target;let r=t.attributeName,o=t.target.getAttribute(r);if(r==="value"){const s=dt(n);o=ut({element:n,maskInputOptions:this.maskInputOptions,tagName:n.tagName,type:s,value:o,maskInputFn:this.maskInputFn})}if(q(t.target,this.blockClass,this.blockSelector,!1)||o===t.oldValue)return;let a=this.attributeMap.get(t.target);if(n.tagName==="IFRAME"&&r==="src"&&!this.keepIframeSrcFn(o))if(!n.contentDocument)r="rr_src";else return;if(a||(a={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(a),this.attributeMap.set(t.target,a)),r==="type"&&n.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&n.setAttribute("data-rr-is-password","true"),!Qt(n.tagName,r)&&(a.attributes[r]=qt(this.doc,pe(n.tagName),pe(r),o),r==="style")){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const s=this.unattachedDoc.createElement("span");t.oldValue&&s.setAttribute("style",t.oldValue);for(const i of Array.from(n.style)){const l=n.style.getPropertyValue(i),c=n.style.getPropertyPriority(i);l!==s.style.getPropertyValue(i)||c!==s.style.getPropertyPriority(i)?c===""?a.styleDiff[i]=l:a.styleDiff[i]=[l,c]:a._unchangedStyles[i]=[l,c]}for(const i of Array.from(s.style))n.style.getPropertyValue(i)===""&&(a.styleDiff[i]=!1)}break}case"childList":{if(q(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(t.target);return}t.addedNodes.forEach(n=>this.genAdds(n,t.target)),t.removedNodes.forEach(n=>{const r=this.mirror.getId(n),o=_e(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);q(t.target,this.blockClass,this.blockSelector,!1)||qe(n,this.mirror)||!sn(n,this.mirror)||(this.addedSet.has(n)?(It(this.addedSet,n),this.droppedSet.add(n)):this.addedSet.has(t.target)&&r===-1||vt(t.target,this.mirror)||(this.movedSet.has(n)&&this.movedMap[hn(r,o)]?It(this.movedSet,n):this.removes.push({parentId:o,id:r,isShadow:_e(t.target)&&Fe(t.target)?!0:void 0})),this.mapRemoves.push(n))});break}}},this.genAdds=(t,n)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(qe(t,this.mirror))return;this.movedSet.add(t);let r=null;n&&this.mirror.hasNode(n)&&(r=this.mirror.getId(n)),r&&r!==-1&&(this.movedMap[hn(this.mirror.getId(t),r)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);q(t,this.blockClass,this.blockSelector,!1)||(t.childNodes.forEach(r=>this.genAdds(r)),me(t)&&t.shadowRoot.childNodes.forEach(r=>{this.processedNodeManager.add(r,this),this.genAdds(r,t)}))}}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(n=>{this[n]=t[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 It(e,t){e.delete(t),t.childNodes.forEach(n=>It(e,n))}function pn(e,t,n){return e.length===0?!1:mn(e,t,n)}function mn(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return e.some(a=>a.id===o)?!0:mn(e,r,n)}function fn(e,t){return e.size===0?!1:yn(e,t)}function yn(e,t){const{parentNode:n}=t;return n?e.has(n)?!0:yn(e,n):!1}let Be;function no(e){Be=e}function ro(){Be=void 0}const R=e=>Be?(...t)=>{try{return e(...t)}catch(n){if(Be&&Be(n)===!0)return;throw n}}:e;var oo=Object.defineProperty,so=Object.defineProperties,io=Object.getOwnPropertyDescriptors,gn=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,lo=Object.prototype.propertyIsEnumerable,vn=(e,t,n)=>t in e?oo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t)=>{for(var n in t||(t={}))ao.call(t,n)&&vn(e,n,t[n]);if(gn)for(var n of gn(t))lo.call(t,n)&&vn(e,n,t[n]);return e},co=(e,t)=>so(e,io(t));const ve=[];function je(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0]}catch{}return e&&e.target}function bn(e,t){var n,r;const o=new to;ve.push(o),o.init(e);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(R(o.processMutations.bind(o)));return i.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),i}function uo({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(t.mousemove===!1)return()=>{};const o=typeof t.mousemove=="number"?t.mousemove:50,a=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let s=[],i;const l=Ne(R(d=>{const h=Date.now()-i;e(s.map(m=>(m.timeOffset-=h,m)),d),s=[],i=null}),a),c=R(Ne(R(d=>{const h=je(d),{clientX:m,clientY:y}=Qe(d)?d.changedTouches[0]:d;i||(i=We()),s.push({x:m,y,id:r.getId(h),timeOffset:We()-i}),l(typeof DragEvent<"u"&&d instanceof DragEvent?E.Drag:d instanceof MouseEvent?E.MouseMove:E.TouchMove)}),o,{trailing:!1})),u=[X("mousemove",c,n),X("touchmove",c,n),X("drag",c,n)];return R(()=>{u.forEach(d=>d())})}function ho({mouseInteractionCb:e,doc:t,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=[];let l=null;const c=u=>d=>{const h=je(d);if(q(h,r,o,!0))return;let m=null,y=u;if("pointerType"in d){switch(d.pointerType){case"mouse":m=ce.Mouse;break;case"touch":m=ce.Touch;break;case"pen":m=ce.Pen;break}m===ce.Touch?O[u]===O.MouseDown?y="TouchStart":O[u]===O.MouseUp&&(y="TouchEnd"):ce.Pen}else Qe(d)&&(m=ce.Touch);m!==null?(l=m,(y.startsWith("Touch")&&m===ce.Touch||y.startsWith("Mouse")&&m===ce.Mouse)&&(m=null)):O[u]===O.Click&&(m=l,l=null);const p=Qe(d)?d.changedTouches[0]:d;if(!p)return;const v=n.getId(h),{clientX:f,clientY:S}=p;R(e)(Sn({type:O[y],id:v,x:f,y:S},m!==null&&{pointerType:m}))};return Object.keys(O).filter(u=>Number.isNaN(Number(u))&&!u.endsWith("_Departed")&&s[u]!==!1).forEach(u=>{let d=pe(u);const h=c(u);if(window.PointerEvent)switch(O[u]){case O.MouseDown:case O.MouseUp:d=d.replace("mouse","pointer");break;case O.TouchStart:case O.TouchEnd:return}i.push(X(d,h,t))}),R(()=>{i.forEach(u=>u())})}function wn({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:a}){const s=R(Ne(R(i=>{const l=je(i);if(!l||q(l,r,o,!0))return;const c=n.getId(l);if(l===t&&t.defaultView){const u=mt(t.defaultView);e({id:c,x:u.left,y:u.top})}else e({id:c,x:l.scrollLeft,y:l.scrollTop})}),a.scroll||100));return X("scroll",s,t)}function po({viewportResizeCb:e},{win:t}){let n=-1,r=-1;const o=R(Ne(R(()=>{const a=ft(),s=yt();(n!==a||r!==s)&&(e({width:Number(s),height:Number(a)}),n=a,r=s)}),200));return X("resize",o,t)}const mo=["INPUT","TEXTAREA","SELECT"],En=new WeakMap;function fo({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:a,ignoreSelector:s,maskInputOptions:i,maskInputFn:l,sampling:c,userTriggeredOnInput:u}){function d(f){let S=je(f);const g=f.isTrusted,w=S&&S.tagName;if(S&&w==="OPTION"&&(S=S.parentElement),!S||!w||mo.indexOf(w)<0||q(S,r,o,!0)||S.classList.contains(a)||s&&S.matches(s))return;let N=S.value,A=!1;const j=dt(S)||"";j==="radio"||j==="checkbox"?A=S.checked:(i[w.toLowerCase()]||i[j])&&(N=ut({element:S,maskInputOptions:i,tagName:w,type:j,value:N,maskInputFn:l})),h(S,u?{text:N,isChecked:A,userTriggered:g}:{text:N,isChecked:A});const V=S.name;j==="radio"&&V&&A&&t.querySelectorAll(`input[type="radio"][name="${V}"]`).forEach(Q=>{if(Q!==S){const J=Q.value;h(Q,u?{text:J,isChecked:!A,userTriggered:!1}:{text:J,isChecked:!A})}})}function h(f,S){const g=En.get(f);if(!g||g.text!==S.text||g.isChecked!==S.isChecked){En.set(f,S);const w=n.getId(f);R(e)(co(Sn({},S),{id:w}))}}const m=(c.input==="last"?["change"]:["input","change"]).map(f=>X(f,R(d),t)),y=t.defaultView;if(!y)return()=>{m.forEach(f=>f())};const p=y.Object.getOwnPropertyDescriptor(y.HTMLInputElement.prototype,"value"),v=[[y.HTMLInputElement.prototype,"value"],[y.HTMLInputElement.prototype,"checked"],[y.HTMLSelectElement.prototype,"value"],[y.HTMLTextAreaElement.prototype,"value"],[y.HTMLSelectElement.prototype,"selectedIndex"],[y.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&m.push(...v.map(f=>Ue(f[0],f[1],{set(){R(d)({target:this,isTrusted:!1}