@screeb/rrweb 1.0.20 → 1.0.21
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 +17 -15
- package/dist/rrweb.cjs.map +1 -1
- package/dist/rrweb.js +17 -15
- package/dist/rrweb.js.map +1 -1
- package/dist/rrweb.umd.cjs +18 -16
- package/dist/rrweb.umd.cjs.map +2 -2
- package/dist/rrweb.umd.min.cjs +1 -1
- package/dist/rrweb.umd.min.cjs.map +2 -2
- package/package.json +1 -1
package/dist/rrweb.umd.min.cjs
CHANGED
|
@@ -15,7 +15,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
15
15
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
16
16
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
17
17
|
PERFORMANCE OF THIS SOFTWARE.
|
|
18
|
-
***************************************************************************** */function Rs(e,t){var s=typeof Symbol=="function"&&e[Symbol.iterator];if(!s)return e;var r,n,i=s.call(e),o=[];try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(a){n={error:a}}finally{try{r&&!r.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return o}var Ue;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(Ue||(Ue={}));var vr={type:"xstate.init"};function It(e){return e===void 0?[]:[].concat(e)}function _e(e){return{type:"xstate.assign",assignment:e}}function xs(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 St(e){return function(t){return e===t}}function Er(e){return typeof e=="string"?{type:e}:e}function ks(e,t){return{value:e,context:t,actions:[],changed:!1,matches:St(e)}}function Os(e,t,s){var r=t,n=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){n=!0;var o=Object.assign({},r);return typeof i.assignment=="function"?o=i.assignment(r,s):Object.keys(i.assignment).forEach(function(a){o[a]=typeof i.assignment[a]=="function"?i.assignment[a](r,s):i.assignment[a]}),r=o,!1}return!0}),r,n]}function wr(e,t){t===void 0&&(t={});var s=Rs(Os(It(e.states[e.initial].entry).map(function(o){return xs(o,t.actions)}),e.context,vr),2),r=s[0],n=s[1],i={config:e,_options:t,initialState:{value:e.initial,actions:r,context:n,matches:St(e.initial)},transition:function(o,a){var l,c,u=typeof o=="string"?{value:o,context:e.context}:o,d=u.value,h=u.context,m=Er(a),f=e.states[d];if(f.on){var y=It(f.on[m.type]);try{for(var g=function(H){var O=typeof Symbol=="function"&&Symbol.iterator,se=O&&H[O],v=0;if(se)return se.call(H);if(H&&typeof H.length=="number")return{next:function(){return H&&v>=H.length&&(H=void 0),{value:H&&H[v++],done:!H}}};throw new TypeError(O?"Object is not iterable.":"Symbol.iterator is not defined.")}(y),p=g.next();!p.done;p=g.next()){var b=p.value;if(b===void 0)return ks(d,h);var E=typeof b=="string"?{target:b}:b,I=E.target,P=E.actions,R=P===void 0?[]:P,w=E.cond,_=w===void 0?function(){return!0}:w,Q=I===void 0,C=I??d,k=e.states[C];if(_(h,m)){var V=Rs(Os((Q?It(R):[].concat(f.exit,R,k.entry).filter(function(H){return H})).map(function(H){return xs(H,i._options.actions)}),h,m),3),Y=V[0],q=V[1],ne=V[2],J=I??d;return{value:J,context:q,actions:Y,changed:I!==d||Y.length>0||ne,matches:St(J)}}}}catch(H){l={error:H}}finally{try{p&&!p.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}}return ks(d,h)}};return i}var As=function(e,t){return e.actions.forEach(function(s){var r=s.exec;return r&&r(e.context,t)})};function Mr(e){var t=e.initialState,s=Ue.NotStarted,r=new Set,n={_machine:e,send:function(i){s===Ue.Running&&(t=e.transition(t,i),As(t,Er(i)),r.forEach(function(o){return o(t)}))},subscribe:function(i){return r.add(i),i(t),{unsubscribe:function(){return r.delete(i)}}},start:function(i){if(i){var o=typeof i=="object"?i:{context:e.config.context,value:i};t={value:o.value,actions:[],context:o.context,matches:St(o.value)}}return s=Ue.Running,As(t,vr),n},stop:function(){return s=Ue.Stopped,r.clear(),n},get state(){return t},get status(){return s}};return n}function Ri(e,t){let s=!1;for(let r=e.length-1;r>=0;r--){const n=e[r];if(n.type===T.FullSnapshot&&(s=!0),n.type===T.Meta&&s&&n.timestamp<=t)return e.slice(r)}return e}function xi(e,{getCastFn:t,applyEventsSynchronously:s,emitter:r}){const n=wr({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:_e({lastPlayedEvent:(i,o)=>o.type==="CAST_EVENT"?o.payload.event:i.lastPlayedEvent}),recordTimeOffset:_e((i,o)=>{let a=i.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(a=o.payload.timeOffset),{...i,timeOffset:a,baselineTime:i.events[0].timestamp+a}}),play(i){const{timer:o,events:a,baselineTime:l,lastPlayedEvent:c}=i;o.clear();for(const f of a)Ds(f,l);const u=Ri(a,l);let d=c?.timestamp;c?.type===T.IncrementalSnapshot&&c.data.source===M.MouseMove&&(d=c.timestamp+c.data.positions[0]?.timeOffset),l<(d||0)&&r.emit($.PlayBack);const h=new Array;let m=!1;for(const f of u){const y=f.type===T.FullSnapshot;if(d&&d<l&&(f.timestamp<=d||f===c)){y&&(m=!0);continue}if(f.timestamp<=l||y&&!m)y&&(m=!0),h.push(f);else{const g=t(f,!1);o.addAction({doAction:()=>{g()},delay:f.delay})}}s(h),r.emit($.Flush),o.start()},pause(i){i.timer.clear()},resetLastPlayedEvent:_e(i=>({...i,lastPlayedEvent:null})),startLive:_e({baselineTime:(i,o)=>(i.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:_e((i,o)=>{const{baselineTime:a,timer:l,events:c}=i;if(o.type==="ADD_EVENT"){const{event:u}=o.payload;Ds(u,a);let d=c.length-1;if(!c[d]||c[d].timestamp<=u.timestamp)c.push(u);else{let f=-1,y=0;for(;y<=d;){const g=Math.floor((y+d)/2);c[g].timestamp<=u.timestamp?y=g+1:d=g-1}f===-1&&(f=y),c.splice(f,0,u)}const h=u.timestamp<a||!l.isActive(),m=t(u,h);h?m():l.isActive()&&l.addAction({doAction:()=>{m()},delay:u.delay})}return{...i,events:c}})}});return Mr(n)}function ki(e){const t=wr({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:(s,r)=>{"payload"in r&&s.timer.setSpeed(r.payload.speed)},recordSpeed:_e({normalSpeed:s=>s.timer.speed}),restoreSpeed:s=>{s.timer.setSpeed(s.normalSpeed)}}});return Mr(t)}const Oi=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],_s=new Map;function Cr(e,t){let s=_s.get(e);return s||(s=new Map,_s.set(e,s)),s.has(t)||s.set(t,[]),s.get(t)}function pe(e,t,s){return async r=>{if(r&&typeof r=="object"&&"rr_type"in r)if(s&&(s.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const n=await pe(e,t,s)(r.args);return await createImageBitmap.apply(null,n)}else if("index"in r){if(s||t===null)return r;const{rr_type:n,index:i}=r;return Cr(t,n)[i]}else if("args"in r){const{rr_type:n,args:i}=r,o=window[n];return new o(...await Promise.all(i.map(pe(e,t,s))))}else{if("base64"in r)return fi(r.base64);if("src"in r){const n=e.get(r.src);if(n)return n;{const i=new Image;return i.src=r.src,e.set(r.src,i),i}}else if("data"in r&&r.rr_type==="Blob"){const n=await Promise.all(r.data.map(pe(e,t,s)));return new Blob(n,{type:r.type})}}else if(Array.isArray(r))return await Promise.all(r.map(pe(e,t,s)));return r}}function Ai(e,t){try{return t===me.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const _i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Li(e,t){if(!t?.constructor)return;const{name:s}=t.constructor;if(!_i.includes(s))return;const r=Cr(e,s);r.includes(t)||r.push(t)}async function Fi({mutation:e,target:t,type:s,imageMap:r,errorHandler:n}){try{const i=Ai(t,s);if(!i)return;if(e.setter){i[e.property]=e.args[0];return}const o=i[e.property],a=await Promise.all(e.args.map(pe(r,i))),l=o.apply(i,a);Li(i,l);const c=!1}catch(i){n(e,i)}}async function Pi({event:e,mutations:t,target:s,imageMap:r,errorHandler:n}){const i=s.getContext("2d");if(!i){n(t[0],new Error("Canvas context is null"));return}const o=t.map(async l=>Promise.all(l.args.map(pe(r,i))));(await Promise.all(o)).forEach((l,c)=>{const u=t[c];try{if(u.setter){i[u.property]=u.args[0];return}const d=i[u.property];u.property==="drawImage"&&typeof u.args[0]=="string"?(r.get(e),d.apply(i,u.args)):d.apply(i,l)}catch(d){n(u,d)}})}async function Pt({event:e,mutation:t,target:s,imageMap:r,canvasEventMap:n,errorHandler:i}){try{const o=n.get(e)||t,a="commands"in o?o.commands:[o];if([me.WebGL,me.WebGL2].includes(t.type)){for(let l=0;l<a.length;l++){const c=a[l];await Fi({mutation:c,type:t.type,target:s,imageMap:r,errorHandler:i})}return}await Pi({event:e,mutations:a,target:s,imageMap:r,errorHandler:i})}catch(o){i(t,o)}}const Ls=5*1e3,Wi=br||Ii,Fs="[replayer]";function Bi(e,t){let s=-1;if(e.length===0)return s;let r=0,n=e.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);e[i].timestamp<=t?(s=i,r=i+1):n=i-1}return s}const Tt={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Ui(e){if(e.type!==T.IncrementalSnapshot)return!1;const t=e.data;return t.source===M.MouseInteraction&&t.type===U.TouchStart?t.pointerType===de.Touch:!1}function Ps(e){return"pointerId"in e&&typeof e.pointerId=="number"?e.pointerId:-1}class Vi{constructor(t,s){if(this.usingVirtualDom=!1,this.virtualDom=new Ge,this.emitter=Wi(),this.legacy_missingNodeRetryMap={},this.cache=ms(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Us(),this.styleMirror=new Jt,this.firstFullSnapshot=null,this.newDocumentQueue=[],this.pointers={},this.mouseTailAnimationFrame=null,this.lastMouseDownEvent=null,this.lastSelectionData=null,this.constructedStyleMutations=[],this.adoptedStyleSheets=[],this.handleResize=a=>{this.iframe.style.display="inherit";for(const l of[...Object.values(this.pointers).flatMap(c=>c.mouseTail),this.iframe])l&&(l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)))},this.applyEventsSynchronously=a=>{for(const l of a){switch(l.type){case T.DomContentLoaded:case T.Load:case T.Custom:continue;case T.FullSnapshot:case T.Meta:case T.Plugin:case T.IncrementalSnapshot:break}this.getCastFn(l,!0)()}},this.getCastFn=(a,l=!1)=>{let c;switch(a.type){case T.DomContentLoaded:case T.Load:break;case T.Custom:c=()=>{this.emitter.emit($.CustomEvent,a)};break;case T.Meta:c=()=>this.emitter.emit($.Resize,{width:a.data.width,height:a.data.height});break;case T.FullSnapshot:c=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===a){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(a,l),this.iframe.contentWindow?.scrollTo(a.data.initialOffset),this.styleMirror.reset()};break;case T.IncrementalSnapshot:c=()=>{if(this.applyIncremental(a,l),!l&&(a===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const d of this.service.state.context.events)if(!(d.timestamp<=a.timestamp)&&this.isUserInteraction(d)){d.delay-a.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=d);break}if(this.nextUserInteractionEvent){const d=this.nextUserInteractionEvent.delay-a.delay,h={speed:Math.min(Math.round(d/Ls),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:h}),this.emitter.emit($.SkipStart,h)}}};break}return()=>{c&&c();for(const h of this.config.plugins||[])h.handler&&h.handler(a,l,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:a}});const d=this.service.state.context.events.length-1;if(!this.config.liveMode&&a===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($.Finish))};let m=50;a.type===T.IncrementalSnapshot&&a.data.source===M.MouseMove&&a.data.positions.length&&(m+=Math.max(0,-a.data.positions[0].timeOffset)),ue(h,m)}this.emitter.emit($.EventCast,a)}},this.stepMouseTails=a=>{const{lineCap:l,lineWidth:c,strokeStyle:u,duration:d}=this.config.mouseTail===!0?Tt:Object.assign({},Tt,this.config.mouseTail),h=d/this.speedService.state.context.timer.speed;let m=!1;Object.values(this.pointers).forEach(f=>{if(!f.mouseTail)return;const y=f.mouseTail,g=y.getContext("2d");if(g&&(f.tailPositions=f.tailPositions.filter(p=>a-p.t<=h),g.clearRect(0,0,y.width,y.height),f.tailPositions.length>1)){m=!0,g.lineWidth=c,g.lineCap=l,g.strokeStyle=u;for(let p=1;p<f.tailPositions.length;p++){const b=f.tailPositions[p-1],E=f.tailPositions[p],I=(a-E.t)/h,P=Math.max(0,1-I);P<=0||(g.globalAlpha=P,g.beginPath(),g.moveTo(b.x,b.y),g.lineTo(E.x,E.y),g.stroke())}g.globalAlpha=1}}),m?this.mouseTailAnimationFrame=requestAnimationFrame(this.stepMouseTails):this.mouseTailAnimationFrame=null},!s?.liveMode&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={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:Tt,useVirtualDom:!0,logger:console};this.config=Object.assign({},r,s),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on($.Resize,this.handleResize),this.setupDom();for(const a of this.config.plugins||[])a.getMirror&&a.getMirror({nodeMirror:this.mirror});this.emitter.on($.Flush,()=>{if(this.usingVirtualDom){const a={mirror:this.mirror,applyCanvas:(c,u,d)=>{Pt({event:c,mutation:u,target:d,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(c,u)=>{c.source===M.StyleSheetRule?this.applyStyleSheetRule(c,u):c.source===M.StyleDeclaration&&this.applyStyleDeclaration(c,u)},afterAppend:(c,u)=>{for(const d of this.config.plugins||[])d.onBuild&&d.onBuild(c,{id:u,replayer:this})}},l=ee(this.iframe);if(l)try{pt(l,this.virtualDom,a,this.virtualDom.mirror)}catch(c){console.warn(c)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[c],d=mt(u.node,this.mirror,this.virtualDom.mirror);pt(d,u.node,a,this.virtualDom.mirror),u.node=d}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(c=>{this.applyStyleSheetMutation(c)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(c=>{this.applyAdoptedStyleSheet(c)}),this.adoptedStyleSheets=[]}for(const[a,{pointerPosition:l,touchActive:c}]of Object.entries(this.pointers)){const u=parseInt(a),d=this.pointers[u];l&&(this.moveAndHover(l.x,l.y,l.id,!0,l.debugData,u),d.pointerPosition=null),c===!0?d.pointerEl.classList.add("touch-active"):c===!1&&d.pointerEl.classList.remove("touch-active"),d.touchActive=null}if(this.lastMouseDownEvent){const[a,l]=this.lastMouseDownEvent;a.dispatchEvent(l)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on($.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset()});const n=new Di([],{speed:this.config.speed});this.service=xi({events:t.map(a=>s&&s.unpackFn?s.unpackFn(a):a).sort((a,l)=>a.timestamp-l.timestamp),timer:n,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(a=>{this.emitter.emit($.StateChange,{player:a})}),this.speedService=ki({normalSpeed:-1,timer:n}),this.speedService.start(),this.speedService.subscribe(a=>{this.emitter.emit($.StateChange,{speed:a})});const i=this.service.state.context.events.find(a=>a.type===T.Meta),o=this.service.state.context.events.find(a=>a.type===T.FullSnapshot);if(i){const{width:a,height:l}=i.data;ue(()=>{this.emitter.emit($.Resize,{width:a,height:l})},0)}o&&ue(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),this.iframe.contentWindow?.scrollTo(o.data.initialOffset))},1)}get timer(){return this.service.state.context.timer}createPointer(t,s){const r=document.createElement("canvas");r.classList.add("replayer-mouse-tail"),r.width=Number.parseFloat(this.iframe.width),r.height=Number.parseFloat(this.iframe.height),this.wrapper.insertBefore(r,this.iframe),r.style.display=this.config.mouseTail===!1?"none":"inherit";const n=document.createElement("div");n.classList.add("replayer-mouse"),this.pointers[t]={touchActive:null,pointerEl:n,tailPositions:[],pointerPosition:null,mouseTail:r},Ui(s)&&n.classList.add("touch-device"),this.wrapper.appendChild(n)}on(t,s){return this.emitter.on(t,s),this}off(t,s){return this.emitter.off(t,s),this}setConfig(t){const s=this.config.skipInactive;if(Object.keys(t).forEach(r=>{t[r],this.config[r]=t[r]}),this.config.skipInactive?s===!1&&this.config.skipInactive===!0&&this.reevaluateFastForward():this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u")if(t.mouseTail===!1)for(const{mouseTail:r}of Object.values(this.pointers))r&&(r.style.display="none");else for(let{mouseTail:r}of Object.values(this.pointers))r||(r=document.createElement("canvas"),r.width=Number.parseFloat(this.iframe.width),r.height=Number.parseFloat(this.iframe.height),r.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(r,this.iframe)),r.style.display="inherit"}getMetaData(){const t=this.service.state.context.events[0],s=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:s.timestamp,totalTime:s.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:s}=this.service.state.context;return t-s[0].timestamp}getMirror(){return this.mirror}play(t=0){this.config.skipInactive&&this.speedService.state.matches("skipping")&&this.backToNormal(),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}})),ee(this.iframe)?.getElementsByTagName("html")[0]?.classList.remove("rrweb-paused"),this.emitter.emit($.Start),this.config.skipInactive&&this.reevaluateFastForward()}pause(t){t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),ee(this.iframe)?.getElementsByTagName("html")[0]?.classList.add("rrweb-paused"),this.emitter.emit($.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($.Resume)}destroy(){this.pause(),this.config.root.removeChild(this.wrapper),this.emitter.emit($.Destroy)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const s=this.config.unpackFn?this.config.unpackFn(t):t;Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:s}}))}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=ms()}reevaluateFastForward(){if(!this.config.skipInactive)return;this.nextUserInteractionEvent=null;const t=this.service.state.context.events,s=t[0];if(!s)return;const r=s.timestamp+this.getCurrentTime(),n=Bi(t,r);if(n===-1)return;const i=t[n],o=this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed;for(let a=n+1;a<t.length;a++){const l=t[a];if(this.isUserInteraction(l)){const c=l.timestamp-i.timestamp;if(c>o){this.nextUserInteractionEvent=l;const u={speed:Math.min(Math.round(c/Ls),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:u}),this.emitter.emit($.SkipStart,u)}break}}}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe);const s=ee(this.iframe),r=ir(this.iframe);r&&s&&(Ti(r,s),Yt(r))}rebuildFullSnapshot(t,s=!1){const r=ee(this.iframe);if(!r)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 n=[],i=(l,c)=>{this.collectIframeAndAttachDocument(n,l);for(const u of this.config.plugins||[])u.onBuild&&u.onBuild(l,{id:c,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),pn(t.data.node,{doc:r,afterAppend:i,cache:this.cache,mirror:this.mirror}),i(r,t.data.node.id);for(const{mutationInQueue:l,builtNode:c}of n)this.attachDocumentToIframe(l,c),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==l);const{documentElement:o,head:a}=r;if(this.insertStyleRules(o,a),!this.service.state.matches("playing")){const l=r.getElementsByTagName("html")[0];l&&l.classList.add("rrweb-paused")}this.emitter.emit($.FullsnapshotRebuilded,t),s||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,s){const r=Oi(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const n=this.virtualDom.createElement("style");this.virtualDom.mirror.add(n,lr(n,this.virtualDom.unserializedId)),t.insertBefore(n,s),n.rules.push({source:M.StyleSheetRule,adds:r.map((i,o)=>({rule:i,index:o}))})}else{const n=document.createElement("style");t.insertBefore(n,s);for(let i=0;i<r.length;i++)n.sheet?.insertRule(r[i],i)}}attachDocumentToIframe(t,s){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,n=ee(s),i=[],o=(a,l)=>{this.collectIframeAndAttachDocument(i,a);const c=r.getMeta(a);if(c?.type===x.Element&&c?.tagName.toUpperCase()==="HTML"&&n){const{documentElement:u,head:d}=n;this.insertStyleRules(u,d)}if(!this.usingVirtualDom)for(const u of this.config.plugins||[])u.onBuild&&u.onBuild(a,{id:l,replayer:this})};Je(t.node,{doc:n,mirror:r,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(n,t.node.id);for(const{mutationInQueue:a,builtNode:l}of i)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a)}collectIframeAndAttachDocument(t,s){if(Ve(s,this.mirror)){const r=this.newDocumentQueue.find(n=>n.parentId===this.mirror.getId(s));r&&t.push({mutationInQueue:r,builtNode:s})}}waitForStylesheetLoad(){const s=ee(this.iframe)?.head;if(s){const r=new Set;let n,i=this.service.state;const o=()=>{i=this.service.state};this.emitter.on($.Start,o),this.emitter.on($.Pause,o);const a=()=>{this.emitter.off($.Start,o),this.emitter.off($.Pause,o)};s.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{l.sheet||(r.add(l),l.addEventListener("load",()=>{r.delete(l),r.size===0&&n!==-1&&(i.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit($.LoadStylesheetEnd),n&&ts(n),a())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit($.LoadStylesheetStart),n=ue(()=>{i.matches("playing")&&this.play(this.getCurrentTime()),n=-1,a()},this.config.loadTimeout))}}async preloadAllImages(){const t=[];for(const s of this.service.state.context.events)s.type===T.IncrementalSnapshot&&s.data.source===M.CanvasMutation&&(t.push(this.deserializeAndPreloadCanvasEvents(s.data,s)),("commands"in s.data?s.data.commands:[s.data]).forEach(n=>{this.preloadImages(n,s)}));return Promise.all(t)}preloadImages(t,s){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(s)){const r=document.createElement("canvas"),n=r.getContext("2d"),i=n?.createImageData(r.width,r.height);n?.putImageData(i,0,0)}}async deserializeAndPreloadCanvasEvents(t,s){if(!this.canvasEventMap.has(s)){const r={isUnchanged:!0};if("commands"in t){const n=await Promise.all(t.commands.map(async i=>{const o=await Promise.all(i.args.map(pe(this.imageMap,null,r)));return{...i,args:o}}));r.isUnchanged===!1&&this.canvasEventMap.set(s,{...t,commands:n})}else{const n=await Promise.all(t.args.map(pe(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(s,{...t,args:n})}}}applyIncremental(t,s){const{data:r}=t;switch(r.source){case M.Mutation:{try{this.applyMutation(r,s)}catch(n){this.warn(`Exception in mutation ${n.message||n}`,r)}break}case M.Drag:case M.TouchMove:case M.MouseMove:{const n=Ps(r);this.pointers[n]||this.createPointer(n,t);const i=this.pointers[n];if(s){const o=r.positions[r.positions.length-1];i.pointerPosition={x:o.x,y:o.y,id:o.id,debugData:r}}else r.positions.forEach(o=>{const a={doAction:()=>{this.moveAndHover(o.x,o.y,o.id,s,r,n)},delay:o.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(a)}),this.timer.addAction({doAction(){},delay:t.delay-r.positions[0]?.timeOffset});break}case M.MouseInteraction:{const n=Ps(r);this.pointers[n]||this.createPointer(n,t);const i=this.pointers[n];if(r.id===-1)break;const o=new Event(De(U[r.type])),a=this.mirror.getNode(r.id);if(!a)return this.debugNodeNotFound(r,r.id);this.emitter.emit($.MouseInteraction,{type:r.type,target:a});const{triggerFocus:l}=this.config;switch(r.type){case U.Blur:"blur"in a&&a.blur();break;case U.Focus:l&&a.focus&&a.focus({preventScroll:!0});break;case U.Click:case U.TouchStart:case U.TouchEnd:case U.MouseDown:case U.MouseUp:s?(r.type===U.TouchStart?(i.touchActive=!0,Object.values(this.pointers).forEach(c=>{c!==i&&!c.touchActive&&(c.touchActive=!1)})):r.type===U.TouchEnd&&(i.touchActive=!1,i.pointerEl.remove(),i.mouseTail&&i.mouseTail.remove(),delete this.pointers[n]),r.type===U.MouseDown?this.lastMouseDownEvent=[a,o]:r.type===U.MouseUp&&(this.lastMouseDownEvent=null),i.pointerPosition={x:r.x||0,y:r.y||0,id:r.id,debugData:r}):(r.type===U.TouchStart&&(i.tailPositions.length=0),this.moveAndHover(r.x||0,r.y||0,r.id,s,r,n),r.type===U.Click?(i.pointerEl.classList.remove("active"),i.pointerEl.offsetWidth,i.pointerEl.classList.add("active")):r.type===U.TouchStart?(i.pointerEl.offsetWidth,i.pointerEl.classList.add("touch-active")):r.type===U.TouchEnd?(i.pointerEl.remove(),i.mouseTail&&i.mouseTail.remove(),delete this.pointers[n]):a.dispatchEvent(o));break;case U.TouchCancel:s?i.touchActive=!1:i.pointerEl.classList.remove("touch-active");break;default:a.dispatchEvent(o)}break}case M.Scroll:{if(r.id===-1)break;if(this.usingVirtualDom){const n=this.virtualDom.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);n.scrollData=r;break}this.applyScroll(r,s);break}case M.ViewportResize:this.emitter.emit($.Resize,{width:r.width,height:r.height});break;case M.Input:{if(r.id===-1)break;if(this.usingVirtualDom){const n=this.virtualDom.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);n.inputData=r;break}this.applyInput(r);break}case M.MediaInteraction:{const n=this.usingVirtualDom?this.virtualDom.mirror.getNode(r.id):this.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);const i=n;try{if(r.currentTime!==void 0&&(i.currentTime=r.currentTime),r.volume!==void 0&&(i.volume=r.volume),r.muted!==void 0&&(i.muted=r.muted),r.type===fe.Pause&&i.pause(),r.type===fe.Play){const o=i.play();typeof o?.catch=="function"&&o.catch(a=>{console.warn(a)})}r.type===fe.RateChange&&(i.playbackRate=r.playbackRate)}catch(o){this.warn(`Failed to replay media interactions: ${o.message||o}`)}break}case M.StyleSheetRule:case M.StyleDeclaration:{this.usingVirtualDom?r.styleId?this.constructedStyleMutations.push(r):r.id&&this.virtualDom.mirror.getNode(r.id)?.rules?.push(r):this.applyStyleSheetMutation(r);break}case M.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const n=this.virtualDom.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);n.canvasMutations.push({event:t,mutation:r})}else{const n=this.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);Pt({event:t,mutation:r,target:n,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case M.Font:{try{const n=new FontFace(r.family,r.buffer?new Uint8Array(JSON.parse(r.fontSource)):r.fontSource,r.descriptors);ee(this.iframe)?.fonts.add(n)}catch(n){this.warn(n)}break}case M.Selection:{if(s){this.lastSelectionData=r;break}this.applySelection(r);break}case M.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(r):this.applyAdoptedStyleSheet(r);break}}}applyMutation(t,s){if(this.config.useVirtualDom&&!this.usingVirtualDom&&s){this.usingVirtualDom=!0;const c=ee(this.iframe);if(c&&zn(c,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length)for(const u in this.legacy_missingNodeRetryMap)try{const d=this.legacy_missingNodeRetryMap[u],h=ar(d.node,this.virtualDom,this.mirror);h&&(d.node=h)}catch(d){this.warn(d)}}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(c=>r.getNode(c.id)?!0:(this.warnNodeNotFound(t,c.id),!1)),t.removes.forEach(c=>{const u=r.getNode(c.id);if(!u)return;let d=r.getNode(c.parentId);if(!d)return this.warnNodeNotFound(t,c.parentId);if(c.isShadow&&be(d)&&(d=d.shadowRoot),r.removeNodeFromMap(u),d)try{d.removeChild(u),this.usingVirtualDom&&u.nodeName==="#text"&&d.nodeName==="STYLE"&&d.rules?.length>0&&(d.rules=[])}catch(h){if(h instanceof DOMException)this.warn("parent could not remove child in mutation",d,u,t);else throw h}});const n={...this.legacy_missingNodeRetryMap},i=[],o=c=>{let u=null;return c.nextId&&(u=r.getNode(c.nextId)),c.nextId!==null&&c.nextId!==void 0&&c.nextId!==-1&&!u},a=c=>{const u=ee(this.iframe);if(!u)return this.warn("Looks like your replayer has been destroyed.");let d=r.getNode(c.parentId);if(!d)return c.node.type===x.Document?this.newDocumentQueue.push(c):i.push(c);c.node.isShadow&&(be(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,m=null;if(c.previousId&&(h=r.getNode(c.previousId)),c.nextId&&(m=r.getNode(c.nextId)),o(c))return i.push(c);if(c.node.rootId&&!r.getNode(c.node.rootId))return;const f=c.node.rootId?r.getNode(c.node.rootId):this.usingVirtualDom?this.virtualDom:u;if(Ve(d,r)){this.attachDocumentToIframe(c,d);return}const y=(b,E)=>{if(!this.usingVirtualDom)for(const I of this.config.plugins||[])I.onBuild&&I.onBuild(b,{id:E,replayer:this})},g=Je(c.node,{doc:f,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:y});if(c.previousId===-1||c.nextId===-1){n[c.node.id]={node:g,mutation:c};return}const p=r.getMeta(d);if(p&&p.type===x.Element&&p.tagName==="textarea"&&c.node.type===x.Text){const b=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const E of b)E.nodeType===d.TEXT_NODE&&d.removeChild(E)}else if(p?.type===x.Document){const b=d;c.node.type===x.DocumentType&&b.childNodes[0]?.nodeType===Node.DOCUMENT_TYPE_NODE&&b.removeChild(b.childNodes[0]),g.nodeName==="HTML"&&b.documentElement&&b.removeChild(b.documentElement)}if(h&&h.nextSibling&&h.nextSibling.parentNode?d.insertBefore(g,h.nextSibling):m&&m.parentNode?d.contains(m)?d.insertBefore(g,m):d.insertBefore(g,null):d.appendChild(g),y(g,c.node.id),this.usingVirtualDom&&g.nodeName==="#text"&&d.nodeName==="STYLE"&&d.rules?.length>0&&(d.rules=[]),Ve(g,this.mirror)){const b=this.mirror.getId(g),E=this.newDocumentQueue.find(I=>I.parentId===b);E&&(this.attachDocumentToIframe(E,g),this.newDocumentQueue=this.newDocumentQueue.filter(I=>I!==E))}(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(n,d,g,c)};t.adds.forEach(c=>{a(c)});const l=Date.now();for(;i.length;){const c=qs(i);if(i.length=0,Date.now()-l>500){this.warn("Timeout in the loop, please check the resolve tree data:",c);break}for(const u of c)r.getNode(u.value.parentId)?Xt(u,h=>{a(h)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(n).length&&Object.assign(this.legacy_missingNodeRetryMap,n),Qs(t.texts).forEach(c=>{const u=r.getNode(c.id);if(!u)return t.removes.find(d=>d.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);if(u.textContent=c.value,this.usingVirtualDom){const d=u.parentNode;d?.rules?.length>0&&(d.rules=[])}}),t.attributes.forEach(c=>{const u=r.getNode(c.id);if(!u)return t.removes.find(d=>d.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);for(const d in c.attributes)if(typeof d=="string"){const h=c.attributes[d];if(h===null)u.removeAttribute(d);else if(typeof h=="string")try{if(d==="_cssText"&&(u.nodeName==="LINK"||u.nodeName==="STYLE"))try{const m=r.getMeta(u),f=Je({...m,attributes:{...m.attributes,...c.attributes}},{doc:u.ownerDocument,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache}),y=u.nextSibling,g=u.parentNode;if(f&&g){g.removeChild(u),g.insertBefore(f,y),r.replace(c.id,f);break}}catch{}u.nodeType!==3&&u.setAttribute(d,h)}catch(m){this.warn("An error occurred may due to the checkout feature.",m)}else if(d==="style"){const m=h,f=u;for(const y in m)if(m[y]===!1)f.style.removeProperty(y);else if(m[y]instanceof Array){const g=m[y];f.style.setProperty(y,g[0],g[1])}else{const g=m[y];f.style.setProperty(y,g)}}}})}applyScroll(t,s){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const n=this.mirror.getMeta(r),i=ee(this.iframe);if(r===i)this.iframe.contentWindow?.scrollTo({top:t.y,left:t.x,behavior:s?"auto":"smooth"});else if(n?.type===x.Document)r.defaultView?.scrollTo({top:t.y,left:t.x,behavior:s?"auto":"smooth"});else try{r.scrollTo({top:t.y,left:t.x,behavior:s?"auto":"smooth"})}catch{}}applyInput(t){const s=this.mirror.getNode(t.id);if(!s)return this.debugNodeNotFound(t,t.id);try{s.checked=t.isChecked,s.value=t.text}catch{}}applySelection(t){try{const s=new Set,r=t.ranges.map(({start:n,startOffset:i,end:o,endOffset:a})=>{const l=this.mirror.getNode(n),c=this.mirror.getNode(o);if(!l||!c)return;const u=new Range;u.setStart(l,i),u.setEnd(c,a);const h=l.ownerDocument?.getSelection();return h&&s.add(h),{range:u,selection:h}});s.forEach(n=>n.removeAllRanges()),r.forEach(n=>n&&n.selection?.addRange(n.range))}catch{}}applyStyleSheetMutation(t){let s=null;t.styleId?s=this.styleMirror.getStyle(t.styleId):t.id&&(s=this.mirror.getNode(t.id)?.sheet||null),s&&(t.source===M.StyleSheetRule?this.applyStyleSheetRule(t,s):t.source===M.StyleDeclaration&&this.applyStyleDeclaration(t,s))}applyStyleSheetRule(t,s){if(t.adds?.forEach(({rule:r,index:n})=>{try{if(Array.isArray(n)){const{positions:i,index:o}=Ot(n);We(s.cssRules,i).insertRule(r,o)}else{const i=n===void 0?void 0:Math.min(n,s.cssRules.length);s?.insertRule(r,i)}}catch{}}),t.removes?.forEach(({index:r})=>{try{if(Array.isArray(r)){const{positions:n,index:i}=Ot(r);We(s.cssRules,n).deleteRule(i||0)}else s?.deleteRule(r)}catch{}}),t.replace)try{s.replace?.(t.replace)}catch{}if(t.replaceSync)try{s.replaceSync?.(t.replaceSync)}catch{}}applyStyleDeclaration(t,s){if(t.set){const r=We(s.rules,t.index);r&&r.style&&r.style.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const r=We(s.rules,t.index);r&&r.style&&r.style.removeProperty(t.remove.property)}}applyAdoptedStyleSheet(t){const s=this.mirror.getNode(t.id);if(!s)return;t.styles?.forEach(o=>{let a=null,l=null;if(be(s)?l=s.ownerDocument?.defaultView||null:s.nodeName==="#document"&&(l=s.defaultView),!!l)try{a=new l.CSSStyleSheet,this.styleMirror.add(a,o.styleId),this.applyStyleSheetRule({source:M.StyleSheetRule,adds:o.rules},a)}catch{}});const r=10;let n=0;const i=(o,a)=>{const l=a.map(c=>this.styleMirror.getStyle(c)).filter(c=>c!==null);be(o)?o.shadowRoot.adoptedStyleSheets=l:o.nodeName==="#document"&&(o.adoptedStyleSheets=l),l.length!==a.length&&n<r&&(ue(()=>i(o,a),0+100*n),n++)};i(s,t.styleIds)}legacy_resolveMissingNode(t,s,r,n){const{previousId:i,nextId:o}=n,a=i&&t[i],l=o&&t[o];if(a){const{node:c,mutation:u}=a;s.insertBefore(c,r),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,s,c,u)}if(l){const{node:c,mutation:u}=l;s.insertBefore(c,r.nextSibling),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,s,c,u)}}moveAndHover(t,s,r,n,i,o){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(i,r);const l=Qt(a,this.iframe),c=t*l.absoluteScale+l.x,u=s*l.absoluteScale+l.y,d=this.pointers[o];d&&d.pointerEl&&(d.pointerEl.style.left=`${c}px`,d.pointerEl.style.top=`${u}px`),n||this.drawMouseTail({x:c,y:u},o),this.hoverElements(a)}drawMouseTail(t,s){const r=this.pointers[s];if(!r||!r.mouseTail)return;const n=typeof performance<"u"?performance.now():Date.now();r.tailPositions.push({x:t.x,y:t.y,t:n}),this.mouseTailAnimationFrame===null&&(this.mouseTailAnimationFrame=requestAnimationFrame(this.stepMouseTails))}hoverElements(t){const s=ee(this.iframe),r=this.lastHoveredRootNode||s;r&&typeof r.querySelectorAll=="function"&&r.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")}),this.lastHoveredRootNode=t.getRootNode();let n=t;for(;n;)n.classList&&n.classList.add(":hover"),n=n.parentElement}isUserInteraction(t){return t.type!==T.IncrementalSnapshot?!1:t.data.source>M.Mutation&&t.data.source<=M.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit($.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,s){this.warn(`Node with id '${s}' not found. `,t)}warnCanvasMutationFailed(t,s){this.warn("Has error on canvas update",s,"canvas mutation:",t)}debugNodeNotFound(t,s){this.debug(`Node with id '${s}' not found. `,t)}warn(...t){this.config.showWarning&&this.config.logger.warn(Fs,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(Fs,...t)}}exports.CanvasManager=vi;exports.EventType=T;exports.IncrementalSource=M;exports.MouseInteractions=U;exports.Replayer=Vi;exports.ReplayerEvents=$;exports.addCustomEvent=Mi;exports.canvasMutation=Pt;exports.deserializeArg=pe;exports.freezePage=Ci;exports.record=os;exports.takeFullSnapshot=Sr;exports.utils=mn;
|
|
18
|
+
***************************************************************************** */function Rs(e,t){var s=typeof Symbol=="function"&&e[Symbol.iterator];if(!s)return e;var r,n,i=s.call(e),o=[];try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(a){n={error:a}}finally{try{r&&!r.done&&(s=i.return)&&s.call(i)}finally{if(n)throw n.error}}return o}var Ue;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(Ue||(Ue={}));var vr={type:"xstate.init"};function It(e){return e===void 0?[]:[].concat(e)}function _e(e){return{type:"xstate.assign",assignment:e}}function xs(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 St(e){return function(t){return e===t}}function Er(e){return typeof e=="string"?{type:e}:e}function ks(e,t){return{value:e,context:t,actions:[],changed:!1,matches:St(e)}}function Os(e,t,s){var r=t,n=!1;return[e.filter(function(i){if(i.type==="xstate.assign"){n=!0;var o=Object.assign({},r);return typeof i.assignment=="function"?o=i.assignment(r,s):Object.keys(i.assignment).forEach(function(a){o[a]=typeof i.assignment[a]=="function"?i.assignment[a](r,s):i.assignment[a]}),r=o,!1}return!0}),r,n]}function wr(e,t){t===void 0&&(t={});var s=Rs(Os(It(e.states[e.initial].entry).map(function(o){return xs(o,t.actions)}),e.context,vr),2),r=s[0],n=s[1],i={config:e,_options:t,initialState:{value:e.initial,actions:r,context:n,matches:St(e.initial)},transition:function(o,a){var l,c,u=typeof o=="string"?{value:o,context:e.context}:o,d=u.value,h=u.context,m=Er(a),f=e.states[d];if(f.on){var y=It(f.on[m.type]);try{for(var g=function(H){var O=typeof Symbol=="function"&&Symbol.iterator,se=O&&H[O],v=0;if(se)return se.call(H);if(H&&typeof H.length=="number")return{next:function(){return H&&v>=H.length&&(H=void 0),{value:H&&H[v++],done:!H}}};throw new TypeError(O?"Object is not iterable.":"Symbol.iterator is not defined.")}(y),p=g.next();!p.done;p=g.next()){var b=p.value;if(b===void 0)return ks(d,h);var E=typeof b=="string"?{target:b}:b,I=E.target,P=E.actions,R=P===void 0?[]:P,w=E.cond,_=w===void 0?function(){return!0}:w,Q=I===void 0,C=I??d,k=e.states[C];if(_(h,m)){var V=Rs(Os((Q?It(R):[].concat(f.exit,R,k.entry).filter(function(H){return H})).map(function(H){return xs(H,i._options.actions)}),h,m),3),Y=V[0],q=V[1],ne=V[2],J=I??d;return{value:J,context:q,actions:Y,changed:I!==d||Y.length>0||ne,matches:St(J)}}}}catch(H){l={error:H}}finally{try{p&&!p.done&&(c=g.return)&&c.call(g)}finally{if(l)throw l.error}}}return ks(d,h)}};return i}var As=function(e,t){return e.actions.forEach(function(s){var r=s.exec;return r&&r(e.context,t)})};function Mr(e){var t=e.initialState,s=Ue.NotStarted,r=new Set,n={_machine:e,send:function(i){s===Ue.Running&&(t=e.transition(t,i),As(t,Er(i)),r.forEach(function(o){return o(t)}))},subscribe:function(i){return r.add(i),i(t),{unsubscribe:function(){return r.delete(i)}}},start:function(i){if(i){var o=typeof i=="object"?i:{context:e.config.context,value:i};t={value:o.value,actions:[],context:o.context,matches:St(o.value)}}return s=Ue.Running,As(t,vr),n},stop:function(){return s=Ue.Stopped,r.clear(),n},get state(){return t},get status(){return s}};return n}function Ri(e,t){let s=!1;for(let r=e.length-1;r>=0;r--){const n=e[r];if(n.type===T.FullSnapshot&&(s=!0),n.type===T.Meta&&s&&n.timestamp<=t)return e.slice(r)}return e}function xi(e,{getCastFn:t,applyEventsSynchronously:s,emitter:r}){const n=wr({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:_e({lastPlayedEvent:(i,o)=>o.type==="CAST_EVENT"?o.payload.event:i.lastPlayedEvent}),recordTimeOffset:_e((i,o)=>{let a=i.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(a=o.payload.timeOffset),{...i,timeOffset:a,baselineTime:i.events[0].timestamp+a}}),play(i){const{timer:o,events:a,baselineTime:l,lastPlayedEvent:c}=i;o.clear();for(const f of a)Ds(f,l);const u=Ri(a,l);let d=c?.timestamp;c?.type===T.IncrementalSnapshot&&c.data.source===M.MouseMove&&(d=c.timestamp+c.data.positions[0]?.timeOffset),l<(d||0)&&r.emit($.PlayBack);const h=new Array;let m=!1;for(const f of u){const y=f.type===T.FullSnapshot;if(d&&d<l&&(f.timestamp<=d||f===c)){y&&(m=!0);continue}if(f.timestamp<=l||y&&!m)y&&(m=!0),h.push(f);else{const g=t(f,!1);o.addAction({doAction:()=>{g()},delay:f.delay})}}s(h),r.emit($.Flush),o.start()},pause(i){i.timer.clear()},resetLastPlayedEvent:_e(i=>({...i,lastPlayedEvent:null})),startLive:_e({baselineTime:(i,o)=>(i.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:_e((i,o)=>{const{baselineTime:a,timer:l,events:c}=i;if(o.type==="ADD_EVENT"){const{event:u}=o.payload;Ds(u,a);let d=c.length-1;if(!c[d]||c[d].timestamp<=u.timestamp)c.push(u);else{let f=-1,y=0;for(;y<=d;){const g=Math.floor((y+d)/2);c[g].timestamp<=u.timestamp?y=g+1:d=g-1}f===-1&&(f=y),c.splice(f,0,u)}const h=u.timestamp<a,m=t(u,h);h?m():l.isActive()&&l.addAction({doAction:()=>{m()},delay:u.delay})}return{...i,events:c}})}});return Mr(n)}function ki(e){const t=wr({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:(s,r)=>{"payload"in r&&s.timer.setSpeed(r.payload.speed)},recordSpeed:_e({normalSpeed:s=>s.timer.speed}),restoreSpeed:s=>{s.timer.setSpeed(s.normalSpeed)}}});return Mr(t)}const Oi=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],_s=new Map;function Cr(e,t){let s=_s.get(e);return s||(s=new Map,_s.set(e,s)),s.has(t)||s.set(t,[]),s.get(t)}function pe(e,t,s){return async r=>{if(r&&typeof r=="object"&&"rr_type"in r)if(s&&(s.isUnchanged=!1),r.rr_type==="ImageBitmap"&&"args"in r){const n=await pe(e,t,s)(r.args);return await createImageBitmap.apply(null,n)}else if("index"in r){if(s||t===null)return r;const{rr_type:n,index:i}=r;return Cr(t,n)[i]}else if("args"in r){const{rr_type:n,args:i}=r,o=window[n];return new o(...await Promise.all(i.map(pe(e,t,s))))}else{if("base64"in r)return fi(r.base64);if("src"in r){const n=e.get(r.src);if(n)return n;{const i=new Image;return i.src=r.src,e.set(r.src,i),i}}else if("data"in r&&r.rr_type==="Blob"){const n=await Promise.all(r.data.map(pe(e,t,s)));return new Blob(n,{type:r.type})}}else if(Array.isArray(r))return await Promise.all(r.map(pe(e,t,s)));return r}}function Ai(e,t){try{return t===me.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch{return null}}const _i=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Li(e,t){if(!t?.constructor)return;const{name:s}=t.constructor;if(!_i.includes(s))return;const r=Cr(e,s);r.includes(t)||r.push(t)}async function Fi({mutation:e,target:t,type:s,imageMap:r,errorHandler:n}){try{const i=Ai(t,s);if(!i)return;if(e.setter){i[e.property]=e.args[0];return}const o=i[e.property],a=await Promise.all(e.args.map(pe(r,i))),l=o.apply(i,a);Li(i,l);const c=!1}catch(i){n(e,i)}}async function Pi({event:e,mutations:t,target:s,imageMap:r,errorHandler:n}){const i=s.getContext("2d");if(!i){n(t[0],new Error("Canvas context is null"));return}const o=t.map(async l=>Promise.all(l.args.map(pe(r,i))));(await Promise.all(o)).forEach((l,c)=>{const u=t[c];try{if(u.setter){i[u.property]=u.args[0];return}const d=i[u.property];u.property==="drawImage"&&typeof u.args[0]=="string"?(r.get(e),d.apply(i,u.args)):d.apply(i,l)}catch(d){n(u,d)}})}async function Pt({event:e,mutation:t,target:s,imageMap:r,canvasEventMap:n,errorHandler:i}){try{const o=n.get(e)||t,a="commands"in o?o.commands:[o];if([me.WebGL,me.WebGL2].includes(t.type)){for(let l=0;l<a.length;l++){const c=a[l];await Fi({mutation:c,type:t.type,target:s,imageMap:r,errorHandler:i})}return}await Pi({event:e,mutations:a,target:s,imageMap:r,errorHandler:i})}catch(o){i(t,o)}}const Ls=5*1e3,Wi=br||Ii,Fs="[replayer]";function Bi(e,t){let s=-1;if(e.length===0)return s;let r=0,n=e.length-1;for(;r<=n;){const i=Math.floor((r+n)/2);e[i].timestamp<=t?(s=i,r=i+1):n=i-1}return s}const Tt={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Ui(e){if(e.type!==T.IncrementalSnapshot)return!1;const t=e.data;return t.source===M.MouseInteraction&&t.type===U.TouchStart?t.pointerType===de.Touch:!1}function Ps(e){return"pointerId"in e&&typeof e.pointerId=="number"?e.pointerId:-1}class Vi{constructor(t,s){if(this.usingVirtualDom=!1,this.virtualDom=new Ge,this.emitter=Wi(),this.legacy_missingNodeRetryMap={},this.cache=ms(),this.imageMap=new Map,this.canvasEventMap=new Map,this.mirror=Us(),this.styleMirror=new Jt,this.firstFullSnapshot=null,this.newDocumentQueue=[],this.pointers={},this.mouseTailAnimationFrame=null,this.lastMouseDownEvent=null,this.lastSelectionData=null,this.constructedStyleMutations=[],this.adoptedStyleSheets=[],this.handleResize=a=>{this.iframe.style.display="inherit";for(const l of[...Object.values(this.pointers).flatMap(c=>c.mouseTail),this.iframe])l&&(l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)))},this.applyEventsSynchronously=a=>{for(const l of a){switch(l.type){case T.DomContentLoaded:case T.Load:case T.Custom:continue;case T.FullSnapshot:case T.Meta:case T.Plugin:case T.IncrementalSnapshot:break}this.getCastFn(l,!0)()}},this.getCastFn=(a,l=!1)=>{let c;switch(a.type){case T.DomContentLoaded:case T.Load:break;case T.Custom:c=()=>{this.emitter.emit($.CustomEvent,a)};break;case T.Meta:c=()=>this.emitter.emit($.Resize,{width:a.data.width,height:a.data.height});break;case T.FullSnapshot:c=()=>{if(this.firstFullSnapshot){if(this.firstFullSnapshot===a){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.rebuildFullSnapshot(a,l),this.iframe.contentWindow?.scrollTo(a.data.initialOffset),this.styleMirror.reset()};break;case T.IncrementalSnapshot:c=()=>{if(this.applyIncremental(a,l),!l&&(a===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const d of this.service.state.context.events)if(!(d.timestamp<=a.timestamp)&&this.isUserInteraction(d)){d.delay-a.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=d);break}if(this.nextUserInteractionEvent){const d=this.nextUserInteractionEvent.delay-a.delay,h={speed:Math.min(Math.round(d/Ls),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:h}),this.emitter.emit($.SkipStart,h)}}};break}return()=>{c&&c();for(const h of this.config.plugins||[])h.handler&&h.handler(a,l,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:a}});const d=this.service.state.context.events.length-1;if(!this.config.liveMode&&a===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($.Finish))};let m=50;a.type===T.IncrementalSnapshot&&a.data.source===M.MouseMove&&a.data.positions.length&&(m+=Math.max(0,-a.data.positions[0].timeOffset)),ue(h,m)}this.emitter.emit($.EventCast,a)}},this.stepMouseTails=a=>{const{lineCap:l,lineWidth:c,strokeStyle:u,duration:d}=this.config.mouseTail===!0?Tt:Object.assign({},Tt,this.config.mouseTail),h=d/this.speedService.state.context.timer.speed;let m=!1;Object.values(this.pointers).forEach(f=>{if(!f.mouseTail)return;const y=f.mouseTail,g=y.getContext("2d");if(g&&(f.tailPositions=f.tailPositions.filter(p=>a-p.t<=h),g.clearRect(0,0,y.width,y.height),f.tailPositions.length>1)){m=!0,g.lineWidth=c,g.lineCap=l,g.strokeStyle=u;for(let p=1;p<f.tailPositions.length;p++){const b=f.tailPositions[p-1],E=f.tailPositions[p],I=(a-E.t)/h,P=Math.max(0,1-I);P<=0||(g.globalAlpha=P,g.beginPath(),g.moveTo(b.x,b.y),g.lineTo(E.x,E.y),g.stroke())}g.globalAlpha=1}}),m?this.mouseTailAnimationFrame=requestAnimationFrame(this.stepMouseTails):this.mouseTailAnimationFrame=null},!s?.liveMode&&t.length<2)throw new Error("Replayer need at least 2 events.");const r={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:Tt,useVirtualDom:!0,logger:console};this.config=Object.assign({},r,s),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on($.Resize,this.handleResize),this.setupDom();for(const a of this.config.plugins||[])a.getMirror&&a.getMirror({nodeMirror:this.mirror});this.emitter.on($.Flush,()=>{if(this.usingVirtualDom){const a={mirror:this.mirror,applyCanvas:(c,u,d)=>{Pt({event:c,mutation:u,target:d,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(c,u)=>{c.source===M.StyleSheetRule?this.applyStyleSheetRule(c,u):c.source===M.StyleDeclaration&&this.applyStyleDeclaration(c,u)},afterAppend:(c,u)=>{for(const d of this.config.plugins||[])d.onBuild&&d.onBuild(c,{id:u,replayer:this})}},l=ee(this.iframe);if(l)try{pt(l,this.virtualDom,a,this.virtualDom.mirror)}catch(c){console.warn(c)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const c in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[c],d=mt(u.node,this.mirror,this.virtualDom.mirror);pt(d,u.node,a,this.virtualDom.mirror),u.node=d}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(c=>{this.applyStyleSheetMutation(c)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(c=>{this.applyAdoptedStyleSheet(c)}),this.adoptedStyleSheets=[]}for(const[a,{pointerPosition:l,touchActive:c}]of Object.entries(this.pointers)){const u=parseInt(a),d=this.pointers[u];l&&(this.moveAndHover(l.x,l.y,l.id,!0,l.debugData,u),d.pointerPosition=null),c===!0?d.pointerEl.classList.add("touch-active"):c===!1&&d.pointerEl.classList.remove("touch-active"),d.touchActive=null}if(this.lastMouseDownEvent){const[a,l]=this.lastMouseDownEvent;a.dispatchEvent(l)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on($.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset()});const n=new Di([],{speed:this.config.speed});this.service=xi({events:t.map(a=>s&&s.unpackFn?s.unpackFn(a):a).sort((a,l)=>a.timestamp-l.timestamp),timer:n,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(a=>{this.emitter.emit($.StateChange,{player:a})}),this.speedService=ki({normalSpeed:-1,timer:n}),this.speedService.start(),this.speedService.subscribe(a=>{this.emitter.emit($.StateChange,{speed:a})});const i=this.service.state.context.events.find(a=>a.type===T.Meta),o=this.service.state.context.events.find(a=>a.type===T.FullSnapshot);if(i){const{width:a,height:l}=i.data;ue(()=>{this.emitter.emit($.Resize,{width:a,height:l})},0)}o&&ue(()=>{this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),this.iframe.contentWindow?.scrollTo(o.data.initialOffset))},1)}get timer(){return this.service.state.context.timer}createPointer(t,s){const r=document.createElement("canvas");r.classList.add("replayer-mouse-tail"),r.width=Number.parseFloat(this.iframe.width),r.height=Number.parseFloat(this.iframe.height),this.wrapper.insertBefore(r,this.iframe),r.style.display=this.config.mouseTail===!1?"none":"inherit";const n=document.createElement("div");n.classList.add("replayer-mouse"),this.pointers[t]={touchActive:null,pointerEl:n,tailPositions:[],pointerPosition:null,mouseTail:r},Ui(s)&&n.classList.add("touch-device"),this.wrapper.appendChild(n)}on(t,s){return this.emitter.on(t,s),this}off(t,s){return this.emitter.off(t,s),this}setConfig(t){const s=this.config.skipInactive;if(Object.keys(t).forEach(r=>{t[r],this.config[r]=t[r]}),this.config.skipInactive?s===!1&&this.config.skipInactive===!0&&this.reevaluateFastForward():this.backToNormal(),typeof t.speed<"u"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail<"u")if(t.mouseTail===!1)for(const{mouseTail:r}of Object.values(this.pointers))r&&(r.style.display="none");else for(let{mouseTail:r}of Object.values(this.pointers))r||(r=document.createElement("canvas"),r.width=Number.parseFloat(this.iframe.width),r.height=Number.parseFloat(this.iframe.height),r.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(r,this.iframe)),r.style.display="inherit"}getMetaData(){const t=this.service.state.context.events[0],s=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:s.timestamp,totalTime:s.timestamp-t.timestamp}}getCurrentTime(){return this.timer.timeOffset+this.getTimeOffset()}getTimeOffset(){const{baselineTime:t,events:s}=this.service.state.context;return t-s[0].timestamp}getMirror(){return this.mirror}play(t=0){this.config.skipInactive&&this.speedService.state.matches("skipping")&&this.backToNormal(),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}})),ee(this.iframe)?.getElementsByTagName("html")[0]?.classList.remove("rrweb-paused"),this.emitter.emit($.Start),this.config.skipInactive&&this.reevaluateFastForward()}pause(t){t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),ee(this.iframe)?.getElementsByTagName("html")[0]?.classList.add("rrweb-paused"),this.emitter.emit($.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($.Resume)}destroy(){this.pause(),this.config.root.removeChild(this.wrapper),this.emitter.emit($.Destroy)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const s=this.config.unpackFn?this.config.unpackFn(t):t;Promise.resolve().then(()=>this.service.send({type:"ADD_EVENT",payload:{event:s}}))}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=ms()}reevaluateFastForward(){if(!this.config.skipInactive)return;this.nextUserInteractionEvent=null;const t=this.service.state.context.events,s=t[0];if(!s)return;const r=s.timestamp+this.getCurrentTime(),n=Bi(t,r);if(n===-1)return;const i=t[n],o=this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed;for(let a=n+1;a<t.length;a++){const l=t[a];if(this.isUserInteraction(l)){const c=l.timestamp-i.timestamp;if(c>o){this.nextUserInteractionEvent=l;const u={speed:Math.min(Math.round(c/Ls),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:u}),this.emitter.emit($.SkipStart,u)}break}}}setupDom(){this.wrapper=document.createElement("div"),this.wrapper.classList.add("replayer-wrapper"),this.config.root.appendChild(this.wrapper),this.iframe=document.createElement("iframe");const t=["allow-same-origin"];this.config.UNSAFE_replayCanvas&&t.push("allow-scripts"),this.iframe.style.display="none",this.iframe.setAttribute("sandbox",t.join(" ")),this.disableInteract(),this.wrapper.appendChild(this.iframe);const s=ee(this.iframe),r=ir(this.iframe);r&&s&&(Ti(r,s),Yt(r))}rebuildFullSnapshot(t,s=!1){const r=ee(this.iframe);if(!r)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 n=[],i=(l,c)=>{this.collectIframeAndAttachDocument(n,l);for(const u of this.config.plugins||[])u.onBuild&&u.onBuild(l,{id:c,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),pn(t.data.node,{doc:r,afterAppend:i,cache:this.cache,mirror:this.mirror}),i(r,t.data.node.id);for(const{mutationInQueue:l,builtNode:c}of n)this.attachDocumentToIframe(l,c),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==l);const{documentElement:o,head:a}=r;if(this.insertStyleRules(o,a),!this.service.state.matches("playing")){const l=r.getElementsByTagName("html")[0];l&&l.classList.add("rrweb-paused")}this.emitter.emit($.FullsnapshotRebuilded,t),s||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,s){const r=Oi(this.config.blockClass).concat(this.config.insertStyleRules);if(this.config.pauseAnimation&&r.push("html.rrweb-paused *, html.rrweb-paused *:before, html.rrweb-paused *:after { animation-play-state: paused !important; }"),this.usingVirtualDom){const n=this.virtualDom.createElement("style");this.virtualDom.mirror.add(n,lr(n,this.virtualDom.unserializedId)),t.insertBefore(n,s),n.rules.push({source:M.StyleSheetRule,adds:r.map((i,o)=>({rule:i,index:o}))})}else{const n=document.createElement("style");t.insertBefore(n,s);for(let i=0;i<r.length;i++)n.sheet?.insertRule(r[i],i)}}attachDocumentToIframe(t,s){const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,n=ee(s),i=[],o=(a,l)=>{this.collectIframeAndAttachDocument(i,a);const c=r.getMeta(a);if(c?.type===x.Element&&c?.tagName.toUpperCase()==="HTML"&&n){const{documentElement:u,head:d}=n;this.insertStyleRules(u,d)}if(!this.usingVirtualDom)for(const u of this.config.plugins||[])u.onBuild&&u.onBuild(a,{id:l,replayer:this})};Je(t.node,{doc:n,mirror:r,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(n,t.node.id);for(const{mutationInQueue:a,builtNode:l}of i)this.attachDocumentToIframe(a,l),this.newDocumentQueue=this.newDocumentQueue.filter(c=>c!==a)}collectIframeAndAttachDocument(t,s){if(Ve(s,this.mirror)){const r=this.newDocumentQueue.find(n=>n.parentId===this.mirror.getId(s));r&&t.push({mutationInQueue:r,builtNode:s})}}waitForStylesheetLoad(){const s=ee(this.iframe)?.head;if(s){const r=new Set;let n,i=this.service.state;const o=()=>{i=this.service.state};this.emitter.on($.Start,o),this.emitter.on($.Pause,o);const a=()=>{this.emitter.off($.Start,o),this.emitter.off($.Pause,o)};s.querySelectorAll('link[rel="stylesheet"]').forEach(l=>{l.sheet||(r.add(l),l.addEventListener("load",()=>{r.delete(l),r.size===0&&n!==-1&&(i.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit($.LoadStylesheetEnd),n&&ts(n),a())}))}),r.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit($.LoadStylesheetStart),n=ue(()=>{i.matches("playing")&&this.play(this.getCurrentTime()),n=-1,a()},this.config.loadTimeout))}}async preloadAllImages(){const t=[];for(const s of this.service.state.context.events)s.type===T.IncrementalSnapshot&&s.data.source===M.CanvasMutation&&(t.push(this.deserializeAndPreloadCanvasEvents(s.data,s)),("commands"in s.data?s.data.commands:[s.data]).forEach(n=>{this.preloadImages(n,s)}));return Promise.all(t)}preloadImages(t,s){if(t.property==="drawImage"&&typeof t.args[0]=="string"&&!this.imageMap.has(s)){const r=document.createElement("canvas"),n=r.getContext("2d"),i=n?.createImageData(r.width,r.height);n?.putImageData(i,0,0)}}async deserializeAndPreloadCanvasEvents(t,s){if(!this.canvasEventMap.has(s)){const r={isUnchanged:!0};if("commands"in t){const n=await Promise.all(t.commands.map(async i=>{const o=await Promise.all(i.args.map(pe(this.imageMap,null,r)));return{...i,args:o}}));r.isUnchanged===!1&&this.canvasEventMap.set(s,{...t,commands:n})}else{const n=await Promise.all(t.args.map(pe(this.imageMap,null,r)));r.isUnchanged===!1&&this.canvasEventMap.set(s,{...t,args:n})}}}applyIncremental(t,s){const{data:r}=t;switch(r.source){case M.Mutation:{try{this.applyMutation(r,s)}catch(n){this.warn(`Exception in mutation ${n.message||n}`,r)}break}case M.Drag:case M.TouchMove:case M.MouseMove:{const n=Ps(r);this.pointers[n]||this.createPointer(n,t);const i=this.pointers[n];if(s){const o=r.positions[r.positions.length-1];i.pointerPosition={x:o.x,y:o.y,id:o.id,debugData:r}}else r.positions.forEach(o=>{const a={doAction:()=>{this.moveAndHover(o.x,o.y,o.id,s,r,n)},delay:o.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(a)}),this.timer.addAction({doAction(){},delay:t.delay-r.positions[0]?.timeOffset});break}case M.MouseInteraction:{const n=Ps(r);this.pointers[n]||this.createPointer(n,t);const i=this.pointers[n];if(r.id===-1)break;const o=new Event(De(U[r.type])),a=this.mirror.getNode(r.id);if(!a)return this.debugNodeNotFound(r,r.id);this.emitter.emit($.MouseInteraction,{type:r.type,target:a});const{triggerFocus:l}=this.config;switch(r.type){case U.Blur:"blur"in a&&a.blur();break;case U.Focus:l&&a.focus&&a.focus({preventScroll:!0});break;case U.Click:case U.TouchStart:case U.TouchEnd:case U.MouseDown:case U.MouseUp:s?(r.type===U.TouchStart?(i.touchActive=!0,Object.values(this.pointers).forEach(c=>{c!==i&&!c.touchActive&&(c.touchActive=!1)})):r.type===U.TouchEnd&&(i.touchActive=!1,i.pointerEl.remove(),i.mouseTail&&i.mouseTail.remove(),delete this.pointers[n]),r.type===U.MouseDown?this.lastMouseDownEvent=[a,o]:r.type===U.MouseUp&&(this.lastMouseDownEvent=null),i.pointerPosition={x:r.x||0,y:r.y||0,id:r.id,debugData:r}):(r.type===U.TouchStart&&(i.tailPositions.length=0),this.moveAndHover(r.x||0,r.y||0,r.id,s,r,n),r.type===U.Click?(i.pointerEl.classList.remove("active"),i.pointerEl.offsetWidth,i.pointerEl.classList.add("active")):r.type===U.TouchStart?(i.pointerEl.offsetWidth,i.pointerEl.classList.add("touch-active")):r.type===U.TouchEnd?(i.pointerEl.remove(),i.mouseTail&&i.mouseTail.remove(),delete this.pointers[n]):a.dispatchEvent(o));break;case U.TouchCancel:s?i.touchActive=!1:i.pointerEl.classList.remove("touch-active");break;default:a.dispatchEvent(o)}break}case M.Scroll:{if(r.id===-1)break;if(this.usingVirtualDom){const n=this.virtualDom.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);n.scrollData=r;break}this.applyScroll(r,s);break}case M.ViewportResize:this.emitter.emit($.Resize,{width:r.width,height:r.height});break;case M.Input:{if(r.id===-1)break;if(this.usingVirtualDom){const n=this.virtualDom.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);n.inputData=r;break}this.applyInput(r);break}case M.MediaInteraction:{const n=this.usingVirtualDom?this.virtualDom.mirror.getNode(r.id):this.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);const i=n;try{if(r.currentTime!==void 0&&(i.currentTime=r.currentTime),r.volume!==void 0&&(i.volume=r.volume),r.muted!==void 0&&(i.muted=r.muted),r.type===fe.Pause&&i.pause(),r.type===fe.Play){const o=i.play();typeof o?.catch=="function"&&o.catch(a=>{console.warn(a)})}r.type===fe.RateChange&&(i.playbackRate=r.playbackRate)}catch(o){this.warn(`Failed to replay media interactions: ${o.message||o}`)}break}case M.StyleSheetRule:case M.StyleDeclaration:{this.usingVirtualDom?r.styleId?this.constructedStyleMutations.push(r):r.id&&this.virtualDom.mirror.getNode(r.id)?.rules?.push(r):this.applyStyleSheetMutation(r);break}case M.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const n=this.virtualDom.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);n.canvasMutations.push({event:t,mutation:r})}else{const n=this.mirror.getNode(r.id);if(!n)return this.debugNodeNotFound(r,r.id);Pt({event:t,mutation:r,target:n,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case M.Font:{try{const n=new FontFace(r.family,r.buffer?new Uint8Array(JSON.parse(r.fontSource)):r.fontSource,r.descriptors);ee(this.iframe)?.fonts.add(n)}catch(n){this.warn(n)}break}case M.Selection:{if(s){this.lastSelectionData=r;break}this.applySelection(r);break}case M.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(r):this.applyAdoptedStyleSheet(r);break}}}applyMutation(t,s){if(this.config.useVirtualDom&&!this.usingVirtualDom&&s){this.usingVirtualDom=!0;const c=ee(this.iframe);if(c&&zn(c,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length)for(const u in this.legacy_missingNodeRetryMap)try{const d=this.legacy_missingNodeRetryMap[u],h=ar(d.node,this.virtualDom,this.mirror);h&&(d.node=h)}catch(d){this.warn(d)}}const r=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(c=>r.getNode(c.id)?!0:(this.warnNodeNotFound(t,c.id),!1)),t.removes.forEach(c=>{const u=r.getNode(c.id);if(!u)return;let d=r.getNode(c.parentId);if(!d)return this.warnNodeNotFound(t,c.parentId);if(c.isShadow&&be(d)&&(d=d.shadowRoot),r.removeNodeFromMap(u),d)try{d.removeChild(u),this.usingVirtualDom&&u.nodeName==="#text"&&d.nodeName==="STYLE"&&d.rules?.length>0&&(d.rules=[])}catch(h){if(h instanceof DOMException)this.warn("parent could not remove child in mutation",d,u,t);else throw h}});const n={...this.legacy_missingNodeRetryMap},i=[],o=c=>{let u=null;return c.nextId&&(u=r.getNode(c.nextId)),c.nextId!==null&&c.nextId!==void 0&&c.nextId!==-1&&!u},a=c=>{const u=ee(this.iframe);if(!u)return this.warn("Looks like your replayer has been destroyed.");let d=r.getNode(c.parentId);if(!d)return c.node.type===x.Document?this.newDocumentQueue.push(c):i.push(c);c.node.isShadow&&(be(d)||d.attachShadow({mode:"open"}),d=d.shadowRoot);let h=null,m=null;if(c.previousId&&(h=r.getNode(c.previousId)),c.nextId&&(m=r.getNode(c.nextId)),o(c))return i.push(c);if(c.node.rootId&&!r.getNode(c.node.rootId))return;const f=c.node.rootId?r.getNode(c.node.rootId):this.usingVirtualDom?this.virtualDom:u;if(Ve(d,r)){this.attachDocumentToIframe(c,d);return}const y=(b,E)=>{if(!this.usingVirtualDom)for(const I of this.config.plugins||[])I.onBuild&&I.onBuild(b,{id:E,replayer:this})},g=Je(c.node,{doc:f,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:y});if(c.previousId===-1||c.nextId===-1){n[c.node.id]={node:g,mutation:c};return}const p=r.getMeta(d);if(p&&p.type===x.Element&&p.tagName==="textarea"&&c.node.type===x.Text){const b=Array.isArray(d.childNodes)?d.childNodes:Array.from(d.childNodes);for(const E of b)E.nodeType===d.TEXT_NODE&&d.removeChild(E)}else if(p?.type===x.Document){const b=d;c.node.type===x.DocumentType&&b.childNodes[0]?.nodeType===Node.DOCUMENT_TYPE_NODE&&b.removeChild(b.childNodes[0]),g.nodeName==="HTML"&&b.documentElement&&b.removeChild(b.documentElement)}if(h&&h.nextSibling&&h.nextSibling.parentNode?d.insertBefore(g,h.nextSibling):m&&m.parentNode?d.contains(m)?d.insertBefore(g,m):d.insertBefore(g,null):d.appendChild(g),y(g,c.node.id),this.usingVirtualDom&&g.nodeName==="#text"&&d.nodeName==="STYLE"&&d.rules?.length>0&&(d.rules=[]),Ve(g,this.mirror)){const b=this.mirror.getId(g),E=this.newDocumentQueue.find(I=>I.parentId===b);E&&(this.attachDocumentToIframe(E,g),this.newDocumentQueue=this.newDocumentQueue.filter(I=>I!==E))}(c.previousId||c.nextId)&&this.legacy_resolveMissingNode(n,d,g,c)};t.adds.forEach(c=>{a(c)});const l=Date.now();for(;i.length;){const c=qs(i);if(i.length=0,Date.now()-l>500){this.warn("Timeout in the loop, please check the resolve tree data:",c);break}for(const u of c)r.getNode(u.value.parentId)?Xt(u,h=>{a(h)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(n).length&&Object.assign(this.legacy_missingNodeRetryMap,n),Qs(t.texts).forEach(c=>{const u=r.getNode(c.id);if(!u)return t.removes.find(d=>d.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);if(u.textContent=c.value,this.usingVirtualDom){const d=u.parentNode;d?.rules?.length>0&&(d.rules=[])}}),t.attributes.forEach(c=>{const u=r.getNode(c.id);if(!u)return t.removes.find(d=>d.id===c.id)?void 0:this.warnNodeNotFound(t,c.id);for(const d in c.attributes)if(typeof d=="string"){const h=c.attributes[d];if(h===null)u.removeAttribute(d);else if(typeof h=="string")try{if(d==="_cssText"&&(u.nodeName==="LINK"||u.nodeName==="STYLE"))try{const m=r.getMeta(u),f=Je({...m,attributes:{...m.attributes,...c.attributes}},{doc:u.ownerDocument,mirror:r,skipChild:!0,hackCss:!0,cache:this.cache}),y=u.nextSibling,g=u.parentNode;if(f&&g){g.removeChild(u),g.insertBefore(f,y),r.replace(c.id,f);break}}catch{}u.nodeType!==3&&u.setAttribute(d,h)}catch(m){this.warn("An error occurred may due to the checkout feature.",m)}else if(d==="style"){const m=h,f=u;for(const y in m)if(m[y]===!1)f.style.removeProperty(y);else if(m[y]instanceof Array){const g=m[y];f.style.setProperty(y,g[0],g[1])}else{const g=m[y];f.style.setProperty(y,g)}}}})}applyScroll(t,s){const r=this.mirror.getNode(t.id);if(!r)return this.debugNodeNotFound(t,t.id);const n=this.mirror.getMeta(r),i=ee(this.iframe);if(r===i)this.iframe.contentWindow?.scrollTo({top:t.y,left:t.x,behavior:s?"auto":"smooth"});else if(n?.type===x.Document)r.defaultView?.scrollTo({top:t.y,left:t.x,behavior:s?"auto":"smooth"});else try{r.scrollTo({top:t.y,left:t.x,behavior:s?"auto":"smooth"})}catch{}}applyInput(t){const s=this.mirror.getNode(t.id);if(!s)return this.debugNodeNotFound(t,t.id);try{s.checked=t.isChecked,s.value=t.text}catch{}}applySelection(t){try{const s=new Set,r=t.ranges.map(({start:n,startOffset:i,end:o,endOffset:a})=>{const l=this.mirror.getNode(n),c=this.mirror.getNode(o);if(!l||!c)return;const u=new Range;u.setStart(l,i),u.setEnd(c,a);const h=l.ownerDocument?.getSelection();return h&&s.add(h),{range:u,selection:h}});s.forEach(n=>n.removeAllRanges()),r.forEach(n=>n&&n.selection?.addRange(n.range))}catch{}}applyStyleSheetMutation(t){let s=null;t.styleId?s=this.styleMirror.getStyle(t.styleId):t.id&&(s=this.mirror.getNode(t.id)?.sheet||null),s&&(t.source===M.StyleSheetRule?this.applyStyleSheetRule(t,s):t.source===M.StyleDeclaration&&this.applyStyleDeclaration(t,s))}applyStyleSheetRule(t,s){if(t.adds?.forEach(({rule:r,index:n})=>{try{if(Array.isArray(n)){const{positions:i,index:o}=Ot(n);We(s.cssRules,i).insertRule(r,o)}else{const i=n===void 0?void 0:Math.min(n,s.cssRules.length);s?.insertRule(r,i)}}catch{}}),t.removes?.forEach(({index:r})=>{try{if(Array.isArray(r)){const{positions:n,index:i}=Ot(r);We(s.cssRules,n).deleteRule(i||0)}else s?.deleteRule(r)}catch{}}),t.replace)try{s.replace?.(t.replace)}catch{}if(t.replaceSync)try{s.replaceSync?.(t.replaceSync)}catch{}}applyStyleDeclaration(t,s){if(t.set){const r=We(s.rules,t.index);r&&r.style&&r.style.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const r=We(s.rules,t.index);r&&r.style&&r.style.removeProperty(t.remove.property)}}applyAdoptedStyleSheet(t){const s=this.mirror.getNode(t.id);if(!s)return;t.styles?.forEach(o=>{let a=null,l=null;if(be(s)?l=s.ownerDocument?.defaultView||null:s.nodeName==="#document"&&(l=s.defaultView),!!l)try{a=new l.CSSStyleSheet,this.styleMirror.add(a,o.styleId),this.applyStyleSheetRule({source:M.StyleSheetRule,adds:o.rules},a)}catch{}});const r=10;let n=0;const i=(o,a)=>{const l=a.map(c=>this.styleMirror.getStyle(c)).filter(c=>c!==null);be(o)?o.shadowRoot.adoptedStyleSheets=l:o.nodeName==="#document"&&(o.adoptedStyleSheets=l),l.length!==a.length&&n<r&&(ue(()=>i(o,a),0+100*n),n++)};i(s,t.styleIds)}legacy_resolveMissingNode(t,s,r,n){const{previousId:i,nextId:o}=n,a=i&&t[i],l=o&&t[o];if(a){const{node:c,mutation:u}=a;s.insertBefore(c,r),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,s,c,u)}if(l){const{node:c,mutation:u}=l;s.insertBefore(c,r.nextSibling),delete t[u.node.id],delete this.legacy_missingNodeRetryMap[u.node.id],(u.previousId||u.nextId)&&this.legacy_resolveMissingNode(t,s,c,u)}}moveAndHover(t,s,r,n,i,o){const a=this.mirror.getNode(r);if(!a)return this.debugNodeNotFound(i,r);const l=Qt(a,this.iframe),c=t*l.absoluteScale+l.x,u=s*l.absoluteScale+l.y,d=this.pointers[o];d&&d.pointerEl&&(d.pointerEl.style.left=`${c}px`,d.pointerEl.style.top=`${u}px`),n||this.drawMouseTail({x:c,y:u},o),this.hoverElements(a)}drawMouseTail(t,s){const r=this.pointers[s];if(!r||!r.mouseTail)return;const n=typeof performance<"u"?performance.now():Date.now();r.tailPositions.push({x:t.x,y:t.y,t:n}),this.mouseTailAnimationFrame===null&&(this.mouseTailAnimationFrame=requestAnimationFrame(this.stepMouseTails))}hoverElements(t){const s=ee(this.iframe),r=this.lastHoveredRootNode||s;r&&typeof r.querySelectorAll=="function"&&r.querySelectorAll(".\\:hover").forEach(i=>{i.classList.remove(":hover")}),this.lastHoveredRootNode=t.getRootNode();let n=t;for(;n;)n.classList&&n.classList.add(":hover"),n=n.parentElement}isUserInteraction(t){return t.type!==T.IncrementalSnapshot?!1:t.data.source>M.Mutation&&t.data.source<=M.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit($.SkipEnd,{speed:this.speedService.state.context.normalSpeed}))}warnNodeNotFound(t,s){this.warn(`Node with id '${s}' not found. `,t)}warnCanvasMutationFailed(t,s){this.warn("Has error on canvas update",s,"canvas mutation:",t)}debugNodeNotFound(t,s){this.debug(`Node with id '${s}' not found. `,t)}warn(...t){this.config.showWarning&&this.config.logger.warn(Fs,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(Fs,...t)}}exports.CanvasManager=vi;exports.EventType=T;exports.IncrementalSource=M;exports.MouseInteractions=U;exports.Replayer=Vi;exports.ReplayerEvents=$;exports.addCustomEvent=Mi;exports.canvasMutation=Pt;exports.deserializeArg=pe;exports.freezePage=Ci;exports.record=os;exports.takeFullSnapshot=Sr;exports.utils=mn;
|
|
19
19
|
;if (typeof module.exports == "object" && typeof exports == "object") {
|
|
20
20
|
var __cp = (to, from, except, desc) => {
|
|
21
21
|
if ((from && typeof from === "object") || typeof from === "function") {
|