@lightworkai.official/debug-capture 0.11.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ var X1=Object.defineProperty,Y1=(J,$,Z)=>($ in J)?X1(J,$,{enumerable:!0,configurable:!0,writable:!0,value:Z}):J[$]=Z,H=(J,$,Z)=>Y1(J,typeof $!=="symbol"?$+"":$,Z),Q0,_=((J)=>{return J[J.DomContentLoaded=0]="DomContentLoaded",J[J.Load=1]="Load",J[J.FullSnapshot=2]="FullSnapshot",J[J.IncrementalSnapshot=3]="IncrementalSnapshot",J[J.Meta=4]="Meta",J[J.Custom=5]="Custom",J[J.Plugin=6]="Plugin",J[J.Asset=7]="Asset",J})(_||{}),M=((J)=>{return J[J.Mutation=0]="Mutation",J[J.MouseMove=1]="MouseMove",J[J.MouseInteraction=2]="MouseInteraction",J[J.Scroll=3]="Scroll",J[J.ViewportResize=4]="ViewportResize",J[J.Input=5]="Input",J[J.TouchMove=6]="TouchMove",J[J.MediaInteraction=7]="MediaInteraction",J[J.StyleSheetRule=8]="StyleSheetRule",J[J.CanvasMutation=9]="CanvasMutation",J[J.Font=10]="Font",J[J.Log=11]="Log",J[J.Drag=12]="Drag",J[J.StyleDeclaration=13]="StyleDeclaration",J[J.Selection=14]="Selection",J[J.AdoptedStyleSheet=15]="AdoptedStyleSheet",J[J.CustomElement=16]="CustomElement",J})(M||{}),u=((J)=>{return J[J.MouseUp=0]="MouseUp",J[J.MouseDown=1]="MouseDown",J[J.Click=2]="Click",J[J.ContextMenu=3]="ContextMenu",J[J.DblClick=4]="DblClick",J[J.Focus=5]="Focus",J[J.Blur=6]="Blur",J[J.TouchStart=7]="TouchStart",J[J.TouchMove_Departed=8]="TouchMove_Departed",J[J.TouchEnd=9]="TouchEnd",J[J.TouchCancel=10]="TouchCancel",J})(u||{}),n=((J)=>{return J[J.Mouse=0]="Mouse",J[J.Pen=1]="Pen",J[J.Touch=2]="Touch",J})(n||{}),jJ=((J)=>{return J[J["2D"]=0]="2D",J[J.WebGL=1]="WebGL",J[J.WebGL2=2]="WebGL2",J})(jJ||{}),GJ=((J)=>{return J[J.Play=0]="Play",J[J.Pause=1]="Pause",J[J.Seeked=2]="Seeked",J[J.VolumeChange=3]="VolumeChange",J[J.RateChange=4]="RateChange",J})(GJ||{}),v=((J)=>{return J[J.Document=0]="Document",J[J.DocumentType=1]="DocumentType",J[J.Element=2]="Element",J[J.Text=3]="Text",J[J.CDATA=4]="CDATA",J[J.Comment=5]="Comment",J})(v||{}),q0={Node:["childNodes","parentNode","parentElement","textContent","ownerDocument"],ShadowRoot:["host","styleSheets"],Element:["shadowRoot","querySelector","querySelectorAll"],MutationObserver:[]},G0={Node:["contains","getRootNode"],ShadowRoot:["getSelection"],Element:[],MutationObserver:["constructor"]},_J={},R0={},Q1=()=>{return!!globalThis.Zone};function nJ(J){if(_J[J])return _J[J];let $=globalThis[J],Z=$.prototype,X=J in q0?q0[J]:void 0,Y=Boolean(X&&X.every((G)=>{var Q,K;return Boolean((K=(Q=Object.getOwnPropertyDescriptor(Z,G))==null?void 0:Q.get)==null?void 0:K.toString().includes("[native code]"))})),q=J in G0?G0[J]:void 0,V=Boolean(q&&q.every((G)=>{var Q;return typeof Z[G]==="function"&&((Q=Z[G])==null?void 0:Q.toString().includes("[native code]"))}));if(Y&&V&&!Q1())return _J[J]=$.prototype,$.prototype;try{let G=document.createElement("iframe");G.style.display="none",document.body.appendChild(G);let Q=G.contentWindow;if(!Q)return $.prototype;let K=Q[J].prototype;if(!K)return G.remove(),Z;let U=navigator.userAgent;if(U.includes("Safari")&&!U.includes("Chrome"))G.classList.add("rr-block"),G.setAttribute("__rrwebUntaintedMutationObserver",""),R0[J]=()=>G.remove();else G.remove();return _J[J]=K}catch{return Z}}var pJ={};function t(J,$,Z){var X;let Y=`${J}.${String(Z)}`;if(pJ[Y])return pJ[Y].call($);let q=nJ(J),V=(X=Object.getOwnPropertyDescriptor(q,Z))==null?void 0:X.get;if(!V)return $[Z];return pJ[Y]=V,V.call($)}var dJ={};function O0(J,$,Z){let X=`${J}.${String(Z)}`;if(dJ[X])return dJ[X].bind($);let q=nJ(J)[Z];if(typeof q!=="function")return $[Z];return dJ[X]=q,q.bind($)}function q1(J){return t("Node",J,"ownerDocument")}function G1(J){return t("Node",J,"childNodes")}function V1(J){return t("Node",J,"parentNode")}function K1(J){return t("Node",J,"parentElement")}function W1(J){return t("Node",J,"textContent")}function U1(J,$){return O0("Node",J,"contains")($)}function B1(J){return O0("Node",J,"getRootNode")()}function j1(J){if(!J||!("host"in J))return null;return t("ShadowRoot",J,"host")}function z1(J){return J.styleSheets}function H1(J){if(!J||!("shadowRoot"in J))return null;return t("Element",J,"shadowRoot")}function P1(J,$){return t("Element",J,"querySelector")($)}function D1(J,$){return t("Element",J,"querySelectorAll")($)}function M0(){return[nJ("MutationObserver").constructor,R0.MutationObserver??(()=>{})]}var AJ=Date.now;if(!/[1-9][0-9]{12}/.test(Date.now().toString()))AJ=()=>new Date().getTime();function QJ(J,$,Z){try{if(!($ in J))return()=>{};let X=J[$],Y=Z(X);if(typeof Y==="function")Y.prototype=Y.prototype||{},Object.defineProperties(Y,{__rrweb_original__:{enumerable:!1,value:X}});return J[$]=Y,()=>{J[$]=X}}catch{return()=>{}}}var A={ownerDocument:q1,childNodes:G1,parentNode:V1,parentElement:K1,textContent:W1,contains:U1,getRootNode:B1,host:j1,styleSheets:z1,shadowRoot:H1,querySelector:P1,querySelectorAll:D1,nowTimestamp:AJ,mutationObserverCtor:M0,patch:QJ};function N0(J){return J.nodeType===J.ELEMENT_NODE}function PJ(J){let $=J&&"host"in J&&"mode"in J&&A.host(J)||null;return Boolean($&&"shadowRoot"in $&&A.shadowRoot($)===J)}function DJ(J){return Object.prototype.toString.call(J)==="[object ShadowRoot]"}function L1(J){if(J.includes(" background-clip: text;")&&!J.includes(" -webkit-background-clip: text;"))J=J.replace(/\sbackground-clip:\s*text;/g," -webkit-background-clip: text; background-clip: text;");return J}function A1(J){let{cssText:$}=J;if($.split('"').length<3)return $;let Z=["@import",`url(${JSON.stringify(J.href)})`];if(J.layerName==="")Z.push("layer");else if(J.layerName)Z.push(`layer(${J.layerName})`);if(J.supportsText)Z.push(`supports(${J.supportsText})`);if(J.media.length)Z.push(J.media.mediaText);return Z.join(" ")+";"}function iJ(J){try{let $=J.rules||J.cssRules;if(!$)return null;let Z=J.href;if(!Z&&J.ownerNode)Z=J.ownerNode.baseURI;let X=Array.from($,(Y)=>_0(Y,Z)).join("");return L1(X)}catch($){return null}}function _0(J,$){if(R1(J)){let Z;try{Z=iJ(J.styleSheet)||A1(J)}catch(X){Z=J.cssText}if(J.styleSheet.href)return IJ(Z,J.styleSheet.href);return Z}else{let Z=J.cssText;if(O1(J)&&J.selectorText.includes(":"))Z=F1(Z);if($)return IJ(Z,$);return Z}}function F1(J){let $=/(\[(?:[\w-]+)[^\\])(:(?:[\w-]+)\])/gm;return J.replace($,"$1\\$2")}function R1(J){return"styleSheet"in J}function O1(J){return"selectorText"in J}class tJ{constructor(){H(this,"idNodeMap",new Map),H(this,"nodeMetaMap",new WeakMap)}getId(J){var $;if(!J)return-1;return(($=this.getMeta(J))==null?void 0:$.id)??-1}getNode(J){return this.idNodeMap.get(J)||null}getIds(){return Array.from(this.idNodeMap.keys())}getMeta(J){return this.nodeMetaMap.get(J)||null}removeNodeFromMap(J){let $=this.getId(J);if(this.idNodeMap.delete($),J.childNodes)J.childNodes.forEach((Z)=>this.removeNodeFromMap(Z))}has(J){return this.idNodeMap.has(J)}hasNode(J){return this.nodeMetaMap.has(J)}add(J,$){let Z=$.id;this.idNodeMap.set(Z,J),this.nodeMetaMap.set(J,$)}replace(J,$){let Z=this.getNode(J);if(Z){let X=this.nodeMetaMap.get(Z);if(X)this.nodeMetaMap.set($,X)}this.idNodeMap.set(J,$)}reset(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}}function M1(){return new tJ}function SJ({element:J,maskInputOptions:$,tagName:Z,type:X,value:Y,maskInputFn:q}){let V=Y||"",G=X&&JJ(X);if($[Z.toLowerCase()]||G&&$[G])if(q)V=q(V,J);else V="*".repeat(V.length);return V}function JJ(J){return J.toLowerCase()}var V0="__rrweb_original__";function N1(J){let $=J.getContext("2d");if(!$)return!0;let Z=50;for(let X=0;X<J.width;X+=Z)for(let Y=0;Y<J.height;Y+=Z){let q=$.getImageData,V=V0 in q?q[V0]:q;if(new Uint32Array(V.call($,X,Y,Math.min(Z,J.width-X),Math.min(Z,J.height-Y)).data.buffer).some((Q)=>Q!==0))return!1}return!0}function fJ(J){let $=J.type;return J.hasAttribute("data-rr-is-password")?"password":$?JJ($):null}function E0(J,$){let Z;try{Z=new URL(J,$??window.location.href)}catch(q){return null}let X=/\.([0-9a-z]+)(?:$)/i,Y=Z.pathname.match(X);return(Y==null?void 0:Y[1])??null}function _1(J){let $="";if(J.indexOf("//")>-1)$=J.split("/").slice(0,3).join("/");else $=J.split("/")[0];return $=$.split("?")[0],$}var E1=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,w1=/^(?:[a-z+]+:)?\/\//i,C1=/^www\..*/i,T1=/^(data:)([^,]*),(.*)/i;function IJ(J,$){return(J||"").replace(E1,(Z,X,Y,q,V,G)=>{let Q=Y||V||G,K=X||q||"";if(!Q)return Z;if(w1.test(Q)||C1.test(Q))return`url(${K}${Q}${K})`;if(T1.test(Q))return`url(${K}${Q}${K})`;if(Q[0]==="/")return`url(${K}${_1($)+Q}${K})`;let U=Q.split("#")[0],j=Q.substring(U.length),P=$.split("#")[0].split("/"),B=U.split("/");P.pop();for(let z of B)if(z===".")continue;else if(z==="..")P.pop();else P.push(z);return`url(${K}${P.join("/")}${j}${K})`})}function EJ(J,$=!1){if($)return J.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"");else return J.replace(/(\/\*[^*]*\*\/)|[\s;]/g,"").replace(/0px/g,"0")}function x1(J,$,Z=!1){let X=Array.from($.childNodes),Y=[],q=0;if(X.length>1&&J&&typeof J==="string"){let V=EJ(J,Z),G=V.length/J.length;for(let Q=1;Q<X.length;Q++)if(X[Q].textContent&&typeof X[Q].textContent==="string"){let K=EJ(X[Q].textContent,Z),U=100,j=3;for(;j<K.length;j++){if(K[j].match(/[a-zA-Z0-9]/)||K.indexOf(K.substring(0,j),1)!==-1)continue;break}for(;j<K.length;j++){let P=K.substring(0,j),B=V.split(P),z=-1;if(B.length===2)z=B[0].length;else if(B.length>2&&B[0]===""&&X[Q-1].textContent!=="")z=V.indexOf(P,1);else if(B.length===1){if(P=P.substring(0,P.length-1),B=V.split(P),B.length<=1)return Y.push(J),Y;j=101}else if(j===K.length-1)z=V.indexOf(P);if(B.length>=2&&j>100){let W=X[Q-1].textContent;if(W&&typeof W==="string"){let L=EJ(W).length;z=V.indexOf(P,L)}if(z===-1)z=B[0].length}if(z!==-1){let W=Math.floor(z/G);for(;W>0&&W<J.length;){if(q+=1,q>50*X.length)return Y.push(J),Y;let L=EJ(J.substring(0,W),Z);if(L.length===z){Y.push(J.substring(0,W)),J=J.substring(W),V=V.substring(z);break}else if(L.length<z)W+=Math.max(1,Math.floor((z-L.length)/G));else W-=Math.max(1,Math.floor((L.length-z)*G))}break}}}}return Y.push(J),Y}function S1(J,$){return x1(J,$).join("/* rr_split */")}var f1=1,I1=new RegExp("[^a-z0-9-_:]"),FJ=-2;function w0(){return f1++}function k1(J){if(J instanceof HTMLFormElement)return"form";let $=JJ(J.tagName);if(I1.test($))return"div";return $}var qJ,K0,v1=/^[^ \t\n\r\u000c]+/,b1=/^[, \t\n\r\u000c]+/;function y1(J,$){if($.trim()==="")return $;let Z=0;function X(q){let V,G=q.exec($.substring(Z));if(G)return V=G[0],Z+=V.length,V;return""}let Y=[];while(!0){if(X(b1),Z>=$.length)break;let q=X(v1);if(q.slice(-1)===",")q=WJ(J,q.substring(0,q.length-1)),Y.push(q);else{let V="";q=WJ(J,q);let G=!1;while(!0){let Q=$.charAt(Z);if(Q===""){Y.push((q+V).trim());break}else if(!G){if(Q===","){Z+=1,Y.push((q+V).trim());break}else if(Q==="(")G=!0}else if(Q===")")G=!1;V+=Q,Z+=1}}}return Y.join(", ")}var W0=new WeakMap;function WJ(J,$){if(!$||$.trim()==="")return $;return eJ(J,$)}function g1(J){return Boolean(J.tagName==="svg"||J.ownerSVGElement)}function eJ(J,$){let Z=W0.get(J);if(!Z)Z=J.createElement("a"),W0.set(J,Z);if(!$)$="";else if($.startsWith("blob:")||$.startsWith("data:"))return $;return Z.setAttribute("href",$),Z.href}function C0(J,$,Z,X){if(!X)return X;if(Z==="src"||Z==="href"&&!($==="use"&&X[0]==="#"))return WJ(J,X);else if(Z==="xlink:href"&&X[0]!=="#")return WJ(J,X);else if(Z==="background"&&["table","td","th"].includes($))return WJ(J,X);else if(Z==="srcset")return y1(J,X);else if(Z==="style")return IJ(X,eJ(J));else if($==="object"&&Z==="data")return WJ(J,X);return X}function T0(J,$,Z){return["video","audio"].includes(J)&&JJ($)==="autoplay"}function h1(J,$,Z){try{if(typeof $==="string"){if(J.classList.contains($))return!0}else for(let X=J.classList.length;X--;){let Y=J.classList[X];if($.test(Y))return!0}if(Z)return J.matches(Z)}catch(X){}return!1}function kJ(J,$,Z){if(!J)return!1;if(J.nodeType!==J.ELEMENT_NODE){if(!Z)return!1;return kJ(A.parentNode(J),$,Z)}for(let X=J.classList.length;X--;){let Y=J.classList[X];if($.test(Y))return!0}if(!Z)return!1;return kJ(A.parentNode(J),$,Z)}function x0(J,$,Z,X){let Y;if(N0(J)){if(Y=J,!A.childNodes(Y).length)return!1}else if(A.parentElement(J)===null)return!1;else Y=A.parentElement(J);try{if(typeof $==="string"){if(X){if(Y.closest(`.${$}`))return!0}else if(Y.classList.contains($))return!0}else if(kJ(Y,$,X))return!0;if(Z){if(X){if(Y.closest(Z))return!0}else if(Y.matches(Z))return!0}}catch(q){}return!1}function u1(J,$,Z){let X=J.contentWindow;if(!X)return;let Y=!1,q;try{q=X.document.readyState}catch(G){return}if(q!=="complete"){let G=setTimeout(()=>{if(!Y)$(),Y=!0},Z);J.addEventListener("load",()=>{clearTimeout(G),Y=!0,$()});return}let V="about:blank";if(X.location.href!==V||J.src===V||J.src==="")return setTimeout($,0),J.addEventListener("load",$);J.addEventListener("load",$)}function m1(J,$,Z){let X=!1,Y;try{Y=J.sheet}catch(V){return}if(Y)return;let q=setTimeout(()=>{if(!X)$(),X=!0},Z);J.addEventListener("load",()=>{clearTimeout(q),X=!0,$()})}function p1(J,$){let{doc:Z,mirror:X,blockClass:Y,blockSelector:q,needsMask:V,inlineStylesheet:G,maskInputOptions:Q={},maskTextFn:K,maskInputFn:U,dataURLOptions:j={},inlineImages:P,recordCanvas:B,keepIframeSrcFn:z,newlyAddedElement:W=!1,cssCaptured:L=!1}=$,R=d1(Z,X);switch(J.nodeType){case J.DOCUMENT_NODE:if(J.compatMode!=="CSS1Compat")return{type:v.Document,childNodes:[],compatMode:J.compatMode};else return{type:v.Document,childNodes:[]};case J.DOCUMENT_TYPE_NODE:return{type:v.DocumentType,name:J.name,publicId:J.publicId,systemId:J.systemId,rootId:R};case J.ELEMENT_NODE:return l1(J,{doc:Z,blockClass:Y,blockSelector:q,inlineStylesheet:G,maskInputOptions:Q,maskInputFn:U,dataURLOptions:j,inlineImages:P,recordCanvas:B,keepIframeSrcFn:z,newlyAddedElement:W,rootId:R});case J.TEXT_NODE:return c1(J,{doc:Z,needsMask:V,maskTextFn:K,rootId:R,cssCaptured:L});case J.CDATA_SECTION_NODE:return{type:v.CDATA,textContent:"",rootId:R};case J.COMMENT_NODE:return{type:v.Comment,textContent:A.textContent(J)||"",rootId:R};default:return!1}}function d1(J,$){if(!$.hasNode(J))return;let Z=$.getId(J);return Z===1?void 0:Z}function c1(J,$){let{needsMask:Z,maskTextFn:X,rootId:Y,cssCaptured:q}=$,V=A.parentNode(J),G=V&&V.tagName,Q="",K=G==="STYLE"?!0:void 0,U=G==="SCRIPT"?!0:void 0;if(U)Q="SCRIPT_PLACEHOLDER";else if(!q){if(Q=A.textContent(J),K&&Q)Q=IJ(Q,eJ($.doc))}if(!K&&!U&&Q&&Z)Q=X?X(Q,A.parentElement(J)):Q.replace(/[\S]/g,"*");return{type:v.Text,textContent:Q||"",rootId:Y}}function l1(J,$){let{doc:Z,blockClass:X,blockSelector:Y,inlineStylesheet:q,maskInputOptions:V={},maskInputFn:G,dataURLOptions:Q={},inlineImages:K,recordCanvas:U,keepIframeSrcFn:j,newlyAddedElement:P=!1,rootId:B}=$,z=h1(J,X,Y),W=k1(J),L={},R=J.attributes.length;for(let D=0;D<R;D++){let O=J.attributes[D];if(!T0(W,O.name,O.value))L[O.name]=C0(Z,W,JJ(O.name),O.value)}if(W==="link"&&q){let D=Array.from(Z.styleSheets).find((x)=>{return x.href===J.href}),O=null;if(D)O=iJ(D);if(O)delete L.rel,delete L.href,L._cssText=O}if(W==="style"&&J.sheet){let D=iJ(J.sheet);if(D){if(J.childNodes.length>1)D=S1(D,J);L._cssText=D}}if(["input","textarea","select"].includes(W)){let{value:D,checked:O}=J;if(L.type!=="radio"&&L.type!=="checkbox"&&L.type!=="submit"&&L.type!=="button"&&D)L.value=SJ({element:J,type:fJ(J),tagName:W,value:D,maskInputOptions:V,maskInputFn:G});else if(O)L.checked=O}if(W==="option")if(J.selected&&!V.select)L.selected=!0;else delete L.selected;if(W==="dialog"&&J.open)L.rr_open_mode=J.matches("dialog:modal")?"modal":"non-modal";if(W==="canvas"&&U){if(J.__context==="2d"){if(!N1(J))L.rr_dataURL=J.toDataURL(Q.type,Q.quality)}else if(!("__context"in J)){let D=J.toDataURL(Q.type,Q.quality),O=Z.createElement("canvas");O.width=J.width,O.height=J.height;let x=O.toDataURL(Q.type,Q.quality);if(D!==x)L.rr_dataURL=D}}if(W==="img"&&K){if(!qJ)qJ=Z.createElement("canvas"),K0=qJ.getContext("2d");let D=J,O=D.currentSrc||D.getAttribute("src")||"<unknown-src>",x=D.crossOrigin,S=()=>{D.removeEventListener("load",S);try{qJ.width=D.naturalWidth,qJ.height=D.naturalHeight,K0.drawImage(D,0,0),L.rr_dataURL=qJ.toDataURL(Q.type,Q.quality)}catch(y){if(D.crossOrigin!=="anonymous"){if(D.crossOrigin="anonymous",D.complete&&D.naturalWidth!==0)S();else D.addEventListener("load",S);return}else console.warn(`Cannot inline img src=${O}! Error: ${y}`)}if(D.crossOrigin==="anonymous")x?L.crossOrigin=x:D.removeAttribute("crossorigin")};if(D.complete&&D.naturalWidth!==0)S();else D.addEventListener("load",S)}if(["audio","video"].includes(W)){let D=L;D.rr_mediaState=J.paused?"paused":"played",D.rr_mediaCurrentTime=J.currentTime,D.rr_mediaPlaybackRate=J.playbackRate,D.rr_mediaMuted=J.muted,D.rr_mediaLoop=J.loop,D.rr_mediaVolume=J.volume}if(!P){if(J.scrollLeft)L.rr_scrollLeft=J.scrollLeft;if(J.scrollTop)L.rr_scrollTop=J.scrollTop}if(z){let{width:D,height:O}=J.getBoundingClientRect();L={class:L.class,rr_width:`${D}px`,rr_height:`${O}px`}}if(W==="iframe"&&!j(L.src)){if(!J.contentDocument)L.rr_src=L.src;delete L.src}let F;try{if(customElements.get(W))F=!0}catch(D){}return{type:v.Element,tagName:W,attributes:L,childNodes:[],isSVG:g1(J)||void 0,needBlock:z,rootId:B,isCustom:F}}function T(J){if(J===void 0||J===null)return"";else return J.toLowerCase()}function S0(J){if(J===!0||J==="all")return{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:J==="all",headMetaDescKeywords:J==="all",headTitleMutations:J==="all"};else if(J)return J;return{}}function i1(J,$){if($.comment&&J.type===v.Comment)return!0;else if(J.type===v.Element){if($.script&&(J.tagName==="script"||J.tagName==="link"&&(J.attributes.rel==="preload"&&J.attributes.as==="script"||J.attributes.rel==="modulepreload")||J.tagName==="link"&&J.attributes.rel==="prefetch"&&typeof J.attributes.href==="string"&&E0(J.attributes.href)==="js"))return!0;else if($.headFavicon&&(J.tagName==="link"&&J.attributes.rel==="shortcut icon"||J.tagName==="meta"&&(T(J.attributes.name).match(/^msapplication-tile(image|color)$/)||T(J.attributes.name)==="application-name"||T(J.attributes.rel)==="icon"||T(J.attributes.rel)==="apple-touch-icon"||T(J.attributes.rel)==="shortcut icon")))return!0;else if(J.tagName==="meta"){if($.headMetaDescKeywords&&T(J.attributes.name).match(/^description|keywords$/))return!0;else if($.headMetaSocial&&(T(J.attributes.property).match(/^(og|twitter|fb):/)||T(J.attributes.name).match(/^(og|twitter):/)||T(J.attributes.name)==="pinterest"))return!0;else if($.headMetaRobots&&(T(J.attributes.name)==="robots"||T(J.attributes.name)==="googlebot"||T(J.attributes.name)==="bingbot"))return!0;else if($.headMetaHttpEquiv&&J.attributes["http-equiv"]!==void 0)return!0;else if($.headMetaAuthorship&&(T(J.attributes.name)==="author"||T(J.attributes.name)==="generator"||T(J.attributes.name)==="framework"||T(J.attributes.name)==="publisher"||T(J.attributes.name)==="progid"||T(J.attributes.property).match(/^article:/)||T(J.attributes.property).match(/^product:/)))return!0;else if($.headMetaVerification&&(T(J.attributes.name)==="google-site-verification"||T(J.attributes.name)==="yandex-verification"||T(J.attributes.name)==="csrf-token"||T(J.attributes.name)==="p:domain_verify"||T(J.attributes.name)==="verify-v1"||T(J.attributes.name)==="verification"||T(J.attributes.name)==="shopify-checkout-api-token"))return!0}}return!1}function UJ(J,$){let{doc:Z,mirror:X,blockClass:Y,blockSelector:q,maskTextClass:V,maskTextSelector:G,skipChild:Q=!1,inlineStylesheet:K=!0,maskInputOptions:U={},maskTextFn:j,maskInputFn:P,slimDOMOptions:B,dataURLOptions:z={},inlineImages:W=!1,recordCanvas:L=!1,onSerialize:R,onIframeLoad:F,iframeLoadTimeout:D=5000,onStylesheetLoad:O,stylesheetLoadTimeout:x=5000,keepIframeSrcFn:S=()=>!1,newlyAddedElement:y=!1,cssCaptured:r=!1}=$,{needsMask:p}=$,{preserveWhiteSpace:l=!0}=$;if(!p)p=x0(J,V,G,p===void 0);let d=p1(J,{doc:Z,mirror:X,blockClass:Y,blockSelector:q,needsMask:p,inlineStylesheet:K,maskInputOptions:U,maskTextFn:j,maskInputFn:P,dataURLOptions:z,inlineImages:W,recordCanvas:L,keepIframeSrcFn:S,newlyAddedElement:y,cssCaptured:r});if(!d)return console.warn(J,"not serialized"),null;let s;if(X.hasNode(J))s=X.getId(J);else if(i1(d,B)||!l&&d.type===v.Text&&!d.textContent.replace(/^\s+|\s+$/gm,"").length)s=FJ;else s=w0();let E=Object.assign(d,{id:s});if(X.add(J,E),s===FJ)return null;if(R)R(J);let zJ=!Q;if(E.type===v.Element){zJ=zJ&&!E.needBlock,delete E.needBlock;let b=A.shadowRoot(J);if(b&&DJ(b))E.isShadowHost=!0}if((E.type===v.Document||E.type===v.Element)&&zJ){if(B.headWhitespace&&E.type===v.Element&&E.tagName==="head")l=!1;let b={doc:Z,mirror:X,blockClass:Y,blockSelector:q,needsMask:p,maskTextClass:V,maskTextSelector:G,skipChild:Q,inlineStylesheet:K,maskInputOptions:U,maskTextFn:j,maskInputFn:P,slimDOMOptions:B,dataURLOptions:z,inlineImages:W,recordCanvas:L,preserveWhiteSpace:l,onSerialize:R,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:O,stylesheetLoadTimeout:x,keepIframeSrcFn:S,cssCaptured:!1};if(E.type===v.Element&&E.tagName==="textarea"&&E.attributes.value!==void 0);else{if(E.type===v.Element&&E.attributes._cssText!==void 0&&typeof E.attributes._cssText==="string")b.cssCaptured=!0;for(let $J of Array.from(A.childNodes(J))){let o=UJ($J,b);if(o)E.childNodes.push(o)}}let c=null;if(N0(J)&&(c=A.shadowRoot(J)))for(let $J of Array.from(A.childNodes(c))){let o=UJ($J,b);if(o)DJ(c)&&(o.isShadow=!0),E.childNodes.push(o)}}let HJ=A.parentNode(J);if(HJ&&PJ(HJ)&&DJ(HJ))E.isShadow=!0;if(E.type===v.Element&&E.tagName==="iframe")u1(J,()=>{let b=J.contentDocument;if(b&&F){let c=UJ(b,{doc:b,mirror:X,blockClass:Y,blockSelector:q,needsMask:p,maskTextClass:V,maskTextSelector:G,skipChild:!1,inlineStylesheet:K,maskInputOptions:U,maskTextFn:j,maskInputFn:P,slimDOMOptions:B,dataURLOptions:z,inlineImages:W,recordCanvas:L,preserveWhiteSpace:l,onSerialize:R,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:O,stylesheetLoadTimeout:x,keepIframeSrcFn:S});if(c)F(J,c)}},D);if(E.type===v.Element&&E.tagName==="link"&&typeof E.attributes.rel==="string"&&(E.attributes.rel==="stylesheet"||E.attributes.rel==="preload"&&typeof E.attributes.href==="string"&&E0(E.attributes.href)==="css"))m1(J,()=>{if(O){let b=UJ(J,{doc:Z,mirror:X,blockClass:Y,blockSelector:q,needsMask:p,maskTextClass:V,maskTextSelector:G,skipChild:!1,inlineStylesheet:K,maskInputOptions:U,maskTextFn:j,maskInputFn:P,slimDOMOptions:B,dataURLOptions:z,inlineImages:W,recordCanvas:L,preserveWhiteSpace:l,onSerialize:R,onIframeLoad:F,iframeLoadTimeout:D,onStylesheetLoad:O,stylesheetLoadTimeout:x,keepIframeSrcFn:S});if(b)O(J,b)}},x);return E}function a1(J,$){let{mirror:Z=new tJ,blockClass:X="rr-block",blockSelector:Y=null,maskTextClass:q="rr-mask",maskTextSelector:V=null,inlineStylesheet:G=!0,inlineImages:Q=!1,recordCanvas:K=!1,maskAllInputs:U=!1,maskTextFn:j,maskInputFn:P,slimDOM:B=!1,dataURLOptions:z,preserveWhiteSpace:W,onSerialize:L,onIframeLoad:R,iframeLoadTimeout:F,onStylesheetLoad:D,stylesheetLoadTimeout:O,keepIframeSrcFn:x=()=>!1}=$,S=U===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:U===!1?{password:!0}:U,y=S0(B);return UJ(J,{doc:J,mirror:Z,blockClass:X,blockSelector:Y,maskTextClass:q,maskTextSelector:V,skipChild:!1,inlineStylesheet:G,maskInputOptions:S,maskTextFn:j,maskInputFn:P,slimDOMOptions:y,dataURLOptions:z,inlineImages:Q,recordCanvas:K,preserveWhiteSpace:W,onSerialize:L,onIframeLoad:R,iframeLoadTimeout:F,onStylesheetLoad:D,stylesheetLoadTimeout:O,keepIframeSrcFn:x,newlyAddedElement:!1})}class J0{constructor(...J){H(this,"parentElement",null),H(this,"parentNode",null),H(this,"ownerDocument"),H(this,"firstChild",null),H(this,"lastChild",null),H(this,"previousSibling",null),H(this,"nextSibling",null),H(this,"ELEMENT_NODE",1),H(this,"TEXT_NODE",3),H(this,"nodeType"),H(this,"nodeName"),H(this,"RRNodeType")}get childNodes(){let J=[],$=this.firstChild;while($)J.push($),$=$.nextSibling;return J}contains(J){if(!(J instanceof J0))return!1;else if(J.ownerDocument!==this.ownerDocument)return!1;else if(J===this)return!0;while(J.parentNode){if(J.parentNode===this)return!0;J=J.parentNode}return!1}appendChild(J){throw Error("RRDomException: Failed to execute 'appendChild' on 'RRNode': This RRNode type does not support this method.")}insertBefore(J,$){throw Error("RRDomException: Failed to execute 'insertBefore' on 'RRNode': This RRNode type does not support this method.")}removeChild(J){throw Error("RRDomException: Failed to execute 'removeChild' on 'RRNode': This RRNode type does not support this method.")}toString(){return"RRNode"}}function g(J,$,Z=document){let X={capture:!0,passive:!0};return Z.addEventListener(J,$,X),()=>Z.removeEventListener(J,$,X)}var VJ=`Please stop import mirror directly. Instead of that,\r
2
+ now you can use replayer.getMirror() to access the mirror instance of a replayer,\r
3
+ or you can use record.mirror to access the mirror instance during recording.`,U0={map:{},getId(){return console.error(VJ),-1},getNode(){return console.error(VJ),null},removeNodeFromMap(){console.error(VJ)},has(){return console.error(VJ),!1},reset(){console.error(VJ)}};if(typeof window<"u"&&window.Proxy&&window.Reflect)U0=new Proxy(U0,{get(J,$,Z){if($==="map")console.error(VJ);return Reflect.get(J,$,Z)}});function RJ(J,$,Z={}){let X=null,Y=0;return function(...q){let V=Date.now();if(!Y&&Z.leading===!1)Y=V;let G=$-(V-Y),Q=this;if(G<=0||G>$){if(X)clearTimeout(X),X=null;Y=V,J.apply(Q,q)}else if(!X&&Z.trailing!==!1)X=setTimeout(()=>{Y=Z.leading===!1?0:Date.now(),X=null,J.apply(Q,q)},G)}}function yJ(J,$,Z,X,Y=window){let q=Y.Object.getOwnPropertyDescriptor(J,$);return Y.Object.defineProperty(J,$,X?Z:{set(V){if(setTimeout(()=>{Z.set.call(this,V)},0),q&&q.set)q.set.call(this,V)}}),()=>yJ(J,$,q||{},!0)}function f0(J){var $,Z,X,Y;let q=J.document;return{left:q.scrollingElement?q.scrollingElement.scrollLeft:J.pageXOffset!==void 0?J.pageXOffset:q.documentElement.scrollLeft||(q==null?void 0:q.body)&&(($=A.parentElement(q.body))==null?void 0:$.scrollLeft)||((Z=q==null?void 0:q.body)==null?void 0:Z.scrollLeft)||0,top:q.scrollingElement?q.scrollingElement.scrollTop:J.pageYOffset!==void 0?J.pageYOffset:(q==null?void 0:q.documentElement.scrollTop)||(q==null?void 0:q.body)&&((X=A.parentElement(q.body))==null?void 0:X.scrollTop)||((Y=q==null?void 0:q.body)==null?void 0:Y.scrollTop)||0}}function I0(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function k0(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function v0(J){if(!J)return null;return J.nodeType===J.ELEMENT_NODE?J:A.parentElement(J)}function h(J,$,Z,X){if(!J)return!1;let Y=v0(J);if(!Y)return!1;try{if(typeof $==="string"){if(Y.classList.contains($))return!0;if(X&&Y.closest("."+$)!==null)return!0}else if(kJ(Y,$,X))return!0}catch(q){}if(Z){if(Y.matches(Z))return!0;if(X&&Y.closest(Z)!==null)return!0}return!1}function r1(J,$){return $.getId(J)!==-1}function cJ(J,$,Z){if(J.tagName==="TITLE"&&Z.headTitleMutations)return!0;return $.getId(J)===FJ}function b0(J,$){if(PJ(J))return!1;let Z=$.getId(J);if(!$.has(Z))return!0;let X=A.parentNode(J);if(X&&X.nodeType===J.DOCUMENT_NODE)return!1;if(!X)return!0;return b0(X,$)}function aJ(J){return Boolean(J.changedTouches)}function s1(J=window){if("NodeList"in J&&!J.NodeList.prototype.forEach)J.NodeList.prototype.forEach=Array.prototype.forEach;if("DOMTokenList"in J&&!J.DOMTokenList.prototype.forEach)J.DOMTokenList.prototype.forEach=Array.prototype.forEach}function y0(J,$){return Boolean(J.nodeName==="IFRAME"&&$.getMeta(J))}function g0(J,$){return Boolean(J.nodeName==="LINK"&&J.nodeType===J.ELEMENT_NODE&&J.getAttribute&&J.getAttribute("rel")==="stylesheet"&&$.getMeta(J))}function rJ(J){if(!J)return!1;if(J instanceof J0&&"shadowRoot"in J)return Boolean(J.shadowRoot);return Boolean(A.shadowRoot(J))}class h0{constructor(){H(this,"id",1),H(this,"styleIDMap",new WeakMap),H(this,"idStyleMap",new Map)}getId(J){return this.styleIDMap.get(J)??-1}has(J){return this.styleIDMap.has(J)}add(J,$){if(this.has(J))return this.getId(J);let Z;if($===void 0)Z=this.id++;else Z=$;return this.styleIDMap.set(J,Z),this.idStyleMap.set(Z,J),Z}getStyle(J){return this.idStyleMap.get(J)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}function u0(J){var $;let Z=null;if("getRootNode"in J&&(($=A.getRootNode(J))==null?void 0:$.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&A.host(A.getRootNode(J)))Z=A.host(A.getRootNode(J));return Z}function o1(J){let $=J,Z;while(Z=u0($))$=Z;return $}function n1(J){let $=A.ownerDocument(J);if(!$)return!1;let Z=o1(J);return A.contains($,Z)}function m0(J){let $=A.ownerDocument(J);if(!$)return!1;return A.contains($,J)||n1(J)}function B0(J){return"__ln"in J}class p0{constructor(){H(this,"length",0),H(this,"head",null),H(this,"tail",null)}get(J){if(J>=this.length)throw Error("Position outside of list range");let $=this.head;for(let Z=0;Z<J;Z++)$=($==null?void 0:$.next)||null;return $}addNode(J){let $={value:J,previous:null,next:null};if(J.__ln=$,J.previousSibling&&B0(J.previousSibling)){let Z=J.previousSibling.__ln.next;if($.next=Z,$.previous=J.previousSibling.__ln,J.previousSibling.__ln.next=$,Z)Z.previous=$}else if(J.nextSibling&&B0(J.nextSibling)&&J.nextSibling.__ln.previous){let Z=J.nextSibling.__ln.previous;if($.previous=Z,$.next=J.nextSibling.__ln,J.nextSibling.__ln.previous=$,Z)Z.next=$}else{if(this.head)this.head.previous=$;$.next=this.head,this.head=$}if($.next===null)this.tail=$;this.length++}removeNode(J){let $=J.__ln;if(!this.head)return;if(!$.previous)if(this.head=$.next,this.head)this.head.previous=null;else this.tail=null;else if($.previous.next=$.next,$.next)$.next.previous=$.previous;else this.tail=$.previous;if(J.__ln)delete J.__ln;this.length--}}var j0=(J,$)=>`${J}@${$}`;class d0{constructor(){H(this,"frozen",!1),H(this,"locked",!1),H(this,"texts",[]),H(this,"attributes",[]),H(this,"attributeMap",new WeakMap),H(this,"removes",[]),H(this,"mapRemoves",[]),H(this,"movedMap",{}),H(this,"addedSet",new Set),H(this,"movedSet",new Set),H(this,"droppedSet",new Set),H(this,"removesSubTreeCache",new Set),H(this,"mutationCb"),H(this,"blockClass"),H(this,"blockSelector"),H(this,"maskTextClass"),H(this,"maskTextSelector"),H(this,"inlineStylesheet"),H(this,"maskInputOptions"),H(this,"maskTextFn"),H(this,"maskInputFn"),H(this,"keepIframeSrcFn"),H(this,"recordCanvas"),H(this,"inlineImages"),H(this,"slimDOMOptions"),H(this,"dataURLOptions"),H(this,"doc"),H(this,"mirror"),H(this,"iframeManager"),H(this,"stylesheetManager"),H(this,"shadowDomManager"),H(this,"canvasManager"),H(this,"processedNodeManager"),H(this,"unattachedDoc"),H(this,"processMutations",(J)=>{J.forEach(this.processMutation),this.emit()}),H(this,"emit",()=>{if(this.frozen||this.locked)return;let J=[],$=new Set,Z=new p0,X=(G)=>{let Q=G,K=FJ;while(K===FJ)Q=Q&&Q.nextSibling,K=Q&&this.mirror.getId(Q);return K},Y=(G)=>{let Q=A.parentNode(G);if(!Q||!m0(G))return;let K=!1;if(G.nodeType===Node.TEXT_NODE){let B=Q.tagName;if(B==="TEXTAREA")return;else if(B==="STYLE"&&this.addedSet.has(Q))K=!0}let U=PJ(Q)?this.mirror.getId(u0(G)):this.mirror.getId(Q),j=X(G);if(U===-1||j===-1)return Z.addNode(G);let P=UJ(G,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:(B)=>{if(y0(B,this.mirror))this.iframeManager.addIframe(B);if(g0(B,this.mirror))this.stylesheetManager.trackLinkElement(B);if(rJ(G))this.shadowDomManager.addShadowRoot(A.shadowRoot(G),this.doc)},onIframeLoad:(B,z)=>{this.iframeManager.attachIframe(B,z),this.shadowDomManager.observeAttachShadow(B)},onStylesheetLoad:(B,z)=>{this.stylesheetManager.attachLinkElement(B,z)},cssCaptured:K});if(P)J.push({parentId:U,nextId:j,node:P}),$.add(P.id)};while(this.mapRemoves.length)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(let G of this.movedSet){if(z0(this.removesSubTreeCache,G,this.mirror)&&!this.movedSet.has(A.parentNode(G)))continue;Y(G)}for(let G of this.addedSet)if(!H0(this.droppedSet,G)&&!z0(this.removesSubTreeCache,G,this.mirror))Y(G);else if(H0(this.movedSet,G))Y(G);else this.droppedSet.add(G);let q=null;while(Z.length){let G=null;if(q){let Q=this.mirror.getId(A.parentNode(q.value)),K=X(q.value);if(Q!==-1&&K!==-1)G=q}if(!G){let Q=Z.tail;while(Q){let K=Q;if(Q=Q.previous,K){let U=this.mirror.getId(A.parentNode(K.value));if(X(K.value)===-1)continue;else if(U!==-1){G=K;break}else{let P=K.value,B=A.parentNode(P);if(B&&B.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let z=A.host(B);if(this.mirror.getId(z)!==-1){G=K;break}}}}}}if(!G){while(Z.head)Z.removeNode(Z.head.value);break}q=G.previous,Z.removeNode(G.value),Y(G.value)}let V={texts:this.texts.map((G)=>{let Q=G.node,K=A.parentNode(Q);if(K&&K.tagName==="TEXTAREA")this.genTextAreaValueMutation(K);return{id:this.mirror.getId(Q),value:G.value}}).filter((G)=>!$.has(G.id)).filter((G)=>this.mirror.has(G.id)),attributes:this.attributes.map((G)=>{let{attributes:Q}=G;if(typeof Q.style==="string"){let K=JSON.stringify(G.styleDiff),U=JSON.stringify(G._unchangedStyles);if(K.length<Q.style.length){if((K+U).split("var(").length===Q.style.split("var(").length)Q.style=G.styleDiff}}return{id:this.mirror.getId(G.node),attributes:Q}}).filter((G)=>!$.has(G.id)).filter((G)=>this.mirror.has(G.id)),removes:this.removes,adds:J};if(!V.texts.length&&!V.attributes.length&&!V.removes.length&&!V.adds.length)return;this.texts=[],this.attributes=[],this.attributeMap=new WeakMap,this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.removesSubTreeCache=new Set,this.movedMap={},this.mutationCb(V)}),H(this,"genTextAreaValueMutation",(J)=>{let $=this.attributeMap.get(J);if(!$)$={node:J,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push($),this.attributeMap.set(J,$);let Z=Array.from(A.childNodes(J),(X)=>A.textContent(X)||"").join("");$.attributes.value=SJ({element:J,maskInputOptions:this.maskInputOptions,tagName:J.tagName,type:fJ(J),value:Z,maskInputFn:this.maskInputFn})}),H(this,"processMutation",(J)=>{if(cJ(J.target,this.mirror,this.slimDOMOptions))return;switch(J.type){case"characterData":{let $=A.textContent(J.target);if(!h(J.target,this.blockClass,this.blockSelector,!1)&&$!==J.oldValue)this.texts.push({value:x0(J.target,this.maskTextClass,this.maskTextSelector,!0)&&$?this.maskTextFn?this.maskTextFn($,v0(J.target)):$.replace(/[\S]/g,"*"):$,node:J.target});break}case"attributes":{let $=J.target,Z=JJ($.tagName),X=J.attributeName,Y=J.target.getAttribute(X);if(X==="value"){let V=fJ($);Y=SJ({element:$,maskInputOptions:this.maskInputOptions,tagName:$.tagName,type:V,value:Y,maskInputFn:this.maskInputFn})}if(h(J.target,this.blockClass,this.blockSelector,!1)||Y===J.oldValue)return;let q=this.attributeMap.get(J.target);if(Z==="iframe"&&X==="src"&&!this.keepIframeSrcFn(Y))if(!$.contentDocument)X="rr_src";else return;if(!q)q={node:J.target,attributes:{},styleDiff:{},_unchangedStyles:{}},this.attributes.push(q),this.attributeMap.set(J.target,q);if(X==="type"&&Z==="input"&&(J.oldValue||"").toLowerCase()==="password")$.setAttribute("data-rr-is-password","true");if(!T0(Z,X)){if(q.attributes[X]=C0(this.doc,Z,JJ(X),Y),X==="style"){if(!this.unattachedDoc)try{this.unattachedDoc=document.implementation.createHTMLDocument()}catch(G){this.unattachedDoc=this.doc}let V=this.unattachedDoc.createElement("span");if(J.oldValue)V.setAttribute("style",J.oldValue);for(let G of Array.from($.style)){let Q=$.style.getPropertyValue(G),K=$.style.getPropertyPriority(G);if(Q!==V.style.getPropertyValue(G)||K!==V.style.getPropertyPriority(G))if(K==="")q.styleDiff[G]=Q;else q.styleDiff[G]=[Q,K];else q._unchangedStyles[G]=[Q,K]}for(let G of Array.from(V.style))if($.style.getPropertyValue(G)==="")q.styleDiff[G]=!1}else if(X==="open"&&$.tagName==="DIALOG")if($.matches("dialog:modal"))q.attributes.rr_open_mode="modal";else q.attributes.rr_open_mode="non-modal"}break}case"childList":{if(h(J.target,this.blockClass,this.blockSelector,!0))return;if(J.target.tagName==="TEXTAREA"){this.genTextAreaValueMutation(J.target);return}J.addedNodes.forEach(($)=>this.genAdds($,J.target)),J.removedNodes.forEach(($)=>{let Z=this.mirror.getId($),X=PJ(J.target)?this.mirror.getId(A.host(J.target)):this.mirror.getId(J.target);if(h(J.target,this.blockClass,this.blockSelector,!1)||cJ($,this.mirror,this.slimDOMOptions)||!r1($,this.mirror))return;if(this.addedSet.has($))sJ(this.addedSet,$),this.droppedSet.add($);else if(this.addedSet.has(J.target)&&Z===-1);else if(b0(J.target,this.mirror));else if(this.movedSet.has($)&&this.movedMap[j0(Z,X)])sJ(this.movedSet,$);else this.removes.push({parentId:X,id:Z,isShadow:PJ(J.target)&&DJ(J.target)?!0:void 0}),t1($,this.removesSubTreeCache);this.mapRemoves.push($)});break}}}),H(this,"genAdds",(J,$)=>{if(this.processedNodeManager.inOtherBuffer(J,this))return;if(this.addedSet.has(J)||this.movedSet.has(J))return;if(this.mirror.hasNode(J)){if(cJ(J,this.mirror,this.slimDOMOptions))return;this.movedSet.add(J);let Z=null;if($&&this.mirror.hasNode($))Z=this.mirror.getId($);if(Z&&Z!==-1)this.movedMap[j0(this.mirror.getId(J),Z)]=!0}else this.addedSet.add(J),this.droppedSet.delete(J);if(!h(J,this.blockClass,this.blockSelector,!1)){if(A.childNodes(J).forEach((Z)=>this.genAdds(Z)),rJ(J))A.childNodes(A.shadowRoot(J)).forEach((Z)=>{this.processedNodeManager.add(Z,this),this.genAdds(Z,J)})}})}init(J){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager","processedNodeManager"].forEach(($)=>{this[$]=J[$]})}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 sJ(J,$){J.delete($),A.childNodes($).forEach((Z)=>sJ(J,Z))}function t1(J,$){let Z=[J];while(Z.length){let X=Z.pop();if($.has(X))continue;$.add(X),A.childNodes(X).forEach((Y)=>Z.push(Y))}return}function z0(J,$,Z){if(J.size===0)return!1;return e1(J,$)}function e1(J,$,Z){let X=A.parentNode($);if(!X)return!1;return J.has(X)}function H0(J,$){if(J.size===0)return!1;return c0(J,$)}function c0(J,$){let Z=A.parentNode($);if(!Z)return!1;if(J.has(Z))return!0;return c0(J,Z)}var LJ;function J6(J){LJ=J}function $6(){LJ=void 0}var N=(J)=>{if(!LJ)return J;return(...Z)=>{try{return J(...Z)}catch(X){if(LJ&&LJ(X)===!0)return;throw X}}},YJ=[];function OJ(J){try{if("composedPath"in J){let $=J.composedPath();if($.length)return $[0]}else if("path"in J&&J.path.length)return J.path[0]}catch{}return J&&J.target}function l0(J,$){let Z=new d0;YJ.push(Z),Z.init(J);let[X,Y]=M0(),q=new X(N(Z.processMutations.bind(Z)));return q.observe($,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),[q,Y]}function Z6({mousemoveCb:J,sampling:$,doc:Z,mirror:X}){if($.mousemove===!1)return()=>{};let Y=typeof $.mousemove==="number"?$.mousemove:50,q=typeof $.mousemoveCallback==="number"?$.mousemoveCallback:500,V=[],G,Q=RJ(N((j)=>{let P=Date.now()-G;J(V.map((B)=>{return B.timeOffset-=P,B}),j),V=[],G=null}),q),K=N(RJ(N((j)=>{let P=OJ(j),{clientX:B,clientY:z}=aJ(j)?j.changedTouches[0]:j;if(!G)G=AJ();V.push({x:B,y:z,id:X.getId(P),timeOffset:AJ()-G}),Q(typeof DragEvent<"u"&&j instanceof DragEvent?M.Drag:j instanceof MouseEvent?M.MouseMove:M.TouchMove)}),Y,{trailing:!1})),U=[g("mousemove",K,Z),g("touchmove",K,Z),g("drag",K,Z)];return N(()=>{U.forEach((j)=>j())})}function X6({mouseInteractionCb:J,doc:$,mirror:Z,blockClass:X,blockSelector:Y,sampling:q}){if(q.mouseInteraction===!1)return()=>{};let V=q.mouseInteraction===!0||q.mouseInteraction===void 0?{}:q.mouseInteraction,G=[],Q=null,K=(U)=>{return(j)=>{let P=OJ(j);if(h(P,X,Y,!0))return;let B=null,z=U;if("pointerType"in j){switch(j.pointerType){case"mouse":B=n.Mouse;break;case"touch":B=n.Touch;break;case"pen":B=n.Pen;break}if(B===n.Touch){if(u[U]===u.MouseDown)z="TouchStart";else if(u[U]===u.MouseUp)z="TouchEnd"}else if(B===n.Pen);}else if(aJ(j))B=n.Touch;if(B!==null){if(Q=B,z.startsWith("Touch")&&B===n.Touch||z.startsWith("Mouse")&&B===n.Mouse)B=null}else if(u[U]===u.Click)B=Q,Q=null;let W=aJ(j)?j.changedTouches[0]:j;if(!W)return;let L=Z.getId(P),{clientX:R,clientY:F}=W;N(J)({type:u[z],id:L,x:R,y:F,...B!==null&&{pointerType:B}})}};return Object.keys(u).filter((U)=>Number.isNaN(Number(U))&&!U.endsWith("_Departed")&&V[U]!==!1).forEach((U)=>{let j=JJ(U),P=K(U);if(window.PointerEvent)switch(u[U]){case u.MouseDown:case u.MouseUp:j=j.replace("mouse","pointer");break;case u.TouchStart:case u.TouchEnd:return}G.push(g(j,P,$))}),N(()=>{G.forEach((U)=>U())})}function i0({scrollCb:J,doc:$,mirror:Z,blockClass:X,blockSelector:Y,sampling:q}){let V=N(RJ(N((G)=>{let Q=OJ(G);if(!Q||h(Q,X,Y,!0))return;let K=Z.getId(Q);if(Q===$&&$.defaultView){let U=f0($.defaultView);J({id:K,x:U.left,y:U.top})}else J({id:K,x:Q.scrollLeft,y:Q.scrollTop})}),q.scroll||100));return g("scroll",V,$)}function Y6({viewportResizeCb:J},{win:$}){let Z=-1,X=-1,Y=N(RJ(N(()=>{let q=I0(),V=k0();if(Z!==q||X!==V)J({width:Number(V),height:Number(q)}),Z=q,X=V}),200));return g("resize",Y,$)}var Q6=["INPUT","TEXTAREA","SELECT"],P0=new WeakMap;function q6({inputCb:J,doc:$,mirror:Z,blockClass:X,blockSelector:Y,ignoreClass:q,ignoreSelector:V,maskInputOptions:G,maskInputFn:Q,sampling:K,userTriggeredOnInput:U}){function j(F){let D=OJ(F),O=F.isTrusted,x=D&&D.tagName;if(D&&x==="OPTION")D=A.parentElement(D);if(!D||!x||Q6.indexOf(x)<0||h(D,X,Y,!0))return;if(D.classList.contains(q)||V&&D.matches(V))return;let S=D.value,y=!1,r=fJ(D)||"";if(r==="radio"||r==="checkbox")y=D.checked;else if(G[x.toLowerCase()]||G[r])S=SJ({element:D,maskInputOptions:G,tagName:x,type:r,value:S,maskInputFn:Q});P(D,U?{text:S,isChecked:y,userTriggered:O}:{text:S,isChecked:y});let p=D.name;if(r==="radio"&&p&&y)$.querySelectorAll(`input[type="radio"][name="${p}"]`).forEach((l)=>{if(l!==D){let d=l.value;P(l,U?{text:d,isChecked:!y,userTriggered:!1}:{text:d,isChecked:!y})}})}function P(F,D){let O=P0.get(F);if(!O||O.text!==D.text||O.isChecked!==D.isChecked){P0.set(F,D);let x=Z.getId(F);N(J)({...D,id:x})}}let z=(K.input==="last"?["change"]:["input","change"]).map((F)=>g(F,N(j),$)),W=$.defaultView;if(!W)return()=>{z.forEach((F)=>F())};let L=W.Object.getOwnPropertyDescriptor(W.HTMLInputElement.prototype,"value"),R=[[W.HTMLInputElement.prototype,"value"],[W.HTMLInputElement.prototype,"checked"],[W.HTMLSelectElement.prototype,"value"],[W.HTMLTextAreaElement.prototype,"value"],[W.HTMLSelectElement.prototype,"selectedIndex"],[W.HTMLOptionElement.prototype,"selected"]];if(L&&L.set)z.push(...R.map((F)=>yJ(F[0],F[1],{set(){N(j)({target:this,isTrusted:!1})}},!1,W)));return N(()=>{z.forEach((F)=>F())})}function vJ(J){let $=[];function Z(X,Y){if(wJ("CSSGroupingRule")&&X.parentRule instanceof CSSGroupingRule||wJ("CSSMediaRule")&&X.parentRule instanceof CSSMediaRule||wJ("CSSSupportsRule")&&X.parentRule instanceof CSSSupportsRule||wJ("CSSConditionRule")&&X.parentRule instanceof CSSConditionRule){let V=Array.from(X.parentRule.cssRules).indexOf(X);return Y.unshift(V),Z(X.parentRule,Y)}else if(X.parentStyleSheet){let V=Array.from(X.parentStyleSheet.cssRules).indexOf(X);Y.unshift(V)}return Y}return Z(J,$)}function e(J,$,Z){let X,Y;if(!J)return{};if(J.ownerNode)X=$.getId(J.ownerNode);else Y=Z.getId(J);return{styleId:Y,id:X}}function G6({styleSheetRuleCb:J,mirror:$,stylesheetManager:Z},{win:X}){if(!X.CSSStyleSheet||!X.CSSStyleSheet.prototype)return()=>{};let Y=X.CSSStyleSheet.prototype.insertRule;X.CSSStyleSheet.prototype.insertRule=new Proxy(Y,{apply:N((U,j,P)=>{let[B,z]=P,{id:W,styleId:L}=e(j,$,Z.styleMirror);if(W&&W!==-1||L&&L!==-1)J({id:W,styleId:L,adds:[{rule:B,index:z}]});return U.apply(j,P)})}),X.CSSStyleSheet.prototype.addRule=function(U,j,P=this.cssRules.length){let B=`${U} { ${j} }`;return X.CSSStyleSheet.prototype.insertRule.apply(this,[B,P])};let q=X.CSSStyleSheet.prototype.deleteRule;X.CSSStyleSheet.prototype.deleteRule=new Proxy(q,{apply:N((U,j,P)=>{let[B]=P,{id:z,styleId:W}=e(j,$,Z.styleMirror);if(z&&z!==-1||W&&W!==-1)J({id:z,styleId:W,removes:[{index:B}]});return U.apply(j,P)})}),X.CSSStyleSheet.prototype.removeRule=function(U){return X.CSSStyleSheet.prototype.deleteRule.apply(this,[U])};let V;if(X.CSSStyleSheet.prototype.replace)V=X.CSSStyleSheet.prototype.replace,X.CSSStyleSheet.prototype.replace=new Proxy(V,{apply:N((U,j,P)=>{let[B]=P,{id:z,styleId:W}=e(j,$,Z.styleMirror);if(z&&z!==-1||W&&W!==-1)J({id:z,styleId:W,replace:B});return U.apply(j,P)})});let G;if(X.CSSStyleSheet.prototype.replaceSync)G=X.CSSStyleSheet.prototype.replaceSync,X.CSSStyleSheet.prototype.replaceSync=new Proxy(G,{apply:N((U,j,P)=>{let[B]=P,{id:z,styleId:W}=e(j,$,Z.styleMirror);if(z&&z!==-1||W&&W!==-1)J({id:z,styleId:W,replaceSync:B});return U.apply(j,P)})});let Q={};if(CJ("CSSGroupingRule"))Q.CSSGroupingRule=X.CSSGroupingRule;else{if(CJ("CSSMediaRule"))Q.CSSMediaRule=X.CSSMediaRule;if(CJ("CSSConditionRule"))Q.CSSConditionRule=X.CSSConditionRule;if(CJ("CSSSupportsRule"))Q.CSSSupportsRule=X.CSSSupportsRule}let K={};return Object.entries(Q).forEach(([U,j])=>{K[U]={insertRule:j.prototype.insertRule,deleteRule:j.prototype.deleteRule},j.prototype.insertRule=new Proxy(K[U].insertRule,{apply:N((P,B,z)=>{let[W,L]=z,{id:R,styleId:F}=e(B.parentStyleSheet,$,Z.styleMirror);if(R&&R!==-1||F&&F!==-1)J({id:R,styleId:F,adds:[{rule:W,index:[...vJ(B),L||0]}]});return P.apply(B,z)})}),j.prototype.deleteRule=new Proxy(K[U].deleteRule,{apply:N((P,B,z)=>{let[W]=z,{id:L,styleId:R}=e(B.parentStyleSheet,$,Z.styleMirror);if(L&&L!==-1||R&&R!==-1)J({id:L,styleId:R,removes:[{index:[...vJ(B),W]}]});return P.apply(B,z)})})}),N(()=>{X.CSSStyleSheet.prototype.insertRule=Y,X.CSSStyleSheet.prototype.deleteRule=q,V&&(X.CSSStyleSheet.prototype.replace=V),G&&(X.CSSStyleSheet.prototype.replaceSync=G),Object.entries(Q).forEach(([U,j])=>{j.prototype.insertRule=K[U].insertRule,j.prototype.deleteRule=K[U].deleteRule})})}function a0({mirror:J,stylesheetManager:$},Z){var X,Y,q;let V=null;if(Z.nodeName==="#document")V=J.getId(Z);else V=J.getId(A.host(Z));let G=Z.nodeName==="#document"?(X=Z.defaultView)==null?void 0:X.Document:(q=(Y=Z.ownerDocument)==null?void 0:Y.defaultView)==null?void 0:q.ShadowRoot,Q=(G==null?void 0:G.prototype)?Object.getOwnPropertyDescriptor(G==null?void 0:G.prototype,"adoptedStyleSheets"):void 0;if(V===null||V===-1||!G||!Q)return()=>{};return Object.defineProperty(Z,"adoptedStyleSheets",{configurable:Q.configurable,enumerable:Q.enumerable,get(){var K;return(K=Q.get)==null?void 0:K.call(this)},set(K){var U;let j=(U=Q.set)==null?void 0:U.call(this,K);if(V!==null&&V!==-1)try{$.adoptStyleSheets(K,V)}catch(P){}return j}}),N(()=>{Object.defineProperty(Z,"adoptedStyleSheets",{configurable:Q.configurable,enumerable:Q.enumerable,get:Q.get,set:Q.set})})}function V6({styleDeclarationCb:J,mirror:$,ignoreCSSAttributes:Z,stylesheetManager:X},{win:Y}){let q=Y.CSSStyleDeclaration.prototype.setProperty;Y.CSSStyleDeclaration.prototype.setProperty=new Proxy(q,{apply:N((G,Q,K)=>{var U;let[j,P,B]=K;if(Z.has(j))return q.apply(Q,[j,P,B]);let{id:z,styleId:W}=e((U=Q.parentRule)==null?void 0:U.parentStyleSheet,$,X.styleMirror);if(z&&z!==-1||W&&W!==-1)J({id:z,styleId:W,set:{property:j,value:P,priority:B},index:vJ(Q.parentRule)});return G.apply(Q,K)})});let V=Y.CSSStyleDeclaration.prototype.removeProperty;return Y.CSSStyleDeclaration.prototype.removeProperty=new Proxy(V,{apply:N((G,Q,K)=>{var U;let[j]=K;if(Z.has(j))return V.apply(Q,[j]);let{id:P,styleId:B}=e((U=Q.parentRule)==null?void 0:U.parentStyleSheet,$,X.styleMirror);if(P&&P!==-1||B&&B!==-1)J({id:P,styleId:B,remove:{property:j},index:vJ(Q.parentRule)});return G.apply(Q,K)})}),N(()=>{Y.CSSStyleDeclaration.prototype.setProperty=q,Y.CSSStyleDeclaration.prototype.removeProperty=V})}function K6({mediaInteractionCb:J,blockClass:$,blockSelector:Z,mirror:X,sampling:Y,doc:q}){let V=N((Q)=>RJ(N((K)=>{let U=OJ(K);if(!U||h(U,$,Z,!0))return;let{currentTime:j,volume:P,muted:B,playbackRate:z,loop:W}=U;J({type:Q,id:X.getId(U),currentTime:j,volume:P,muted:B,playbackRate:z,loop:W})}),Y.media||500)),G=[g("play",V(GJ.Play),q),g("pause",V(GJ.Pause),q),g("seeked",V(GJ.Seeked),q),g("volumechange",V(GJ.VolumeChange),q),g("ratechange",V(GJ.RateChange),q)];return N(()=>{G.forEach((Q)=>Q())})}function W6({fontCb:J,doc:$}){let Z=$.defaultView;if(!Z)return()=>{};let X=[],Y=new WeakMap,q=Z.FontFace;Z.FontFace=function(Q,K,U){let j=new q(Q,K,U);return Y.set(j,{family:Q,buffer:typeof K!=="string",descriptors:U,fontSource:typeof K==="string"?K:JSON.stringify(Array.from(new Uint8Array(K)))}),j};let V=QJ($.fonts,"add",function(G){return function(Q){return setTimeout(N(()=>{let K=Y.get(Q);if(K)J(K),Y.delete(Q)}),0),G.apply(this,[Q])}});return X.push(()=>{Z.FontFace=q}),X.push(V),N(()=>{X.forEach((G)=>G())})}function U6(J){let{doc:$,mirror:Z,blockClass:X,blockSelector:Y,selectionCb:q}=J,V=!0,G=N(()=>{let Q=$.getSelection();if(!Q||V&&(Q==null?void 0:Q.isCollapsed))return;V=Q.isCollapsed||!1;let K=[],U=Q.rangeCount||0;for(let j=0;j<U;j++){let P=Q.getRangeAt(j),{startContainer:B,startOffset:z,endContainer:W,endOffset:L}=P;if(h(B,X,Y,!0)||h(W,X,Y,!0))continue;K.push({start:Z.getId(B),startOffset:z,end:Z.getId(W),endOffset:L})}q({ranges:K})});return G(),g("selectionchange",G)}function B6({doc:J,customElementCb:$}){let Z=J.defaultView;if(!Z||!Z.customElements)return()=>{};return QJ(Z.customElements,"define",function(Y){return function(q,V,G){try{$({define:{name:q}})}catch(Q){console.warn(`Custom element callback failed for ${q}`)}return Y.apply(this,[q,V,G])}})}function j6(J,$){let{mutationCb:Z,mousemoveCb:X,mouseInteractionCb:Y,scrollCb:q,viewportResizeCb:V,inputCb:G,mediaInteractionCb:Q,styleSheetRuleCb:K,styleDeclarationCb:U,canvasMutationCb:j,fontCb:P,selectionCb:B,customElementCb:z}=J;J.mutationCb=(...W)=>{if($.mutation)$.mutation(...W);Z(...W)},J.mousemoveCb=(...W)=>{if($.mousemove)$.mousemove(...W);X(...W)},J.mouseInteractionCb=(...W)=>{if($.mouseInteraction)$.mouseInteraction(...W);Y(...W)},J.scrollCb=(...W)=>{if($.scroll)$.scroll(...W);q(...W)},J.viewportResizeCb=(...W)=>{if($.viewportResize)$.viewportResize(...W);V(...W)},J.inputCb=(...W)=>{if($.input)$.input(...W);G(...W)},J.mediaInteractionCb=(...W)=>{if($.mediaInteaction)$.mediaInteaction(...W);Q(...W)},J.styleSheetRuleCb=(...W)=>{if($.styleSheetRule)$.styleSheetRule(...W);K(...W)},J.styleDeclarationCb=(...W)=>{if($.styleDeclaration)$.styleDeclaration(...W);U(...W)},J.canvasMutationCb=(...W)=>{if($.canvasMutation)$.canvasMutation(...W);j(...W)},J.fontCb=(...W)=>{if($.font)$.font(...W);P(...W)},J.selectionCb=(...W)=>{if($.selection)$.selection(...W);B(...W)},J.customElementCb=(...W)=>{if($.customElement)$.customElement(...W);z(...W)}}function z6(J,$={}){let Z=J.doc.defaultView;if(!Z)return()=>{};j6(J,$);let X,Y=()=>{};if(J.recordDOM)[X,Y]=l0(J,J.doc);let q=Z6(J),V=X6(J),G=i0(J),Q=Y6(J,{win:Z}),K=q6(J),U=K6(J),j=()=>{},P=()=>{},B=()=>{},z=()=>{};if(J.recordDOM){if(j=G6(J,{win:Z}),P=a0(J,J.doc),B=V6(J,{win:Z}),J.collectFonts)z=W6(J)}let W=U6(J),L=B6(J),R=[];for(let F of J.plugins)R.push(F.observer(F.callback,Z,F.options));return N(()=>{YJ.forEach((F)=>F.reset()),X==null||X.disconnect(),Y(),q(),V(),G(),Q(),K(),U(),j(),P(),B(),z(),W(),L(),R.forEach((F)=>F())})}function wJ(J){return typeof window[J]<"u"}function CJ(J){return Boolean(typeof window[J]<"u"&&window[J].prototype&&"insertRule"in window[J].prototype&&"deleteRule"in window[J].prototype)}class oJ{constructor(J){H(this,"iframeIdToRemoteIdMap",new WeakMap),H(this,"iframeRemoteIdToIdMap",new WeakMap),this.generateIdFn=J}getId(J,$,Z,X){let Y=Z||this.getIdToRemoteIdMap(J),q=X||this.getRemoteIdToIdMap(J),V=Y.get($);if(!V)V=this.generateIdFn(),Y.set($,V),q.set(V,$);return V}getIds(J,$){let Z=this.getIdToRemoteIdMap(J),X=this.getRemoteIdToIdMap(J);return $.map((Y)=>this.getId(J,Y,Z,X))}getRemoteId(J,$,Z){let X=Z||this.getRemoteIdToIdMap(J);if(typeof $!=="number")return $;let Y=X.get($);if(!Y)return-1;return Y}getRemoteIds(J,$){let Z=this.getRemoteIdToIdMap(J);return $.map((X)=>this.getRemoteId(J,X,Z))}reset(J){if(!J){this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap;return}this.iframeIdToRemoteIdMap.delete(J),this.iframeRemoteIdToIdMap.delete(J)}getIdToRemoteIdMap(J){let $=this.iframeIdToRemoteIdMap.get(J);if(!$)$=new Map,this.iframeIdToRemoteIdMap.set(J,$);return $}getRemoteIdToIdMap(J){let $=this.iframeRemoteIdToIdMap.get(J);if(!$)$=new Map,this.iframeRemoteIdToIdMap.set(J,$);return $}}class r0{constructor(J){if(H(this,"iframes",new WeakMap),H(this,"crossOriginIframeMap",new WeakMap),H(this,"crossOriginIframeMirror",new oJ(w0)),H(this,"crossOriginIframeStyleMirror"),H(this,"crossOriginIframeRootIdMap",new WeakMap),H(this,"mirror"),H(this,"mutationCb"),H(this,"wrappedEmit"),H(this,"loadListener"),H(this,"stylesheetManager"),H(this,"recordCrossOriginIframes"),this.mutationCb=J.mutationCb,this.wrappedEmit=J.wrappedEmit,this.stylesheetManager=J.stylesheetManager,this.recordCrossOriginIframes=J.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new oJ(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=J.mirror,this.recordCrossOriginIframes)window.addEventListener("message",this.handleMessage.bind(this))}addIframe(J){if(this.iframes.set(J,!0),J.contentWindow)this.crossOriginIframeMap.set(J.contentWindow,J)}addLoadListener(J){this.loadListener=J}attachIframe(J,$){var Z,X;if(this.mutationCb({adds:[{parentId:this.mirror.getId(J),nextId:null,node:$}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),this.recordCrossOriginIframes)(Z=J.contentWindow)==null||Z.addEventListener("message",this.handleMessage.bind(this));if((X=this.loadListener)==null||X.call(this,J),J.contentDocument&&J.contentDocument.adoptedStyleSheets&&J.contentDocument.adoptedStyleSheets.length>0)this.stylesheetManager.adoptStyleSheets(J.contentDocument.adoptedStyleSheets,this.mirror.getId(J.contentDocument))}handleMessage(J){let $=J;if($.data.type!=="rrweb"||$.origin!==$.data.origin)return;if(!J.source)return;let X=this.crossOriginIframeMap.get(J.source);if(!X)return;let Y=this.transformCrossOriginEvent(X,$.data.event);if(Y)this.wrappedEmit(Y,$.data.isCheckout)}transformCrossOriginEvent(J,$){var Z;switch($.type){case _.FullSnapshot:{this.crossOriginIframeMirror.reset(J),this.crossOriginIframeStyleMirror.reset(J),this.replaceIdOnNode($.data.node,J);let X=$.data.node.id;return this.crossOriginIframeRootIdMap.set(J,X),this.patchRootIdOnNode($.data.node,X),{timestamp:$.timestamp,type:_.IncrementalSnapshot,data:{source:M.Mutation,adds:[{parentId:this.mirror.getId(J),nextId:null,node:$.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}}}case _.Meta:case _.Load:case _.DomContentLoaded:return!1;case _.Plugin:return $;case _.Custom:return this.replaceIds($.data.payload,J,["id","parentId","previousId","nextId"]),$;case _.IncrementalSnapshot:switch($.data.source){case M.Mutation:return $.data.adds.forEach((X)=>{this.replaceIds(X,J,["parentId","nextId","previousId"]),this.replaceIdOnNode(X.node,J);let Y=this.crossOriginIframeRootIdMap.get(J);Y&&this.patchRootIdOnNode(X.node,Y)}),$.data.removes.forEach((X)=>{this.replaceIds(X,J,["parentId","id"])}),$.data.attributes.forEach((X)=>{this.replaceIds(X,J,["id"])}),$.data.texts.forEach((X)=>{this.replaceIds(X,J,["id"])}),$;case M.Drag:case M.TouchMove:case M.MouseMove:return $.data.positions.forEach((X)=>{this.replaceIds(X,J,["id"])}),$;case M.ViewportResize:return!1;case M.MediaInteraction:case M.MouseInteraction:case M.Scroll:case M.CanvasMutation:case M.Input:return this.replaceIds($.data,J,["id"]),$;case M.StyleSheetRule:case M.StyleDeclaration:return this.replaceIds($.data,J,["id"]),this.replaceStyleIds($.data,J,["styleId"]),$;case M.Font:return $;case M.Selection:return $.data.ranges.forEach((X)=>{this.replaceIds(X,J,["start","end"])}),$;case M.AdoptedStyleSheet:return this.replaceIds($.data,J,["id"]),this.replaceStyleIds($.data,J,["styleIds"]),(Z=$.data.styles)==null||Z.forEach((X)=>{this.replaceStyleIds(X,J,["styleId"])}),$}}return!1}replace(J,$,Z,X){for(let Y of X){if(!Array.isArray($[Y])&&typeof $[Y]!=="number")continue;if(Array.isArray($[Y]))$[Y]=J.getIds(Z,$[Y]);else $[Y]=J.getId(Z,$[Y])}return $}replaceIds(J,$,Z){return this.replace(this.crossOriginIframeMirror,J,$,Z)}replaceStyleIds(J,$,Z){return this.replace(this.crossOriginIframeStyleMirror,J,$,Z)}replaceIdOnNode(J,$){if(this.replaceIds(J,$,["id","rootId"]),"childNodes"in J)J.childNodes.forEach((Z)=>{this.replaceIdOnNode(Z,$)})}patchRootIdOnNode(J,$){if(J.type!==v.Document&&!J.rootId)J.rootId=$;if("childNodes"in J)J.childNodes.forEach((Z)=>{this.patchRootIdOnNode(Z,$)})}}class s0{constructor(J){H(this,"shadowDoms",new WeakSet),H(this,"mutationCb"),H(this,"scrollCb"),H(this,"bypassOptions"),H(this,"mirror"),H(this,"restoreHandlers",[]),this.mutationCb=J.mutationCb,this.scrollCb=J.scrollCb,this.bypassOptions=J.bypassOptions,this.mirror=J.mirror,this.init()}init(){this.reset(),this.patchAttachShadow(Element,document)}addShadowRoot(J,$){if(!DJ(J))return;if(this.shadowDoms.has(J))return;this.shadowDoms.add(J);let[Z]=l0({...this.bypassOptions,doc:$,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this},J);this.restoreHandlers.push(()=>Z.disconnect()),this.restoreHandlers.push(i0({...this.bypassOptions,scrollCb:this.scrollCb,doc:J,mirror:this.mirror})),setTimeout(()=>{if(J.adoptedStyleSheets&&J.adoptedStyleSheets.length>0)this.bypassOptions.stylesheetManager.adoptStyleSheets(J.adoptedStyleSheets,this.mirror.getId(A.host(J)));this.restoreHandlers.push(a0({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},J))},0)}observeAttachShadow(J){if(!J.contentWindow||!J.contentDocument)return;this.patchAttachShadow(J.contentWindow.Element,J.contentDocument)}patchAttachShadow(J,$){let Z=this;this.restoreHandlers.push(QJ(J.prototype,"attachShadow",function(X){return function(Y){let q=X.call(this,Y),V=A.shadowRoot(this);if(V&&m0(this))Z.addShadowRoot(V,$);return q}}))}reset(){this.restoreHandlers.forEach((J)=>{try{J()}catch($){}}),this.restoreHandlers=[],this.shadowDoms=new WeakSet}}var BJ="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",H6=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(KJ=0;KJ<BJ.length;KJ++)H6[BJ.charCodeAt(KJ)]=KJ;var KJ,P6=function(J){var $=new Uint8Array(J),Z,X=$.length,Y="";for(Z=0;Z<X;Z+=3)Y+=BJ[$[Z]>>2],Y+=BJ[($[Z]&3)<<4|$[Z+1]>>4],Y+=BJ[($[Z+1]&15)<<2|$[Z+2]>>6],Y+=BJ[$[Z+2]&63];if(X%3===2)Y=Y.substring(0,Y.length-1)+"=";else if(X%3===1)Y=Y.substring(0,Y.length-2)+"==";return Y},D0=new Map;function D6(J,$){let Z=D0.get(J);if(!Z)Z=new Map,D0.set(J,Z);if(!Z.has($))Z.set($,[]);return Z.get($)}var o0=(J,$,Z)=>{if(!J||!(t0(J,$)||typeof J==="object"))return;let X=J.constructor.name,Y=D6(Z,X),q=Y.indexOf(J);if(q===-1)q=Y.length,Y.push(J);return q};function TJ(J,$,Z){if(J instanceof Array)return J.map((X)=>TJ(X,$,Z));else if(J===null)return J;else if(J instanceof Float32Array||J instanceof Float64Array||J instanceof Int32Array||J instanceof Uint32Array||J instanceof Uint8Array||J instanceof Uint16Array||J instanceof Int16Array||J instanceof Int8Array||J instanceof Uint8ClampedArray)return{rr_type:J.constructor.name,args:[Object.values(J)]};else if(J instanceof ArrayBuffer){let X=J.constructor.name,Y=P6(J);return{rr_type:X,base64:Y}}else if(J instanceof DataView)return{rr_type:J.constructor.name,args:[TJ(J.buffer,$,Z),J.byteOffset,J.byteLength]};else if(J instanceof HTMLImageElement){let X=J.constructor.name,{src:Y}=J;return{rr_type:X,src:Y}}else if(J instanceof HTMLCanvasElement)return{rr_type:"HTMLImageElement",src:J.toDataURL()};else if(J instanceof ImageData)return{rr_type:J.constructor.name,args:[TJ(J.data,$,Z),J.width,J.height]};else if(t0(J,$)||typeof J==="object"){let X=J.constructor.name,Y=o0(J,$,Z);return{rr_type:X,index:Y}}return J}var n0=(J,$,Z)=>{return J.map((X)=>TJ(X,$,Z))},t0=(J,$)=>{let X=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter((Y)=>typeof $[Y]==="function");return Boolean(X.find((Y)=>J instanceof $[Y]))};function L6(J,$,Z,X){let Y=[],q=Object.getOwnPropertyNames($.CanvasRenderingContext2D.prototype);for(let V of q)try{if(typeof $.CanvasRenderingContext2D.prototype[V]!=="function")continue;let G=QJ($.CanvasRenderingContext2D.prototype,V,function(Q){return function(...K){if(!h(this.canvas,Z,X,!0))setTimeout(()=>{let U=n0(K,$,this);J(this.canvas,{type:jJ["2D"],property:V,args:U})},0);return Q.apply(this,K)}});Y.push(G)}catch{let G=yJ($.CanvasRenderingContext2D.prototype,V,{set(Q){J(this.canvas,{type:jJ["2D"],property:V,args:[Q],setter:!0})}});Y.push(G)}return()=>{Y.forEach((V)=>V())}}function A6(J){return J==="experimental-webgl"?"webgl":J}function L0(J,$,Z,X){let Y=[];try{let q=QJ(J.HTMLCanvasElement.prototype,"getContext",function(V){return function(G,...Q){if(!h(this,$,Z,!0)){let K=A6(G);if(!("__context"in this))this.__context=K;if(X&&["webgl","webgl2"].includes(K))if(Q[0]&&typeof Q[0]==="object"){let U=Q[0];if(!U.preserveDrawingBuffer)U.preserveDrawingBuffer=!0}else Q.splice(0,1,{preserveDrawingBuffer:!0})}return V.apply(this,[G,...Q])}});Y.push(q)}catch{console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{Y.forEach((q)=>q())}}function A0(J,$,Z,X,Y,q){let V=[],G=Object.getOwnPropertyNames(J);for(let Q of G){if(["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(Q))continue;try{if(typeof J[Q]!=="function")continue;let K=QJ(J,Q,function(U){return function(...j){let P=U.apply(this,j);if(o0(P,q,this),"tagName"in this.canvas&&!h(this.canvas,X,Y,!0)){let B=n0(j,q,this),z={type:$,property:Q,args:B};Z(this.canvas,z)}return P}});V.push(K)}catch{let K=yJ(J,Q,{set(U){Z(this.canvas,{type:$,property:Q,args:[U],setter:!0})}});V.push(K)}}return V}function F6(J,$,Z,X){let Y=[];if(typeof $.WebGLRenderingContext<"u")Y.push(...A0($.WebGLRenderingContext.prototype,jJ.WebGL,J,Z,X,$));if(typeof $.WebGL2RenderingContext<"u")Y.push(...A0($.WebGL2RenderingContext.prototype,jJ.WebGL2,J,Z,X,$));return()=>{Y.forEach((q)=>q())}}var e0=`(function() {
4
+ "use strict";
5
+ var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
6
+ var lookup = typeof Uint8Array === "undefined" ? [] : new Uint8Array(256);
7
+ for (var i = 0; i < chars.length; i++) {
8
+ lookup[chars.charCodeAt(i)] = i;
9
+ }
10
+ var encode = function(arraybuffer) {
11
+ var bytes = new Uint8Array(arraybuffer), i2, len = bytes.length, base64 = "";
12
+ for (i2 = 0; i2 < len; i2 += 3) {
13
+ base64 += chars[bytes[i2] >> 2];
14
+ base64 += chars[(bytes[i2] & 3) << 4 | bytes[i2 + 1] >> 4];
15
+ base64 += chars[(bytes[i2 + 1] & 15) << 2 | bytes[i2 + 2] >> 6];
16
+ base64 += chars[bytes[i2 + 2] & 63];
17
+ }
18
+ if (len % 3 === 2) {
19
+ base64 = base64.substring(0, base64.length - 1) + "=";
20
+ } else if (len % 3 === 1) {
21
+ base64 = base64.substring(0, base64.length - 2) + "==";
22
+ }
23
+ return base64;
24
+ };
25
+ const lastBlobMap = /* @__PURE__ */ new Map();
26
+ const transparentBlobMap = /* @__PURE__ */ new Map();
27
+ async function getTransparentBlobFor(width, height, dataURLOptions) {
28
+ const id = \`\${width}-\${height}\`;
29
+ if ("OffscreenCanvas" in globalThis) {
30
+ if (transparentBlobMap.has(id)) return transparentBlobMap.get(id);
31
+ const offscreen = new OffscreenCanvas(width, height);
32
+ offscreen.getContext("2d");
33
+ const blob = await offscreen.convertToBlob(dataURLOptions);
34
+ const arrayBuffer = await blob.arrayBuffer();
35
+ const base64 = encode(arrayBuffer);
36
+ transparentBlobMap.set(id, base64);
37
+ return base64;
38
+ } else {
39
+ return "";
40
+ }
41
+ }
42
+ const worker = self;
43
+ worker.onmessage = async function(e) {
44
+ if ("OffscreenCanvas" in globalThis) {
45
+ const { id, bitmap, width, height, dataURLOptions } = e.data;
46
+ const transparentBase64 = getTransparentBlobFor(
47
+ width,
48
+ height,
49
+ dataURLOptions
50
+ );
51
+ const offscreen = new OffscreenCanvas(width, height);
52
+ const ctx = offscreen.getContext("2d");
53
+ ctx.drawImage(bitmap, 0, 0);
54
+ bitmap.close();
55
+ const blob = await offscreen.convertToBlob(dataURLOptions);
56
+ const type = blob.type;
57
+ const arrayBuffer = await blob.arrayBuffer();
58
+ const base64 = encode(arrayBuffer);
59
+ if (!lastBlobMap.has(id) && await transparentBase64 === base64) {
60
+ lastBlobMap.set(id, base64);
61
+ return worker.postMessage({ id });
62
+ }
63
+ if (lastBlobMap.get(id) === base64) return worker.postMessage({ id });
64
+ worker.postMessage({
65
+ id,
66
+ type,
67
+ base64,
68
+ width,
69
+ height
70
+ });
71
+ lastBlobMap.set(id, base64);
72
+ } else {
73
+ return worker.postMessage({ id: e.data.id });
74
+ }
75
+ };
76
+ })();
77
+ //# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map
78
+ `,F0=typeof self<"u"&&self.Blob&&new Blob([e0],{type:"text/javascript;charset=utf-8"});function R6(J){let $;try{if($=F0&&(self.URL||self.webkitURL).createObjectURL(F0),!$)throw"";let Z=new Worker($,{name:J==null?void 0:J.name});return Z.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL($)}),Z}catch(Z){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(e0),{name:J==null?void 0:J.name})}finally{$&&(self.URL||self.webkitURL).revokeObjectURL($)}}class J1{constructor(J){H(this,"pendingCanvasMutations",new Map),H(this,"rafStamps",{latestId:0,invokeId:null}),H(this,"mirror"),H(this,"mutationCb"),H(this,"resetObservers"),H(this,"frozen",!1),H(this,"locked",!1),H(this,"processMutation",(G,Q)=>{if(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)this.rafStamps.invokeId=this.rafStamps.latestId;if(!this.pendingCanvasMutations.has(G))this.pendingCanvasMutations.set(G,[]);this.pendingCanvasMutations.get(G).push(Q)});let{sampling:$="all",win:Z,blockClass:X,blockSelector:Y,recordCanvas:q,dataURLOptions:V}=J;if(this.mutationCb=J.mutationCb,this.mirror=J.mirror,q&&$==="all")this.initCanvasMutationObserver(Z,X,Y);if(q&&typeof $==="number")this.initCanvasFPSObserver($,Z,X,Y,{dataURLOptions:V})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(J,$,Z,X,Y){let q=L0($,Z,X,!0),V=new Map,G=new R6;G.onmessage=(B)=>{let{id:z}=B.data;if(V.set(z,!1),!("base64"in B.data))return;let{base64:W,type:L,width:R,height:F}=B.data;this.mutationCb({id:z,type:jJ["2D"],commands:[{property:"clearRect",args:[0,0,R,F]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:W}],type:L}]},0,0]}]})};let Q=1000/J,K=0,U,j=()=>{let B=[];return $.document.querySelectorAll("canvas").forEach((z)=>{if(!h(z,Z,X,!0))B.push(z)}),B},P=(B)=>{if(K&&B-K<Q){U=requestAnimationFrame(P);return}K=B,j().forEach(async(z)=>{var W;let L=this.mirror.getId(z);if(V.get(L))return;if(z.width===0||z.height===0)return;if(V.set(L,!0),["webgl","webgl2"].includes(z.__context)){let F=z.getContext(z.__context);if(((W=F==null?void 0:F.getContextAttributes())==null?void 0:W.preserveDrawingBuffer)===!1)F.clear(F.COLOR_BUFFER_BIT)}let R=await createImageBitmap(z);G.postMessage({id:L,bitmap:R,width:z.width,height:z.height,dataURLOptions:Y.dataURLOptions},[R])}),U=requestAnimationFrame(P)};U=requestAnimationFrame(P),this.resetObservers=()=>{q(),cancelAnimationFrame(U)}}initCanvasMutationObserver(J,$,Z){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let X=L0(J,$,Z,!1),Y=L6(this.processMutation.bind(this),J,$,Z),q=F6(this.processMutation.bind(this),J,$,Z);this.resetObservers=()=>{X(),Y(),q()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let J=($)=>{this.rafStamps.latestId=$,requestAnimationFrame(J)};requestAnimationFrame(J)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((J,$)=>{let Z=this.mirror.getId($);this.flushPendingCanvasMutationFor($,Z)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(J,$){if(this.frozen||this.locked)return;let Z=this.pendingCanvasMutations.get(J);if(!Z||$===-1)return;let X=Z.map((q)=>{let{type:V,...G}=q;return G}),{type:Y}=Z[0];this.mutationCb({id:$,type:Y,commands:X}),this.pendingCanvasMutations.delete(J)}}class $1{constructor(J){H(this,"trackedLinkElements",new WeakSet),H(this,"mutationCb"),H(this,"adoptedStyleSheetCb"),H(this,"styleMirror",new h0),this.mutationCb=J.mutationCb,this.adoptedStyleSheetCb=J.adoptedStyleSheetCb}attachLinkElement(J,$){if("_cssText"in $.attributes)this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:$.id,attributes:$.attributes}]});this.trackLinkElement(J)}trackLinkElement(J){if(this.trackedLinkElements.has(J))return;this.trackedLinkElements.add(J),this.trackStylesheetInLinkElement(J)}adoptStyleSheets(J,$){if(J.length===0)return;let Z={id:$,styleIds:[]},X=[];for(let Y of J){let q;if(!this.styleMirror.has(Y))q=this.styleMirror.add(Y),X.push({styleId:q,rules:Array.from(Y.rules||CSSRule,(V,G)=>({rule:_0(V,Y.href),index:G}))});else q=this.styleMirror.getId(Y);Z.styleIds.push(q)}if(X.length>0)Z.styles=X;this.adoptedStyleSheetCb(Z)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(J){}}class Z1{constructor(){H(this,"nodeMap",new WeakMap),H(this,"active",!1)}inOtherBuffer(J,$){let Z=this.nodeMap.get(J);return Z&&Array.from(Z).some((X)=>X!==$)}add(J,$){if(!this.active)this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1});this.nodeMap.set(J,(this.nodeMap.get(J)||new Set).add($))}destroy(){}}var k,xJ,lJ,bJ=!1;try{if(Array.from([1],(J)=>J*2)[0]!==2){let J=document.createElement("iframe");document.body.appendChild(J),Array.from=((Q0=J.contentWindow)==null?void 0:Q0.Array.from)||Array.from,document.body.removeChild(J)}}catch(J){console.debug("Unable to override Array.from",J)}var a=M1();function gJ(J={}){let{emit:$,checkoutEveryNms:Z,checkoutEveryNth:X,blockClass:Y="rr-block",blockSelector:q=null,ignoreClass:V="rr-ignore",ignoreSelector:G=null,maskTextClass:Q="rr-mask",maskTextSelector:K=null,inlineStylesheet:U=!0,maskAllInputs:j,maskInputOptions:P,slimDOMOptions:B,maskInputFn:z,maskTextFn:W,hooks:L,packFn:R,sampling:F={},dataURLOptions:D={},mousemoveWait:O,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:y=!1,recordAfter:r=J.recordAfter==="DOMContentLoaded"?J.recordAfter:"load",userTriggeredOnInput:p=!1,collectFonts:l=!1,inlineImages:d=!1,plugins:s,keepIframeSrcFn:E=()=>!1,ignoreCSSAttributes:zJ=new Set([]),errorHandler:HJ}=J;J6(HJ);let b=y?window.parent===window:!0,c=!1;if(!b)try{if(window.parent.document)c=!1}catch(w){c=!0}if(b&&!$)throw Error("emit function is required");if(!b&&!c)return()=>{};if(O!==void 0&&F.mousemove===void 0)F.mousemove=O;a.reset();let $J=j===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:P!==void 0?P:{password:!0},o=S0(B);s1();let $0,hJ=0,Z0=(w)=>{for(let i of s||[])if(i.eventProcessor)w=i.eventProcessor(w);if(R&&!c)w=R(w);return w};k=(w,i)=>{var f;let I=w;if(I.timestamp=AJ(),((f=YJ[0])==null?void 0:f.isFrozen())&&I.type!==_.FullSnapshot&&!(I.type===_.IncrementalSnapshot&&I.data.source===M.Mutation))YJ.forEach((m)=>m.unfreeze());if(b)$==null||$(Z0(I),i);else if(c){let m={type:"rrweb",event:Z0(I),origin:window.location.origin,isCheckout:i};window.parent.postMessage(m,"*")}if(I.type===_.FullSnapshot)$0=I,hJ=0;else if(I.type===_.IncrementalSnapshot){if(I.data.source===M.Mutation&&I.data.isAttachIframe)return;hJ++;let m=X&&hJ>=X,C=Z&&I.timestamp-$0.timestamp>Z;if(m||C)xJ(!0)}};let MJ=(w)=>{k({type:_.IncrementalSnapshot,data:{source:M.Mutation,...w}})},X0=(w)=>k({type:_.IncrementalSnapshot,data:{source:M.Scroll,...w}}),Y0=(w)=>k({type:_.IncrementalSnapshot,data:{source:M.CanvasMutation,...w}}),ZJ=new $1({mutationCb:MJ,adoptedStyleSheetCb:(w)=>k({type:_.IncrementalSnapshot,data:{source:M.AdoptedStyleSheet,...w}})}),XJ=new r0({mirror:a,mutationCb:MJ,stylesheetManager:ZJ,recordCrossOriginIframes:y,wrappedEmit:k});for(let w of s||[])if(w.getMirror)w.getMirror({nodeMirror:a,crossOriginIframeMirror:XJ.crossOriginIframeMirror,crossOriginIframeStyleMirror:XJ.crossOriginIframeStyleMirror});let uJ=new Z1;lJ=new J1({recordCanvas:S,mutationCb:Y0,win:window,blockClass:Y,blockSelector:q,mirror:a,sampling:F.canvas,dataURLOptions:D});let NJ=new s0({mutationCb:MJ,scrollCb:X0,bypassOptions:{blockClass:Y,blockSelector:q,maskTextClass:Q,maskTextSelector:K,inlineStylesheet:U,maskInputOptions:$J,dataURLOptions:D,maskTextFn:W,maskInputFn:z,recordCanvas:S,inlineImages:d,sampling:F,slimDOMOptions:o,iframeManager:XJ,stylesheetManager:ZJ,canvasManager:lJ,keepIframeSrcFn:E,processedNodeManager:uJ},mirror:a});xJ=(w=!1)=>{if(!x)return;k({type:_.Meta,data:{href:window.location.href,width:k0(),height:I0()}},w),ZJ.reset(),NJ.init(),YJ.forEach((f)=>f.lock());let i=a1(document,{mirror:a,blockClass:Y,blockSelector:q,maskTextClass:Q,maskTextSelector:K,inlineStylesheet:U,maskAllInputs:$J,maskTextFn:W,maskInputFn:z,slimDOM:o,dataURLOptions:D,recordCanvas:S,inlineImages:d,onSerialize:(f)=>{if(y0(f,a))XJ.addIframe(f);if(g0(f,a))ZJ.trackLinkElement(f);if(rJ(f))NJ.addShadowRoot(A.shadowRoot(f),document)},onIframeLoad:(f,I)=>{XJ.attachIframe(f,I),NJ.observeAttachShadow(f)},onStylesheetLoad:(f,I)=>{ZJ.attachLinkElement(f,I)},keepIframeSrcFn:E});if(!i)return console.warn("Failed to snapshot the document");if(k({type:_.FullSnapshot,data:{node:i,initialOffset:f0(window)}},w),YJ.forEach((f)=>f.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0)ZJ.adoptStyleSheets(document.adoptedStyleSheets,a.getId(document))};try{let w=[],i=(I)=>{var m;return N(z6)({mutationCb:MJ,mousemoveCb:(C,mJ)=>k({type:_.IncrementalSnapshot,data:{source:mJ,positions:C}}),mouseInteractionCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.MouseInteraction,...C}}),scrollCb:X0,viewportResizeCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.ViewportResize,...C}}),inputCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.Input,...C}}),mediaInteractionCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.MediaInteraction,...C}}),styleSheetRuleCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.StyleSheetRule,...C}}),styleDeclarationCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.StyleDeclaration,...C}}),canvasMutationCb:Y0,fontCb:(C)=>k({type:_.IncrementalSnapshot,data:{source:M.Font,...C}}),selectionCb:(C)=>{k({type:_.IncrementalSnapshot,data:{source:M.Selection,...C}})},customElementCb:(C)=>{k({type:_.IncrementalSnapshot,data:{source:M.CustomElement,...C}})},blockClass:Y,ignoreClass:V,ignoreSelector:G,maskTextClass:Q,maskTextSelector:K,maskInputOptions:$J,inlineStylesheet:U,sampling:F,recordDOM:x,recordCanvas:S,inlineImages:d,userTriggeredOnInput:p,collectFonts:l,doc:I,maskInputFn:z,maskTextFn:W,keepIframeSrcFn:E,blockSelector:q,slimDOMOptions:o,dataURLOptions:D,mirror:a,iframeManager:XJ,stylesheetManager:ZJ,shadowDomManager:NJ,processedNodeManager:uJ,canvasManager:lJ,ignoreCSSAttributes:zJ,plugins:((m=s==null?void 0:s.filter((C)=>C.observer))==null?void 0:m.map((C)=>({observer:C.observer,options:C.options,callback:(mJ)=>k({type:_.Plugin,data:{plugin:C.name,payload:mJ}})})))||[]},L)};XJ.addLoadListener((I)=>{try{w.push(i(I.contentDocument))}catch(m){console.warn(m)}});let f=()=>{xJ(),w.push(i(document)),bJ=!0};if(["interactive","complete"].includes(document.readyState))f();else w.push(g("DOMContentLoaded",()=>{if(k({type:_.DomContentLoaded,data:{}}),r==="DOMContentLoaded")f()})),w.push(g("load",()=>{if(k({type:_.Load,data:{}}),r==="load")f()},window));return()=>{w.forEach((I)=>{try{I()}catch(m){if(!String(m).toLowerCase().includes("cross-origin"))console.warn(m)}}),uJ.destroy(),bJ=!1,$6()}}catch(w){console.warn(w)}}gJ.addCustomEvent=(J,$)=>{if(!bJ)throw Error("please add custom event after start recording");k({type:_.Custom,data:{tag:J,payload:$}})};gJ.freezePage=()=>{YJ.forEach((J)=>J.freeze())};gJ.takeFullSnapshot=(J)=>{if(!bJ)throw Error("please take full snapshot after start recording");xJ(J)};gJ.mirror=a;export{gJ as record};
package/dist/submit.d.ts CHANGED
@@ -4,7 +4,7 @@ export interface FiledTicket {
4
4
  number: number;
5
5
  status: string;
6
6
  }
