Socket
Socket
Sign inDemoInstall

rrweb-snapshot

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rrweb-snapshot - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

9

dist/rrweb-snapshot.js

@@ -170,3 +170,10 @@ var rrwebSnapshot = (function (exports) {

var fired = false;
if (win.document.readyState !== 'complete') {
var readyState;
try {
readyState = win.document.readyState;
}
catch (error) {
return;
}
if (readyState !== 'complete') {
var timer_1 = setTimeout(function () {

@@ -173,0 +180,0 @@ if (!fired) {

2

dist/rrweb-snapshot.min.js

@@ -1,2 +0,2 @@

var rrwebSnapshot=function(e){"use strict";var t;(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var r=1,n=RegExp("[^a-z1-6-_]"),a=-2;function i(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(o).join(""):null}catch(e){return null}}function o(e){return function(e){return"styleSheet"in e}(e)?i(e.styleSheet)||"":e.cssText}var s=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,c=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,u=/^(data:)([^,]*),(.*)/i;function l(e,t){return(e||"").replace(s,function(e,r,n,a,i,o){var s,l=n||i||o,f=r||a||"";if(!l)return e;if(!c.test(l))return"url("+f+l+f+")";if(u.test(l))return"url("+f+l+f+")";if("/"===l[0])return"url("+f+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+l)+f+")";var p=t.split("/"),d=l.split("/");p.pop();for(var m=0,h=d;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?p.pop():p.push(v))}return"url("+f+p.join("/")+f+")"})}function f(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function p(){var e=document.createElement("a");return e.href="",e.href}function d(e,t,r){return"src"===t||("href"===t||"xlink:href"===t)&&r?f(e,r):"srcset"===t&&r?function(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?f(e,r[0])+" "+r[1]:1===r.length?""+f(e,r[0]):""}).join(", ")}(e,r):"style"===t&&r?l(r,p()):r}function m(t,r){var a,o,s=r.doc,c=r.blockClass,u=r.blockSelector,f=r.inlineStylesheet,m=r.maskInputOptions,h=void 0===m?{}:m,v=r.recordCanvas;if(s.__sn){var y=s.__sn.id;a=1===y?void 0:y}switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[],rootId:a};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:a};case t.ELEMENT_NODE:for(var g=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach(function(e){if(t.test(e))return!0});return!!r&&e.matches(r)}(t,c,u),b=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return n.test(t)?"div":t}(t),T={},N=0,C=Array.from(t.attributes);N<C.length;N++){var k=C[N],E=k.name,S=k.value;T[E]=d(s,E,S)}if("link"===b&&f){var _,w=Array.from(s.styleSheets).find(function(e){return e.href===t.href});(_=i(w))&&(delete T.rel,delete T.href,T._cssText=l(_,w.href))}if("style"===b&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(_=i(t.sheet))&&(T._cssText=l(_,p()));if("input"===b||"textarea"===b||"select"===b){S=t.value;"radio"!==T.type&&"checkbox"!==T.type&&"submit"!==T.type&&"button"!==T.type&&S?T.value=h[T.type]||h[b]?"*".repeat(S.length):S:t.checked&&(T.checked=t.checked)}if("option"===b){var D=t.parentElement;T.value===D.value&&(T.selected=t.selected)}if("canvas"===b&&v&&(T.rr_dataURL=t.toDataURL()),"audio"!==b&&"video"!==b||(T.rr_mediaState=t.paused?"paused":"played"),t.scrollLeft&&(T.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(T.rr_scrollTop=t.scrollTop),g){var x=t.getBoundingClientRect(),A=x.width,O=x.height;T={class:T.class,rr_width:A+"px",rr_height:O+"px"}}return"iframe"===b&&delete T.src,{type:e.NodeType.Element,tagName:b,attributes:T,childNodes:[],isSVG:(o=t,"svg"===o.tagName||o instanceof SVGElement||void 0),needBlock:g,rootId:a};case t.TEXT_NODE:var I=t.parentNode&&t.parentNode.tagName,L=t.textContent,M="STYLE"===I||void 0;return M&&L&&(L=l(L,p())),"SCRIPT"===I&&(L="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:L||"",isStyle:M,rootId:a};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:a};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:a};default:return!1}}function h(e){return void 0===e?"":e.toLowerCase()}function v(t,n){var i,o=n.doc,s=n.map,c=n.blockClass,u=n.blockSelector,l=n.skipChild,f=void 0!==l&&l,p=n.inlineStylesheet,d=void 0===p||p,y=n.maskInputOptions,g=void 0===y?{}:y,b=n.slimDOMOptions,T=n.recordCanvas,N=void 0!==T&&T,C=n.onSerialize,k=n.onIframeLoad,E=n.iframeLoadTimeout,S=void 0===E?5e3:E,_=n.preserveWhiteSpace,w=void 0===_||_,D=m(t,{doc:o,blockClass:c,blockSelector:u,inlineStylesheet:d,maskInputOptions:g,recordCanvas:N});if(!D)return console.warn(t,"not serialized"),null;i="__sn"in t?t.__sn.id:!function(t,r){if(r.comment&&t.type===e.NodeType.Comment)return!0;if(t.type===e.NodeType.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(h(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===h(t.attributes.name)||"icon"===h(t.attributes.rel)||"apple-touch-icon"===h(t.attributes.rel)||"shortcut icon"===h(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&h(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(h(t.attributes.property).match(/^(og|twitter|fb):/)||h(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===h(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===h(t.attributes.name)||"googlebot"===h(t.attributes.name)||"bingbot"===h(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===h(t.attributes.name)||"generator"===h(t.attributes.name)||"framework"===h(t.attributes.name)||"publisher"===h(t.attributes.name)||"progid"===h(t.attributes.name)||h(t.attributes.property).match(/^article:/)||h(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===h(t.attributes.name)||"yandex-verification"===h(t.attributes.name)||"csrf-token"===h(t.attributes.name)||"p:domain_verify"===h(t.attributes.name)||"verify-v1"===h(t.attributes.name)||"verification"===h(t.attributes.name)||"shopify-checkout-api-token"===h(t.attributes.name)))return!0}}return!1}(D,b)&&(w||D.type!==e.NodeType.Text||D.isStyle||D.textContent.replace(/^\s+|\s+$/gm,"").length)?r++:a;var x=Object.assign(D,{id:i});if(t.__sn=x,i===a)return null;s[i]=t,C&&C(t);var A=!f;if(x.type===e.NodeType.Element&&(A=A&&!x.needBlock,delete x.needBlock),(x.type===e.NodeType.Document||x.type===e.NodeType.Element)&&A){b.headWhitespace&&D.type===e.NodeType.Element&&"head"===D.tagName&&(w=!1);for(var O=0,I=Array.from(t.childNodes);O<I.length;O++){var L=v(I[O],{doc:o,map:s,blockClass:c,blockSelector:u,skipChild:f,inlineStylesheet:d,maskInputOptions:g,slimDOMOptions:b,recordCanvas:N,preserveWhiteSpace:w,onSerialize:C,onIframeLoad:k,iframeLoadTimeout:S});L&&x.childNodes.push(L)}}return x.type===e.NodeType.Element&&"iframe"===x.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a=!1;if("complete"===n.document.readyState)"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t();else{var i=setTimeout(function(){a||(t(),a=!0)},r);e.addEventListener("load",function(){clearTimeout(i),a=!0,t()})}}}(t,function(){var e=t.contentDocument;if(e&&k){var r=v(e,{doc:e,map:s,blockClass:c,blockSelector:u,skipChild:!1,inlineStylesheet:d,maskInputOptions:g,slimDOMOptions:b,recordCanvas:N,preserveWhiteSpace:w,onSerialize:C,onIframeLoad:k,iframeLoadTimeout:S});r&&k(t,r)}},S),x}var y=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function g(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function i(){var e={line:r,column:n};return function(t){return t.position=new o(e),d(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return p(/^{\s*/)}function l(){return p(/^}/)}function f(){var t,r=[];for(d(),m(r);e.length&&"}"!==e.charAt(0)&&(t=w()||D());)!1!==t&&(r.push(t),m(r));return r}function p(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function d(){p(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=p(/^([^{]+)/);if(e)return b(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=i(),t=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=b(t[0]);if(!p(/^:\s*/))return c("property missing ':'");var n=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(y,""),value:n?b(n[0]).replace(y,""):""});return p(/^[;\s]*/),a}}function T(){var e,t=[];if(!u())return c("missing '{'");for(m(t);e=g();)!1!==e&&(t.push(e),m(t)),e=g();return l()?t:c("missing '}'")}function N(){for(var e,t=[],r=i();e=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),p(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:T()})}var C,k=_("import"),E=_("charset"),S=_("namespace");function _(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=p(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function w(){if("@"===e[0])return function(){var e=i(),t=p(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=p(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=m();n=N();)o.push(n),o=o.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=p(/^@media *([^{]+)/);if(t){var r=b(t[1]);if(!u())return c("@media missing '{'");var n=m().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=i(),t=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:b(t[1]),media:b(t[2])})}()||function(){var e=i(),t=p(/^@supports *([^{]+)/);if(t){var r=b(t[1]);if(!u())return c("@supports missing '{'");var n=m().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||k()||E()||S()||function(){var e=i(),t=p(/^@([-\w]+)?document *([^{]+)/);if(t){var r=b(t[1]),n=b(t[2]);if(!u())return c("@document missing '{'");var a=m().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=i();if(p(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=m();r=g();)n.push(r),n=n.concat(m());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=i();if(p(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=m().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(p(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=m();t=g();)r.push(t),r=r.concat(m());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function D(){var e=i(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:T()})):c("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var a=n?t:r;for(var i=0,o=Object.keys(t);i<o.length;i++){var s=o[i],c=t[s];Array.isArray(c)?c.forEach(function(t){e(t,a)}):c&&"object"==typeof c&&e(c,a)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}((C=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:C,parsingErrors:s}}))}function b(e){return e?e.replace(/^\s+|\s+$/g,""):""}var T={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var N=/([^\\]):hover/g;function C(e){var t=g(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(N.test(t)){var r=t.replace(N,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function k(t,r){var n=r.doc,a=r.hackCss;switch(t.type){case e.NodeType.Document:return n.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.NodeType.Element:var i,o=function(e){var t=T[e.tagName]?T[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);i=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",o):n.createElement(o);var s=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===o&&"rr_dataURL"===e){var s=document.createElement("img");s.src=r,s.onload=function(){var e=i.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===e&&(i.style.width=r),"rr_height"===e&&(i.style.height=r),"rr_mediaState"===e)switch(r){case"played":i.play();case"paused":i.pause()}}else{var c="textarea"===o&&"value"===e,u="style"===o&&"_cssText"===e;if(u&&a&&(r=C(r)),c||u){for(var l=n.createTextNode(r),f=0,p=Array.from(i.childNodes);f<p.length;f++){var d=p[f];d.nodeType===i.TEXT_NODE&&i.removeChild(d)}return i.appendChild(l),"continue"}if("iframe"===o&&"src"===e)return"continue";try{t.isSVG&&"xlink:href"===e?i.setAttributeNS("http://www.w3.org/1999/xlink",e,r):"onload"===e||"onclick"===e||"onmouse"===e.substring(0,7)?i.setAttribute("_"+e,r):i.setAttribute(e,r)}catch(e){}}};for(var c in t.attributes)s(c);return i;case e.NodeType.Text:return n.createTextNode(t.isStyle&&a?C(t.textContent):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function E(t,r){var n=r.doc,a=r.map,i=r.skipChild,o=void 0!==i&&i,s=r.hackCss,c=void 0===s||s,u=r.afterAppend,l=k(t,{doc:n,hackCss:c});if(!l)return null;if(t.rootId&&console.assert(a[t.rootId]===n,"Target document should has the same root id."),t.type===e.NodeType.Document&&(n.close(),n.open(),l=n),l.__sn=t,a[t.id]=l,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!o)for(var f=0,p=t.childNodes;f<p.length;f++){var d=p[f],m=E(d,{doc:n,map:a,skipChild:!1,hackCss:c,afterAppend:u});m?(l.appendChild(m),u&&u(m)):console.warn("Failed to rebuild",d)}return l}return e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.inlineStylesheet,o=void 0===i||i,s=r.recordCanvas,c=void 0!==s&&s,u=r.blockSelector,l=void 0===u?null:u,f=r.maskAllInputs,p=void 0!==f&&f,d=r.slimDOM,m=void 0!==d&&d,h={};return[v(e,{doc:e,map:h,blockClass:a,blockSelector:l,skipChild:!1,inlineStylesheet:o,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===p?{}:p,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:c,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]},e.serializeNodeWithId=v,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=E(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.NodeType.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)}),[s,o]},e.buildNodeWithSN=E,e.addHoverClass=C,e.transformAttribute=d,e.visitSnapshot=function(t,r){!function t(n){r(n),n.type!==e.NodeType.Document&&n.type!==e.NodeType.Element||n.childNodes.forEach(t)}(t)},e.cleanupSnapshot=function(){r=1},e.IGNORED_NODE=a,e}({});
var rrwebSnapshot=function(e){"use strict";var t;(t=e.NodeType||(e.NodeType={}))[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment";var r=1,n=RegExp("[^a-z1-6-_]"),a=-2;function i(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(o).join(""):null}catch(e){return null}}function o(e){return function(e){return"styleSheet"in e}(e)?i(e.styleSheet)||"":e.cssText}var s=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,c=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,u=/^(data:)([^,]*),(.*)/i;function l(e,t){return(e||"").replace(s,function(e,r,n,a,i,o){var s,l=n||i||o,f=r||a||"";if(!l)return e;if(!c.test(l))return"url("+f+l+f+")";if(u.test(l))return"url("+f+l+f+")";if("/"===l[0])return"url("+f+(((s=t).indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+l)+f+")";var p=t.split("/"),d=l.split("/");p.pop();for(var m=0,h=d;m<h.length;m++){var v=h[m];"."!==v&&(".."===v?p.pop():p.push(v))}return"url("+f+p.join("/")+f+")"})}function f(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function p(){var e=document.createElement("a");return e.href="",e.href}function d(e,t,r){return"src"===t||("href"===t||"xlink:href"===t)&&r?f(e,r):"srcset"===t&&r?function(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?f(e,r[0])+" "+r[1]:1===r.length?""+f(e,r[0]):""}).join(", ")}(e,r):"style"===t&&r?l(r,p()):r}function m(t,r){var a,o,s=r.doc,c=r.blockClass,u=r.blockSelector,f=r.inlineStylesheet,m=r.maskInputOptions,h=void 0===m?{}:m,v=r.recordCanvas;if(s.__sn){var y=s.__sn.id;a=1===y?void 0:y}switch(t.nodeType){case t.DOCUMENT_NODE:return{type:e.NodeType.Document,childNodes:[],rootId:a};case t.DOCUMENT_TYPE_NODE:return{type:e.NodeType.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:a};case t.ELEMENT_NODE:for(var g=function(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach(function(e){if(t.test(e))return!0});return!!r&&e.matches(r)}(t,c,u),b=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return n.test(t)?"div":t}(t),T={},N=0,C=Array.from(t.attributes);N<C.length;N++){var k=C[N],E=k.name,S=k.value;T[E]=d(s,E,S)}if("link"===b&&f){var _,w=Array.from(s.styleSheets).find(function(e){return e.href===t.href});(_=i(w))&&(delete T.rel,delete T.href,T._cssText=l(_,w.href))}if("style"===b&&t.sheet&&!(t.innerText||t.textContent||"").trim().length)(_=i(t.sheet))&&(T._cssText=l(_,p()));if("input"===b||"textarea"===b||"select"===b){S=t.value;"radio"!==T.type&&"checkbox"!==T.type&&"submit"!==T.type&&"button"!==T.type&&S?T.value=h[T.type]||h[b]?"*".repeat(S.length):S:t.checked&&(T.checked=t.checked)}if("option"===b){var D=t.parentElement;T.value===D.value&&(T.selected=t.selected)}if("canvas"===b&&v&&(T.rr_dataURL=t.toDataURL()),"audio"!==b&&"video"!==b||(T.rr_mediaState=t.paused?"paused":"played"),t.scrollLeft&&(T.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(T.rr_scrollTop=t.scrollTop),g){var x=t.getBoundingClientRect(),A=x.width,O=x.height;T={class:T.class,rr_width:A+"px",rr_height:O+"px"}}return"iframe"===b&&delete T.src,{type:e.NodeType.Element,tagName:b,attributes:T,childNodes:[],isSVG:(o=t,"svg"===o.tagName||o instanceof SVGElement||void 0),needBlock:g,rootId:a};case t.TEXT_NODE:var I=t.parentNode&&t.parentNode.tagName,L=t.textContent,M="STYLE"===I||void 0;return M&&L&&(L=l(L,p())),"SCRIPT"===I&&(L="SCRIPT_PLACEHOLDER"),{type:e.NodeType.Text,textContent:L||"",isStyle:M,rootId:a};case t.CDATA_SECTION_NODE:return{type:e.NodeType.CDATA,textContent:"",rootId:a};case t.COMMENT_NODE:return{type:e.NodeType.Comment,textContent:t.textContent||"",rootId:a};default:return!1}}function h(e){return void 0===e?"":e.toLowerCase()}function v(t,n){var i,o=n.doc,s=n.map,c=n.blockClass,u=n.blockSelector,l=n.skipChild,f=void 0!==l&&l,p=n.inlineStylesheet,d=void 0===p||p,y=n.maskInputOptions,g=void 0===y?{}:y,b=n.slimDOMOptions,T=n.recordCanvas,N=void 0!==T&&T,C=n.onSerialize,k=n.onIframeLoad,E=n.iframeLoadTimeout,S=void 0===E?5e3:E,_=n.preserveWhiteSpace,w=void 0===_||_,D=m(t,{doc:o,blockClass:c,blockSelector:u,inlineStylesheet:d,maskInputOptions:g,recordCanvas:N});if(!D)return console.warn(t,"not serialized"),null;i="__sn"in t?t.__sn.id:!function(t,r){if(r.comment&&t.type===e.NodeType.Comment)return!0;if(t.type===e.NodeType.Element){if(r.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as))return!0;if(r.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(h(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===h(t.attributes.name)||"icon"===h(t.attributes.rel)||"apple-touch-icon"===h(t.attributes.rel)||"shortcut icon"===h(t.attributes.rel))))return!0;if("meta"===t.tagName){if(r.headMetaDescKeywords&&h(t.attributes.name).match(/^description|keywords$/))return!0;if(r.headMetaSocial&&(h(t.attributes.property).match(/^(og|twitter|fb):/)||h(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===h(t.attributes.name)))return!0;if(r.headMetaRobots&&("robots"===h(t.attributes.name)||"googlebot"===h(t.attributes.name)||"bingbot"===h(t.attributes.name)))return!0;if(r.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(r.headMetaAuthorship&&("author"===h(t.attributes.name)||"generator"===h(t.attributes.name)||"framework"===h(t.attributes.name)||"publisher"===h(t.attributes.name)||"progid"===h(t.attributes.name)||h(t.attributes.property).match(/^article:/)||h(t.attributes.property).match(/^product:/)))return!0;if(r.headMetaVerification&&("google-site-verification"===h(t.attributes.name)||"yandex-verification"===h(t.attributes.name)||"csrf-token"===h(t.attributes.name)||"p:domain_verify"===h(t.attributes.name)||"verify-v1"===h(t.attributes.name)||"verification"===h(t.attributes.name)||"shopify-checkout-api-token"===h(t.attributes.name)))return!0}}return!1}(D,b)&&(w||D.type!==e.NodeType.Text||D.isStyle||D.textContent.replace(/^\s+|\s+$/gm,"").length)?r++:a;var x=Object.assign(D,{id:i});if(t.__sn=x,i===a)return null;s[i]=t,C&&C(t);var A=!f;if(x.type===e.NodeType.Element&&(A=A&&!x.needBlock,delete x.needBlock),(x.type===e.NodeType.Document||x.type===e.NodeType.Element)&&A){b.headWhitespace&&D.type===e.NodeType.Element&&"head"===D.tagName&&(w=!1);for(var O=0,I=Array.from(t.childNodes);O<I.length;O++){var L=v(I[O],{doc:o,map:s,blockClass:c,blockSelector:u,skipChild:f,inlineStylesheet:d,maskInputOptions:g,slimDOMOptions:b,recordCanvas:N,preserveWhiteSpace:w,onSerialize:C,onIframeLoad:k,iframeLoadTimeout:S});L&&x.childNodes.push(L)}}return x.type===e.NodeType.Element&&"iframe"===x.tagName&&function(e,t,r){var n=e.contentWindow;if(n){var a,i=!1;try{a=n.document.readyState}catch(e){return}if("complete"===a)"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t();else{var o=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()})}}}(t,function(){var e=t.contentDocument;if(e&&k){var r=v(e,{doc:e,map:s,blockClass:c,blockSelector:u,skipChild:!1,inlineStylesheet:d,maskInputOptions:g,slimDOMOptions:b,recordCanvas:N,preserveWhiteSpace:w,onSerialize:C,onIframeLoad:k,iframeLoadTimeout:S});r&&k(t,r)}},S),x}var y=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function g(e,t){void 0===t&&(t={});var r=1,n=1;function a(e){var t=e.match(/\n/g);t&&(r+=t.length);var a=e.lastIndexOf("\n");n=-1===a?n+e.length:e.length-a}function i(){var e={line:r,column:n};return function(t){return t.position=new o(e),d(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function c(a){var i=new Error(t.source+":"+r+":"+n+": "+a);if(i.reason=a,i.filename=t.source,i.line=r,i.column=n,i.source=e,!t.silent)throw i;s.push(i)}function u(){return p(/^{\s*/)}function l(){return p(/^}/)}function f(){var t,r=[];for(d(),m(r);e.length&&"}"!==e.charAt(0)&&(t=w()||D());)!1!==t&&(r.push(t),m(r));return r}function p(t){var r=t.exec(e);if(r){var n=r[0];return a(n),e=e.slice(n.length),r}}function d(){p(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=i();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return c("End of comment missing");var o=e.slice(2,r-2);return n+=2,a(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=p(/^([^{]+)/);if(e)return b(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=i(),t=p(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=b(t[0]);if(!p(/^:\s*/))return c("property missing ':'");var n=p(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),a=e({type:"declaration",property:r.replace(y,""),value:n?b(n[0]).replace(y,""):""});return p(/^[;\s]*/),a}}function T(){var e,t=[];if(!u())return c("missing '{'");for(m(t);e=g();)!1!==e&&(t.push(e),m(t)),e=g();return l()?t:c("missing '}'")}function N(){for(var e,t=[],r=i();e=p(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),p(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:T()})}var C,k=_("import"),E=_("charset"),S=_("namespace");function _(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=i(),n=p(t);if(n){var a={type:e};return a[e]=n[1].trim(),r(a)}}}function w(){if("@"===e[0])return function(){var e=i(),t=p(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=p(/^([-\w]+)\s*/)))return c("@keyframes missing name");var n,a=t[1];if(!u())return c("@keyframes missing '{'");for(var o=m();n=N();)o.push(n),o=o.concat(m());return l()?e({type:"keyframes",name:a,vendor:r,keyframes:o}):c("@keyframes missing '}'")}}()||function(){var e=i(),t=p(/^@media *([^{]+)/);if(t){var r=b(t[1]);if(!u())return c("@media missing '{'");var n=m().concat(f());return l()?e({type:"media",media:r,rules:n}):c("@media missing '}'")}}()||function(){var e=i(),t=p(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:b(t[1]),media:b(t[2])})}()||function(){var e=i(),t=p(/^@supports *([^{]+)/);if(t){var r=b(t[1]);if(!u())return c("@supports missing '{'");var n=m().concat(f());return l()?e({type:"supports",supports:r,rules:n}):c("@supports missing '}'")}}()||k()||E()||S()||function(){var e=i(),t=p(/^@([-\w]+)?document *([^{]+)/);if(t){var r=b(t[1]),n=b(t[2]);if(!u())return c("@document missing '{'");var a=m().concat(f());return l()?e({type:"document",document:n,vendor:r,rules:a}):c("@document missing '}'")}}()||function(){var e=i();if(p(/^@page */)){var t=v()||[];if(!u())return c("@page missing '{'");for(var r,n=m();r=g();)n.push(r),n=n.concat(m());return l()?e({type:"page",selectors:t,declarations:n}):c("@page missing '}'")}}()||function(){var e=i();if(p(/^@host\s*/)){if(!u())return c("@host missing '{'");var t=m().concat(f());return l()?e({type:"host",rules:t}):c("@host missing '}'")}}()||function(){var e=i();if(p(/^@font-face\s*/)){if(!u())return c("@font-face missing '{'");for(var t,r=m();t=g();)r.push(t),r=r.concat(m());return l()?e({type:"font-face",declarations:r}):c("@font-face missing '}'")}}()}function D(){var e=i(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:T()})):c("selector missing")}return function e(t,r){var n=t&&"string"==typeof t.type;var a=n?t:r;for(var i=0,o=Object.keys(t);i<o.length;i++){var s=o[i],c=t[s];Array.isArray(c)?c.forEach(function(t){e(t,a)}):c&&"object"==typeof c&&e(c,a)}n&&Object.defineProperty(t,"parent",{configurable:!0,writable:!0,enumerable:!1,value:r||null});return t}((C=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:C,parsingErrors:s}}))}function b(e){return e?e.replace(/^\s+|\s+$/g,""):""}var T={script:"noscript",altglyph:"altGlyph",altglyphdef:"altGlyphDef",altglyphitem:"altGlyphItem",animatecolor:"animateColor",animatemotion:"animateMotion",animatetransform:"animateTransform",clippath:"clipPath",feblend:"feBlend",fecolormatrix:"feColorMatrix",fecomponenttransfer:"feComponentTransfer",fecomposite:"feComposite",feconvolvematrix:"feConvolveMatrix",fediffuselighting:"feDiffuseLighting",fedisplacementmap:"feDisplacementMap",fedistantlight:"feDistantLight",fedropshadow:"feDropShadow",feflood:"feFlood",fefunca:"feFuncA",fefuncb:"feFuncB",fefuncg:"feFuncG",fefuncr:"feFuncR",fegaussianblur:"feGaussianBlur",feimage:"feImage",femerge:"feMerge",femergenode:"feMergeNode",femorphology:"feMorphology",feoffset:"feOffset",fepointlight:"fePointLight",fespecularlighting:"feSpecularLighting",fespotlight:"feSpotLight",fetile:"feTile",feturbulence:"feTurbulence",foreignobject:"foreignObject",glyphref:"glyphRef",lineargradient:"linearGradient",radialgradient:"radialGradient"};var N=/([^\\]):hover/g;function C(e){var t=g(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(N.test(t)){var r=t.replace(N,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function k(t,r){var n=r.doc,a=r.hackCss;switch(t.type){case e.NodeType.Document:return n.implementation.createDocument(null,"",null);case e.NodeType.DocumentType:return n.implementation.createDocumentType(t.name||"html",t.publicId,t.systemId);case e.NodeType.Element:var i,o=function(e){var t=T[e.tagName]?T[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}(t);i=t.isSVG?n.createElementNS("http://www.w3.org/2000/svg",o):n.createElement(o);var s=function(e){if(!t.attributes.hasOwnProperty(e))return"continue";var r=t.attributes[e];if(r="boolean"==typeof r||"number"==typeof r?"":r,e.startsWith("rr_")){if("canvas"===o&&"rr_dataURL"===e){var s=document.createElement("img");s.src=r,s.onload=function(){var e=i.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===e&&(i.style.width=r),"rr_height"===e&&(i.style.height=r),"rr_mediaState"===e)switch(r){case"played":i.play();case"paused":i.pause()}}else{var c="textarea"===o&&"value"===e,u="style"===o&&"_cssText"===e;if(u&&a&&(r=C(r)),c||u){for(var l=n.createTextNode(r),f=0,p=Array.from(i.childNodes);f<p.length;f++){var d=p[f];d.nodeType===i.TEXT_NODE&&i.removeChild(d)}return i.appendChild(l),"continue"}if("iframe"===o&&"src"===e)return"continue";try{t.isSVG&&"xlink:href"===e?i.setAttributeNS("http://www.w3.org/1999/xlink",e,r):"onload"===e||"onclick"===e||"onmouse"===e.substring(0,7)?i.setAttribute("_"+e,r):i.setAttribute(e,r)}catch(e){}}};for(var c in t.attributes)s(c);return i;case e.NodeType.Text:return n.createTextNode(t.isStyle&&a?C(t.textContent):t.textContent);case e.NodeType.CDATA:return n.createCDATASection(t.textContent);case e.NodeType.Comment:return n.createComment(t.textContent);default:return null}}function E(t,r){var n=r.doc,a=r.map,i=r.skipChild,o=void 0!==i&&i,s=r.hackCss,c=void 0===s||s,u=r.afterAppend,l=k(t,{doc:n,hackCss:c});if(!l)return null;if(t.rootId&&console.assert(a[t.rootId]===n,"Target document should has the same root id."),t.type===e.NodeType.Document&&(n.close(),n.open(),l=n),l.__sn=t,a[t.id]=l,(t.type===e.NodeType.Document||t.type===e.NodeType.Element)&&!o)for(var f=0,p=t.childNodes;f<p.length;f++){var d=p[f],m=E(d,{doc:n,map:a,skipChild:!1,hackCss:c,afterAppend:u});m?(l.appendChild(m),u&&u(m)):console.warn("Failed to rebuild",d)}return l}return e.snapshot=function(e,t){var r=t||{},n=r.blockClass,a=void 0===n?"rr-block":n,i=r.inlineStylesheet,o=void 0===i||i,s=r.recordCanvas,c=void 0!==s&&s,u=r.blockSelector,l=void 0===u?null:u,f=r.maskAllInputs,p=void 0!==f&&f,d=r.slimDOM,m=void 0!==d&&d,h={};return[v(e,{doc:e,map:h,blockClass:a,blockSelector:l,skipChild:!1,inlineStylesheet:o,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===p?{}:p,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:c,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]},e.serializeNodeWithId=v,e.rebuild=function(t,r){var n=r.doc,a=r.onVisit,i=r.hackCss,o={},s=E(t,{doc:n,map:o,skipChild:!1,hackCss:void 0===i||i,afterAppend:r.afterAppend});return function(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}(o,function(t){a&&a(t),function(t){var r=t.__sn;if(r.type===e.NodeType.Element){var n=t;for(var a in r.attributes)if(r.attributes.hasOwnProperty(a)&&a.startsWith("rr_")){var i=r.attributes[a];"rr_scrollLeft"===a&&(n.scrollLeft=i),"rr_scrollTop"===a&&(n.scrollTop=i)}}}(t)}),[s,o]},e.buildNodeWithSN=E,e.addHoverClass=C,e.transformAttribute=d,e.visitSnapshot=function(t,r){!function t(n){r(n),n.type!==e.NodeType.Document&&n.type!==e.NodeType.Element||n.childNodes.forEach(t)}(t)},e.cleanupSnapshot=function(){r=1},e.IGNORED_NODE=a,e}({});
//# sourceMappingURL=rrweb-snapshot.min.js.map

@@ -168,3 +168,10 @@ var NodeType;

var fired = false;
if (win.document.readyState !== 'complete') {
var readyState;
try {
readyState = win.document.readyState;
}
catch (error) {
return;
}
if (readyState !== 'complete') {
var timer_1 = setTimeout(function () {

@@ -171,0 +178,0 @@ if (!fired) {

@@ -1,2 +0,2 @@

var NodeType;!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"}(NodeType||(NodeType={}));var _id=1,tagNameRegex=RegExp("[^a-z1-6-_]"),IGNORED_NODE=-2;function genId(){return _id++}function getValidTagName(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return tagNameRegex.test(t)?"div":t}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(getCssRuleString).join(""):null}catch(e){return null}}function getCssRuleString(e){return isCSSImportRule(e)?getCssRulesString(e.styleSheet)||"":e.cssText}function isCSSImportRule(e){return"styleSheet"in e}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,DATA_URI=/^(data:)([^,]*),(.*)/i;function absoluteToStylesheet(e,t){return(e||"").replace(URL_IN_CSS_REF,function(e,r,n,i,a,o){var s=n||a||o,l=r||i||"";if(!s)return e;if(!RELATIVE_PATH.test(s))return"url("+l+s+l+")";if(DATA_URI.test(s))return"url("+l+s+l+")";if("/"===s[0])return"url("+l+(extractOrigin(t)+s)+l+")";var c=t.split("/"),u=s.split("/");c.pop();for(var f=0,d=u;f<d.length;f++){var p=d[f];"."!==p&&(".."===p?c.pop():c.push(p))}return"url("+l+c.join("/")+l+")"})}function getAbsoluteSrcsetString(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?absoluteToDoc(e,r[0])+" "+r[1]:1===r.length?""+absoluteToDoc(e,r[0]):""}).join(", ")}function absoluteToDoc(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}function getHref(){var e=document.createElement("a");return e.href="",e.href}function transformAttribute(e,t,r){return"src"===t||("href"===t||"xlink:href"===t)&&r?absoluteToDoc(e,r):"srcset"===t&&r?getAbsoluteSrcsetString(e,r):"style"===t&&r?absoluteToStylesheet(r,getHref()):r}function _isBlockedElement(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach(function(e){if(t.test(e))return!0});return!!r&&e.matches(r)}function onceIframeLoaded(e,t,r){var n=e.contentWindow;if(n){var i=!1;if("complete"===n.document.readyState){"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t()}else{var a=setTimeout(function(){i||(t(),i=!0)},r);e.addEventListener("load",function(){clearTimeout(a),i=!0,t()})}}}function serializeNode(e,t){var r,n=t.doc,i=t.blockClass,a=t.blockSelector,o=t.inlineStylesheet,s=t.maskInputOptions,l=void 0===s?{}:s,c=t.recordCanvas;if(n.__sn){var u=n.__sn.id;r=1===u?void 0:u}switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[],rootId:r};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:r};case e.ELEMENT_NODE:for(var f=_isBlockedElement(e,i,a),d=getValidTagName(e),p={},m=0,h=Array.from(e.attributes);m<h.length;m++){var v=h[m],g=v.name,y=v.value;p[g]=transformAttribute(n,g,y)}if("link"===d&&o){var b,E=Array.from(n.styleSheets).find(function(t){return t.href===e.href});(b=getCssRulesString(E))&&(delete p.rel,delete p.href,p._cssText=absoluteToStylesheet(b,E.href))}if("style"===d&&e.sheet&&!(e.innerText||e.textContent||"").trim().length)(b=getCssRulesString(e.sheet))&&(p._cssText=absoluteToStylesheet(b,getHref()));if("input"===d||"textarea"===d||"select"===d){y=e.value;"radio"!==p.type&&"checkbox"!==p.type&&"submit"!==p.type&&"button"!==p.type&&y?p.value=l[p.type]||l[d]?"*".repeat(y.length):y:e.checked&&(p.checked=e.checked)}if("option"===d){var T=e.parentElement;p.value===T.value&&(p.selected=e.selected)}if("canvas"===d&&c&&(p.rr_dataURL=e.toDataURL()),"audio"!==d&&"video"!==d||(p.rr_mediaState=e.paused?"paused":"played"),e.scrollLeft&&(p.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(p.rr_scrollTop=e.scrollTop),f){var N=e.getBoundingClientRect(),C=N.width,S=N.height;p={class:p.class,rr_width:C+"px",rr_height:S+"px"}}return"iframe"===d&&delete p.src,{type:NodeType.Element,tagName:d,attributes:p,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:f,rootId:r};case e.TEXT_NODE:var I=e.parentNode&&e.parentNode.tagName,x=e.textContent,w="STYLE"===I||void 0;return w&&x&&(x=absoluteToStylesheet(x,getHref())),"SCRIPT"===I&&(x="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:x||"",isStyle:w,rootId:r};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:"",rootId:r};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||"",rootId:r};default:return!1}}function lowerIfExists(e){return void 0===e?"":e.toLowerCase()}function slimDOMExcluded(e,t){if(t.comment&&e.type===NodeType.Comment)return!0;if(e.type===NodeType.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(lowerIfExists(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===lowerIfExists(e.attributes.name)||"icon"===lowerIfExists(e.attributes.rel)||"apple-touch-icon"===lowerIfExists(e.attributes.rel)||"shortcut icon"===lowerIfExists(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&lowerIfExists(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(lowerIfExists(e.attributes.property).match(/^(og|twitter|fb):/)||lowerIfExists(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===lowerIfExists(e.attributes.name)||"googlebot"===lowerIfExists(e.attributes.name)||"bingbot"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===lowerIfExists(e.attributes.name)||"generator"===lowerIfExists(e.attributes.name)||"framework"===lowerIfExists(e.attributes.name)||"publisher"===lowerIfExists(e.attributes.name)||"progid"===lowerIfExists(e.attributes.name)||lowerIfExists(e.attributes.property).match(/^article:/)||lowerIfExists(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===lowerIfExists(e.attributes.name)||"yandex-verification"===lowerIfExists(e.attributes.name)||"csrf-token"===lowerIfExists(e.attributes.name)||"p:domain_verify"===lowerIfExists(e.attributes.name)||"verify-v1"===lowerIfExists(e.attributes.name)||"verification"===lowerIfExists(e.attributes.name)||"shopify-checkout-api-token"===lowerIfExists(e.attributes.name)))return!0}}return!1}function serializeNodeWithId(e,t){var r,n=t.doc,i=t.map,a=t.blockClass,o=t.blockSelector,s=t.skipChild,l=void 0!==s&&s,c=t.inlineStylesheet,u=void 0===c||c,f=t.maskInputOptions,d=void 0===f?{}:f,p=t.slimDOMOptions,m=t.recordCanvas,h=void 0!==m&&m,v=t.onSerialize,g=t.onIframeLoad,y=t.iframeLoadTimeout,b=void 0===y?5e3:y,E=t.preserveWhiteSpace,T=void 0===E||E,N=serializeNode(e,{doc:n,blockClass:a,blockSelector:o,inlineStylesheet:u,maskInputOptions:d,recordCanvas:h});if(!N)return console.warn(e,"not serialized"),null;r="__sn"in e?e.__sn.id:slimDOMExcluded(N,p)||!T&&N.type===NodeType.Text&&!N.isStyle&&!N.textContent.replace(/^\s+|\s+$/gm,"").length?IGNORED_NODE:genId();var C=Object.assign(N,{id:r});if(e.__sn=C,r===IGNORED_NODE)return null;i[r]=e,v&&v(e);var S=!l;if(C.type===NodeType.Element&&(S=S&&!C.needBlock,delete C.needBlock),(C.type===NodeType.Document||C.type===NodeType.Element)&&S){p.headWhitespace&&N.type===NodeType.Element&&"head"===N.tagName&&(T=!1);for(var I=0,x=Array.from(e.childNodes);I<x.length;I++){var w=serializeNodeWithId(x[I],{doc:n,map:i,blockClass:a,blockSelector:o,skipChild:l,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b});w&&C.childNodes.push(w)}}return C.type===NodeType.Element&&"iframe"===C.tagName&&onceIframeLoaded(e,function(){var t=e.contentDocument;if(t&&g){var r=serializeNodeWithId(t,{doc:t,map:i,blockClass:a,blockSelector:o,skipChild:!1,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b});r&&g(e,r)}},b),C}function snapshot(e,t){var r=t||{},n=r.blockClass,i=void 0===n?"rr-block":n,a=r.inlineStylesheet,o=void 0===a||a,s=r.recordCanvas,l=void 0!==s&&s,c=r.blockSelector,u=void 0===c?null:c,f=r.maskAllInputs,d=void 0!==f&&f,p=r.slimDOM,m=void 0!==p&&p,h={};return[serializeNodeWithId(e,{doc:e,map:h,blockClass:i,blockSelector:u,skipChild:!1,inlineStylesheet:o,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===d?{}:d,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:l,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]}function visitSnapshot(e,t){!function e(r){t(r),r.type!==NodeType.Document&&r.type!==NodeType.Element||r.childNodes.forEach(e)}(e)}function cleanupSnapshot(){_id=1}var commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function parse(e,t){void 0===t&&(t={});var r=1,n=1;function i(e){var t=e.match(/\n/g);t&&(r+=t.length);var i=e.lastIndexOf("\n");n=-1===i?n+e.length:e.length-i}function a(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function l(i){var a=new Error(t.source+":"+r+":"+n+": "+i);if(a.reason=i,a.filename=t.source,a.line=r,a.column=n,a.source=e,!t.silent)throw a;s.push(a)}function c(){return d(/^{\s*/)}function u(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=I()||x());)!1!==t&&(r.push(t),m(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return i(n),e=e.slice(n.length),r}}function p(){d(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=a();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var o=e.slice(2,r-2);return n+=2,i(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=d(/^([^{]+)/);if(e)return trim(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=a(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=trim(t[0]);if(!d(/^:\s*/))return l("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:r.replace(commentre,""),value:n?trim(n[0]).replace(commentre,""):""});return d(/^[;\s]*/),i}}function y(){var e,t=[];if(!c())return l("missing '{'");for(m(t);e=g();)!1!==e&&(t.push(e),m(t)),e=g();return u()?t:l("missing '}'")}function b(){for(var e,t=[],r=a();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var E,T=S("import"),N=S("charset"),C=S("namespace");function S(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=a(),n=d(t);if(n){var i={type:e};return i[e]=n[1].trim(),r(i)}}}function I(){if("@"===e[0])return function(){var e=a(),t=d(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return l("@keyframes missing name");var n,i=t[1];if(!c())return l("@keyframes missing '{'");for(var o=m();n=b();)o.push(n),o=o.concat(m());return u()?e({type:"keyframes",name:i,vendor:r,keyframes:o}):l("@keyframes missing '}'")}}()||function(){var e=a(),t=d(/^@media *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@media missing '{'");var n=m().concat(f());return u()?e({type:"media",media:r,rules:n}):l("@media missing '}'")}}()||function(){var e=a(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:trim(t[1]),media:trim(t[2])})}()||function(){var e=a(),t=d(/^@supports *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@supports missing '{'");var n=m().concat(f());return u()?e({type:"supports",supports:r,rules:n}):l("@supports missing '}'")}}()||T()||N()||C()||function(){var e=a(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=trim(t[1]),n=trim(t[2]);if(!c())return l("@document missing '{'");var i=m().concat(f());return u()?e({type:"document",document:n,vendor:r,rules:i}):l("@document missing '}'")}}()||function(){var e=a();if(d(/^@page */)){var t=v()||[];if(!c())return l("@page missing '{'");for(var r,n=m();r=g();)n.push(r),n=n.concat(m());return u()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}()||function(){var e=a();if(d(/^@host\s*/)){if(!c())return l("@host missing '{'");var t=m().concat(f());return u()?e({type:"host",rules:t}):l("@host missing '}'")}}()||function(){var e=a();if(d(/^@font-face\s*/)){if(!c())return l("@font-face missing '{'");for(var t,r=m();t=g();)r.push(t),r=r.concat(m());return u()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}()}function x(){var e=a(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:y()})):l("selector missing")}return addParent((E=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:s}}))}function trim(e){return e?e.replace(/^\s+|\s+$/g,""):""}function addParent(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,i=0,a=Object.keys(e);i<a.length;i++){var o=e[a[i]];Array.isArray(o)?o.forEach(function(e){addParent(e,n)}):o&&"object"==typeof o&&addParent(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var tagMap={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 getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}var HOVER_SELECTOR=/([^\\]):hover/g;function addHoverClass(e){var t=parse(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(HOVER_SELECTOR.test(t)){var r=t.replace(HOVER_SELECTOR,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function buildNode(e,t){var r=t.doc,n=t.hackCss;switch(e.type){case NodeType.Document:return r.implementation.createDocument(null,"",null);case NodeType.DocumentType:return r.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case NodeType.Element:var i,a=getTagName(e);i=e.isSVG?r.createElementNS("http://www.w3.org/2000/svg",a):r.createElement(a);var o=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";var o=e.attributes[t];if(o="boolean"==typeof o||"number"==typeof o?"":o,t.startsWith("rr_")){if("canvas"===a&&"rr_dataURL"===t){var s=document.createElement("img");s.src=o,s.onload=function(){var e=i.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===t&&(i.style.width=o),"rr_height"===t&&(i.style.height=o),"rr_mediaState"===t)switch(o){case"played":i.play();case"paused":i.pause()}}else{var l="textarea"===a&&"value"===t,c="style"===a&&"_cssText"===t;if(c&&n&&(o=addHoverClass(o)),l||c){for(var u=r.createTextNode(o),f=0,d=Array.from(i.childNodes);f<d.length;f++){var p=d[f];p.nodeType===i.TEXT_NODE&&i.removeChild(p)}return i.appendChild(u),"continue"}if("iframe"===a&&"src"===t)return"continue";try{e.isSVG&&"xlink:href"===t?i.setAttributeNS("http://www.w3.org/1999/xlink",t,o):"onload"===t||"onclick"===t||"onmouse"===t.substring(0,7)?i.setAttribute("_"+t,o):i.setAttribute(t,o)}catch(e){}}};for(var s in e.attributes)o(s);return i;case NodeType.Text:return r.createTextNode(e.isStyle&&n?addHoverClass(e.textContent):e.textContent);case NodeType.CDATA:return r.createCDATASection(e.textContent);case NodeType.Comment:return r.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t){var r=t.doc,n=t.map,i=t.skipChild,a=void 0!==i&&i,o=t.hackCss,s=void 0===o||o,l=t.afterAppend,c=buildNode(e,{doc:r,hackCss:s});if(!c)return null;if(e.rootId&&console.assert(n[e.rootId]===r,"Target document should has the same root id."),e.type===NodeType.Document&&(r.close(),r.open(),c=r),c.__sn=e,n[e.id]=c,(e.type===NodeType.Document||e.type===NodeType.Element)&&!a)for(var u=0,f=e.childNodes;u<f.length;u++){var d=f[u],p=buildNodeWithSN(d,{doc:r,map:n,skipChild:!1,hackCss:s,afterAppend:l});p?(c.appendChild(p),l&&l(p)):console.warn("Failed to rebuild",d)}return c}function visit(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}function handleScroll(e){var t=e.__sn;if(t.type===NodeType.Element){var r=e;for(var n in t.attributes)if(t.attributes.hasOwnProperty(n)&&n.startsWith("rr_")){var i=t.attributes[n];"rr_scrollLeft"===n&&(r.scrollLeft=i),"rr_scrollTop"===n&&(r.scrollTop=i)}}}function rebuild(e,t){var r=t.doc,n=t.onVisit,i=t.hackCss,a={},o=buildNodeWithSN(e,{doc:r,map:a,skipChild:!1,hackCss:void 0===i||i,afterAppend:t.afterAppend});return visit(a,function(e){n&&n(e),handleScroll(e)}),[o,a]}export{snapshot,serializeNodeWithId,rebuild,buildNodeWithSN,addHoverClass,transformAttribute,visitSnapshot,cleanupSnapshot,IGNORED_NODE,NodeType};
var NodeType;!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"}(NodeType||(NodeType={}));var _id=1,tagNameRegex=RegExp("[^a-z1-6-_]"),IGNORED_NODE=-2;function genId(){return _id++}function getValidTagName(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return tagNameRegex.test(t)?"div":t}function getCssRulesString(e){try{var t=e.rules||e.cssRules;return t?Array.from(t).map(getCssRuleString).join(""):null}catch(e){return null}}function getCssRuleString(e){return isCSSImportRule(e)?getCssRulesString(e.styleSheet)||"":e.cssText}function isCSSImportRule(e){return"styleSheet"in e}function extractOrigin(e){return(e.indexOf("//")>-1?e.split("/").slice(0,3).join("/"):e.split("/")[0]).split("?")[0]}var URL_IN_CSS_REF=/url\((?:(')([^']*)'|(")([^"]*)"|([^)]*))\)/gm,RELATIVE_PATH=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,DATA_URI=/^(data:)([^,]*),(.*)/i;function absoluteToStylesheet(e,t){return(e||"").replace(URL_IN_CSS_REF,function(e,r,n,i,a,o){var s=n||a||o,l=r||i||"";if(!s)return e;if(!RELATIVE_PATH.test(s))return"url("+l+s+l+")";if(DATA_URI.test(s))return"url("+l+s+l+")";if("/"===s[0])return"url("+l+(extractOrigin(t)+s)+l+")";var c=t.split("/"),u=s.split("/");c.pop();for(var f=0,d=u;f<d.length;f++){var p=d[f];"."!==p&&(".."===p?c.pop():c.push(p))}return"url("+l+c.join("/")+l+")"})}function getAbsoluteSrcsetString(e,t){return""===t.trim()?t:t.split(",").map(function(t){var r=t.trimLeft().trimRight().split(" ");return 2===r.length?absoluteToDoc(e,r[0])+" "+r[1]:1===r.length?""+absoluteToDoc(e,r[0]):""}).join(", ")}function absoluteToDoc(e,t){if(!t||""===t.trim())return t;var r=e.createElement("a");return r.href=t,r.href}function isSVGElement(e){return"svg"===e.tagName||e instanceof SVGElement}function getHref(){var e=document.createElement("a");return e.href="",e.href}function transformAttribute(e,t,r){return"src"===t||("href"===t||"xlink:href"===t)&&r?absoluteToDoc(e,r):"srcset"===t&&r?getAbsoluteSrcsetString(e,r):"style"===t&&r?absoluteToStylesheet(r,getHref()):r}function _isBlockedElement(e,t,r){if("string"==typeof t){if(e.classList.contains(t))return!0}else e.classList.forEach(function(e){if(t.test(e))return!0});return!!r&&e.matches(r)}function onceIframeLoaded(e,t,r){var n=e.contentWindow;if(n){var i,a=!1;try{i=n.document.readyState}catch(e){return}if("complete"===i){"about:blank"===n.location.href&&"about:blank"!==e.src&&""!==e.src?e.addEventListener("load",t):t()}else{var o=setTimeout(function(){a||(t(),a=!0)},r);e.addEventListener("load",function(){clearTimeout(o),a=!0,t()})}}}function serializeNode(e,t){var r,n=t.doc,i=t.blockClass,a=t.blockSelector,o=t.inlineStylesheet,s=t.maskInputOptions,l=void 0===s?{}:s,c=t.recordCanvas;if(n.__sn){var u=n.__sn.id;r=1===u?void 0:u}switch(e.nodeType){case e.DOCUMENT_NODE:return{type:NodeType.Document,childNodes:[],rootId:r};case e.DOCUMENT_TYPE_NODE:return{type:NodeType.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:r};case e.ELEMENT_NODE:for(var f=_isBlockedElement(e,i,a),d=getValidTagName(e),p={},m=0,h=Array.from(e.attributes);m<h.length;m++){var v=h[m],g=v.name,y=v.value;p[g]=transformAttribute(n,g,y)}if("link"===d&&o){var b,E=Array.from(n.styleSheets).find(function(t){return t.href===e.href});(b=getCssRulesString(E))&&(delete p.rel,delete p.href,p._cssText=absoluteToStylesheet(b,E.href))}if("style"===d&&e.sheet&&!(e.innerText||e.textContent||"").trim().length)(b=getCssRulesString(e.sheet))&&(p._cssText=absoluteToStylesheet(b,getHref()));if("input"===d||"textarea"===d||"select"===d){y=e.value;"radio"!==p.type&&"checkbox"!==p.type&&"submit"!==p.type&&"button"!==p.type&&y?p.value=l[p.type]||l[d]?"*".repeat(y.length):y:e.checked&&(p.checked=e.checked)}if("option"===d){var T=e.parentElement;p.value===T.value&&(p.selected=e.selected)}if("canvas"===d&&c&&(p.rr_dataURL=e.toDataURL()),"audio"!==d&&"video"!==d||(p.rr_mediaState=e.paused?"paused":"played"),e.scrollLeft&&(p.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(p.rr_scrollTop=e.scrollTop),f){var N=e.getBoundingClientRect(),C=N.width,S=N.height;p={class:p.class,rr_width:C+"px",rr_height:S+"px"}}return"iframe"===d&&delete p.src,{type:NodeType.Element,tagName:d,attributes:p,childNodes:[],isSVG:isSVGElement(e)||void 0,needBlock:f,rootId:r};case e.TEXT_NODE:var I=e.parentNode&&e.parentNode.tagName,x=e.textContent,w="STYLE"===I||void 0;return w&&x&&(x=absoluteToStylesheet(x,getHref())),"SCRIPT"===I&&(x="SCRIPT_PLACEHOLDER"),{type:NodeType.Text,textContent:x||"",isStyle:w,rootId:r};case e.CDATA_SECTION_NODE:return{type:NodeType.CDATA,textContent:"",rootId:r};case e.COMMENT_NODE:return{type:NodeType.Comment,textContent:e.textContent||"",rootId:r};default:return!1}}function lowerIfExists(e){return void 0===e?"":e.toLowerCase()}function slimDOMExcluded(e,t){if(t.comment&&e.type===NodeType.Comment)return!0;if(e.type===NodeType.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&"preload"===e.attributes.rel&&"script"===e.attributes.as))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(lowerIfExists(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===lowerIfExists(e.attributes.name)||"icon"===lowerIfExists(e.attributes.rel)||"apple-touch-icon"===lowerIfExists(e.attributes.rel)||"shortcut icon"===lowerIfExists(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&lowerIfExists(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(lowerIfExists(e.attributes.property).match(/^(og|twitter|fb):/)||lowerIfExists(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===lowerIfExists(e.attributes.name)||"googlebot"===lowerIfExists(e.attributes.name)||"bingbot"===lowerIfExists(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===lowerIfExists(e.attributes.name)||"generator"===lowerIfExists(e.attributes.name)||"framework"===lowerIfExists(e.attributes.name)||"publisher"===lowerIfExists(e.attributes.name)||"progid"===lowerIfExists(e.attributes.name)||lowerIfExists(e.attributes.property).match(/^article:/)||lowerIfExists(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===lowerIfExists(e.attributes.name)||"yandex-verification"===lowerIfExists(e.attributes.name)||"csrf-token"===lowerIfExists(e.attributes.name)||"p:domain_verify"===lowerIfExists(e.attributes.name)||"verify-v1"===lowerIfExists(e.attributes.name)||"verification"===lowerIfExists(e.attributes.name)||"shopify-checkout-api-token"===lowerIfExists(e.attributes.name)))return!0}}return!1}function serializeNodeWithId(e,t){var r,n=t.doc,i=t.map,a=t.blockClass,o=t.blockSelector,s=t.skipChild,l=void 0!==s&&s,c=t.inlineStylesheet,u=void 0===c||c,f=t.maskInputOptions,d=void 0===f?{}:f,p=t.slimDOMOptions,m=t.recordCanvas,h=void 0!==m&&m,v=t.onSerialize,g=t.onIframeLoad,y=t.iframeLoadTimeout,b=void 0===y?5e3:y,E=t.preserveWhiteSpace,T=void 0===E||E,N=serializeNode(e,{doc:n,blockClass:a,blockSelector:o,inlineStylesheet:u,maskInputOptions:d,recordCanvas:h});if(!N)return console.warn(e,"not serialized"),null;r="__sn"in e?e.__sn.id:slimDOMExcluded(N,p)||!T&&N.type===NodeType.Text&&!N.isStyle&&!N.textContent.replace(/^\s+|\s+$/gm,"").length?IGNORED_NODE:genId();var C=Object.assign(N,{id:r});if(e.__sn=C,r===IGNORED_NODE)return null;i[r]=e,v&&v(e);var S=!l;if(C.type===NodeType.Element&&(S=S&&!C.needBlock,delete C.needBlock),(C.type===NodeType.Document||C.type===NodeType.Element)&&S){p.headWhitespace&&N.type===NodeType.Element&&"head"===N.tagName&&(T=!1);for(var I=0,x=Array.from(e.childNodes);I<x.length;I++){var w=serializeNodeWithId(x[I],{doc:n,map:i,blockClass:a,blockSelector:o,skipChild:l,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b});w&&C.childNodes.push(w)}}return C.type===NodeType.Element&&"iframe"===C.tagName&&onceIframeLoaded(e,function(){var t=e.contentDocument;if(t&&g){var r=serializeNodeWithId(t,{doc:t,map:i,blockClass:a,blockSelector:o,skipChild:!1,inlineStylesheet:u,maskInputOptions:d,slimDOMOptions:p,recordCanvas:h,preserveWhiteSpace:T,onSerialize:v,onIframeLoad:g,iframeLoadTimeout:b});r&&g(e,r)}},b),C}function snapshot(e,t){var r=t||{},n=r.blockClass,i=void 0===n?"rr-block":n,a=r.inlineStylesheet,o=void 0===a||a,s=r.recordCanvas,l=void 0!==s&&s,c=r.blockSelector,u=void 0===c?null:c,f=r.maskAllInputs,d=void 0!==f&&f,p=r.slimDOM,m=void 0!==p&&p,h={};return[serializeNodeWithId(e,{doc:e,map:h,blockClass:i,blockSelector:u,skipChild:!1,inlineStylesheet:o,maskInputOptions:!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0}:!1===d?{}:d,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,recordCanvas:l,preserveWhiteSpace:r.preserveWhiteSpace,onSerialize:r.onSerialize,onIframeLoad:r.onIframeLoad,iframeLoadTimeout:r.iframeLoadTimeout}),h]}function visitSnapshot(e,t){!function e(r){t(r),r.type!==NodeType.Document&&r.type!==NodeType.Element||r.childNodes.forEach(e)}(e)}function cleanupSnapshot(){_id=1}var commentre=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g;function parse(e,t){void 0===t&&(t={});var r=1,n=1;function i(e){var t=e.match(/\n/g);t&&(r+=t.length);var i=e.lastIndexOf("\n");n=-1===i?n+e.length:e.length-i}function a(){var e={line:r,column:n};return function(t){return t.position=new o(e),p(),t}}var o=function(){return function(e){this.start=e,this.end={line:r,column:n},this.source=t.source}}();o.prototype.content=e;var s=[];function l(i){var a=new Error(t.source+":"+r+":"+n+": "+i);if(a.reason=i,a.filename=t.source,a.line=r,a.column=n,a.source=e,!t.silent)throw a;s.push(a)}function c(){return d(/^{\s*/)}function u(){return d(/^}/)}function f(){var t,r=[];for(p(),m(r);e.length&&"}"!==e.charAt(0)&&(t=I()||x());)!1!==t&&(r.push(t),m(r));return r}function d(t){var r=t.exec(e);if(r){var n=r[0];return i(n),e=e.slice(n.length),r}}function p(){d(/^\s*/)}function m(e){var t;for(void 0===e&&(e=[]);t=h();)!1!==t&&e.push(t),t=h();return e}function h(){var t=a();if("/"===e.charAt(0)&&"*"===e.charAt(1)){for(var r=2;""!==e.charAt(r)&&("*"!==e.charAt(r)||"/"!==e.charAt(r+1));)++r;if(r+=2,""===e.charAt(r-1))return l("End of comment missing");var o=e.slice(2,r-2);return n+=2,i(o),e=e.slice(r),n+=2,t({type:"comment",comment:o})}}function v(){var e=d(/^([^{]+)/);if(e)return trim(e[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g,"").replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g,function(e){return e.replace(/,/g,"‌")}).split(/\s*(?![^(]*\)),\s*/).map(function(e){return e.replace(/\u200C/g,",")})}function g(){var e=a(),t=d(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/);if(t){var r=trim(t[0]);if(!d(/^:\s*/))return l("property missing ':'");var n=d(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/),i=e({type:"declaration",property:r.replace(commentre,""),value:n?trim(n[0]).replace(commentre,""):""});return d(/^[;\s]*/),i}}function y(){var e,t=[];if(!c())return l("missing '{'");for(m(t);e=g();)!1!==e&&(t.push(e),m(t)),e=g();return u()?t:l("missing '}'")}function b(){for(var e,t=[],r=a();e=d(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/);)t.push(e[1]),d(/^,\s*/);if(t.length)return r({type:"keyframe",values:t,declarations:y()})}var E,T=S("import"),N=S("charset"),C=S("namespace");function S(e){var t=new RegExp("^@"+e+"\\s*([^;]+);");return function(){var r=a(),n=d(t);if(n){var i={type:e};return i[e]=n[1].trim(),r(i)}}}function I(){if("@"===e[0])return function(){var e=a(),t=d(/^@([-\w]+)?keyframes\s*/);if(t){var r=t[1];if(!(t=d(/^([-\w]+)\s*/)))return l("@keyframes missing name");var n,i=t[1];if(!c())return l("@keyframes missing '{'");for(var o=m();n=b();)o.push(n),o=o.concat(m());return u()?e({type:"keyframes",name:i,vendor:r,keyframes:o}):l("@keyframes missing '}'")}}()||function(){var e=a(),t=d(/^@media *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@media missing '{'");var n=m().concat(f());return u()?e({type:"media",media:r,rules:n}):l("@media missing '}'")}}()||function(){var e=a(),t=d(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/);if(t)return e({type:"custom-media",name:trim(t[1]),media:trim(t[2])})}()||function(){var e=a(),t=d(/^@supports *([^{]+)/);if(t){var r=trim(t[1]);if(!c())return l("@supports missing '{'");var n=m().concat(f());return u()?e({type:"supports",supports:r,rules:n}):l("@supports missing '}'")}}()||T()||N()||C()||function(){var e=a(),t=d(/^@([-\w]+)?document *([^{]+)/);if(t){var r=trim(t[1]),n=trim(t[2]);if(!c())return l("@document missing '{'");var i=m().concat(f());return u()?e({type:"document",document:n,vendor:r,rules:i}):l("@document missing '}'")}}()||function(){var e=a();if(d(/^@page */)){var t=v()||[];if(!c())return l("@page missing '{'");for(var r,n=m();r=g();)n.push(r),n=n.concat(m());return u()?e({type:"page",selectors:t,declarations:n}):l("@page missing '}'")}}()||function(){var e=a();if(d(/^@host\s*/)){if(!c())return l("@host missing '{'");var t=m().concat(f());return u()?e({type:"host",rules:t}):l("@host missing '}'")}}()||function(){var e=a();if(d(/^@font-face\s*/)){if(!c())return l("@font-face missing '{'");for(var t,r=m();t=g();)r.push(t),r=r.concat(m());return u()?e({type:"font-face",declarations:r}):l("@font-face missing '}'")}}()}function x(){var e=a(),t=v();return t?(m(),e({type:"rule",selectors:t,declarations:y()})):l("selector missing")}return addParent((E=f(),{type:"stylesheet",stylesheet:{source:t.source,rules:E,parsingErrors:s}}))}function trim(e){return e?e.replace(/^\s+|\s+$/g,""):""}function addParent(e,t){for(var r=e&&"string"==typeof e.type,n=r?e:t,i=0,a=Object.keys(e);i<a.length;i++){var o=e[a[i]];Array.isArray(o)?o.forEach(function(e){addParent(e,n)}):o&&"object"==typeof o&&addParent(o,n)}return r&&Object.defineProperty(e,"parent",{configurable:!0,writable:!0,enumerable:!1,value:t||null}),e}var tagMap={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 getTagName(e){var t=tagMap[e.tagName]?tagMap[e.tagName]:e.tagName;return"link"===t&&e.attributes._cssText&&(t="style"),t}var HOVER_SELECTOR=/([^\\]):hover/g;function addHoverClass(e){var t=parse(e,{silent:!0});return t.stylesheet?(t.stylesheet.rules.forEach(function(t){"selectors"in t&&(t.selectors||[]).forEach(function(t){if(HOVER_SELECTOR.test(t)){var r=t.replace(HOVER_SELECTOR,"$1.\\:hover");e=e.replace(t,t+", "+r)}})}),e):e}function buildNode(e,t){var r=t.doc,n=t.hackCss;switch(e.type){case NodeType.Document:return r.implementation.createDocument(null,"",null);case NodeType.DocumentType:return r.implementation.createDocumentType(e.name||"html",e.publicId,e.systemId);case NodeType.Element:var i,a=getTagName(e);i=e.isSVG?r.createElementNS("http://www.w3.org/2000/svg",a):r.createElement(a);var o=function(t){if(!e.attributes.hasOwnProperty(t))return"continue";var o=e.attributes[t];if(o="boolean"==typeof o||"number"==typeof o?"":o,t.startsWith("rr_")){if("canvas"===a&&"rr_dataURL"===t){var s=document.createElement("img");s.src=o,s.onload=function(){var e=i.getContext("2d");e&&e.drawImage(s,0,0,s.width,s.height)}}if("rr_width"===t&&(i.style.width=o),"rr_height"===t&&(i.style.height=o),"rr_mediaState"===t)switch(o){case"played":i.play();case"paused":i.pause()}}else{var l="textarea"===a&&"value"===t,c="style"===a&&"_cssText"===t;if(c&&n&&(o=addHoverClass(o)),l||c){for(var u=r.createTextNode(o),f=0,d=Array.from(i.childNodes);f<d.length;f++){var p=d[f];p.nodeType===i.TEXT_NODE&&i.removeChild(p)}return i.appendChild(u),"continue"}if("iframe"===a&&"src"===t)return"continue";try{e.isSVG&&"xlink:href"===t?i.setAttributeNS("http://www.w3.org/1999/xlink",t,o):"onload"===t||"onclick"===t||"onmouse"===t.substring(0,7)?i.setAttribute("_"+t,o):i.setAttribute(t,o)}catch(e){}}};for(var s in e.attributes)o(s);return i;case NodeType.Text:return r.createTextNode(e.isStyle&&n?addHoverClass(e.textContent):e.textContent);case NodeType.CDATA:return r.createCDATASection(e.textContent);case NodeType.Comment:return r.createComment(e.textContent);default:return null}}function buildNodeWithSN(e,t){var r=t.doc,n=t.map,i=t.skipChild,a=void 0!==i&&i,o=t.hackCss,s=void 0===o||o,l=t.afterAppend,c=buildNode(e,{doc:r,hackCss:s});if(!c)return null;if(e.rootId&&console.assert(n[e.rootId]===r,"Target document should has the same root id."),e.type===NodeType.Document&&(r.close(),r.open(),c=r),c.__sn=e,n[e.id]=c,(e.type===NodeType.Document||e.type===NodeType.Element)&&!a)for(var u=0,f=e.childNodes;u<f.length;u++){var d=f[u],p=buildNodeWithSN(d,{doc:r,map:n,skipChild:!1,hackCss:s,afterAppend:l});p?(c.appendChild(p),l&&l(p)):console.warn("Failed to rebuild",d)}return c}function visit(e,t){for(var r in e)e[r]&&(n=e[r],t(n));var n}function handleScroll(e){var t=e.__sn;if(t.type===NodeType.Element){var r=e;for(var n in t.attributes)if(t.attributes.hasOwnProperty(n)&&n.startsWith("rr_")){var i=t.attributes[n];"rr_scrollLeft"===n&&(r.scrollLeft=i),"rr_scrollTop"===n&&(r.scrollTop=i)}}}function rebuild(e,t){var r=t.doc,n=t.onVisit,i=t.hackCss,a={},o=buildNodeWithSN(e,{doc:r,map:a,skipChild:!1,hackCss:void 0===i||i,afterAppend:t.afterAppend});return visit(a,function(e){n&&n(e),handleScroll(e)}),[o,a]}export{snapshot,serializeNodeWithId,rebuild,buildNodeWithSN,addHoverClass,transformAttribute,visitSnapshot,cleanupSnapshot,IGNORED_NODE,NodeType};
//# sourceMappingURL=rrweb-snapshot.min.js.map

@@ -171,3 +171,10 @@ 'use strict';

var fired = false;
if (win.document.readyState !== 'complete') {
var readyState;
try {
readyState = win.document.readyState;
}
catch (error) {
return;
}
if (readyState !== 'complete') {
var timer_1 = setTimeout(function () {

@@ -174,0 +181,0 @@ if (!fired) {

{
"name": "rrweb-snapshot",
"version": "1.0.6",
"version": "1.0.7",
"description": "rrweb's component to take a snapshot of DOM, aka DOM serializer",

@@ -5,0 +5,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc