@highlight-run/rrweb 2.0.11 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/plugins/console-record.js +5 -5
  2. package/dist/plugins/console-record.min.js +5 -5
  3. package/dist/plugins/console-record.min.js.map +1 -1
  4. package/dist/plugins/console-replay.js +3 -3
  5. package/dist/plugins/console-replay.min.js +3 -3
  6. package/dist/plugins/console-replay.min.js.map +1 -1
  7. package/dist/record/rrweb-record-pack.js +2 -2
  8. package/dist/record/rrweb-record-pack.min.js +2 -2
  9. package/dist/record/rrweb-record-pack.min.js.map +1 -1
  10. package/dist/record/rrweb-record.js +3 -3
  11. package/dist/record/rrweb-record.min.js +3 -3
  12. package/dist/record/rrweb-record.min.js.map +1 -1
  13. package/dist/replay/rrweb-replay-unpack.js +4 -3
  14. package/dist/replay/rrweb-replay-unpack.min.js +4 -3
  15. package/dist/replay/rrweb-replay-unpack.min.js.map +1 -1
  16. package/dist/replay/rrweb-replay.js +4 -3
  17. package/dist/replay/rrweb-replay.min.js +4 -3
  18. package/dist/replay/rrweb-replay.min.js.map +1 -1
  19. package/dist/rrweb-all.js +25 -24
  20. package/dist/rrweb-all.min.js +25 -24
  21. package/dist/rrweb-all.min.js.map +1 -1
  22. package/dist/rrweb.js +15 -14
  23. package/dist/rrweb.min.js +15 -14
  24. package/dist/rrweb.min.js.map +1 -1
  25. package/es/rrweb/packages/rrdom/es/virtual-dom.js +63 -1
  26. package/es/rrweb/packages/rrweb/src/index.js +1 -1
  27. package/es/rrweb/packages/rrweb/src/record/index.js +1 -1
  28. package/es/rrweb/packages/rrweb/src/record/mutation.js +1 -1
  29. package/es/rrweb/packages/rrweb/src/record/observer.js +1 -1
  30. package/es/rrweb/packages/rrweb/src/replay/index.js +1 -1
  31. package/es/rrweb/packages/rrweb/src/utils.js +1 -1
  32. package/es/rrweb/packages/rrweb-snapshot/es/rrweb-snapshot.js +1871 -0
  33. package/lib/plugins/console-record.js +9 -1
  34. package/lib/plugins/console-replay.js +9 -1
  35. package/lib/record/rrweb-record-pack.js +9 -3
  36. package/lib/record/rrweb-record.js +1063 -17
  37. package/lib/replay/rrweb-replay-unpack.js +999 -47
  38. package/lib/replay/rrweb-replay.js +999 -47
  39. package/lib/rrweb-all.js +2020 -88
  40. package/lib/rrweb.js +2020 -88
  41. package/package.json +3 -3