7
- export declare function toBase64(bytes: Uint8Array): string;
7
+ export { toBase64 } from "./base64";
8
8
  /**
9
9
  * A data URI for the JSON bundle, so the bulk lands in object storage.
10
10
  *
package/dist/types.d.ts CHANGED
@@ -157,6 +157,47 @@ export interface DebugContext {
157
157
  extra: Record<string, unknown>;
158
158
  }
159
159
  export type ScreenshotMethod = "display-media" | "html-to-image" | "none" | "cancelled";
160
+ /**
161
+ * One rrweb event. Typed by shape rather than imported from `@rrweb/types`,
162
+ * so a host that reads a bundle needs nothing of rrweb's to do it — the
163
+ * recorder is loaded on demand and its types stay its own.
164
+ */
165
+ export interface ReplayEvent {
166
+ type: number;
167
+ timestamp: number;
168
+ data: unknown;
169
+ }
170
+ /**
171
+ * The last stretch of the session, as the desk will play it back.
172
+ *
173
+ * Always begins with a full snapshot of the page: rrweb can only replay from
174
+ * one, so the window is cut at a checkpoint and never mid-stream. That is why
175
+ * `durationMs` is at least the configured length and can be up to half as
176
+ * much again.
177
+ */
178
+ export interface ReplayCapture {
179
+ events: ReplayEvent[];
180
+ startedAt: string;
181
+ endedAt: string;
182
+ durationMs: number;
183
+ }
184
+ /**
185
+ * What the ticket says about its replay, without the replay: the summary that
186
+ * travels in `context` and lets the desk label the play button before the
187
+ * attachment loads — or say why there is none.
188
+ */
189
+ export interface ReplaySummary {
190
+ /** Whole seconds covered, when one was attached. */
191
+ seconds?: number;
192
+ events?: number;
193
+ startedAt?: string;
194
+ endedAt?: string;
195
+ /** Size of the attachment as sent, and whether it is gzip. */
196
+ bytes?: number;
197
+ compressed?: boolean;
198
+ /** Present when the host records but this report carries no replay. */
199
+ omitted?: "declined" | "too-large" | "empty";
200
+ }
160
201
  export interface DebugBundle {
161
202
  context: DebugContext;
162
203
  reason: DebugReason;
@@ -168,6 +209,14 @@ export interface DebugBundle {
168
209
  /** PNG data URL, or null if capture failed / was skipped. */
169
210
  screenshotDataUrl: string | null;
170
211
  screenshotMethod: ScreenshotMethod;
212
+ /**
213
+ * The session replay, when the host records one. Its own attachment on the
214
+ * way out, like the screenshot — never inside the JSON bundle.
215
+ *
216
+ * Absent: nothing was recorded. `null`: there was one and the reporter
217
+ * chose to leave it out — the desk is told which.
218
+ */
219
+ replay?: ReplayCapture | null;
171
220
  meta: {
172
221
  generatedBy: string;
173
222
  schemaVersion: number;
@@ -38,6 +38,9 @@ export interface Strings {
38
38
  captured: string;
39
39
  reporter: string;
40
40
  page: string;
41
+ /** The replay row: "{seconds}" is replaced. */
42
+ replayAttach: string;
43
+ replayWhat: string;
41
44
  /** The hand-off dialog, shown before leaving for the support portal. */
42
45
  handoffTitle: string;
43
46
  handoffBody: string;
@@ -10,4 +10,4 @@
10
10
  * Everything is explicit for the same reason: the host's `body` font and colours
11
11
  * do not inherit past the boundary, so stating them is not belt-and-braces.
12
12
  */
13
- export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; }\n\n.backdrop {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; align-items: center; justify-content: center;\n padding: 24px; background: rgba(15, 23, 42, 0.55);\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Noto Sans Thai\", sans-serif;\n color: #0f172a;\n}\n.panel {\n display: flex; flex-direction: column; gap: 16px;\n width: min(820px, 100%); max-height: 90vh; overflow-y: auto;\n /* No bottom padding: the footer supplies its own and sits flush, so it can\n stick to the panel's edge without a gap under it. */\n padding: 24px 24px 0; border-radius: 16px; background: #fff;\n box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);\n}\n.head { display: flex; align-items: flex-start; gap: 12px; }\nh2 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }\nlabel { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }\n.req { color: #dc2626; }\n.hint { font-weight: 400; color: #64748b; }\ninput[type=\"text\"], textarea {\n width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\ninput[type=\"text\"]:focus, textarea:focus {\n outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);\n}\ntextarea { min-height: 88px; resize: vertical; }\n\n.meta {\n padding: 12px 14px; border-radius: 10px; background: #f8fafc;\n font-size: 13px; line-height: 1.7; color: #475569; word-break: break-all;\n}\n.meta b { color: #0f172a; font-weight: 600; }\n\n.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }\n.sep { width: 1px; align-self: stretch; background: #e2e8f0; margin: 0 4px; }\nbutton {\n display: inline-flex; align-items: center; gap: 6px; cursor: pointer;\n padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 500;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\nbutton:hover:not(:disabled) { background: #f1f5f9; }\nbutton:disabled { opacity: 0.5; cursor: not-allowed; }\nbutton[aria-pressed=\"true\"] { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }\nbutton.primary { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.primary:hover:not(:disabled) { background: #1d4ed8; }\nbutton.icon { padding: 6px 10px; border-color: transparent; font-size: 18px; line-height: 1; }\n\n/* The on-image text editor. Absolutely placed over the canvas and matched to\n the shape it becomes \u2014 same weight, same red, same white plate \u2014 so what you\n type is what gets drawn, at the position you clicked. Sized in JS, because\n the font size tracks the image's own scale. */\n.text-edit {\n position: absolute; z-index: 2; margin: 0; padding: 2px 4px;\n font-family: system-ui, sans-serif; font-weight: 600; line-height: 1.25;\n color: #e11d48; background: rgba(255, 255, 255, 0.92);\n border: 1px dashed #e11d48; border-radius: 4px; outline: none;\n box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);\n}\n.text-edit::placeholder { color: rgba(225, 29, 72, 0.45); }\n\ncanvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; border-radius: 10px; touch-action: none; }\n.shot { position: relative; }\n.status { font-size: 13px; color: #64748b; }\n.status[data-tone=\"error\"] { color: #dc2626; }\n/* Pinned to the bottom of the scrolling panel.\n A screenshot is tall \u2014 often taller than the viewport \u2014 so \u0E41\u0E08\u0E49\u0E07\u0E1B\u0E31\u0E0D\u0E2B\u0E32 sat\n below the fold and the last step of filing a report was \"scroll to the end\n and find the button\". Sticky, with its own ground and a rule above it so the\n annotated image scrolls underneath rather than bleeding into it. */\n.foot {\n position: sticky; bottom: 0; z-index: 3;\n display: flex; align-items: center; gap: 12px;\n margin: 4px -24px 0; padding: 12px 24px;\n background: #fff; border-top: 1px solid #e2e8f0;\n border-radius: 0 0 16px 16px;\n}\n.foot .grow { flex: 1; }\n";
13
+ export declare const CSS = "\n:host { all: initial; }\n* { box-sizing: border-box; }\n\n.backdrop {\n position: fixed; inset: 0; z-index: 2147483000;\n display: flex; align-items: center; justify-content: center;\n padding: 24px; background: rgba(15, 23, 42, 0.55);\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Noto Sans Thai\", sans-serif;\n color: #0f172a;\n}\n.panel {\n display: flex; flex-direction: column; gap: 16px;\n width: min(820px, 100%); max-height: 90vh; overflow-y: auto;\n /* No bottom padding: the footer supplies its own and sits flush, so it can\n stick to the panel's edge without a gap under it. */\n padding: 24px 24px 0; border-radius: 16px; background: #fff;\n box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);\n}\n.head { display: flex; align-items: flex-start; gap: 12px; }\nh2 { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }\nlabel { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }\n.req { color: #dc2626; }\n.hint { font-weight: 400; color: #64748b; }\ninput[type=\"text\"], textarea {\n width: 100%; padding: 10px 12px; font: inherit; font-size: 14px;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\ninput[type=\"text\"]:focus, textarea:focus {\n outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);\n}\ntextarea { min-height: 88px; resize: vertical; }\n\n.meta {\n padding: 12px 14px; border-radius: 10px; background: #f8fafc;\n font-size: 13px; line-height: 1.7; color: #475569; word-break: break-all;\n}\n.meta b { color: #0f172a; font-weight: 600; }\n.meta .check {\n display: flex; align-items: flex-start; gap: 8px; margin: 8px 0 0; padding-top: 8px;\n border-top: 1px solid #e2e8f0; font-weight: 500; color: #0f172a; word-break: normal; cursor: pointer;\n}\n.meta .check input { margin: 5px 0 0; flex: none; accent-color: #2563eb; }\n.meta .check .hint { display: block; font-size: 12px; line-height: 1.5; margin-top: 2px; }\n\n.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }\n.sep { width: 1px; align-self: stretch; background: #e2e8f0; margin: 0 4px; }\nbutton {\n display: inline-flex; align-items: center; gap: 6px; cursor: pointer;\n padding: 8px 14px; font: inherit; font-size: 14px; font-weight: 500;\n border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; color: inherit;\n}\nbutton:hover:not(:disabled) { background: #f1f5f9; }\nbutton:disabled { opacity: 0.5; cursor: not-allowed; }\nbutton[aria-pressed=\"true\"] { border-color: #2563eb; background: #eff6ff; color: #1d4ed8; }\nbutton.primary { background: #2563eb; border-color: #2563eb; color: #fff; }\nbutton.primary:hover:not(:disabled) { background: #1d4ed8; }\nbutton.icon { padding: 6px 10px; border-color: transparent; font-size: 18px; line-height: 1; }\n\n/* The on-image text editor. Absolutely placed over the canvas and matched to\n the shape it becomes \u2014 same weight, same red, same white plate \u2014 so what you\n type is what gets drawn, at the position you clicked. Sized in JS, because\n the font size tracks the image's own scale. */\n.text-edit {\n position: absolute; z-index: 2; margin: 0; padding: 2px 4px;\n font-family: system-ui, sans-serif; font-weight: 600; line-height: 1.25;\n color: #e11d48; background: rgba(255, 255, 255, 0.92);\n border: 1px dashed #e11d48; border-radius: 4px; outline: none;\n box-shadow: 0 2px 10px rgba(15, 23, 42, 0.18);\n}\n.text-edit::placeholder { color: rgba(225, 29, 72, 0.45); }\n\ncanvas { width: 100%; height: auto; display: block; border: 1px solid #e2e8f0; border-radius: 10px; touch-action: none; }\n.shot { position: relative; }\n.status { font-size: 13px; color: #64748b; }\n.status[data-tone=\"error\"] { color: #dc2626; }\n/* Pinned to the bottom of the scrolling panel.\n A screenshot is tall \u2014 often taller than the viewport \u2014 so \u0E41\u0E08\u0E49\u0E07\u0E1B\u0E31\u0E0D\u0E2B\u0E32 sat\n below the fold and the last step of filing a report was \"scroll to the end\n and find the button\". Sticky, with its own ground and a rule above it so the\n annotated image scrolls underneath rather than bleeding into it. */\n.foot {\n position: sticky; bottom: 0; z-index: 3;\n display: flex; align-items: center; gap: 12px;\n margin: 4px -24px 0; padding: 12px 24px;\n background: #fff; border-top: 1px solid #e2e8f0;\n border-radius: 0 0 16px 16px;\n}\n.foot .grow { flex: 1; }\n";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lightworkai.official/debug-capture",
3
- "version": "0.11.0",
4
- "description": "Report-a-problem widget: rolling network/console/action capture, annotated screenshot, and submission to a Lightwork Support host",
3
+ "version": "0.12.0",
4
+ "description": "Report-a-problem widget: rolling network/console/action capture, optional rrweb session replay, annotated screenshot, and submission to a Lightwork Support host",
5
5
  "type": "module",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  ],
28
28
  "scripts": {
29
29
  "build": "rm -rf dist && bun run build:esm && bun run build:iife && bun run build:types",
30
- "build:esm": "bun build src/index.ts --outfile dist/index.mjs --format esm --minify && bun build src/server.ts --outfile dist/server.mjs --format esm --target node --external node:crypto",
31
- "build:iife": "bun build src/embed.ts --outfile dist/debug-capture.js --format iife --minify",
30
+ "build:esm": "bun build src/index.ts --outfile dist/index.mjs --format esm --minify --external @rrweb/record && bun build src/server.ts --outfile dist/server.mjs --format esm --target node --external node:crypto",
31
+ "build:iife": "bun build src/embed.ts --outfile dist/debug-capture.js --format iife --minify --external @rrweb/record && bun build node_modules/@rrweb/record/dist/record.js --outfile dist/rrweb-record.mjs --format esm --minify",
32
32
  "build:types": "tsc -p tsconfig.build.json --emitDeclarationOnly --outDir dist",
33
33
  "typecheck": "tsc -p tsconfig.json --noEmit",
34
34
  "test": "bun test src"
@@ -48,11 +48,16 @@
48
48
  "support",
49
49
  "helpdesk",
50
50
  "ticket",
51
- "annotate"
51
+ "annotate",
52
+ "session-replay",
53
+ "rrweb"
52
54
  ],
53
55
  "license": "MIT",
54
56
  "author": "Lightwork AI",
55
57
  "publishConfig": {
56
58
  "access": "public"
59
+ },
60
+ "dependencies": {
61
+ "@rrweb/record": "2.1.4"
57
62
  }
58
63
  }
package/src/base64.ts ADDED
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Base64 for a payload of any size.
3
+ *
4
+ * This was `btoa(String.fromCharCode(...bytes))`, which spreads every byte into
5
+ * the argument list — and an argument list has a hard limit. It worked on the
6
+ * tiny bundles a test produces and threw "Maximum call stack size exceeded" on
7
+ * a real one, at the last possible moment: the user has written the report,
8
+ * drawn on the screenshot, and pressed send.
9
+ *
10
+ * Chunked, so the argument count is bounded no matter how large the bundle is.
11
+ */
12
+ const CHUNK = 0x8000;
13
+
14
+ export function toBase64(bytes: Uint8Array): string {
15
+ let binary = "";
16
+ for (let i = 0; i < bytes.length; i += CHUNK) {
17
+ binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
18
+ }
19
+ return btoa(binary);
20
+ }
package/src/budget.ts CHANGED
@@ -24,9 +24,9 @@ export const BUNDLE_BUDGET_BYTES = 2_000_000;
24
24
  const OMITTED = "[body dropped — report size budget]";
25
25
 
26
26
  function sizeOf(bundle: DebugBundle): number {
27
- // The screenshot is a separate attachment; measuring it here would trim
28
- // bodies to make room for something that is not in this budget.
29
- const { screenshotDataUrl: _omit, ...rest } = bundle;
27
+ // The screenshot and the replay are separate attachments; measuring them
28
+ // here would trim bodies to make room for something not in this budget.
29
+ const { screenshotDataUrl: _omit, replay: _alsoOmit, ...rest } = bundle;
30
30
  return JSON.stringify(rest).length;
31
31
  }
32
32
 
package/src/bundle.ts CHANGED
@@ -12,6 +12,7 @@ import { causeCount, computeCause } from './capture/cause';
12
12
  import { getConsoleLog } from './capture/consoleBuffer';
13
13
  import { collectContext } from './context';
14
14
  import { getNetworkLog } from './capture/networkBuffer';
15
+ import { takeReplay } from './capture/replay';
15
16
  import type {
16
17
  ActionTrailEntry,
17
18
  CapturedConsoleEntry,
@@ -54,6 +55,10 @@ export function buildBundle(input: BuildBundleInput): DebugBundle {
54
55
  console: consoleLog,
55
56
  screenshotDataUrl: input.screenshotDataUrl,
56
57
  screenshotMethod: input.screenshotMethod,
58
+ // Taken now, before the reporter's own dialog is on the page. Absent when
59
+ // nothing was recorded; the dialog sets it to null when the reporter
60
+ // chooses to leave it out, and the two mean different things to the desk.
61
+ replay: takeReplay() ?? undefined,
57
62
  meta: {
58
63
  generatedBy: 'lightwork-debug-capture',
59
64
  schemaVersion: SCHEMA_VERSION,
@@ -143,7 +148,9 @@ function summaryLines(bundle: DebugBundle): string[] {
143
148
  `Client : ${ctx.client.userAgent}`,
144
149
  `Viewport : ${ctx.client.viewport.width}×${ctx.client.viewport.height} @${ctx.client.viewport.dpr}x`,
145
150
  `Reason : ${REASON_LABELS[bundle.reason.type]}${bundle.reason.message ? ` — ${bundle.reason.message}` : ''}`,
146
- `Captured : ${bundle.network.length} requests · ${bundle.console.length} console · ${bundle.actionTrail.length} actions · screenshot=${bundle.screenshotMethod}`,
151
+ `Captured : ${bundle.network.length} requests · ${bundle.console.length} console · ${bundle.actionTrail.length} actions · screenshot=${bundle.screenshotMethod}${
152
+ bundle.replay ? ` · replay=${Math.round(bundle.replay.durationMs / 1000)}s` : ''
153
+ }`,
147
154
  ];
148
155
  }
149
156
 
@@ -34,13 +34,48 @@ function safeReplacer(): (key: string, value: unknown) => unknown {
34
34
  };
35
35
  }
36
36
 
37
+ /**
38
+ * Describe one console argument, and never throw doing it.
39
+ *
40
+ * `String(x)` is not safe on an arbitrary object, which is easy to miss because
41
+ * it is safe on almost all of them. An object with a null prototype, or one
42
+ * whose `Symbol.toPrimitive`/`toString` is absent or throws, raises
43
+ * "Cannot convert object to primitive value" — and it was reachable here TWICE:
44
+ * as the `??` fallback when JSON.stringify returns undefined, and inside the
45
+ * catch that exists precisely because stringify already failed.
46
+ *
47
+ * That mattered more than a logging edge case. This runs inside a patched
48
+ * `console.warn`, so throwing here turns somebody ELSE's warning into an
49
+ * exception raised from the logging call — which the crash watcher then reports
50
+ * as an error in the host application. A Vue dev warning naming a component
51
+ * (reka-ui's Popover passes one) was enough: the app showed a red
52
+ * "Cannot convert object to primitive value" toast, sourced to nothing the host
53
+ * had done, on a page where nothing was wrong.
54
+ *
55
+ * Every step after the first is therefore guarded, INCLUDING the last-resort
56
+ * one: `Object.prototype.toString.call` looks up `Symbol.toStringTag`, so a
57
+ * Proxy with a throwing `get` trap defeats that too — measured, not assumed.
58
+ * `typeof` is the only description of a value that cannot execute any of its
59
+ * code, which is what makes it the floor.
60
+ */
37
61
  function stringifyArg(arg: unknown): string {
38
62
  if (typeof arg === 'string') return arg;
39
63
  if (arg instanceof Error) return `${arg.name}: ${arg.message}`;
40
64
  try {
41
- return JSON.stringify(arg, safeReplacer()) ?? String(arg);
65
+ const json = JSON.stringify(arg, safeReplacer());
66
+ if (json !== undefined) return json;
42
67
  } catch {
68
+ /* not serialisable — fall through to a description of it */
69
+ }
70
+ try {
43
71
  return String(arg);
72
+ } catch {
73
+ /* no primitive conversion — fall through */
74
+ }
75
+ try {
76
+ return Object.prototype.toString.call(arg);
77
+ } catch {
78
+ return `[${typeof arg}]`;
44
79
  }
45
80
  }
46
81
 
@@ -209,8 +209,8 @@ function installFetch(): void {
209
209
  }
210
210
 
211
211
  interface PatchedXhr extends XMLHttpRequest {
212
- __cibEntry?: CapturedRequest;
213
- __cibStart?: number;
212
+ __lwEntry?: CapturedRequest;
213
+ __lwStart?: number;
214
214
  }
215
215
 
216
216
  function installXhr(): void {
@@ -222,7 +222,7 @@ function installXhr(): void {
222
222
  const patchedOpen = function (this: PatchedXhr, method: string, url: string | URL): void {
223
223
  const urlStr = typeof url === 'string' ? url : url.toString();
224
224
  // Skip framework chatter (headers aren't set yet at open() — URL is enough).
225
- this.__cibEntry = isFrameworkNoise(urlStr, {})
225
+ this.__lwEntry = isFrameworkNoise(urlStr, {})
226
226
  ? undefined
227
227
  : {
228
228
  id: nextId(),
@@ -244,7 +244,7 @@ function installXhr(): void {
244
244
  this: PatchedXhr,
245
245
  body?: Document | XMLHttpRequestBodyInit | null,
246
246
  ): void {
247
- const entry = this.__cibEntry;
247
+ const entry = this.__lwEntry;
248
248
  if (entry) {
249
249
  entry.startedAt = new Date().toISOString();
250
250
  entry.requestBody =