rrweb
Version:
record and replay the web
4 lines • 166 kB
JavaScript
var rrweb=function(ee){"use strict";var O;(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"})(O||(O={}));function wr(e){return e.nodeType===e.ELEMENT_NODE}function Xe(e){const t=e?.host;return Boolean(t?.shadowRoot===e)}function qe(e){return Object.prototype.toString.call(e)==="[object ShadowRoot]"}function co(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 uo(e){const{cssText:t}=e;if(t.split('"').length<3)return t;const r=["@import",`url(${JSON.stringify(e.href)})`];return e.layerName===""?r.push("layer"):e.layerName&&r.push(`layer(${e.layerName})`),e.supportsText&&r.push(`supports(${e.supportsText})`),e.media.length&&r.push(e.media.mediaText),r.join(" ")+";"}function ct(e){try{const t=e.rules||e.cssRules;return t?co(Array.from(t,Er).join("")):null}catch{return null}}function Er(e){let t;if(po(e))try{t=ct(e.styleSheet)||uo(e)}catch{}else if(mo(e)&&e.selectorText.includes(":"))return ho(e.cssText);return t||e.cssText}function ho(e){const t=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return e.replace(t,"$1\\$2")}function po(e){return"styleSheet"in e}function mo(e){return"selectorText"in e}class Ot{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(t){var r;if(!t)return-1;const n=(r=this.getMeta(t))===null||r===void 0?void 0:r.id;return n??-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 r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(n=>this.removeNodeFromMap(n))}has(t){return this.idNodeMap.has(t)}hasNode(t){return this.nodeMetaMap.has(t)}add(t,r){const n=r.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,r)}replace(t,r){const n=this.getNode(t);if(n){const o=this.nodeMetaMap.get(n);o&&this.nodeMetaMap.set(r,o)}this.idNodeMap.set(t,r)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Cr(){return new Ot}function xt({element:e,maskInputOptions:t,tagName:r,type:n,value:o,maskInputFn:i}){let a=o||"";const l=n&&Ce(n);return(t[r.toLowerCase()]||l&&t[l])&&(i?a=i(a,e):a="*".repeat(a.length)),a}function Ce(e){return e.toLowerCase()}const Mr="__rrweb_original__";function fo(e){const t=e.getContext("2d");if(!t)return!0;const r=50;for(let n=0;n<e.width;n+=r)for(let o=0;o<e.height;o+=r){const i=t.getImageData,a=Mr in i?i[Mr]:i;if(new Uint32Array(a.call(t,n,o,Math.min(r,e.width-n),Math.min(r,e.height-o)).data.buffer).some(l=>l!==0))return!1}return!0}function go(e,t){return!e||!t||e.type!==t.type?!1:e.type===O.Document?e.compatMode===t.compatMode:e.type===O.DocumentType?e.name===t.name&&e.publicId===t.publicId&&e.systemId===t.systemId:e.type===O.Comment||e.type===O.Text||e.type===O.CDATA?e.textContent===t.textContent:e.type===O.Element?e.tagName===t.tagName&&JSON.stringify(e.attributes)===JSON.stringify(t.attributes)&&e.isSVG===t.isSVG&&e.needBlock===t.needBlock:!1}function Rt(e){const t=e.type;return e.hasAttribute("data-rr-is-password")?"password":t?Ce(t):null}function Nr(e,t){var r;let n;try{n=new URL(e,t??window.location.href)}catch{return null}const o=/\.([0-9a-z]+)(?:$)/i,i=n.pathname.match(o);return(r=i?.[1])!==null&&r!==void 0?r:null}let yo=1;const vo=new RegExp("[^a-z0-9-_:]"),Je=-2;function Tr(){return yo++}function So(e){if(e instanceof HTMLFormElement)return"form";const t=Ce(e.tagName);return vo.test(t)?"div":t}function bo(e){let t="";return e.indexOf("//")>-1?t=e.split("/").slice(0,3).join("/"):t=e.split("/")[0],t=t.split("?")[0],t}let Ae,Ir;const wo=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,Eo=/^(?:[a-z+]+:)?\/\//i,Co=/^www\..*/i,Mo=/^(data:)([^,]*),(.*)/i;function ut(e,t){return(e||"").replace(wo,(r,n,o,i,a,l)=>{const s=o||a||l,c=n||i||"";if(!s)return r;if(Eo.test(s)||Co.test(s))return`url(${c}${s}${c})`;if(Mo.test(s))return`url(${c}${s}${c})`;if(s[0]==="/")return`url(${c}${bo(t)+s}${c})`;const u=t.split("/"),d=s.split("/");u.pop();for(const h of d)h!=="."&&(h===".."?u.pop():u.push(h));return`url(${c}${u.join("/")}${c})`})}const No=/^[^ \t\n\r\u000c]+/,To=/^[, \t\n\r\u000c]+/;function Io(e,t){if(t.trim()==="")return t;let r=0;function n(i){let a;const l=i.exec(t.substring(r));return l?(a=l[0],r+=a.length,a):""}const o=[];for(;n(To),!(r>=t.length);){let i=n(No);if(i.slice(-1)===",")i=dt(e,i.substring(0,i.length-1)),o.push(i);else{let a="";i=dt(e,i);let l=!1;for(;;){const s=t.charAt(r);if(s===""){o.push((i+a).trim());break}else if(l)s===")"&&(l=!1);else if(s===","){r+=1,o.push((i+a).trim());break}else s==="("&&(l=!0);a+=s,r+=1}}}return o.join(", ")}function dt(e,t){if(!t||t.trim()==="")return t;const r=e.createElement("a");return r.href=t,r.href}function Do(e){return Boolean(e.tagName==="svg"||e.ownerSVGElement)}function At(){const e=document.createElement("a");return e.href="",e.href}function Dr(e,t,r,n){return n&&(r==="src"||r==="href"&&!(t==="use"&&n[0]==="#")||r==="xlink:href"&&n[0]!=="#"||r==="background"&&(t==="table"||t==="td"||t==="th")?dt(e,n):r==="srcset"?Io(e,n):r==="style"?ut(n,At()):t==="object"&&r==="data"?dt(e,n):n)}function kr(e,t,r){return(e==="video"||e==="audio")&&t==="autoplay"}function ko(e,t,r){try{if(typeof t=="string"){if(e.classList.contains(t))return!0}else for(let n=e.classList.length;n--;){const o=e.classList[n];if(t.test(o))return!0}if(r)return e.matches(r)}catch{}return!1}function ht(e,t,r){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return r?ht(e.parentNode,t,r):!1;for(let n=e.classList.length;n--;){const o=e.classList[n];if(t.test(o))return!0}return r?ht(e.parentNode,t,r):!1}function Or(e,t,r,n){try{const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(o===null)return!1;if(typeof t=="string"){if(n){if(o.closest(`.${t}`))return!0}else if(o.classList.contains(t))return!0}else if(ht(o,t,n))return!0;if(r){if(n){if(o.closest(r))return!0}else if(o.matches(r))return!0}}catch{}return!1}function Oo(e,t,r){const n=e.contentWindow;if(!n)return;let o=!1,i;try{i=n.document.readyState}catch{return}if(i!=="complete"){const l=setTimeout(()=>{o||(t(),o=!0)},r);e.addEventListener("load",()=>{clearTimeout(l),o=!0,t()});return}const a="about:blank";if(n.location.href!==a||e.src===a||e.src==="")return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}function xo(e,t,r){let n=!1,o;try{o=e.sheet}catch{return}if(o)return;const i=setTimeout(()=>{n||(t(),n=!0)},r);e.addEventListener("load",()=>{clearTimeout(i),n=!0,t()})}function Ro(e,t){const{doc:r,mirror:n,blockClass:o,blockSelector:i,needsMask:a,inlineStylesheet:l,maskInputOptions:s={},maskTextFn:c,maskInputFn:u,dataURLOptions:d={},inlineImages:h,recordCanvas:m,keepIframeSrcFn:g,newlyAddedElement:p=!1}=t,y=Ao(r,n);switch(e.nodeType){case e.DOCUMENT_NODE:return e.compatMode!=="CSS1Compat"?{type:O.Document,childNodes:[],compatMode:e.compatMode}:{type:O.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:O.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:y};case e.ELEMENT_NODE:return _o(e,{doc:r,blockClass:o,blockSelector:i,inlineStylesheet:l,maskInputOptions:s,maskInputFn:u,dataURLOptions:d,inlineImages:h,recordCanvas:m,keepIframeSrcFn:g,newlyAddedElement:p,rootId:y});case e.TEXT_NODE:return Lo(e,{needsMask:a,maskTextFn:c,rootId:y});case e.CDATA_SECTION_NODE:return{type:O.CDATA,textContent:"",rootId:y};case e.COMMENT_NODE:return{type:O.Comment,textContent:e.textContent||"",rootId:y};default:return!1}}function Ao(e,t){if(!t.hasNode(e))return;const r=t.getId(e);return r===1?void 0:r}function Lo(e,t){var r;const{needsMask:n,maskTextFn:o,rootId:i}=t,a=e.parentNode&&e.parentNode.tagName;let l=e.textContent;const s=a==="STYLE"?!0:void 0,c=a==="SCRIPT"?!0:void 0;if(s&&l){try{e.nextSibling||e.previousSibling||!((r=e.parentNode.sheet)===null||r===void 0)&&r.cssRules&&(l=ct(e.parentNode.sheet))}catch(u){console.warn(`Cannot get CSS styles from text's parentNode. Error: ${u}`,e)}l=ut(l,At())}return c&&(l="SCRIPT_PLACEHOLDER"),!s&&!c&&l&&n&&(l=o?o(l,e.parentElement):l.replace(/[\S]/g,"*")),{type:O.Text,textContent:l||"",isStyle:s,rootId:i}}function _o(e,t){const{doc:r,blockClass:n,blockSelector:o,inlineStylesheet:i,maskInputOptions:a={},maskInputFn:l,dataURLOptions:s={},inlineImages:c,recordCanvas:u,keepIframeSrcFn:d,newlyAddedElement:h=!1,rootId:m}=t,g=ko(e,n,o),p=So(e);let y={};const f=e.attributes.length;for(let v=0;v<f;v++){const w=e.attributes[v];kr(p,w.name,w.value)||(y[w.name]=Dr(r,p,Ce(w.name),w.value))}if(p==="link"&&i){const v=Array.from(r.styleSheets).find(N=>N.href===e.href);let w=null;v&&(w=ct(v)),w&&(delete y.rel,delete y.href,y._cssText=ut(w,v.href))}if(p==="style"&&e.sheet&&!(e.innerText||e.textContent||"").trim().length){const v=ct(e.sheet);v&&(y._cssText=ut(v,At()))}if(p==="input"||p==="textarea"||p==="select"){const v=e.value,w=e.checked;y.type!=="radio"&&y.type!=="checkbox"&&y.type!=="submit"&&y.type!=="button"&&v?y.value=xt({element:e,type:Rt(e),tagName:p,value:v,maskInputOptions:a,maskInputFn:l}):w&&(y.checked=w)}if(p==="option"&&(e.selected&&!a.select?y.selected=!0:delete y.selected),p==="canvas"&&u){if(e.__context==="2d")fo(e)||(y.rr_dataURL=e.toDataURL(s.type,s.quality));else if(!("__context"in e)){const v=e.toDataURL(s.type,s.quality),w=document.createElement("canvas");w.width=e.width,w.height=e.height;const N=w.toDataURL(s.type,s.quality);v!==N&&(y.rr_dataURL=v)}}if(p==="img"&&c){Ae||(Ae=r.createElement("canvas"),Ir=Ae.getContext("2d"));const v=e,w=v.crossOrigin;v.crossOrigin="anonymous";const N=()=>{v.removeEventListener("load",N);try{Ae.width=v.naturalWidth,Ae.height=v.naturalHeight,Ir.drawImage(v,0,0),y.rr_dataURL=Ae.toDataURL(s.type,s.quality)}catch(D){console.warn(`Cannot inline img src=${v.currentSrc}! Error: ${D}`)}w?y.crossOrigin=w:v.removeAttribute("crossorigin")};v.complete&&v.naturalWidth!==0?N():v.addEventListener("load",N)}if((p==="audio"||p==="video")&&(y.rr_mediaState=e.paused?"paused":"played",y.rr_mediaCurrentTime=e.currentTime),h||(e.scrollLeft&&(y.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(y.rr_scrollTop=e.scrollTop)),g){const{width:v,height:w}=e.getBoundingClientRect();y={class:y.class,rr_width:`${v}px`,rr_height:`${w}px`}}p==="iframe"&&!d(y.src)&&(e.contentDocument||(y.rr_src=y.src),delete y.src);let S;try{customElements.get(p)&&(S=!0)}catch{}return{type:O.Element,tagName:p,attributes:y,childNodes:[],isSVG:Do(e)||void 0,needBlock:g,rootId:m,isCustom:S}}function z(e){return e==null?"":e.toLowerCase()}function Fo(e,t){return!!(t.comment&&e.type===O.Comment||e.type===O.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"&&Nr(e.attributes.href)==="js")||t.headFavicon&&(e.tagName==="link"&&e.attributes.rel==="shortcut icon"||e.tagName==="meta"&&(z(e.attributes.name).match(/^msapplication-tile(image|color)$/)||z(e.attributes.name)==="application-name"||z(e.attributes.rel)==="icon"||z(e.attributes.rel)==="apple-touch-icon"||z(e.attributes.rel)==="shortcut icon"))||e.tagName==="meta"&&(t.headMetaDescKeywords&&z(e.attributes.name).match(/^description|keywords$/)||t.headMetaSocial&&(z(e.attributes.property).match(/^(og|twitter|fb):/)||z(e.attributes.name).match(/^(og|twitter):/)||z(e.attributes.name)==="pinterest")||t.headMetaRobots&&(z(e.attributes.name)==="robots"||z(e.attributes.name)==="googlebot"||z(e.attributes.name)==="bingbot")||t.headMetaHttpEquiv&&e.attributes["http-equiv"]!==void 0||t.headMetaAuthorship&&(z(e.attributes.name)==="author"||z(e.attributes.name)==="generator"||z(e.attributes.name)==="framework"||z(e.attributes.name)==="publisher"||z(e.attributes.name)==="progid"||z(e.attributes.property).match(/^article:/)||z(e.attributes.property).match(/^product:/))||t.headMetaVerification&&(z(e.attributes.name)==="google-site-verification"||z(e.attributes.name)==="yandex-verification"||z(e.attributes.name)==="csrf-token"||z(e.attributes.name)==="p:domain_verify"||z(e.attributes.name)==="verify-v1"||z(e.attributes.name)==="verification"||z(e.attributes.name)==="shopify-checkout-api-token"))))}function Le(e,t){const{doc:r,mirror:n,blockClass:o,blockSelector:i,maskTextClass:a,maskTextSelector:l,skipChild:s=!1,inlineStylesheet:c=!0,maskInputOptions:u={},maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:g={},inlineImages:p=!1,recordCanvas:y=!1,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:v=5e3,onStylesheetLoad:w,stylesheetLoadTimeout:N=5e3,keepIframeSrcFn:D=()=>!1,newlyAddedElement:A=!1}=t;let{needsMask:M}=t,{preserveWhiteSpace:B=!0}=t;!M&&e.childNodes&&(M=Or(e,a,l,M===void 0));const j=Ro(e,{doc:r,mirror:n,blockClass:o,blockSelector:i,needsMask:M,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,dataURLOptions:g,inlineImages:p,recordCanvas:y,keepIframeSrcFn:D,newlyAddedElement:A});if(!j)return console.warn(e,"not serialized"),null;let re;n.hasNode(e)?re=n.getId(e):Fo(j,m)||!B&&j.type===O.Text&&!j.isStyle&&!j.textContent.replace(/^\s+|\s+$/gm,"").length?re=Je:re=Tr();const I=Object.assign(j,{id:re});if(n.add(e,I),re===Je)return null;f&&f(e);let H=!s;if(I.type===O.Element){H=H&&!I.needBlock,delete I.needBlock;const F=e.shadowRoot;F&&qe(F)&&(I.isShadowHost=!0)}if((I.type===O.Document||I.type===O.Element)&&H){m.headWhitespace&&I.type===O.Element&&I.tagName==="head"&&(B=!1);const F={doc:r,mirror:n,blockClass:o,blockSelector:i,needsMask:M,maskTextClass:a,maskTextSelector:l,skipChild:s,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:g,inlineImages:p,recordCanvas:y,preserveWhiteSpace:B,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:N,keepIframeSrcFn:D};if(!(I.type===O.Element&&I.tagName==="textarea"&&I.attributes.value!==void 0))for(const V of Array.from(e.childNodes)){const L=Le(V,F);L&&I.childNodes.push(L)}if(wr(e)&&e.shadowRoot)for(const V of Array.from(e.shadowRoot.childNodes)){const L=Le(V,F);L&&(qe(e.shadowRoot)&&(L.isShadow=!0),I.childNodes.push(L))}}return e.parentNode&&Xe(e.parentNode)&&qe(e.parentNode)&&(I.isShadow=!0),I.type===O.Element&&I.tagName==="iframe"&&Oo(e,()=>{const F=e.contentDocument;if(F&&S){const V=Le(F,{doc:F,mirror:n,blockClass:o,blockSelector:i,needsMask:M,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:g,inlineImages:p,recordCanvas:y,preserveWhiteSpace:B,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:N,keepIframeSrcFn:D});V&&S(e,V)}},v),I.type===O.Element&&I.tagName==="link"&&typeof I.attributes.rel=="string"&&(I.attributes.rel==="stylesheet"||I.attributes.rel==="preload"&&typeof I.attributes.href=="string"&&Nr(I.attributes.href)==="css")&&xo(e,()=>{if(w){const F=Le(e,{doc:r,mirror:n,blockClass:o,blockSelector:i,needsMask:M,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:c,maskInputOptions:u,maskTextFn:d,maskInputFn:h,slimDOMOptions:m,dataURLOptions:g,inlineImages:p,recordCanvas:y,preserveWhiteSpace:B,onSerialize:f,onIframeLoad:S,iframeLoadTimeout:v,onStylesheetLoad:w,stylesheetLoadTimeout:N,keepIframeSrcFn:D});F&&w(e,F)}},N),I}function $o(e,t){const{mirror:r=new Ot,blockClass:n="rr-block",blockSelector:o=null,maskTextClass:i="rr-mask",maskTextSelector:a=null,inlineStylesheet:l=!0,inlineImages:s=!1,recordCanvas:c=!1,maskAllInputs:u=!1,maskTextFn:d,maskInputFn:h,slimDOM:m=!1,dataURLOptions:g,preserveWhiteSpace:p,onSerialize:y,onIframeLoad:f,iframeLoadTimeout:S,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:N=()=>!1}=t||{};return Le(e,{doc:e,mirror:r,blockClass:n,blockSelector:o,maskTextClass:i,maskTextSelector:a,skipChild:!1,inlineStylesheet:l,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:g,inlineImages:s,recordCanvas:c,preserveWhiteSpace:p,onSerialize:y,onIframeLoad:f,iframeLoadTimeout:S,onStylesheetLoad:v,stylesheetLoadTimeout:w,keepIframeSrcFn:N,newlyAddedElement:!1})}const xr=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function Po(e,t={}){let r=1,n=1;function o(E){const b=E.match(/\n/g);b&&(r+=b.length);const k=E.lastIndexOf(`
`);n=k===-1?n+E.length:E.length-k}function i(){const E={line:r,column:n};return b=>(b.position=new a(E),g(),b)}class a{constructor(b){this.start=b,this.end={line:r,column:n},this.source=t.source}}a.prototype.content=e;const l=[];function s(E){const b=new Error(`${t.source||""}:${r}:${n}: ${E}`);if(b.reason=E,b.filename=t.source,b.line=r,b.column=n,b.source=e,t.silent)l.push(b);else throw b}function c(){const E=h();return{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:l}}}function u(){return m(/^{\s*/)}function d(){return m(/^}/)}function h(){let E;const b=[];for(g(),p(b);e.length&&e.charAt(0)!=="}"&&(E=x()||q());)E&&(b.push(E),p(b));return b}function m(E){const b=E.exec(e);if(!b)return;const k=b[0];return o(k),e=e.slice(k.length),b}function g(){m(/^\s*/)}function p(E=[]){let b;for(;b=y();)b&&E.push(b),b=y();return E}function y(){const E=i();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 s("End of comment missing");const k=e.slice(2,b-2);return n+=2,o(k),e=e.slice(b),n+=2,E({type:"comment",comment:k})}function f(){const E=m(/^([^{]+)/);if(E)return ve(E[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 E=i(),b=m(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(!b)return;const k=ve(b[0]);if(!m(/^:\s*/))return s("property missing ':'");const W=m(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),Y=E({type:"declaration",property:k.replace(xr,""),value:W?ve(W[0]).replace(xr,""):""});return m(/^[;\s]*/),Y}function v(){const E=[];if(!u())return s("missing '{'");p(E);let b;for(;b=S();)b!==!1&&(E.push(b),p(E)),b=S();return d()?E:s("missing '}'")}function w(){let E;const b=[],k=i();for(;E=m(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)b.push(E[1]),m(/^,\s*/);if(b.length)return k({type:"keyframe",values:b,declarations:v()})}function N(){const E=i();let b=m(/^@([-\w]+)?keyframes\s*/);if(!b)return;const k=b[1];if(b=m(/^([-\w]+)\s*/),!b)return s("@keyframes missing name");const W=b[1];if(!u())return s("@keyframes missing '{'");let Y,K=p();for(;Y=w();)K.push(Y),K=K.concat(p());return d()?E({type:"keyframes",name:W,vendor:k,keyframes:K}):s("@keyframes missing '}'")}function D(){const E=i(),b=m(/^@supports *([^{]+)/);if(!b)return;const k=ve(b[1]);if(!u())return s("@supports missing '{'");const W=p().concat(h());return d()?E({type:"supports",supports:k,rules:W}):s("@supports missing '}'")}function A(){const E=i();if(!m(/^@host\s*/))return;if(!u())return s("@host missing '{'");const b=p().concat(h());return d()?E({type:"host",rules:b}):s("@host missing '}'")}function M(){const E=i(),b=m(/^@media *([^{]+)/);if(!b)return;const k=ve(b[1]);if(!u())return s("@media missing '{'");const W=p().concat(h());return d()?E({type:"media",media:k,rules:W}):s("@media missing '}'")}function B(){const E=i(),b=m(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(b)return E({type:"custom-media",name:ve(b[1]),media:ve(b[2])})}function j(){const E=i();if(!m(/^@page */))return;const b=f()||[];if(!u())return s("@page missing '{'");let k=p(),W;for(;W=S();)k.push(W),k=k.concat(p());return d()?E({type:"page",selectors:b,declarations:k}):s("@page missing '}'")}function re(){const E=i(),b=m(/^@([-\w]+)?document *([^{]+)/);if(!b)return;const k=ve(b[1]),W=ve(b[2]);if(!u())return s("@document missing '{'");const Y=p().concat(h());return d()?E({type:"document",document:W,vendor:k,rules:Y}):s("@document missing '}'")}function I(){const E=i();if(!m(/^@font-face\s*/))return;if(!u())return s("@font-face missing '{'");let b=p(),k;for(;k=S();)b.push(k),b=b.concat(p());return d()?E({type:"font-face",declarations:b}):s("@font-face missing '}'")}const H=L("import"),F=L("charset"),V=L("namespace");function L(E){const b=new RegExp("^@"+E+"\\s*([^;]+);");return()=>{const k=i(),W=m(b);if(!W)return;const Y={type:E};return Y[E]=W[1].trim(),k(Y)}}function x(){if(e[0]==="@")return N()||M()||B()||D()||H()||F()||V()||re()||j()||A()||I()}function q(){const E=i(),b=f();return b?(p(),E({type:"rule",selectors:b,declarations:v()})):s("selector missing")}return Lt(c())}function ve(e){return e?e.replace(/^\s+|\s+$/g,""):""}function Lt(e,t){const r=e&&typeof e.type=="string",n=r?e:t;for(const o of Object.keys(e)){const i=e[o];Array.isArray(i)?i.forEach(a=>{Lt(a,n)}):i&&typeof i=="object"&&Lt(i,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}const Rr={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 Uo(e){let t=Rr[e.tagName]?Rr[e.tagName]:e.tagName;return t==="link"&&e.attributes._cssText&&(t="style"),t}function Ar(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const Lr=/(max|min)-device-(width|height)/,Wo=new RegExp(Lr.source,"g"),_r=/([^\\]):hover/,jo=new RegExp(_r.source,"g");function Fr(e,t){const r=t?.stylesWithHoverClass.get(e);if(r)return r;const n=Po(e,{silent:!0});if(!n.stylesheet)return e;const o=[],i=[];function a(s){"selectors"in s&&s.selectors&&s.selectors.forEach(c=>{_r.test(c)&&o.push(c)}),"media"in s&&s.media&&Lr.test(s.media)&&i.push(s.media),"rules"in s&&s.rules&&s.rules.forEach(a)}a(n.stylesheet);let l=e;if(o.length>0){const s=new RegExp(o.filter((c,u)=>o.indexOf(c)===u).sort((c,u)=>u.length-c.length).map(c=>Ar(c)).join("|"),"g");l=l.replace(s,c=>{const u=c.replace(jo,"$1.\\:hover");return`${c}, ${u}`})}if(i.length>0){const s=new RegExp(i.filter((c,u)=>i.indexOf(c)===u).sort((c,u)=>u.length-c.length).map(c=>Ar(c)).join("|"),"g");l=l.replace(s,c=>c.replace(Wo,"$1-$2"))}return t?.stylesWithHoverClass.set(e,l),l}function $r(){return{stylesWithHoverClass:new Map}}function Bo(e,t){var r;const{doc:n,hackCss:o,cache:i}=t;switch(e.type){case O.Document:return n.implementation.createDocument(null,"",null);case O.DocumentType:return n.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case O.Element:{const a=Uo(e);let l;e.isSVG?l=n.createElementNS("http://www.w3.org/2000/svg",a):(e.isCustom&&((r=n.defaultView)===null||r===void 0?void 0:r.customElements)&&!n.defaultView.customElements.get(e.tagName)&&n.defaultView.customElements.define(e.tagName,class extends n.defaultView.HTMLElement{}),l=n.createElement(a));const s={};for(const c in e.attributes){if(!Object.prototype.hasOwnProperty.call(e.attributes,c))continue;let u=e.attributes[c];if(a==="option"&&c==="selected"&&u===!1||u===null)continue;if(u===!0&&(u=""),c.startsWith("rr_")){s[c]=u;continue}const d=a==="textarea"&&c==="value",h=a==="style"&&c==="_cssText";if(h&&o&&typeof u=="string"&&(u=Fr(u,i)),(d||h)&&typeof u=="string"){l.appendChild(n.createTextNode(u)),e.childNodes=[];continue}try{if(e.isSVG&&c==="xlink:href")l.setAttributeNS("http://www.w3.org/1999/xlink",c,u.toString());else if(c==="onload"||c==="onclick"||c.substring(0,7)==="onmouse")l.setAttribute("_"+c,u.toString());else if(a==="meta"&&e.attributes["http-equiv"]==="Content-Security-Policy"&&c==="content"){l.setAttribute("csp-content",u.toString());continue}else a==="link"&&(e.attributes.rel==="preload"||e.attributes.rel==="modulepreload")&&e.attributes.as==="script"||a==="link"&&e.attributes.rel==="prefetch"&&typeof e.attributes.href=="string"&&e.attributes.href.endsWith(".js")||(a==="img"&&e.attributes.srcset&&e.attributes.rr_dataURL?l.setAttribute("rrweb-original-srcset",e.attributes.srcset):l.setAttribute(c,u.toString()))}catch{}}for(const c in s){const u=s[c];if(a==="canvas"&&c==="rr_dataURL"){const d=document.createElement("img");d.onload=()=>{const h=l.getContext("2d");h&&h.drawImage(d,0,0,d.width,d.height)},d.src=u.toString(),l.RRNodeType&&(l.rr_dataURL=u.toString())}else if(a==="img"&&c==="rr_dataURL"){const d=l;d.currentSrc.startsWith("data:")||(d.setAttribute("rrweb-original-src",e.attributes.src),d.src=u.toString())}if(c==="rr_width")l.style.width=u.toString();else if(c==="rr_height")l.style.height=u.toString();else if(c==="rr_mediaCurrentTime"&&typeof u=="number")l.currentTime=u;else if(c==="rr_mediaState")switch(u){case"played":l.play().catch(d=>console.warn("media playback error",d));break;case"paused":l.pause();break}}if(e.isShadowHost)if(!l.shadowRoot)l.attachShadow({mode:"open"});else for(;l.shadowRoot.firstChild;)l.shadowRoot.removeChild(l.shadowRoot.firstChild);return l}case O.Text:return n.createTextNode(e.isStyle&&o?Fr(e.textContent,i):e.textContent);case O.CDATA:return n.createCDATASection(e.textContent);case O.Comment:return n.createComment(e.textContent);default:return null}}function Qe(e,t){const{doc:r,mirror:n,skipChild:o=!1,hackCss:i=!0,afterAppend:a,cache:l}=t;if(n.has(e.id)){const c=n.getNode(e.id),u=n.getMeta(c);if(go(u,e))return n.getNode(e.id)}let s=Bo(e,{doc:r,hackCss:i,cache:l});if(!s)return null;if(e.rootId&&n.getNode(e.rootId)!==r&&n.replace(e.rootId,r),e.type===O.Document&&(r.close(),r.open(),e.compatMode==="BackCompat"&&e.childNodes&&e.childNodes[0].type!==O.DocumentType&&(e.childNodes[0].type===O.Element&&"xmlns"in e.childNodes[0].attributes&&e.childNodes[0].attributes.xmlns==="http://www.w3.org/1999/xhtml"?r.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'):r.write('<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">')),s=r),n.add(s,e),(e.type===O.Document||e.type===O.Element)&&!o)for(const c of e.childNodes){const u=Qe(c,{doc:r,mirror:n,skipChild:!1,hackCss:i,afterAppend:a,cache:l});if(!u){console.warn("Failed to rebuild",c);continue}if(c.isShadow&&wr(s)&&s.shadowRoot)s.shadowRoot.appendChild(u);else if(e.type===O.Document&&c.type==O.Element){const d=u;let h=null;d.childNodes.forEach(m=>{m.nodeName==="BODY"&&(h=m)}),h?(d.removeChild(h),s.appendChild(u),d.appendChild(h)):s.appendChild(u)}else s.appendChild(u);a&&a(u,c.id)}return s}function Vo(e,t){function r(n){t(n)}for(const n of e.getIds())e.has(n)&&r(e.getNode(n))}function zo(e,t){const r=t.getMeta(e);if(r?.type!==O.Element)return;const n=e;for(const o in r.attributes){if(!(Object.prototype.hasOwnProperty.call(r.attributes,o)&&o.startsWith("rr_")))continue;const i=r.attributes[o];o==="rr_scrollLeft"&&(n.scrollLeft=i),o==="rr_scrollTop"&&(n.scrollTop=i)}}function Ho(e,t){const{doc:r,onVisit:n,hackCss:o=!0,afterAppend:i,cache:a,mirror:l=new Ot}=t,s=Qe(e,{doc:r,mirror:l,skipChild:!1,hackCss:o,afterAppend:i,cache:a});return Vo(l,c=>{n&&n(c),zo(c,l)}),s}function ie(e,t,r=document){const n={capture:!0,passive:!0};return r.addEventListener(e,t,n),()=>r.removeEventListener(e,t,n)}const _e=`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(_e),-1},getNode(){return console.error(_e),null},removeNodeFromMap(){console.error(_e)},has(){return console.error(_e),!1},reset(){console.error(_e)}},typeof window<"u"&&window.Proxy&&window.Reflect&&(ee.mirror=new Proxy(ee.mirror,{get(e,t,r){return t==="map"&&console.error(_e),Reflect.get(e,t,r)}}));function Fe(e,t,r={}){let n=null,o=0;return function(...i){const a=Date.now();!o&&r.leading===!1&&(o=a);const l=t-(a-o),s=this;l<=0||l>t?(n&&(clearTimeout(n),n=null),o=a,e.apply(s,i)):!n&&r.trailing!==!1&&(n=setTimeout(()=>{o=r.leading===!1?0:Date.now(),n=null,e.apply(s,i)},l))}}function Ke(e,t,r,n,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,n?r:{set(a){setTimeout(()=>{r.set.call(this,a)},0),i&&i.set&&i.set.call(this,a)}}),()=>Ke(e,t,i||{},!0)}function Me(e,t,r){try{if(!(t in e))return()=>{};const n=e[t],o=r(n);return typeof o=="function"&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:n}})),e[t]=o,()=>{e[t]=n}}catch{return()=>{}}}let Ze=Date.now;/[1-9][0-9]{12}/.test(Date.now().toString())||(Ze=()=>new Date().getTime());function _t(e){var t,r,n,o,i,a;const l=e.document;return{left:l.scrollingElement?l.scrollingElement.scrollLeft:e.pageXOffset!==void 0?e.pageXOffset:l?.documentElement.scrollLeft||((r=(t=l?.body)==null?void 0:t.parentElement)==null?void 0:r.scrollLeft)||((n=l?.body)==null?void 0:n.scrollLeft)||0,top:l.scrollingElement?l.scrollingElement.scrollTop:e.pageYOffset!==void 0?e.pageYOffset:l?.documentElement.scrollTop||((i=(o=l?.body)==null?void 0:o.parentElement)==null?void 0:i.scrollTop)||((a=l?.body)==null?void 0:a.scrollTop)||0}}function Ft(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function $t(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Pt(e){return e?e.nodeType===e.ELEMENT_NODE?e:e.parentElement:null}function ae(e,t,r,n){if(!e)return!1;const o=Pt(e);if(!o)return!1;try{if(typeof t=="string"){if(o.classList.contains(t)||n&&o.closest("."+t)!==null)return!0}else if(ht(o,t,n))return!0}catch{}return!!(r&&(o.matches(r)||n&&o.closest(r)!==null))}function Pr(e,t){return t.getId(e)!==-1}function pt(e,t){return t.getId(e)===Je}function Ut(e,t){if(Xe(e))return!1;const r=t.getId(e);return t.has(r)?e.parentNode&&e.parentNode.nodeType===e.DOCUMENT_NODE?!1:e.parentNode?Ut(e.parentNode,t):!0:!0}function mt(e){return Boolean(e.changedTouches)}function Wt(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 r=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do if(this===r)return!0;while(r=r&&r.parentNode);return!1})}function Ur(e){const t={},r=(o,i)=>{const a={value:o,parent:i,children:[]};return t[o.node.id]=a,a},n=[];for(const o of e){const{nextId:i,parentId:a}=o;if(i&&i in t){const l=t[i];if(l.parent){const s=l.parent.children.indexOf(l);l.parent.children.splice(s,0,r(o,l.parent))}else{const s=n.indexOf(l);n.splice(s,0,r(o,null))}continue}if(a in t){const l=t[a];l.children.push(r(o,l));continue}n.push(r(o,null))}return n}function jt(e,t){t(e.value);for(let r=e.children.length-1;r>=0;r--)jt(e.children[r],t)}function $e(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function Bt(e,t){return Boolean(e.nodeName==="LINK"&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&e.getAttribute("rel")==="stylesheet"&&t.getMeta(e))}function Vt(e,t){var r,n;const o=(n=(r=e.ownerDocument)==null?void 0:r.defaultView)==null?void 0:n.frameElement;if(!o||o===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const i=o.getBoundingClientRect(),a=Vt(o,t),l=i.height/o.clientHeight;return{x:i.x*a.relativeScale+a.x,y:i.y*a.relativeScale+a.y,relativeScale:l,absoluteScale:a.absoluteScale*l}}function Ne(e){return Boolean(e?.shadowRoot)}function Pe(e,t){const r=e[t[0]];return t.length===1?r:Pe(r.cssRules[t[1]].cssRules,t.slice(2))}function zt(e){const t=[...e],r=t.pop();return{positions:t,index:r}}function Wr(e){const t=new Set,r=[];for(let n=e.length;n--;){const o=e[n];t.has(o.id)||(r.push(o),t.add(o.id))}return r}class Ht{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var r;return(r=this.styleIDMap.get(t))!=null?r:-1}has(t){return this.styleIDMap.has(t)}add(t,r){if(this.has(t))return this.getId(t);let n;return r===void 0?n=this.id++:n=r,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}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 Gt(e){var t,r;let n=null;return((r=(t=e.getRootNode)==null?void 0:t.call(e))==null?void 0:r.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(n=e.getRootNode().host),n}function jr(e){let t=e,r;for(;r=Gt(t);)t=r;return t}function Br(e){const t=e.ownerDocument;if(!t)return!1;const r=jr(e);return t.contains(r)}function Yt(e){const t=e.ownerDocument;return t?t.contains(e)||Br(e):!1}var Go=Object.freeze({__proto__:null,on:ie,get _mirror(){return ee.mirror},throttle:Fe,hookSetter:Ke,patch:Me,get nowTimestamp(){return Ze},getWindowScroll:_t,getWindowHeight:Ft,getWindowWidth:$t,closestElementOfNode:Pt,isBlocked:ae,isSerialized:Pr,isIgnored:pt,isAncestorRemoved:Ut,legacy_isTouchEvent:mt,polyfill:Wt,queueToResolveTrees:Ur,iterateResolveTree:jt,isSerializedIframe:$e,isSerializedStylesheet:Bt,getBaseDimension:Vt,hasShadowRoot:Ne,getNestedRule:Pe,getPositionsAndIndex:zt,uniqueTextMutations:Wr,StyleSheetMirror:Ht,getShadowHost:Gt,getRootShadowHost:jr,shadowHostInDom:Br,inDom:Yt}),T=(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))(T||{}),C=(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))(C||{}),P=(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))(P||{}),Se=(e=>(e[e.Mouse=0]="Mouse",e[e.Pen=1]="Pen",e[e.Touch=2]="Touch",e))(Se||{}),be=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(be||{}),we=(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))(we||{}),U=(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))(U||{});function Vr(e){return"__ln"in e}class Yo{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 r=this.head;for(let n=0;n<t;n++)r=r?.next||null;return r}addNode(t){const r={value:t,previous:null,next:null};if(t.__ln=r,t.previousSibling&&Vr(t.previousSibling)){const n=t.previousSibling.__ln.next;r.next=n,r.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=r,n&&(n.previous=r)}else if(t.nextSibling&&Vr(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;r.previous=n,r.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=r,n&&(n.next=r)}else this.head&&(this.head.previous=r),r.next=this.head,this.head=r;r.next===null&&(this.tail=r),this.length++}removeNode(t){const r=t.__ln;!this.head||(r.previous?(r.previous.next=r.next,r.next?r.next.previous=r.previous:this.tail=r.previous):(this.head=r.next,this.head?this.head.previous=null:this.tail=null),t.__ln&&delete t.__ln,this.length--)}}const zr=(e,t)=>`${e}@${t}`;class Xo{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=[],r=new Set,n=new Yo,o=s=>{let c=s,u=Je;for(;u===Je;)c=c&&c.nextSibling,u=c&&this.mirror.getId(c);return u},i=s=>{if(!s.parentNode||!Yt(s)||s.parentNode.tagName==="TEXTAREA")return;const c=Xe(s.parentNode)?this.mirror.getId(Gt(s)):this.mirror.getId(s.parentNode),u=o(s);if(c===-1||u===-1)return n.addNode(s);const d=Le(s,{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=>{$e(h,this.mirror)&&this.iframeManager.addIframe(h),Bt(h,this.mirror)&&this.stylesheetManager.trackLinkElement(h),Ne(s)&&this.shadowDomManager.addShadowRoot(s.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}),r.add(d.id))};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const s of this.movedSet)Hr(this.removes,s,this.mirror)&&!this.movedSet.has(s.parentNode)||i(s);for(const s of this.addedSet)!Yr(this.droppedSet,s)&&!Hr(this.removes,s,this.mirror)||Yr(this.movedSet,s)?i(s):this.droppedSet.add(s);let a=null;for(;n.length;){let s=null;if(a){const c=this.mirror.getId(a.value.parentNode),u=o(a.value);c!==-1&&u!==-1&&(s=a)}if(!s){let c=n.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){s=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){s=u;break}}}}}}if(!s){for(;n.head;)n.removeNode(n.head.value);break}a=s.previous,n.removeNode(s.value),i(s.value)}const l={texts:this.texts.map(s=>{const c=s.node;return c.parentNode.tagName==="TEXTAREA"&&this.genTextAreaValueMutation(c.parentNode),{id:this.mirror.getId(c),value:s.value}}).filter(s=>!r.has(s.id)).filter(s=>this.mirror.has(s.id)),attributes:this.attributes.map(s=>{const{attributes:c}=s;if(typeof c.style=="string"){const u=JSON.stringify(s.styleDiff),d=JSON.stringify(s._unchangedStyles);u.length<c.style.length&&(u+d).split("var(").length===c.style.split("var(").length&&(c.style=s.styleDiff)}return{id:this.mirror.getId(s.node),attributes:c}}).filter(s=>!r.has(s.id)).filter(s=>this.mirror.has(s.id)),removes:this.removes,adds:t};!l.texts.length&&!l.attributes.length&&!l.removes.length&&!l.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(l))},this.genTextAreaValueMutation=t=>{let r=this.attributeMap.get(t);r||(r={node:t,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(r),this.attributeMap.set(t,r)),r.attributes.value=Array.from(t.childNodes,n=>n.textContent||"").join("")},this.processMutation=t=>{if(!pt(t.target,this.mirror))switch(t.type){case"characterData":{const r=t.target.textContent;!ae(t.target,this.blockClass,this.blockSelector,!1)&&r!==t.oldValue&&this.texts.push({value:Or(t.target,this.maskTextClass,this.maskTextSelector,!0)&&r?this.maskTextFn?this.maskTextFn(r,Pt(t.target)):r.replace(/[\S]/g,"*"):r,node:t.target});break}case"attributes":{const r=t.target;let n=t.attributeName,o=t.target.getAttribute(n);if(n==="value"){const a=Rt(r);o=xt({element:r,maskInputOptions:this.maskInputOptions,tagName:r.tagName,type:a,value:o,maskInputFn:this.maskInputFn})}if(ae(t.target,this.blockClass,this.blockSelector,!1)||o===t.oldValue)return;let i=this.attributeMap.get(t.target);if(r.tagName==="IFRAME"&&n==="src"&&!this.keepIframeSrcFn(o))if(!r.contentDocument)n="rr_src";else return;if(i||(i={node:t.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(i),this.attributeMap.set(t.target,i)),n==="type"&&r.tagName==="INPUT"&&(t.oldValue||"").toLowerCase()==="password"&&r.setAttribute("data-rr-is-password","true"),!kr(r.tagName,n)&&(i.attributes[n]=Dr(this.doc,Ce(r.tagName),Ce(n),o),n==="style")){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch{this.unattachedDoc=this.doc}const a=this.unattachedDoc.createElement("span");t.oldValue&&a.setAttribute("style",t.oldValue);for(const l of Array.from(r.style)){const s=r.style.getPropertyValue(l),c=r.style.getPropertyPriority(l);s!==a.style.getPropertyValue(l)||c!==a.style.getPropertyPriority(l)?c===""?i.styleDiff[l]=s:i.styleDiff[l]=[s,c]:i._unchangedStyles[l]=[s,c]}for(const l of Array.from(a.style))r.style.getPropertyValue(l)===""&&(i.styleDiff[l]=!1)}break}case"childList":{if(ae(t.target,this.blockClass,this.blockSelector,!0))return;if(t.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(t.target);return}t.addedNodes.forEach(r=>this.genAdds(r,t.target)),t.removedNodes.forEach(r=>{const n=this.mirror.getId(r),o=Xe(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);ae(t.target,this.blockClass,this.blockSelector,!1)||pt(r,this.mirror)||!Pr(r,this.mirror)||(this.addedSet.has(r)?(Xt(this.addedSet,r),this.droppedSet.add(r)):this.addedSet.has(t.target)&&n===-1||Ut(t.target,this.mirror)||(this.movedSet.has(r)&&this.movedMap[zr(n,o)]?Xt(this.movedSet,r):this.removes.push({parentId:o,id:n,isShadow:Xe(t.target)&&qe(t.target)?!0:void 0})),this.mapRemoves.push(r))});break}}},this.genAdds=(t,r)=>{if(!this.processedNodeManager.inOtherBuffer(t,this)&&!(this.addedSet.has(t)||this.movedSet.has(t))){if(this.mirror.hasNode(t)){if(pt(t,this.mirror))return;this.movedSet.add(t);let n=null;r&&this.mirror.hasNode(r)&&(n=this.mirror.getId(r)),n&&n!==-1&&(this.movedMap[zr(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);ae(t,this.blockClass,this.blockSelector,!1)||(t.childNodes.forEach(n=>this.genAdds(n)),Ne(t)&&t.shadowRoot.childNodes.forEach(n=>{this.processedNodeManager.add(n,this),this.genAdds(n,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(r=>{this[r]=t[r]})}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 Xt(e,t){e.delete(t),t.childNodes.forEach(r=>Xt(e,r))}function Hr(e,t,r){return e.length===0?!1:Gr(e,t,r)}function Gr(e,t,r){const{parentNode:n}=t;if(!n)return!1;const o=r.getId(n);return e.some(i=>i.id===o)?!0:Gr(e,n,r)}function Yr(e,t){return e.size===0?!1:Xr(e,t)}function Xr(e,t){const{parentNode:r}=t;return r?e.has(r)?!0:Xr(e,r):!1}let et;function qo(e){et=e}function Jo(){et=void 0}const $=e=>et?(...t)=>{try{return e(...t)}catch(r){if(et&&et(r)===!0)return;throw r}}:e;var Qo=Object.defineProperty,Ko=Object.defineProperties,Zo=Object.getOwnPropertyDescriptors,qr=Object.getOwnPropertySymbols,es=Object.prototype.hasOwnProperty,ts=Object.prototype.propertyIsEnumerable,Jr=(e,t,r)=>t in e?Qo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qr=(e,t)=>{for(var r in t||(t={}))es.call(t,r)&&Jr(e,r,t[r]);if(qr)for(var r of qr(t))ts.call(t,r)&&Jr(e,r,t[r]);return e},rs=(e,t)=>Ko(e,Zo(t));const Oe=[];function tt(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 Kr(e,t){var r,n;const o=new Xo;Oe.push(o),o.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const a=(n=(r=window?.Zone)==null?void 0:r.__symbol__)==null?void 0:n.call(r,"MutationObserver");a&&window[a]&&(i=window[a]);const l=new i($(o.processMutations.bind(o)));return l.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),l}function ns({mousemoveCb:e,sampling:t,doc:r,mirror:n}){if(t.mousemove===!1)return()=>{};const o=typeof t.mousemove=="number"?t.mousemove:50,i=typeof t.mousemoveCallback=="number"?t.mousemoveCallback:500;let a=[],l;const s=Fe($(d=>{const h=Date.now()-l;e(a.map(m=>(m.timeOffset-=h,m)),d),a=[],l=null}),i),c=$(Fe($(d=>{const h=tt(d),{clientX:m,clientY:g}=mt(d)?d.changedTouches[0]:d;l||(l=Ze()),a.push({x:m,y:g,id:n.getId(h),timeOffset:Ze()-l}),s(typeof DragEvent<"u"&&d instanceof DragEvent?C.Drag:d instanceof MouseEvent?C.MouseMove:C.TouchMove)}),o,{trailing:!1})),u=[ie("mousemove",c,r),ie("touchmove",c,r),ie("drag",c,r)];return $(()=>{u.forEach(d=>d())})}function os({mouseInteractionCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:i}){if(i.mouseInteraction===!1)return()=>{};const a=i.mouseInteraction===!0||i.mouseInteraction===void 0?{}:i.mouseInteraction,l=[];let s=null;const c=u=>d=>{const h=tt(d);if(ae(h,n,o,!0))return;let m=null,g=u;if("pointerType"in d){switch(d.pointerType){case"mouse":m=Se.Mouse;break;case"touch":m=Se.Touch;break;case"pen":m=Se.Pen;break}m===Se.Touch?P[u]===P.MouseDown?g="TouchStart":P[u]===P.MouseUp&&(g="TouchEnd"):Se.Pen}else mt(d)&&(m=Se.Touch);m!==null?(s=m,(g.startsWith("Touch")&&m===Se.Touch||g.startsWith("Mouse")&&m===Se.Mouse)&&(m=null)):P[u]===P.Click&&(m=s,s=null);const p=mt(d)?d.changedTouches[0]:d;if(!p)return;const y=r.getId(h),{clientX:f,clientY:S}=p;$(e)(Qr({type:P[g],id:y,x:f,y:S},m!==null&&{pointerType:m}))};return Object.keys(P).filter(u=>Number.isNaN(Number(u))&&!u.endsWith("_Departed")&&a[u]!==!1).forEach(u=>{let d=Ce(u);const h=c(u);if(window.PointerEvent)switch(P[u]){case P.MouseDown:case P.MouseUp:d=d.replace("mouse","pointer");break;case P.TouchStart:case P.TouchEnd:return}l.push(ie(d,h,t))}),$(()=>{l.forEach(u=>u())})}function Zr({scrollCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,sampling:i}){const a=$(Fe($(l=>{const s=tt(l);if(!s||ae(s,n,o,!0))return;const c=r.getId(s);if(s===t&&t.defaultView){const u=_t(t.defaultView);e({id:c,x:u.left,y:u.top})}else e({id:c,x:s.scrollLeft,y:s.scrollTop})}),i.scroll||100));return ie("scroll",a,t)}function ss({viewportResizeCb:e},{win:t}){let r=-1,n=-1;const o=$(Fe($(()=>{const i=Ft(),a=$t();(r!==i||n!==a)&&(e({width:Number(a),height:Number(i)}),r=i,n=a)}),200));return ie("resize",o,t)}const is=["INPUT","TEXTAREA","SELECT"],en=new WeakMap;function as({inputCb:e,doc:t,mirror:r,blockClass:n,blockSelector:o,ignoreClass:i,ignoreSelector:a,maskInputOptions:l,maskInputFn:s,sampling:c,userTriggeredOnInput:u}){function d(f){let S=tt(f);const v=f.isTrusted,w=S&&S.tagName;if(S&&w==="OPTION"&&(S=S.parentElement),!S||!w||is.indexOf(w)<0||ae(S,n,o,!0)||S.classList.contains(i)||a&&S.matches(a))return;let N=S.value,D=!1;const A=Rt(S)||"";A==="radio"||A==="checkbox"?D=S.checked:(l[w.toLowerCase()]||l[A])&&(N=xt({element:S,maskInputOptions:l,tagName:w,type:A,value:N,maskInputFn:s})),h(S,u?{text:N,isChecked:D,userTriggered:v}:{text:N,isChecked:D});const M=S.name;A==="radio"&&M&&D&&t.querySelectorAll(`input[type="radio"][name="${M}"]`).forEach(B=>{if(B!==S){const j=B.value;h(B,u?{text:j,isChecked:!D,userTriggered:!1}:{text:j,isChecked:!D})}})}function h(f,S){const v=en.get(f);if(!v||v.text!==S.text||v.isChecked!==S.isChecked){en.set(f,S);const w=r.getId(f);$(e)(rs(Qr({},S),{id:w}))}}const m=(c.input==="last"?["change"]:["input","change"]).map(f=>ie(f,$(d),t)),g=t.defaultView;if(!g)return()=>{m.forEach(f=>f())};const p=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),y=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&m.push(...y.map(f=>Ke(f[0],f[1],{set(){$(d)({target:this,isTrusted:!1})}},!1