@@ -1,4 +1,5 @@
1
- var rrwebReplay=function(Q,y){"use strict";function Ke(t){const e={},i=/;(?![^(]*\))/g,s=/:(.+)/,o=/\/\*.*?\*\//g;return t.replace(o,"").split(i).forEach(function(r){if(r){const a=r.split(s);a.length>1&&(e[q(a[0].trim())]=a[1].trim())}}),e}function ue(t){const e=[];for(const i in t){const s=t[i];if(typeof s!="string")continue;const o=st(i);e.push(`${o}: ${s};`)}return e.join(" ")}const et=/-([a-z])/g,tt=/^--[a-zA-Z0-9-]+$/,q=t=>tt.test(t)?t:t.replace(et,(e,i)=>i?i.toUpperCase():""),it=/\B([A-Z])/g,st=t=>t.replace(it,"-$1").toLowerCase();class S{constructor(...e){this.childNodes=[],this.parentElement=null,this.parentNode=null,this.ELEMENT_NODE=b.ELEMENT_NODE,this.TEXT_NODE=b.TEXT_NODE}get firstChild(){return this.childNodes[0]||null}get lastChild(){return this.childNodes[this.childNodes.length-1]||null}get nextSibling(){const e=this.parentNode;if(!e)return null;const i=e.childNodes,s=i.indexOf(this);return i[s+1]||null}contains(e){if(e===this)return!0;for(const i of this.childNodes)if(i.contains(e))return!0;return!1}appendChild(e){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(e,i){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(e){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}function ot(t){return class Ze extends t{constructor(){super(...arguments),this.nodeType=b.DOCUMENT_NODE,this.nodeName="#document",this.compatMode="CSS1Compat",this.RRNodeType=y.NodeType.Document,this.textContent=null}get documentElement(){return this.childNodes.find(i=>i.RRNodeType===y.NodeType.Element&&i.tagName==="HTML")||null}get body(){var i;return((i=this.documentElement)===null||i===void 0?void 0:i.childNodes.find(s=>s.RRNodeType===y.NodeType.Element&&s.tagName==="BODY"))||null}get head(){var i;return((i=this.documentElement)===null||i===void 0?void 0:i.childNodes.find(s=>s.RRNodeType===y.NodeType.Element&&s.tagName==="HEAD"))||null}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(i){const s=i.RRNodeType;if((s===y.NodeType.Element||s===y.NodeType.DocumentType)&&this.childNodes.some(o=>o.RRNodeType===s))throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${s===y.NodeType.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);return i.parentElement=null,i.parentNode=this,this.childNodes.push(i),i}insertBefore(i,s){const o=i.RRNodeType;if((o===y.NodeType.Element||o===y.NodeType.DocumentType)&&this.childNodes.some(a=>a.RRNodeType===o))throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${o===y.NodeType.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);if(s===null)return this.appendChild(i);const r=this.childNodes.indexOf(s);if(r==-1)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return this.childNodes.splice(r,0,i),i.parentElement=null,i.parentNode=this,i}removeChild(i){const s=this.childNodes.indexOf(i);if(s===-1)throw new Error("Failed to execute 'removeChild' on 'RRDocument': The RRNode to be removed is not a child of this RRNode.");return this.childNodes.splice(s,1),i.parentElement=null,i.parentNode=null,i}open(){this.childNodes=[]}close(){}write(i){let s;if(i==='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'?s="-//W3C//DTD XHTML 1.0 Transitional//EN":i==='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'&&(s="-//W3C//DTD HTML 4.0 Transitional//EN"),s){const o=this.createDocumentType("html",s,"");this.open(),this.appendChild(o)}}createDocument(i,s,o){return new Ze}createDocumentType(i,s,o){const r=new(he(S))(i,s,o);return r.ownerDocument=this,r}createElement(i){const s=new(me(S))(i);return s.ownerDocument=this,s}createElementNS(i,s){return this.createElement(s)}createTextNode(i){const s=new(pe(S))(i);return s.ownerDocument=this,s}createComment(i){const s=new(fe(S))(i);return s.ownerDocument=this,s}createCDATASection(i){const s=new(ye(S))(i);return s.ownerDocument=this,s}toString(){return"RRDocument"}}}function he(t){return class extends t{constructor(e,i,s){super(),this.nodeType=b.DOCUMENT_TYPE_NODE,this.RRNodeType=y.NodeType.DocumentType,this.textContent=null,this.name=e,this.publicId=i,this.systemId=s,this.nodeName=e}toString(){return"RRDocumentType"}}}function me(t){return class extends t{constructor(e){super(),this.nodeType=b.ELEMENT_NODE,this.RRNodeType=y.NodeType.Element,this.attributes={},this.shadowRoot=null,this.tagName=e.toUpperCase(),this.nodeName=e.toUpperCase()}get textContent(){let e="";return this.childNodes.forEach(i=>e+=i.textContent),e}set textContent(e){this.childNodes=[this.ownerDocument.createTextNode(e)]}get classList(){return new rt(this.attributes.class,e=>{this.attributes.class=e})}get id(){return this.attributes.id||""}get className(){return this.attributes.class||""}get style(){const e=this.attributes.style?Ke(this.attributes.style):{},i=/\B([A-Z])/g;return e.setProperty=(s,o,r)=>{if(i.test(s))return;const a=q(s);o?e[a]=o:delete e[a],r==="important"&&(e[a]+=" !important"),this.attributes.style=ue(e)},e.removeProperty=s=>{if(i.test(s))return"";const o=q(s),r=e[o]||"";return delete e[o],this.attributes.style=ue(e),r},e}getAttribute(e){return this.attributes[e]||null}setAttribute(e,i){this.attributes[e]=i}setAttributeNS(e,i,s){this.setAttribute(i,s)}removeAttribute(e){delete this.attributes[e]}appendChild(e){return this.childNodes.push(e),e.parentNode=this,e.parentElement=this,e}insertBefore(e,i){if(i===null)return this.appendChild(e);const s=this.childNodes.indexOf(i);if(s==-1)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return this.childNodes.splice(s,0,e),e.parentElement=this,e.parentNode=this,e}removeChild(e){const i=this.childNodes.indexOf(e);if(i===-1)throw new Error("Failed to execute 'removeChild' on 'RRElement': The RRNode to be removed is not a child of this RRNode.");return this.childNodes.splice(i,1),e.parentElement=null,e.parentNode=null,e}attachShadow(e){const i=this.ownerDocument.createElement("SHADOWROOT");return this.shadowRoot=i,i}dispatchEvent(e){return!0}toString(){let e="";for(const i in this.attributes)e+=`${i}="${this.attributes[i]}" `;return`${this.tagName} ${e}`}}}function nt(t){return class extends t{attachShadow(e){throw new Error("RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow")}play(){this.paused=!1}pause(){this.paused=!0}}}function pe(t){return class extends t{constructor(e){super(),this.nodeType=b.TEXT_NODE,this.nodeName="#text",this.RRNodeType=y.NodeType.Text,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRText text=${JSON.stringify(this.data)}`}}}function fe(t){return class extends t{constructor(e){super(),this.nodeType=b.COMMENT_NODE,this.nodeName="#comment",this.RRNodeType=y.NodeType.Comment,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRComment text=${JSON.stringify(this.data)}`}}}function ye(t){return class extends t{constructor(e){super(),this.nodeName="#cdata-section",this.nodeType=b.CDATA_SECTION_NODE,this.RRNodeType=y.NodeType.CDATA,this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}toString(){return`RRCDATASection data=${JSON.stringify(this.data)}`}}}class rt{constructor(e,i){if(this.classes=[],this.add=(...s)=>{for(const o of s){const r=String(o);this.classes.indexOf(r)>=0||this.classes.push(r)}this.onChange&&this.onChange(this.classes.join(" "))},this.remove=(...s)=>{this.classes=this.classes.filter(o=>s.indexOf(o)===-1),this.onChange&&this.onChange(this.classes.join(" "))},e){const s=e.trim().split(/\s+/);this.classes.push(...s)}this.onChange=i}}var b;(function(t){t[t.PLACEHOLDER=0]="PLACEHOLDER",t[t.ELEMENT_NODE=1]="ELEMENT_NODE",t[t.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",t[t.TEXT_NODE=3]="TEXT_NODE",t[t.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",t[t.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",t[t.ENTITY_NODE=6]="ENTITY_NODE",t[t.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",t[t.COMMENT_NODE=8]="COMMENT_NODE",t[t.DOCUMENT_NODE=9]="DOCUMENT_NODE",t[t.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",t[t.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"})(b||(b={}));const J={svg:"http://www.w3.org/2000/svg","xlink:href":"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"};function A(t,e,i,s){const o=t.childNodes,r=e.childNodes;s=s||e.mirror||e.ownerDocument.mirror,(o.length>0||r.length>0)&&ge(Array.from(o),r,t,i,s);let a=null,c=null;switch(e.RRNodeType){case y.NodeType.Document:{c=e.scrollData;break}case y.NodeType.Element:{const d=t,n=e;switch(at(d,n,s),c=n.scrollData,a=n.inputData,n.tagName){case"AUDIO":case"VIDEO":{const l=t,u=n;u.paused!==void 0&&(u.paused?l.pause():l.play()),u.muted!==void 0&&(l.muted=u.muted),u.volume!==void 0&&(l.volume=u.volume),u.currentTime!==void 0&&(l.currentTime=u.currentTime);break}case"CANVAS":e.canvasMutations.forEach(l=>i.applyCanvas(l.event,l.mutation,t));break;case"STYLE":ct(d,e.rules);break}if(n.shadowRoot){d.shadowRoot||d.attachShadow({mode:"open"});const l=d.shadowRoot.childNodes,u=n.shadowRoot.childNodes;(l.length>0||u.length>0)&&ge(Array.from(l),u,d.shadowRoot,i,s)}break}case y.NodeType.Text:case y.NodeType.Comment:case y.NodeType.CDATA:t.textContent!==e.data&&(t.textContent=e.data);break}if(c&&i.applyScroll(c,!0),a&&i.applyInput(a),e.nodeName==="IFRAME"){const d=t.contentDocument,n=e;if(d){const l=s.getMeta(n.contentDocument);l&&i.mirror.add(d,Object.assign({},l)),A(d,n.contentDocument,i,s)}}}function at(t,e,i){const s=t.attributes,o=e.attributes;for(const r in o){const a=o[r],c=i.getMeta(e);if(c&&"isSVG"in c&&c.isSVG&&J[r])t.setAttributeNS(J[r],r,a);else if(e.tagName==="CANVAS"&&r==="rr_dataURL"){const d=document.createElement("img");d.src=a,d.onload=()=>{const n=t.getContext("2d");n&&n.drawImage(d,0,0,d.width,d.height)}}else t.setAttribute(r,a)}for(const{name:r}of Array.from(s))r in o||t.removeAttribute(r);e.scrollLeft&&(t.scrollLeft=e.scrollLeft),e.scrollTop&&(t.scrollTop=e.scrollTop)}function ge(t,e,i,s,o){var r;let a=0,c=t.length-1,d=0,n=e.length-1,l=t[a],u=t[c],m=e[d],p=e[n],T,g;for(;a<=c&&d<=n;)if(l===void 0)l=t[++a];else if(u===void 0)u=t[--c];else if(s.mirror.getId(l)===o.getId(m))A(l,m,s,o),l=t[++a],m=e[++d];else if(s.mirror.getId(u)===o.getId(p))A(u,p,s,o),u=t[--c],p=e[--n];else if(s.mirror.getId(l)===o.getId(p))try{i.insertBefore(l,u.nextSibling),A(l,p,s,o),l=t[++a],p=e[--n]}catch(f){console.error(f,i,l,u)}else if(s.mirror.getId(u)===o.getId(m))try{i.insertBefore(u,l),A(u,m,s,o),u=t[--c],m=e[++d]}catch(f){console.error(f,i,u,l)}else{if(!T){T={};for(let f=a;f<=c;f++){const h=t[f];h&&s.mirror.hasNode(h)&&(T[s.mirror.getId(h)]=f)}}if(g=T[o.getId(m)],g){const f=t[g];try{i.insertBefore(f,l),A(f,m,s,o),t[g]=void 0}catch(h){console.error(h,i,f,l)}}else{const f=Z(m,s.mirror,o);i.nodeName==="#document"&&((r=s.mirror.getMeta(f))===null||r===void 0?void 0:r.type)===y.NodeType.Element&&i.documentElement&&(i.removeChild(i.documentElement),t[a]=void 0,l=void 0);try{i.insertBefore(f,l||null),A(f,m,s,o)}catch(h){console.error(h,i,f,l||null)}}m=e[++d]}if(a>c){const f=e[n+1];let h=null;for(f&&i.childNodes.forEach(v=>{s.mirror.getId(v)===o.getId(f)&&(h=v)});d<=n;++d){const v=Z(e[d],s.mirror,o);try{i.insertBefore(v,h),A(v,e[d],s,o)}catch(E){console.error(E,i,v,h)}}}else if(d>n)for(;a<=c;a++){const f=t[a];f&&(i.removeChild(f),s.mirror.removeNodeFromMap(f))}}function Z(t,e,i){let s=e.getNode(i.getId(t));const o=i.getMeta(t);if(s!==null)return s;switch(t.RRNodeType){case y.NodeType.Document:s=new Document;break;case y.NodeType.DocumentType:s=document.implementation.createDocumentType(t.name,t.publicId,t.systemId);break;case y.NodeType.Element:{t.tagName.toLowerCase(),o&&"isSVG"in o&&o?.isSVG?s=document.createElementNS(J.svg,t.tagName.toLowerCase()):s=document.createElement(t.tagName);break}case y.NodeType.Text:s=document.createTextNode(t.data);break;case y.NodeType.Comment:s=document.createComment(t.data);break;case y.NodeType.CDATA:s=document.createCDATASection(t.data);break}return o&&e.add(s,Object.assign({},o)),s}function U(t,e){const i=t[e[0]];return e.length===1?i:U(i.cssRules[e[1]].cssRules,e.slice(2))}var M;(function(t){t[t.Insert=0]="Insert",t[t.Remove=1]="Remove",t[t.Snapshot=2]="Snapshot",t[t.SetProperty=3]="SetProperty",t[t.RemoveProperty=4]="RemoveProperty"})(M||(M={}));function ve(t){const e=[...t],i=e.pop();return{positions:e,index:i}}function ct(t,e){const i=t.sheet;e.forEach(s=>{if(s.type===M.Insert)try{if(Array.isArray(s.index)){const{positions:o,index:r}=ve(s.index);U(i.cssRules,o).insertRule(s.cssText,r)}else i.insertRule(s.cssText,s.index)}catch{}else if(s.type===M.Remove)try{if(Array.isArray(s.index)){const{positions:o,index:r}=ve(s.index);U(i.cssRules,o).deleteRule(r||0)}else i.deleteRule(s.index)}catch{}else s.type===M.SetProperty?U(i.cssRules,s.index).style.setProperty(s.property,s.value,s.priority):s.type===M.RemoveProperty&&U(i.cssRules,s.index).style.removeProperty(s.property)})}class k extends ot(S){constructor(e){super(),this._unserializedId=-1,this.mirror=Tt(),this.scrollData=null,e&&(this.mirror=e)}get unserializedId(){return this._unserializedId--}createDocument(e,i,s){return new k}createDocumentType(e,i,s){const o=new lt(e,i,s);return o.ownerDocument=this,o}createElement(e){const i=e.toUpperCase();let s;switch(i){case"AUDIO":case"VIDEO":s=new dt(i);break;case"IFRAME":s=new mt(i,this.mirror);break;case"CANVAS":s=new ut(i);break;case"STYLE":s=new ht(i);break;default:s=new $(i);break}return s.ownerDocument=this,s}createComment(e){const i=new ft(e);return i.ownerDocument=this,i}createCDATASection(e){const i=new yt(e);return i.ownerDocument=this,i}createTextNode(e){const i=new pt(e);return i.ownerDocument=this,i}destroyTree(){this.childNodes=[],this.mirror.reset()}open(){super.open(),this._unserializedId=-1}}const lt=he(S);class $ extends me(S){constructor(){super(...arguments),this.inputData=null,this.scrollData=null}}class dt extends nt($){}class ut extends ${constructor(){super(...arguments),this.canvasMutations=[]}getContext(){return null}}class ht extends ${constructor(){super(...arguments),this.rules=[]}}class mt extends ${constructor(e,i){super(e),this.contentDocument=new k,this.contentDocument.mirror=i}}const pt=pe(S),ft=fe(S),yt=ye(S);function gt(t){return t instanceof HTMLFormElement?"FORM":t.tagName.toUpperCase()}function Te(t,e,i,s){let o;switch(t.nodeType){case b.DOCUMENT_NODE:s&&s.nodeName==="IFRAME"?o=s.contentDocument:(o=e,o.compatMode=t.compatMode);break;case b.DOCUMENT_TYPE_NODE:const a=t;o=e.createDocumentType(a.name,a.publicId,a.systemId);break;case b.ELEMENT_NODE:const c=t,d=gt(c);o=e.createElement(d);const n=o;for(const{name:l,value:u}of Array.from(c.attributes))n.attributes[l]=u;c.scrollLeft&&(n.scrollLeft=c.scrollLeft),c.scrollTop&&(n.scrollTop=c.scrollTop);break;case b.TEXT_NODE:o=e.createTextNode(t.textContent||"");break;case b.CDATA_SECTION_NODE:o=e.createCDATASection(t.data);break;case b.COMMENT_NODE:o=e.createComment(t.textContent||"");break;case b.DOCUMENT_FRAGMENT_NODE:o=s.attachShadow({mode:"open"});break;default:return null}let r=i.getMeta(t);return e instanceof k&&(r||(r=Ne(o,e.unserializedId),i.add(t,r)),e.mirror.add(o,Object.assign({},r))),o}function vt(t,e=y.createMirror(),i=new k){function s(o,r){const a=Te(o,i,e,r);a!==null&&(r?.nodeName!=="IFRAME"&&o.nodeType!==b.DOCUMENT_FRAGMENT_NODE&&(r?.appendChild(a),a.parentNode=r,a.parentElement=r),o.nodeName==="IFRAME"?s(o.contentDocument,a):(o.nodeType===b.DOCUMENT_NODE||o.nodeType===b.ELEMENT_NODE||o.nodeType===b.DOCUMENT_FRAGMENT_NODE)&&(o.nodeType===b.ELEMENT_NODE&&o.shadowRoot&&s(o.shadowRoot,a),o.childNodes.forEach(c=>s(c,a))))}return s(t,null),i}function Tt(){return new Nt}class Nt{constructor(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}getId(e){var i;if(!e)return-1;const s=(i=this.getMeta(e))===null||i===void 0?void 0:i.id;return s??-1}getNode(e){return this.idNodeMap.get(e)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(e){return this.nodeMetaMap.get(e)||null}removeNodeFromMap(e){const i=this.getId(e);this.idNodeMap.delete(i),e.childNodes&&e.childNodes.forEach(s=>this.removeNodeFromMap(s))}has(e){return this.idNodeMap.has(e)}hasNode(e){return this.nodeMetaMap.has(e)}add(e,i){const s=i.id;this.idNodeMap.set(s,e),this.nodeMetaMap.set(e,i)}replace(e,i){this.idNodeMap.set(e,i)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function Ne(t,e){switch(t.RRNodeType){case y.NodeType.Document:return{id:e,type:t.RRNodeType,childNodes:[]};case y.NodeType.DocumentType:const i=t;return{id:e,type:t.RRNodeType,name:i.name,publicId:i.publicId,systemId:i.systemId};case y.NodeType.Element:return{id:e,type:t.RRNodeType,tagName:t.tagName.toLowerCase(),attributes:{},childNodes:[]};case y.NodeType.Text:return{id:e,type:t.RRNodeType,textContent:t.textContent||""};case y.NodeType.Comment:return{id:e,type:t.RRNodeType,textContent:t.textContent||""};case y.NodeType.CDATA:return{id:e,type:t.RRNodeType,textContent:""}}}function Ee(t){return t=t||Object.create(null),{on:function(i,s){(t[i]||(t[i]=[])).push(s)},off:function(i,s){t[i]&&t[i].splice(t[i].indexOf(s)>>>0,1)},emit:function(i,s){(t[i]||[]).slice().map(function(o){o(s)}),(t["*"]||[]).slice().map(function(o){o(i,s)})}}}var Et=Object.freeze({__proto__:null,default:Ee});function Dt(t=window,e=document){if("scrollBehavior"in e.documentElement.style&&t.__forceSmoothScrollPolyfill__!==!0)return;const i=t.HTMLElement||t.Element,s=468,o={scroll:t.scroll||t.scrollTo,scrollBy:t.scrollBy,elementScroll:i.prototype.scroll||d,scrollIntoView:i.prototype.scrollIntoView},r=t.performance&&t.performance.now?t.performance.now.bind(t.performance):Date.now;function a(h){const v=["MSIE ","Trident/","Edge/"];return new RegExp(v.join("|")).test(h)}const c=a(t.navigator.userAgent)?1:0;function d(h,v){this.scrollLeft=h,this.scrollTop=v}function n(h){return .5*(1-Math.cos(Math.PI*h))}function l(h){if(h===null||typeof h!="object"||h.behavior===void 0||h.behavior==="auto"||h.behavior==="instant")return!0;if(typeof h=="object"&&h.behavior==="smooth")return!1;throw new TypeError("behavior member of ScrollOptions "+h.behavior+" is not a valid value for enumeration ScrollBehavior.")}function u(h,v){if(v==="Y")return h.clientHeight+c<h.scrollHeight;if(v==="X")return h.clientWidth+c<h.scrollWidth}function m(h,v){const E=t.getComputedStyle(h,null)["overflow"+v];return E==="auto"||E==="scroll"}function p(h){const v=u(h,"Y")&&m(h,"Y"),E=u(h,"X")&&m(h,"X");return v||E}function T(h){for(;h!==e.body&&p(h)===!1;)h=h.parentNode||h.host;return h}function g(h){const v=r();let E,C,O,I=(v-h.startTime)/s;I=I>1?1:I,E=n(I),C=h.startX+(h.x-h.startX)*E,O=h.startY+(h.y-h.startY)*E,h.method.call(h.scrollable,C,O),(C!==h.x||O!==h.y)&&t.requestAnimationFrame(g.bind(t,h))}function f(h,v,E){let C,O,I,B;const ce=r();h===e.body?(C=t,O=t.scrollX||t.pageXOffset,I=t.scrollY||t.pageYOffset,B=o.scroll):(C=h,O=h.scrollLeft,I=h.scrollTop,B=d),g({scrollable:C,method:B,startTime:ce,startX:O,startY:I,x:v,y:E})}t.scroll=t.scrollTo=function(){if(arguments[0]!==void 0){if(l(arguments[0])===!0){o.scroll.call(t,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:t.scrollX||t.pageXOffset,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:t.scrollY||t.pageYOffset);return}f.call(t,e.body,arguments[0].left!==void 0?~~arguments[0].left:t.scrollX||t.pageXOffset,arguments[0].top!==void 0?~~arguments[0].top:t.scrollY||t.pageYOffset)}},t.scrollBy=function(){if(arguments[0]!==void 0){if(l(arguments[0])){o.scrollBy.call(t,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:0,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:0);return}f.call(t,e.body,~~arguments[0].left+(t.scrollX||t.pageXOffset),~~arguments[0].top+(t.scrollY||t.pageYOffset))}},i.prototype.scroll=i.prototype.scrollTo=function(){if(arguments[0]===void 0)return;if(l(arguments[0])===!0){if(typeof arguments[0]=="number"&&arguments[1]===void 0)throw new SyntaxError("Value could not be converted");o.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left:typeof arguments[0]!="object"?~~arguments[0]:this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top:arguments[1]!==void 0?~~arguments[1]:this.scrollTop);return}const h=arguments[0].left,v=arguments[0].top;f.call(this,this,typeof h>"u"?this.scrollLeft:~~h,typeof v>"u"?this.scrollTop:~~v)},i.prototype.scrollBy=function(){if(arguments[0]!==void 0){if(l(arguments[0])===!0){o.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop);return}this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior})}},i.prototype.scrollIntoView=function(){if(l(arguments[0])===!0){o.scrollIntoView.call(this,arguments[0]===void 0?!0:arguments[0]);return}const h=T(this),v=h.getBoundingClientRect(),E=this.getBoundingClientRect();h!==e.body?(f.call(this,h,h.scrollLeft+E.left-v.left,h.scrollTop+E.top-v.top),t.getComputedStyle(h).position!=="fixed"&&t.scrollBy({left:v.left,top:v.top,behavior:"smooth"})):t.scrollBy({left:E.left,top:E.top,behavior:"smooth"})}}var D=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(D||{}),R=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t))(R||{}),x=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(x||{}),Y=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(Y||{}),K=(t=>(t[t.Play=0]="Play",t[t.Pause=1]="Pause",t[t.Seeked=2]="Seeked",t[t.VolumeChange=3]="VolumeChange",t))(K||{}),N=(t=>(t.Start="start",t.Pause="pause",t.Resume="resume",t.Resize="resize",t.Finish="finish",t.FullsnapshotRebuilded="fullsnapshot-rebuilded",t.LoadStylesheetStart="load-stylesheet-start",t.LoadStylesheetEnd="load-stylesheet-end",t.SkipStart="skip-start",t.SkipEnd="skip-end",t.MouseInteraction="mouse-interaction",t.EventCast="event-cast",t.CustomEvent="custom-event",t.Flush="flush",t.StateChange="state-change",t.PlayBack="play-back",t))(N||{});class bt{constructor(e=[],i){this.timeOffset=0,this.raf=null,this.actions=e,this.speed=i}addAction(e){const i=this.findActionIndex(e);this.actions.splice(i,0,e)}addActions(e){this.actions=this.actions.concat(e)}replaceActions(e){this.actions.length=0,this.actions.splice(0,0,...e)}start(){this.timeOffset=0;let e=performance.now();const{actions:i}=this,s=this;function o(){const r=performance.now();for(s.timeOffset+=(r-e)*s.speed,e=r;i.length;){const a=i[0];if(s.timeOffset>=a.delay)i.shift(),a.doAction();else break}(i.length>0||s.liveMode)&&(s.raf=requestAnimationFrame(o))}this.raf=requestAnimationFrame(o)}clear(){this.raf&&(cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0}setSpeed(e){this.speed=e}toggleLiveMode(e){this.liveMode=e}isActive(){return this.raf!==null}findActionIndex(e){let i=0,s=this.actions.length-1;for(;i<=s;){const o=Math.floor((i+s)/2);if(this.actions[o].delay<e.delay)i=o+1;else if(this.actions[o].delay>e.delay)s=o-1;else return o+1}return i}}function ee(t,e){if(t.type===D.IncrementalSnapshot&&t.data.source===R.MouseMove){const i=t.data.positions[0].timeOffset,s=t.timestamp+i;return t.delay=s-e,s-e}return t.delay=t.timestamp-e,t.delay}/*! *****************************************************************************
1
+ var rrwebReplay=function(he){"use strict";var R;(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"})(R||(R={}));function vt(e){return e.nodeType===e.ELEMENT_NODE}var xe=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var n;if(!t)return-1;var r=(n=this.getMeta(t))===null||n===void 0?void 0:n.id;return r??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var n=this,r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(function(i){return n.removeNodeFromMap(i)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,n){var r=n.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,n)},e.prototype.replace=function(t,n){this.idNodeMap.set(t,n)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Tt(){return new xe}var Re=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function Nt(e,t){t===void 0&&(t={});var n=1,r=1;function i(g){var p=g.match(/\n/g);p&&(n+=p.length);var b=g.lastIndexOf(`
2
+ `);r=b===-1?r+g.length:g.length-b}function s(){var g={line:n,column:r};return function(p){return p.position=new a(g),N(),p}}var a=function(){function g(p){this.start=p,this.end={line:n,column:r},this.source=t.source}return g}();a.prototype.content=e;var u=[];function c(g){var p=new Error(t.source+":"+n+":"+r+": "+g);if(p.reason=g,p.filename=t.source,p.line=n,p.column=r,p.source=e,t.silent)u.push(p);else throw p}function o(){var g=h();return{type:"stylesheet",stylesheet:{source:t.source,rules:g,parsingErrors:u}}}function l(){return f(/^{\s*/)}function d(){return f(/^}/)}function h(){var g,p=[];for(N(),y(p);e.length&&e.charAt(0)!=="}"&&(g=I()||re());)g!==!1&&(p.push(g),y(p));return p}function f(g){var p=g.exec(e);if(p){var b=p[0];return i(b),e=e.slice(b.length),p}}function N(){f(/^\s*/)}function y(g){g===void 0&&(g=[]);for(var p;p=v();)p!==!1&&g.push(p),p=v();return g}function v(){var g=s();if(!(e.charAt(0)!=="/"||e.charAt(1)!=="*")){for(var p=2;e.charAt(p)!==""&&(e.charAt(p)!=="*"||e.charAt(p+1)!=="/");)++p;if(p+=2,e.charAt(p-1)==="")return c("End of comment missing");var b=e.slice(2,p-2);return r+=2,i(b),e=e.slice(p),r+=2,g({type:"comment",comment:b})}}function m(){var g=f(/^([^{]+)/);if(g)return V(g[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(p){return p.replace(/,/g,"\u200C")}).split(/\s*(?![^(]*\)),\s*/).map(function(p){return p.replace(/\u200C/g,",")})}function T(){var g=s(),p=f(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(p){var b=V(p[0]);if(!f(/^:\s*/))return c("property missing ':'");var x=f(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),P=g({type:"declaration",property:b.replace(Re,""),value:x?V(x[0]).replace(Re,""):""});return f(/^[;\s]*/),P}}function w(){var g=[];if(!l())return c("missing '{'");y(g);for(var p;p=T();)p!==!1&&(g.push(p),y(g)),p=T();return d()?g:c("missing '}'")}function A(){for(var g,p=[],b=s();g=f(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)p.push(g[1]),f(/^,\s*/);if(p.length)return b({type:"keyframe",values:p,declarations:w()})}function L(){var g=s(),p=f(/^@([-\w]+)?keyframes\s*/);if(p){var b=p[1];if(p=f(/^([-\w]+)\s*/),!p)return c("@keyframes missing name");var x=p[1];if(!l())return c("@keyframes missing '{'");for(var P,de=y();P=A();)de.push(P),de=de.concat(y());return d()?g({type:"keyframes",name:x,vendor:b,keyframes:de}):c("@keyframes missing '}'")}}function O(){var g=s(),p=f(/^@supports *([^{]+)/);if(p){var b=V(p[1]);if(!l())return c("@supports missing '{'");var x=y().concat(h());return d()?g({type:"supports",supports:b,rules:x}):c("@supports missing '}'")}}function U(){var g=s(),p=f(/^@host\s*/);if(p){if(!l())return c("@host missing '{'");var b=y().concat(h());return d()?g({type:"host",rules:b}):c("@host missing '}'")}}function j(){var g=s(),p=f(/^@media *([^{]+)/);if(p){var b=V(p[1]);if(!l())return c("@media missing '{'");var x=y().concat(h());return d()?g({type:"media",media:b,rules:x}):c("@media missing '}'")}}function _(){var g=s(),p=f(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(p)return g({type:"custom-media",name:V(p[1]),media:V(p[2])})}function te(){var g=s(),p=f(/^@page */);if(p){var b=m()||[];if(!l())return c("@page missing '{'");for(var x=y(),P;P=T();)x.push(P),x=x.concat(y());return d()?g({type:"page",selectors:b,declarations:x}):c("@page missing '}'")}}function H(){var g=s(),p=f(/^@([-\w]+)?document *([^{]+)/);if(p){var b=V(p[1]),x=V(p[2]);if(!l())return c("@document missing '{'");var P=y().concat(h());return d()?g({type:"document",document:x,vendor:b,rules:P}):c("@document missing '}'")}}function ne(){var g=s(),p=f(/^@font-face\s*/);if(p){if(!l())return c("@font-face missing '{'");for(var b=y(),x;x=T();)b.push(x),b=b.concat(y());return d()?g({type:"font-face",declarations:b}):c("@font-face missing '}'")}}var ue=q("import"),Ce=q("charset"),Se=q("namespace");function q(g){var p=new RegExp("^@"+g+"\\s*([^;]+);");return function(){var b=s(),x=f(p);if(x){var P={type:g};return P[g]=x[1].trim(),b(P)}}}function I(){if(e[0]==="@")return L()||j()||_()||O()||ue()||Ce()||Se()||H()||te()||U()||ne()}function re(){var g=s(),p=m();return p?(y(),g({type:"rule",selectors:p,declarations:w()})):c("selector missing")}return me(o())}function V(e){return e?e.replace(/^\s+|\s+$/g,""):""}function me(e,t){for(var n=e&&typeof e.type=="string",r=n?e:t,i=0,s=Object.keys(e);i<s.length;i++){var a=s[i],u=e[a];Array.isArray(u)?u.forEach(function(c){me(c,r)}):u&&typeof u=="object"&&me(u,r)}return n&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var Ae={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 Et(e){var t=Ae[e.tagName]?Ae[e.tagName]:e.tagName;return t==="link"&&e.attributes._cssText&&(t="style"),t}function wt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Ie=/([^\\]):hover/,bt=new RegExp(Ie.source,"g");function Oe(e,t){var n;if(!(!((n=window?.HIG_CONFIGURATION)===null||n===void 0)&&n.enableOnHoverClass))return e;var r=t?.stylesWithHoverClass.get(e);if(r)return r;var i=Nt(e,{silent:!0});if(!i.stylesheet)return e;var s=[];if(i.stylesheet.rules.forEach(function(c){"selectors"in c&&(c.selectors||[]).forEach(function(o){Ie.test(o)&&s.push(o)})}),s.length===0)return e;var a=new RegExp(s.filter(function(c,o){return s.indexOf(c)===o}).sort(function(c,o){return o.length-c.length}).map(function(c){return wt(c)}).join("|"),"g"),u=e.replace(a,function(c){var o=c.replace(bt,"$1.\\:hover");return c+", "+o});return t?.stylesWithHoverClass.set(e,u),u}function ke(){var e=new Map;return{stylesWithHoverClass:e}}function Dt(e,t){var n=t.doc,r=t.hackCss,i=t.cache;switch(e.type){case R.Document:return n.implementation.createDocument(null,"",null);case R.DocumentType:return n.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case R.Element:var s=Et(e),a;e.isSVG?a=n.createElementNS("http://www.w3.org/2000/svg",s):a=n.createElement(s);var u=function(d){if(!e.attributes.hasOwnProperty(d))return"continue";var h=e.attributes[d];if(s==="option"&&d==="selected"&&h===!1)return"continue";if(h=typeof h=="boolean"||typeof h=="number"?"":h,d.startsWith("rr_")){if(s==="canvas"&&d==="rr_dataURL"){var f=document.createElement("img");f.src=h,f.onload=function(){var _=a.getContext("2d");_&&_.drawImage(f,0,0,f.width,f.height)}}else if(s==="img"&&d==="rr_dataURL"){var N=a;N.currentSrc.startsWith("data:")||(N.setAttribute("rrweb-original-src",e.attributes.src),N.src=h,N.setAttribute("rrweb-inline-src",h))}if(d==="rr_width")a.style.width=h;else if(d==="rr_height")a.style.height=h;else if(d==="rr_mediaCurrentTime")a.currentTime=e.attributes.rr_mediaCurrentTime;else if(d==="rr_mediaState")switch(h){case"played":a.play().catch(function(_){return console.warn("media playback error",_)});break;case"paused":a.pause();break}}else{var y=s==="textarea"&&d==="value",v=s==="style"&&d==="_cssText";if(v&&r&&(h=Oe(h,i),typeof h=="string")){for(var m=/url\(\"https:\/\/\S*(.eot|.woff2|.ttf|.woff)\S*\"\)/gm,T=void 0,w=[],A="https://replay-cors-proxy.highlightrun.workers.dev";(T=m.exec(h))!==null;)T.index===m.lastIndex&&m.lastIndex++,T.forEach(function(_,te){if(te===0){var H=_.slice(5,_.length-2);w.push({originalUrl:H,proxyUrl:H.replace(H,A+"?url="+H)})}});w.forEach(function(_){h=h.replace(_.originalUrl,_.proxyUrl)})}if(y||v){for(var L=n.createTextNode(h),O=0,U=Array.from(a.childNodes);O<U.length;O++){var j=U[O];j.nodeType===a.TEXT_NODE&&a.removeChild(j)}return a.appendChild(L),"continue"}try{if(e.isSVG&&d==="xlink:href")a.setAttributeNS("http://www.w3.org/1999/xlink",d,h);else if(d==="onload"||d==="onclick"||d.substring(0,7)==="onmouse")a.setAttribute("_"+d,h);else{if(s==="meta"&&e.attributes["http-equiv"]==="Content-Security-Policy"&&d==="content")return a.setAttribute("csp-content",h),"continue";s==="link"&&e.attributes.rel==="preload"&&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?a.setAttribute("rrweb-original-srcset",e.attributes.srcset):a.setAttribute(d,h))}}catch{}}};for(var c in e.attributes)u(c);if(s==="img"){var o=a;if(!o.currentSrc.startsWith("data:")){var l=o.getAttribute("rrweb-inline-src");l!=null&&l.startsWith("data:")&&(o.src=l)}}if(e.isShadowHost)if(!a.shadowRoot)a.attachShadow({mode:"open"});else for(;a.shadowRoot.firstChild;)a.shadowRoot.removeChild(a.shadowRoot.firstChild);return a;case R.Text:return n.createTextNode(e.isStyle&&r?Oe(e.textContent,i):e.textContent);case R.CDATA:return n.createCDATASection(e.textContent);case R.Comment:return n.createComment(e.textContent);default:return null}}function ie(e,t){var n=t.doc,r=t.mirror,i=t.skipChild,s=i===void 0?!1:i,a=t.hackCss,u=a===void 0?!0:a,c=t.afterAppend,o=t.cache,l=Dt(e,{doc:n,hackCss:u,cache:o});if(!l)return null;if(e.rootId&&console.assert(r.getNode(e.rootId)===n,"Target document should have the same root id."),e.type===R.Document&&(n.close(),n.open(),e.compatMode==="BackCompat"&&e.childNodes&&e.childNodes[0].type!==R.DocumentType&&(e.childNodes[0].type===R.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===R.Document||e.type===R.Element)&&!s)for(var d=0,h=e.childNodes;d<h.length;d++){var f=h[d],N=ie(f,{doc:n,mirror:r,skipChild:!1,hackCss:u,afterAppend:c,cache:o});if(!N){console.warn("Failed to rebuild",f);continue}f.isShadow&&vt(l)&&l.shadowRoot?l.shadowRoot.appendChild(N):l.appendChild(N),c&&c(N)}return l}function Mt(e,t){function n(a){t(a)}for(var r=0,i=e.getIds();r<i.length;r++){var s=i[r];e.has(s)&&n(e.getNode(s))}}function Ct(e,t){var n=t.getMeta(e);if(n?.type===R.Element){var r=e;for(var i in n.attributes)if(n.attributes.hasOwnProperty(i)&&i.startsWith("rr_")){var s=n.attributes[i];i==="rr_scrollLeft"&&(r.scrollLeft=s),i==="rr_scrollTop"&&(r.scrollTop=s)}}}function St(e,t){var n=t.doc,r=t.onVisit,i=t.hackCss,s=i===void 0?!0:i,a=t.afterAppend,u=t.cache,c=t.mirror,o=c===void 0?new xe:c,l=ie(e,{doc:n,mirror:o,skipChild:!1,hackCss:s,afterAppend:a,cache:u});return Mt(o,function(d){r&&r(d),Ct(d,o)}),l}var E;(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"})(E||(E={}));var xt=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(t){var n;if(!t)return-1;var r=(n=this.getMeta(t))===null||n===void 0?void 0:n.id;return r??-1},e.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},e.prototype.removeNodeFromMap=function(t){var n=this,r=this.getId(t);this.idNodeMap.delete(r),t.childNodes&&t.childNodes.forEach(function(i){return n.removeNodeFromMap(i)})},e.prototype.has=function(t){return this.idNodeMap.has(t)},e.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},e.prototype.add=function(t,n){var r=n.id;this.idNodeMap.set(r,t),this.nodeMetaMap.set(t,n)},e.prototype.replace=function(t,n){this.idNodeMap.set(t,n)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function Rt(){return new xt}function At(e){const t={},n=/;(?![^(]*\))/g,r=/:(.+)/,i=/\/\*.*?\*\//g;return e.replace(i,"").split(n).forEach(function(s){if(s){const a=s.split(r);a.length>1&&(t[pe(a[0].trim())]=a[1].trim())}}),t}function _e(e){const t=[];for(const n in e){const r=e[n];if(typeof r!="string")continue;const i=_t(n);t.push(`${i}: ${r};`)}return t.join(" ")}const It=/-([a-z])/g,Ot=/^--[a-zA-Z0-9-]+$/,pe=e=>Ot.test(e)?e:e.replace(It,(t,n)=>n?n.toUpperCase():""),kt=/\B([A-Z])/g,_t=e=>e.replace(kt,"-$1").toLowerCase();class F{constructor(...t){this.childNodes=[],this.parentElement=null,this.parentNode=null,this.ELEMENT_NODE=C.ELEMENT_NODE,this.TEXT_NODE=C.TEXT_NODE}get firstChild(){return this.childNodes[0]||null}get lastChild(){return this.childNodes[this.childNodes.length-1]||null}get nextSibling(){const t=this.parentNode;if(!t)return null;const n=t.childNodes,r=n.indexOf(this);return n[r+1]||null}contains(t){if(t===this)return!0;for(const n of this.childNodes)if(n.contains(t))return!0;return!1}appendChild(t){throw new Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(t,n){throw new Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(t){throw new Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}function Lt(e){return class yt extends e{constructor(){super(...arguments),this.nodeType=C.DOCUMENT_NODE,this.nodeName="#document",this.compatMode="CSS1Compat",this.RRNodeType=E.Document,this.textContent=null}get documentElement(){return this.childNodes.find(n=>n.RRNodeType===E.Element&&n.tagName==="HTML")||null}get body(){var n;return((n=this.documentElement)===null||n===void 0?void 0:n.childNodes.find(r=>r.RRNodeType===E.Element&&r.tagName==="BODY"))||null}get head(){var n;return((n=this.documentElement)===null||n===void 0?void 0:n.childNodes.find(r=>r.RRNodeType===E.Element&&r.tagName==="HEAD"))||null}get implementation(){return this}get firstElementChild(){return this.documentElement}appendChild(n){const r=n.RRNodeType;if((r===E.Element||r===E.DocumentType)&&this.childNodes.some(i=>i.RRNodeType===r))throw new Error(`RRDomException: Failed to execute 'appendChild' on 'RRNode': Only one ${r===E.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);return n.parentElement=null,n.parentNode=this,this.childNodes.push(n),n}insertBefore(n,r){const i=n.RRNodeType;if((i===E.Element||i===E.DocumentType)&&this.childNodes.some(a=>a.RRNodeType===i))throw new Error(`RRDomException: Failed to execute 'insertBefore' on 'RRNode': Only one ${i===E.Element?"RRElement":"RRDoctype"} on RRDocument allowed.`);if(r===null)return this.appendChild(n);const s=this.childNodes.indexOf(r);if(s==-1)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return this.childNodes.splice(s,0,n),n.parentElement=null,n.parentNode=this,n}removeChild(n){const r=this.childNodes.indexOf(n);if(r===-1)throw new Error("Failed to execute 'removeChild' on 'RRDocument': The RRNode to be removed is not a child of this RRNode.");return this.childNodes.splice(r,1),n.parentElement=null,n.parentNode=null,n}open(){this.childNodes=[]}close(){}write(n){let r;if(n==='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">'?r="-//W3C//DTD XHTML 1.0 Transitional//EN":n==='<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "">'&&(r="-//W3C//DTD HTML 4.0 Transitional//EN"),r){const i=this.createDocumentType("html",r,"");this.open(),this.appendChild(i)}}createDocument(n,r,i){return new yt}createDocumentType(n,r,i){const s=new(Le(F))(n,r,i);return s.ownerDocument=this,s}createElement(n){const r=new(Pe(F))(n);return r.ownerDocument=this,r}createElementNS(n,r){return this.createElement(r)}createTextNode(n){const r=new(Fe(F))(n);return r.ownerDocument=this,r}createComment(n){const r=new($e(F))(n);return r.ownerDocument=this,r}createCDATASection(n){const r=new(Ue(F))(n);return r.ownerDocument=this,r}toString(){return"RRDocument"}}}function Le(e){return class extends e{constructor(t,n,r){super(),this.nodeType=C.DOCUMENT_TYPE_NODE,this.RRNodeType=E.DocumentType,this.textContent=null,this.name=t,this.publicId=n,this.systemId=r,this.nodeName=t}toString(){return"RRDocumentType"}}}function Pe(e){return class extends e{constructor(t){super(),this.nodeType=C.ELEMENT_NODE,this.RRNodeType=E.Element,this.attributes={},this.shadowRoot=null,this.tagName=t.toUpperCase(),this.nodeName=t.toUpperCase()}get textContent(){let t="";return this.childNodes.forEach(n=>t+=n.textContent),t}set textContent(t){this.childNodes=[this.ownerDocument.createTextNode(t)]}get classList(){return new Ft(this.attributes.class,t=>{this.attributes.class=t})}get id(){return this.attributes.id||""}get className(){return this.attributes.class||""}get style(){const t=this.attributes.style?At(this.attributes.style):{},n=/\B([A-Z])/g;return t.setProperty=(r,i,s)=>{if(n.test(r))return;const a=pe(r);i?t[a]=i:delete t[a],s==="important"&&(t[a]+=" !important"),this.attributes.style=_e(t)},t.removeProperty=r=>{if(n.test(r))return"";const i=pe(r),s=t[i]||"";return delete t[i],this.attributes.style=_e(t),s},t}getAttribute(t){return this.attributes[t]||null}setAttribute(t,n){this.attributes[t]=n}setAttributeNS(t,n,r){this.setAttribute(n,r)}removeAttribute(t){delete this.attributes[t]}appendChild(t){return this.childNodes.push(t),t.parentNode=this,t.parentElement=this,t}insertBefore(t,n){if(n===null)return this.appendChild(t);const r=this.childNodes.indexOf(n);if(r==-1)throw new Error("Failed to execute 'insertBefore' on 'RRNode': The RRNode before which the new node is to be inserted is not a child of this RRNode.");return this.childNodes.splice(r,0,t),t.parentElement=this,t.parentNode=this,t}removeChild(t){const n=this.childNodes.indexOf(t);if(n===-1)throw new Error("Failed to execute 'removeChild' on 'RRElement': The RRNode to be removed is not a child of this RRNode.");return this.childNodes.splice(n,1),t.parentElement=null,t.parentNode=null,t}attachShadow(t){const n=this.ownerDocument.createElement("SHADOWROOT");return this.shadowRoot=n,n}dispatchEvent(t){return!0}toString(){let t="";for(const n in this.attributes)t+=`${n}="${this.attributes[n]}" `;return`${this.tagName} ${t}`}}}function Pt(e){return class extends e{attachShadow(t){throw new Error("RRDomException: Failed to execute 'attachShadow' on 'RRElement': This RRElement does not support attachShadow")}play(){this.paused=!1}pause(){this.paused=!0}}}function Fe(e){return class extends e{constructor(t){super(),this.nodeType=C.TEXT_NODE,this.nodeName="#text",this.RRNodeType=E.Text,this.data=t}get textContent(){return this.data}set textContent(t){this.data=t}toString(){return`RRText text=${JSON.stringify(this.data)}`}}}function $e(e){return class extends e{constructor(t){super(),this.nodeType=C.COMMENT_NODE,this.nodeName="#comment",this.RRNodeType=E.Comment,this.data=t}get textContent(){return this.data}set textContent(t){this.data=t}toString(){return`RRComment text=${JSON.stringify(this.data)}`}}}function Ue(e){return class extends e{constructor(t){super(),this.nodeName="#cdata-section",this.nodeType=C.CDATA_SECTION_NODE,this.RRNodeType=E.CDATA,this.data=t}get textContent(){return this.data}set textContent(t){this.data=t}toString(){return`RRCDATASection data=${JSON.stringify(this.data)}`}}}class Ft{constructor(t,n){if(this.classes=[],this.add=(...r)=>{for(const i of r){const s=String(i);this.classes.indexOf(s)>=0||this.classes.push(s)}this.onChange&&this.onChange(this.classes.join(" "))},this.remove=(...r)=>{this.classes=this.classes.filter(i=>r.indexOf(i)===-1),this.onChange&&this.onChange(this.classes.join(" "))},t){const r=t.trim().split(/\s+/);this.classes.push(...r)}this.onChange=n}}var C;(function(e){e[e.PLACEHOLDER=0]="PLACEHOLDER",e[e.ELEMENT_NODE=1]="ELEMENT_NODE",e[e.ATTRIBUTE_NODE=2]="ATTRIBUTE_NODE",e[e.TEXT_NODE=3]="TEXT_NODE",e[e.CDATA_SECTION_NODE=4]="CDATA_SECTION_NODE",e[e.ENTITY_REFERENCE_NODE=5]="ENTITY_REFERENCE_NODE",e[e.ENTITY_NODE=6]="ENTITY_NODE",e[e.PROCESSING_INSTRUCTION_NODE=7]="PROCESSING_INSTRUCTION_NODE",e[e.COMMENT_NODE=8]="COMMENT_NODE",e[e.DOCUMENT_NODE=9]="DOCUMENT_NODE",e[e.DOCUMENT_TYPE_NODE=10]="DOCUMENT_TYPE_NODE",e[e.DOCUMENT_FRAGMENT_NODE=11]="DOCUMENT_FRAGMENT_NODE"})(C||(C={}));const fe={svg:"http://www.w3.org/2000/svg","xlink:href":"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/2000/xmlns/"};function B(e,t,n,r){const i=e.childNodes,s=t.childNodes;r=r||t.mirror||t.ownerDocument.mirror,(i.length>0||s.length>0)&&Be(Array.from(i),s,e,n,r);let a=null,u=null;switch(t.RRNodeType){case E.Document:{u=t.scrollData;break}case E.Element:{const c=e,o=t;switch($t(c,o,r),u=o.scrollData,a=o.inputData,o.tagName){case"AUDIO":case"VIDEO":{const l=e,d=o;d.paused!==void 0&&(d.paused?l.pause():l.play()),d.muted!==void 0&&(l.muted=d.muted),d.volume!==void 0&&(l.volume=d.volume),d.currentTime!==void 0&&(l.currentTime=d.currentTime);break}case"CANVAS":t.canvasMutations.forEach(l=>n.applyCanvas(l.event,l.mutation,e));break;case"STYLE":Ut(c,t.rules);break}if(o.shadowRoot){c.shadowRoot||c.attachShadow({mode:"open"});const l=c.shadowRoot.childNodes,d=o.shadowRoot.childNodes;(l.length>0||d.length>0)&&Be(Array.from(l),d,c.shadowRoot,n,r)}break}case E.Text:case E.Comment:case E.CDATA:e.textContent!==t.data&&(e.textContent=t.data);break}if(u&&n.applyScroll(u,!0),a&&n.applyInput(a),t.nodeName==="IFRAME"){const c=e.contentDocument,o=t;if(c){const l=r.getMeta(o.contentDocument);l&&n.mirror.add(c,Object.assign({},l)),B(c,o.contentDocument,n,r)}}}function $t(e,t,n){const r=e.attributes,i=t.attributes;for(const s in i){const a=i[s],u=n.getMeta(t);if(u&&"isSVG"in u&&u.isSVG&&fe[s])e.setAttributeNS(fe[s],s,a);else if(t.tagName==="CANVAS"&&s==="rr_dataURL"){const c=document.createElement("img");c.src=a,c.onload=()=>{const o=e.getContext("2d");o&&o.drawImage(c,0,0,c.width,c.height)}}else e.setAttribute(s,a)}for(const{name:s}of Array.from(r))s in i||e.removeAttribute(s);t.scrollLeft&&(e.scrollLeft=t.scrollLeft),t.scrollTop&&(e.scrollTop=t.scrollTop)}function Be(e,t,n,r,i){var s;let a=0,u=e.length-1,c=0,o=t.length-1,l=e[a],d=e[u],h=t[c],f=t[o],N,y;for(;a<=u&&c<=o;)if(l===void 0)l=e[++a];else if(d===void 0)d=e[--u];else if(r.mirror.getId(l)===i.getId(h))B(l,h,r,i),l=e[++a],h=t[++c];else if(r.mirror.getId(d)===i.getId(f))B(d,f,r,i),d=e[--u],f=t[--o];else if(r.mirror.getId(l)===i.getId(f))try{n.insertBefore(l,d.nextSibling),B(l,f,r,i),l=e[++a],f=t[--o]}catch(v){console.error(v,n,l,d)}else if(r.mirror.getId(d)===i.getId(h))try{n.insertBefore(d,l),B(d,h,r,i),d=e[--u],h=t[++c]}catch(v){console.error(v,n,d,l)}else{if(!N){N={};for(let v=a;v<=u;v++){const m=e[v];m&&r.mirror.hasNode(m)&&(N[r.mirror.getId(m)]=v)}}if(y=N[i.getId(h)],y){const v=e[y];try{n.insertBefore(v,l),B(v,h,r,i),e[y]=void 0}catch(m){console.error(m,n,v,l)}}else{const v=ge(h,r.mirror,i);n.nodeName==="#document"&&((s=r.mirror.getMeta(v))===null||s===void 0?void 0:s.type)===E.Element&&n.documentElement&&(n.removeChild(n.documentElement),e[a]=void 0,l=void 0);try{n.insertBefore(v,l||null),B(v,h,r,i)}catch(m){console.error(m,n,v,l||null)}}h=t[++c]}if(a>u){const v=t[o+1];let m=null;for(v&&n.childNodes.forEach(T=>{r.mirror.getId(T)===i.getId(v)&&(m=T)});c<=o;++c){const T=ge(t[c],r.mirror,i);try{n.insertBefore(T,m),B(T,t[c],r,i)}catch(w){console.error(w,n,T,m)}}}else if(c>o)for(;a<=u;a++){const v=e[a];v&&(n.removeChild(v),r.mirror.removeNodeFromMap(v))}}function ge(e,t,n){let r=t.getNode(n.getId(e));const i=n.getMeta(e);if(r!==null)return r;switch(e.RRNodeType){case E.Document:r=new Document;break;case E.DocumentType:r=document.implementation.createDocumentType(e.name,e.publicId,e.systemId);break;case E.Element:{e.tagName.toLowerCase(),i&&"isSVG"in i&&i?.isSVG?r=document.createElementNS(fe.svg,e.tagName.toLowerCase()):r=document.createElement(e.tagName);break}case E.Text:r=document.createTextNode(e.data);break;case E.Comment:r=document.createComment(e.data);break;case E.CDATA:r=document.createCDATASection(e.data);break}return i&&t.add(r,Object.assign({},i)),r}function J(e,t){const n=e[t[0]];return t.length===1?n:J(n.cssRules[t[1]].cssRules,t.slice(2))}var $;(function(e){e[e.Insert=0]="Insert",e[e.Remove=1]="Remove",e[e.Snapshot=2]="Snapshot",e[e.SetProperty=3]="SetProperty",e[e.RemoveProperty=4]="RemoveProperty"})($||($={}));function Ve(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function Ut(e,t){const n=e.sheet;t.forEach(r=>{if(r.type===$.Insert)try{if(Array.isArray(r.index)){const{positions:i,index:s}=Ve(r.index);J(n.cssRules,i).insertRule(r.cssText,s)}else n.insertRule(r.cssText,r.index)}catch{}else if(r.type===$.Remove)try{if(Array.isArray(r.index)){const{positions:i,index:s}=Ve(r.index);J(n.cssRules,i).deleteRule(s||0)}else n.deleteRule(r.index)}catch{}else r.type===$.SetProperty?J(n.cssRules,r.index).style.setProperty(r.property,r.value,r.priority):r.type===$.RemoveProperty&&J(n.cssRules,r.index).style.removeProperty(r.property)})}class Y extends Lt(F){constructor(t){super(),this._unserializedId=-1,this.mirror=qt(),this.scrollData=null,t&&(this.mirror=t)}get unserializedId(){return this._unserializedId--}createDocument(t,n,r){return new Y}createDocumentType(t,n,r){const i=new Bt(t,n,r);return i.ownerDocument=this,i}createElement(t){const n=t.toUpperCase();let r;switch(n){case"AUDIO":case"VIDEO":r=new Vt(n);break;case"IFRAME":r=new Ht(n,this.mirror);break;case"CANVAS":r=new Wt(n);break;case"STYLE":r=new jt(n);break;default:r=new Z(n);break}return r.ownerDocument=this,r}createComment(t){const n=new Yt(t);return n.ownerDocument=this,n}createCDATASection(t){const n=new zt(t);return n.ownerDocument=this,n}createTextNode(t){const n=new Gt(t);return n.ownerDocument=this,n}destroyTree(){this.childNodes=[],this.mirror.reset()}open(){super.open(),this._unserializedId=-1}}const Bt=Le(F);class Z extends Pe(F){constructor(){super(...arguments),this.inputData=null,this.scrollData=null}}class Vt extends Pt(Z){}class Wt extends Z{constructor(){super(...arguments),this.canvasMutations=[]}getContext(){return null}}class jt extends Z{constructor(){super(...arguments),this.rules=[]}}class Ht extends Z{constructor(t,n){super(t),this.contentDocument=new Y,this.contentDocument.mirror=n}}const Gt=Fe(F),Yt=$e(F),zt=Ue(F);function Xt(e){return e instanceof HTMLFormElement?"FORM":e.tagName.toUpperCase()}function We(e,t,n,r){let i;switch(e.nodeType){case C.DOCUMENT_NODE:r&&r.nodeName==="IFRAME"?i=r.contentDocument:(i=t,i.compatMode=e.compatMode);break;case C.DOCUMENT_TYPE_NODE:const a=e;i=t.createDocumentType(a.name,a.publicId,a.systemId);break;case C.ELEMENT_NODE:const u=e,c=Xt(u);i=t.createElement(c);const o=i;for(const{name:l,value:d}of Array.from(u.attributes))o.attributes[l]=d;u.scrollLeft&&(o.scrollLeft=u.scrollLeft),u.scrollTop&&(o.scrollTop=u.scrollTop);break;case C.TEXT_NODE:i=t.createTextNode(e.textContent||"");break;case C.CDATA_SECTION_NODE:i=t.createCDATASection(e.data);break;case C.COMMENT_NODE:i=t.createComment(e.textContent||"");break;case C.DOCUMENT_FRAGMENT_NODE:i=r.attachShadow({mode:"open"});break;default:return null}let s=n.getMeta(e);return t instanceof Y&&(s||(s=je(i,t.unserializedId),n.add(e,s)),t.mirror.add(i,Object.assign({},s))),i}function Qt(e,t=Rt(),n=new Y){function r(i,s){const a=We(i,n,t,s);a!==null&&(s?.nodeName!=="IFRAME"&&i.nodeType!==C.DOCUMENT_FRAGMENT_NODE&&(s?.appendChild(a),a.parentNode=s,a.parentElement=s),i.nodeName==="IFRAME"?r(i.contentDocument,a):(i.nodeType===C.DOCUMENT_NODE||i.nodeType===C.ELEMENT_NODE||i.nodeType===C.DOCUMENT_FRAGMENT_NODE)&&(i.nodeType===C.ELEMENT_NODE&&i.shadowRoot&&r(i.shadowRoot,a),i.childNodes.forEach(u=>r(u,a))))}return r(e,null),n}function qt(){return new Jt}class Jt{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){this.idNodeMap.set(t,n)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function je(e,t){switch(e.RRNodeType){case E.Document:return{id:t,type:e.RRNodeType,childNodes:[]};case E.DocumentType:const n=e;return{id:t,type:e.RRNodeType,name:n.name,publicId:n.publicId,systemId:n.systemId};case E.Element:return{id:t,type:e.RRNodeType,tagName:e.tagName.toLowerCase(),attributes:{},childNodes:[]};case E.Text:return{id:t,type:e.RRNodeType,textContent:e.textContent||""};case E.Comment:return{id:t,type:e.RRNodeType,textContent:e.textContent||""};case E.CDATA:return{id:t,type:e.RRNodeType,textContent:""}}}function He(e){return e=e||Object.create(null),{on:function(n,r){(e[n]||(e[n]=[])).push(r)},off:function(n,r){e[n]&&e[n].splice(e[n].indexOf(r)>>>0,1)},emit:function(n,r){(e[n]||[]).slice().map(function(i){i(r)}),(e["*"]||[]).slice().map(function(i){i(n,r)})}}}var Zt=Object.freeze({__proto__:null,default:He});function Kt(e=window,t=document){if("scrollBehavior"in t.documentElement.style&&e.__forceSmoothScrollPolyfill__!==!0)return;const n=e.HTMLElement||e.Element,r=468,i={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:n.prototype.scroll||c,scrollIntoView:n.prototype.scrollIntoView},s=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now;function a(m){const T=["MSIE ","Trident/","Edge/"];return new RegExp(T.join("|")).test(m)}const u=a(e.navigator.userAgent)?1:0;function c(m,T){this.scrollLeft=m,this.scrollTop=T}function o(m){return .5*(1-Math.cos(Math.PI*m))}function l(m){if(m===null||typeof m!="object"||m.behavior===void 0||m.behavior==="auto"||m.behavior==="instant")return!0;if(typeof m=="object"&&m.behavior==="smooth")return!1;throw new TypeError("behavior member of ScrollOptions "+m.behavior+" is not a valid value for enumeration ScrollBehavior.")}function d(m,T){if(T==="Y")return m.clientHeight+u<m.scrollHeight;if(T==="X")return m.clientWidth+u<m.scrollWidth}function h(m,T){const w=e.getComputedStyle(m,null)["overflow"+T];return w==="auto"||w==="scroll"}function f(m){const T=d(m,"Y")&&h(m,"Y"),w=d(m,"X")&&h(m,"X");return T||w}function N(m){for(;m!==t.body&&f(m)===!1;)m=m.parentNode||m.host;return m}function y(m){const T=s();let w,A,L,O=(T-m.startTime)/r;O=O>1?1:O,w=o(O),A=m.startX+(m.x-m.startX)*w,L=m.startY+(m.y-m.startY)*w,m.method.call(m.scrollable,A,L),(A!==m.x||L!==m.y)&&e.requestAnimationFrame(y.bind(e,m))}function v(m,T,w){let A,L,O,U;const j=s();m===t.body?(A=e,L=e.scrollX||e.pageXOffset,O=e.scrollY||e.pageYOffset,U=i.scroll):(A=m,L=m.scrollLeft,O=m.scrollTop,U=c),y({scrollable:A,method:U,startTime:j,startX:L,startY:O,x:T,y:w})}e.scroll=e.scrollTo=function(){if(arguments[0]!==void 0){if(l(arguments[0])===!0){i.scroll.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:e.scrollY||e.pageYOffset);return}v.call(e,t.body,arguments[0].left!==void 0?~~arguments[0].left:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?~~arguments[0].top:e.scrollY||e.pageYOffset)}},e.scrollBy=function(){if(arguments[0]!==void 0){if(l(arguments[0])){i.scrollBy.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:0,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:0);return}v.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset))}},n.prototype.scroll=n.prototype.scrollTo=function(){if(arguments[0]===void 0)return;if(l(arguments[0])===!0){if(typeof arguments[0]=="number"&&arguments[1]===void 0)throw new SyntaxError("Value could not be converted");i.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left:typeof arguments[0]!="object"?~~arguments[0]:this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top:arguments[1]!==void 0?~~arguments[1]:this.scrollTop);return}const m=arguments[0].left,T=arguments[0].top;v.call(this,this,typeof m>"u"?this.scrollLeft:~~m,typeof T>"u"?this.scrollTop:~~T)},n.prototype.scrollBy=function(){if(arguments[0]!==void 0){if(l(arguments[0])===!0){i.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop);return}this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior})}},n.prototype.scrollIntoView=function(){if(l(arguments[0])===!0){i.scrollIntoView.call(this,arguments[0]===void 0?!0:arguments[0]);return}const m=N(this),T=m.getBoundingClientRect(),w=this.getBoundingClientRect();m!==t.body?(v.call(this,m,m.scrollLeft+w.left-T.left,m.scrollTop+w.top-T.top),e.getComputedStyle(m).position!=="fixed"&&e.scrollBy({left:T.left,top:T.top,behavior:"smooth"})):e.scrollBy({left:w.left,top:w.top,behavior:"smooth"})}}var 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||{}),S=(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))(S||{}),k=(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))(k||{}),oe=(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(oe||{}),ye=(e=>(e[e.Play=0]="Play",e[e.Pause=1]="Pause",e[e.Seeked=2]="Seeked",e[e.VolumeChange=3]="VolumeChange",e))(ye||{}),D=(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))(D||{});class en{constructor(t=[],n){this.timeOffset=0,this.raf=null,this.actions=t,this.speed=n}addAction(t){const n=this.findActionIndex(t);this.actions.splice(n,0,t)}addActions(t){this.actions=this.actions.concat(t)}replaceActions(t){this.actions.length=0,this.actions.splice(0,0,...t)}start(){this.timeOffset=0;let t=performance.now();const{actions:n}=this,r=this;function i(){const s=performance.now();for(r.timeOffset+=(s-t)*r.speed,t=s;n.length;){const a=n[0];if(r.timeOffset>=a.delay)n.shift(),a.doAction();else break}(n.length>0||r.liveMode)&&(r.raf=requestAnimationFrame(i))}this.raf=requestAnimationFrame(i)}clear(){this.raf&&(cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0}setSpeed(t){this.speed=t}toggleLiveMode(t){this.liveMode=t}isActive(){return this.raf!==null}findActionIndex(t){let n=0,r=this.actions.length-1;for(;n<=r;){const i=Math.floor((n+r)/2);if(this.actions[i].delay<t.delay)n=i+1;else if(this.actions[i].delay>t.delay)r=i-1;else return i+1}return n}}function ve(e,t){if(e.type===M.IncrementalSnapshot&&e.data.source===S.MouseMove){const n=e.data.positions[0].timeOffset,r=e.timestamp+n;return e.delay=r-t,r-t}return e.delay=e.timestamp-t,e.delay}/*! *****************************************************************************
2
3
  Copyright (c) Microsoft Corporation.
3
4
 
4
5
  Permission to use, copy, modify, and/or distribute this software for any
@@ -11,7 +12,7 @@ var rrwebReplay=function(Q,y){"use strict";function Ke(t){const e={},i=/;(?![^(]
11
12
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
12
13
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13
14
  PERFORMANCE OF THIS SOFTWARE.
14
- ***************************************************************************** */function De(t,e){var i=typeof Symbol=="function"&&t[Symbol.iterator];if(!i)return t;var s,o,r=i.call(t),a=[];try{for(;(e===void 0||e-- >0)&&!(s=r.next()).done;)a.push(s.value)}catch(c){o={error:c}}finally{try{s&&!s.done&&(i=r.return)&&i.call(r)}finally{if(o)throw o.error}}return a}var P;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(P||(P={}));var be={type:"xstate.init"};function te(t){return t===void 0?[]:[].concat(t)}function L(t){return{type:"xstate.assign",assignment:t}}function Re(t,e){return typeof(t=typeof t=="string"&&e&&e[t]?e[t]:t)=="string"?{type:t}:typeof t=="function"?{type:t.name,exec:t}:t}function G(t){return function(e){return t===e}}function we(t){return typeof t=="string"?{type:t}:t}function xe(t,e){return{value:t,context:e,actions:[],changed:!1,matches:G(t)}}function Ce(t,e,i){var s=e,o=!1;return[t.filter(function(r){if(r.type==="xstate.assign"){o=!0;var a=Object.assign({},s);return typeof r.assignment=="function"?a=r.assignment(s,i):Object.keys(r.assignment).forEach(function(c){a[c]=typeof r.assignment[c]=="function"?r.assignment[c](s,i):r.assignment[c]}),s=a,!1}return!0}),s,o]}function Se(t,e){e===void 0&&(e={});var i=De(Ce(te(t.states[t.initial].entry).map(function(a){return Re(a,e.actions)}),t.context,be),2),s=i[0],o=i[1],r={config:t,_options:e,initialState:{value:t.initial,actions:s,context:o,matches:G(t.initial)},transition:function(a,c){var d,n,l=typeof a=="string"?{value:a,context:t.context}:a,u=l.value,m=l.context,p=we(c),T=t.states[u];if(T.on){var g=te(T.on[p.type]);try{for(var f=function(w){var de=typeof Symbol=="function"&&Symbol.iterator,qe=de&&w[de],Je=0;if(qe)return qe.call(w);if(w&&typeof w.length=="number")return{next:function(){return w&&Je>=w.length&&(w=void 0),{value:w&&w[Je++],done:!w}}};throw new TypeError(de?"Object is not iterable.":"Symbol.iterator is not defined.")}(g),h=f.next();!h.done;h=f.next()){var v=h.value;if(v===void 0)return xe(u,m);var E=typeof v=="string"?{target:v}:v,C=E.target,O=E.actions,I=O===void 0?[]:O,B=E.cond,ce=B===void 0?function(){return!0}:B,Kt=C===void 0,ei=C??u,ti=t.states[ei];if(ce(m,p)){var le=De(Ce((Kt?te(I):[].concat(T.exit,I,ti.entry).filter(function(w){return w})).map(function(w){return Re(w,r._options.actions)}),m,p),3),Xe=le[0],ii=le[1],si=le[2],Qe=C??u;return{value:Qe,context:ii,actions:Xe,changed:C!==u||Xe.length>0||si,matches:G(Qe)}}}}catch(w){d={error:w}}finally{try{h&&!h.done&&(n=f.return)&&n.call(f)}finally{if(d)throw d.error}}}return xe(u,m)}};return r}var Me=function(t,e){return t.actions.forEach(function(i){var s=i.exec;return s&&s(t.context,e)})};function Ie(t){var e=t.initialState,i=P.NotStarted,s=new Set,o={_machine:t,send:function(r){i===P.Running&&(e=t.transition(e,r),Me(e,we(r)),s.forEach(function(a){return a(e)}))},subscribe:function(r){return s.add(r),r(e),{unsubscribe:function(){return s.delete(r)}}},start:function(r){if(r){var a=typeof r=="object"?r:{context:t.config.context,value:r};e={value:a.value,actions:[],context:a.context,matches:G(a.value)}}return i=P.Running,Me(e,be),o},stop:function(){return i=P.Stopped,s.clear(),o},get state(){return e},get status(){return i}};return o}var Rt=Object.defineProperty,wt=Object.defineProperties,xt=Object.getOwnPropertyDescriptors,Ae=Object.getOwnPropertySymbols,Ct=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Oe=(t,e,i)=>e in t?Rt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,H=(t,e)=>{for(var i in e||(e={}))Ct.call(e,i)&&Oe(t,i,e[i]);if(Ae)for(var i of Ae(e))St.call(e,i)&&Oe(t,i,e[i]);return t},z=(t,e)=>wt(t,xt(e));function Mt(t,e){for(let i=t.length-1;i>=0;i--){const s=t[i];if(s.type===D.Meta&&s.timestamp<=e)return t.slice(i)}return t}function It(t,{getCastFn:e,applyEventsSynchronously:i,emitter:s}){const o=Se({id:"player",context:t,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]},REPLACE_EVENTS:{target:"playing",actions:["replaceEvents"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]},REPLACE_EVENTS:{target:"paused",actions:["replaceEvents"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:L({lastPlayedEvent:(r,a)=>a.type==="CAST_EVENT"?a.payload.event:r.lastPlayedEvent}),recordTimeOffset:L((r,a)=>{let c=r.timeOffset;return"payload"in a&&"timeOffset"in a.payload&&(c=a.payload.timeOffset),z(H({},r),{timeOffset:c,baselineTime:r.events[0].timestamp+c})}),play(r){var a;const{timer:c,events:d,baselineTime:n,lastPlayedEvent:l}=r;c.clear();for(const g of d)ee(g,n);const u=Mt(d,n);let m=l?.timestamp;l?.type===D.IncrementalSnapshot&&l.data.source===R.MouseMove&&(m=l.timestamp+((a=l.data.positions[0])==null?void 0:a.timeOffset)),n<(m||0)&&s.emit(N.PlayBack);const p=new Array,T=new Array;for(const g of u)if(!(m&&m<n&&(g.timestamp<=m||g===l)))if(g.timestamp<n)p.push(g);else{const f=e(g,!1);T.push({doAction:()=>{f()},delay:g.delay})}i(p),s.emit(N.Flush),c.addActions(T),c.start()},pause(r){r.timer.clear()},resetLastPlayedEvent:L(r=>z(H({},r),{lastPlayedEvent:null})),startLive:L({baselineTime:(r,a)=>(r.timer.toggleLiveMode(!0),r.timer.start(),a.type==="TO_LIVE"&&a.payload.baselineTime?a.payload.baselineTime:Date.now())}),replaceEvents:L((r,a)=>{const{events:c,timer:d,baselineTime:n}=r;if(a.type==="REPLACE_EVENTS"){const{events:l}=a.payload;c.length=0;const u=[];for(const m of l)if(ee(m,n),c.push(m),m.timestamp>=d.timeOffset+n){const p=e(m,!1);u.push({doAction:()=>{p()},delay:m.delay})}d.isActive()&&d.replaceActions(u)}return z(H({},r),{events:c})}),addEvent:L((r,a)=>{const{baselineTime:c,timer:d,events:n}=r;if(a.type==="ADD_EVENT"){const{event:l}=a.payload;ee(l,c);let u=n.length-1;if(!n[u]||n[u].timestamp<=l.timestamp)n.push(l);else{let T=-1,g=0;for(;g<=u;){const f=Math.floor((g+u)/2);n[f].timestamp<=l.timestamp?g=f+1:u=f-1}T===-1&&(T=g),n.splice(T,0,l)}const m=l.timestamp<c,p=e(l,m);m?p():d.isActive()&&d.addAction({doAction:()=>{p()},delay:l.delay})}return z(H({},r),{events:n})})}});return Ie(o)}function At(t){const e=Se({id:"speed",context:t,initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:(i,s)=>{"payload"in s&&i.timer.setSpeed(s.payload.speed)},recordSpeed:L({normalSpeed:i=>i.timer.speed}),restoreSpeed:i=>{i.timer.setSpeed(i.normalSpeed)}}});return Ie(e)}const F=`Please stop import mirror directly. Instead of that,\r
15
+ ***************************************************************************** */function Ge(e,t){var n=typeof Symbol=="function"&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),a=[];try{for(;(t===void 0||t-- >0)&&!(r=s.next()).done;)a.push(r.value)}catch(u){i={error:u}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return a}var z;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(z||(z={}));var Ye={type:"xstate.init"};function Te(e){return e===void 0?[]:[].concat(e)}function G(e){return{type:"xstate.assign",assignment:e}}function ze(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function se(e){return function(t){return e===t}}function Xe(e){return typeof e=="string"?{type:e}:e}function Qe(e,t){return{value:e,context:t,actions:[],changed:!1,matches:se(e)}}function qe(e,t,n){var r=t,i=!1;return[e.filter(function(s){if(s.type==="xstate.assign"){i=!0;var a=Object.assign({},r);return typeof s.assignment=="function"?a=s.assignment(r,n):Object.keys(s.assignment).forEach(function(u){a[u]=typeof s.assignment[u]=="function"?s.assignment[u](r,n):s.assignment[u]}),r=a,!1}return!0}),r,i]}function Je(e,t){t===void 0&&(t={});var n=Ge(qe(Te(e.states[e.initial].entry).map(function(a){return ze(a,t.actions)}),e.context,Ye),2),r=n[0],i=n[1],s={config:e,_options:t,initialState:{value:e.initial,actions:r,context:i,matches:se(e.initial)},transition:function(a,u){var c,o,l=typeof a=="string"?{value:a,context:e.context}:a,d=l.value,h=l.context,f=Xe(u),N=e.states[d];if(N.on){var y=Te(N.on[f.type]);try{for(var v=function(I){var re=typeof Symbol=="function"&&Symbol.iterator,g=re&&I[re],p=0;if(g)return g.call(I);if(I&&typeof I.length=="number")return{next:function(){return I&&p>=I.length&&(I=void 0),{value:I&&I[p++],done:!I}}};throw new TypeError(re?"Object is not iterable.":"Symbol.iterator is not defined.")}(y),m=v.next();!m.done;m=v.next()){var T=m.value;if(T===void 0)return Qe(d,h);var w=typeof T=="string"?{target:T}:T,A=w.target,L=w.actions,O=L===void 0?[]:L,U=w.cond,j=U===void 0?function(){return!0}:U,_=A===void 0,te=A??d,H=e.states[te];if(j(h,f)){var ne=Ge(qe((_?Te(O):[].concat(N.exit,O,H.entry).filter(function(I){return I})).map(function(I){return ze(I,s._options.actions)}),h,f),3),ue=ne[0],Ce=ne[1],Se=ne[2],q=A??d;return{value:q,context:Ce,actions:ue,changed:A!==d||ue.length>0||Se,matches:se(q)}}}}catch(I){c={error:I}}finally{try{m&&!m.done&&(o=v.return)&&o.call(v)}finally{if(c)throw c.error}}}return Qe(d,h)}};return s}var Ze=function(e,t){return e.actions.forEach(function(n){var r=n.exec;return r&&r(e.context,t)})};function Ke(e){var t=e.initialState,n=z.NotStarted,r=new Set,i={_machine:e,send:function(s){n===z.Running&&(t=e.transition(t,s),Ze(t,Xe(s)),r.forEach(function(a){return a(t)}))},subscribe:function(s){return r.add(s),s(t),{unsubscribe:function(){return r.delete(s)}}},start:function(s){if(s){var a=typeof s=="object"?s:{context:e.config.context,value:s};t={value:a.value,actions:[],context:a.context,matches:se(a.value)}}return n=z.Running,Ze(t,Ye),i},stop:function(){return n=z.Stopped,r.clear(),i},get state(){return t},get status(){return n}};return i}var tn=Object.defineProperty,nn=Object.defineProperties,rn=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,sn=Object.prototype.propertyIsEnumerable,tt=(e,t,n)=>t in e?tn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ae=(e,t)=>{for(var n in t||(t={}))on.call(t,n)&&tt(e,n,t[n]);if(et)for(var n of et(t))sn.call(t,n)&&tt(e,n,t[n]);return e},ce=(e,t)=>nn(e,rn(t));function an(e,t){for(let n=e.length-1;n>=0;n--){const r=e[n];if(r.type===M.Meta&&r.timestamp<=t)return e.slice(n)}return e}function cn(e,{getCastFn:t,applyEventsSynchronously:n,emitter:r}){const i=Je({id:"player",context:e,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]},REPLACE_EVENTS:{target:"playing",actions:["replaceEvents"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]},REPLACE_EVENTS:{target:"paused",actions:["replaceEvents"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:G({lastPlayedEvent:(s,a)=>a.type==="CAST_EVENT"?a.payload.event:s.lastPlayedEvent}),recordTimeOffset:G((s,a)=>{let u=s.timeOffset;return"payload"in a&&"timeOffset"in a.payload&&(u=a.payload.timeOffset),ce(ae({},s),{timeOffset:u,baselineTime:s.events[0].timestamp+u})}),play(s){var a;const{timer:u,events:c,baselineTime:o,lastPlayedEvent:l}=s;u.clear();for(const y of c)ve(y,o);const d=an(c,o);let h=l?.timestamp;l?.type===M.IncrementalSnapshot&&l.data.source===S.MouseMove&&(h=l.timestamp+((a=l.data.positions[0])==null?void 0:a.timeOffset)),o<(h||0)&&r.emit(D.PlayBack);const f=new Array,N=new Array;for(const y of d)if(!(h&&h<o&&(y.timestamp<=h||y===l)))if(y.timestamp<o)f.push(y);else{const v=t(y,!1);N.push({doAction:()=>{v()},delay:y.delay})}n(f),r.emit(D.Flush),u.addActions(N),u.start()},pause(s){s.timer.clear()},resetLastPlayedEvent:G(s=>ce(ae({},s),{lastPlayedEvent:null})),startLive:G({baselineTime:(s,a)=>(s.timer.toggleLiveMode(!0),s.timer.start(),a.type==="TO_LIVE"&&a.payload.baselineTime?a.payload.baselineTime:Date.now())}),replaceEvents:G((s,a)=>{const{events:u,timer:c,baselineTime:o}=s;if(a.type==="REPLACE_EVENTS"){const{events:l}=a.payload;u.length=0;const d=[];for(const h of l)if(ve(h,o),u.push(h),h.timestamp>=c.timeOffset+o){const f=t(h,!1);d.push({doAction:()=>{f()},delay:h.delay})}c.isActive()&&c.replaceActions(d)}return ce(ae({},s),{events:u})}),addEvent:G((s,a)=>{const{baselineTime:u,timer:c,events:o}=s;if(a.type==="ADD_EVENT"){const{event:l}=a.payload;ve(l,u);let d=o.length-1;if(!o[d]||o[d].timestamp<=l.timestamp)o.push(l);else{let N=-1,y=0;for(;y<=d;){const v=Math.floor((y+d)/2);o[v].timestamp<=l.timestamp?y=v+1:d=v-1}N===-1&&(N=y),o.splice(N,0,l)}const h=l.timestamp<u,f=t(l,h);h?f():c.isActive()&&c.addAction({doAction:()=>{f()},delay:l.delay})}return ce(ae({},s),{events:o})})}});return Ke(i)}function ln(e){const t=Je({id:"speed",context:e,initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:(n,r)=>{"payload"in r&&n.timer.setSpeed(r.payload.speed)},recordSpeed:G({normalSpeed:n=>n.timer.speed}),restoreSpeed:n=>{n.timer.setSpeed(n.normalSpeed)}}});return Ke(t)}const X=`Please stop import mirror directly. Instead of that,\r
15
16
  now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
