@kalayanasundaram123/rrweb 2.0.1 → 2.0.2
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.
- package/dist/rrweb.cjs +9 -2
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.js +9 -2
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +9 -2
- package/dist/rrweb.umd.cjs.map +2 -2
- package/dist/rrweb.umd.min.cjs +2 -2
- package/dist/rrweb.umd.min.cjs.map +3 -3
- package/package.json +1 -1
- package/umd/rrweb.js +9 -2
- package/umd/rrweb.min.js +2 -2
package/package.json
CHANGED
package/umd/rrweb.js
CHANGED
|
@@ -13985,6 +13985,13 @@ function WorkerWrapper(options) {
|
|
|
13985
13985
|
objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL);
|
|
13986
13986
|
}
|
|
13987
13987
|
}
|
|
13988
|
+
function canCreateBlobWorker(win) {
|
|
13989
|
+
try {
|
|
13990
|
+
return typeof Worker !== "undefined" && win.origin != null && win.origin !== "null";
|
|
13991
|
+
} catch (e2) {
|
|
13992
|
+
return false;
|
|
13993
|
+
}
|
|
13994
|
+
}
|
|
13988
13995
|
class CanvasManager {
|
|
13989
13996
|
constructor(options) {
|
|
13990
13997
|
__publicField(this, "pendingCanvasMutations", /* @__PURE__ */ new Map());
|
|
@@ -14015,7 +14022,7 @@ class CanvasManager {
|
|
|
14015
14022
|
this.mutationCb = options.mutationCb;
|
|
14016
14023
|
this.mirror = options.mirror;
|
|
14017
14024
|
this.options = options;
|
|
14018
|
-
if (recordCanvas && typeof sampling === "number") {
|
|
14025
|
+
if (recordCanvas && typeof sampling === "number" && canCreateBlobWorker(win)) {
|
|
14019
14026
|
this.worker = this.initFPSWorker();
|
|
14020
14027
|
}
|
|
14021
14028
|
this.addWindow(win);
|
|
@@ -14023,7 +14030,7 @@ class CanvasManager {
|
|
|
14023
14030
|
this.startRAFTimestamping();
|
|
14024
14031
|
this.startPendingCanvasMutationFlusher();
|
|
14025
14032
|
}
|
|
14026
|
-
if (recordCanvas && typeof sampling === "number") {
|
|
14033
|
+
if (recordCanvas && typeof sampling === "number" && this.worker) {
|
|
14027
14034
|
this.initCanvasFPSObserver();
|
|
14028
14035
|
}
|
|
14029
14036
|
}
|
package/umd/rrweb.min.js
CHANGED
|
@@ -161,7 +161,7 @@ or you can use record.mirror to access the mirror instance during recording.`;ex
|
|
|
161
161
|
};
|
|
162
162
|
})();
|
|
163
163
|
//# sourceMappingURL=image-bitmap-data-url-worker-DIbJg1p8.js.map
|
|
164
|
-
`,Sn=typeof self!="undefined"&&self.Blob&&new Blob([No],{type:"text/javascript;charset=utf-8"});function $u(e){let t;try{if(t=Sn&&(self.URL||self.webkitURL).createObjectURL(Sn),!t)throw"";const r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch(r){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(No),{name:e==null?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}class zu{constructor(t){R(this,"pendingCanvasMutations",new Map),R(this,"rafStamps",{latestId:0,invokeId:null}),R(this,"options"),R(this,"mirror"),R(this,"shadowDoms",new Set),R(this,"windowsSet",new WeakSet),R(this,"windows",[]),R(this,"mutationCb"),R(this,"restoreHandlers",[]),R(this,"frozen",!1),R(this,"locked",!1),R(this,"snapshotInProgressMap",new Map),R(this,"worker",null),R(this,"lastSnapshotTime",0),R(this,"processMutation",(o,a)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(o)||this.pendingCanvasMutations.set(o,[]),this.pendingCanvasMutations.get(o).push(a)});const{sampling:r="all",win:s,recordCanvas:i}=t;t.sampling=r,this.mutationCb=t.mutationCb,this.mirror=t.mirror,this.options=t,i&&typeof r=="number"&&(this.worker=this.initFPSWorker()),this.addWindow(s),i&&r==="all"&&(this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher()),i&&typeof r=="number"&&this.initCanvasFPSObserver()}reset(){var t;this.pendingCanvasMutations.clear(),this.restoreHandlers.forEach(r=>{try{r()}catch(s){}}),this.restoreHandlers=[],this.windowsSet=new WeakSet,this.windows=[],this.shadowDoms=new Set,(t=this.worker)==null||t.terminate(),this.worker=null,this.snapshotInProgressMap=new Map}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}addWindow(t){const{sampling:r="all",blockClass:s,blockSelector:i,recordCanvas:o}=this.options;if(!this.windowsSet.has(t)){if(o&&r==="all"&&this.initCanvasMutationObserver(t,s,i),o&&typeof r=="number"){const a=bn(t,s,i,!0);this.restoreHandlers.push(()=>{a()})}this.windowsSet.add(t),this.windows.push(new WeakRef(t))}}addShadowRoot(t){this.shadowDoms.add(new WeakRef(t))}resetShadowRoots(){this.shadowDoms=new Set}initFPSWorker(){const t=new $u;return t.onmessage=r=>{const s=r.data,{id:i}=s;if(this.snapshotInProgressMap.set(i,!1),!("base64"in s))return;const{base64:o,type:a,width:u,height:l}=s;this.mutationCb({id:i,type:Ce["2D"],commands:[{property:"clearRect",args:[0,0,u,l]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:o}],type:a}]},0,0]}]})},t}initCanvasFPSObserver(){let t;if(!this.windows.length&&!this.shadowDoms.size)return;const r=s=>{this.takeSnapshot(s),t=requestAnimationFrame(r)};t=requestAnimationFrame(r),this.restoreHandlers.push(()=>{t&&cancelAnimationFrame(t)})}initCanvasMutationObserver(t,r,s){const i=bn(t,r,s,!1),o=Uu(this.processMutation.bind(this),t,r,s),a=Wu(this.processMutation.bind(this),t,r,s);this.restoreHandlers.push(()=>{i(),o(),a()})}getCanvasElements(t,r){const s=[],i=o=>{o.querySelectorAll("canvas").forEach(a=>{oe(a,t,r,!0)||s.push(a)})};for(const o of this.windows){const a=o.deref();let u;try{u=a&&a.document}catch(l){}u&&i(u)}for(const o of this.shadowDoms){const a=o.deref();a&&i(a)}return s}takeSnapshot(t){const{sampling:r,blockClass:s,blockSelector:i,dataURLOptions:o}=this.options,u=1e3/(typeof r=="number"?r:2);if(this.lastSnapshotTime&&t-this.lastSnapshotTime<u)return;this.lastSnapshotTime=t,this.getCanvasElements(s,i).forEach(c=>{var n;const d=this.mirror.getId(c);if(!this.snapshotInProgressMap.get(d)&&!(!this.mirror.hasNode(c)||c.width===0||c.height===0)){if(this.snapshotInProgressMap.set(d,!0),["webgl","webgl2"].includes(c.__context)){const h=c.getContext(c.__context);((n=h==null?void 0:h.getContextAttributes())==null?void 0:n.preserveDrawingBuffer)===!1&&h.clear(h.COLOR_BUFFER_BIT)}createImageBitmap(c).then(h=>{var f;(f=this.worker)==null||f.postMessage({id:d,bitmap:h,width:c.width,height:c.height,dataURLOptions:o},[h])}).catch(()=>{this.snapshotInProgressMap.delete(d)})}})}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const s=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,s)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const s=this.pendingCanvasMutations.get(t);if(!s||r===-1)return;const i=s.map(a=>{const c=a,{type:u}=c;return Ue(c,["type"])}),{type:o}=s[0];this.mutationCb({id:r,type:o,commands:i}),this.pendingCanvasMutations.delete(t)}}class ju{constructor(t){R(this,"trackedLinkElements",new WeakSet),R(this,"mutationCb"),R(this,"adoptedStyleSheetCb"),R(this,"styleMirror",new Ws),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const s={id:r,styleIds:[]},i=[];for(const o of t){let a;this.styleMirror.has(o)?a=this.styleMirror.getId(o):(a=this.styleMirror.add(o),i.push({styleId:a,rules:Array.from(o.rules||CSSRule,(u,l)=>({rule:kn(u,o.href),index:l}))})),s.styleIds.push(a)}i.length>0&&(s.styles=i),this.adoptedStyleSheetCb(s)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class Vu{constructor(){R(this,"nodeMap",new WeakMap),R(this,"active",!1)}inOtherBuffer(t,r){const s=this.nodeMap.get(t);return s&&Array.from(s).some(i=>i!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}}let ee,Rt,St,kt=!1;try{if(Array.from([1],e=>e*2)[0]!==2){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Gs=e.contentWindow)==null?void 0:Gs.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}const pe=Pn();function Te(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:s,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:u=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:n=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:m,maskTextFn:p,hooks:g,packFn:b,sampling:y={},dataURLOptions:w={},mousemoveWait:C,recordDOM:v=!0,recordCanvas:S=!1,recordCrossOriginIframes:E=!1,recordAfter:M=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:I=!1,collectFonts:N=!1,inlineImages:F=!1,plugins:T,keepIframeSrcFn:x=()=>!1,ignoreCSSAttributes:ue=new Set([]),errorHandler:ae}=e;fu(ae);const V=E?window.parent===window:!0;let k=!1;if(!V)try{window.parent.document&&(k=!1)}catch(L){k=!0}if(V&&!t)throw new Error("emit function is required");if(!V&&!k)return()=>{};C!==void 0&&y.mousemove===void 0&&(y.mousemove=C),pe.reset();const X=d===!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}:h!==void 0?h:{password:!0},te=Wn(f);Ls();let Z,G=0;const Re=L=>{for(const re of T||[])re.eventProcessor&&(L=re.eventProcessor(L));return b&&!k&&(L=b(L)),L};ee=(L,re)=>{var q;const K=L;if(K.timestamp=Xe(),(q=ke[0])!=null&&q.isFrozen()&&K.type!==_.FullSnapshot&&!(K.type===_.IncrementalSnapshot&&K.data.source===A.Mutation)&&ke.forEach(ce=>ce.unfreeze()),V)t==null||t(Re(K),re);else if(k){const ce={type:"rrweb",event:Re(K),origin:window.location.origin,isCheckout:re};window.parent.postMessage(ce,"*")}if(K.type===_.FullSnapshot)Z=K,G=0;else if(K.type===_.IncrementalSnapshot){if(K.data.source===A.Mutation&&K.data.isAttachIframe)return;G++;const ce=s&&G>=s,H=r&&K.timestamp-Z.timestamp>r;(ce||H)&&Rt(!0)}};const O=L=>{ee({type:_.IncrementalSnapshot,data:P({source:A.Mutation},L)})},we=L=>ee({type:_.IncrementalSnapshot,data:P({source:A.Scroll},L)}),fe=L=>ee({type:_.IncrementalSnapshot,data:P({source:A.CanvasMutation},L)}),Ze=L=>ee({type:_.IncrementalSnapshot,data:P({source:A.AdoptedStyleSheet},L)}),le=new ju({mutationCb:O,adoptedStyleSheetCb:Ze}),de=new Nu({mirror:pe,mutationCb:O,stylesheetManager:le,recordCrossOriginIframes:E,wrappedEmit:ee});for(const L of T||[])L.getMirror&&L.getMirror({nodeMirror:pe,crossOriginIframeMirror:de.crossOriginIframeMirror,crossOriginIframeStyleMirror:de.crossOriginIframeStyleMirror});const _e=new Vu;St=new zu({recordCanvas:S,mutationCb:fe,win:window,blockClass:i,blockSelector:o,mirror:pe,sampling:y.canvas,dataURLOptions:w});const Me=new Ou({mutationCb:O,scrollCb:we,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:n,maskInputOptions:X,dataURLOptions:w,maskTextFn:p,maskInputFn:m,recordCanvas:S,inlineImages:F,sampling:y,slimDOMOptions:te,iframeManager:de,stylesheetManager:le,canvasManager:St,keepIframeSrcFn:x,processedNodeManager:_e},mirror:pe});Rt=(L=!1)=>{if(!v)return;ee({type:_.Meta,data:{href:window.location.href,width:_s(),height:Ts()}},L),le.reset(),Me.init(),ke.forEach(q=>q.lock());const re=Da(document,{mirror:pe,blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:n,maskAllInputs:X,maskTextFn:p,maskInputFn:m,slimDOM:te,dataURLOptions:w,recordCanvas:S,inlineImages:F,onSerialize:q=>{Ye(q,pe)&&de.addIframe(q),Us(q,pe)&&le.trackLinkElement(q),Ie(q)&&Me.addShadowRoot(B.shadowRoot(q),document)},onIframeLoad:(q,K)=>{de.attachIframe(q,K),q.contentWindow&&St.addWindow(q.contentWindow),Me.observeAttachShadow(q)},onStylesheetLoad:(q,K)=>{le.attachLinkElement(q,K)},keepIframeSrcFn:x});if(!re)return console.warn("Failed to snapshot the document");ee({type:_.FullSnapshot,data:{node:re,initialOffset:As(window)}},L),ke.forEach(q=>q.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&le.adoptStyleSheets(document.adoptedStyleSheets,pe.getId(document))};try{const L=[],re=K=>{var ce;return $(Mu)({mutationCb:O,mousemoveCb:(H,Xt)=>ee({type:_.IncrementalSnapshot,data:{source:Xt,positions:H}}),mouseInteractionCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.MouseInteraction},H)}),scrollCb:we,viewportResizeCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.ViewportResize},H)}),inputCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.Input},H)}),mediaInteractionCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.MediaInteraction},H)}),styleSheetRuleCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.StyleSheetRule},H)}),styleDeclarationCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.StyleDeclaration},H)}),canvasMutationCb:fe,fontCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.Font},H)}),selectionCb:H=>{ee({type:_.IncrementalSnapshot,data:P({source:A.Selection},H)})},customElementCb:H=>{ee({type:_.IncrementalSnapshot,data:P({source:A.CustomElement},H)})},blockClass:i,ignoreClass:a,ignoreSelector:u,maskTextClass:l,maskTextSelector:c,maskInputOptions:X,inlineStylesheet:n,sampling:y,recordDOM:v,recordCanvas:S,inlineImages:F,userTriggeredOnInput:I,collectFonts:N,doc:K,maskInputFn:m,maskTextFn:p,keepIframeSrcFn:x,blockSelector:o,slimDOMOptions:te,dataURLOptions:w,mirror:pe,iframeManager:de,stylesheetManager:le,shadowDomManager:Me,processedNodeManager:_e,canvasManager:St,ignoreCSSAttributes:ue,plugins:((ce=T==null?void 0:T.filter(H=>H.observer))==null?void 0:ce.map(H=>({observer:H.observer,options:H.options,callback:Xt=>ee({type:_.Plugin,data:{plugin:H.name,payload:Xt}})})))||[]},g)};de.addLoadListener(K=>{try{L.push(re(K.contentDocument))}catch(ce){console.warn(ce)}});const q=()=>{Rt(),L.push(re(document)),kt=!0};return["interactive","complete"].includes(document.readyState)?q():(L.push(ne("DOMContentLoaded",()=>{ee({type:_.DomContentLoaded,data:{}}),M==="DOMContentLoaded"&&q()})),L.push(ne("load",()=>{ee({type:_.Load,data:{}}),M==="load"&&q()},window))),()=>{L.forEach(K=>{try{K()}catch(ce){String(ce).toLowerCase().includes("cross-origin")||console.warn(ce)}}),_e.destroy(),kt=!1,du()}}catch(L){console.warn(L)}}Te.addCustomEvent=(e,t)=>{if(!kt)throw new Error("please add custom event after start recording");ee({type:_.Custom,data:{tag:e,payload:t}})};Te.freezePage=()=>{ke.forEach(e=>e.freeze())};Te.takeFullSnapshot=e=>{if(!kt)throw new Error("please take full snapshot after start recording");Rt(e)};Te.mirror=pe;function qu(e){return{all:e=e||new Map,on:function(t,r){var s=e.get(t);s?s.push(r):e.set(t,[r])},off:function(t,r){var s=e.get(t);s&&(r?s.splice(s.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var s=e.get(t);s&&s.slice().map(function(i){i(r)}),(s=e.get("*"))&&s.slice().map(function(i){i(t,r)})}}}function Gu(e=window,t=document){if("scrollBehavior"in t.documentElement.style&&e.__forceSmoothScrollPolyfill__!==!0)return;const r=e.HTMLElement||e.Element,s=468,i={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:r.prototype.scroll||l,scrollIntoView:r.prototype.scrollIntoView},o=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now;function a(b){const y=["MSIE ","Trident/","Edge/"];return new RegExp(y.join("|")).test(b)}const u=a(e.navigator.userAgent)?1:0;function l(b,y){this.scrollLeft=b,this.scrollTop=y}function c(b){return .5*(1-Math.cos(Math.PI*b))}function n(b){if(b===null||typeof b!="object"||b.behavior===void 0||b.behavior==="auto"||b.behavior==="instant")return!0;if(typeof b=="object"&&b.behavior==="smooth")return!1;throw new TypeError("behavior member of ScrollOptions "+b.behavior+" is not a valid value for enumeration ScrollBehavior.")}function d(b,y){if(y==="Y")return b.clientHeight+u<b.scrollHeight;if(y==="X")return b.clientWidth+u<b.scrollWidth}function h(b,y){const w=e.getComputedStyle(b,null)["overflow"+y];return w==="auto"||w==="scroll"}function f(b){const y=d(b,"Y")&&h(b,"Y"),w=d(b,"X")&&h(b,"X");return y||w}function m(b){for(;b!==t.body&&f(b)===!1;)b=b.parentNode||b.host;return b}function p(b){const y=o();let w,C,v,S=(y-b.startTime)/s;S=S>1?1:S,w=c(S),C=b.startX+(b.x-b.startX)*w,v=b.startY+(b.y-b.startY)*w,b.method.call(b.scrollable,C,v),(C!==b.x||v!==b.y)&&e.requestAnimationFrame(p.bind(e,b))}function g(b,y,w){let C,v,S,E;const M=o();b===t.body?(C=e,v=e.scrollX||e.pageXOffset,S=e.scrollY||e.pageYOffset,E=i.scroll):(C=b,v=b.scrollLeft,S=b.scrollTop,E=l),p({scrollable:C,method:E,startTime:M,startX:v,startY:S,x:y,y:w})}e.scroll=e.scrollTo=function(){if(arguments[0]!==void 0){if(n(arguments[0])===!0){i.scroll.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:e.scrollY||e.pageYOffset);return}g.call(e,t.body,arguments[0].left!==void 0?~~arguments[0].left:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?~~arguments[0].top:e.scrollY||e.pageYOffset)}},e.scrollBy=function(){if(arguments[0]!==void 0){if(n(arguments[0])){i.scrollBy.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:0,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:0);return}g.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset))}},r.prototype.scroll=r.prototype.scrollTo=function(){if(arguments[0]===void 0)return;if(n(arguments[0])===!0){if(typeof arguments[0]=="number"&&arguments[1]===void 0)throw new SyntaxError("Value could not be converted");i.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left:typeof arguments[0]!="object"?~~arguments[0]:this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top:arguments[1]!==void 0?~~arguments[1]:this.scrollTop);return}const b=arguments[0].left,y=arguments[0].top;g.call(this,this,typeof b=="undefined"?this.scrollLeft:~~b,typeof y=="undefined"?this.scrollTop:~~y)},r.prototype.scrollBy=function(){if(arguments[0]!==void 0){if(n(arguments[0])===!0){i.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop);return}this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior})}},r.prototype.scrollIntoView=function(){if(n(arguments[0])===!0){i.scrollIntoView.call(this,arguments[0]===void 0?!0:arguments[0]);return}const b=m(this),y=b.getBoundingClientRect(),w=this.getBoundingClientRect();b!==t.body?(g.call(this,b,b.scrollLeft+w.left-y.left,b.scrollTop+w.top-y.top),e.getComputedStyle(b).position!=="fixed"&&e.scrollBy({left:y.left,top:y.top,behavior:"smooth"})):e.scrollBy({left:w.left,top:w.top,behavior:"smooth"})}}class Hu{constructor(t=[],r){R(this,"timeOffset",0),R(this,"speed"),R(this,"actions"),R(this,"raf",null),R(this,"lastTimestamp"),this.actions=t,this.speed=r.speed}addAction(t){const r=this.raf===!0;if(!this.actions.length||this.actions[this.actions.length-1].delay<=t.delay)this.actions.push(t);else{const s=this.findActionIndex(t);this.actions.splice(s,0,t)}r&&(this.raf=requestAnimationFrame(this.rafCheck.bind(this)))}start(){this.timeOffset=0,this.lastTimestamp=performance.now(),this.raf=requestAnimationFrame(this.rafCheck.bind(this))}updateLiveTime(){this.raf===!0&&this.rafCheck()}rafCheck(){const t=performance.now();for(this.timeOffset+=(t-this.lastTimestamp)*this.speed,this.lastTimestamp=t;this.actions.length;){const r=this.actions[0];if(this.timeOffset>=r.delay)this.actions.shift(),r.doAction();else break}this.actions.length>0?this.raf=requestAnimationFrame(this.rafCheck.bind(this)):this.raf=!0}clear(){this.raf&&(this.raf!==!0&&cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0}setSpeed(t){this.speed=t}isActive(){return this.raf!==null}findActionIndex(t){let r=0,s=this.actions.length-1;for(;r<=s;){const i=Math.floor((r+s)/2);if(this.actions[i].delay<t.delay)r=i+1;else if(this.actions[i].delay>t.delay)s=i-1;else return i+1}return r}}function Cn(e,t){if(e.type===_.IncrementalSnapshot&&e.data.source===A.MouseMove&&e.data.positions&&e.data.positions.length){const r=e.data.positions[0].timeOffset,s=e.timestamp+r;return e.delay=s-t,s-t}return e.delay=e.timestamp-t,e.delay}/*! *****************************************************************************
|
|
164
|
+
`,Sn=typeof self!="undefined"&&self.Blob&&new Blob([No],{type:"text/javascript;charset=utf-8"});function $u(e){let t;try{if(t=Sn&&(self.URL||self.webkitURL).createObjectURL(Sn),!t)throw"";const r=new Worker(t,{name:e==null?void 0:e.name});return r.addEventListener("error",()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),r}catch(r){return new Worker("data:text/javascript;charset=utf-8,"+encodeURIComponent(No),{name:e==null?void 0:e.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}function zu(e){try{return typeof Worker!="undefined"&&e.origin!=null&&e.origin!=="null"}catch(t){return!1}}class ju{constructor(t){R(this,"pendingCanvasMutations",new Map),R(this,"rafStamps",{latestId:0,invokeId:null}),R(this,"options"),R(this,"mirror"),R(this,"shadowDoms",new Set),R(this,"windowsSet",new WeakSet),R(this,"windows",[]),R(this,"mutationCb"),R(this,"restoreHandlers",[]),R(this,"frozen",!1),R(this,"locked",!1),R(this,"snapshotInProgressMap",new Map),R(this,"worker",null),R(this,"lastSnapshotTime",0),R(this,"processMutation",(o,a)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(o)||this.pendingCanvasMutations.set(o,[]),this.pendingCanvasMutations.get(o).push(a)});const{sampling:r="all",win:s,recordCanvas:i}=t;t.sampling=r,this.mutationCb=t.mutationCb,this.mirror=t.mirror,this.options=t,i&&typeof r=="number"&&zu(s)&&(this.worker=this.initFPSWorker()),this.addWindow(s),i&&r==="all"&&(this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher()),i&&typeof r=="number"&&this.worker&&this.initCanvasFPSObserver()}reset(){var t;this.pendingCanvasMutations.clear(),this.restoreHandlers.forEach(r=>{try{r()}catch(s){}}),this.restoreHandlers=[],this.windowsSet=new WeakSet,this.windows=[],this.shadowDoms=new Set,(t=this.worker)==null||t.terminate(),this.worker=null,this.snapshotInProgressMap=new Map}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}addWindow(t){const{sampling:r="all",blockClass:s,blockSelector:i,recordCanvas:o}=this.options;if(!this.windowsSet.has(t)){if(o&&r==="all"&&this.initCanvasMutationObserver(t,s,i),o&&typeof r=="number"){const a=bn(t,s,i,!0);this.restoreHandlers.push(()=>{a()})}this.windowsSet.add(t),this.windows.push(new WeakRef(t))}}addShadowRoot(t){this.shadowDoms.add(new WeakRef(t))}resetShadowRoots(){this.shadowDoms=new Set}initFPSWorker(){const t=new $u;return t.onmessage=r=>{const s=r.data,{id:i}=s;if(this.snapshotInProgressMap.set(i,!1),!("base64"in s))return;const{base64:o,type:a,width:u,height:l}=s;this.mutationCb({id:i,type:Ce["2D"],commands:[{property:"clearRect",args:[0,0,u,l]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:o}],type:a}]},0,0]}]})},t}initCanvasFPSObserver(){let t;if(!this.windows.length&&!this.shadowDoms.size)return;const r=s=>{this.takeSnapshot(s),t=requestAnimationFrame(r)};t=requestAnimationFrame(r),this.restoreHandlers.push(()=>{t&&cancelAnimationFrame(t)})}initCanvasMutationObserver(t,r,s){const i=bn(t,r,s,!1),o=Uu(this.processMutation.bind(this),t,r,s),a=Wu(this.processMutation.bind(this),t,r,s);this.restoreHandlers.push(()=>{i(),o(),a()})}getCanvasElements(t,r){const s=[],i=o=>{o.querySelectorAll("canvas").forEach(a=>{oe(a,t,r,!0)||s.push(a)})};for(const o of this.windows){const a=o.deref();let u;try{u=a&&a.document}catch(l){}u&&i(u)}for(const o of this.shadowDoms){const a=o.deref();a&&i(a)}return s}takeSnapshot(t){const{sampling:r,blockClass:s,blockSelector:i,dataURLOptions:o}=this.options,u=1e3/(typeof r=="number"?r:2);if(this.lastSnapshotTime&&t-this.lastSnapshotTime<u)return;this.lastSnapshotTime=t,this.getCanvasElements(s,i).forEach(c=>{var n;const d=this.mirror.getId(c);if(!this.snapshotInProgressMap.get(d)&&!(!this.mirror.hasNode(c)||c.width===0||c.height===0)){if(this.snapshotInProgressMap.set(d,!0),["webgl","webgl2"].includes(c.__context)){const h=c.getContext(c.__context);((n=h==null?void 0:h.getContextAttributes())==null?void 0:n.preserveDrawingBuffer)===!1&&h.clear(h.COLOR_BUFFER_BIT)}createImageBitmap(c).then(h=>{var f;(f=this.worker)==null||f.postMessage({id:d,bitmap:h,width:c.width,height:c.height,dataURLOptions:o},[h])}).catch(()=>{this.snapshotInProgressMap.delete(d)})}})}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=r=>{this.rafStamps.latestId=r,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,r)=>{const s=this.mirror.getId(r);this.flushPendingCanvasMutationFor(r,s)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,r){if(this.frozen||this.locked)return;const s=this.pendingCanvasMutations.get(t);if(!s||r===-1)return;const i=s.map(a=>{const c=a,{type:u}=c;return Ue(c,["type"])}),{type:o}=s[0];this.mutationCb({id:r,type:o,commands:i}),this.pendingCanvasMutations.delete(t)}}class Vu{constructor(t){R(this,"trackedLinkElements",new WeakSet),R(this,"mutationCb"),R(this,"adoptedStyleSheetCb"),R(this,"styleMirror",new Ws),this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,r){"_cssText"in r.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:r.id,attributes:r.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,r){if(t.length===0)return;const s={id:r,styleIds:[]},i=[];for(const o of t){let a;this.styleMirror.has(o)?a=this.styleMirror.getId(o):(a=this.styleMirror.add(o),i.push({styleId:a,rules:Array.from(o.rules||CSSRule,(u,l)=>({rule:kn(u,o.href),index:l}))})),s.styleIds.push(a)}i.length>0&&(s.styles=i),this.adoptedStyleSheetCb(s)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}class qu{constructor(){R(this,"nodeMap",new WeakMap),R(this,"active",!1)}inOtherBuffer(t,r){const s=this.nodeMap.get(t);return s&&Array.from(s).some(i=>i!==r)}add(t,r){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(t,(this.nodeMap.get(t)||new Set).add(r))}destroy(){}}let ee,Rt,St,kt=!1;try{if(Array.from([1],e=>e*2)[0]!==2){const e=document.createElement("iframe");document.body.appendChild(e),Array.from=((Gs=e.contentWindow)==null?void 0:Gs.Array.from)||Array.from,document.body.removeChild(e)}}catch(e){console.debug("Unable to override Array.from",e)}const pe=Pn();function Te(e={}){const{emit:t,checkoutEveryNms:r,checkoutEveryNth:s,blockClass:i="rr-block",blockSelector:o=null,ignoreClass:a="rr-ignore",ignoreSelector:u=null,maskTextClass:l="rr-mask",maskTextSelector:c=null,inlineStylesheet:n=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:f,maskInputFn:m,maskTextFn:p,hooks:g,packFn:b,sampling:y={},dataURLOptions:w={},mousemoveWait:C,recordDOM:v=!0,recordCanvas:S=!1,recordCrossOriginIframes:E=!1,recordAfter:M=e.recordAfter==="DOMContentLoaded"?e.recordAfter:"load",userTriggeredOnInput:I=!1,collectFonts:N=!1,inlineImages:F=!1,plugins:T,keepIframeSrcFn:x=()=>!1,ignoreCSSAttributes:ue=new Set([]),errorHandler:ae}=e;fu(ae);const V=E?window.parent===window:!0;let k=!1;if(!V)try{window.parent.document&&(k=!1)}catch(L){k=!0}if(V&&!t)throw new Error("emit function is required");if(!V&&!k)return()=>{};C!==void 0&&y.mousemove===void 0&&(y.mousemove=C),pe.reset();const X=d===!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}:h!==void 0?h:{password:!0},te=Wn(f);Ls();let Z,G=0;const Re=L=>{for(const re of T||[])re.eventProcessor&&(L=re.eventProcessor(L));return b&&!k&&(L=b(L)),L};ee=(L,re)=>{var q;const K=L;if(K.timestamp=Xe(),(q=ke[0])!=null&&q.isFrozen()&&K.type!==_.FullSnapshot&&!(K.type===_.IncrementalSnapshot&&K.data.source===A.Mutation)&&ke.forEach(ce=>ce.unfreeze()),V)t==null||t(Re(K),re);else if(k){const ce={type:"rrweb",event:Re(K),origin:window.location.origin,isCheckout:re};window.parent.postMessage(ce,"*")}if(K.type===_.FullSnapshot)Z=K,G=0;else if(K.type===_.IncrementalSnapshot){if(K.data.source===A.Mutation&&K.data.isAttachIframe)return;G++;const ce=s&&G>=s,H=r&&K.timestamp-Z.timestamp>r;(ce||H)&&Rt(!0)}};const O=L=>{ee({type:_.IncrementalSnapshot,data:P({source:A.Mutation},L)})},we=L=>ee({type:_.IncrementalSnapshot,data:P({source:A.Scroll},L)}),fe=L=>ee({type:_.IncrementalSnapshot,data:P({source:A.CanvasMutation},L)}),Ze=L=>ee({type:_.IncrementalSnapshot,data:P({source:A.AdoptedStyleSheet},L)}),le=new Vu({mutationCb:O,adoptedStyleSheetCb:Ze}),de=new Nu({mirror:pe,mutationCb:O,stylesheetManager:le,recordCrossOriginIframes:E,wrappedEmit:ee});for(const L of T||[])L.getMirror&&L.getMirror({nodeMirror:pe,crossOriginIframeMirror:de.crossOriginIframeMirror,crossOriginIframeStyleMirror:de.crossOriginIframeStyleMirror});const _e=new qu;St=new ju({recordCanvas:S,mutationCb:fe,win:window,blockClass:i,blockSelector:o,mirror:pe,sampling:y.canvas,dataURLOptions:w});const Me=new Ou({mutationCb:O,scrollCb:we,bypassOptions:{blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:n,maskInputOptions:X,dataURLOptions:w,maskTextFn:p,maskInputFn:m,recordCanvas:S,inlineImages:F,sampling:y,slimDOMOptions:te,iframeManager:de,stylesheetManager:le,canvasManager:St,keepIframeSrcFn:x,processedNodeManager:_e},mirror:pe});Rt=(L=!1)=>{if(!v)return;ee({type:_.Meta,data:{href:window.location.href,width:_s(),height:Ts()}},L),le.reset(),Me.init(),ke.forEach(q=>q.lock());const re=Da(document,{mirror:pe,blockClass:i,blockSelector:o,maskTextClass:l,maskTextSelector:c,inlineStylesheet:n,maskAllInputs:X,maskTextFn:p,maskInputFn:m,slimDOM:te,dataURLOptions:w,recordCanvas:S,inlineImages:F,onSerialize:q=>{Ye(q,pe)&&de.addIframe(q),Us(q,pe)&&le.trackLinkElement(q),Ie(q)&&Me.addShadowRoot(B.shadowRoot(q),document)},onIframeLoad:(q,K)=>{de.attachIframe(q,K),q.contentWindow&&St.addWindow(q.contentWindow),Me.observeAttachShadow(q)},onStylesheetLoad:(q,K)=>{le.attachLinkElement(q,K)},keepIframeSrcFn:x});if(!re)return console.warn("Failed to snapshot the document");ee({type:_.FullSnapshot,data:{node:re,initialOffset:As(window)}},L),ke.forEach(q=>q.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&le.adoptStyleSheets(document.adoptedStyleSheets,pe.getId(document))};try{const L=[],re=K=>{var ce;return $(Mu)({mutationCb:O,mousemoveCb:(H,Xt)=>ee({type:_.IncrementalSnapshot,data:{source:Xt,positions:H}}),mouseInteractionCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.MouseInteraction},H)}),scrollCb:we,viewportResizeCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.ViewportResize},H)}),inputCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.Input},H)}),mediaInteractionCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.MediaInteraction},H)}),styleSheetRuleCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.StyleSheetRule},H)}),styleDeclarationCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.StyleDeclaration},H)}),canvasMutationCb:fe,fontCb:H=>ee({type:_.IncrementalSnapshot,data:P({source:A.Font},H)}),selectionCb:H=>{ee({type:_.IncrementalSnapshot,data:P({source:A.Selection},H)})},customElementCb:H=>{ee({type:_.IncrementalSnapshot,data:P({source:A.CustomElement},H)})},blockClass:i,ignoreClass:a,ignoreSelector:u,maskTextClass:l,maskTextSelector:c,maskInputOptions:X,inlineStylesheet:n,sampling:y,recordDOM:v,recordCanvas:S,inlineImages:F,userTriggeredOnInput:I,collectFonts:N,doc:K,maskInputFn:m,maskTextFn:p,keepIframeSrcFn:x,blockSelector:o,slimDOMOptions:te,dataURLOptions:w,mirror:pe,iframeManager:de,stylesheetManager:le,shadowDomManager:Me,processedNodeManager:_e,canvasManager:St,ignoreCSSAttributes:ue,plugins:((ce=T==null?void 0:T.filter(H=>H.observer))==null?void 0:ce.map(H=>({observer:H.observer,options:H.options,callback:Xt=>ee({type:_.Plugin,data:{plugin:H.name,payload:Xt}})})))||[]},g)};de.addLoadListener(K=>{try{L.push(re(K.contentDocument))}catch(ce){console.warn(ce)}});const q=()=>{Rt(),L.push(re(document)),kt=!0};return["interactive","complete"].includes(document.readyState)?q():(L.push(ne("DOMContentLoaded",()=>{ee({type:_.DomContentLoaded,data:{}}),M==="DOMContentLoaded"&&q()})),L.push(ne("load",()=>{ee({type:_.Load,data:{}}),M==="load"&&q()},window))),()=>{L.forEach(K=>{try{K()}catch(ce){String(ce).toLowerCase().includes("cross-origin")||console.warn(ce)}}),_e.destroy(),kt=!1,du()}}catch(L){console.warn(L)}}Te.addCustomEvent=(e,t)=>{if(!kt)throw new Error("please add custom event after start recording");ee({type:_.Custom,data:{tag:e,payload:t}})};Te.freezePage=()=>{ke.forEach(e=>e.freeze())};Te.takeFullSnapshot=e=>{if(!kt)throw new Error("please take full snapshot after start recording");Rt(e)};Te.mirror=pe;function Gu(e){return{all:e=e||new Map,on:function(t,r){var s=e.get(t);s?s.push(r):e.set(t,[r])},off:function(t,r){var s=e.get(t);s&&(r?s.splice(s.indexOf(r)>>>0,1):e.set(t,[]))},emit:function(t,r){var s=e.get(t);s&&s.slice().map(function(i){i(r)}),(s=e.get("*"))&&s.slice().map(function(i){i(t,r)})}}}function Hu(e=window,t=document){if("scrollBehavior"in t.documentElement.style&&e.__forceSmoothScrollPolyfill__!==!0)return;const r=e.HTMLElement||e.Element,s=468,i={scroll:e.scroll||e.scrollTo,scrollBy:e.scrollBy,elementScroll:r.prototype.scroll||l,scrollIntoView:r.prototype.scrollIntoView},o=e.performance&&e.performance.now?e.performance.now.bind(e.performance):Date.now;function a(b){const y=["MSIE ","Trident/","Edge/"];return new RegExp(y.join("|")).test(b)}const u=a(e.navigator.userAgent)?1:0;function l(b,y){this.scrollLeft=b,this.scrollTop=y}function c(b){return .5*(1-Math.cos(Math.PI*b))}function n(b){if(b===null||typeof b!="object"||b.behavior===void 0||b.behavior==="auto"||b.behavior==="instant")return!0;if(typeof b=="object"&&b.behavior==="smooth")return!1;throw new TypeError("behavior member of ScrollOptions "+b.behavior+" is not a valid value for enumeration ScrollBehavior.")}function d(b,y){if(y==="Y")return b.clientHeight+u<b.scrollHeight;if(y==="X")return b.clientWidth+u<b.scrollWidth}function h(b,y){const w=e.getComputedStyle(b,null)["overflow"+y];return w==="auto"||w==="scroll"}function f(b){const y=d(b,"Y")&&h(b,"Y"),w=d(b,"X")&&h(b,"X");return y||w}function m(b){for(;b!==t.body&&f(b)===!1;)b=b.parentNode||b.host;return b}function p(b){const y=o();let w,C,v,S=(y-b.startTime)/s;S=S>1?1:S,w=c(S),C=b.startX+(b.x-b.startX)*w,v=b.startY+(b.y-b.startY)*w,b.method.call(b.scrollable,C,v),(C!==b.x||v!==b.y)&&e.requestAnimationFrame(p.bind(e,b))}function g(b,y,w){let C,v,S,E;const M=o();b===t.body?(C=e,v=e.scrollX||e.pageXOffset,S=e.scrollY||e.pageYOffset,E=i.scroll):(C=b,v=b.scrollLeft,S=b.scrollTop,E=l),p({scrollable:C,method:E,startTime:M,startX:v,startY:S,x:y,y:w})}e.scroll=e.scrollTo=function(){if(arguments[0]!==void 0){if(n(arguments[0])===!0){i.scroll.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:e.scrollY||e.pageYOffset);return}g.call(e,t.body,arguments[0].left!==void 0?~~arguments[0].left:e.scrollX||e.pageXOffset,arguments[0].top!==void 0?~~arguments[0].top:e.scrollY||e.pageYOffset)}},e.scrollBy=function(){if(arguments[0]!==void 0){if(n(arguments[0])){i.scrollBy.call(e,arguments[0].left!==void 0?arguments[0].left:typeof arguments[0]!="object"?arguments[0]:0,arguments[0].top!==void 0?arguments[0].top:arguments[1]!==void 0?arguments[1]:0);return}g.call(e,t.body,~~arguments[0].left+(e.scrollX||e.pageXOffset),~~arguments[0].top+(e.scrollY||e.pageYOffset))}},r.prototype.scroll=r.prototype.scrollTo=function(){if(arguments[0]===void 0)return;if(n(arguments[0])===!0){if(typeof arguments[0]=="number"&&arguments[1]===void 0)throw new SyntaxError("Value could not be converted");i.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left:typeof arguments[0]!="object"?~~arguments[0]:this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top:arguments[1]!==void 0?~~arguments[1]:this.scrollTop);return}const b=arguments[0].left,y=arguments[0].top;g.call(this,this,typeof b=="undefined"?this.scrollLeft:~~b,typeof y=="undefined"?this.scrollTop:~~y)},r.prototype.scrollBy=function(){if(arguments[0]!==void 0){if(n(arguments[0])===!0){i.elementScroll.call(this,arguments[0].left!==void 0?~~arguments[0].left+this.scrollLeft:~~arguments[0]+this.scrollLeft,arguments[0].top!==void 0?~~arguments[0].top+this.scrollTop:~~arguments[1]+this.scrollTop);return}this.scroll({left:~~arguments[0].left+this.scrollLeft,top:~~arguments[0].top+this.scrollTop,behavior:arguments[0].behavior})}},r.prototype.scrollIntoView=function(){if(n(arguments[0])===!0){i.scrollIntoView.call(this,arguments[0]===void 0?!0:arguments[0]);return}const b=m(this),y=b.getBoundingClientRect(),w=this.getBoundingClientRect();b!==t.body?(g.call(this,b,b.scrollLeft+w.left-y.left,b.scrollTop+w.top-y.top),e.getComputedStyle(b).position!=="fixed"&&e.scrollBy({left:y.left,top:y.top,behavior:"smooth"})):e.scrollBy({left:w.left,top:w.top,behavior:"smooth"})}}class Yu{constructor(t=[],r){R(this,"timeOffset",0),R(this,"speed"),R(this,"actions"),R(this,"raf",null),R(this,"lastTimestamp"),this.actions=t,this.speed=r.speed}addAction(t){const r=this.raf===!0;if(!this.actions.length||this.actions[this.actions.length-1].delay<=t.delay)this.actions.push(t);else{const s=this.findActionIndex(t);this.actions.splice(s,0,t)}r&&(this.raf=requestAnimationFrame(this.rafCheck.bind(this)))}start(){this.timeOffset=0,this.lastTimestamp=performance.now(),this.raf=requestAnimationFrame(this.rafCheck.bind(this))}updateLiveTime(){this.raf===!0&&this.rafCheck()}rafCheck(){const t=performance.now();for(this.timeOffset+=(t-this.lastTimestamp)*this.speed,this.lastTimestamp=t;this.actions.length;){const r=this.actions[0];if(this.timeOffset>=r.delay)this.actions.shift(),r.doAction();else break}this.actions.length>0?this.raf=requestAnimationFrame(this.rafCheck.bind(this)):this.raf=!0}clear(){this.raf&&(this.raf!==!0&&cancelAnimationFrame(this.raf),this.raf=null),this.actions.length=0}setSpeed(t){this.speed=t}isActive(){return this.raf!==null}findActionIndex(t){let r=0,s=this.actions.length-1;for(;r<=s;){const i=Math.floor((r+s)/2);if(this.actions[i].delay<t.delay)r=i+1;else if(this.actions[i].delay>t.delay)s=i-1;else return i+1}return r}}function Cn(e,t){if(e.type===_.IncrementalSnapshot&&e.data.source===A.MouseMove&&e.data.positions&&e.data.positions.length){const r=e.data.positions[0].timeOffset,s=e.timestamp+r;return e.delay=s-t,s-t}return e.delay=e.timestamp-t,e.delay}/*! *****************************************************************************
|
|
165
165
|
Copyright (c) Microsoft Corporation.
|
|
166
166
|
|
|
167
167
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -174,7 +174,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
174
174
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
175
175
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
176
176
|
PERFORMANCE OF THIS SOFTWARE.
|
|
177
|
-
***************************************************************************** */function En(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s,i,o=r.call(e),a=[];try{for(;(t===void 0||t-- >0)&&!(s=o.next()).done;)a.push(s.value)}catch(u){i={error:u}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}var He;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(He||(He={}));var Oo={type:"xstate.init"};function es(e){return e===void 0?[]:[].concat(e)}function ze(e){return{type:"xstate.assign",assignment:e}}function xn(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function Pt(e){return function(t){return e===t}}function Io(e){return typeof e=="string"?{type:e}:e}function Rn(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Pt(e)}}function Mn(e,t,r){var s=t,i=!1;return[e.filter(function(o){if(o.type==="xstate.assign"){i=!0;var a=Object.assign({},s);return typeof o.assignment=="function"?a=o.assignment(s,r):Object.keys(o.assignment).forEach(function(u){a[u]=typeof o.assignment[u]=="function"?o.assignment[u](s,r):o.assignment[u]}),s=a,!1}return!0}),s,i]}function Do(e,t){t===void 0&&(t={});var r=En(Mn(es(e.states[e.initial].entry).map(function(a){return xn(a,t.actions)}),e.context,Oo),2),s=r[0],i=r[1],o={config:e,_options:t,initialState:{value:e.initial,actions:s,context:i,matches:Pt(e.initial)},transition:function(a,u){var l,c,n=typeof a=="string"?{value:a,context:e.context}:a,d=n.value,h=n.context,f=Io(u),m=e.states[d];if(m.on){var p=es(m.on[f.type]);try{for(var g=function(k){var X=typeof Symbol=="function"&&Symbol.iterator,te=X&&k[X],Z=0;if(te)return te.call(k);if(k&&typeof k.length=="number")return{next:function(){return k&&Z>=k.length&&(k=void 0),{value:k&&k[Z++],done:!k}}};throw new TypeError(X?"Object is not iterable.":"Symbol.iterator is not defined.")}(p),b=g.next();!b.done;b=g.next()){var y=b.value;if(y===void 0)return Rn(d,h);var w=typeof y=="string"?{target:y}:y,C=w.target,v=w.actions,S=v===void 0?[]:v,E=w.cond,M=E===void 0?function(){return!0}:E,I=C===void 0,N=C!=null?C:d,F=e.states[N];if(M(h,f)){var T=En(Mn((I?es(S):[].concat(m.exit,S,F.entry).filter(function(k){return k})).map(function(k){return xn(k,o._options.actions)}),h,f),3),x=T[0],ue=T[1],ae=T[2],V=C!=null?C:d;return{value:V,context:ue,actions:x,changed:C!==d||x.length>0||ae,matches:Pt(V)}}}}catch(k){l={error:k}}finally{try{b&&!b.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}}return Rn(d,h)}};return o}var Nn=function(e,t){return e.actions.forEach(function(r){var s=r.exec;return s&&s(e.context,t)})};function Ao(e){var t=e.initialState,r=He.NotStarted,s=new Set,i={_machine:e,send:function(o){r===He.Running&&(t=e.transition(t,o),Nn(t,Io(o)),s.forEach(function(a){return a(t)}))},subscribe:function(o){return s.add(o),o(t),{unsubscribe:function(){return s.delete(o)}}},start:function(o){if(o){var a=typeof o=="object"?o:{context:e.config.context,value:o};t={value:a.value,actions:[],context:a.context,matches:Pt(a.value)}}return r=He.Running,Nn(t,Oo),i},stop:function(){return r=He.Stopped,s.clear(),i},get state(){return t},get status(){return r}};return i}function Yu(e,t){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.type===_.Meta&&s.timestamp<=t)return e.slice(r)}return e}function Xu(e,{getCastFn:t,applyEventsSynchronously:r,emitter:s}){const i=Do({id:"player",context:e,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:ze({lastPlayedEvent:(o,a)=>a.type==="CAST_EVENT"?a.payload.event:o.lastPlayedEvent}),recordTimeOffset:ze((o,a)=>{let u=o.timeOffset;return"payload"in a&&"timeOffset"in a.payload&&(u=a.payload.timeOffset),se(P({},o),{timeOffset:u,baselineTime:o.events[0].timestamp+u})}),play(o){var a;const{timer:u,events:l,baselineTime:c,lastPlayedEvent:n}=o;u.clear();for(const m of l)Cn(m,c);const d=Yu(l,c);let h=n==null?void 0:n.timestamp;(n==null?void 0:n.type)===_.IncrementalSnapshot&&n.data.source===A.MouseMove&&(h=n.timestamp+((a=n.data.positions[0])==null?void 0:a.timeOffset)),c<(h||0)&&s.emit(z.PlayBack);const f=new Array;for(const m of d)if(!(h&&h<c&&(m.timestamp<=h||m===n)))if(m.timestamp<c)f.push(m);else{const p=t(m,!1);u.addAction({doAction:()=>{p()},delay:m.delay})}r(f),s.emit(z.Flush),u.start()},pause(o){o.timer.clear()},resetLastPlayedEvent:ze(o=>se(P({},o),{lastPlayedEvent:null})),startLive:ze({baselineTime:(o,a)=>(o.timer.start(),a.type==="TO_LIVE"&&a.payload.baselineTime?a.payload.baselineTime:Date.now())}),addEvent:ze((o,a)=>{const{baselineTime:u,timer:l,events:c}=o;if(a.type==="ADD_EVENT"){const{event:n}=a.payload;Cn(n,u);let d=c.length-1;if(!c[d]||c[d].timestamp<=n.timestamp)c.push(n);else{let m=-1,p=0;for(;p<=d;){const g=Math.floor((p+d)/2);c[g].timestamp<=n.timestamp?p=g+1:d=g-1}m===-1&&(m=p),c.splice(m,0,n)}const h=n.timestamp<u,f=t(n,h);h?f():l.isActive()&&l.addAction({doAction:()=>{f()},delay:n.delay})}return se(P({},o),{events:c})})}});return Ao(i)}function Ju(e){const t=Do({id:"speed",context:e,initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:(r,s)=>{"payload"in s&&r.timer.setSpeed(s.payload.speed)},recordSpeed:ze({normalSpeed:r=>r.timer.speed}),restoreSpeed:r=>{r.timer.setSpeed(r.normalSpeed)}}});return Ao(t)}const Qu=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],On=new Map;function To(e,t){let r=On.get(e);return r||(r=new Map,On.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function De(e,t,r){return async s=>{if(s&&typeof s=="object"&&"rr_type"in s)if(r&&(r.isUnchanged=!1),s.rr_type==="ImageBitmap"&&"args"in s){const i=await De(e,t,r)(s.args);return await createImageBitmap.apply(null,i)}else if("index"in s){if(r||t===null)return s;const{rr_type:i,index:o}=s;return To(t,i)[o]}else if("args"in s){const{rr_type:i,args:o}=s,a=window[i];return new a(...await Promise.all(o.map(De(e,t,r))))}else{if("base64"in s)return Du(s.base64);if("src"in s){const i=e.get(s.src);if(i)return i;{const o=new Image;return o.src=s.src,e.set(s.src,o),o}}else if("data"in s&&s.rr_type==="Blob"){const i=await Promise.all(s.data.map(De(e,t,r)));return new Blob(i,{type:s.type})}}else if(Array.isArray(s))return await Promise.all(s.map(De(e,t,r)));return s}}function Zu(e,t){try{return t===Ce.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(r){return null}}const Ku=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function ec(e,t){if(!(t!=null&&t.constructor))return;const{name:r}=t.constructor;if(!Ku.includes(r))return;const s=To(e,r);s.includes(t)||s.push(t)}async function tc({mutation:e,target:t,type:r,imageMap:s,errorHandler:i}){try{const o=Zu(t,r);if(!o)return;if(e.setter){o[e.property]=e.args[0];return}const a=o[e.property],u=await Promise.all(e.args.map(De(s,o))),l=a.apply(o,u);ec(o,l);const c=!1}catch(o){i(e,o)}}async function rc({event:e,mutations:t,target:r,imageMap:s,errorHandler:i}){const o=r.getContext("2d");if(!o){i(t[0],new Error("Canvas context is null"));return}const a=t.map(async l=>Promise.all(l.args.map(De(s,o))));(await Promise.all(a)).forEach((l,c)=>{const n=t[c];try{if(n.setter){o[n.property]=n.args[0];return}const d=o[n.property];n.property==="drawImage"&&typeof n.args[0]=="string"?(s.get(e),d.apply(o,n.args)):d.apply(o,l)}catch(d){i(n,d)}})}async function as({event:e,mutation:t,target:r,imageMap:s,canvasEventMap:i,errorHandler:o}){try{const a=i.get(e)||t,u="commands"in a?a.commands:[a];if([Ce.WebGL,Ce.WebGL2].includes(t.type)){for(let l=0;l<u.length;l++){const c=u[l];await tc({mutation:c,type:t.type,target:r,imageMap:s,errorHandler:o})}return}await rc({event:e,mutations:u,target:r,imageMap:s,errorHandler:o})}catch(a){o(t,a)}}class sc{constructor(t){R(this,"mediaMap",new Map),R(this,"warn"),R(this,"service"),R(this,"speedService"),R(this,"emitter"),R(this,"getCurrentTime"),R(this,"metadataCallbackMap",new Map),this.warn=t.warn,this.service=t.service,this.speedService=t.speedService,this.emitter=t.emitter,this.getCurrentTime=t.getCurrentTime,this.emitter.on(z.Start,this.start.bind(this)),this.emitter.on(z.SkipStart,this.start.bind(this)),this.emitter.on(z.Pause,this.pause.bind(this)),this.emitter.on(z.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(t={pause:!1}){this.mediaMap.forEach((r,s)=>{this.syncTargetWithState(s),t.pause&&s.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:t,target:r,mediaState:s}){if(s.isPlaying){const o=(t-s.lastInteractionTimeOffset)/1e3*s.playbackRate,a="duration"in r&&r.duration;if(Number.isNaN(a)){this.waitForMetadata(r);return}let u=s.currentTimeAtLastInteraction+o;r.loop&&a!==!1&&(u=u%a),r.currentTime=u}else r.pause(),r.currentTime=s.currentTimeAtLastInteraction}waitForMetadata(t){if(this.metadataCallbackMap.has(t)||!("addEventListener"in t))return;const r=()=>{this.metadataCallbackMap.delete(t);const s=this.mediaMap.get(t);s&&this.seekTo({time:this.getCurrentTime(),target:t,mediaState:s})};this.metadataCallbackMap.set(t,r),t.addEventListener("loadedmetadata",r,{once:!0})}getMediaStateFromMutation({target:t,timeOffset:r,mutation:s}){var f,m,p,g,b;const i=this.mediaMap.get(t),{type:o,playbackRate:a,currentTime:u,muted:l,volume:c,loop:n}=s;return{isPlaying:o===Oe.Play||o!==Oe.Pause&&((i==null?void 0:i.isPlaying)||t.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(f=u!=null?u:i==null?void 0:i.currentTimeAtLastInteraction)!=null?f:0,lastInteractionTimeOffset:r,playbackRate:(m=a!=null?a:i==null?void 0:i.playbackRate)!=null?m:1,volume:(p=c!=null?c:i==null?void 0:i.volume)!=null?p:1,muted:(g=l!=null?l:i==null?void 0:i.muted)!=null?g:t.getAttribute("muted")===null,loop:(b=n!=null?n:i==null?void 0:i.loop)!=null?b:t.getAttribute("loop")===null}}syncTargetWithState(t){const r=this.mediaMap.get(t);if(!r)return;const{muted:s,loop:i,volume:o,isPlaying:a}=r,u=this.service.state.matches("paused"),l=r.playbackRate*this.speedService.state.context.timer.speed;try{this.seekTo({time:this.getCurrentTime(),target:t,mediaState:r}),t.volume!==o&&(t.volume=o),t.muted=s,t.loop=i,t.playbackRate!==l&&(t.playbackRate=l),a&&!u?t.play():t.pause()}catch(c){this.warn(`Failed to replay media interactions: ${c.message||c}`)}}addMediaElements(t,r,s){if(!["AUDIO","VIDEO"].includes(t.nodeName))return;const i=t,o=s.getMeta(i);if(!o||!("attributes"in o))return;const a=this.service.state.matches("paused"),u=o.attributes;let l=!1;u.rr_mediaState?l=u.rr_mediaState==="played":l=i.getAttribute("autoplay")!==null,l&&a&&i.pause();let c=1;typeof u.rr_mediaPlaybackRate=="number"&&(c=u.rr_mediaPlaybackRate);let n=!1;typeof u.rr_mediaMuted=="boolean"?n=u.rr_mediaMuted:n=i.getAttribute("muted")!==null;let d=!1;typeof u.rr_mediaLoop=="boolean"?d=u.rr_mediaLoop:d=i.getAttribute("loop")!==null;let h=1;typeof u.rr_mediaVolume=="number"&&(h=u.rr_mediaVolume);let f=0;typeof u.rr_mediaCurrentTime=="number"&&(f=u.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:l,currentTimeAtLastInteraction:f,lastInteractionTimeOffset:r,playbackRate:c,volume:h,muted:n,loop:d}),this.syncTargetWithState(i)}mediaMutation({target:t,timeOffset:r,mutation:s}){this.mediaMap.set(t,this.getMediaStateFromMutation({target:t,timeOffset:r,mutation:s})),this.syncTargetWithState(t)}isSupportedMediaElement(t){return["AUDIO","VIDEO"].includes(t.nodeName)}reset(){this.mediaMap.clear()}}function Ct(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e,s=r.open,i=s&&r.matches("dialog:modal"),o=r.getAttribute("rr_open_mode"),a=typeof(t==null?void 0:t.attributes.open)=="string"||typeof r.getAttribute("open")=="string",u=o==="modal";if(!(s&&!(i&&o==="non-modal"||!i&&u))){if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}s&&r.close(),a&&(u?r.showModal():r.show())}}function ic(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e;if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}t.attributes.open===null&&(r.removeAttribute("open"),r.removeAttribute("rr_open_mode"))}const nc=5*1e3,oc=qu,In="[replayer]",ts={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Dn(e){return e.type==_.IncrementalSnapshot&&(e.data.source==A.TouchMove||e.data.source==A.MouseInteraction&&e.data.type==j.TouchStart)}class ac{constructor(t,r){if(R(this,"wrapper"),R(this,"iframe"),R(this,"UNSAFE_replayCanvas",!1),R(this,"service"),R(this,"speedService"),R(this,"config"),R(this,"usingVirtualDom",!1),R(this,"virtualDom",new Qe),R(this,"mouse"),R(this,"mouseTail",null),R(this,"tailPositions",[]),R(this,"emitter",oc()),R(this,"nextUserInteractionEvent"),R(this,"legacy_missingNodeRetryMap",{}),R(this,"cache",Di()),R(this,"imageMap",new Map),R(this,"canvasEventMap",new Map),R(this,"mirror",Pn()),R(this,"styleMirror",new Ws),R(this,"mediaManager"),R(this,"firstFullSnapshot",null),R(this,"newDocumentQueue",[]),R(this,"mousePos",null),R(this,"touchActive",null),R(this,"lastMouseDownEvent",null),R(this,"lastHoveredRootNode"),R(this,"lastSelectionData",null),R(this,"constructedStyleMutations",[]),R(this,"adoptedStyleSheets",[]),R(this,"handleResize",u=>{this.iframe.style.display="inherit";for(const l of[this.mouseTail,this.iframe])l&&(l.setAttribute("width",String(u.width)),l.setAttribute("height",String(u.height)))}),R(this,"applyEventsSynchronously",u=>{for(const l of u){switch(l.type){case _.DomContentLoaded:case _.Load:case _.Custom:continue;case _.FullSnapshot:case _.Meta:case _.Plugin:case _.IncrementalSnapshot:break}this.getCastFn(l,!0)()}}),R(this,"getCastFn",(u,l=!1)=>{let c;switch(u.type){case _.DomContentLoaded:case _.Load:break;case _.Custom:c=()=>{this.emitter.emit(z.CustomEvent,u)};break;case _.Meta:c=()=>this.emitter.emit(z.Resize,{width:u.data.width,height:u.data.height});break;case _.FullSnapshot:c=()=>{var d;if(this.firstFullSnapshot){if(this.firstFullSnapshot===u){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(u,l),(d=this.iframe.contentWindow)==null||d.scrollTo(u.data.initialOffset)};break;case _.IncrementalSnapshot:c=()=>{if(this.applyIncremental(u,l),!l&&(u===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const d of this.service.state.context.events)if(!(d.timestamp<=u.timestamp)&&this.isUserInteraction(d)){d.delay-u.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=d);break}if(this.nextUserInteractionEvent){const d=this.nextUserInteractionEvent.delay-u.delay,h={speed:Math.min(Math.round(d/nc),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:h}),this.emitter.emit(z.SkipStart,h)}}};break}return()=>{c&&c();for(const h of this.config.plugins||[])h.handler&&h.handler(u,l,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:u}});const d=this.service.state.context.events.length-1;if(!this.config.liveMode&&u===this.service.state.context.events[d]){const h=()=>{d<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(z.Finish))};let f=50;u.type===_.IncrementalSnapshot&&u.data.source===A.MouseMove&&u.data.positions.length&&(f+=Math.max(0,-u.data.positions[0].timeOffset)),setTimeout(h,f)}this.emitter.emit(z.EventCast,u)}}),!(r!=null&&r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const s={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,inactivePeriodThreshold:10*1e3,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:ts,useVirtualDom:!0,logger:console};this.config=Object.assign({},s,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(z.Resize,this.handleResize),this.setupDom();for(const u of this.config.plugins||[])u.getMirror&&u.getMirror({nodeMirror:this.mirror});this.emitter.on(z.Flush,()=>{if(this.usingVirtualDom){const u={mirror:this.mirror,applyCanvas:(l,c,n)=>{as({event:l,mutation:c,target:n,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(l,c)=>{l.source===A.StyleSheetRule?this.applyStyleSheetRule(l,c):l.source===A.StyleDeclaration&&this.applyStyleDeclaration(l,c)},afterAppend:(l,c)=>{for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(l,{id:c,replayer:this})}};if(this.iframe.contentDocument)try{Dt(this.iframe.contentDocument,this.virtualDom,u,this.virtualDom.mirror)}catch(l){console.warn(l)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const l in this.legacy_missingNodeRetryMap)try{const c=this.legacy_missingNodeRetryMap[l],n=At(c.node,this.mirror,this.virtualDom.mirror);Dt(n,c.node,u,this.virtualDom.mirror),c.node=n}catch(c){this.warn(c)}this.constructedStyleMutations.forEach(l=>{this.applyStyleSheetMutation(l)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(l=>{this.applyAdoptedStyleSheet(l)}),this.adoptedStyleSheets=[]}if(this.mousePos&&(this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null),this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null,this.lastMouseDownEvent){const[u,l]=this.lastMouseDownEvent;u.dispatchEvent(l)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(z.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const i=new Hu([],{speed:this.config.speed});this.service=Xu({events:t.map(u=>r&&r.unpackFn?r.unpackFn(u):u).sort((u,l)=>u.timestamp-l.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(u=>{this.emitter.emit(z.StateChange,{player:u})}),this.speedService=Ju({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(u=>{this.emitter.emit(z.StateChange,{speed:u})}),this.mediaManager=new sc({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const o=this.service.state.context.events.find(u=>u.type===_.Meta),a=this.service.state.context.events.find(u=>u.type===_.FullSnapshot);if(o){const{width:u,height:l}=o.data;setTimeout(()=>{this.emitter.emit(z.Resize,{width:u,height:l})},0)}a&&setTimeout(()=>{var u;this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),(u=this.iframe.contentWindow)==null||u.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Dn)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,r){return this.emitter.on(t,r),this}off(t,r){return this.emitter.off(t,r),this}setConfig(t){Object.keys(t).forEach(r=>{t[r],this.config[r]=t[r]}),this.config.skipInactive||this.backToNormal(),typeof t.speed!="undefined"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail!="undefined"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getMetaData(){const t=this.service.state.context.events[0],r=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:r.timestamp,totalTime:r.timestamp-t.timestamp}}getCurrentTime(){return this.config.liveMode&&this.timer.updateLiveTime(),this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:r}=this.service.state.context;return t-r[0].timestamp}getMirror(){return this.mirror}play(t=0){var r,s;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(s=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||s.classList.remove("rrweb-paused"),this.emitter.emit(z.Start)}pause(t){var r,s;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(s=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||s.classList.add("rrweb-paused"),this.emitter.emit(z.Pause)}resume(t=0){this.warn("The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(z.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(z.Destroy)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const r=this.config.unpackFn?this.config.unpackFn(t):t;Dn(r)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:r}}))}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=Di()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.config.UNSAFE_replayCanvas?(this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin allow-scripts"),this.wrapper.appendChild(this.iframe),this.UNSAFE_replayCanvas=!0):(this.iframe=sl({root:this.wrapper}),this.UNSAFE_replayCanvas=!1),this.iframe.style.display="none",this.disableInteract(),this.iframe.contentWindow&&this.iframe.contentDocument&&(Gu(this.iframe.contentWindow,this.iframe.contentDocument),Ls(this.iframe.contentWindow))}rebuildFullSnapshot(t,r=!1){if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&this.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const s=[],i=new Set,o=(l,c)=>{if(l.nodeName==="DIALOG"&&i.add(l),this.collectIframeAndAttachDocument(s,l),this.mediaManager.isSupportedMediaElement(l)){const{events:n}=this.service.state.context;this.mediaManager.addMediaElements(l,t.timestamp-n[0].timestamp,this.mirror)}for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(l,{id:c,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),rl(t.data.node,{doc:this.iframe.contentDocument,afterAppend:o,cache:this.cache,mirror:this.mirror,UNSAFE_allowUnprotectedRebuild:this.UNSAFE_replayCanvas}),o(this.iframe.contentDocument,t.data.node.id);for(const{mutationInQueue:l,builtNode:c}of s)this.attachDocumentToIframe(l,c),this.newDocumentQueue=this.newDocumentQueue.filter(n=>n!==l);const{documentElement:a,head:u}=this.iframe.contentDocument;this.insertStyleRules(a,u),i.forEach(l=>Ct(l)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(z.FullsnapshotRebuilded,t),r||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,r){var s;const i=Qu(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&i.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),!!i.length)if(this.usingVirtualDom){const o=this.virtualDom.createElement("style");this.virtualDom.mirror.add(o,co(o,this.virtualDom.unserializedId)),t.insertBefore(o,r),o.rules.push({source:A.StyleSheetRule,adds:i.map((a,u)=>({rule:a,index:u}))})}else{const o=document.createElement("style");t.insertBefore(o,r);for(let a=0;a<i.length;a++)(s=o.sheet)==null||s.insertRule(i[a],a)}}attachDocumentToIframe(t,r){const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],o=new Set,a=(u,l)=>{u.nodeName==="DIALOG"&&o.add(u),this.collectIframeAndAttachDocument(i,u);const c=s.getMeta(u);if((c==null?void 0:c.type)===Se.Element&&(c==null?void 0:c.tagName.toUpperCase())==="HTML"){const{documentElement:n,head:d}=r.contentDocument;this.insertStyleRules(n,d)}if(!this.usingVirtualDom)for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(u,{id:l,replayer:this})};rt(t.node,{doc:r.contentDocument,mirror:s,hackCss:!0,skipChild:!1,afterAppend:a,cache:this.cache}),a(r.contentDocument,t.node.id);for(const{mutationInQueue:u,builtNode:l}of i)this.attachDocumentToIframe(u,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==u);o.forEach(u=>Ct(u))}collectIframeAndAttachDocument(t,r){if(Ye(r,this.mirror)){const s=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(r));s&&t.push({mutationInQueue:s,builtNode:r})}}waitForStylesheetLoad(){var t;const r=(t=this.iframe.contentDocument)==null?void 0:t.head;if(r){const s=new Set;let i,o=this.service.state;const a=()=>{o=this.service.state};this.emitter.on(z.Start,a),this.emitter.on(z.Pause,a);const u=()=>{this.emitter.off(z.Start,a),this.emitter.off(z.Pause,a)};r.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{l.sheet||(s.add(l),l.addEventListener("load",()=>{s.delete(l),s.size===0&&i!==-1&&(o.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(z.LoadStylesheetEnd),i&&clearTimeout(i),u())}))}),s.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(z.LoadStylesheetStart),i=setTimeout(()=>{o.matches("playing")&&this.play(this.getCurrentTime()),i=-1,u()},this.config.loadTimeout))}}async preloadAllImages(){const t=[];for(const r of this.service.state.context.events)r.type===_.IncrementalSnapshot&&r.data.source===A.CanvasMutation&&(t.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(t)}preloadImages(t,r){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(r)){const s=document.createElement("canvas"),i=s.getContext("2d"),o=i==null?void 0:i.createImageData(s.width,s.height);i==null||i.putImageData(o,0,0)}}async deserializeAndPreloadCanvasEvents(t,r){if(!this.canvasEventMap.has(r)){const s={isUnchanged:!0};if("commands"in t){const i=await Promise.all(t.commands.map(async o=>{const a=await Promise.all(o.args.map(De(this.imageMap,null,s)));return se(P({},o),{args:a})}));s.isUnchanged===!1&&this.canvasEventMap.set(r,se(P({},t),{commands:i}))}else{const i=await Promise.all(t.args.map(De(this.imageMap,null,s)));s.isUnchanged===!1&&this.canvasEventMap.set(r,se(P({},t),{args:i}))}}}applyIncremental(t,r){var s,i,o;const{data:a}=t;switch(a.source){case A.Mutation:{try{this.applyMutation(a,r)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,a)}break}case A.Drag:case A.TouchMove:case A.MouseMove:if(r){const u=a.positions[a.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:a}}else a.positions.forEach(u=>{const l={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,r,a)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(l)}),this.timer.addAction({doAction(){},delay:t.delay-((s=a.positions[0])==null?void 0:s.timeOffset)});break;case A.MouseInteraction:{if(a.id===-1)break;const u=new Event(Ae(j[a.type])),l=this.mirror.getNode(a.id);if(!l)return this.debugNodeNotFound(a,a.id);this.emitter.emit(z.MouseInteraction,{type:a.type,target:l});const{triggerFocus:c}=this.config;switch(a.type){case j.Blur:"blur"in l&&l.blur();break;case j.Focus:c&&l.focus&&l.focus({preventScroll:!0});break;case j.Click:case j.TouchStart:case j.TouchEnd:case j.MouseDown:case j.MouseUp:r?(a.type===j.TouchStart?this.touchActive=!0:a.type===j.TouchEnd&&(this.touchActive=!1),a.type===j.MouseDown?this.lastMouseDownEvent=[l,u]:a.type===j.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:a.x||0,y:a.y||0,id:a.id,debugData:a}):(a.type===j.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(a.x||0,a.y||0,a.id,r,a),a.type===j.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):a.type===j.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):a.type===j.TouchEnd?this.mouse.classList.remove("touch-active"):l.dispatchEvent(u));break;case j.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:l.dispatchEvent(u)}break}case A.Scroll:{if(a.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);u.scrollData=a;break}this.applyScroll(a,r);break}case A.ViewportResize:this.emitter.emit(z.Resize,{width:a.width,height:a.height});break;case A.Input:{if(a.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);u.inputData=a;break}this.applyInput(a);break}case A.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(a.id):this.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);const l=u,{events:c}=this.service.state.context;this.mediaManager.mediaMutation({target:l,timeOffset:t.timestamp-c[0].timestamp,mutation:a});break}case A.StyleSheetRule:case A.StyleDeclaration:{this.usingVirtualDom?a.styleId?this.constructedStyleMutations.push(a):a.id&&((i=this.virtualDom.mirror.getNode(a.id))==null||i.rules.push(a)):this.applyStyleSheetMutation(a);break}case A.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);u.canvasMutations.push({event:t,mutation:a})}else{const u=this.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);as({event:t,mutation:a,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case A.Font:{try{const u=new FontFace(a.family,a.buffer?new Uint8Array(JSON.parse(a.fontSource)):a.fontSource,a.descriptors);(o=this.iframe.contentDocument)==null||o.fonts.add(u)}catch(u){this.warn(u)}break}case A.Selection:{if(r){this.lastSelectionData=a;break}this.applySelection(a);break}case A.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(a):this.applyAdoptedStyleSheet(a);break}}}applyMutation(t,r){if(this.config.useVirtualDom&&!this.usingVirtualDom&&r&&(this.usingVirtualDom=!0,ql(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const c in this.legacy_missingNodeRetryMap)try{const n=this.legacy_missingNodeRetryMap[c],d=uo(n.node,this.virtualDom,this.mirror);d&&(n.node=d)}catch(n){this.warn(n)}const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(c=>s.getNode(c.id)?!0:(this.warnNodeNotFound(t,c.id),!1)),t.removes.forEach(c=>{var n;const d=s.getNode(c.id);if(!d)return;let h=s.getNode(c.parentId);if(!h)return this.warnNodeNotFound(t,c.parentId);if(c.isShadow&&Ie(h)&&(h=h.shadowRoot),s.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((n=h.rules)==null?void 0:n.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=P({},this.legacy_missingNodeRetryMap),o=[],a=c=>{let n=null;return c.nextId&&(n=s.getNode(c.nextId)),c.nextId!==null&&c.nextId!==void 0&&c.nextId!==-1&&!n},u=c=>{var n,d;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let h=s.getNode(c.parentId);if(!h)return c.node.type===Se.Document?this.newDocumentQueue.push(c):o.push(c);c.node.isShadow&&(Ie(h)||h.attachShadow({mode:"open"}),h=h.shadowRoot);let f=null,m=null;if(c.previousId&&(f=s.getNode(c.previousId)),c.nextId&&(m=s.getNode(c.nextId)),a(c))return o.push(c);if(c.node.rootId&&!s.getNode(c.node.rootId))return;const p=c.node.rootId?s.getNode(c.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ye(h,s)){this.attachDocumentToIframe(c,h);return}const g=(w,C)=>{if(!this.usingVirtualDom){Ct(w);for(const v of this.config.plugins||[])v.onBuild&&v.onBuild(w,{id:C,replayer:this})}},b=rt(c.node,{doc:p,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:g});if(c.previousId===-1||c.nextId===-1){i[c.node.id]={node:b,mutation:c};return}const y=s.getMeta(h);if(y&&y.type===Se.Element&&c.node.type===Se.Text){const w=Array.isArray(h.childNodes)?h.childNodes:Array.from(h.childNodes);if(y.tagName==="textarea")for(const C of w)C.nodeType===h.TEXT_NODE&&h.removeChild(C);else if(y.tagName==="style"&&w.length===1)for(const C of w)C.nodeType===h.TEXT_NODE&&!s.hasNode(C)&&(b.textContent=C.textContent,h.removeChild(C))}else if((y==null?void 0:y.type)===Se.Document){const w=h;c.node.type===Se.DocumentType&&((n=w.childNodes[0])==null?void 0:n.nodeType)===Node.DOCUMENT_TYPE_NODE&&w.removeChild(w.childNodes[0]),b.nodeName==="HTML"&&w.documentElement&&w.removeChild(w.documentElement)}if(f&&f.nextSibling&&f.nextSibling.parentNode?h.insertBefore(b,f.nextSibling):m&&m.parentNode?h.contains(m)?h.insertBefore(b,m):h.insertBefore(b,null):h.appendChild(b),g(b,c.node.id),this.usingVirtualDom&&b.nodeName==="#text"&&h.nodeName==="STYLE"&&((d=h.rules)==null?void 0:d.length)>0&&(h.rules=[]),Ye(b,this.mirror)){const w=this.mirror.getId(b),C=this.newDocumentQueue.find(v=>v.parentId===w);C&&(this.attachDocumentToIframe(C,b),this.newDocumentQueue=this.newDocumentQueue.filter(v=>v!==C))}(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(i,h,b,c)};t.adds.forEach(c=>{u(c)});const l=Date.now();for(;o.length;){const c=go(o);if(o.length=0,Date.now()-l>500){this.warn("Timeout in the loop, please check the resolve tree data:",c);break}for(const n of c)s.getNode(n.value.parentId)?Fs(n,h=>{u(h)}):this.debug("Drop resolve tree since there is no parent for the root node.",n)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),yo(t.texts).forEach(c=>{var n;const d=s.getNode(c.id);if(!d)return t.removes.find(f=>f.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);const h=d.parentElement;if(c.value&&h&&h.tagName==="STYLE"?d.textContent=$t(c.value,this.cache):d.textContent=c.value,this.usingVirtualDom){const f=d.parentNode;((n=f==null?void 0:f.rules)==null?void 0:n.length)>0&&(f.rules=[])}}),t.attributes.forEach(c=>{var n;const d=s.getNode(c.id);if(!d)return t.removes.find(h=>h.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);for(const h in c.attributes)if(typeof h=="string"){const f=c.attributes[h];if(f===null)d.removeAttribute(h),h==="open"&&ic(d,c);else if(typeof f=="string")try{if(h==="_cssText"&&(d.nodeName==="LINK"||d.nodeName==="STYLE"))try{const m=s.getMeta(d),p=rt(se(P({},m),{attributes:P(P({},m.attributes),c.attributes)}),{doc:d.ownerDocument,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache});Object.assign(m.attributes,c.attributes);const g=d.nextSibling,b=d.parentNode;if(p&&b){b.removeChild(d),b.insertBefore(p,g),s.replace(c.id,p);break}}catch(m){}if(h==="value"&&d.nodeName==="TEXTAREA"){const m=d;m.childNodes.forEach(g=>m.removeChild(g));const p=(n=d.ownerDocument)==null?void 0:n.createTextNode(f);p&&m.appendChild(p)}else d.setAttribute(h,f);h==="rr_open_mode"&&d.nodeName==="DIALOG"&&Ct(d,c)}catch(m){this.warn("An error occurred may due to the checkout feature.",m)}else if(h==="style"){const m=f,p=d;for(const g in m)if(m[g]===!1)p.style.removeProperty(g);else if(m[g]instanceof Array){const b=m[g];p.style.setProperty(g,b[0],b[1])}else{const b=m[g];p.style.setProperty(g,b)}}}})}applyScroll(t,r){var s,i;const o=this.mirror.getNode(t.id);if(!o)return this.debugNodeNotFound(t,t.id);const a=this.mirror.getMeta(o);if(o===this.iframe.contentDocument)(s=this.iframe.contentWindow)==null||s.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else if((a==null?void 0:a.type)===Se.Document)(i=o.defaultView)==null||i.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else try{o.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"})}catch(u){}}applyInput(t){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);try{r.checked=t.isChecked,r.value=t.text}catch(s){}}applySelection(t){try{const r=new Set,s=t.ranges.map(({start:i,startOffset:o,end:a,endOffset:u})=>{const l=this.mirror.getNode(i),c=this.mirror.getNode(a);if(!l||!c)return;const n=new Range;n.setStart(l,o),n.setEnd(c,u);const d=l.ownerDocument,h=d==null?void 0:d.getSelection();return h&&r.add(h),{range:n,selection:h}});r.forEach(i=>i.removeAllRanges()),s.forEach(i=>{var o;return i&&((o=i.selection)==null?void 0:o.addRange(i.range))})}catch(r){}}applyStyleSheetMutation(t){var r;let s=null;t.styleId?s=this.styleMirror.getStyle(t.styleId):t.id&&(s=((r=this.mirror.getNode(t.id))==null?void 0:r.sheet)||null),s&&(t.source===A.StyleSheetRule?this.applyStyleSheetRule(t,s):t.source===A.StyleDeclaration&&this.applyStyleDeclaration(t,s))}applyStyleSheetRule(t,r){var s,i,o,a;if((s=t.adds)==null||s.forEach(({rule:u,index:l})=>{try{if(Array.isArray(l)){const{positions:c,index:n}=ns(l),d=qe(r.cssRules,c);d==null||d.insertRule(u,n)}else{const c=l===void 0?void 0:Math.min(l,r.cssRules.length);r==null||r.insertRule(u,c)}}catch(c){}}),(i=t.removes)==null||i.forEach(({index:u})=>{try{if(Array.isArray(u)){const{positions:l,index:c}=ns(u),n=qe(r.cssRules,l);n==null||n.deleteRule(c||0)}else r==null||r.deleteRule(u)}catch(l){}}),typeof t.replace=="string")try{(o=r.replace)==null||o.call(r,t.replace)}catch(u){}if(typeof t.replaceSync=="string")try{(a=r.replaceSync)==null||a.call(r,t.replaceSync)}catch(u){}}applyStyleDeclaration(t,r){if(t.set){const s=qe(r.rules,t.index);s!=null&&s.style&&s.style.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const s=qe(r.rules,t.index);s!=null&&s.style&&s.style.removeProperty(t.remove.property)}}applyAdoptedStyleSheet(t){var r;const s=this.mirror.getNode(t.id);if(!s)return;(r=t.styles)==null||r.forEach(u=>{var l;let c=null,n=null;if(Ie(s)?n=((l=s.ownerDocument)==null?void 0:l.defaultView)||null:s.nodeName==="#document"&&(n=s.defaultView),!!n)try{c=new n.CSSStyleSheet,this.styleMirror.add(c,u.styleId),this.applyStyleSheetRule({source:A.StyleSheetRule,adds:u.rules},c)}catch(d){}});const i=10;let o=0;const a=(u,l)=>{const c=l.map(n=>this.styleMirror.getStyle(n)).filter(n=>n!==null);Ie(u)?u.shadowRoot.adoptedStyleSheets=c:u.nodeName==="#document"&&(u.adoptedStyleSheets=c),c.length!==l.length&&o<i&&(setTimeout(()=>a(u,l),0+100*o),o++)};a(s,t.styleIds)}legacy_resolveMissingNode(t,r,s,i){const{previousId:o,nextId:a}=i,u=o&&t[o],l=a&&t[a];if(u){const{node:c,mutation:n}=u;r.insertBefore(c,s),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,c,n)}if(l){const{node:c,mutation:n}=l;r.insertBefore(c,s.nextSibling),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,c,n)}}moveAndHover(t,r,s,i,o){const a=this.mirror.getNode(s);if(!a)return this.debugNodeNotFound(o,s);const u=Bs(a,this.iframe),l=t*u.absoluteScale+u.x,c=r*u.absoluteScale+u.y;this.mouse.style.left=`${l}px`,this.mouse.style.top=`${c}px`,i||this.drawMouseTail({x:l,y:c}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:r,lineWidth:s,strokeStyle:i,duration:o}=this.config.mouseTail===!0?ts:Object.assign({},ts,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const u=this.mouseTail.getContext("2d");!u||!this.tailPositions.length||(u.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),u.beginPath(),u.lineWidth=s,u.lineCap=r,u.strokeStyle=i,u.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(l=>u.lineTo(l.x,l.y)),u.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(u=>u!==t),a()},o/this.speedService.state.context.timer.speed)}hoverElements(t){var r;(r=this.lastHoveredRootNode||this.iframe.contentDocument)==null||r.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")}),this.lastHoveredRootNode=t.getRootNode();let s=t;for(;s;)s.classList&&s.classList.add(":hover"),s=s.parentElement}isUserInteraction(t){return t.type!==_.IncrementalSnapshot?!1:t.data.source>A.Mutation&&t.data.source<=A.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(z.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,r){this.warn(`Node with id '${r}' not found. `,t)}warnCanvasMutationFailed(t,r){this.warn("Has error on canvas update",r,"canvas mutation:",t)}debugNodeNotFound(t,r){this.debug(`Node with id '${r}' not found. `,t)}warn(...t){this.config.showWarning&&this.config.logger.warn(In,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(In,...t)}}const{addCustomEvent:lc}=Te,{freezePage:uc}=Te,{takeFullSnapshot:cc}=Te;exports.EventType=_;exports.IncrementalSource=A;exports.MouseInteractions=j;exports.Replayer=ac;exports.ReplayerEvents=z;exports.addCustomEvent=lc;exports.canvasMutation=as;exports.freezePage=uc;exports.record=Te;exports.takeFullSnapshot=cc;exports.utils=au;
|
|
177
|
+
***************************************************************************** */function En(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s,i,o=r.call(e),a=[];try{for(;(t===void 0||t-- >0)&&!(s=o.next()).done;)a.push(s.value)}catch(u){i={error:u}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(i)throw i.error}}return a}var He;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(He||(He={}));var Oo={type:"xstate.init"};function es(e){return e===void 0?[]:[].concat(e)}function ze(e){return{type:"xstate.assign",assignment:e}}function xn(e,t){return typeof(e=typeof e=="string"&&t&&t[e]?t[e]:e)=="string"?{type:e}:typeof e=="function"?{type:e.name,exec:e}:e}function Pt(e){return function(t){return e===t}}function Io(e){return typeof e=="string"?{type:e}:e}function Rn(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Pt(e)}}function Mn(e,t,r){var s=t,i=!1;return[e.filter(function(o){if(o.type==="xstate.assign"){i=!0;var a=Object.assign({},s);return typeof o.assignment=="function"?a=o.assignment(s,r):Object.keys(o.assignment).forEach(function(u){a[u]=typeof o.assignment[u]=="function"?o.assignment[u](s,r):o.assignment[u]}),s=a,!1}return!0}),s,i]}function Do(e,t){t===void 0&&(t={});var r=En(Mn(es(e.states[e.initial].entry).map(function(a){return xn(a,t.actions)}),e.context,Oo),2),s=r[0],i=r[1],o={config:e,_options:t,initialState:{value:e.initial,actions:s,context:i,matches:Pt(e.initial)},transition:function(a,u){var l,c,n=typeof a=="string"?{value:a,context:e.context}:a,d=n.value,h=n.context,f=Io(u),m=e.states[d];if(m.on){var p=es(m.on[f.type]);try{for(var g=function(k){var X=typeof Symbol=="function"&&Symbol.iterator,te=X&&k[X],Z=0;if(te)return te.call(k);if(k&&typeof k.length=="number")return{next:function(){return k&&Z>=k.length&&(k=void 0),{value:k&&k[Z++],done:!k}}};throw new TypeError(X?"Object is not iterable.":"Symbol.iterator is not defined.")}(p),b=g.next();!b.done;b=g.next()){var y=b.value;if(y===void 0)return Rn(d,h);var w=typeof y=="string"?{target:y}:y,C=w.target,v=w.actions,S=v===void 0?[]:v,E=w.cond,M=E===void 0?function(){return!0}:E,I=C===void 0,N=C!=null?C:d,F=e.states[N];if(M(h,f)){var T=En(Mn((I?es(S):[].concat(m.exit,S,F.entry).filter(function(k){return k})).map(function(k){return xn(k,o._options.actions)}),h,f),3),x=T[0],ue=T[1],ae=T[2],V=C!=null?C:d;return{value:V,context:ue,actions:x,changed:C!==d||x.length>0||ae,matches:Pt(V)}}}}catch(k){l={error:k}}finally{try{b&&!b.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}}return Rn(d,h)}};return o}var Nn=function(e,t){return e.actions.forEach(function(r){var s=r.exec;return s&&s(e.context,t)})};function Ao(e){var t=e.initialState,r=He.NotStarted,s=new Set,i={_machine:e,send:function(o){r===He.Running&&(t=e.transition(t,o),Nn(t,Io(o)),s.forEach(function(a){return a(t)}))},subscribe:function(o){return s.add(o),o(t),{unsubscribe:function(){return s.delete(o)}}},start:function(o){if(o){var a=typeof o=="object"?o:{context:e.config.context,value:o};t={value:a.value,actions:[],context:a.context,matches:Pt(a.value)}}return r=He.Running,Nn(t,Oo),i},stop:function(){return r=He.Stopped,s.clear(),i},get state(){return t},get status(){return r}};return i}function Xu(e,t){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.type===_.Meta&&s.timestamp<=t)return e.slice(r)}return e}function Ju(e,{getCastFn:t,applyEventsSynchronously:r,emitter:s}){const i=Do({id:"player",context:e,initial:"paused",states:{playing:{on:{PAUSE:{target:"paused",actions:["pause"]},CAST_EVENT:{target:"playing",actions:"castEvent"},END:{target:"paused",actions:["resetLastPlayedEvent","pause"]},ADD_EVENT:{target:"playing",actions:["addEvent"]}}},paused:{on:{PLAY:{target:"playing",actions:["recordTimeOffset","play"]},CAST_EVENT:{target:"paused",actions:"castEvent"},TO_LIVE:{target:"live",actions:["startLive"]},ADD_EVENT:{target:"paused",actions:["addEvent"]}}},live:{on:{ADD_EVENT:{target:"live",actions:["addEvent"]},CAST_EVENT:{target:"live",actions:["castEvent"]}}}}},{actions:{castEvent:ze({lastPlayedEvent:(o,a)=>a.type==="CAST_EVENT"?a.payload.event:o.lastPlayedEvent}),recordTimeOffset:ze((o,a)=>{let u=o.timeOffset;return"payload"in a&&"timeOffset"in a.payload&&(u=a.payload.timeOffset),se(P({},o),{timeOffset:u,baselineTime:o.events[0].timestamp+u})}),play(o){var a;const{timer:u,events:l,baselineTime:c,lastPlayedEvent:n}=o;u.clear();for(const m of l)Cn(m,c);const d=Xu(l,c);let h=n==null?void 0:n.timestamp;(n==null?void 0:n.type)===_.IncrementalSnapshot&&n.data.source===A.MouseMove&&(h=n.timestamp+((a=n.data.positions[0])==null?void 0:a.timeOffset)),c<(h||0)&&s.emit(z.PlayBack);const f=new Array;for(const m of d)if(!(h&&h<c&&(m.timestamp<=h||m===n)))if(m.timestamp<c)f.push(m);else{const p=t(m,!1);u.addAction({doAction:()=>{p()},delay:m.delay})}r(f),s.emit(z.Flush),u.start()},pause(o){o.timer.clear()},resetLastPlayedEvent:ze(o=>se(P({},o),{lastPlayedEvent:null})),startLive:ze({baselineTime:(o,a)=>(o.timer.start(),a.type==="TO_LIVE"&&a.payload.baselineTime?a.payload.baselineTime:Date.now())}),addEvent:ze((o,a)=>{const{baselineTime:u,timer:l,events:c}=o;if(a.type==="ADD_EVENT"){const{event:n}=a.payload;Cn(n,u);let d=c.length-1;if(!c[d]||c[d].timestamp<=n.timestamp)c.push(n);else{let m=-1,p=0;for(;p<=d;){const g=Math.floor((p+d)/2);c[g].timestamp<=n.timestamp?p=g+1:d=g-1}m===-1&&(m=p),c.splice(m,0,n)}const h=n.timestamp<u,f=t(n,h);h?f():l.isActive()&&l.addAction({doAction:()=>{f()},delay:n.delay})}return se(P({},o),{events:c})})}});return Ao(i)}function Qu(e){const t=Do({id:"speed",context:e,initial:"normal",states:{normal:{on:{FAST_FORWARD:{target:"skipping",actions:["recordSpeed","setSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}},skipping:{on:{BACK_TO_NORMAL:{target:"normal",actions:["restoreSpeed"]},SET_SPEED:{target:"normal",actions:["setSpeed"]}}}}},{actions:{setSpeed:(r,s)=>{"payload"in s&&r.timer.setSpeed(s.payload.speed)},recordSpeed:ze({normalSpeed:r=>r.timer.speed}),restoreSpeed:r=>{r.timer.setSpeed(r.normalSpeed)}}});return Ao(t)}const Zu=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],On=new Map;function To(e,t){let r=On.get(e);return r||(r=new Map,On.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function De(e,t,r){return async s=>{if(s&&typeof s=="object"&&"rr_type"in s)if(r&&(r.isUnchanged=!1),s.rr_type==="ImageBitmap"&&"args"in s){const i=await De(e,t,r)(s.args);return await createImageBitmap.apply(null,i)}else if("index"in s){if(r||t===null)return s;const{rr_type:i,index:o}=s;return To(t,i)[o]}else if("args"in s){const{rr_type:i,args:o}=s,a=window[i];return new a(...await Promise.all(o.map(De(e,t,r))))}else{if("base64"in s)return Du(s.base64);if("src"in s){const i=e.get(s.src);if(i)return i;{const o=new Image;return o.src=s.src,e.set(s.src,o),o}}else if("data"in s&&s.rr_type==="Blob"){const i=await Promise.all(s.data.map(De(e,t,r)));return new Blob(i,{type:s.type})}}else if(Array.isArray(s))return await Promise.all(s.map(De(e,t,r)));return s}}function Ku(e,t){try{return t===Ce.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(r){return null}}const ec=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function tc(e,t){if(!(t!=null&&t.constructor))return;const{name:r}=t.constructor;if(!ec.includes(r))return;const s=To(e,r);s.includes(t)||s.push(t)}async function rc({mutation:e,target:t,type:r,imageMap:s,errorHandler:i}){try{const o=Ku(t,r);if(!o)return;if(e.setter){o[e.property]=e.args[0];return}const a=o[e.property],u=await Promise.all(e.args.map(De(s,o))),l=a.apply(o,u);tc(o,l);const c=!1}catch(o){i(e,o)}}async function sc({event:e,mutations:t,target:r,imageMap:s,errorHandler:i}){const o=r.getContext("2d");if(!o){i(t[0],new Error("Canvas context is null"));return}const a=t.map(async l=>Promise.all(l.args.map(De(s,o))));(await Promise.all(a)).forEach((l,c)=>{const n=t[c];try{if(n.setter){o[n.property]=n.args[0];return}const d=o[n.property];n.property==="drawImage"&&typeof n.args[0]=="string"?(s.get(e),d.apply(o,n.args)):d.apply(o,l)}catch(d){i(n,d)}})}async function as({event:e,mutation:t,target:r,imageMap:s,canvasEventMap:i,errorHandler:o}){try{const a=i.get(e)||t,u="commands"in a?a.commands:[a];if([Ce.WebGL,Ce.WebGL2].includes(t.type)){for(let l=0;l<u.length;l++){const c=u[l];await rc({mutation:c,type:t.type,target:r,imageMap:s,errorHandler:o})}return}await sc({event:e,mutations:u,target:r,imageMap:s,errorHandler:o})}catch(a){o(t,a)}}class ic{constructor(t){R(this,"mediaMap",new Map),R(this,"warn"),R(this,"service"),R(this,"speedService"),R(this,"emitter"),R(this,"getCurrentTime"),R(this,"metadataCallbackMap",new Map),this.warn=t.warn,this.service=t.service,this.speedService=t.speedService,this.emitter=t.emitter,this.getCurrentTime=t.getCurrentTime,this.emitter.on(z.Start,this.start.bind(this)),this.emitter.on(z.SkipStart,this.start.bind(this)),this.emitter.on(z.Pause,this.pause.bind(this)),this.emitter.on(z.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(t={pause:!1}){this.mediaMap.forEach((r,s)=>{this.syncTargetWithState(s),t.pause&&s.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:t,target:r,mediaState:s}){if(s.isPlaying){const o=(t-s.lastInteractionTimeOffset)/1e3*s.playbackRate,a="duration"in r&&r.duration;if(Number.isNaN(a)){this.waitForMetadata(r);return}let u=s.currentTimeAtLastInteraction+o;r.loop&&a!==!1&&(u=u%a),r.currentTime=u}else r.pause(),r.currentTime=s.currentTimeAtLastInteraction}waitForMetadata(t){if(this.metadataCallbackMap.has(t)||!("addEventListener"in t))return;const r=()=>{this.metadataCallbackMap.delete(t);const s=this.mediaMap.get(t);s&&this.seekTo({time:this.getCurrentTime(),target:t,mediaState:s})};this.metadataCallbackMap.set(t,r),t.addEventListener("loadedmetadata",r,{once:!0})}getMediaStateFromMutation({target:t,timeOffset:r,mutation:s}){var f,m,p,g,b;const i=this.mediaMap.get(t),{type:o,playbackRate:a,currentTime:u,muted:l,volume:c,loop:n}=s;return{isPlaying:o===Oe.Play||o!==Oe.Pause&&((i==null?void 0:i.isPlaying)||t.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(f=u!=null?u:i==null?void 0:i.currentTimeAtLastInteraction)!=null?f:0,lastInteractionTimeOffset:r,playbackRate:(m=a!=null?a:i==null?void 0:i.playbackRate)!=null?m:1,volume:(p=c!=null?c:i==null?void 0:i.volume)!=null?p:1,muted:(g=l!=null?l:i==null?void 0:i.muted)!=null?g:t.getAttribute("muted")===null,loop:(b=n!=null?n:i==null?void 0:i.loop)!=null?b:t.getAttribute("loop")===null}}syncTargetWithState(t){const r=this.mediaMap.get(t);if(!r)return;const{muted:s,loop:i,volume:o,isPlaying:a}=r,u=this.service.state.matches("paused"),l=r.playbackRate*this.speedService.state.context.timer.speed;try{this.seekTo({time:this.getCurrentTime(),target:t,mediaState:r}),t.volume!==o&&(t.volume=o),t.muted=s,t.loop=i,t.playbackRate!==l&&(t.playbackRate=l),a&&!u?t.play():t.pause()}catch(c){this.warn(`Failed to replay media interactions: ${c.message||c}`)}}addMediaElements(t,r,s){if(!["AUDIO","VIDEO"].includes(t.nodeName))return;const i=t,o=s.getMeta(i);if(!o||!("attributes"in o))return;const a=this.service.state.matches("paused"),u=o.attributes;let l=!1;u.rr_mediaState?l=u.rr_mediaState==="played":l=i.getAttribute("autoplay")!==null,l&&a&&i.pause();let c=1;typeof u.rr_mediaPlaybackRate=="number"&&(c=u.rr_mediaPlaybackRate);let n=!1;typeof u.rr_mediaMuted=="boolean"?n=u.rr_mediaMuted:n=i.getAttribute("muted")!==null;let d=!1;typeof u.rr_mediaLoop=="boolean"?d=u.rr_mediaLoop:d=i.getAttribute("loop")!==null;let h=1;typeof u.rr_mediaVolume=="number"&&(h=u.rr_mediaVolume);let f=0;typeof u.rr_mediaCurrentTime=="number"&&(f=u.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:l,currentTimeAtLastInteraction:f,lastInteractionTimeOffset:r,playbackRate:c,volume:h,muted:n,loop:d}),this.syncTargetWithState(i)}mediaMutation({target:t,timeOffset:r,mutation:s}){this.mediaMap.set(t,this.getMediaStateFromMutation({target:t,timeOffset:r,mutation:s})),this.syncTargetWithState(t)}isSupportedMediaElement(t){return["AUDIO","VIDEO"].includes(t.nodeName)}reset(){this.mediaMap.clear()}}function Ct(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e,s=r.open,i=s&&r.matches("dialog:modal"),o=r.getAttribute("rr_open_mode"),a=typeof(t==null?void 0:t.attributes.open)=="string"||typeof r.getAttribute("open")=="string",u=o==="modal";if(!(s&&!(i&&o==="non-modal"||!i&&u))){if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}s&&r.close(),a&&(u?r.showModal():r.show())}}function nc(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e;if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}t.attributes.open===null&&(r.removeAttribute("open"),r.removeAttribute("rr_open_mode"))}const oc=5*1e3,ac=Gu,In="[replayer]",ts={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Dn(e){return e.type==_.IncrementalSnapshot&&(e.data.source==A.TouchMove||e.data.source==A.MouseInteraction&&e.data.type==j.TouchStart)}class lc{constructor(t,r){if(R(this,"wrapper"),R(this,"iframe"),R(this,"UNSAFE_replayCanvas",!1),R(this,"service"),R(this,"speedService"),R(this,"config"),R(this,"usingVirtualDom",!1),R(this,"virtualDom",new Qe),R(this,"mouse"),R(this,"mouseTail",null),R(this,"tailPositions",[]),R(this,"emitter",ac()),R(this,"nextUserInteractionEvent"),R(this,"legacy_missingNodeRetryMap",{}),R(this,"cache",Di()),R(this,"imageMap",new Map),R(this,"canvasEventMap",new Map),R(this,"mirror",Pn()),R(this,"styleMirror",new Ws),R(this,"mediaManager"),R(this,"firstFullSnapshot",null),R(this,"newDocumentQueue",[]),R(this,"mousePos",null),R(this,"touchActive",null),R(this,"lastMouseDownEvent",null),R(this,"lastHoveredRootNode"),R(this,"lastSelectionData",null),R(this,"constructedStyleMutations",[]),R(this,"adoptedStyleSheets",[]),R(this,"handleResize",u=>{this.iframe.style.display="inherit";for(const l of[this.mouseTail,this.iframe])l&&(l.setAttribute("width",String(u.width)),l.setAttribute("height",String(u.height)))}),R(this,"applyEventsSynchronously",u=>{for(const l of u){switch(l.type){case _.DomContentLoaded:case _.Load:case _.Custom:continue;case _.FullSnapshot:case _.Meta:case _.Plugin:case _.IncrementalSnapshot:break}this.getCastFn(l,!0)()}}),R(this,"getCastFn",(u,l=!1)=>{let c;switch(u.type){case _.DomContentLoaded:case _.Load:break;case _.Custom:c=()=>{this.emitter.emit(z.CustomEvent,u)};break;case _.Meta:c=()=>this.emitter.emit(z.Resize,{width:u.data.width,height:u.data.height});break;case _.FullSnapshot:c=()=>{var d;if(this.firstFullSnapshot){if(this.firstFullSnapshot===u){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(u,l),(d=this.iframe.contentWindow)==null||d.scrollTo(u.data.initialOffset)};break;case _.IncrementalSnapshot:c=()=>{if(this.applyIncremental(u,l),!l&&(u===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const d of this.service.state.context.events)if(!(d.timestamp<=u.timestamp)&&this.isUserInteraction(d)){d.delay-u.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=d);break}if(this.nextUserInteractionEvent){const d=this.nextUserInteractionEvent.delay-u.delay,h={speed:Math.min(Math.round(d/oc),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:h}),this.emitter.emit(z.SkipStart,h)}}};break}return()=>{c&&c();for(const h of this.config.plugins||[])h.handler&&h.handler(u,l,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:u}});const d=this.service.state.context.events.length-1;if(!this.config.liveMode&&u===this.service.state.context.events[d]){const h=()=>{d<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(z.Finish))};let f=50;u.type===_.IncrementalSnapshot&&u.data.source===A.MouseMove&&u.data.positions.length&&(f+=Math.max(0,-u.data.positions[0].timeOffset)),setTimeout(h,f)}this.emitter.emit(z.EventCast,u)}}),!(r!=null&&r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const s={speed:1,maxSpeed:360,root:document.body,loadTimeout:0,skipInactive:!1,inactivePeriodThreshold:10*1e3,showWarning:!0,showDebug:!1,blockClass:"rr-block",liveMode:!1,insertStyleRules:[],triggerFocus:!0,UNSAFE_replayCanvas:!1,pauseAnimation:!0,mouseTail:ts,useVirtualDom:!0,logger:console};this.config=Object.assign({},s,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(z.Resize,this.handleResize),this.setupDom();for(const u of this.config.plugins||[])u.getMirror&&u.getMirror({nodeMirror:this.mirror});this.emitter.on(z.Flush,()=>{if(this.usingVirtualDom){const u={mirror:this.mirror,applyCanvas:(l,c,n)=>{as({event:l,mutation:c,target:n,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(l,c)=>{l.source===A.StyleSheetRule?this.applyStyleSheetRule(l,c):l.source===A.StyleDeclaration&&this.applyStyleDeclaration(l,c)},afterAppend:(l,c)=>{for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(l,{id:c,replayer:this})}};if(this.iframe.contentDocument)try{Dt(this.iframe.contentDocument,this.virtualDom,u,this.virtualDom.mirror)}catch(l){console.warn(l)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const l in this.legacy_missingNodeRetryMap)try{const c=this.legacy_missingNodeRetryMap[l],n=At(c.node,this.mirror,this.virtualDom.mirror);Dt(n,c.node,u,this.virtualDom.mirror),c.node=n}catch(c){this.warn(c)}this.constructedStyleMutations.forEach(l=>{this.applyStyleSheetMutation(l)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(l=>{this.applyAdoptedStyleSheet(l)}),this.adoptedStyleSheets=[]}if(this.mousePos&&(this.moveAndHover(this.mousePos.x,this.mousePos.y,this.mousePos.id,!0,this.mousePos.debugData),this.mousePos=null),this.touchActive===!0?this.mouse.classList.add("touch-active"):this.touchActive===!1&&this.mouse.classList.remove("touch-active"),this.touchActive=null,this.lastMouseDownEvent){const[u,l]=this.lastMouseDownEvent;u.dispatchEvent(l)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(z.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const i=new Yu([],{speed:this.config.speed});this.service=Ju({events:t.map(u=>r&&r.unpackFn?r.unpackFn(u):u).sort((u,l)=>u.timestamp-l.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(u=>{this.emitter.emit(z.StateChange,{player:u})}),this.speedService=Qu({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(u=>{this.emitter.emit(z.StateChange,{speed:u})}),this.mediaManager=new ic({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const o=this.service.state.context.events.find(u=>u.type===_.Meta),a=this.service.state.context.events.find(u=>u.type===_.FullSnapshot);if(o){const{width:u,height:l}=o.data;setTimeout(()=>{this.emitter.emit(z.Resize,{width:u,height:l})},0)}a&&setTimeout(()=>{var u;this.firstFullSnapshot||(this.firstFullSnapshot=a,this.rebuildFullSnapshot(a),(u=this.iframe.contentWindow)==null||u.scrollTo(a.data.initialOffset))},1),this.service.state.context.events.find(Dn)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,r){return this.emitter.on(t,r),this}off(t,r){return this.emitter.off(t,r),this}setConfig(t){Object.keys(t).forEach(r=>{t[r],this.config[r]=t[r]}),this.config.skipInactive||this.backToNormal(),typeof t.speed!="undefined"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail!="undefined"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getMetaData(){const t=this.service.state.context.events[0],r=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:r.timestamp,totalTime:r.timestamp-t.timestamp}}getCurrentTime(){return this.config.liveMode&&this.timer.updateLiveTime(),this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:r}=this.service.state.context;return t-r[0].timestamp}getMirror(){return this.mirror}play(t=0){var r,s;this.service.state.matches("paused")?this.service.send({type:"PLAY",payload:{timeOffset:t}}):(this.service.send({type:"PAUSE"}),this.service.send({type:"PLAY",payload:{timeOffset:t}})),(s=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||s.classList.remove("rrweb-paused"),this.emitter.emit(z.Start)}pause(t){var r,s;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(s=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||s.classList.add("rrweb-paused"),this.emitter.emit(z.Pause)}resume(t=0){this.warn("The 'resume' was deprecated in 1.0. Please use 'play' method which has the same interface."),this.play(t),this.emitter.emit(z.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(z.Destroy)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const r=this.config.unpackFn?this.config.unpackFn(t):t;Dn(r)&&this.mouse.classList.add("touch-device"),Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:r}}))}enableInteract(){this.iframe.setAttribute("scrolling","auto"),this.iframe.style.pointerEvents="auto"}disableInteract(){this.iframe.setAttribute("scrolling","no"),this.iframe.style.pointerEvents="none"}resetCache(){this.cache=Di()}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.mouse=document.createElement("div"),this.mouse.classList.add("replayer-mouse"),this.wrapper.appendChild(this.mouse),this.config.mouseTail!==!1&&(this.mouseTail=document.createElement("canvas"),this.mouseTail.classList.add("replayer-mouse-tail"),this.mouseTail.style.display="inherit",this.wrapper.appendChild(this.mouseTail)),this.config.UNSAFE_replayCanvas?(this.iframe=document.createElement("iframe"),this.iframe.setAttribute("sandbox","allow-same-origin allow-scripts"),this.wrapper.appendChild(this.iframe),this.UNSAFE_replayCanvas=!0):(this.iframe=sl({root:this.wrapper}),this.UNSAFE_replayCanvas=!1),this.iframe.style.display="none",this.disableInteract(),this.iframe.contentWindow&&this.iframe.contentDocument&&(Hu(this.iframe.contentWindow,this.iframe.contentDocument),Ls(this.iframe.contentWindow))}rebuildFullSnapshot(t,r=!1){if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");Object.keys(this.legacy_missingNodeRetryMap).length&&this.warn("Found unresolved missing node map",this.legacy_missingNodeRetryMap),this.legacy_missingNodeRetryMap={};const s=[],i=new Set,o=(l,c)=>{if(l.nodeName==="DIALOG"&&i.add(l),this.collectIframeAndAttachDocument(s,l),this.mediaManager.isSupportedMediaElement(l)){const{events:n}=this.service.state.context;this.mediaManager.addMediaElements(l,t.timestamp-n[0].timestamp,this.mirror)}for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(l,{id:c,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),rl(t.data.node,{doc:this.iframe.contentDocument,afterAppend:o,cache:this.cache,mirror:this.mirror,UNSAFE_allowUnprotectedRebuild:this.UNSAFE_replayCanvas}),o(this.iframe.contentDocument,t.data.node.id);for(const{mutationInQueue:l,builtNode:c}of s)this.attachDocumentToIframe(l,c),this.newDocumentQueue=this.newDocumentQueue.filter(n=>n!==l);const{documentElement:a,head:u}=this.iframe.contentDocument;this.insertStyleRules(a,u),i.forEach(l=>Ct(l)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(z.FullsnapshotRebuilded,t),r||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,r){var s;const i=Zu(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&i.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),!!i.length)if(this.usingVirtualDom){const o=this.virtualDom.createElement("style");this.virtualDom.mirror.add(o,co(o,this.virtualDom.unserializedId)),t.insertBefore(o,r),o.rules.push({source:A.StyleSheetRule,adds:i.map((a,u)=>({rule:a,index:u}))})}else{const o=document.createElement("style");t.insertBefore(o,r);for(let a=0;a<i.length;a++)(s=o.sheet)==null||s.insertRule(i[a],a)}}attachDocumentToIframe(t,r){const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],o=new Set,a=(u,l)=>{u.nodeName==="DIALOG"&&o.add(u),this.collectIframeAndAttachDocument(i,u);const c=s.getMeta(u);if((c==null?void 0:c.type)===Se.Element&&(c==null?void 0:c.tagName.toUpperCase())==="HTML"){const{documentElement:n,head:d}=r.contentDocument;this.insertStyleRules(n,d)}if(!this.usingVirtualDom)for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(u,{id:l,replayer:this})};rt(t.node,{doc:r.contentDocument,mirror:s,hackCss:!0,skipChild:!1,afterAppend:a,cache:this.cache}),a(r.contentDocument,t.node.id);for(const{mutationInQueue:u,builtNode:l}of i)this.attachDocumentToIframe(u,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==u);o.forEach(u=>Ct(u))}collectIframeAndAttachDocument(t,r){if(Ye(r,this.mirror)){const s=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(r));s&&t.push({mutationInQueue:s,builtNode:r})}}waitForStylesheetLoad(){var t;const r=(t=this.iframe.contentDocument)==null?void 0:t.head;if(r){const s=new Set;let i,o=this.service.state;const a=()=>{o=this.service.state};this.emitter.on(z.Start,a),this.emitter.on(z.Pause,a);const u=()=>{this.emitter.off(z.Start,a),this.emitter.off(z.Pause,a)};r.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{l.sheet||(s.add(l),l.addEventListener("load",()=>{s.delete(l),s.size===0&&i!==-1&&(o.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(z.LoadStylesheetEnd),i&&clearTimeout(i),u())}))}),s.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(z.LoadStylesheetStart),i=setTimeout(()=>{o.matches("playing")&&this.play(this.getCurrentTime()),i=-1,u()},this.config.loadTimeout))}}async preloadAllImages(){const t=[];for(const r of this.service.state.context.events)r.type===_.IncrementalSnapshot&&r.data.source===A.CanvasMutation&&(t.push(this.deserializeAndPreloadCanvasEvents(r.data,r)),("commands"in r.data?r.data.commands:[r.data]).forEach(i=>{this.preloadImages(i,r)}));return Promise.all(t)}preloadImages(t,r){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(r)){const s=document.createElement("canvas"),i=s.getContext("2d"),o=i==null?void 0:i.createImageData(s.width,s.height);i==null||i.putImageData(o,0,0)}}async deserializeAndPreloadCanvasEvents(t,r){if(!this.canvasEventMap.has(r)){const s={isUnchanged:!0};if("commands"in t){const i=await Promise.all(t.commands.map(async o=>{const a=await Promise.all(o.args.map(De(this.imageMap,null,s)));return se(P({},o),{args:a})}));s.isUnchanged===!1&&this.canvasEventMap.set(r,se(P({},t),{commands:i}))}else{const i=await Promise.all(t.args.map(De(this.imageMap,null,s)));s.isUnchanged===!1&&this.canvasEventMap.set(r,se(P({},t),{args:i}))}}}applyIncremental(t,r){var s,i,o;const{data:a}=t;switch(a.source){case A.Mutation:{try{this.applyMutation(a,r)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,a)}break}case A.Drag:case A.TouchMove:case A.MouseMove:if(r){const u=a.positions[a.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:a}}else a.positions.forEach(u=>{const l={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,r,a)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(l)}),this.timer.addAction({doAction(){},delay:t.delay-((s=a.positions[0])==null?void 0:s.timeOffset)});break;case A.MouseInteraction:{if(a.id===-1)break;const u=new Event(Ae(j[a.type])),l=this.mirror.getNode(a.id);if(!l)return this.debugNodeNotFound(a,a.id);this.emitter.emit(z.MouseInteraction,{type:a.type,target:l});const{triggerFocus:c}=this.config;switch(a.type){case j.Blur:"blur"in l&&l.blur();break;case j.Focus:c&&l.focus&&l.focus({preventScroll:!0});break;case j.Click:case j.TouchStart:case j.TouchEnd:case j.MouseDown:case j.MouseUp:r?(a.type===j.TouchStart?this.touchActive=!0:a.type===j.TouchEnd&&(this.touchActive=!1),a.type===j.MouseDown?this.lastMouseDownEvent=[l,u]:a.type===j.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:a.x||0,y:a.y||0,id:a.id,debugData:a}):(a.type===j.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(a.x||0,a.y||0,a.id,r,a),a.type===j.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):a.type===j.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):a.type===j.TouchEnd?this.mouse.classList.remove("touch-active"):l.dispatchEvent(u));break;case j.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:l.dispatchEvent(u)}break}case A.Scroll:{if(a.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);u.scrollData=a;break}this.applyScroll(a,r);break}case A.ViewportResize:this.emitter.emit(z.Resize,{width:a.width,height:a.height});break;case A.Input:{if(a.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);u.inputData=a;break}this.applyInput(a);break}case A.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(a.id):this.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);const l=u,{events:c}=this.service.state.context;this.mediaManager.mediaMutation({target:l,timeOffset:t.timestamp-c[0].timestamp,mutation:a});break}case A.StyleSheetRule:case A.StyleDeclaration:{this.usingVirtualDom?a.styleId?this.constructedStyleMutations.push(a):a.id&&((i=this.virtualDom.mirror.getNode(a.id))==null||i.rules.push(a)):this.applyStyleSheetMutation(a);break}case A.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);u.canvasMutations.push({event:t,mutation:a})}else{const u=this.mirror.getNode(a.id);if(!u)return this.debugNodeNotFound(a,a.id);as({event:t,mutation:a,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case A.Font:{try{const u=new FontFace(a.family,a.buffer?new Uint8Array(JSON.parse(a.fontSource)):a.fontSource,a.descriptors);(o=this.iframe.contentDocument)==null||o.fonts.add(u)}catch(u){this.warn(u)}break}case A.Selection:{if(r){this.lastSelectionData=a;break}this.applySelection(a);break}case A.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(a):this.applyAdoptedStyleSheet(a);break}}}applyMutation(t,r){if(this.config.useVirtualDom&&!this.usingVirtualDom&&r&&(this.usingVirtualDom=!0,ql(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const c in this.legacy_missingNodeRetryMap)try{const n=this.legacy_missingNodeRetryMap[c],d=uo(n.node,this.virtualDom,this.mirror);d&&(n.node=d)}catch(n){this.warn(n)}const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(c=>s.getNode(c.id)?!0:(this.warnNodeNotFound(t,c.id),!1)),t.removes.forEach(c=>{var n;const d=s.getNode(c.id);if(!d)return;let h=s.getNode(c.parentId);if(!h)return this.warnNodeNotFound(t,c.parentId);if(c.isShadow&&Ie(h)&&(h=h.shadowRoot),s.removeNodeFromMap(d),h)try{h.removeChild(d),this.usingVirtualDom&&d.nodeName==="#text"&&h.nodeName==="STYLE"&&((n=h.rules)==null?void 0:n.length)>0&&(h.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",h,d,t);else throw f}});const i=P({},this.legacy_missingNodeRetryMap),o=[],a=c=>{let n=null;return c.nextId&&(n=s.getNode(c.nextId)),c.nextId!==null&&c.nextId!==void 0&&c.nextId!==-1&&!n},u=c=>{var n,d;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let h=s.getNode(c.parentId);if(!h)return c.node.type===Se.Document?this.newDocumentQueue.push(c):o.push(c);c.node.isShadow&&(Ie(h)||h.attachShadow({mode:"open"}),h=h.shadowRoot);let f=null,m=null;if(c.previousId&&(f=s.getNode(c.previousId)),c.nextId&&(m=s.getNode(c.nextId)),a(c))return o.push(c);if(c.node.rootId&&!s.getNode(c.node.rootId))return;const p=c.node.rootId?s.getNode(c.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Ye(h,s)){this.attachDocumentToIframe(c,h);return}const g=(w,C)=>{if(!this.usingVirtualDom){Ct(w);for(const v of this.config.plugins||[])v.onBuild&&v.onBuild(w,{id:C,replayer:this})}},b=rt(c.node,{doc:p,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:g});if(c.previousId===-1||c.nextId===-1){i[c.node.id]={node:b,mutation:c};return}const y=s.getMeta(h);if(y&&y.type===Se.Element&&c.node.type===Se.Text){const w=Array.isArray(h.childNodes)?h.childNodes:Array.from(h.childNodes);if(y.tagName==="textarea")for(const C of w)C.nodeType===h.TEXT_NODE&&h.removeChild(C);else if(y.tagName==="style"&&w.length===1)for(const C of w)C.nodeType===h.TEXT_NODE&&!s.hasNode(C)&&(b.textContent=C.textContent,h.removeChild(C))}else if((y==null?void 0:y.type)===Se.Document){const w=h;c.node.type===Se.DocumentType&&((n=w.childNodes[0])==null?void 0:n.nodeType)===Node.DOCUMENT_TYPE_NODE&&w.removeChild(w.childNodes[0]),b.nodeName==="HTML"&&w.documentElement&&w.removeChild(w.documentElement)}if(f&&f.nextSibling&&f.nextSibling.parentNode?h.insertBefore(b,f.nextSibling):m&&m.parentNode?h.contains(m)?h.insertBefore(b,m):h.insertBefore(b,null):h.appendChild(b),g(b,c.node.id),this.usingVirtualDom&&b.nodeName==="#text"&&h.nodeName==="STYLE"&&((d=h.rules)==null?void 0:d.length)>0&&(h.rules=[]),Ye(b,this.mirror)){const w=this.mirror.getId(b),C=this.newDocumentQueue.find(v=>v.parentId===w);C&&(this.attachDocumentToIframe(C,b),this.newDocumentQueue=this.newDocumentQueue.filter(v=>v!==C))}(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(i,h,b,c)};t.adds.forEach(c=>{u(c)});const l=Date.now();for(;o.length;){const c=go(o);if(o.length=0,Date.now()-l>500){this.warn("Timeout in the loop, please check the resolve tree data:",c);break}for(const n of c)s.getNode(n.value.parentId)?Fs(n,h=>{u(h)}):this.debug("Drop resolve tree since there is no parent for the root node.",n)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),yo(t.texts).forEach(c=>{var n;const d=s.getNode(c.id);if(!d)return t.removes.find(f=>f.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);const h=d.parentElement;if(c.value&&h&&h.tagName==="STYLE"?d.textContent=$t(c.value,this.cache):d.textContent=c.value,this.usingVirtualDom){const f=d.parentNode;((n=f==null?void 0:f.rules)==null?void 0:n.length)>0&&(f.rules=[])}}),t.attributes.forEach(c=>{var n;const d=s.getNode(c.id);if(!d)return t.removes.find(h=>h.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);for(const h in c.attributes)if(typeof h=="string"){const f=c.attributes[h];if(f===null)d.removeAttribute(h),h==="open"&&nc(d,c);else if(typeof f=="string")try{if(h==="_cssText"&&(d.nodeName==="LINK"||d.nodeName==="STYLE"))try{const m=s.getMeta(d),p=rt(se(P({},m),{attributes:P(P({},m.attributes),c.attributes)}),{doc:d.ownerDocument,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache});Object.assign(m.attributes,c.attributes);const g=d.nextSibling,b=d.parentNode;if(p&&b){b.removeChild(d),b.insertBefore(p,g),s.replace(c.id,p);break}}catch(m){}if(h==="value"&&d.nodeName==="TEXTAREA"){const m=d;m.childNodes.forEach(g=>m.removeChild(g));const p=(n=d.ownerDocument)==null?void 0:n.createTextNode(f);p&&m.appendChild(p)}else d.setAttribute(h,f);h==="rr_open_mode"&&d.nodeName==="DIALOG"&&Ct(d,c)}catch(m){this.warn("An error occurred may due to the checkout feature.",m)}else if(h==="style"){const m=f,p=d;for(const g in m)if(m[g]===!1)p.style.removeProperty(g);else if(m[g]instanceof Array){const b=m[g];p.style.setProperty(g,b[0],b[1])}else{const b=m[g];p.style.setProperty(g,b)}}}})}applyScroll(t,r){var s,i;const o=this.mirror.getNode(t.id);if(!o)return this.debugNodeNotFound(t,t.id);const a=this.mirror.getMeta(o);if(o===this.iframe.contentDocument)(s=this.iframe.contentWindow)==null||s.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else if((a==null?void 0:a.type)===Se.Document)(i=o.defaultView)==null||i.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else try{o.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"})}catch(u){}}applyInput(t){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);try{r.checked=t.isChecked,r.value=t.text}catch(s){}}applySelection(t){try{const r=new Set,s=t.ranges.map(({start:i,startOffset:o,end:a,endOffset:u})=>{const l=this.mirror.getNode(i),c=this.mirror.getNode(a);if(!l||!c)return;const n=new Range;n.setStart(l,o),n.setEnd(c,u);const d=l.ownerDocument,h=d==null?void 0:d.getSelection();return h&&r.add(h),{range:n,selection:h}});r.forEach(i=>i.removeAllRanges()),s.forEach(i=>{var o;return i&&((o=i.selection)==null?void 0:o.addRange(i.range))})}catch(r){}}applyStyleSheetMutation(t){var r;let s=null;t.styleId?s=this.styleMirror.getStyle(t.styleId):t.id&&(s=((r=this.mirror.getNode(t.id))==null?void 0:r.sheet)||null),s&&(t.source===A.StyleSheetRule?this.applyStyleSheetRule(t,s):t.source===A.StyleDeclaration&&this.applyStyleDeclaration(t,s))}applyStyleSheetRule(t,r){var s,i,o,a;if((s=t.adds)==null||s.forEach(({rule:u,index:l})=>{try{if(Array.isArray(l)){const{positions:c,index:n}=ns(l),d=qe(r.cssRules,c);d==null||d.insertRule(u,n)}else{const c=l===void 0?void 0:Math.min(l,r.cssRules.length);r==null||r.insertRule(u,c)}}catch(c){}}),(i=t.removes)==null||i.forEach(({index:u})=>{try{if(Array.isArray(u)){const{positions:l,index:c}=ns(u),n=qe(r.cssRules,l);n==null||n.deleteRule(c||0)}else r==null||r.deleteRule(u)}catch(l){}}),typeof t.replace=="string")try{(o=r.replace)==null||o.call(r,t.replace)}catch(u){}if(typeof t.replaceSync=="string")try{(a=r.replaceSync)==null||a.call(r,t.replaceSync)}catch(u){}}applyStyleDeclaration(t,r){if(t.set){const s=qe(r.rules,t.index);s!=null&&s.style&&s.style.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const s=qe(r.rules,t.index);s!=null&&s.style&&s.style.removeProperty(t.remove.property)}}applyAdoptedStyleSheet(t){var r;const s=this.mirror.getNode(t.id);if(!s)return;(r=t.styles)==null||r.forEach(u=>{var l;let c=null,n=null;if(Ie(s)?n=((l=s.ownerDocument)==null?void 0:l.defaultView)||null:s.nodeName==="#document"&&(n=s.defaultView),!!n)try{c=new n.CSSStyleSheet,this.styleMirror.add(c,u.styleId),this.applyStyleSheetRule({source:A.StyleSheetRule,adds:u.rules},c)}catch(d){}});const i=10;let o=0;const a=(u,l)=>{const c=l.map(n=>this.styleMirror.getStyle(n)).filter(n=>n!==null);Ie(u)?u.shadowRoot.adoptedStyleSheets=c:u.nodeName==="#document"&&(u.adoptedStyleSheets=c),c.length!==l.length&&o<i&&(setTimeout(()=>a(u,l),0+100*o),o++)};a(s,t.styleIds)}legacy_resolveMissingNode(t,r,s,i){const{previousId:o,nextId:a}=i,u=o&&t[o],l=a&&t[a];if(u){const{node:c,mutation:n}=u;r.insertBefore(c,s),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,c,n)}if(l){const{node:c,mutation:n}=l;r.insertBefore(c,s.nextSibling),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,c,n)}}moveAndHover(t,r,s,i,o){const a=this.mirror.getNode(s);if(!a)return this.debugNodeNotFound(o,s);const u=Bs(a,this.iframe),l=t*u.absoluteScale+u.x,c=r*u.absoluteScale+u.y;this.mouse.style.left=`${l}px`,this.mouse.style.top=`${c}px`,i||this.drawMouseTail({x:l,y:c}),this.hoverElements(a)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:r,lineWidth:s,strokeStyle:i,duration:o}=this.config.mouseTail===!0?ts:Object.assign({},ts,this.config.mouseTail),a=()=>{if(!this.mouseTail)return;const u=this.mouseTail.getContext("2d");!u||!this.tailPositions.length||(u.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),u.beginPath(),u.lineWidth=s,u.lineCap=r,u.strokeStyle=i,u.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(l=>u.lineTo(l.x,l.y)),u.stroke())};this.tailPositions.push(t),a(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(u=>u!==t),a()},o/this.speedService.state.context.timer.speed)}hoverElements(t){var r;(r=this.lastHoveredRootNode||this.iframe.contentDocument)==null||r.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")}),this.lastHoveredRootNode=t.getRootNode();let s=t;for(;s;)s.classList&&s.classList.add(":hover"),s=s.parentElement}isUserInteraction(t){return t.type!==_.IncrementalSnapshot?!1:t.data.source>A.Mutation&&t.data.source<=A.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(z.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,r){this.warn(`Node with id '${r}' not found. `,t)}warnCanvasMutationFailed(t,r){this.warn("Has error on canvas update",r,"canvas mutation:",t)}debugNodeNotFound(t,r){this.debug(`Node with id '${r}' not found. `,t)}warn(...t){this.config.showWarning&&this.config.logger.warn(In,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(In,...t)}}const{addCustomEvent:uc}=Te,{freezePage:cc}=Te,{takeFullSnapshot:hc}=Te;exports.EventType=_;exports.IncrementalSource=A;exports.MouseInteractions=j;exports.Replayer=lc;exports.ReplayerEvents=z;exports.addCustomEvent=uc;exports.canvasMutation=as;exports.freezePage=cc;exports.record=Te;exports.takeFullSnapshot=hc;exports.utils=au;
|
|
178
178
|
if (typeof module.exports == "object" && typeof exports == "object") {
|
|
179
179
|
var __cp = (to, from, except, desc) => {
|
|
180
180
|
if ((from && typeof from === "object") || typeof from === "function") {
|