UNPKG

zipyai

Version:

SDK for zipy

1 lines 201 kB
!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 o,i,a,s="zipy",c="rrweb";!function(e){e[e.POSTENDUSERINFOANDGETUSERCONFIG=0]="POSTENDUSERINFOANDGETUSERCONFIG",e[e.POSTENDUSERINFO=1]="POSTENDUSERINFO",e[e.GETUSERCONFIG=2]="GETUSERCONFIG"}(o||(o={})),function(e){e[e.ANONYMS=0]="ANONYMS",e[e.IDENTIFIED=1]="IDENTIFIED"}(i||(i={})),function(e){e[e.NORECORDING=0]="NORECORDING",e[e.RECORDINGPENDING=1]="RECORDINGPENDING",e[e.RECORDINGSUCCESSFUL=2]="RECORDINGSUCCESSFUL"}(a||(a={}));var l,u,d,p,f="logEvent",g="exceptionEvent",m="errorEvent",h=1024,v="startIframeRecording",y="stopIframeRecording",w="iframeContentLoaded";(p=l||(l={})).DEBUG="1",p.WARNING="2",p.ERROR="3",p.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 I,S=/^(?!-)[A-Za-z0-9-]+([\-\.]{1}[a-z0-9]+)*\.[A-Za-z]{2,6}$/,C=/^(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,b=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"}(I||(I={}));var E,k,A,T={"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"}(A||(A={}));var R,N=["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,z={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.51",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:5e3,maxPayloadSize100KB:102400},M=!1;function x(e){M&&console.info(s,e)}function D(e){M&&console.debug(s,e)}function U(e){M&&console.log(s,e)}function L(e){M&&console.error(s,e)}function P(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 G(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{t=G(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 B=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,o=e.maskInputFn,i=e.value||"",a=r&&r.toLowerCase();return(t[n.toLowerCase()]||a&&t[a])&&(i=o?o(i):"*".repeat(i.length)),i}var Z,q,V="__rrweb_original__",K=1,J=new RegExp("[^a-z0-9-_:]"),H=-2;function j(){return K++}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,o,i,a){var s,c=r||i||a,l=n||o||"";if(!c)return e;if(X.test(c)||Q.test(c))return"url(".concat(l).concat(c).concat(l,")");if($.test(c))return"url(".concat(l).concat(c).concat(l,")");if("/"===c[0])return"url(".concat(l).concat((s=t,(s.indexOf("//")>-1?s.split("/").slice(0,3).join("/"):s.split("/")[0]).split("?")[0]+c)).concat(l,")");var u=t.split("/"),d=c.split("/");u.pop();for(var p=0,f=d;p<f.length;p++){var g=f[p];"."!==g&&(".."===g?u.pop():u.push(g))}return"url(".concat(l).concat(u.join("/")).concat(l,")")})}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 oe(){var e=document.createElement("a");return e.href="",e.href}function ie(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,o=e.exec(t.substring(n));return o?(n+=(r=o[0]).length,r):""}for(var o=[];r(ne),!(n>=t.length);){var i=r(te);if(","===i.slice(-1))i=re(e,i.substring(0,i.length-1)),o.push(i);else{var a="";i=re(e,i);for(var s=!1;;){var c=t.charAt(n);if(""===c){o.push((i+a).trim());break}if(s)")"===c&&(s=!1);else{if(","===c){n+=1,o.push((i+a).trim());break}"("===c&&(s=!0)}a+=c,n+=1}}}return o.join(", ")}(e,r):"style"===n?ee(r,oe()):"object"===t&&"data"===n?re(e,r):r:re(e,r):r}function ae(e,t,n){return("video"===e||"audio"===e)&&"autoplay"===t}function se(e,t,n){if(!e)return!1;if(e.nodeType!==e.ELEMENT_NODE)return!!n&&se(e.parentNode,t,n);for(var r=e.classList.length;r--;)if(t.test(e.classList[r]))return!0;return!!n&&se(e.parentNode,t,n)}function ce(e,t,n,r){var o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(null===o)return!1;if(r)return!0;if("string"==typeof t){if(o.classList.contains(t))return!0;if(o.closest(".".concat(t)))return!0}else if(se(o,t,!0))return!0;if(n){if(o.matches(n))return!0;if(o.closest(n))return!0}return!1}function le(e){return null==e?"":e.toLowerCase()}function ue(e,t){var n,r=t.doc,o=t.mirror,i=t.blockClass,a=t.blockSelector,s=t.maskTextClass,c=t.maskTextSelector,l=t.skipChild,u=void 0!==l&&l,d=t.inlineStylesheet,p=void 0===d||d,f=t.maskInputOptions,g=void 0===f?{}:f,m=t.maskTextFn,h=t.maskInputFn,v=t.slimDOMOptions,y=t.dataURLOptions,w=void 0===y?{}:y,I=t.inlineImages,S=void 0!==I&&I,C=t.recordCanvas,b=void 0!==C&&C,E=t.onSerialize,k=t.onIframeLoad,A=t.iframeLoadTimeout,T=void 0===A?5e3:A,R=t.onStylesheetLoad,N=t.stylesheetLoadTimeout,z=void 0===N?5e3:N,M=t.keepIframeSrcFn,x=void 0===M?function(){return!1}:M,D=t.newlyAddedElement,U=t.maskAllText,L=void 0!==U&&U,_=t.preserveWhiteSpace,B=void 0===_||_,K=function(e,t){var n=t.doc,r=t.blockClass,o=t.blockSelector,i=t.maskTextClass,a=t.maskTextSelector,s=t.inlineStylesheet,c=t.maskInputOptions,l=void 0===c?{}:c,u=t.maskTextFn,d=t.maskInputFn,p=t.dataURLOptions,f=void 0===p?{}:p,g=t.inlineImages,m=t.recordCanvas,h=t.keepIframeSrcFn,v=t.newlyAddedElement,y=void 0!==v&&v,w=t.maskAllText,I=void 0!==w&&w,S=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:S};case e.ELEMENT_NODE:return function(e,t){for(var n=t.doc,r=t.inlineStylesheet,o=t.maskInputOptions,i=void 0===o?{}:o,a=t.maskInputFn,s=t.dataURLOptions,c=void 0===s?{}:s,l=t.inlineImages,u=t.recordCanvas,d=t.keepIframeSrcFn,p=t.newlyAddedElement,f=void 0!==p&&p,g=t.rootId,m=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),h=function(e){if(e instanceof HTMLFormElement)return"form";var t=e.tagName.toLowerCase().trim();return J.test(t)?"div":t}(e),v={},y=e.attributes.length,w=0;w<y;w++){var I=e.attributes[w];ae(h,I.name)||(v[I.name]=ie(n,h,I.name,I.value))}if("link"===h&&r){var S=Array.from(n.styleSheets).find(function(t){return t.href===e.href}),C=null;S&&(C=G(S)),C&&(delete v.rel,delete v.href,v._cssText=ee(C,S.href))}if("style"===h&&e.sheet&&!(e.innerText||e.textContent||"").trim().length&&(C=G(e.sheet))&&(v._cssText=ee(C,oe())),"input"===h||"textarea"===h||"select"===h){var b=e.value,E=e.checked;if("radio"!==v.type&&"checkbox"!==v.type&&"submit"!==v.type&&"button"!==v.type&&b){var k=e.hasAttribute("data-rr-is-password")?"password":"string"==typeof v.type?v.type.toLowerCase():null;v.value=W({type:k,tagName:h,value:b,maskInputOptions:i,maskInputFn:a})}else E&&(v.checked=E)}if("option"===h&&(e.selected&&!i.select?v.selected=!0:delete v.selected),"canvas"===h&&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 o=t.getImageData;if(new Uint32Array((V in o?o[V]:o).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(c.type,c.quality));else if(!("__context"in e)){var A=e.toDataURL(c.type,c.quality),T=document.createElement("canvas");T.width=e.width,T.height=e.height,A!==T.toDataURL(c.type,c.quality)&&(v.rr_dataURL=A)}if("img"===h&&l){Z||(Z=n.createElement("canvas"),q=Z.getContext("2d"));var R=e,N=R.crossOrigin;R.crossOrigin="anonymous";var z=function(){R.removeEventListener("load",z);try{Z.width=R.naturalWidth,Z.height=R.naturalHeight,q.drawImage(R,0,0),v.rr_dataURL=Z.toDataURL(c.type,c.quality)}catch(e){console.warn("Cannot inline img src=".concat(R.currentSrc,"! Error: ").concat(e))}N?v.crossOrigin=N:R.removeAttribute("crossorigin")};R.complete&&0!==R.naturalWidth?z():R.addEventListener("load",z)}if("audio"!==h&&"video"!==h||(v.rr_mediaState=e.paused?"paused":"played",v.rr_mediaCurrentTime=e.currentTime),f||(e.scrollLeft&&(v.rr_scrollLeft=e.scrollLeft),e.scrollTop&&(v.rr_scrollTop=e.scrollTop)),m){var M=e.getBoundingClientRect(),x=M.height;v={class:v.class,rr_width:"".concat(M.width,"px"),rr_height:"".concat(x,"px")}}return"iframe"!==h||d(v.src)||(e.contentDocument||(v.rr_src=v.src),delete v.src),{type:O.Element,tagName:h,attributes:v,childNodes:[],isSVG:(D=e,Boolean("svg"===D.tagName||D.ownerSVGElement)||void 0),needBlock:m,rootId:g};var D}(e,{doc:n,blockClass:r,blockSelector:o,inlineStylesheet:s,maskInputOptions:l,maskInputFn:d,dataURLOptions:f,inlineImages:g,recordCanvas:m,keepIframeSrcFn:h,newlyAddedElement:y,rootId:S});case e.TEXT_NODE:return function(e,t){var n,r,o=t.maskTextClass,i=t.maskTextSelector,a=t.maskTextFn,s=t.rootId,c=t.maskAllText,l=e.parentNode&&e.parentNode.tagName,u=e.textContent,d="STYLE"===l||void 0,p="SCRIPT"===l||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,oe())}return p&&(u="SCRIPT_PLACEHOLDER"),!d&&!p&&u&&ce(e,o,i,c)&&(u=a?a(u):u.replace(/[\S]/g,"*")),{type:O.Text,textContent:u||"",isStyle:d,rootId:s}}(e,{maskTextClass:i,maskTextSelector:a,maskTextFn:u,rootId:S,maskAllText:I});case e.CDATA_SECTION_NODE:return{type:O.CDATA,textContent:"",rootId:S};case e.COMMENT_NODE:return{type:O.Comment,textContent:e.textContent||"",rootId:S};default:return!1}}(e,{doc:r,mirror:o,blockClass:i,blockSelector:a,maskTextClass:s,maskTextSelector:c,inlineStylesheet:p,maskInputOptions:g,maskTextFn:m,maskInputFn:h,dataURLOptions:w,inlineImages:S,recordCanvas:b,keepIframeSrcFn:x,newlyAddedElement:void 0!==D&&D,maskAllText:L});if(!K)return console.warn(e,"not serialized"),null;n=o.hasNode(e)?o.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&&(le(e.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===le(e.attributes.name)||"icon"===le(e.attributes.rel)||"apple-touch-icon"===le(e.attributes.rel)||"shortcut icon"===le(e.attributes.rel))))return!0;if("meta"===e.tagName){if(t.headMetaDescKeywords&&le(e.attributes.name).match(/^description|keywords$/))return!0;if(t.headMetaSocial&&(le(e.attributes.property).match(/^(og|twitter|fb):/)||le(e.attributes.name).match(/^(og|twitter):/)||"pinterest"===le(e.attributes.name)))return!0;if(t.headMetaRobots&&("robots"===le(e.attributes.name)||"googlebot"===le(e.attributes.name)||"bingbot"===le(e.attributes.name)))return!0;if(t.headMetaHttpEquiv&&void 0!==e.attributes["http-equiv"])return!0;if(t.headMetaAuthorship&&("author"===le(e.attributes.name)||"generator"===le(e.attributes.name)||"framework"===le(e.attributes.name)||"publisher"===le(e.attributes.name)||"progid"===le(e.attributes.name)||le(e.attributes.property).match(/^article:/)||le(e.attributes.property).match(/^product:/)))return!0;if(t.headMetaVerification&&("google-site-verification"===le(e.attributes.name)||"yandex-verification"===le(e.attributes.name)||"csrf-token"===le(e.attributes.name)||"p:domain_verify"===le(e.attributes.name)||"verify-v1"===le(e.attributes.name)||"verification"===le(e.attributes.name)||"shopify-checkout-api-token"===le(e.attributes.name)))return!0}}return!1}(K,v)&&(B||K.type!==O.Text||K.isStyle||K.textContent.replace(/^\s+|\s+$/gm,"").length)?j():H;var Y=Object.assign(K,{id:n});if(o.add(e,Y),n===H)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&&(B=!1);for(var $={doc:r,mirror:o,blockClass:i,blockSelector:a,maskTextClass:s,maskTextSelector:c,skipChild:u,inlineStylesheet:p,maskInputOptions:g,maskTextFn:m,maskInputFn:h,slimDOMOptions:v,dataURLOptions:w,inlineImages:S,recordCanvas:b,preserveWhiteSpace:B,onSerialize:E,onIframeLoad:k,iframeLoadTimeout:T,onStylesheetLoad:R,stylesheetLoadTimeout:z,keepIframeSrcFn:x,maskAllText:L},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,se=Array.from(e.shadowRoot.childNodes);re<se.length;re++){var de;(de=ue(se[re],$))&&(F(e.shadowRoot)&&(de.isShadow=!0),Y.childNodes.push(de))}}return e.parentNode&&P(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 o,i=!1;try{o=r.document.readyState}catch(e){return}if("complete"===o){var a="about:blank";if(r.location.href!==a||e.src===a||""===e.src)return setTimeout(t,0),e.addEventListener("load",t);e.addEventListener("load",t)}else{var s=setTimeout(function(){i||(t(),i=!0)},n);e.addEventListener("load",function(){clearTimeout(s),i=!0,t()})}}}(e,function(){var t=e.contentDocument;if(t&&k){var n=ue(t,{doc:t,mirror:o,blockClass:i,blockSelector:a,maskTextClass:s,maskTextSelector:c,skipChild:!1,inlineStylesheet:p,maskInputOptions:g,maskTextFn:m,maskInputFn:h,slimDOMOptions:v,dataURLOptions:w,inlineImages:S,recordCanvas:b,preserveWhiteSpace:B,onSerialize:E,onIframeLoad:k,iframeLoadTimeout:T,onStylesheetLoad:R,stylesheetLoadTimeout:z,keepIframeSrcFn:x,maskAllText:L});n&&k(e,n)}},T),Y.type===O.Element&&"link"===Y.tagName&&"stylesheet"===Y.attributes.rel&&function(e,t,n){var r,o=!1;try{r=e.sheet}catch(e){return}if(!r){var i=setTimeout(function(){o||(t(),o=!0)},n);e.addEventListener("load",function(){clearTimeout(i),o=!0,t()})}}(e,function(){if(R){var t=ue(e,{doc:r,mirror:o,blockClass:i,blockSelector:a,maskTextClass:s,maskTextSelector:c,skipChild:!1,inlineStylesheet:p,maskInputOptions:g,maskTextFn:m,maskInputFn:h,slimDOMOptions:v,dataURLOptions:w,inlineImages:S,recordCanvas:b,preserveWhiteSpace:B,onSerialize:E,onIframeLoad:k,iframeLoadTimeout:T,onStylesheetLoad:R,stylesheetLoadTimeout:z,keepIframeSrcFn:x,maskAllText:L});t&&R(e,t)}},z),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 pe="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 fe={map:{},getId:()=>(console.error(pe),-1),getNode:()=>(console.error(pe),null),removeNodeFromMap(){console.error(pe)},has:()=>(console.error(pe),!1),reset(){console.error(pe)}};function ge(e,t,n={}){let r=null,o=0;return function(...i){const a=Date.now();o||!1!==n.leading||(o=a);const s=t-(a-o),c=this;s<=0||s>t?(r&&(clearTimeout(r),r=null),o=a,e.apply(c,i)):r||!1===n.trailing||(r=setTimeout(()=>{o=!1===n.leading?0:Date.now(),r=null,e.apply(c,i)},s))}}function me(e,t,n,r,o=window){const i=o.Object.getOwnPropertyDescriptor(e,t);return o.Object.defineProperty(e,t,r?n:{set(e){setTimeout(()=>{n.set.call(this,e)},0),i&&i.set&&i.set.call(this,e)}}),()=>me(e,t,i||{},!0)}function he(e,t,n){try{if(!(t in e))return()=>{};const r=e[t],o=n(r);return"function"==typeof o&&(o.prototype=o.prototype||{},Object.defineProperties(o,{__rrweb_original__:{enumerable:!1,value:r}})),e[t]=o,()=>{e[t]=r}}catch(e){return()=>{}}}function ve(e){var t,n,r,o,i,a;const s=e.document;return{left:s.scrollingElement?s.scrollingElement.scrollLeft:void 0!==e.pageXOffset?e.pageXOffset:(null==s?void 0:s.documentElement.scrollLeft)||(null===(n=null===(t=null==s?void 0:s.body)||void 0===t?void 0:t.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(r=null==s?void 0:s.body)||void 0===r?void 0:r.scrollLeft)||0,top:s.scrollingElement?s.scrollingElement.scrollTop:void 0!==e.pageYOffset?e.pageYOffset:(null==s?void 0:s.documentElement.scrollTop)||(null===(i=null===(o=null==s?void 0:s.body)||void 0===o?void 0:o.parentElement)||void 0===i?void 0:i.scrollTop)||(null===(a=null==s?void 0:s.body)||void 0===a?void 0:a.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 Ie(e,t,n,r){if(!e)return!1;const o=e.nodeType===e.ELEMENT_NODE?e:e.parentElement;if(!o)return!1;try{if("string"==typeof t){if(o.classList.contains(t))return!0;if(r&&null!==o.closest("."+t))return!0}else if(se(o,t,r))return!0}catch(e){}if(n){if(o.matches(n))return!0;if(r&&null!==o.closest(n))return!0}return!1}function Se(e,t){return t.getId(e)===H}function Ce(e,t){if(P(e))return!1;const n=t.getId(e);return!t.has(n)||(!e.parentNode||e.parentNode.nodeType!==e.DOCUMENT_NODE)&&(!e.parentNode||Ce(e.parentNode,t))}function be(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 Ae(e){return Boolean(null==e?void 0:e.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(fe=new Proxy(fe,{get:(e,t,n)=>("map"===t&&console.error(pe),Reflect.get(e,t,n))}));class Te{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 Ne(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 ze=/* @__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))(ze||{}),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||{}),xe=/* @__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))(xe||{}),De=/* @__PURE__ */(e=>(e[e["2D"]=0]="2D",e[e.WebGL=1]="WebGL",e[e.WebGL2=2]="WebGL2",e))(De||{});function Ue(e){return"__ln"in e}class Le{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&&Ue(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&&Ue(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 Pe=(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 Le,n=e=>{let t=e,n=H;for(;n===H;)t=t&&t.nextSibling,n=t&&this.mirror.getId(t);return n},r=r=>{if(!r.parentNode||!Ne(r))return;const o=P(r.parentNode)?this.mirror.getId(Re(r)):this.mirror.getId(r.parentNode),i=n(r);if(-1===o||-1===i)return t.addNode(r);const a=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),Ae(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)}});a&&e.push({parentId:o,nextId:i,node:a})};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 o=null;for(;t.length;){let e=null;if(o){const t=this.mirror.getId(o.value.parentNode),r=n(o.value);-1!==t&&-1!==r&&(e=o)}if(!e)for(let r=t.length-1;r>=0;r--){const o=t.get(r);if(o){const t=this.mirror.getId(o.value.parentNode);if(-1===n(o.value))continue;if(-1!==t){e=o;break}{const t=o.value;if(t.parentNode&&t.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&-1!==this.mirror.getId(t.parentNode.host)){e=o;break}}}}if(!e){for(;t.head;)t.removeNode(t.head.value);break}o=e.previous,t.removeNode(e.value),r(e.value)}const i={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};(i.texts.length||i.attributes.length||i.removes.length||i.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(i))},this.processMutation=e=>{if(!Se(e.target,this.mirror))switch(e.type){case"characterData":{const t=e.target.textContent;Ie(e.target,this.blockClass,this.blockSelector,!1)||t===e.oldValue||this.texts.push({value:ce(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(Ie(e.target,this.blockClass,this.blockSelector,!1)||r===e.oldValue)return;let o=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(o||(o={node:e.target,attributes:{}},this.attributes.push(o)),"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==o.attributes.style&&(o.attributes.style={});const r=o.attributes.style;for(const e of Array.from(t.style)){const o=t.style.getPropertyValue(e),i=t.style.getPropertyPriority(e);o===n.style.getPropertyValue(e)&&i===n.style.getPropertyPriority(e)||(r[e]=""===i?o:[o,i])}for(const e of Array.from(n.style))""===t.style.getPropertyValue(e)&&(r[e]=!1)}else ae(t.tagName,n)||(o.attributes[n]=ie(this.doc,t.tagName,n,r));break}case"childList":if(Ie(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=P(e.target)?this.mirror.getId(e.target.host):this.mirror.getId(e.target);Ie(e.target,this.blockClass,this.blockSelector,!1)||Se(t,this.mirror)||!function(e,t){return-1!==t.getId(e)}(t,this.mirror)||(this.addedSet.has(t)?(Ge(this.addedSet,t),this.droppedSet.add(t)):this.addedSet.has(e.target)&&-1===n||Ce(e.target,this.mirror)||(this.movedSet.has(t)&&this.movedMap[Pe(n,r)]?Ge(this.movedSet,t):this.removes.push({parentId:r,id:n,isShadow:!(!P(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(Se(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[Pe(this.mirror.getId(e),n)]=!0)}else this.addedSet.add(e),this.droppedSet.delete(e);Ie(e,this.blockClass,this.blockSelector,!1)||(e.childNodes.forEach(e=>this.genAdds(e)),Ae(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 Ge(e,t){e.delete(t),t.childNodes.forEach(t=>Ge(e,t))}function _e(e,t,n){return 0!==e.length&&Be(e,t,n)}function Be(e,t,n){const{parentNode:r}=t;if(!r)return!1;const o=n.getId(r);return!!e.some(e=>e.id===o)||Be(e,r,n)}function We(e,t){return 0!==e.size&&Ze(e,t)}function Ze(e,t){const{parentNode:n}=t;return!!n&&(!!e.has(n)||Ze(e,n))}let qe;function Ve(e){qe=e}function Ke(){qe=void 0}const Je=e=>qe?(...t)=>{try{return e(...t)}catch(e){if(qe&&!0===qe(e))return;throw e}}:e;function He(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="",o=e[n];o&&o.tagName&&o.attributes&&o.attributes.length&&(r=n>0?o.tagName.toLowerCase()+He(o.attributes)+" > ":o.tagName.toLowerCase()+He(o.attributes),t+=r)}return t}(t):""}const Ye=[];function Xe(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 Qe(e,t){var n,r;const o=new Fe;Ye.push(o),o.init(e);let i=window.MutationObserver||window.__rrMutationObserver;const a=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");a&&window[a]&&(i=window[a]);const s=new i(Je(o.processMutations.bind(o)));return s.observe(t,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),s}function $e({scrollCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i}){return de("scroll",Je(ge(Je(i=>{const a=Xe(i);if(!a||Ie(a,r,o,!0))return;const s=n.getId(a);if(a===t&&t.defaultView){const n=ve(t.defaultView);e({id:s,x:n.left,y:n.top})}else e({id:s,x:a.scrollLeft,y:a.scrollTop})}),i.scroll||100)),t)}function et(e,t){const n=Object.assign({},e);return t||delete n.userTriggered,n}const tt=["INPUT","TEXTAREA","SELECT"],nt=new WeakMap;function rt(e){return function(e,t){if(st("CSSGroupingRule")&&e.parentRule instanceof CSSGroupingRule||st("CSSMediaRule")&&e.parentRule instanceof CSSMediaRule||st("CSSSupportsRule")&&e.parentRule instanceof CSSSupportsRule||st("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,o;return e?(e.ownerNode?r=t.getId(e.ownerNode):o=n.getId(e),{styleId:o,id:r}):{}}function it({mirror:e,stylesheetManager:t},n){var r,o,i;let a=null;a=e.getId("#document"===n.nodeName?n:n.host);const s="#document"===n.nodeName?null===(r=n.defaultView)||void 0===r?void 0:r.Document:null===(i=null===(o=n.ownerDocument)||void 0===o?void 0:o.defaultView)||void 0===i?void 0:i.ShadowRoot,c=Object.getOwnPropertyDescriptor(null==s?void 0:s.prototype,"adoptedStyleSheets");return null!==a&&-1!==a&&s&&c?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get(){var e;return null===(e=c.get)||void 0===e?void 0:e.call(this)},set(e){var n;const r=null===(n=c.set)||void 0===n?void 0:n.call(this,e);if(null!==a&&-1!==a)try{t.adoptStyleSheets(e,a)}catch(e){}return r}}),Je(()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:c.configurable,enumerable:c.enumerable,get:c.get,set:c.set})})):()=>{}}function at(e,t={}){const n=e.doc.defaultView;if(!n)return()=>{};!function(e,t){const{mutationCb:n,mousemoveCb:r,mouseInteractionCb:o,scrollCb:i,viewportResizeCb:a,inputCb:s,mediaInteractionCb:c,styleSheetRuleCb:l,styleDeclarationCb:u,canvasMutationCb:d,fontCb:p,selectionCb:f}=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),o(...e)},e.scrollCb=(...e)=>{t.scroll&&t.scroll(...e),i(...e)},e.viewportResizeCb=(...e)=>{t.viewportResize&&t.viewportResize(...e),a(...e)},e.inputCb=(...e)=>{t.input&&t.input(...e),s(...e)},e.mediaInteractionCb=(...e)=>{t.mediaInteaction&&t.mediaInteaction(...e),c(...e)},e.styleSheetRuleCb=(...e)=>{t.styleSheetRule&&t.styleSheetRule(...e),l(...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),p(...e)},e.selectionCb=(...e)=>{t.selection&&t.selection(...e),f(...e)}}(e,t);const r=Qe(e,e.doc),o=function({mousemoveCb:e,sampling:t,doc:n,mirror:r}){if(!1===t.mousemove)return()=>{};const o="number"==typeof t.mousemove?t.mousemove:50,i="number"==typeof t.mousemoveCallback?t.mousemoveCallback:500;let a,s=[];const c=ge(Je(t=>{const n=Date.now()-a;e(s.map(e=>(e.timeOffset-=n,e)),t),s=[],a=null}),i),l=Je(ge(Je(e=>{const t=Xe(e),{clientX:n,clientY:o}=be(e)?e.changedTouches[0]:e;a||(a=Date.now()),s.push({x:n,y:o,id:r.getId(t),timeOffset:Date.now()-a}),c("undefined"!=typeof DragEvent&&e instanceof DragEvent?Me.Drag:e instanceof MouseEvent?Me.MouseMove:Me.TouchMove)}),o,{trailing:!1})),u=[de("mousemove",l,n),de("touchmove",l,n),de("drag",l,n)];return Je(()=>{u.forEach(e=>e())})}(e),i=function({mouseInteractionCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,sampling:i,captureClickEvents:a}){if(!1===i.mouseInteraction)return()=>{};const s=!0===i.mouseInteraction||void 0===i.mouseInteraction?{}:i.mouseInteraction,c=[];let l=0,u="";return Object.keys(xe).filter(e=>Number.isNaN(Number(e))&&!e.endsWith("_Departed")&&!1!==s[e]).forEach(i=>{const s=i.toLowerCase(),d=(t=>i=>{const s=Xe(i);if(Ie(s,r,o,!0))return;const c=be(i)?i.changedTouches[0]:i;if(!c)return;const d=n.getId(s),{clientX:p,clientY:f}=c,g=je(i);let m={type:xe[t],id:d,x:p,y:f,nodePath:g};if(xe[t]===xe.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."),"")}(i),o=!!a&&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}(i),s=i.offsetX,c=i.offsetY,[d,p]=function(e){let t=e.target;return t?[t.clientHeight,t.clientWidth]:(console.error("Event target is not an HTML element."),[0,0])}(i),f=function(e){var t,n,r,o;const i=(null===(o=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===o?void 0:o.length)||0;let a=null==e?void 0:e.target;if(a){if(!a||!(null==a?void 0:a.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 i>0&&t.unshift(`iframe_context.level-${i}`),t.join(" > ")}return null}(i),g=(new Date).getTime();let h=!1;a&&u===f&&(h=g-l<3e3),l=new Date(g).getTime(),u=f||"",m=Object.assign(Object.assign({},m),{deadClick:o,innerText:r,offsetX:s,offsetY:c,rageClick:h,screenHeight:e,screenWidth:t,navigationUrl:n,elementHeight:d,elementWidth:p,selector:f})}Je(e)(m)})(i);c.push(de(s,d,t))}),Je(()=>{c.forEach(e=>e())})}(e),a=$e(e),s=function({viewportResizeCb:e}){let t=-1,n=-1;return de("resize",Je(ge(Je(()=>{const r=ye(),o=we();t===r&&n===o||(e({width:Number(o),height:Number(r)}),t=r,n=o)}),200)),window)}(e),c=function({inputCb:e,doc:t,mirror:n,blockClass:r,blockSelector:o,ignoreClass:i,maskInputOptions:a,maskInputFn:s,sampling:c,userTriggeredOnInput:l}){function u(e){let n=Xe(e);const c=je(e),u=e.isTrusted,p=n&&n.tagName;if(n&&"OPTION"===p&&(n=n.parentElement),!n||!p||tt.indexOf(p)<0||Ie(n,r,o,!0))return;if(n.classList.contains(i))return;let f=n.value,g=!1;const m=Oe(n)||"";"radio"===m||"checkbox"===m?g=n.checked:(a[p.toLowerCase()]||a[m])&&(f=W({maskInputOptions:a,tagName:p,type:m,value:f,maskInputFn:s})),d(n,Je(et)({text:f,isChecked:g,userTriggered:u,nodePath:c},l));const h=n.name;"radio"===m&&h&&g&&t.querySelectorAll(`input[type="radio"][name="${h}"]`).forEach(e=>{e!==n&&d(e,Je(et)({text:e.value,isChecked:!g,userTriggered:!1,nodePath:""},l))})}function d(t,r){const o=nt.get(t);if(!o||o.text!==r.text||o.isChecked!==r.isChecked){nt.set(t,r);const o=n.getId(t);Je(e)(Object.assign(Object.assign({},r),{id:o}))}}const p=("last"===c.input?["change"]:["input","change"]).map(e=>de(e,Je(u),t)),f=t.defaultView;if(!f)return()=>{p.forEach(e=>e())};const g=f.Object.getOwnPropertyDescriptor(f.HTMLInputElement.prototype,"value");return g&&g.set&&p.push(...[[f.HTMLInputElement.prototype,"value"],[f.HTMLInputElement.prototype,"checked"],[f.HTMLSelectElement.prototype,"value"],[f.HTMLTextAreaElement.prototype,"value"],[f.HTMLSelectElement.prototype,"selectedIndex"],[f.HTMLOptionElement.prototype,"selected"]].map(e=>me(e[0],e[1],{set(){Je(u)({target:this,isTrusted:!1})}},!1,f))),Je(()=>{p.forEach(e=>e())})}(e),l=function({mediaInteractionCb:e,blockClass:t,blockSelector:n,mirror:r,sampling:o}){const i=Je(i=>ge(Je(o=>{const a=Xe(o);if(!a||Ie(a,t,n,!0))return;const{currentTime:s,volume:c,muted:l,playbackRate:u}=a;e({type:i,id:r.getId(a),currentTime:s,volume:c,muted:l,playbackRate:u})}),o.media||500)),a=[de("play",i(0)),de("pause",i(1)),de("seeked",i(2)),de("volumechange",i(3)),de("ratechange",i(4))];return Je(()=>{a.forEach(e=>e())})}(e),u=function({styleSheetRuleCb:e,mirror:t,stylesheetManager:n},{win:r}){if(!r.CSSStyleSheet||!r.CSSStyleSheet.prototype)return()=>{};const o=r.CSSStyleSheet.prototype.insertRule;r.CSSStyleSheet.prototype.insertRule=new Proxy(o,{apply:Je((r,o,i)=>{const[a,s]=i,{id:c,styleId:l}=ot(o,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:a,index:s}]}),r.apply(o,i)})});const i=r.CSSStyleSheet.prototype.deleteRule;let a,s;r.CSSStyleSheet.prototype.deleteRule=new Proxy(i,{apply:Je((r,o,i)=>{const[a]=i,{id:s,styleId:c}=ot(o,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,removes:[{index:a}]}),r.apply(o,i)})}),r.CSSStyleSheet.prototype.replace&&(a=r.CSSStyleSheet.prototype.replace,r.CSSStyleSheet.prototype.replace=new Proxy(a,{apply:Je((r,o,i)=>{const[a]=i,{id:s,styleId:c}=ot(o,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,replace:a}),r.apply(o,i)})})),r.CSSStyleSheet.prototype.replaceSync&&(s=r.CSSStyleSheet.prototype.replaceSync,r.CSSStyleSheet.prototype.replaceSync=new Proxy(s,{apply:Je((r,o,i)=>{const[a]=i,{id:s,styleId:c}=ot(o,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,replaceSync:a}),r.apply(o,i)})}));const c={};ct("CSSGroupingRule")?c.CSSGroupingRule=r.CSSGroupingRule:(ct("CSSMediaRule")&&(c.CSSMediaRule=r.CSSMediaRule),ct("CSSConditionRule")&&(c.CSSConditionRule=r.CSSConditionRule),ct("CSSSupportsRule")&&(c.CSSSupportsRule=r.CSSSupportsRule));const l={};return Object.entries(c).forEach(([r,o])=>{l[r]={insertRule:o.prototype.insertRule,deleteRule:o.prototype.deleteRule},o.prototype.insertRule=new Proxy(l[r].insertRule,{apply:Je((r,o,i)=>{const[a,s]=i,{id:c,styleId:l}=ot(o.parentStyleSheet,t,n.styleMirror);return(c&&-1!==c||l&&-1!==l)&&e({id:c,styleId:l,adds:[{rule:a,index:[...rt(o),s||0]}]}),r.apply(o,i)})}),o.prototype.deleteRule=new Proxy(l[r].deleteRule,{apply:Je((r,o,i)=>{const[a]=i,{id:s,styleId:c}=ot(o.parentStyleSheet,t,n.styleMirror);return(s&&-1!==s||c&&-1!==c)&&e({id:s,styleId:c,removes:[{index:[...rt(o),a]}]}),r.apply(o,i)})})}),Je(()=>{try{r.CSSStyleSheet.prototype.insertRule=o,r.CSSStyleSheet.prototype.deleteRule=i,a&&(r.CSSStyleSheet.prototype.replace=a),s&&(r.CSSStyleSheet.prototype.replaceSync=s)}catch(e){}try{Object.entries(c).forEach(([e,t])=>{t.prototype.insertRule=l[e].insertRule,t.prototype.deleteRule=l[e].deleteRule})}catch(e){}})}(e,{win:n}),d=it(e,e.doc),p=function({styleDeclarationCb:e,mirror:t,ignoreCSSAttributes:n,stylesheetManager:r},{win:o}){const i=o.CSSStyleDeclaration.prototype.setProperty;o.CSSStyleDeclaration.prototype.setProperty=new Proxy(i,{apply:Je((o,a,s)=>{var c;const[l,u,d]=s;if(n.has(l))return i.apply(a,[l,u,d]);const{id:p,styleId:f}=ot(null===(c=a.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(p&&-1!==p||f&&-1!==f)&&e({id:p,styleId:f,set:{property:l,value:u,priority:d},index:rt(a.parentRule)}),o.apply(a,s)})});const a=o.CSSStyleDeclaration.prototype.removeProperty;return o.CSSStyleDeclaration.prototype.removeProperty=new Proxy(a,{apply:Je((o,i,s)=>{var c;const[l]=s;if(n.has(l))return a.apply(i,[l]);const{id:u,styleId:d}=ot(null===(c=i.parentRule)||void 0===c?void 0:c.parentStyleSheet,t,r.styleMirror);return(u&&-1!==u||d&&-1!==d)&&e({id:u,styleId:d,remove:{property:l},index:rt(i.parentRule)}),o.apply(i,s)})}),Je(()=>{try{o.CSSStyleDeclaration.prototype.setProperty=i,o.CSSStyleDeclaration.prototype.removeProperty=a}catch(e){}})}(e,{win:n}),f=e.collectFonts?function({fontCb:e,doc:t}){const n=t.defaultView;if(!n)return()=>{};const r=[],o=new WeakMap,i=n.FontFace;n.FontFace=function(e,t,n){const r=new i(e,t,n);return o.set(r,{family:e,buffer:"string"!=typeof t,descriptors:n,fontSource:"string"==typeof t?t:JSON.stringify(Array.from(new Uint8Array(t)))}),r};const a=he(t.fonts,"add",function(t){return function(n){return setTimeout(Je(()=>{const t=o.get(n);t&&(e(t),o.delete(n))}),0),t.apply(this,[n])}});return r.push(()=>{n.FontFace=i}),r.push(a),Je(()=>{r.forEach(e=>e())})}(e):()=>{},g=function(e){const{doc:t,mirror:n,blockClass:r,blockSelector:o,selectionCb:i}=e;let a=!0;const s=Je(()=>{const e=t.getSelection();if(!e||a&&(null==e?void 0:e.isCollapsed))return;a=e.isCollapsed||!1;const s=[],c=e.rangeCount||0;for(let t=0;t<c;t++){const i=e.getRangeAt(t),{startContainer:a,startOffset:c,endContainer:l,endOffset:u}=i;Ie(a,r,o,!0)||Ie(l,r,o,!0)||s.push({start:n.getId(a),startOffset:c,end:n.getId(l),endOffset:u})}i({ranges:s})});return s(),de("selectionchange",s)}(e),m=[];for(const t of e.plugins)m.push(t.observer(t.callback,n,t.options));return Je(()=>{Ye.forEach(e=>e.reset()),r.disconnect(),o(),i(),a(),s(),c(),l(),u(),d(),p(),f(),g(),m.forEach(e=>e())})}function st(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 lt{constructor(e){this.generateIdFn=e,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(e,t,n,r){const o=n||this.getIdToRemoteIdMap(e),i=r||this.getRemoteIdToIdMap(e);let a=o.get(t);return a||(a=this.generateIdFn(),o.set(t,a),i.set(a,t)),a}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 ut{constructor(e){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new lt(j),this.crossOriginIframeRootIdMap=new WeakMap,this.mutationCb=e.mutationCb,this.wrappedEmit=e.wrappedEmit,this.stylesheetManager=e.stylesheetManager,this.recordCrossOriginIframes=e.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new lt(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;const n=this.crossOriginIframeMap.get(e.source);if(!n)return;const r=this.transformCrossOriginEvent(n,t.data.event);r&&this.wrappedEmit(r,t.data.isCheckout)}transformCrossOriginEvent(e,t){var n;switch(t.type){case ze.FullSnapshot:{this.crossOriginIframeMirror.reset(e),this.crossOriginIframeStyleMirror.reset(