zipyai
Version:
SDK for zipy
1 lines • 271 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).zipyai={})}(this,function(e){var t,n,r;!function(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.ReplayerEvent=11]="ReplayerEvent",e[e.ConsoleInfo=50]="ConsoleInfo",e[e.ConsoleError=51]="ConsoleError",e[e.ConsoleWarning=52]="ConsoleWarning",e[e.ConsoleDebug=53]="ConsoleDebug",e[e.Error=70]="Error",e[e.RangeError=71]="RangeError",e[e.ReferenceError=72]="ReferenceError",e[e.TypeError=73]="TypeError",e[e.SyntaxError=74]="SyntaxError",e[e.URIError=75]="URIError",e[e.EvalError=76]="EvalError",e[e.UnhandledRejection=77]="UnhandledRejection",e[e.BROWSERDATA=100]="BROWSERDATA",e[e.NAVIGATION=101]="NAVIGATION",e[e.Online=102]="Online",e[e.Offline=103]="Offline",e[e.XHR=104]="XHR",e[e.WSOPEN=105]="WSOPEN",e[e.WSCLOSE=106]="WSCLOSE",e[e.WSMESSAGE=107]="WSMESSAGE",e[e.WSERROR=108]="WSERROR",e[e.Fonts=109]="Fonts",e[e.Link=110]="Link",e[e.Css=111]="Css",e[e.Image=112]="Image",e[e.Js=113]="Js",e[e.Media=114]="Media",e[e.ZipyLogMessage=115]="ZipyLogMessage",e[e.ZipyLogException=116]="ZipyLogException",e[e.ZipyLogFrontendError=117]="ZipyLogFrontendError",e[e.ZipyLogNetworkError=118]="ZipyLogNetworkError",e[e.Performance=119]="Performance",e[e.PerfNavigation=120]="PerfNavigation",e[e.OtherNetworkCall=121]="OtherNetworkCall",e[e.WebVitals=122]="WebVitals",e[e.NavigationStart=123]="NavigationStart",e[e.DEBUG_INFO=124]="DEBUG_INFO",e[e.CustomEvent=125]="CustomEvent",e[e.CpuUsage=126]="CpuUsage",e[e.MemoryUsage=127]="MemoryUsage"}(t||(t={})),function(e){e[e.MESSAGESEND=0]="MESSAGESEND",e[e.MESSAGERECEIVED=1]="MESSAGERECEIVED",e[e.SOCKETCLOSE=2]="SOCKETCLOSE",e[e.SOCKETERROR=3]="SOCKETERROR",e[e.SOCKETOPEN=4]="SOCKETOPEN"}(n||(n={})),function(e){e[e.ELEMENT=0]="ELEMENT",e[e.EVENT=1]="EVENT",e[e.FIRST_INPUT=2]="FIRST_INPUT",e[e.LARGEST_CONTENTFUL_PAINT=3]="LARGEST_CONTENTFUL_PAINT",e[e.LAYOUT_SHIFT=4]="LAYOUT_SHIFT",e[e.LONGTASK=5]="LONGTASK",e[e.MARK=6]="MARK",e[e.MEASURE=7]="MEASURE",e[e.NAVIGATION=8]="NAVIGATION",e[e.PAINT=9]="PAINT",e[e.RESOURCE=10]="RESOURCE"}(r||(r={}));var i,o,s,a="zipy",l="rrweb";!function(e){e[e.POSTENDUSERINFOANDGETUSERCONFIG=0]="POSTENDUSERINFOANDGETUSERCONFIG",e[e.POSTENDUSERINFO=1]="POSTENDUSERINFO",e[e.GETUSERCONFIG=2]="GETUSERCONFIG"}(i||(i={})),function(e){e[e.ANONYMS=0]="ANONYMS",e[e.IDENTIFIED=1]="IDENTIFIED"}(o||(o={})),function(e){e[e.NORECORDING=0]="NORECORDING",e[e.RECORDINGPENDING=1]="RECORDINGPENDING",e[e.RECORDINGSUCCESSFUL=2]="RECORDINGSUCCESSFUL"}(s||(s={}));var c,u,d,f,p="logEvent",h="exceptionEvent",g="errorEvent",m=1024,v="startIframeRecording",y="stopIframeRecording",w="iframeContentLoaded";(f=c||(c={})).DEBUG="1",f.WARNING="2",f.ERROR="3",f.LOG="4",function(e){e[e.BLOCKING=0]="BLOCKING",e[e.NON_BLOCKING=1]="NON_BLOCKING"}(u||(u={})),function(e){e.session_data="_zsession-data",e.total_data_sent="_ztotal-data-sent",e.enduser_last_activity_time="_zenduser-last-activity-time",e.last_activity_time="_zlast-activity-time",e.utms="_utms"}(d||(d={}));var b,I=/^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$/,S=/^(https?|ftp):\/\/(([a-z\d]([a-z\d-]*[a-z\d])?\.)+[a-z]{2,}|localhost)(\/[-a-z\d%_.~+]*)*(\?[;&a-z\d%_.~+=-]*)?(\#[-a-z\d_]*)?$/i,C=499;!function(e){e[e.FCP=0]="FCP",e[e.FP=1]="FP",e[e.FID=2]="FID",e[e.CLS=3]="CLS",e[e.LCP=4]="LCP"}(b||(b={}));var E,k,T,N={"Content-Type":"application/json","Content-Encoding":"gzip"};!function(e){e.INIT="init",e.REINIT="reinit",e.PAGE_OUT="pageout"}(E||(E={})),function(e){e.PAGELOAD="pageload",e.VISIBLE="visibility visible",e.VISIBLEFOCUSED="visible and focused",e.HIDDEN="visibility hidden",e.IDENTIFY="identify",e.ANONYMIZE="anonymize",e.STREAMDATARECORDINGPAUSE="streamdata recording paused",e.STREAMDATAEXPIRE="streamdata session expired",e.FOCUS="focus",e.BLUR="blur",e.NA=""}(k||(k={})),function(e){e[e.IDLE=0]="IDLE",e[e.PENDING=1]="PENDING",e[e.SUCCESS=2]="SUCCESS",e[e.FAILED=3]="FAILED"}(T||(T={}));var R,A=["utm_source","utm_medium","utm_term","utm_content","utm_campaign"];!function(e){e[e.STOP=0]="STOP",e[e.START=1]="START"}(R||(R={}));var O,x={streamMgrUrl:"https://services.zipy.ai/sdk-session-manager/v2/enduser-info",registerSessionUrl:"https://services.zipy.ai/sdk-session-manager/v1/register-sdk-session",notifyUserURL:"https://services.zipy.ai/sdk-session-manager/v1/nu",sdkVersion:"1.0.59",errorUrl:"divolte.collector",streamMgrRetryCount:5,zipyDeploymentEnviornment:"Production",sdkLoopTime:1e3,perfLoopTime:5e3,ignoreEmptyErros:!0,ignoreLargeResponse:!0,debugLogs:!1,sessionLinkUrl:"https://app.zipy.ai",isNPM:!0,streamMgrRetryDelay:100,maxPayloadSize100KB:102400},M=!1;function z(e){M&&console.info(a,e)}function U(e){M&&console.debug(a,e)}function D(e){M&&console.log(a,e)}function P(e){M&&console.error(a,e)}function L(e){var t=null==e?void 0:e.host;return Boolean((null==t?void 0:t.shadowRoot)===e)}function F(e){return"[object ShadowRoot]"===Object.prototype.toString.call(e)}function B(e){try{var t=e.rules||e.cssRules;return t?((n=Array.from(t).map(_).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(e){return null}var n}function _(e){var t=e.cssText;if(function(e){return"styleSheet"in e}(e))try{e.styleSheet&&(t=B(e.styleSheet)||t)}catch(e){}return t}!function(e){e[e.Document=0]="Document",e[e.DocumentType=1]="DocumentType",e[e.Element=2]="Element",e[e.Text=3]="Text",e[e.CDATA=4]="CDATA",e[e.Comment=5]="Comment"}(O||(O={}));var G=function(){function e(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return e.prototype.getId=function(e){var t;if(!e)return-1;var n=null===(t=this.getMeta(e))||void 0===t?void 0:t.id;return null!=n?n:-1},e.prototype.getNode=function(e){return this.idNodeMap.get(e)||null},e.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},e.prototype.getMeta=function(e){return this.nodeMetaMap.get(e)||null},e.prototype.removeNodeFromMap=function(e){var t=this,n=this.getId(e);this.idNodeMap.delete(n),e.childNodes&&e.childNodes.forEach(function(e){return t.removeNodeFromMap(e)})},e.prototype.has=function(e){return this.idNodeMap.has(e)},e.prototype.hasNode=function(e){return this.nodeMetaMap.has(e)},e.prototype.add=function(e,t){this.idNodeMap.set(t.id,e),this.nodeMetaMap.set(e,t)},e.prototype.replace=function(e,t){var n=this.getNode(e);if(n){var r=this.nodeMetaMap.get(n);r&&this.nodeMetaMap.set(t,r)}this.idNodeMap.set(e,t)},e.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},e}();function W(e){var t=e.maskInputOptions,n=e.tagName,r=e.type,i=e.maskInputFn,o=e.value||"",s=r&&r.toLowerCase();return(t[n.toLowerCase()]||s&&t[s])&&(o=i?i(o):"*".repeat(o.length)),o}var V,j,q="__rrweb_original__",Z=1,H=new RegExp("[^a-z0-9-_:]"),K=-2;function J(){return Z++}var Y=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,X=/^(?:[a-z+]+:)?\/\//i,Q=/^www\..*/i,$=/^(data:)([^,]*),(.*)/i;function ee(e,t){return(e||"").replace(Y,function(e,n,r,i,o,s){var a,l=r||o||s,c=n||i||"";if(!l)return e;if(X.test(l)||Q.test(l))return"url(".concat(c).concat(l).concat(c,")");if($.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=t,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var u=t.split("/"),d=l.split("/");u.pop();for(var f=0,p=d;f<p.length;f++){var h=p[f];"."!==h&&(".."===h?u.pop():u.push(h))}return"url(".concat(c).concat(u.join("/")).concat(c,")")})}var te=/^[^ \t\n\r\u000c]+/,ne=/^[, \t\n\r\u000c]+/;function re(e,t){if(!t||""===t.trim())return t;var n=e.createElement("a");return n.href=t,n.href}function ie(){var e=document.createElement("a");return e.href="",e.href}function oe(e,t,n,r){return r?"src"===n||"href"===n&&("use"!==t||"#"!==r[0])||"xlink:href"===n&&"#"!==r[0]?re(e,r):"background"!==n||"table"!==t&&"td"!==t&&"th"!==t?"srcset"===n?function(e,t){if(""===t.trim())return t;var n=0;function r(e){var r,i=e.exec(t.substring(n));return i?(n+=(r=i[0]).length,r):""}for(var i=[];r(ne),!(n>=t.length);){var o=r(te);if(","===o.slice(-1))o=re(e,o.substring(0,o.length-1)),i.push(o);else{var s="";o=re(e,o);for(var a=!1;;){var l=t.charAt(n);if(""===l){i.push((o+s).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,i.push((o+s).trim());break}"("===l&&(a=!0)}s+=l,n+=1}}}return i.join(", ")}(e,r):"style"===n?ee(r,ie()):"object"===t&&"data"===n?re(e,r):r:re(e,r):r}function se(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function ae(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&ae(e.parentNode,t,n);for(var r=e.classList.length;r--;)if(t.test(e.classList[r]))return!0;return!!n&&ae(e.parentNode,t,n)}function le(e,t,n,r){var i=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===i)return!1;if(r)return!0;if("string"==typeof t){if(i.classList.contains(t))return!0;if(i.closest(".".concat(t)))return!0}else if(ae(i,t,!0))return!0;if(n){if(i.matches(n))return!0;if(i.closest(n))return!0}return!1}function ce(e){return null==e?"":e.toLowerCase()}function ue(e,t){var n,r=t.doc,i=t.mirror,o=t.blockClass,s=t.blockSelector,a=t.maskTextClass,l=t.maskTextSelector,c=t.skipChild,u=void 0!==c&&c,d=t.inlineStylesheet,f=void 0===d||d,p=t.maskInputOptions,h=void 0===p?{}:p,g=t.maskTextFn,m=t.maskInputFn,v=t.slimDOMOptions,y=t.dataURLOptions,w=void 0===y?{}:y,b=t.inlineImages,I=void 0!==b&&b,S=t.recordCanvas,C=void 0!==S&&S,E=t.onSerialize,k=t.onIframeLoad,T=t.iframeLoadTimeout,N=void 0===T?5e3:T,R=t.onStylesheetLoad,A=t.stylesheetLoadTimeout,x=void 0===A?5e3:A,M=t.keepIframeSrcFn,z=void 0===M?function(){return!1}:M,U=t.newlyAddedElement,D=t.maskAllText,P=void 0!==D&&D,_=t.preserveWhiteSpace,G=void 0===_||_,Z=function(e,t){var n=t.doc,r=t.blockClass,i=t.blockSelector,o=t.maskTextClass,s=t.maskTextSelector,a=t.inlineStylesheet,l=t.maskInputOptions,c=void 0===l?{}:l,u=t.maskTextFn,d=t.maskInputFn,f=t.dataURLOptions,p=void 0===f?{}:f,h=t.inlineImages,g=t.recordCanvas,m=t.keepIframeSrcFn,v=t.newlyAddedElement,y=void 0!==v&&v,w=t.maskAllText,b=void 0!==w&&w,I=function(e,t){if(t.hasNode(e)){var n=t.getId(e);return 1===n?void 0:n}}(n,t.mirror);switch(e.nodeType){case e.DOCUMENT_NODE:return"CSS1Compat"!==e.compatMode?{type:O.Document,childNodes:[],compatMode:e.compatMode}:{type:O.Document,childNodes:[]};case e.DOCUMENT_TYPE_NODE:return{type:O.DocumentType,name:e.name,publicId:e.publicId,systemId:e.systemId,rootId:I};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.inlineStylesheet,i=t.maskInputOptions,o=void 0===i?{}:i,s=t.maskInputFn,a=t.dataURLOptions,l=void 0===a?{}:a,c=t.inlineImages,u=t.recordCanvas,d=t.keepIframeSrcFn,f=t.newlyAddedElement,p=void 0!==f&&f,h=t.rootId,g=function(e,t,n){if("string"==typeof t){if(e.classList.contains(t))return!0}else for(var r=e.classList.length;r--;)if(t.test(e.classList[r]))return!0;return!!n&&e.matches(n)}(e,t.blockClass,t.blockSelector),m=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return H.test(t)?"div":t}(e),v={},y=e.attributes.length,w=0;w<y;w++){var b=e.attributes[w];se(m,b.name)||(v[b.name]=oe(n,m,b.name,b.value))}if("link"===m&&r){var I=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),S=null;I&&(S=B(I)),S&&(delete v.rel,delete v.href,v._cssText=ee(S,I.href))}if("style"===m&&e.sheet&&!(e.innerText||e.textContent||"").trim().length&&(S=B(e.sheet))&&(v._cssText=ee(S,ie())),"input"===m||"textarea"===m||"select"===m){var C=e.value,E=e.checked;if("radio"!==v.type&&"checkbox"!==v.type&&"submit"!==v.type&&"button"!==v.type&&C){var k=e.hasAttribute("data-rr-is-password")?"password":"string"==typeof v.type?v.type.toLowerCase():null;v.value=W({type:k,tagName:m,value:C,maskInputOptions:o,maskInputFn:s})}else E&&(v.checked=E)}if("option"===m&&(e.selected&&!o.select?v.selected=!0:delete v.selected),"canvas"===m&&u)if("2d"===e.__context)(function(e){var t=e.getContext("2d");if(!t)return!0;for(var n=0;n<e.width;n+=50)for(var r=0;r<e.height;r+=50){var i=t.getImageData;if(new Uint32Array((q in i?i[q]:i).call(t,n,r,Math.min(50,e.width-n),Math.min(50,e.height-r)).data.buffer).some(function(e){return 0!==e}))return!1}return!0})(e)||(v.rr_dataURL=e.toDataURL(l.type,l.quality));else if(!("__context"in e)){var T=e.toDataURL(l.type,l.quality),N=document.createElement("canvas");N.width=e.width,N.height=e.height,T!==N.toDataURL(l.type,l.quality)&&(v.rr_dataURL=T)}if("img"===m&&c){V||(V=n.createElement("canvas"),j=V.getContext("2d"));var R=e,A=R.crossOrigin;R.crossOrigin="anonymous";var x=function(){R.removeEventListener("load",x);try{V.width=R.naturalWidth,V.height=R.naturalHeight,j.drawImage(R,0,0),v.rr_dataURL=V.toDataURL(l.type,l.quality)}catch(e){console.warn("Cannot inline img src=".concat(R.currentSrc,"! Error: ").concat(e))}A?v.crossOrigin=A:R.removeAttribute("crossorigin")};R.complete&&0!==R.naturalWidth?x():R.addEventListener("load",x)}if("audio"!==m&&"video"!==m||(v.rr_mediaState=e.paused?"paused":"played",v.rr_mediaCurrentTime=e.currentTime),p||(e.scrollLeft&&(v.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(v.rr_scrollTop=e.scrollTop)),g){var M=e.getBoundingClientRect(),z=M.height;v={class:v.class,rr_width:"".concat(M.width,"px"),rr_height:"".concat(z,"px")}}return"iframe"!==m||d(v.src)||(e.contentDocument||(v.rr_src=v.src),delete v.src),{type:O.Element,tagName:m,attributes:v,childNodes:[],isSVG:(U=e,Boolean("svg"===U.tagName||U.ownerSVGElement)||void 0),needBlock:g,rootId:h};var U}(e,{doc:n,blockClass:r,blockSelector:i,inlineStylesheet:a,maskInputOptions:c,maskInputFn:d,dataURLOptions:p,inlineImages:h,recordCanvas:g,keepIframeSrcFn:m,newlyAddedElement:y,rootId:I});case e.TEXT_NODE:return function(e,t){var n,r,i=t.maskTextClass,o=t.maskTextSelector,s=t.maskTextFn,a=t.rootId,l=t.maskAllText,c=e.parentNode&&e.parentNode.tagName,u=e.textContent,d="STYLE"===c||void 0,f="SCRIPT"===c||void 0;if(d&&u){try{e.nextSibling||e.previousSibling||(null===(n=e.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(u=(r=e.parentNode.sheet).cssRules?Array.from(r.cssRules).map(function(e){return e.cssText||""}).join(""):"")}catch(t){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(t),e)}u=ee(u,ie())}return f&&(u="SCRIPT_PLACEHOLDER"),!d&&!f&&u&&le(e,i,o,l)&&(u=s?s(u):u.replace(/[\S]/g,"*")),{type:O.Text,textContent:u||"",isStyle:d,rootId:a}}(e,{maskTextClass:o,maskTextSelector:s,maskTextFn:u,rootId:I,maskAllText:b});case e.CDATA_SECTION_NODE:return{type:O.CDATA,textContent:"",rootId:I};case e.COMMENT_NODE:return{type:O.Comment,textContent:e.textContent||"",rootId:I};default:return!1}}(e,{doc:r,mirror:i,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:f,maskInputOptions:h,maskTextFn:g,maskInputFn:m,dataURLOptions:w,inlineImages:I,recordCanvas:C,keepIframeSrcFn:z,newlyAddedElement:void 0!==U&&U,maskAllText:P});if(!Z)return console.warn(e,"not serialized"),null;n=i.hasNode(e)?i.getId(e):!function(e,t){if(t.comment&&e.type===O.Comment)return!0;if(e.type===O.Element){if(t.script&&("script"===e.tagName||"link"===e.tagName&&("preload"===e.attributes.rel||"modulepreload"===e.attributes.rel)&&"script"===e.attributes.as||"link"===e.tagName&&"prefetch"===e.attributes.rel&&"string"==typeof e.attributes.href&&e.attributes.href.endsWith(".js")))return!0;if(t.headFavicon&&("link"===e.tagName&&"shortcut icon"===e.attributes.rel||"meta"===e.tagName&&(ce(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===ce(e.attributes.name)||"icon"===ce(e.attributes.rel)||"apple-touch-icon"===ce(e.attributes.rel)||"shortcut icon"===ce(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&ce(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(ce(e.attributes.property).match(/^(og|twitter|fb):/)||ce(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===ce(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===ce(e.attributes.name)||"googlebot"===ce(e.attributes.name)||"bingbot"===ce(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===ce(e.attributes.name)||"generator"===ce(e.attributes.name)||"framework"===ce(e.attributes.name)||"publisher"===ce(e.attributes.name)||"progid"===ce(e.attributes.name)||ce(e.attributes.property).match(/^article:/)||ce(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===ce(e.attributes.name)||"yandex-verification"===ce(e.attributes.name)||"csrf-token"===ce(e.attributes.name)||"p:domain_verify"===ce(e.attributes.name)||"verify-v1"===ce(e.attributes.name)||"verification"===ce(e.attributes.name)||"shopify-checkout-api-token"===ce(e.attributes.name)))return!0}}return!1}(Z,v)&&(G||Z.type!==O.Text||Z.isStyle||Z.textContent.replace(/^\s+|\s+$/gm,"").length)?J():K;var Y=Object.assign(Z,{id:n});if(i.add(e,Y),n===K)return null;E&&E(e);var X=!u;if(Y.type===O.Element){X=X&&!Y.needBlock,delete Y.needBlock;var Q=e.shadowRoot;Q&&F(Q)&&(Y.isShadowHost=!0)}if((Y.type===O.Document||Y.type===O.Element)&&X){v.headWhitespace&&Y.type===O.Element&&"head"===Y.tagName&&(G=!1);for(var $={doc:r,mirror:i,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:u,inlineStylesheet:f,maskInputOptions:h,maskTextFn:g,maskInputFn:m,slimDOMOptions:v,dataURLOptions:w,inlineImages:I,recordCanvas:C,preserveWhiteSpace:G,onSerialize:E,onIframeLoad:k,iframeLoadTimeout:N,onStylesheetLoad:R,stylesheetLoadTimeout:x,keepIframeSrcFn:z,maskAllText:P},te=0,ne=Array.from(e.childNodes);te<ne.length;te++)(de=ue(ne[te],$))&&Y.childNodes.push(de);if(function(e){return e.nodeType===e.ELEMENT_NODE}(e)&&e.shadowRoot)for(var re=0,ae=Array.from(e.shadowRoot.childNodes);re<ae.length;re++){var de;(de=ue(ae[re],$))&&(F(e.shadowRoot)&&(de.isShadow=!0),Y.childNodes.push(de))}}return e.parentNode&&L(e.parentNode)&&F(e.parentNode)&&(Y.isShadow=!0),Y.type===O.Element&&"iframe"===Y.tagName&&function(e,t,n){var r=e.contentWindow;if(r){var i,o=!1;try{i=r.document.readyState}catch(e){return}if("complete"===i){var s="about:blank";if(r.location.href!==s||e.src===s||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var a=setTimeout(function(){o||(t(),o=!0)},n);e.addEventListener("load",function(){clearTimeout(a),o=!0,t()})}}}(e,function(){var t=e.contentDocument;if(t&&k){var n=ue(t,{doc:t,mirror:i,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:f,maskInputOptions:h,maskTextFn:g,maskInputFn:m,slimDOMOptions:v,dataURLOptions:w,inlineImages:I,recordCanvas:C,preserveWhiteSpace:G,onSerialize:E,onIframeLoad:k,iframeLoadTimeout:N,onStylesheetLoad:R,stylesheetLoadTimeout:x,keepIframeSrcFn:z,maskAllText:P});n&&k(e,n)}},N),Y.type===O.Element&&"link"===Y.tagName&&"stylesheet"===Y.attributes.rel&&function(e,t,n){var r,i=!1;try{r=e.sheet}catch(e){return}if(!r){var o=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(o),i=!0,t()})}}(e,function(){if(R){var t=ue(e,{doc:r,mirror:i,blockClass:o,blockSelector:s,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:f,maskInputOptions:h,maskTextFn:g,maskInputFn:m,slimDOMOptions:v,dataURLOptions:w,inlineImages:I,recordCanvas:C,preserveWhiteSpace:G,onSerialize:E,onIframeLoad:k,iframeLoadTimeout:N,onStylesheetLoad:R,stylesheetLoadTimeout:x,keepIframeSrcFn:z,maskAllText:P});t&&R(e,t)}},x),Y}function de(e,t,n=document){const r={capture:!0,passive:!0};return n.addEventListener(e,t,r),()=>n.removeEventListener(e,t,r)}const fe="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let pe={map:{},getId:()=>(console.error(fe),-1),getNode:()=>(console.error(fe),null),removeNodeFromMap(){console.error(fe)},has:()=>(console.error(fe),!1),reset(){console.error(fe)}};function he(e,t,n={}){let r=null,i=0;return function(...o){const s=Date.now();i||!1!==n.leading||(i=s);const a=t-(s-i),l=this;a<=0||a>t?(r&&(clearTimeout(r),r=null),i=s,e.apply(l,o)):r||!1===n.trailing||(r=setTimeout(()=>{i=!1===n.leading?0:Date.now(),r=null,e.apply(l,o)},a))}}function ge(e,t,n,r,i=window){const o=i.Object.getOwnPropertyDescriptor(e,t);return i.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),o&&o.set&&o.set.call(this,e)}}),()=>ge(e,t,o||{},!0)}function me(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],i=n(r);return"function"==typeof i&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=i,()=>{e[t]=r}}catch(e){return()=>{}}}function ve(e){var t,n,r,i,o,s;const a=e.document;return{left:a.scrollingElement?a.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==a?void 0:a.documentElement.scrollLeft)||(null===(n=null===(t=null==a?void 0:a.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null==a?void 0:a.body)||void 0===r?void 0:r.scrollLeft)||0,top:a.scrollingElement?a.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==a?void 0:a.documentElement.scrollTop)||(null===(o=null===(i=null==a?void 0:a.body)||void 0===i?void 0:i.parentElement)||void 0===o?void 0:o.scrollTop)||(null===(s=null==a?void 0:a.body)||void 0===s?void 0:s.scrollTop)||0}}function ye(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function we(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function be(e,t,n,r){if(!e)return!1;const i=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!i)return!1;try{if("string"==typeof t){if(i.classList.contains(t))return!0;if(r&&null!==i.closest("."+t))return!0}else if(ae(i,t,r))return!0}catch(e){}if(n){if(i.matches(n))return!0;if(r&&null!==i.closest(n))return!0}return!1}function Ie(e,t){return t.getId(e)===K}function Se(e,t){if(L(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Se(e.parentNode,t))}function Ce(e){return Boolean(e.changedTouches)}function Ee(e,t){return Boolean("IFRAME"===e.nodeName&&t.getMeta(e))}function ke(e,t){return Boolean("LINK"===e.nodeName&&e.nodeType===e.ELEMENT_NODE&&e.getAttribute&&"stylesheet"===e.getAttribute("rel")&&t.getMeta(e))}function Te(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(pe=new Proxy(pe,{get:(e,t,n)=>("map"===t&&console.error(fe),Reflect.get(e,t,n))}));class Ne{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(e){var t;return null!==(t=this.styleIDMap.get(e))&&void 0!==t?t:-1}has(e){return this.styleIDMap.has(e)}add(e,t){if(this.has(e))return this.getId(e);let n;return n=void 0===t?this.id++:t,this.styleIDMap.set(e,n),this.idStyleMap.set(n,e),n}getStyle(e){return this.idStyleMap.get(e)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function Re(e){var t,n;let r=null;return(null===(n=null===(t=e.getRootNode)||void 0===t?void 0:t.call(e))||void 0===n?void 0:n.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&e.getRootNode().host&&(r=e.getRootNode().host),r}function Ae(e){const t=e.ownerDocument;return!!t&&(t.contains(e)||function(e){const t=e.ownerDocument;if(!t)return!1;const n=function(e){let t,n=e;for(;t=Re(n);)n=t;return n}(e);return t.contains(n)}(e))}function Oe(e){return e.hasAttribute("data-rr-is-password")?"password":e.hasAttribute("type")?e.getAttribute("type").toLowerCase():null}var xe=/* @__PURE__ */(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))(xe||{}),Me=/* @__PURE__ */(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e))(Me||{}),ze=/* @__PURE__ */(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))(ze||{}),Ue=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(Ue||{});function De(e){return"__ln"in e}class Pe{constructor(){this.length=0,this.head=null}get(e){if(e>=this.length)throw new Error("Position outside of list range");let t=this.head;for(let n=0;n<e;n++)t=(null==t?void 0:t.next)||null;return t}addNode(e){const t={value:e,previous:null,next:null};if(e.__ln=t,e.previousSibling&&De(e.previousSibling)){const n=e.previousSibling.__ln.next;t.next=n,t.previous=e.previousSibling.__ln,e.previousSibling.__ln.next=t,n&&(n.previous=t)}else if(e.nextSibling&&De(e.nextSibling)&&e.nextSibling.__ln.previous){const n=e.nextSibling.__ln.previous;t.previous=n,t.next=e.nextSibling.__ln,e.nextSibling.__ln.previous=t,n&&(n.next=t)}else this.head&&(this.head.previous=t),t.next=this.head,this.head=t;this.length++}removeNode(e){const t=e.__ln;this.head&&(t.previous?(t.previous.next=t.next,t.next&&(t.next.previous=t.previous)):(this.head=t.next,this.head&&(this.head.previous=null)),e.__ln&&delete e.__ln,this.length--)}}const Le=(e,t)=>`${e}@${t}`;class Fe{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=e=>{e.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const e=[],t=new Pe,n=e=>{let t=e,n=K;for(;n===K;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{if(!r.parentNode||!Ae(r))return;const i=L(r.parentNode)?this.mirror.getId(Re(r)):this.mirror.getId(r.parentNode),o=n(r);if(-1===i||-1===o)return t.addNode(r);const s=ue(r,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,maskAllText:this.maskAllText,onSerialize:e=>{Ee(e,this.mirror)&&this.iframeManager.addIframe(e),ke(e,this.mirror)&&this.stylesheetManager.trackLinkElement(e),Te(r)&&this.shadowDomManager.addShadowRoot(r.shadowRoot,this.doc)},onIframeLoad:(e,t)=>{this.iframeManager.attachIframe(e,t),this.shadowDomManager.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{this.stylesheetManager.attachLinkElement(e,t)}});s&&e.push({parentId:i,nextId:o,node:s})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const e of this.movedSet)_e(this.removes,e,this.mirror)&&!this.movedSet.has(e.parentNode)||r(e);for(const e of this.addedSet)We(this.droppedSet,e)||_e(this.removes,e,this.mirror)?We(this.movedSet,e)?r(e):this.droppedSet.add(e):r(e);let i=null;for(;t.length;){let e=null;if(i){const t=this.mirror.getId(i.value.parentNode),r=n(i.value);-1!==t&&-1!==r&&(e=i)}if(!e)for(let r=t.length-1;r>=0;r--){const i=t.get(r);if(i){const t=this.mirror.getId(i.value.parentNode);if(-1===n(i.value))continue;if(-1!==t){e=i;break}{const t=i.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&-1!==this.mirror.getId(t.parentNode.host)){e=i;break}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}i=e.previous,t.removeNode(e.value),r(e.value)}const o={texts:this.texts.map(e=>({id:this.mirror.getId(e.node),value:e.value})).filter(e=>this.mirror.has(e.id)),attributes:this.attributes.map(e=>({id:this.mirror.getId(e.node),attributes:e.attributes})).filter(e=>this.mirror.has(e.id)),removes:this.removes,adds:e};(o.texts.length||o.attributes.length||o.removes.length||o.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(o))},this.processMutation=e=>{if(!Ie(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;be(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:le(e.target,this.maskTextClass,this.maskTextSelector,this.maskAllText)&&t?this.maskTextFn?this.maskTextFn(t):t.replace(/[\S]/g,"*"):t,node:e.target});break}case"attributes":{const t=e.target;let n=e.attributeName,r=e.target.getAttribute(n);if("value"===n){const e=Oe(t);r=W({maskInputOptions:this.maskInputOptions,tagName:t.tagName,type:e,value:r,maskInputFn:this.maskInputFn})}if(be(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let i=this.attributes.find(t=>t.node===e.target);if("IFRAME"===t.tagName&&"src"===n&&!this.keepIframeSrcFn(r)){if(t.contentDocument)return;n="rr_src"}if(i||(i={node:e.target,attributes:{}},this.attributes.push(i)),"type"===n&&"INPUT"===t.tagName&&"password"===(e.oldValue||"").toLowerCase()&&t.setAttribute("data-rr-is-password","true"),"style"===n){const n=this.doc.createElement("span");e.oldValue&&n.setAttribute("style",e.oldValue),null==i.attributes.style&&(i.attributes.style={});const r=i.attributes.style;for(const e of Array.from(t.style)){const i=t.style.getPropertyValue(e),o=t.style.getPropertyPriority(e);i===n.style.getPropertyValue(e)&&o===n.style.getPropertyPriority(e)||(r[e]=""===o?i:[i,o])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else se(t.tagName,n)||(i.attributes[n]=oe(this.doc,t.tagName,n,r));break}case"childList":if(be(e.target,this.blockClass,this.blockSelector,!0))return;e.addedNodes.forEach(t=>this.genAdds(t,e.target)),e.removedNodes.forEach(t=>{const n=this.mirror.getId(t),r=L(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);be(e.target,this.blockClass,this.blockSelector,!1)||Ie(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Be(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Se(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Le(n,r)]?Be(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!L(e.target)||!F(e.target))||void 0})),this.mapRemoves.push(t))})}},this.genAdds=(e,t)=>{if(!this.processedNodeManager.inOtherBuffer(e,this)){if(this.mirror.hasNode(e)){if(Ie(e,this.mirror))return;this.movedSet.add(e);let n=null;t&&this.mirror.hasNode(t)&&(n=this.mirror.getId(t)),n&&-1!==n&&(this.movedMap[Le(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);be(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach(e=>this.genAdds(e)),Te(e)&&e.shadowRoot.childNodes.forEach(t=>{this.processedNodeManager.add(t,this),this.genAdds(t,e)}))}}}init(e){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager","maskAllText"].forEach(t=>{this[t]=e[t]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Be(e,t){e.delete(t),t.childNodes.forEach(t=>Be(e,t))}function _e(e,t,n){return 0!==e.length&&Ge(e,t,n)}function Ge(e,t,n){const{parentNode:r}=t;if(!r)return!1;const i=n.getId(r);return!!e.some(e=>e.id===i)||Ge(e,r,n)}function We(e,t){return 0!==e.size&&Ve(e,t)}function Ve(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||Ve(e,n))}let je;function qe(e){je=e}function Ze(){je=void 0}const He=e=>je?(...t)=>{try{return e(...t)}catch(e){if(je&&!0===je(e))return;throw e}}:e;function Ke(e){let t="";return!e||e&&!e.length||Object.values(e).forEach(e=>{if(e&&e.nodeName){let n=e.nodeName,r=e.nodeValue;"class"==n?t=t+"."+r:"id"==n?t=t+"#"+r:"type"==n&&(t+=`[${n}="${r}"]`)}}),t}function Je(e){const t=function(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t}else if("path"in e&&e.path.length)return e.path;return null}catch(e){return null}}(e);return t?function(e){if(!e||!Array.isArray(e))return"";let t="";for(let n=e.length>3?3:e.length-1;n>=0;n--){let r="",i=e[n];i&&i.tagName&&i.attributes&&i.attributes.length&&(r=n>0?i.tagName.toLowerCase()+Ke(i.attributes)+" > ":i.tagName.toLowerCase()+Ke(i.attributes),t+=r)}return t}(t):""}class Ye{constructor(){this.clickArray=[]}isRageClick(e,t){const n=this.clickArray[this.clickArray.length-1];if(n&&n.selector===e&&t-n.timestamp<=1e3){if(this.clickArray.push({selector:e,timestamp:t}),this.clickArray.length>=3)return!0}else this.clickArray=[{selector:e,timestamp:t}];return!1}}const Xe=[];function Qe(e){try{if("composedPath"in e){const t=e.composedPath();if(t.length)return t[0]}else if("path"in e&&e.path.length)return e.path[0];return e.target}catch(t){return e.target}}function $e(e,t){var n,r;const i=new Fe;Xe.push(i),i.init(e);let o=window.MutationObserver||window.__rrMutationObserver;const s=null===(r=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===r?void 0:r.call(n,"MutationObserver");s&&window[s]&&(o=window[s]);const a=new o(He(i.processMutations.bind(i)));return a.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function et({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o}){return de("scroll",He(he(He(o=>{const s=Qe(o);if(!s||be(s,r,i,!0))return;const a=n.getId(s);if(s===t&&t.defaultView){const n=ve(t.defaultView);e({id:a,x:n.left,y:n.top})}else e({id:a,x:s.scrollLeft,y:s.scrollTop})}),o.scroll||100)),t)}function tt(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const nt=["INPUT","TEXTAREA","SELECT"],rt=new WeakMap;function it(e){return function(e,t){if(lt("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||lt("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||lt("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||lt("CSSConditionRule")&&e.parentRule instanceof CSSConditionRule){const n=Array.from(e.parentRule.cssRules).indexOf(e);t.unshift(n)}else if(e.parentStyleSheet){const n=Array.from(e.parentStyleSheet.cssRules).indexOf(e);t.unshift(n)}return t}(e,[])}function ot(e,t,n){let r,i;return e?(e.ownerNode?r=t.getId(e.ownerNode):i=n.getId(e),{styleId:i,id:r}):{}}function st({mirror:e,stylesheetManager:t},n){var r,i,o;let s=null;s=e.getId("#document"===n.nodeName?n:n.host);const a="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(o=null===(i=n.ownerDocument)||void 0===i?void 0:i.defaultView)||void 0===o?void 0:o.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==s&&-1!==s&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var e;return null===(e=l.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=l.set)||void 0===n?void 0:n.call(this,e);if(null!==s&&-1!==s)try{t.adoptStyleSheets(e,s)}catch(e){}return r}}),He(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})})):()=>{}}function at(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:i,scrollCb:o,viewportResizeCb:s,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:u,canvasMutationCb:d,fontCb:f,selectionCb:p}=e;e.mutationCb=(...e)=>{t.mutation&&t.mutation(...e),n(...e)},e.mousemoveCb=(...e)=>{t.mousemove&&t.mousemove(...e),r(...e)},e.mouseInteractionCb=(...e)=>{t.mouseInteraction&&t.mouseInteraction(...e),i(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),o(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),s(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),a(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),l(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),c(...e)},e.styleDeclarationCb=(...e)=>{t.styleDeclaration&&t.styleDeclaration(...e),u(...e)},e.canvasMutationCb=(...e)=>{t.canvasMutation&&t.canvasMutation(...e),d(...e)},e.fontCb=(...e)=>{t.font&&t.font(...e),f(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),p(...e)}}(e,t);const r=$e(e,e.doc),i=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const i="number"==typeof t.mousemove?t.mousemove:50,o="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let s,a=[];const l=he(He(t=>{const n=Date.now()-s;e(a.map(e=>(e.timeOffset-=n,e)),t),a=[],s=null}),o),c=He(he(He(e=>{const t=Qe(e),{clientX:n,clientY:i}=Ce(e)?e.changedTouches[0]:e;s||(s=Date.now()),a.push({x:n,y:i,id:r.getId(t),timeOffset:Date.now()-s}),l("undefined"!=typeof DragEvent&&e instanceof DragEvent?Me.Drag:e instanceof MouseEvent?Me.MouseMove:Me.TouchMove)}),i,{trailing:!1})),u=[de("mousemove",c,n),de("touchmove",c,n),de("drag",c,n)];return He(()=>{u.forEach(e=>e())})}(e),o=function({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,sampling:o,captureClickEvents:s}){const a=new Ye;if(!1===o.mouseInteraction)return()=>{};const l=!0===o.mouseInteraction||void 0===o.mouseInteraction?{}:o.mouseInteraction,c=[];return Object.keys(ze).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==l[e]).forEach(o=>{const l=o.toLowerCase(),u=(t=>o=>{const l=Qe(o);if(be(l,r,i,!0))return;const c=Ce(o)?o.changedTouches[0]:o;if(!c)return;const u=n.getId(l),{clientX:d,clientY:f}=c,p=Je(o);let h={type:ze[t],id:u,x:d,y:f,nodePath:p};if(ze[t]===ze.Click){const e=window.innerHeight?window.innerHeight:null,t=window.innerWidth?window.innerWidth:null,n=window.location.href||"",r=function(e){let t=e.target;return t?t.innerText||"":(console.error("Event target is not an HTML element."),"")}(o),i=!!s&&function(e){const t=e.target,n=t?null==t?void 0:t.nodeName.toLowerCase():"",r=t instanceof HTMLAnchorElement||null!==t.onclick||t.hasAttribute("onclick");return"a"!==n&&!r}(o),l=o.offsetX,c=o.offsetY,[u,d]=function(e){let t=e.target;return t?[t.clientHeight,t.clientWidth]:(console.error("Event target is not an HTML element."),[0,0])}(o),f=function(e){var t,n,r,i;const o=(null===(i=null===(r=null===(n=null===(t=null==e?void 0:e.target)||void 0===t?void 0:t.ownerDocument)||void 0===n?void 0:n.location)||void 0===r?void 0:r.ancestorOrigins)||void 0===i?void 0:i.length)||0;let s=null==e?void 0:e.target;if(s){if(!s||!(null==s?void 0:s.parentNode))return null;const t=[];let n=null==e?void 0:e.target;for(;n&&(null==n?void 0:n.tagName);){let e=n.tagName.toLowerCase(),r=Array.from(n.parentNode.children).indexOf(n)+1;t.unshift("body"!==e?e+(r>1?`:nth-child(${r})`:""):e),n=n.parentNode?n.parentNode:null}return o>0&&t.unshift(`iframe_context.level-${o}`),t.join(" > ")}return null}(o),p=(new Date).getTime();let g=!1;s&&f&&f.trim().length>0&&(g=a.isRageClick(f,p)),h=Object.assign(Object.assign({},h),{deadClick:i,innerText:r,offsetX:l,offsetY:c,rageClick:g,screenHeight:e,screenWidth:t,navigationUrl:n,elementHeight:u,elementWidth:d,selector:f})}He(e)(h)})(o);c.push(de(l,u,t))}),He(()=>{c.forEach(e=>e())})}(e),s=et(e),a=function({viewportResizeCb:e}){let t=-1,n=-1;return de("resize",He(he(He(()=>{const r=ye(),i=we();t===r&&n===i||(e({width:Number(i),height:Number(r)}),t=r,n=i)}),200)),window)}(e),l=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:i,ignoreClass:o,maskInputOptions:s,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function u(e){let n=Qe(e);const l=Je(e),u=e.isTrusted,f=n&&n.tagName;if(n&&"OPTION"===f&&(n=n.parentElement),!n||!f||nt.indexOf(f)<0||be(n,r,i,!0))return;if(n.classList.contains(o))return;let p=n.value,h=!1;const g=Oe(n)||"";"radio"===g||"checkbox"===g?h=n.checked:(s[f.toLowerCase()]||s[g])&&(p=W({maskInputOptions:s,tagName:f,type:g,value:p,maskInputFn:a})),d(n,He(tt)({text:p,isChecked:h,userTriggered:u,nodePath:l},c));const m=n.name;"radio"===g&&m&&h&&t.querySelectorAll(`input[type="radio"][name="${m}"]`).forEach(e=>{e!==n&&d(e,He(tt)({text:e.value,isChecked:!h,userTriggered:!1,nodePath:""},c))})}function d(t,r){const i=rt.get(t);if(!i||i.text!==r.text||i.isChecked!==r.isChecked){rt.set(t,r);const i=n.getId(t);He(e)(Object.assign(Object.assign({},r),{id:i}))}}const f=("last"===l.input?["change"]:["input","change"]).map(e=>de(e,He(u),t)),p=t.defaultView;if(!p)return()=>{f.forEach(e=>e())};const h=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value");return h&&h.set&&f.push(...[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]].map(e=>ge(e[0],e[1],{set(){He(u)({target:this,isTrusted:!1})}},!1,p))),He(()=>{f.forEach(e=>e())})}(e),c=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:i}){const o=He(o=>he(He(i=>{const s=Qe(i);if(!s||be(s,t,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:u}=s;e({type:o,id:r.getId(s),currentTime:a,volume:l,muted:c,playbackRate:u})}),i.media||500)),s=[de("play",o(0)),de("pause",o(1)),de("seeked",o(2)),de("volumechange",o(3)),de("ratechange",o(4))];return He(()=>{s.forEach(e=>e())})}(e),u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const i=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(i,{apply:He((r,i,o)=>{const[s,a]=o,{id:l,styleId:c}=ot(i,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:a}]}),r.apply(i,o)})});const o=r.CSSStyleSheet.prototype.deleteRule;let s,a;r.CSSStyleSheet.prototype.deleteRule=new Proxy(o,{apply:He((r,i,o)=>{const[s]=o,{id:a,styleId:l}=ot(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:s}]}),r.apply(i,o)})}),r.CSSStyleSheet.prototype.replace&&(s=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(s,{apply:He((r,i,o)=>{const[s]=o,{id:a,styleId:l}=ot(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replace:s}),r.apply(i,o)})})),r.CSSStyleSheet.prototype.replaceSync&&(a=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(a,{apply:He((r,i,o)=>{const[s]=o,{id:a,styleId:l}=ot(i,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,replaceSync:s}),r.apply(i,o)})}));const l={};ct("CSSGroupingRule")?l.CSSGroupingRule=r.CSSGroupingRule:(ct("CSSMediaRule")&&(l.CSSMediaRule=r.CSSMediaRule),ct("CSSConditionRule")&&(l.CSSConditionRule=r.CSSConditionRule),ct("CSSSupportsRule")&&(l.CSSSupportsRule=r.CSSSupportsRule));const c={};return Object.entries(l).forEach(([r,i])=>{c[r]={insertRule:i.prototype.insertRule,deleteRule:i.prototype.deleteRule},i.prototype.insertRule=new Proxy(c[r].insertRule,{apply:He((r,i,o)=>{const[s,a]=o,{id:l,styleId:c}=ot(i.parentStyleSheet,t,n.styleMirror);return(l&&-1!==l||c&&-1!==c)&&e({id:l,styleId:c,adds:[{rule:s,index:[...it(i),a||0]}]}),r.apply(i,o)})}),i.prototype.deleteRule=new Proxy(c[r].deleteRule,{apply:He((r,i,o)=>{const[s]=o,{id:a,styleId:l}=ot(i.parentStyleSheet,t,n.styleMirror);return(a&&-1!==a||l&&-1!==l)&&e({id:a,styleId:l,removes:[{index:[...it(i),s]}]}),r.apply(i,o)})})}),He(()=>{try{r.CSSStyleSheet.prototype.insertRule=i,r.CSSStyleSheet.prototype.deleteRule=o,s&&(r.CSSStyleSheet.prototype.replace=s),a&&(r.CSSStyleSheet.prototype.replaceSync=a)}catch(e){}try{Object.entries(l).forEach(([e,t])=>{t.prototype.insertRule=c[e].insertRule,t.prototype.deleteRule=c[e].deleteRule})}catch(e){}})}(e,{win:n}),d=st(e,e.doc),f=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:i}){const o=i.CSSStyleDeclaration.prototype.setProperty;i.CSSStyleDeclaration.prototype.setProperty=new Proxy(o,{apply:He((i,s,a)=>{var l;const[c,u,d]=a;if(n.has(c))return o.apply(s,[c,u,d]);const{id:f,styleId:p}=ot(null===(l=s.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,r.styleMirror);return(f&&-1!==f||p&&-1!==p)&&e({id:f,styleId:p,set:{property:c,value:u,priority:d},index:it(s.parentRule)}),i.apply(s,a)})});const s=i.CSSStyleDeclaration.prototype.removeProperty;return i.CSSStyleDeclaration.prototype.removeProperty=new Proxy(s,{apply:He((i,o,a)=>{var l;const[c]=a;if(n.has(c))return s.apply(o,[c]);const{id:u,styleId:d}=ot(null===(l=o.parentRule)||void 0===l?void 0:l.parentStyleSheet,t,r.styleMirror);return(u&&-1!==u||d&&-1!==d)&&e({id:u,styleId:d,remove:{property:c},index:it(o.parentRule)}),i.apply(o,a)})}),He(()=>{try{i.CSSStyleDeclaration.prototype.setProperty=o,i.CSSStyleDeclaration.prototype.removeProperty=s}catch(e){}})}(e,{win:n}),p=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],i=new WeakMap,o=n.FontFace;n.FontFace=function(e,t,n){const r=new o(e,t,n);return i.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const s=me(t.fonts,"add",function(t){return function(n){return setTimeout(He(()=>{const t=i.get(n);t&&(e(t),i.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=o}),r.push(s),He(()=>{r.forEach(e=>e())})}(e):()=>{},h=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:i,selectionCb:o}=e;let s=!0;const a=He(()=>{const e=t.getSelection();if(!e||s&&(null==e?void 0:e.isCollapsed))return;s=e.isCollapsed||!1;const a=[],l=e.rangeCount||0;for(let t=0;t<l;t++){const o=e.getRangeAt(t),{startContainer:s,startOffset:l,endContainer:c,endOffset:u}=o;be(s,r,i,!0)||be(c,r,i,!0)||a.push({start:n.getId(s),startOffset:l,end:n.getId(c),endOffset:u})}o({ranges:a})});return a(),de("selectionchange",a)}(e),g=[];for(const t of e.plugins)g.push(t.observer(t.callback,n,t.options));return He(()=>{Xe.forEach(e=>e.reset()),r.disconnect(),i(),o(),s(),a(),l(),c(),u(),d(),f(),p(),h(),g.forEach(e=>e())})}function lt(e){return void 0!==window[e]}function ct(e){return Boolean(void 0!==window[e]&&window[e].prototype&&"insertRule"in window[e].prototype&&"deleteRule"in window[e].prototype)}class ut{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const i=n||this.getIdToRemoteIdMap(e),o=r||this.getRemoteIdToIdMap(e);let s=i.get(t);return s||(s=this.generateIdFn(),i.set(t,s),o.set(s,t)),s}getIds(e,t){const n=this.getIdToRemoteIdMap(e),r=this.getRemoteIdToIdMap(e);return t.map(t=>this.getId(e,t,n,r))}getRemoteId(e,t,n){const r=n||this.getRemoteIdToIdMap(e);return"number"!=typeof t?t:r.get(t)||-1}getRemoteIds(e,t){const n=this.getRemoteIdToIdMap(e);return t.map(t=>this.getRemoteId(e,t,n))}reset(e){if(!e)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(e),this.iframeRemoteIdToIdMap.delete(e)}getIdToRemoteIdMap(e){let t=this.iframeIdToRemoteIdMap.get(e);return t||(t=new Map,this.iframeIdToRemoteIdMap.set(e,t)),t}getRemoteIdToIdMap(e){let t=this.iframeRemoteIdToIdMap.get(e);return t||(t=new Map,this.iframeRemoteIdToIdMap.set(e,t)),t}}class dt{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new ut(J),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new ut(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=e.mirror,this.recordCrossOriginIframes&&(window.removeEventListener("message",this.handleMessage.bind(this)),window.addEventListener("message",this.handleMessage.bind(this)))}addIframe(e){this.iframes.set(e,!0),e.contentWindow&&this.crossOriginIframeMap.set(e.contentWindow,e)}addLoadListener(e){this.loadListener=e}attachIframe(e,t){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(e),nextId:null,node:t}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,e),e.contentDocument&&e.contentDocument.adoptedStyleSheets&&e.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(e.contentDocument.adoptedStyleSheets,this.mirror.getId(e.contentDocument))}handleMessage(e){const t=e;if("rrweb"!==t.data.type||t.origin!==t.data.origin)return;if(!e.source)return;con