16
- or you can use record.mirror to access the mirror instance during recording.`;let _e={map:{},getId(){return console.error(F),-1},getNode(){return console.error(F),null},removeNodeFromMap(){console.error(F)},has(){return console.error(F),!1},reset(){console.error(F)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(_e=new Proxy(_e,{get(t,e,i){return e==="map"&&console.error(F),Reflect.get(t,e,i)}}));function Ot(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=function(e){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===e)return!0;while(e=e&&e.parentNode);return!1})}function _t(t){const e={},i=(o,r)=>{const a={value:o,parent:r,children:[]};return e[o.node.id]=a,a},s=[];for(const o of t){const{nextId:r,parentId:a}=o;if(r&&r in e){const c=e[r];if(c.parent){const d=c.parent.children.indexOf(c);c.parent.children.splice(d,0,i(o,c.parent))}else{const d=s.indexOf(c);s.splice(d,0,i(o,null))}continue}if(a in e){const c=e[a];c.children.push(i(o,c));continue}s.push(i(o,null))}return s}function Le(t,e){e(t.value);for(let i=t.children.length-1;i>=0;i--)Le(t.children[i],e)}function ie(t,e){return Boolean(t.nodeName==="IFRAME"&&e.getMeta(t))}function ke(t,e){var i,s;const o=(s=(i=t.ownerDocument)==null?void 0:i.defaultView)==null?void 0:s.frameElement;if(!o||o===e)return{x:0,y:0,relativeScale:1,absoluteScale:1};const r=o.getBoundingClientRect(),a=ke(o,e),c=r.height/o.clientHeight;return{x:r.x*a.relativeScale+a.x,y:r.y*a.relativeScale+a.y,relativeScale:c,absoluteScale:a.absoluteScale*c}}function Pe(t){return Boolean(t?.shadowRoot)}function W(t,e){const i=t[e[0]];return e.length===1?i:W(i.cssRules[e[1]].cssRules,e.slice(2))}function Fe(t){const e=[...t],i=e.pop();return{positions:e,index:i}}function Lt(t){const e=new Set,i=[];for(let s=t.length;s--;){const o=t[s];e.has(o.id)||(i.push(o),e.add(o.id))}return i}const kt=t=>[`.${t} { background: currentColor }`,"noscript { display: none !important; }",`.${t} { background: currentColor; border-radius: 5px; }`,`.${t}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`];for(var Ve="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",j=typeof Uint8Array>"u"?[]:new Uint8Array(256),X=0;X<Ve.length;X++)j[Ve.charCodeAt(X)]=X;var Pt=function(t){var e=t.length*.75,i=t.length,s,o=0,r,a,c,d;t[t.length-1]==="="&&(e--,t[t.length-2]==="="&&e--);var n=new ArrayBuffer(e),l=new Uint8Array(n);for(s=0;s<i;s+=4)r=j[t.charCodeAt(s)],a=j[t.charCodeAt(s+1)],c=j[t.charCodeAt(s+2)],d=j[t.charCodeAt(s+3)],l[o++]=r<<2|a>>4,l[o++]=(a&15)<<4|c>>2,l[o++]=(c&3)<<6|d&63;return n},Ft=(t,e,i)=>new Promise((s,o)=>{var r=d=>{try{c(i.next(d))}catch(n){o(n)}},a=d=>{try{c(i.throw(d))}catch(n){o(n)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(r,a);c((i=i.apply(t,e)).next())});const Be=new Map;function Ue(t,e){let i=Be.get(t);return i||(i=new Map,Be.set(t,i)),i.has(e)||i.set(e,[]),i.get(e)}function _(t,e,i){return s=>Ft(this,null,function*(){if(s&&typeof s=="object"&&"rr_type"in s)if(i&&(i.isUnchanged=!1),s.rr_type==="ImageBitmap"&&"args"in s){const o=yield _(t,e,i)(s.args);return yield createImageBitmap.apply(null,o)}else if("index"in s){if(i||e===null)return s;const{rr_type:o,index:r}=s;return Ue(e,o)[r]}else if("args"in s){const{rr_type:o,args:r}=s,a=window[o];return new a(...yield Promise.all(r.map(_(t,e,i))))}else{if("base64"in s)return Pt(s.base64);if("src"in s){const o=t.get(s.src);if(o)return o;{const r=new Image;return r.src=s.src,t.set(s.src,r),r}}else if("data"in s&&s.rr_type==="Blob"){const o=yield Promise.all(s.data.map(_(t,e,i)));return new Blob(o,{type:s.type})}}else if(Array.isArray(s))return yield Promise.all(s.map(_(t,e,i)));return s})}var Vt=(t,e,i)=>new Promise((s,o)=>{var r=d=>{try{c(i.next(d))}catch(n){o(n)}},a=d=>{try{c(i.throw(d))}catch(n){o(n)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(r,a);c((i=i.apply(t,e)).next())});function Bt(t,e){try{return e===Y.WebGL?t.getContext("webgl")||t.getContext("experimental-webgl"):t.getContext("webgl2")}catch{return null}}const Ut=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function $t(t,e){if(!(e!=null&&e.constructor))return;const{name:i}=e.constructor;if(!Ut.includes(i))return;const s=Ue(t,i);s.includes(e)||s.push(e)}function Wt(t){return Vt(this,arguments,function*({mutation:e,target:i,type:s,imageMap:o,errorHandler:r}){try{const a=Bt(i,s);if(!a)return;if(e.setter){a[e.property]=e.args[0];return}const c=a[e.property],d=yield Promise.all(e.args.map(_(o,a))),n=c.apply(a,d);$t(a,n)}catch(a){r(e,a)}})}var jt=(t,e,i)=>new Promise((s,o)=>{var r=d=>{try{c(i.next(d))}catch(n){o(n)}},a=d=>{try{c(i.throw(d))}catch(n){o(n)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(r,a);c((i=i.apply(t,e)).next())});function Yt(t){return jt(this,arguments,function*({event:e,mutation:i,target:s,imageMap:o,errorHandler:r}){try{const a=s.getContext("2d");if(i.setter){a[i.property]=i.args[0];return}const c=a[i.property];if(i.property==="drawImage"&&typeof i.args[0]=="string"){const d=o.get(e);c.apply(a,i.args)}else{const d=yield Promise.all(i.args.map(_(o,a)));c.apply(a,d)}}catch(a){r(i,a)}})}var Gt=(t,e,i)=>new Promise((s,o)=>{var r=d=>{try{c(i.next(d))}catch(n){o(n)}},a=d=>{try{c(i.throw(d))}catch(n){o(n)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(r,a);c((i=i.apply(t,e)).next())});function $e(t){return Gt(this,arguments,function*({event:e,mutation:i,target:s,imageMap:o,canvasEventMap:r,errorHandler:a}){try{const c=r.get(e)||i,d="commands"in c?c.commands:[c];if([Y.WebGL,Y.WebGL2].includes(i.type)){for(let n=0;n<d.length;n++){const l=d[n];yield Wt({mutation:l,type:i.type,target:s,imageMap:o,errorHandler:a})}return}for(let n=0;n<d.length;n++){const l=d[n];yield Yt({event:e,mutation:l,target:s,imageMap:o,errorHandler:a})}}catch(c){a(i,c)}})}var Ht=Object.defineProperty,zt=Object.defineProperties,Xt=Object.getOwnPropertyDescriptors,We=Object.getOwnPropertySymbols,Qt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable,je=(t,e,i)=>e in t?Ht(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,V=(t,e)=>{for(var i in e||(e={}))Qt.call(e,i)&&je(t,i,e[i]);if(We)for(var i of We(e))qt.call(e,i)&&je(t,i,e[i]);return t},se=(t,e)=>zt(t,Xt(e)),oe=(t,e,i)=>new Promise((s,o)=>{var r=d=>{try{c(i.next(d))}catch(n){o(n)}},a=d=>{try{c(i.throw(d))}catch(n){o(n)}},c=d=>d.done?s(d.value):Promise.resolve(d.value).then(r,a);c((i=i.apply(t,e)).next())});const Ye=10*1e3,Ge=2*1e3,He=1*1e3,ze=60*60*1e3,Jt=Ee||Et,ne="[replayer]",re={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function ae(t){return t.type==D.IncrementalSnapshot&&(t.data.source==R.TouchMove||t.data.source==R.MouseInteraction&&t.data.type==x.TouchStart)}class Zt{constructor(e,i){if(this.usingVirtualDom=!1,this.virtualDom=new k,this.mouseTail=null,this.tailPositions=[],this.emitter=Jt(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=y.createCache(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=y.createMirror(),this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(i!=null&&i.liveMode)&&e.length<2)throw new Error("Replayer need at least 2 events.");const s={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:re,useVirtualDom:!0,inactiveThreshold:.02,inactiveSkipTime:Ge};this.config=Object.assign({},s,i),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(N.Resize,this.handleResize),this.setupDom(),this.emitter.on(N.Flush,()=>{if(this.usingVirtualDom){const c={mirror:this.mirror,applyCanvas:(d,n,l)=>{$e({event:d,mutation:n,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this)};if(A(this.iframe.contentDocument,this.virtualDom,c,this.virtualDom.mirror),this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const d in this.legacy_missingNodeRetryMap)try{const n=this.legacy_missingNodeRetryMap[d],l=Z(n.node,this.mirror,this.virtualDom.mirror);A(l,n.node,c,this.virtualDom.mirror),n.node=l}catch(n){this.config.showWarning&&console.warn(n)}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null}),this.emitter.on(N.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset()});const o=new bt([],i?.speed||s.speed);this.service=It({events:e.map(c=>i&&i.unpackFn?i.unpackFn(c):c).sort((c,d)=>c.timestamp-d.timestamp),timer:o,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(c=>{this.emitter.emit(N.StateChange,{player:c})}),this.speedService=At({normalSpeed:-1,timer:o}),this.speedService.start(),this.speedService.subscribe(c=>{this.emitter.emit(N.StateChange,{speed:c})});const r=this.service.state.context.events.find(c=>c.type===D.Meta),a=this.service.state.context.events.find(c=>c.type===D.FullSnapshot);if(r){const{width:c,height:d}=r.data;setTimeout(()=>{this.emitter.emit(N.Resize,{width:c,height:d})},0)}a&&setTimeout(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),this.iframe.contentWindow.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(ae)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(e,i){return this.emitter.on(e,i),this}off(e,i){return this.emitter.off(e,i),this}setConfig(e){Object.keys(e).forEach(i=>{this.config[i]=e[i]}),this.config.skipInactive||this.backToNormal(),typeof e.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:e.speed}}),typeof e.mouseTail<"u"&&(e.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getActivityIntervals(){if(this.activityIntervals.length==0){const e=[],i=this.getMetaData(),s=[{timestamp:i.startTime},...this.service.state.context.events.filter(a=>this.isUserInteraction(a)),{timestamp:i.endTime}];for(let a=1;a<s.length;a++){const c=s[a-1],d=s[a];d.timestamp-c.timestamp>Ye?e.push({startTime:c.timestamp,endTime:d.timestamp,duration:d.timestamp-c.timestamp,active:!1}):e.push({startTime:c.timestamp,endTime:d.timestamp,duration:d.timestamp-c.timestamp,active:!0})}const o=[];let r=e[0];for(let a=1;a<e.length;a++)e[a].active!=e[a-1].active&&(o.push({startTime:r.startTime,endTime:e[a-1].endTime,duration:e[a-1].endTime-r.startTime,active:e[a-1].active}),r=e[a]);r&&e.length>0&&o.push({startTime:r.startTime,endTime:e[e.length-1].endTime,duration:e[e.length-1].endTime-r.startTime,active:e[e.length-1].active}),r=o[0];for(let a=1;a<o.length;a++)(!o[a].active&&o[a].duration>this.config.inactiveThreshold*i.totalTime||!o[a-1].active&&o[a-1].duration>this.config.inactiveThreshold*i.totalTime)&&(this.activityIntervals.push({startTime:r.startTime,endTime:o[a-1].endTime,duration:o[a-1].endTime-r.startTime,active:o[a-1].active}),r=o[a]);r&&o.length>0&&this.activityIntervals.push({startTime:r.startTime,endTime:o[o.length-1].endTime,duration:o[o.length-1].endTime-r.startTime,active:o[o.length-1].active})}return this.activityIntervals}getMetaData(){const e=this.service.state.context.events[0],i=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:e.timestamp,endTime:i.timestamp,totalTime:i.timestamp-e.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:e,events:i}=this.service.state.context;return e-i[0].timestamp}getMirror(){return this.mirror}play(e=0){var i,s;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:e}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:e}})),(s=(i=this.iframe.contentDocument)==null?void 0:i.getElementsByTagName("html")[0])==null||s.classList.remove("rrweb-paused"),this.emitter.emit(N.Start),this.handleInactivity(this.getMetaData().startTime+e,!0)}pause(e){var i,s;e===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof e=="number"&&(this.play(e),this.service.send({type:"PAUSE"})),(s=(i=this.iframe.contentDocument)==null?void 0:i.getElementsByTagName("html")[0])==null||s.classList.add("rrweb-paused"),this.emitter.emit(N.Pause)}resume(e=0){console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(e),this.emitter.emit(N.Resume)}startLive(e){this.service.send({type:"TO_LIVE",payload:{baselineTime:e}})}addEvent(e){const i=this.config.unpackFn?this.config.unpackFn(e):e;ae(i)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:i}}))}replaceEvents(e){for(const i of e)if(ae(i)){this.mouse.classList.add("touch-device");break}this.service.send({type:"REPLACE_EVENTS",payload:{events:e}})}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=y.createCache()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");const e=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&e.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",e.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Dt(this.iframe.contentWindow,this.iframe.contentDocument),Ot(this.iframe.contentWindow))}handleResize(e){this.iframe.style.display="inherit";for(const i of[this.mouseTail,this.iframe])!i||(i.setAttribute("width",String(e.width)),i.setAttribute("height",String(e.height)))}applyEventsSynchronously(e){for(const i of e){switch(i.type){case D.DomContentLoaded:case D.Load:case D.Custom:continue;case D.FullSnapshot:case D.Meta:case D.Plugin:case D.IncrementalSnapshot:break}this.getCastFn(i,!0)()}this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null}getCastFn(e,i=!1){let s;switch(e.type){case D.DomContentLoaded:case D.Load:break;case D.Custom:s=()=>{this.emitter.emit(N.CustomEvent,e)};break;case D.Meta:s=()=>this.emitter.emit(N.Resize,{width:e.data.width,height:e.data.height});break;case D.FullSnapshot:s=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===e){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(e,i),this.iframe.contentWindow.scrollTo(e.data.initialOffset)};break;case D.IncrementalSnapshot:s=()=>{if(this.applyIncremental(e,i),!i&&(this.handleInactivity(e.timestamp),e===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const o of this.service.state.context.events)if(!(o.timestamp<=e.timestamp)&&this.isUserInteraction(o)){o.delay-e.delay>Ye*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=o);break}if(this.nextUserInteractionEvent){const o=this.nextUserInteractionEvent.delay-e.delay,r={speed:Math.min(Math.round(o/Ge),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:r}),this.emitter.emit(N.SkipStart,r)}}};break}return()=>{s&&s();for(const r of this.config.plugins||[])r.handler(e,i,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:e}});const o=this.service.state.context.events.length-1;if(e===this.service.state.context.events[o]){const r=()=>{o<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(N.Finish))};e.type===D.IncrementalSnapshot&&e.data.source===R.MouseMove&&e.data.positions.length?setTimeout(()=>{r()},Math.max(0,-e.data.positions[0].timeOffset+50)):r()}this.emitter.emit(N.EventCast,e)}}handleInactivity(e,i){if((e===this.inactiveEndTimestamp||i)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){for(const s of this.getActivityIntervals())if(e>=s.startTime&&e<s.endTime&&!s.active){this.inactiveEndTimestamp=s.endTime;break}if(this.inactiveEndTimestamp){const s=this.inactiveEndTimestamp-e,o={speed:s/ze*this.config.inactiveSkipTime<He?s/He:Math.round(Math.max(s,ze)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:o}),this.emitter.emit(N.SkipStart,o)}}}rebuildFullSnapshot(e,i=!1){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const s=[];y.rebuild(e.data.node,{doc:this.iframe.contentDocument,afterAppend:a=>{this.collectIframeAndAttachDocument(s,a)},cache:this.cache,mirror:this.mirror});for(const{mutationInQueue:a,builtNode:c}of s)this.attachDocumentToIframe(a,c),this.newDocumentQueue=this.newDocumentQueue.filter(d=>d!==a);const{documentElement:o,head:r}=this.iframe.contentDocument;this.insertStyleRules(o,r),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(N.FullsnapshotRebuilded,e),i||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(e,i){const s=kt(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&s.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const o=this.virtualDom.createElement("style");this.virtualDom.mirror.add(o,Ne(o,this.virtualDom.unserializedId)),e.insertBefore(o,i);for(let r=0;r<s.length;r++)o.rules.push({cssText:s[r],type:M.Insert,index:r})}else{const o=document.createElement("style");e.insertBefore(o,i);for(let r=0;r<s.length;r++)o.sheet.insertRule(s[r],r)}}attachDocumentToIframe(e,i){const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,o=[];y.buildNodeWithSN(e.node,{doc:i.contentDocument,mirror:s,hackCss:!0,skipChild:!1,afterAppend:r=>{this.collectIframeAndAttachDocument(o,r);const a=s.getMeta(r);if(a?.type===y.NodeType.Element&&a?.tagName.toUpperCase()==="HTML"){const{documentElement:c,head:d}=i.contentDocument;this.insertStyleRules(c,d)}},cache:this.cache});for(const{mutationInQueue:r,builtNode:a}of o)this.attachDocumentToIframe(r,a),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==r)}collectIframeAndAttachDocument(e,i){if(ie(i,this.mirror)){const s=this.newDocumentQueue.find(o=>o.parentId===this.mirror.getId(i));s&&e.push({mutationInQueue:s,builtNode:i})}}waitForStylesheetLoad(){var e;const i=(e=this.iframe.contentDocument)==null?void 0:e.head;if(i){const s=new Set;let o,r=this.service.state;const a=()=>{r=this.service.state};this.emitter.on(N.Start,a),this.emitter.on(N.Pause,a);const c=()=>{this.emitter.off(N.Start,a),this.emitter.off(N.Pause,a)};i.querySelectorAll('link[rel="stylesheet"]').forEach(d=>{d.sheet||(s.add(d),d.addEventListener("load",()=>{s.delete(d),s.size===0&&o!==-1&&(r.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(N.LoadStylesheetEnd),o&&clearTimeout(o),c())}))}),s.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(N.LoadStylesheetStart),o=setTimeout(()=>{r.matches("playing")&&this.play(this.getCurrentTime()),o=-1,c()},this.config.loadTimeout))}}hasImageArg(e){for(const i of e)if(!(!i||typeof i!="object")){if("rr_type"in i&&"args"in i){if(this.hasImageArg(i.args))return!0}else if("rr_type"in i&&i.rr_type==="HTMLImageElement"||i instanceof Array&&this.hasImageArg(i))return!0}return!1}getImageArgs(e){const i=[];for(const s of e)!s||typeof s!="object"||("rr_type"in s&&"args"in s?i.push(...this.getImageArgs(s.args)):"rr_type"in s&&s.rr_type==="HTMLImageElement"?i.push(s.src):s instanceof Array&&i.push(...this.getImageArgs(s)));return i}preloadAllImages(){return oe(this,null,function*(){this.service.state;const e=()=>{this.service.state};this.emitter.on(N.Start,e),this.emitter.on(N.Pause,e);const i=[];for(const s of this.service.state.context.events)s.type===D.IncrementalSnapshot&&s.data.source===R.CanvasMutation&&(i.push(this.deserializeAndPreloadCanvasEvents(s.data,s)),("commands"in s.data?s.data.commands:[s.data]).forEach(o=>{this.preloadImages(o,s)}));return Promise.all(i)})}preloadImages(e,i){if(e.property==="drawImage"&&typeof e.args[0]=="string"&&!this.imageMap.has(i)){const s=document.createElement("canvas"),o=s.getContext("2d"),r=o?.createImageData(s.width,s.height);r?.data,JSON.parse(e.args[0]),o?.putImageData(r,0,0)}}deserializeAndPreloadCanvasEvents(e,i){return oe(this,null,function*(){if(!this.canvasEventMap.has(i)){const s={isUnchanged:!0};if("commands"in e){const o=yield Promise.all(e.commands.map(r=>oe(this,null,function*(){const a=yield Promise.all(r.args.map(_(this.imageMap,null,s)));return se(V({},r),{args:a})})));s.isUnchanged===!1&&this.canvasEventMap.set(i,se(V({},e),{commands:o}))}else{const o=yield Promise.all(e.args.map(_(this.imageMap,null,s)));s.isUnchanged===!1&&this.canvasEventMap.set(i,se(V({},e),{args:o}))}}})}applyIncremental(e,i){var s,o,r,a,c,d;const{data:n}=e;switch(n.source){case R.Mutation:{try{this.applyMutation(n,i)}catch(l){this.warn(`Exception in mutation ${l.message||l}`,n)}break}case R.Drag:case R.TouchMove:case R.MouseMove:if(i){const l=n.positions[n.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:n}}else n.positions.forEach(l=>{const u={doAction:()=>{this.moveAndHover(l.x,l.y,l.id,i,n)},delay:l.timeOffset+e.timestamp-this.service.state.context.baselineTime};this.timer.addAction(u)}),this.timer.addAction({doAction(){},delay:e.delay-((s=n.positions[0])==null?void 0:s.timeOffset)});break;case R.MouseInteraction:{if(n.id===-1||i)break;const l=new Event(x[n.type].toLowerCase()),u=this.mirror.getNode(n.id);if(!u)return this.debugNodeNotFound(n,n.id);this.emitter.emit(N.MouseInteraction,{type:n.type,target:u});const{triggerFocus:m}=this.config;switch(n.type){case x.Blur:"blur"in u&&u.blur();break;case x.Focus:m&&u.focus&&u.focus({preventScroll:!0});break;case x.Click:case x.TouchStart:case x.TouchEnd:i?(n.type===x.TouchStart?this.touchActive=!0:n.type===x.TouchEnd&&(this.touchActive=!1),this.mousePos={x:n.x,y:n.y,id:n.id,debugData:n}):(n.type===x.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(n.x,n.y,n.id,i,n),n.type===x.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):n.type===x.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):n.type===x.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case x.TouchCancel:i?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:u.dispatchEvent(l)}break}case R.Scroll:{if(n.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);l.scrollData=n;break}this.applyScroll(n,i);break}case R.ViewportResize:this.emitter.emit(N.Resize,{width:n.width,height:n.height});break;case R.Input:{if(n.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);l.inputData=n;break}this.applyInput(n);break}case R.MediaInteraction:{const l=this.usingVirtualDom?this.virtualDom.mirror.getNode(n.id):this.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);const u=l;try{n.currentTime&&(u.currentTime=n.currentTime),n.volume&&(u.volume=n.volume),n.muted&&(u.muted=n.muted),n.type===K.Pause&&u.pause(),n.type===K.Play&&u.play()}catch(m){this.config.showWarning&&console.warn(`Failed to replay media interactions: ${m.message||m}`)}break}case R.StyleSheetRule:{if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);const u=l.rules;(o=n.adds)==null||o.forEach(({rule:m,index:p})=>u?.push({cssText:m,index:p,type:M.Insert})),(r=n.removes)==null||r.forEach(({index:m})=>u?.push({index:m,type:M.Remove}))}else{const l=this.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);const u=l.sheet;(a=n.adds)==null||a.forEach(({rule:m,index:p})=>{try{if(Array.isArray(p)){const{positions:T,index:g}=Fe(p);W(u.cssRules,T).insertRule(m,g)}else{const T=p===void 0?void 0:Math.min(p,u.cssRules.length);u.insertRule(m,T)}}catch{}}),(c=n.removes)==null||c.forEach(({index:m})=>{try{if(Array.isArray(m)){const{positions:p,index:T}=Fe(m);W(u.cssRules,p).deleteRule(T||0)}else u?.deleteRule(m)}catch{}})}break}case R.StyleDeclaration:{if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);const u=l.rules;n.set&&u.push(V({type:M.SetProperty,index:n.index},n.set)),n.remove&&u.push(V({type:M.RemoveProperty,index:n.index},n.remove))}else{const l=this.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);const u=l.sheet;n.set&&W(u.rules,n.index).style.setProperty(n.set.property,n.set.value,n.set.priority),n.remove&&W(u.rules,n.index).style.removeProperty(n.remove.property)}break}case R.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);l.canvasMutations.push({event:e,mutation:n})}else{const l=this.mirror.getNode(n.id);if(!l)return this.debugNodeNotFound(n,n.id);$e({event:e,mutation:n,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case R.Font:{try{const l=new FontFace(n.family,n.buffer?new Uint8Array(JSON.parse(n.fontSource)):n.fontSource,n.descriptors);(d=this.iframe.contentDocument)==null||d.fonts.add(l)}catch(l){this.config.showWarning&&console.warn(l)}break}}}applyMutation(e,i){if(this.config.useVirtualDom&&!this.usingVirtualDom&&i&&(this.usingVirtualDom=!0,vt(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const n in this.legacy_missingNodeRetryMap)try{const l=this.legacy_missingNodeRetryMap[n],u=Te(l.node,this.virtualDom,this.mirror);u&&(l.node=u)}catch(l){this.config.showWarning&&console.warn(l)}const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;e.removes.forEach(n=>{var l;const u=s.getNode(n.id);if(!u)return e.removes.find(p=>p.id===n.parentId)?void 0:this.warnNodeNotFound(e,n.id);let m=s.getNode(n.parentId);if(!m)return this.warnNodeNotFound(e,n.parentId);if(n.isShadow&&Pe(m)&&(m=m.shadowRoot),s.removeNodeFromMap(u),m)try{m.removeChild(u),this.usingVirtualDom&&u.nodeName==="#text"&&m.nodeName==="STYLE"&&((l=m.rules)==null?void 0:l.length)>0&&(m.rules=[])}catch(p){if(p instanceof DOMException)this.warn("parent could not remove child in mutation",m,u,e);else throw p}});const o=V({},this.legacy_missingNodeRetryMap),r=[],a=n=>{let l=null;return n.nextId&&(l=s.getNode(n.nextId)),n.nextId!==null&&n.nextId!==void 0&&n.nextId!==-1&&!l},c=n=>{var l;if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");let u=s.getNode(n.parentId);if(!u)return n.node.type===y.NodeType.Document?this.newDocumentQueue.push(n):r.push(n);n.node.isShadow&&(Pe(u)||u.attachShadow({mode:"open"}),u=u.shadowRoot);let m=null,p=null;if(n.previousId&&(m=s.getNode(n.previousId)),n.nextId&&(p=s.getNode(n.nextId)),a(n))return r.push(n);if(n.node.rootId&&!s.getNode(n.node.rootId))return;const T=n.node.rootId?s.getNode(n.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(ie(u,s)){this.attachDocumentToIframe(n,u);return}const g=y.buildNodeWithSN(n.node,{doc:T,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache});if(n.previousId===-1||n.nextId===-1){o[n.node.id]={node:g,mutation:n};return}const f=s.getMeta(u);if(f&&f.type===y.NodeType.Element&&f.tagName==="textarea"&&n.node.type===y.NodeType.Text){const h=Array.isArray(u.childNodes)?u.childNodes:Array.from(u.childNodes);for(const v of h)v.nodeType===u.TEXT_NODE&&u.removeChild(v)}if(m&&m.nextSibling&&m.nextSibling.parentNode)u.insertBefore(g,m.nextSibling);else if(p&&p.parentNode)u.contains(p)?u.insertBefore(g,p):u.insertBefore(g,null);else{if(u===T)for(;T.firstChild;)T.removeChild(T.firstChild);u.appendChild(g)}if(this.usingVirtualDom&&g.nodeName==="#text"&&u.nodeName==="STYLE"&&((l=u.rules)==null?void 0:l.length)>0&&(u.rules=[]),ie(g,this.mirror)){const h=this.mirror.getId(g),v=this.newDocumentQueue.find(E=>E.parentId===h);v&&(this.attachDocumentToIframe(v,g),this.newDocumentQueue=this.newDocumentQueue.filter(E=>E!==v))}(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(o,u,g,n)};e.adds.forEach(n=>{c(n)});const d=Date.now();for(;r.length;){const n=_t(r);if(r.length=0,Date.now()-d>500){this.warn("Timeout in the loop, please check the resolve tree data:",n);break}for(const l of n)s.getNode(l.value.parentId)?Le(l,u=>{c(u)}):this.debug("Drop resolve tree since there is no parent for the root node.",l)}Object.keys(o).length&&Object.assign(this.legacy_missingNodeRetryMap,o),Lt(e.texts).forEach(n=>{var l;const u=s.getNode(n.id);if(!u)return e.removes.find(m=>m.id===n.id)?void 0:this.warnNodeNotFound(e,n.id);if(u.textContent=n.value,this.usingVirtualDom){const m=u.parentNode;((l=m?.rules)==null?void 0:l.length)>0&&(m.rules=[])}}),e.attributes.forEach(n=>{const l=s.getNode(n.id);if(!l)return e.removes.find(u=>u.id===n.id)?void 0:this.warnNodeNotFound(e,n.id);for(const u in n.attributes)if(typeof u=="string"){const m=n.attributes[u];if(m===null)l.removeAttribute(u);else if(typeof m=="string")try{l.setAttribute(u,m)}catch(p){this.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",p)}else if(u==="style"){const p=m,T=l;for(const g in p)if(p[g]===!1)T.style.removeProperty(g);else if(p[g]instanceof Array){const f=p[g];T.style.setProperty(g,f[0],f[1])}else{const f=p[g];T.style.setProperty(g,f)}}}})}applyScroll(e,i){const s=this.mirror.getNode(e.id);if(!s)return this.debugNodeNotFound(e,e.id);const o=this.mirror.getMeta(s);if(s===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:e.y,left:e.x,behavior:i?"auto":"smooth"});else if(o?.type===y.NodeType.Document)s.defaultView.scrollTo({top:e.y,left:e.x,behavior:i?"auto":"smooth"});else try{s.scrollTop=e.y,s.scrollLeft=e.x}catch{}}applyInput(e){const i=this.mirror.getNode(e.id);if(!i)return this.debugNodeNotFound(e,e.id);try{i.checked=e.isChecked,i.value=e.text}catch{}}legacy_resolveMissingNode(e,i,s,o){const{previousId:r,nextId:a}=o,c=r&&e[r],d=a&&e[a];if(c){const{node:n,mutation:l}=c;i.insertBefore(n,s),delete e[l.node.id],delete this.legacy_missingNodeRetryMap[l.node.id],(l.previousId||l.nextId)&&this.legacy_resolveMissingNode(e,i,n,l)}if(d){const{node:n,mutation:l}=d;i.insertBefore(n,s.nextSibling),delete e[l.node.id],delete this.legacy_missingNodeRetryMap[l.node.id],(l.previousId||l.nextId)&&this.legacy_resolveMissingNode(e,i,n,l)}}moveAndHover(e,i,s,o,r){const a=this.mirror.getNode(s);if(!a)return this.debugNodeNotFound(r,s);const c=ke(a,this.iframe),d=e*c.absoluteScale+c.x,n=i*c.absoluteScale+c.y;this.mouse.style.left=`${d}px`,this.mouse.style.top=`${n}px`,o||this.drawMouseTail({x:d,y:n}),this.hoverElements(a)}drawMouseTail(e){if(!this.mouseTail)return;const{lineCap:i,lineWidth:s,strokeStyle:o,duration:r}=this.config.mouseTail===!0?re:Object.assign({},re,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const c=this.mouseTail.getContext("2d");!c||!this.tailPositions.length||(c.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),c.beginPath(),c.lineWidth=s,c.lineCap=i,c.strokeStyle=o,c.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(d=>c.lineTo(d.x,d.y)),c.stroke())};this.tailPositions.push(e),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(c=>c!==e),a()},r/this.speedService.state.context.timer.speed)}hoverElements(e){var i;(i=this.iframe.contentDocument)==null||i.querySelectorAll(".\\:hover").forEach(o=>{o.classList.remove(":hover")});let s=e;for(;s;)s.classList&&s.classList.add(":hover"),s=s.parentElement}isUserInteraction(e){return e.type!==D.IncrementalSnapshot?!1:e.data.source>R.Mutation&&e.data.source<=R.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(N.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(e,i){this.warn(`Node with id '${i}' not found. `,e)}warnCanvasMutationFailed(e,i){this.warn("Has error on canvas update",i,"canvas mutation:",e)}debugNodeNotFound(e,i){this.debug(ne,`Node with id '${i}' not found. `,e)}warn(...e){!this.config.showWarning||console.warn(ne,...e)}debug(...e){!this.config.showDebug||console.log(ne,...e)}}return Q.Replayer=Zt,Object.defineProperty(Q,"__esModule",{value:!0}),Q}({},rrwebSnapshot);
17
+ or you can use record.mirror to access the mirror instance during recording.`;let nt={map:{},getId(){return console.error(X),-1},getNode(){return console.error(X),null},removeNodeFromMap(){console.error(X)},has(){return console.error(X),!1},reset(){console.error(X)}};typeof window<"u"&&window.Proxy&&window.Reflect&&(nt=new Proxy(nt,{get(e,t,n){return t==="map"&&console.error(X),Reflect.get(e,t,n)}}));function un(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=function(t){if(!(0 in arguments))throw new TypeError("1 argument is required");do if(this===t)return!0;while(t=t&&t.parentNode);return!1})}function dn(e){const t={},n=(i,s)=>{const a={value:i,parent:s,children:[]};return t[i.node.id]=a,a},r=[];for(const i of e){const{nextId:s,parentId:a}=i;if(s&&s in t){const u=t[s];if(u.parent){const c=u.parent.children.indexOf(u);u.parent.children.splice(c,0,n(i,u.parent))}else{const c=r.indexOf(u);r.splice(c,0,n(i,null))}continue}if(a in t){const u=t[a];u.children.push(n(i,u));continue}r.push(n(i,null))}return r}function rt(e,t){t(e.value);for(let n=e.children.length-1;n>=0;n--)rt(e.children[n],t)}function Ne(e,t){return Boolean(e.nodeName==="IFRAME"&&t.getMeta(e))}function it(e,t){var n,r;const i=(r=(n=e.ownerDocument)==null?void 0:n.defaultView)==null?void 0:r.frameElement;if(!i||i===t)return{x:0,y:0,relativeScale:1,absoluteScale:1};const s=i.getBoundingClientRect(),a=it(i,t),u=s.height/i.clientHeight;return{x:s.x*a.relativeScale+a.x,y:s.y*a.relativeScale+a.y,relativeScale:u,absoluteScale:a.absoluteScale*u}}function ot(e){return Boolean(e?.shadowRoot)}function K(e,t){const n=e[t[0]];return t.length===1?n:K(n.cssRules[t[1]].cssRules,t.slice(2))}function st(e){const t=[...e],n=t.pop();return{positions:t,index:n}}function hn(e){const t=new Set,n=[];for(let r=e.length;r--;){const i=e[r];t.has(i.id)||(n.push(i),t.add(i.id))}return n}const mn=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }",`.${e} { background: currentColor; border-radius: 5px; }`,`.${e}:hover::after {content: 'Redacted'; color: white; background: black; text-align: center; width: 100%; display: block;}`];for(var at="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ee=typeof Uint8Array>"u"?[]:new Uint8Array(256),le=0;le<at.length;le++)ee[at.charCodeAt(le)]=le;var pn=function(e){var t=e.length*.75,n=e.length,r,i=0,s,a,u,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var o=new ArrayBuffer(t),l=new Uint8Array(o);for(r=0;r<n;r+=4)s=ee[e.charCodeAt(r)],a=ee[e.charCodeAt(r+1)],u=ee[e.charCodeAt(r+2)],c=ee[e.charCodeAt(r+3)],l[i++]=s<<2|a>>4,l[i++]=(a&15)<<4|u>>2,l[i++]=(u&3)<<6|c&63;return o},fn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{u(n.next(c))}catch(o){i(o)}},a=c=>{try{u(n.throw(c))}catch(o){i(o)}},u=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);u((n=n.apply(e,t)).next())});const ct=new Map;function lt(e,t){let n=ct.get(e);return n||(n=new Map,ct.set(e,n)),n.has(t)||n.set(t,[]),n.get(t)}function W(e,t,n){return r=>fn(this,null,function*(){if(r&&typeof r=="object"&&"rr_type"in r)if(n&&(n.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const i=yield W(e,t,n)(r.args);return yield createImageBitmap.apply(null,i)}else if("index"in r){if(n||t===null)return r;const{rr_type:i,index:s}=r;return lt(t,i)[s]}else if("args"in r){const{rr_type:i,args:s}=r,a=window[i];return new a(...yield Promise.all(s.map(W(e,t,n))))}else{if("base64"in r)return pn(r.base64);if("src"in r){const i=e.get(r.src);if(i)return i;{const s=new Image;return s.src=r.src,e.set(r.src,s),s}}else if("data"in r&&r.rr_type==="Blob"){const i=yield Promise.all(r.data.map(W(e,t,n)));return new Blob(i,{type:r.type})}}else if(Array.isArray(r))return yield Promise.all(r.map(W(e,t,n)));return r})}var gn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{u(n.next(c))}catch(o){i(o)}},a=c=>{try{u(n.throw(c))}catch(o){i(o)}},u=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);u((n=n.apply(e,t)).next())});function yn(e,t){try{return t===oe.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const vn=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Tn(e,t){if(!(t!=null&&t.constructor))return;const{name:n}=t.constructor;if(!vn.includes(n))return;const r=lt(e,n);r.includes(t)||r.push(t)}function Nn(e){return gn(this,arguments,function*({mutation:t,target:n,type:r,imageMap:i,errorHandler:s}){try{const a=yn(n,r);if(!a)return;if(t.setter){a[t.property]=t.args[0];return}const u=a[t.property],c=yield Promise.all(t.args.map(W(i,a))),o=u.apply(a,c);Tn(a,o)}catch(a){s(t,a)}})}var En=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{u(n.next(c))}catch(o){i(o)}},a=c=>{try{u(n.throw(c))}catch(o){i(o)}},u=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);u((n=n.apply(e,t)).next())});function wn(e){return En(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,errorHandler:s}){try{const a=r.getContext("2d");if(n.setter){a[n.property]=n.args[0];return}const u=a[n.property];if(n.property==="drawImage"&&typeof n.args[0]=="string"){const c=i.get(t);u.apply(a,n.args)}else{const c=yield Promise.all(n.args.map(W(i,a)));u.apply(a,c)}}catch(a){s(n,a)}})}var bn=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{u(n.next(c))}catch(o){i(o)}},a=c=>{try{u(n.throw(c))}catch(o){i(o)}},u=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);u((n=n.apply(e,t)).next())});function ut(e){return bn(this,arguments,function*({event:t,mutation:n,target:r,imageMap:i,canvasEventMap:s,errorHandler:a}){try{const u=s.get(t)||n,c="commands"in u?u.commands:[u];if([oe.WebGL,oe.WebGL2].includes(n.type)){for(let o=0;o<c.length;o++){const l=c[o];yield Nn({mutation:l,type:n.type,target:r,imageMap:i,errorHandler:a})}return}for(let o=0;o<c.length;o++){const l=c[o];yield wn({event:t,mutation:l,target:r,imageMap:i,errorHandler:a})}}catch(u){a(n,u)}})}var Dn=Object.defineProperty,Mn=Object.defineProperties,Cn=Object.getOwnPropertyDescriptors,dt=Object.getOwnPropertySymbols,Sn=Object.prototype.hasOwnProperty,xn=Object.prototype.propertyIsEnumerable,ht=(e,t,n)=>t in e?Dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Q=(e,t)=>{for(var n in t||(t={}))Sn.call(t,n)&&ht(e,n,t[n]);if(dt)for(var n of dt(t))xn.call(t,n)&&ht(e,n,t[n]);return e},Ee=(e,t)=>Mn(e,Cn(t)),we=(e,t,n)=>new Promise((r,i)=>{var s=c=>{try{u(n.next(c))}catch(o){i(o)}},a=c=>{try{u(n.throw(c))}catch(o){i(o)}},u=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,a);u((n=n.apply(e,t)).next())});const mt=10*1e3,pt=2*1e3,ft=1*1e3,gt=60*60*1e3,Rn=He||Zt,be="[replayer]",De={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Me(e){return e.type==M.IncrementalSnapshot&&(e.data.source==S.TouchMove||e.data.source==S.MouseInteraction&&e.data.type==k.TouchStart)}class An{constructor(t,n){if(this.usingVirtualDom=!1,this.virtualDom=new Y,this.mouseTail=null,this.tailPositions=[],this.emitter=Rn(),this.activityIntervals=[],this.legacy_missingNodeRetryMap={},this.cache=ke(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Tt(),this.firstFullSnapshot=null,this.newDocumentQueue=[],this.mousePos=null,this.touchActive=null,!(n!=null&&n.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,showWarning:!0,showDebug:!1,blockClass:"highlight-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:De,useVirtualDom:!0,inactiveThreshold:.02,inactiveSkipTime:pt};this.config=Object.assign({},r,n),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(D.Resize,this.handleResize),this.setupDom(),this.emitter.on(D.Flush,()=>{if(this.usingVirtualDom){const u={mirror:this.mirror,applyCanvas:(c,o,l)=>{ut({event:c,mutation:o,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this)};if(B(this.iframe.contentDocument,this.virtualDom,u,this.virtualDom.mirror),this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const o=this.legacy_missingNodeRetryMap[c],l=ge(o.node,this.mirror,this.virtualDom.mirror);B(l,o.node,u,this.virtualDom.mirror),o.node=l}catch(o){this.config.showWarning&&console.warn(o)}}this.mousePos&&this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null}),this.emitter.on(D.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset()});const i=new en([],n?.speed||r.speed);this.service=cn({events:t.map(u=>n&&n.unpackFn?n.unpackFn(u):u).sort((u,c)=>u.timestamp-c.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(u=>{this.emitter.emit(D.StateChange,{player:u})}),this.speedService=ln({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(u=>{this.emitter.emit(D.StateChange,{speed:u})});const s=this.service.state.context.events.find(u=>u.type===M.Meta),a=this.service.state.context.events.find(u=>u.type===M.FullSnapshot);if(s){const{width:u,height:c}=s.data;setTimeout(()=>{this.emitter.emit(D.Resize,{width:u,height:c})},0)}a&&setTimeout(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),this.iframe.contentWindow.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Me)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,n){return this.emitter.on(t,n),this}off(t,n){return this.emitter.off(t,n),this}setConfig(t){Object.keys(t).forEach(n=>{this.config[n]=t[n]}),this.config.skipInactive||this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getActivityIntervals(){if(this.activityIntervals.length==0){const t=[],n=this.getMetaData(),r=[{timestamp:n.startTime},...this.service.state.context.events.filter(a=>this.isUserInteraction(a)),{timestamp:n.endTime}];for(let a=1;a<r.length;a++){const u=r[a-1],c=r[a];c.timestamp-u.timestamp>mt?t.push({startTime:u.timestamp,endTime:c.timestamp,duration:c.timestamp-u.timestamp,active:!1}):t.push({startTime:u.timestamp,endTime:c.timestamp,duration:c.timestamp-u.timestamp,active:!0})}const i=[];let s=t[0];for(let a=1;a<t.length;a++)t[a].active!=t[a-1].active&&(i.push({startTime:s.startTime,endTime:t[a-1].endTime,duration:t[a-1].endTime-s.startTime,active:t[a-1].active}),s=t[a]);s&&t.length>0&&i.push({startTime:s.startTime,endTime:t[t.length-1].endTime,duration:t[t.length-1].endTime-s.startTime,active:t[t.length-1].active}),s=i[0];for(let a=1;a<i.length;a++)(!i[a].active&&i[a].duration>this.config.inactiveThreshold*n.totalTime||!i[a-1].active&&i[a-1].duration>this.config.inactiveThreshold*n.totalTime)&&(this.activityIntervals.push({startTime:s.startTime,endTime:i[a-1].endTime,duration:i[a-1].endTime-s.startTime,active:i[a-1].active}),s=i[a]);s&&i.length>0&&this.activityIntervals.push({startTime:s.startTime,endTime:i[i.length-1].endTime,duration:i[i.length-1].endTime-s.startTime,active:i[i.length-1].active})}return this.activityIntervals}getMetaData(){const t=this.service.state.context.events[0],n=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:n.timestamp,totalTime:n.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:n}=this.service.state.context;return t-n[0].timestamp}getMirror(){return this.mirror}play(t=0){var n,r;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.remove("rrweb-paused"),this.emitter.emit(D.Start),this.handleInactivity(this.getMetaData().startTime+t,!0)}pause(t){var n,r;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(r=(n=this.iframe.contentDocument)==null?void 0:n.getElementsByTagName("html")[0])==null||r.classList.add("rrweb-paused"),this.emitter.emit(D.Pause)}resume(t=0){console.warn("The 'resume' will be departed in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(D.Resume)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const n=this.config.unpackFn?this.config.unpackFn(t):t;Me(n)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:n}}))}replaceEvents(t){for(const n of t)if(Me(n)){this.mouse.classList.add("touch-device");break}this.service.send({type:"REPLACE_EVENTS",payload:{events:t}})}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=ke()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe),this.iframe.contentWindow&&this.iframe.contentDocument&&(Kt(this.iframe.contentWindow,this.iframe.contentDocument),un(this.iframe.contentWindow))}handleResize(t){this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])!n||(n.setAttribute("width",String(t.width)),n.setAttribute("height",String(t.height)))}applyEventsSynchronously(t){for(const n of t){switch(n.type){case M.DomContentLoaded:case M.Load:case M.Custom:continue;case M.FullSnapshot:case M.Meta:case M.Plugin:case M.IncrementalSnapshot:break}this.getCastFn(n,!0)()}this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null}getCastFn(t,n=!1){let r;switch(t.type){case M.DomContentLoaded:case M.Load:break;case M.Custom:r=()=>{this.emitter.emit(D.CustomEvent,t)};break;case M.Meta:r=()=>this.emitter.emit(D.Resize,{width:t.data.width,height:t.data.height});break;case M.FullSnapshot:r=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===t){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(t,n),this.iframe.contentWindow.scrollTo(t.data.initialOffset)};break;case M.IncrementalSnapshot:r=()=>{if(this.applyIncremental(t,n),!n&&(this.handleInactivity(t.timestamp),t===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const i of this.service.state.context.events)if(!(i.timestamp<=t.timestamp)&&this.isUserInteraction(i)){i.delay-t.delay>mt*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=i);break}if(this.nextUserInteractionEvent){const i=this.nextUserInteractionEvent.delay-t.delay,s={speed:Math.min(Math.round(i/pt),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:s}),this.emitter.emit(D.SkipStart,s)}}};break}return()=>{r&&r();for(const s of this.config.plugins||[])s.handler(t,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:t}});const i=this.service.state.context.events.length-1;if(t===this.service.state.context.events[i]){const s=()=>{i<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(D.Finish))};t.type===M.IncrementalSnapshot&&t.data.source===S.MouseMove&&t.data.positions.length?setTimeout(()=>{s()},Math.max(0,-t.data.positions[0].timeOffset+50)):s()}this.emitter.emit(D.EventCast,t)}}handleInactivity(t,n){if((t===this.inactiveEndTimestamp||n)&&(this.inactiveEndTimestamp=null,this.backToNormal()),this.config.skipInactive&&!this.inactiveEndTimestamp){for(const r of this.getActivityIntervals())if(t>=r.startTime&&t<r.endTime&&!r.active){this.inactiveEndTimestamp=r.endTime;break}if(this.inactiveEndTimestamp){const r=this.inactiveEndTimestamp-t,i={speed:r/gt*this.config.inactiveSkipTime<ft?r/ft:Math.round(Math.max(r,gt)/this.config.inactiveSkipTime)};this.speedService.send({type:"FAST_FORWARD",payload:i}),this.emitter.emit(D.SkipStart,i)}}}rebuildFullSnapshot(t,n=!1){if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&console.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const r=[];St(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a=>{this.collectIframeAndAttachDocument(r,a)},cache:this.cache,mirror:this.mirror});for(const{mutationInQueue:a,builtNode:u}of r)this.attachDocumentToIframe(a,u),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a);const{documentElement:i,head:s}=this.iframe.contentDocument;this.insertStyleRules(i,s),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(D.FullsnapshotRebuilded,t),n||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,n){const r=mn(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const i=this.virtualDom.createElement("style");this.virtualDom.mirror.add(i,je(i,this.virtualDom.unserializedId)),t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.rules.push({cssText:r[s],type:$.Insert,index:s})}else{const i=document.createElement("style");t.insertBefore(i,n);for(let s=0;s<r.length;s++)i.sheet.insertRule(r[s],s)}}attachDocumentToIframe(t,n){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[];ie(t.node,{doc:n.contentDocument,mirror:r,hackCss:!0,skipChild:!1,afterAppend:s=>{this.collectIframeAndAttachDocument(i,s);const a=r.getMeta(s);if(a?.type===R.Element&&a?.tagName.toUpperCase()==="HTML"){const{documentElement:u,head:c}=n.contentDocument;this.insertStyleRules(u,c)}},cache:this.cache});for(const{mutationInQueue:s,builtNode:a}of i)this.attachDocumentToIframe(s,a),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==s)}collectIframeAndAttachDocument(t,n){if(Ne(n,this.mirror)){const r=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(n));r&&t.push({mutationInQueue:r,builtNode:n})}}waitForStylesheetLoad(){var t;const n=(t=this.iframe.contentDocument)==null?void 0:t.head;if(n){const r=new Set;let i,s=this.service.state;const a=()=>{s=this.service.state};this.emitter.on(D.Start,a),this.emitter.on(D.Pause,a);const u=()=>{this.emitter.off(D.Start,a),this.emitter.off(D.Pause,a)};n.querySelectorAll('link[rel="stylesheet"]').forEach(c=>{c.sheet||(r.add(c),c.addEventListener("load",()=>{r.delete(c),r.size===0&&i!==-1&&(s.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(D.LoadStylesheetEnd),i&&clearTimeout(i),u())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(D.LoadStylesheetStart),i=setTimeout(()=>{s.matches("playing")&&this.play(this.getCurrentTime()),i=-1,u()},this.config.loadTimeout))}}hasImageArg(t){for(const n of t)if(!(!n||typeof n!="object")){if("rr_type"in n&&"args"in n){if(this.hasImageArg(n.args))return!0}else if("rr_type"in n&&n.rr_type==="HTMLImageElement"||n instanceof Array&&this.hasImageArg(n))return!0}return!1}getImageArgs(t){const n=[];for(const r of t)!r||typeof r!="object"||("rr_type"in r&&"args"in r?n.push(...this.getImageArgs(r.args)):"rr_type"in r&&r.rr_type==="HTMLImageElement"?n.push(r.src):r instanceof Array&&n.push(...this.getImageArgs(r)));return n}preloadAllImages(){return we(this,null,function*(){this.service.state;const t=()=>{this.service.state};this.emitter.on(D.Start,t),this.emitter.on(D.Pause,t);const n=[];for(const r of this.service.state.context.events)r.type===M.IncrementalSnapshot&&r.data.source===S.CanvasMutation&&(n.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(n)})}preloadImages(t,n){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(n)){const r=document.createElement("canvas"),i=r.getContext("2d"),s=i?.createImageData(r.width,r.height);s?.data,JSON.parse(t.args[0]),i?.putImageData(s,0,0)}}deserializeAndPreloadCanvasEvents(t,n){return we(this,null,function*(){if(!this.canvasEventMap.has(n)){const r={isUnchanged:!0};if("commands"in t){const i=yield Promise.all(t.commands.map(s=>we(this,null,function*(){const a=yield Promise.all(s.args.map(W(this.imageMap,null,r)));return Ee(Q({},s),{args:a})})));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{commands:i}))}else{const i=yield Promise.all(t.args.map(W(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(n,Ee(Q({},t),{args:i}))}}})}applyIncremental(t,n){var r,i,s,a,u,c;const{data:o}=t;switch(o.source){case S.Mutation:{try{this.applyMutation(o,n)}catch(l){this.warn(`Exception in mutation ${l.message||l}`,o)}break}case S.Drag:case S.TouchMove:case S.MouseMove:if(n){const l=o.positions[o.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:o}}else o.positions.forEach(l=>{const d={doAction:()=>{this.moveAndHover(l.x,l.y,l.id,n,o)},delay:l.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((r=o.positions[0])==null?void 0:r.timeOffset)});break;case S.MouseInteraction:{if(o.id===-1||n)break;const l=new Event(k[o.type].toLowerCase()),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(D.MouseInteraction,{type:o.type,target:d});const{triggerFocus:h}=this.config;switch(o.type){case k.Blur:"blur"in d&&d.blur();break;case k.Focus:h&&d.focus&&d.focus({preventScroll:!0});break;case k.Click:case k.TouchStart:case k.TouchEnd:n?(o.type===k.TouchStart?this.touchActive=!0:o.type===k.TouchEnd&&(this.touchActive=!1),this.mousePos={x:o.x,y:o.y,id:o.id,debugData:o}):(o.type===k.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x,o.y,o.id,n,o),o.type===k.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===k.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===k.TouchEnd&&this.mouse.classList.remove("touch-active"));break;case k.TouchCancel:n?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(l)}break}case S.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.scrollData=o;break}this.applyScroll(o,n);break}case S.ViewportResize:this.emitter.emit(D.Resize,{width:o.width,height:o.height});break;case S.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.inputData=o;break}this.applyInput(o);break}case S.MediaInteraction:{const l=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const d=l;try{o.currentTime&&(d.currentTime=o.currentTime),o.volume&&(d.volume=o.volume),o.muted&&(d.muted=o.muted),o.type===ye.Pause&&d.pause(),o.type===ye.Play&&d.play()}catch(h){this.config.showWarning&&console.warn(`Failed to replay media interactions: ${h.message||h}`)}break}case S.StyleSheetRule:{if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const d=l.rules;(i=o.adds)==null||i.forEach(({rule:h,index:f})=>d?.push({cssText:h,index:f,type:$.Insert})),(s=o.removes)==null||s.forEach(({index:h})=>d?.push({index:h,type:$.Remove}))}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const d=l.sheet;(a=o.adds)==null||a.forEach(({rule:h,index:f})=>{try{if(Array.isArray(f)){const{positions:N,index:y}=st(f);K(d.cssRules,N).insertRule(h,y)}else{const N=f===void 0?void 0:Math.min(f,d.cssRules.length);d.insertRule(h,N)}}catch{}}),(u=o.removes)==null||u.forEach(({index:h})=>{try{if(Array.isArray(h)){const{positions:f,index:N}=st(h);K(d.cssRules,f).deleteRule(N||0)}else d?.deleteRule(h)}catch{}})}break}case S.StyleDeclaration:{if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const d=l.rules;o.set&&d.push(Q({type:$.SetProperty,index:o.index},o.set)),o.remove&&d.push(Q({type:$.RemoveProperty,index:o.index},o.remove))}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const d=l.sheet;o.set&&K(d.rules,o.index).style.setProperty(o.set.property,o.set.value,o.set.priority),o.remove&&K(d.rules,o.index).style.removeProperty(o.remove.property)}break}case S.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.canvasMutations.push({event:t,mutation:o})}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);ut({event:t,mutation:o,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case S.Font:{try{const l=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(c=this.iframe.contentDocument)==null||c.fonts.add(l)}catch(l){this.config.showWarning&&console.warn(l)}break}}}applyMutation(t,n){if(this.config.useVirtualDom&&!this.usingVirtualDom&&n&&(this.usingVirtualDom=!0,Qt(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const o in this.legacy_missingNodeRetryMap)try{const l=this.legacy_missingNodeRetryMap[o],d=We(l.node,this.virtualDom,this.mirror);d&&(l.node=d)}catch(l){this.config.showWarning&&console.warn(l)}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes.forEach(o=>{var l;const d=r.getNode(o.id);if(!d)return t.removes.find(f=>f.id===o.parentId)?void 0:this.warnNodeNotFound(t,o.id);let h=r.getNode(o.parentId);if(!h)return this.warnNodeNotFound(t,o.parentId);if(o.isShadow&&ot(h)&&(h=h.shadowRoot),r.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((l=h.rules)==null?void 0:l.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),s=[],a=o=>{let l=null;return o.nextId&&(l=r.getNode(o.nextId)),o.nextId!==null&&o.nextId!==void 0&&o.nextId!==-1&&!l},u=o=>{var l;if(!this.iframe.contentDocument)return console.warn("Looks like your replayer has been destroyed.");let d=r.getNode(o.parentId);if(!d)return o.node.type===R.Document?this.newDocumentQueue.push(o):s.push(o);o.node.isShadow&&(ot(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,f=null;if(o.previousId&&(h=r.getNode(o.previousId)),o.nextId&&(f=r.getNode(o.nextId)),a(o))return s.push(o);if(o.node.rootId&&!r.getNode(o.node.rootId))return;const N=o.node.rootId?r.getNode(o.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ne(d,r)){this.attachDocumentToIframe(o,d);return}const y=ie(o.node,{doc:N,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache});if(o.previousId===-1||o.nextId===-1){i[o.node.id]={node:y,mutation:o};return}const v=r.getMeta(d);if(v&&v.type===R.Element&&v.tagName==="textarea"&&o.node.type===R.Text){const m=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const T of m)T.nodeType===d.TEXT_NODE&&d.removeChild(T)}if(h&&h.nextSibling&&h.nextSibling.parentNode)d.insertBefore(y,h.nextSibling);else if(f&&f.parentNode)d.contains(f)?d.insertBefore(y,f):d.insertBefore(y,null);else{if(d===N)for(;N.firstChild;)N.removeChild(N.firstChild);d.appendChild(y)}if(this.usingVirtualDom&&y.nodeName==="#text"&&d.nodeName==="STYLE"&&((l=d.rules)==null?void 0:l.length)>0&&(d.rules=[]),Ne(y,this.mirror)){const m=this.mirror.getId(y),T=this.newDocumentQueue.find(w=>w.parentId===m);T&&(this.attachDocumentToIframe(T,y),this.newDocumentQueue=this.newDocumentQueue.filter(w=>w!==T))}(o.previousId||o.nextId)&&this.legacy_resolveMissingNode(i,d,y,o)};t.adds.forEach(o=>{u(o)});const c=Date.now();for(;s.length;){const o=dn(s);if(s.length=0,Date.now()-c>500){this.warn("Timeout in the loop, please check the resolve tree data:",o);break}for(const l of o)r.getNode(l.value.parentId)?rt(l,d=>{u(d)}):this.debug("Drop resolve tree since there is no parent for the root node.",l)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),hn(t.texts).forEach(o=>{var l;const d=r.getNode(o.id);if(!d)return t.removes.find(h=>h.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);if(d.textContent=o.value,this.usingVirtualDom){const h=d.parentNode;((l=h?.rules)==null?void 0:l.length)>0&&(h.rules=[])}}),t.attributes.forEach(o=>{const l=r.getNode(o.id);if(!l)return t.removes.find(d=>d.id===o.id)?void 0:this.warnNodeNotFound(t,o.id);for(const d in o.attributes)if(typeof d=="string"){const h=o.attributes[d];if(h===null)l.removeAttribute(d);else if(typeof h=="string")try{l.setAttribute(d,h)}catch(f){this.config.showWarning&&console.warn("An error occurred may due to the checkout feature.",f)}else if(d==="style"){const f=h,N=l;for(const y in f)if(f[y]===!1)N.style.removeProperty(y);else if(f[y]instanceof Array){const v=f[y];N.style.setProperty(y,v[0],v[1])}else{const v=f[y];N.style.setProperty(y,v)}}}})}applyScroll(t,n){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const i=this.mirror.getMeta(r);if(r===this.iframe.contentDocument)this.iframe.contentWindow.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else if(i?.type===R.Document)r.defaultView.scrollTo({top:t.y,left:t.x,behavior:n?"auto":"smooth"});else try{r.scrollTop=t.y,r.scrollLeft=t.x}catch{}}applyInput(t){const n=this.mirror.getNode(t.id);if(!n)return this.debugNodeNotFound(t,t.id);try{n.checked=t.isChecked,n.value=t.text}catch{}}legacy_resolveMissingNode(t,n,r,i){const{previousId:s,nextId:a}=i,u=s&&t[s],c=a&&t[a];if(u){const{node:o,mutation:l}=u;n.insertBefore(o,r),delete t[l.node.id],delete this.legacy_missingNodeRetryMap[l.node.id],(l.previousId||l.nextId)&&this.legacy_resolveMissingNode(t,n,o,l)}if(c){const{node:o,mutation:l}=c;n.insertBefore(o,r.nextSibling),delete t[l.node.id],delete this.legacy_missingNodeRetryMap[l.node.id],(l.previousId||l.nextId)&&this.legacy_resolveMissingNode(t,n,o,l)}}moveAndHover(t,n,r,i,s){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(s,r);const u=it(a,this.iframe),c=t*u.absoluteScale+u.x,o=n*u.absoluteScale+u.y;this.mouse.style.left=`${c}px`,this.mouse.style.top=`${o}px`,i||this.drawMouseTail({x:c,y:o}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:n,lineWidth:r,strokeStyle:i,duration:s}=this.config.mouseTail===!0?De:Object.assign({},De,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const u=this.mouseTail.getContext("2d");!u||!this.tailPositions.length||(u.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),u.beginPath(),u.lineWidth=r,u.lineCap=n,u.strokeStyle=i,u.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(c=>u.lineTo(c.x,c.y)),u.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(u=>u!==t),a()},s/this.speedService.state.context.timer.speed)}hoverElements(t){var n;(n=this.iframe.contentDocument)==null||n.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")});let r=t;for(;r;)r.classList&&r.classList.add(":hover"),r=r.parentElement}isUserInteraction(t){return t.type!==M.IncrementalSnapshot?!1:t.data.source>S.Mutation&&t.data.source<=S.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(D.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,n){this.warn(`Node with id '${n}' not found. `,t)}warnCanvasMutationFailed(t,n){this.warn("Has error on canvas update",n,"canvas mutation:",t)}debugNodeNotFound(t,n){this.debug(be,`Node with id '${n}' not found. `,t)}warn(...t){!this.config.showWarning||console.warn(be,...t)}debug(...t){!this.config.showDebug||console.log(be,...t)}}return he.Replayer=An,Object.defineProperty(he,"__esModule",{value:!0}),he}({});
17
18
  //# sourceMappingURL=rrweb-replay.min.js.map