@posthog/rrweb-player 0.0.38 → 0.0.40

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.
@@ -144,7 +144,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
144
144
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
145
145
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
146
146
  PERFORMANCE OF THIS SOFTWARE.
147
- ***************************************************************************** */function yn(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s,i,a=r.call(e),o=[];try{for(;(t===void 0||t-- >0)&&!(s=a.next()).done;)o.push(s.value)}catch(u){i={error:u}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}var $e;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})($e||($e={}));var Fo={type:"xstate.init"};function Kr(e){return e===void 0?[]:[].concat(e)}function qe(e){return{type:"xstate.assign",assignment:e}}function wn(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 Nt(e){return function(t){return e===t}}function Bo(e){return typeof e=="string"?{type:e}:e}function vn(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Nt(e)}}function bn(e,t,r){var s=t,i=!1;return[e.filter(function(a){if(a.type==="xstate.assign"){i=!0;var o=Object.assign({},s);return typeof a.assignment=="function"?o=a.assignment(s,r):Object.keys(a.assignment).forEach(function(u){o[u]=typeof a.assignment[u]=="function"?a.assignment[u](s,r):a.assignment[u]}),s=o,!1}return!0}),s,i]}function Uo(e,t){t===void 0&&(t={});var r=yn(bn(Kr(e.states[e.initial].entry).map(function(o){return wn(o,t.actions)}),e.context,Fo),2),s=r[0],i=r[1],a={config:e,_options:t,initialState:{value:e.initial,actions:s,context:i,matches:Nt(e.initial)},transition:function(o,u){var d,l,n=typeof o=="string"?{value:o,context:e.context}:o,c=n.value,f=n.context,h=Bo(u),p=e.states[c];if(p.on){var m=Kr(p.on[h.type]);try{for(var g=function(L){var j=typeof Symbol=="function"&&Symbol.iterator,H=j&&L[j],z=0;if(H)return H.call(L);if(L&&typeof L.length=="number")return{next:function(){return L&&z>=L.length&&(L=void 0),{value:L&&L[z++],done:!L}}};throw new TypeError(j?"Object is not iterable.":"Symbol.iterator is not defined.")}(m),v=g.next();!v.done;v=g.next()){var y=v.value;if(y===void 0)return vn(c,f);var S=typeof y=="string"?{target:y}:y,C=S.target,w=S.actions,b=w===void 0?[]:w,E=S.cond,R=E===void 0?function(){return!0}:E,N=C===void 0,x=C!=null?C:c,I=e.states[x];if(R(f,h)){var T=yn(bn((N?Kr(b):[].concat(p.exit,b,I.entry).filter(function(L){return L})).map(function(L){return wn(L,a._options.actions)}),f,h),3),J=T[0],U=T[1],M=T[2],q=C!=null?C:c;return{value:q,context:U,actions:J,changed:C!==c||J.length>0||M,matches:Nt(q)}}}}catch(L){d={error:L}}finally{try{v&&!v.done&&(l=g.return)&&l.call(g)}finally{if(d)throw d.error}}}return vn(c,f)}};return a}var Sn=function(e,t){return e.actions.forEach(function(r){var s=r.exec;return s&&s(e.context,t)})};function zo(e){var t=e.initialState,r=$e.NotStarted,s=new Set,i={_machine:e,send:function(a){r===$e.Running&&(t=e.transition(t,a),Sn(t,Bo(a)),s.forEach(function(o){return o(t)}))},subscribe:function(a){return s.add(a),a(t),{unsubscribe:function(){return s.delete(a)}}},start:function(a){if(a){var o=typeof a=="object"?a:{context:e.config.context,value:a};t={value:o.value,actions:[],context:o.context,matches:Nt(o.value)}}return r=$e.Running,Sn(t,Fo),i},stop:function(){return r=$e.Stopped,s.clear(),i},get state(){return t},get status(){return r}};return i}function Fu(e,t){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.type===te.Meta&&s.timestamp<=t)return e.slice(r)}return e}function Bu(e,{getCastFn:t,applyEventsSynchronously:r,emitter:s}){const i=Uo({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:qe({lastPlayedEvent:(a,o)=>o.type==="CAST_EVENT"?o.payload.event:a.lastPlayedEvent}),recordTimeOffset:qe((a,o)=>{let u=a.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(u=o.payload.timeOffset),le(Q({},a),{timeOffset:u,baselineTime:a.events[0].timestamp+u})}),play(a){var o;const{timer:u,events:d,baselineTime:l,lastPlayedEvent:n}=a;u.clear();for(const p of d)gn(p,l);const c=Fu(d,l);let f=n==null?void 0:n.timestamp;(n==null?void 0:n.type)===te.IncrementalSnapshot&&n.data.source===Y.MouseMove&&(f=n.timestamp+((o=n.data.positions[0])==null?void 0:o.timeOffset)),l<(f||0)&&s.emit(V.PlayBack);const h=new Array;for(const p of c)if(!(f&&f<l&&(p.timestamp<=f||p===n)))if(p.timestamp<l)h.push(p);else{const m=t(p,!1);u.addAction({doAction:()=>{m()},delay:p.delay})}r(h),s.emit(V.Flush),u.start()},pause(a){a.timer.clear()},resetLastPlayedEvent:qe(a=>le(Q({},a),{lastPlayedEvent:null})),startLive:qe({baselineTime:(a,o)=>(a.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:qe((a,o)=>{const{baselineTime:u,timer:d,events:l}=a;if(o.type==="ADD_EVENT"){const{event:n}=o.payload;gn(n,u);let c=l.length-1;if(!l[c]||l[c].timestamp<=n.timestamp)l.push(n);else{let p=-1,m=0;for(;m<=c;){const g=Math.floor((m+c)/2);l[g].timestamp<=n.timestamp?m=g+1:c=g-1}p===-1&&(p=m),l.splice(p,0,n)}const f=n.timestamp<u,h=t(n,f);f?h():d.isActive()&&d.addAction({doAction:()=>{h()},delay:n.delay})}return le(Q({},a),{events:l})})}});return zo(i)}function Uu(e){const t=Uo({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:qe({normalSpeed:r=>r.timer.speed}),restoreSpeed:r=>{r.timer.setSpeed(r.normalSpeed)}}});return zo(t)}const zu=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],En=new Map;function qo(e,t){let r=En.get(e);return r||(r=new Map,En.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function xe(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 xe(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:a}=s;return qo(t,i)[a]}else if("args"in s){const{rr_type:i,args:a}=s,o=window[i];return new o(...await Promise.all(a.map(xe(e,t,r))))}else{if("base64"in s)return Pu(s.base64);if("src"in s){const i=e.get(s.src);if(i)return i;{const a=new Image;return a.src=s.src,e.set(s.src,a),a}}else if("data"in s&&s.rr_type==="Blob"){const i=await Promise.all(s.data.map(xe(e,t,r)));return new Blob(i,{type:s.type})}}else if(Array.isArray(s))return await Promise.all(s.map(xe(e,t,r)));return s}}function qu(e,t){try{return t===Mt.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(r){return null}}const Wu=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function $u(e,t){if(!(t!=null&&t.constructor))return;const{name:r}=t.constructor;if(!Wu.includes(r))return;const s=qo(e,r);s.includes(t)||s.push(t)}async function ju({mutation:e,target:t,type:r,imageMap:s,errorHandler:i}){try{const a=qu(t,r);if(!a)return;if(e.setter){a[e.property]=e.args[0];return}const o=a[e.property],u=await Promise.all(e.args.map(xe(s,a))),d=o.apply(a,u);$u(a,d);const l=!1}catch(a){i(e,a)}}async function Vu({event:e,mutations:t,target:r,imageMap:s,errorHandler:i}){const a=r.getContext("2d");if(!a){i(t[0],new Error("Canvas context is null"));return}const o=t.map(async d=>Promise.all(d.args.map(xe(s,a))));(await Promise.all(o)).forEach((d,l)=>{const n=t[l];try{if(n.setter){a[n.property]=n.args[0];return}const c=a[n.property];n.property==="drawImage"&&typeof n.args[0]=="string"?(s.get(e),c.apply(a,n.args)):c.apply(a,d)}catch(c){i(n,c)}})}async function Cn({event:e,mutation:t,target:r,imageMap:s,canvasEventMap:i,errorHandler:a}){try{const o=i.get(e)||t,u="commands"in o?o.commands:[o];if([Mt.WebGL,Mt.WebGL2].includes(t.type)){for(let d=0;d<u.length;d++){const l=u[d];await ju({mutation:l,type:t.type,target:r,imageMap:s,errorHandler:a})}return}await Vu({event:e,mutations:u,target:r,imageMap:s,errorHandler:a})}catch(o){a(t,o)}}const Rn=["AUDIO","VIDEO"];class Gu{constructor(t){F(this,"mediaMap",new Map),F(this,"warn"),F(this,"service"),F(this,"speedService"),F(this,"emitter"),F(this,"getCurrentTime"),F(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(V.Start,this.start.bind(this)),this.emitter.on(V.SkipStart,this.start.bind(this)),this.emitter.on(V.Pause,this.pause.bind(this)),this.emitter.on(V.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 a=(t-s.lastInteractionTimeOffset)/1e3*s.playbackRate,o="duration"in r&&r.duration;if(Number.isNaN(o)){this.waitForMetadata(r);return}let u=s.currentTimeAtLastInteraction+a;r.loop&&o!==!1&&(u=u%o),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 h,p,m,g,v;const i=this.mediaMap.get(t),{type:a,playbackRate:o,currentTime:u,muted:d,volume:l,loop:n}=s;return{isPlaying:a===ai.Play||a!==ai.Pause&&((i==null?void 0:i.isPlaying)||t.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(h=u!=null?u:i==null?void 0:i.currentTimeAtLastInteraction)!=null?h:0,lastInteractionTimeOffset:r,playbackRate:(p=o!=null?o:i==null?void 0:i.playbackRate)!=null?p:1,volume:(m=l!=null?l:i==null?void 0:i.volume)!=null?m:1,muted:(g=d!=null?d:i==null?void 0:i.muted)!=null?g:t.getAttribute("muted")===null,loop:(v=n!=null?n:i==null?void 0:i.loop)!=null?v:t.getAttribute("loop")===null}}syncTargetWithState(t){const r=this.mediaMap.get(t);if(!r)return;const{muted:s,loop:i,volume:a,isPlaying:o}=r,u=this.service.state.matches("paused"),d=r.playbackRate*this.speedService.state.context.timer.speed;try{this.seekTo({time:this.getCurrentTime(),target:t,mediaState:r}),t.volume!==a&&(t.volume=a),t.muted=s,t.loop=i,t.playbackRate!==d&&(t.playbackRate=d),o&&!u?t.play():t.pause()}catch(l){this.warn(`Failed to replay media interactions: ${l.message||l}`)}}addMediaElements(t,r,s){if(!this.isSupportedMediaElement(t))return;const i=t,a=s.getMeta(i);if(!a||!("attributes"in a))return;const o=this.service.state.matches("paused"),u=a.attributes;let d=!1;u.rr_mediaState?d=u.rr_mediaState==="played":d=i.getAttribute("autoplay")!==null,d&&o&&i.pause();let l=1;typeof u.rr_mediaPlaybackRate=="number"&&(l=u.rr_mediaPlaybackRate);let n=!1;typeof u.rr_mediaMuted=="boolean"?n=u.rr_mediaMuted:n=i.getAttribute("muted")!==null;let c=!1;typeof u.rr_mediaLoop=="boolean"?c=u.rr_mediaLoop:c=i.getAttribute("loop")!==null;let f=1;typeof u.rr_mediaVolume=="number"&&(f=u.rr_mediaVolume);let h=0;typeof u.rr_mediaCurrentTime=="number"&&(h=u.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:d,currentTimeAtLastInteraction:h,lastInteractionTimeOffset:r,playbackRate:l,volume:f,muted:n,loop:c}),this.syncTargetWithState(i)}mediaMutation({target:t,timeOffset:r,mutation:s}){Rn.includes(t.nodeName)&&(this.mediaMap.set(t,this.getMediaStateFromMutation({target:t,timeOffset:r,mutation:s})),this.syncTargetWithState(t))}isSupportedMediaElement(t){return Rn.includes(t.nodeName)}reset(){this.mediaMap.clear()}}function vt(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e,s=r.open,i=s&&r.matches("dialog:modal"),a=r.getAttribute("rr_open_mode"),o=typeof(t==null?void 0:t.attributes.open)=="string"||typeof r.getAttribute("open")=="string",u=a==="modal";if(!(s&&!(i&&a==="non-modal"||!i&&u))){if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}s&&r.close(),o&&(u?r.showModal():r.show())}}function Hu(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 Yu=5*1e3,Ju=Lo||ku,xn="[replayer]",Zr={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Mn(e){return e.type==te.IncrementalSnapshot&&(e.data.source==Y.TouchMove||e.data.source==Y.MouseInteraction&&e.data.type==ne.TouchStart)}class Xu{constructor(t,r){if(F(this,"wrapper"),F(this,"iframe"),F(this,"service"),F(this,"speedService"),F(this,"config"),F(this,"usingVirtualDom",!1),F(this,"virtualDom",new Ye),F(this,"mouse"),F(this,"mouseTail",null),F(this,"tailPositions",[]),F(this,"emitter",Ju()),F(this,"nextUserInteractionEvent"),F(this,"legacy_missingNodeRetryMap",{}),F(this,"cache",_s()),F(this,"imageMap",new Map),F(this,"canvasEventMap",new Map),F(this,"mirror",Zn()),F(this,"styleMirror",new Du),F(this,"mediaManager"),F(this,"firstFullSnapshot",null),F(this,"newDocumentQueue",[]),F(this,"mousePos",null),F(this,"touchActive",null),F(this,"lastMouseDownEvent",null),F(this,"lastHoveredRootNode"),F(this,"lastSelectionData",null),F(this,"constructedStyleMutations",[]),F(this,"adoptedStyleSheets",[]),F(this,"emitterHandlers",[]),F(this,"serviceSubscription"),F(this,"speedServiceSubscription"),F(this,"timeouts",new Set),F(this,"styleSheetLoadListeners",new Map),F(this,"handleResize",l=>{this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])n&&(n.setAttribute("width",String(l.width)),n.setAttribute("height",String(l.height)))}),F(this,"applyEventsSynchronously",l=>{for(const n of l){switch(n.type){case te.DomContentLoaded:case te.Load:case te.Custom:continue;case te.FullSnapshot:case te.Meta:case te.Plugin:case te.IncrementalSnapshot:break}this.getCastFn(n,!0)()}}),F(this,"getCastFn",(l,n=!1)=>{let c;switch(l.type){case te.DomContentLoaded:case te.Load:break;case te.Custom:c=()=>{this.emitter.emit(V.CustomEvent,l)};break;case te.Meta:c=()=>this.emitter.emit(V.Resize,{width:l.data.width,height:l.data.height});break;case te.FullSnapshot:c=()=>{var h;if(this.firstFullSnapshot){if(this.firstFullSnapshot===l){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(l,n),(h=this.iframe.contentWindow)==null||h.scrollTo(l.data.initialOffset)};break;case te.IncrementalSnapshot:c=()=>{if(this.applyIncremental(l,n),!n&&(l===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const h of this.service.state.context.events)if(!(h.timestamp<=l.timestamp)&&this.isUserInteraction(h)){h.delay-l.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=h);break}if(this.nextUserInteractionEvent){const h=this.nextUserInteractionEvent.delay-l.delay,p={speed:Math.min(Math.round(h/Yu),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:p}),this.emitter.emit(V.SkipStart,p)}}};break}return()=>{c&&c();for(const p of this.config.plugins||[])p.handler&&p.handler(l,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:l}});const h=this.service.state.context.events.length-1;if(!this.config.liveMode&&l===this.service.state.context.events[h]){const p=()=>{h<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(V.Finish))};let m=50;l.type===te.IncrementalSnapshot&&l.data.source===Y.MouseMove&&l.data.positions.length&&(m+=Math.max(0,-l.data.positions[0].timeOffset)),setTimeout(p,m)}this.emitter.emit(V.EventCast,l)}}),!(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:Zr,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.addEmitterHandler(V.Resize,this.handleResize),this.setupDom();for(const l of this.config.plugins||[])l.getMirror&&l.getMirror({nodeMirror:this.mirror});const i=()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(n,c,f)=>{Cn({event:n,mutation:c,target:f,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(n,c)=>{n.source===Y.StyleSheetRule?this.applyStyleSheetRule(n,c):n.source===Y.StyleDeclaration&&this.applyStyleDeclaration(n,c)},afterAppend:(n,c)=>{for(const f of this.config.plugins||[])f.onBuild&&f.onBuild(n,{id:c,replayer:this})}};if(this.iframe.contentDocument)try{Rt(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror)}catch(n){this.warn(n)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const n in this.legacy_missingNodeRetryMap)try{const c=this.legacy_missingNodeRetryMap[n],f=xt(c.node,this.mirror,this.virtualDom.mirror);Rt(f,c.node,l,this.virtualDom.mirror),c.node=f}catch(c){this.warn(c)}this.constructedStyleMutations.forEach(n=>{this.applyStyleSheetMutation(n)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(n=>{this.applyAdoptedStyleSheet(n)}),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[l,n]=this.lastMouseDownEvent;l.dispatchEvent(n)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)};this.addEmitterHandler(V.Flush,i);const a=()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()};this.addEmitterHandler(V.PlayBack,a);const o=new Lu([],{speed:this.config.speed});this.service=Bu({events:t.map(l=>r&&r.unpackFn?r.unpackFn(l):l).sort((l,n)=>l.timestamp-n.timestamp),timer:o,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.serviceSubscription=this.service.subscribe(l=>{this.emitter.emit(V.StateChange,{player:l})}),this.speedService=Uu({normalSpeed:-1,timer:o}),this.speedService.start(),this.speedServiceSubscription=this.speedService.subscribe(l=>{this.emitter.emit(V.StateChange,{speed:l})}),this.mediaManager=new Gu({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const u=this.service.state.context.events.find(l=>l.type===te.Meta),d=this.service.state.context.events.find(l=>l.type===te.FullSnapshot);if(u){const{width:l,height:n}=u.data;this.addTimeout(()=>{this.emitter.emit(V.Resize,{width:l,height:n})},0)}d&&this.addTimeout(()=>{var l;this.firstFullSnapshot||(this.firstFullSnapshot=d,this.rebuildFullSnapshot(d),(l=this.iframe.contentWindow)==null||l.scrollTo(d.data.initialOffset))},1),this.service.state.context.events.find(Mn)&&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}addEmitterHandler(t,r){this.emitter.on(t,r),this.emitterHandlers.push({event:t,handler:r})}addTimeout(t,r){const s=setTimeout(()=>{this.timeouts.delete(s),t()},r);return this.timeouts.add(s),s}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.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(V.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(V.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(V.Resume)}destroy(){var t,r;!this.wrapper||!this.wrapper.parentNode||(this.pause(),this.emitterHandlers.forEach(({event:s,handler:i})=>{this.emitter.off(s,i)}),this.emitterHandlers=[],(t=this.serviceSubscription)==null||t.unsubscribe(),(r=this.speedServiceSubscription)==null||r.unsubscribe(),this.serviceSubscription=void 0,this.speedServiceSubscription=void 0,this.timeouts.forEach(s=>clearTimeout(s)),this.timeouts.clear(),this.styleSheetLoadListeners.forEach((s,i)=>{i.removeEventListener("load",s)}),this.styleSheetLoadListeners.clear(),this.imageMap.clear(),this.canvasEventMap.clear(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.resetCache(),this.config.root.removeChild(this.wrapper),this.emitter.emit(V.Destroy))}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const r=this.config.unpackFn?this.config.unpackFn(t):t;Mn(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=_s()}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.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),this.iframe.contentWindow&&this.iframe.contentDocument&&(Iu(this.iframe.contentWindow,this.iframe.contentDocument),_u(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,a=(d,l)=>{if(d.nodeName==="DIALOG"&&i.add(d),this.collectIframeAndAttachDocument(s,d),this.mediaManager.isSupportedMediaElement(d)){const{events:n}=this.service.state.context;this.mediaManager.addMediaElements(d,t.timestamp-n[0].timestamp,this.mirror)}for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(d,{id:l,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),al(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a,cache:this.cache,mirror:this.mirror}),a(this.iframe.contentDocument,t.data.node.id);for(const{mutationInQueue:d,builtNode:l}of s)this.attachDocumentToIframe(d,l),this.newDocumentQueue=this.newDocumentQueue.filter(n=>n!==d);const{documentElement:o,head:u}=this.iframe.contentDocument;this.insertStyleRules(o,u),i.forEach(d=>vt(d)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(V.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; }"),this.usingVirtualDom){const a=this.virtualDom.createElement("style");this.virtualDom.mirror.add(a,Po(a,this.virtualDom.unserializedId)),t.insertBefore(a,r),a.rules.push({source:Y.StyleSheetRule,adds:i.map((o,u)=>({rule:o,index:u}))})}else{const a=document.createElement("style");t.insertBefore(a,r);for(let o=0;o<i.length;o++)(s=a.sheet)==null||s.insertRule(i[o],o)}}attachDocumentToIframe(t,r){const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],a=new Set,o=(u,d)=>{u.nodeName==="DIALOG"&&a.add(u),this.collectIframeAndAttachDocument(i,u);const l=s.getMeta(u);if((l==null?void 0:l.type)===Re.Element&&(l==null?void 0:l.tagName.toUpperCase())==="HTML"){const{documentElement:n,head:c}=r.contentDocument;this.insertStyleRules(n,c)}if(!this.usingVirtualDom)for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(u,{id:d,replayer:this})};et(t.node,{doc:r.contentDocument,mirror:s,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(r.contentDocument,t.node.id);for(const{mutationInQueue:u,builtNode:d}of i)this.attachDocumentToIframe(u,d),this.newDocumentQueue=this.newDocumentQueue.filter(l=>l!==u);a.forEach(u=>vt(u))}collectIframeAndAttachDocument(t,r){if(Qr(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,a=this.service.state;const o=()=>{a=this.service.state};this.emitter.on(V.Start,o),this.emitter.on(V.Pause,o);const u=()=>{this.emitter.off(V.Start,o),this.emitter.off(V.Pause,o)};r.querySelectorAll('link[rel="stylesheet"]').forEach(d=>{d.sheet||(s.add(d),d.addEventListener("load",()=>{s.delete(d),s.size===0&&i!==-1&&(a.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(V.LoadStylesheetEnd),i&&clearTimeout(i),u())}))}),s.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(V.LoadStylesheetStart),i=setTimeout(()=>{a.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===te.IncrementalSnapshot&&r.data.source===Y.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"),a=i==null?void 0:i.createImageData(s.width,s.height);i==null||i.putImageData(a,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 a=>{const o=await Promise.all(a.args.map(xe(this.imageMap,null,s)));return le(Q({},a),{args:o})}));s.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{commands:i}))}else{const i=await Promise.all(t.args.map(xe(this.imageMap,null,s)));s.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{args:i}))}}}applyIncremental(t,r){var s,i,a;const{data:o}=t;switch(o.source){case Y.Mutation:{try{this.applyMutation(o,r)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,o)}break}case Y.Drag:case Y.TouchMove:case Y.MouseMove:if(r){const u=o.positions[o.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:o}}else o.positions.forEach(u=>{const d={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,r,o)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((s=o.positions[0])==null?void 0:s.timeOffset)});break;case Y.MouseInteraction:{if(o.id===-1)break;const u=new Event(Fa(ne[o.type])),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(V.MouseInteraction,{type:o.type,target:d});const{triggerFocus:l}=this.config;switch(o.type){case ne.Blur:"blur"in d&&d.blur();break;case ne.Focus:l&&d.focus&&d.focus({preventScroll:!0});break;case ne.Click:case ne.TouchStart:case ne.TouchEnd:case ne.MouseDown:case ne.MouseUp:r?(o.type===ne.TouchStart?this.touchActive=!0:o.type===ne.TouchEnd&&(this.touchActive=!1),o.type===ne.MouseDown?this.lastMouseDownEvent=[d,u]:o.type===ne.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:o.x||0,y:o.y||0,id:o.id,debugData:o}):(o.type===ne.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x||0,o.y||0,o.id,r,o),o.type===ne.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===ne.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===ne.TouchEnd?this.mouse.classList.remove("touch-active"):d.dispatchEvent(u));break;case ne.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(u)}break}case Y.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.scrollData=o;break}this.applyScroll(o,r);break}case Y.ViewportResize:this.emitter.emit(V.Resize,{width:o.width,height:o.height});break;case Y.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.inputData=o;break}this.applyInput(o);break}case Y.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u,{events:l}=this.service.state.context;this.mediaManager.mediaMutation({target:d,timeOffset:t.timestamp-l[0].timestamp,mutation:o});break}case Y.StyleSheetRule:case Y.StyleDeclaration:{this.usingVirtualDom?o.styleId?this.constructedStyleMutations.push(o):o.id&&((i=this.virtualDom.mirror.getNode(o.id))==null||i.rules.push(o)):this.applyStyleSheetMutation(o);break}case Y.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.canvasMutations.push({event:t,mutation:o})}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);Cn({event:t,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case Y.Font:{try{const u=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(a=this.iframe.contentDocument)==null||a.fonts.add(u)}catch(u){this.warn(u)}break}case Y.Selection:{if(r){this.lastSelectionData=o;break}this.applySelection(o);break}case Y.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(o):this.applyAdoptedStyleSheet(o);break}}}applyMutation(t,r){if(this.config.useVirtualDom&&!this.usingVirtualDom&&r&&(this.usingVirtualDom=!0,cu(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const d in this.legacy_missingNodeRetryMap)try{const l=this.legacy_missingNodeRetryMap[d],n=Do(l.node,this.virtualDom,this.mirror);n&&(l.node=n)}catch(l){this.warn(l)}const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(d=>s.getNode(d.id)?!0:(this.warnNodeNotFound(t,d.id),!1)),t.removes.forEach(d=>{var l;const n=s.getNode(d.id);if(!n)return;let c=s.getNode(d.parentId);if(!c)return this.warnNodeNotFound(t,d.parentId);if(d.isShadow&&yt(c)&&(c=c.shadowRoot),s.removeNodeFromMap(n),c)try{c.removeChild(n),this.usingVirtualDom&&n.nodeName==="#text"&&c.nodeName==="STYLE"&&((l=c.rules)==null?void 0:l.length)>0&&(c.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",c,n,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),a=[],o=d=>{var l,n;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let c=s.getNode(d.parentId);if(!c)return d.node.type===Re.Document?this.newDocumentQueue.push(d):t.adds.some(S=>S.node.id===d.parentId)?a.push(d):void 0;d.node.isShadow&&(yt(c)||c.attachShadow({mode:"open"}),c=c.shadowRoot);let f=null,h=null;if(d.previousId&&(f=s.getNode(d.previousId)),d.nextId&&(h=s.getNode(d.nextId)),d.node.rootId&&!s.getNode(d.node.rootId))return;const p=d.node.rootId?s.getNode(d.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Qr(c,s)){this.attachDocumentToIframe(d,c);return}const m=(y,S)=>{if(!this.usingVirtualDom){vt(y);for(const C of this.config.plugins||[])C.onBuild&&C.onBuild(y,{id:S,replayer:this})}},g=et(d.node,{doc:p,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:m});if(d.previousId===-1||d.nextId===-1){i[d.node.id]={node:g,mutation:d};return}const v=s.getMeta(c);if(v&&v.type===Re.Element&&d.node.type===Re.Text){const y=Array.isArray(c.childNodes)?c.childNodes:Array.from(c.childNodes);if(v.tagName==="textarea")for(const S of y)S.nodeType===c.TEXT_NODE&&c.removeChild(S);else if(v.tagName==="style"&&y.length===1)for(const S of y)S.nodeType===c.TEXT_NODE&&!s.hasNode(S)&&(g.textContent=S.textContent,c.removeChild(S))}else if((v==null?void 0:v.type)===Re.Document){const y=c;d.node.type===Re.DocumentType&&((l=y.childNodes[0])==null?void 0:l.nodeType)===Node.DOCUMENT_TYPE_NODE&&y.removeChild(y.childNodes[0]),g.nodeName==="HTML"&&y.documentElement&&y.removeChild(y.documentElement)}if(f&&f.nextSibling&&f.nextSibling.parentNode?c.insertBefore(g,f.nextSibling):h&&h.parentNode?c.contains(h)?c.insertBefore(g,h):c.insertBefore(g,null):c.appendChild(g),m(g,d.node.id),this.usingVirtualDom&&g.nodeName==="#text"&&c.nodeName==="STYLE"&&((n=c.rules)==null?void 0:n.length)>0&&(c.rules=[]),Qr(g,this.mirror)){const y=this.mirror.getId(g),S=this.newDocumentQueue.find(C=>C.parentId===y);S&&(this.attachDocumentToIframe(S,g),this.newDocumentQueue=this.newDocumentQueue.filter(C=>C!==S))}(d.previousId||d.nextId)&&this.legacy_resolveMissingNode(i,c,g,d)};t.adds.forEach(d=>{o(d)});const u=performance.now();for(;a.length;){const d=Ou(a);if(a.length=0,performance.now()-u>150){this.warn("Timeout in the loop, please check the resolve tree data:",d);break}for(const l of d)s.getNode(l.value.parentId)?ko(l,c=>{o(c)}):this.debug("Drop resolve tree since there is no parent for the root node.",l)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),Au(t.texts).forEach(d=>{var l;const n=s.getNode(d.id);if(!n)return t.removes.find(c=>c.id===d.id)?void 0:this.warnNodeNotFound(t,d.id);if(n.textContent=d.value,this.usingVirtualDom){const c=n.parentNode;((l=c==null?void 0:c.rules)==null?void 0:l.length)>0&&(c.rules=[])}}),t.attributes.forEach(d=>{var l;const n=s.getNode(d.id);if(!n)return t.removes.find(c=>c.id===d.id)?void 0:this.warnNodeNotFound(t,d.id);for(const c in d.attributes)if(typeof c=="string"){const f=d.attributes[c];if(f===null)n.removeAttribute(c),c==="open"&&Hu(n,d);else if(typeof f=="string")try{if(c==="_cssText"&&(n.nodeName==="LINK"||n.nodeName==="STYLE"))try{const h=s.getMeta(n);Object.assign(h.attributes,d.attributes);const p=et(h,{doc:n.ownerDocument,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache}),m=n.nextSibling,g=n.parentNode;if(p&&g){g.removeChild(n),g.insertBefore(p,m),s.replace(d.id,p);break}}catch(h){}if(c==="value"&&n.nodeName==="TEXTAREA"){const h=n;h.childNodes.forEach(m=>h.removeChild(m));const p=(l=n.ownerDocument)==null?void 0:l.createTextNode(f);p&&h.appendChild(p)}else n.setAttribute(c,f);c==="rr_open_mode"&&n.nodeName==="DIALOG"&&vt(n,d)}catch(h){this.warn("An error occurred may due to the checkout feature.",h)}else if(c==="style"){const h=f,p=n;for(const m in h)if(h[m]===!1)p.style.removeProperty(m);else if(h[m]instanceof Array){const g=h[m];p.style.setProperty(m,g[0],g[1])}else{const g=h[m];p.style.setProperty(m,g)}}}})}applyScroll(t,r){var s,i;const a=this.mirror.getNode(t.id);if(!a)return this.debugNodeNotFound(t,t.id);const o=this.mirror.getMeta(a);if(a===this.iframe.contentDocument)(s=this.iframe.contentWindow)==null||s.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else if((o==null?void 0:o.type)===Re.Document)(i=a.defaultView)==null||i.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else try{a.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:a,end:o,endOffset:u})=>{const d=this.mirror.getNode(i),l=this.mirror.getNode(o);if(!d||!l)return;const n=new Range;n.setStart(d,a),n.setEnd(l,u);const c=d.ownerDocument,f=c==null?void 0:c.getSelection();return f&&r.add(f),{range:n,selection:f}});r.forEach(i=>i.removeAllRanges()),s.forEach(i=>{var a;return i&&((a=i.selection)==null?void 0:a.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===Y.StyleSheetRule?this.applyStyleSheetRule(t,s):t.source===Y.StyleDeclaration&&this.applyStyleDeclaration(t,s))}applyStyleSheetRule(t,r){var s,i,a,o;if((s=t.adds)==null||s.forEach(({rule:u,index:d})=>{try{if(Array.isArray(d)){const{positions:l,index:n}=pn(d);Qe(r.cssRules,l).insertRule(u,n)}else{const l=d===void 0?void 0:Math.min(d,r.cssRules.length);r==null||r.insertRule(u,l)}}catch(l){}}),(i=t.removes)==null||i.forEach(({index:u})=>{try{if(Array.isArray(u)){const{positions:d,index:l}=pn(u);Qe(r.cssRules,d).deleteRule(l||0)}else r==null||r.deleteRule(u)}catch(d){}}),t.replace)try{(a=r.replace)==null||a.call(r,t.replace)}catch(u){}if(t.replaceSync)try{(o=r.replaceSync)==null||o.call(r,t.replaceSync)}catch(u){}}applyStyleDeclaration(t,r){var s,i;if(t.set){const a=Qe(r.rules,t.index);(s=a==null?void 0:a.style)==null||s.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const a=Qe(r.rules,t.index);(i=a==null?void 0:a.style)==null||i.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 d;let l=null,n=null;if(yt(s)?n=((d=s.ownerDocument)==null?void 0:d.defaultView)||null:s.nodeName==="#document"&&(n=s.defaultView),!!n)try{l=new n.CSSStyleSheet,this.styleMirror.add(l,u.styleId),this.applyStyleSheetRule({source:Y.StyleSheetRule,adds:u.rules},l)}catch(c){}});const i=10;let a=0;const o=(u,d)=>{const l=d.map(n=>this.styleMirror.getStyle(n)).filter(n=>n!==null);yt(u)?u.shadowRoot.adoptedStyleSheets=l:u.nodeName==="#document"&&(u.adoptedStyleSheets=l),l.length!==d.length&&a<i&&(setTimeout(()=>o(u,d),0+100*a),a++)};o(s,t.styleIds)}legacy_resolveMissingNode(t,r,s,i){const{previousId:a,nextId:o}=i,u=a&&t[a],d=o&&t[o];if(u){const{node:l,mutation:n}=u;r.insertBefore(l,s),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,l,n)}if(d){const{node:l,mutation:n}=d;r.insertBefore(l,s.nextSibling),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,l,n)}}moveAndHover(t,r,s,i,a){const o=this.mirror.getNode(s);if(!o)return this.debugNodeNotFound(a,s);const u=Io(o,this.iframe),d=t*u.absoluteScale+u.x,l=r*u.absoluteScale+u.y;this.mouse.style.left=`${d}px`,this.mouse.style.top=`${l}px`,i||this.drawMouseTail({x:d,y:l}),this.hoverElements(o)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:r,lineWidth:s,strokeStyle:i,duration:a}=this.config.mouseTail===!0?Zr:Object.assign({},Zr,this.config.mouseTail),o=()=>{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(d=>u.lineTo(d.x,d.y)),u.stroke())};this.tailPositions.push(t),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(u=>u!==t),o()},a/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!==te.IncrementalSnapshot?!1:t.data.source>Y.Mutation&&t.data.source<=Y.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(V.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(xn,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(xn,...t)}}var de=Uint8Array,Me=Uint16Array,li=Uint32Array,Wo=new de([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),$o=new de([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Qu=new de([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jo=function(e,t){for(var r=new Me(31),s=0;s<31;++s)r[s]=t+=1<<e[s-1];for(var i=new li(r[30]),s=1;s<30;++s)for(var a=r[s];a<r[s+1];++a)i[a]=a-r[s]<<5|s;return[r,i]},Vo=jo(Wo,2),Go=Vo[0],Ku=Vo[1];Go[28]=258,Ku[258]=28;var Zu=jo($o,0),ec=Zu[0],ui=new Me(32768);for(var K=0;K<32768;++K){var Ce=(K&43690)>>>1|(K&21845)<<1;Ce=(Ce&52428)>>>2|(Ce&13107)<<2,Ce=(Ce&61680)>>>4|(Ce&3855)<<4,ui[K]=((Ce&65280)>>>8|(Ce&255)<<8)>>>1}var tt=function(e,t,r){for(var s=e.length,i=0,a=new Me(t);i<s;++i)++a[e[i]-1];var o=new Me(t);for(i=0;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var u;if(r){u=new Me(1<<t);var d=15-t;for(i=0;i<s;++i)if(e[i])for(var l=i<<4|e[i],n=t-e[i],c=o[e[i]-1]++<<n,f=c|(1<<n)-1;c<=f;++c)u[ui[c]>>>d]=l}else for(u=new Me(s),i=0;i<s;++i)u[i]=ui[o[e[i]-1]++]>>>15-e[i];return u},lt=new de(288);for(var K=0;K<144;++K)lt[K]=8;for(var K=144;K<256;++K)lt[K]=9;for(var K=256;K<280;++K)lt[K]=7;for(var K=280;K<288;++K)lt[K]=8;var Ho=new de(32);for(var K=0;K<32;++K)Ho[K]=5;var tc=tt(lt,9,1),rc=tt(Ho,5,1),ei=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},pe=function(e,t,r){var s=t/8>>0;return(e[s]|e[s+1]<<8)>>>(t&7)&r},ti=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(t&7)},ic=function(e){return(e/8>>0)+(e&7&&1)},Yo=function(e,t,r){(r==null||r>e.length)&&(r=e.length);var s=new(e instanceof Me?Me:e instanceof li?li:de)(r-t);return s.set(e.subarray(t,r)),s},sc=function(e,t,r){var s=e.length,i=!t||r,a=!r||r.i;r||(r={}),t||(t=new de(s*3));var o=function(O){var P=t.length;if(O>P){var $=new de(Math.max(P*2,O));$.set(t),t=$}},u=r.f||0,d=r.p||0,l=r.b||0,n=r.l,c=r.d,f=r.m,h=r.n,p=s*8;do{if(!n){r.f=u=pe(e,d,1);var m=pe(e,d+1,3);if(d+=3,m)if(m==1)n=tc,c=rc,f=9,h=5;else if(m==2){var S=pe(e,d,31)+257,C=pe(e,d+10,15)+4,w=S+pe(e,d+5,31)+1;d+=14;for(var b=new de(w),E=new de(19),R=0;R<C;++R)E[Qu[R]]=pe(e,d+R*3,7);d+=C*3;var N=ei(E),x=(1<<N)-1;if(!a&&d+w*(N+7)>p)break;for(var I=tt(E,N,1),R=0;R<w;){var T=I[pe(e,d,x)];d+=T&15;var g=T>>>4;if(g<16)b[R++]=g;else{var J=0,U=0;for(g==16?(U=3+pe(e,d,3),d+=2,J=b[R-1]):g==17?(U=3+pe(e,d,7),d+=3):g==18&&(U=11+pe(e,d,127),d+=7);U--;)b[R++]=J}}var M=b.subarray(0,S),q=b.subarray(S);f=ei(M),h=ei(q),n=tt(M,f,1),c=tt(q,h,1)}else throw"invalid block type";else{var g=ic(d)+4,v=e[g-4]|e[g-3]<<8,y=g+v;if(y>s){if(a)throw"unexpected EOF";break}i&&o(l+v),t.set(e.subarray(g,y),l),r.b=l+=v,r.p=d=y*8;continue}if(d>p)throw"unexpected EOF"}i&&o(l+131072);for(var L=(1<<f)-1,j=(1<<h)-1,H=f+h+18;a||d+H<p;){var J=n[ti(e,d)&L],z=J>>>4;if(d+=J&15,d>p)throw"unexpected EOF";if(!J)throw"invalid length/literal";if(z<256)t[l++]=z;else if(z==256){n=null;break}else{var X=z-254;if(z>264){var R=z-257,ae=Wo[R];X=pe(e,d,(1<<ae)-1)+Go[R],d+=ae}var _=c[ti(e,d)&j],D=_>>>4;if(!_)throw"invalid distance";d+=_&15;var q=ec[D];if(D>3){var ae=$o[D];q+=ti(e,d)&(1<<ae)-1,d+=ae}if(d>p)throw"unexpected EOF";i&&o(l+131072);for(var A=l+X;l<A;l+=4)t[l]=t[l-q],t[l+1]=t[l+1-q],t[l+2]=t[l+2-q],t[l+3]=t[l+3-q];l=A}}r.l=n,r.p=d,r.b=l,n&&(u=1,r.m=f,r.d=c,r.n=h)}while(!u);return l==t.length?t:Yo(t,0,l)},nc=function(e){if((e[0]&15)!=8||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(e[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function oc(e,t){return sc((nc(e),e.subarray(2,-4)),t)}function ac(e,t){for(var r=e.length,s=new de(e.length+(e.length>>>1)),i=0,a=function(l){s[i++]=l},o=0;o<r;++o){if(i+5>s.length){var u=new de(i+8+(r-o<<1));u.set(s),s=u}var d=e.charCodeAt(o);a(d)}return Yo(s,0,i)}function lc(e,t){var r="";if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);for(var s=0;s<e.length;){var i=e[s++];i<128||t?r+=String.fromCharCode(i):i<224?r+=String.fromCharCode((i&31)<<6|e[s++]&63):i<240?r+=String.fromCharCode((i&15)<<12|(e[s++]&63)<<6|e[s++]&63):(i=((i&15)<<18|(e[s++]&63)<<12|(e[s++]&63)<<6|e[s++]&63)-65536,r+=String.fromCharCode(55296|i>>10,56320|i&1023))}return r}const Nn="v1",uc=e=>{if(typeof e!="string")return e;try{const t=JSON.parse(e);if(t.timestamp)return t}catch(t){}try{const t=JSON.parse(lc(oc(ac(e,!0))));if(t.v===Nn)return t;throw new Error(`These events were packed with packer ${t.v} which is incompatible with current packer ${Nn}.`)}catch(t){throw console.error(t),new Error("Unknown data format.")}};var Fi=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Fi||{}),ci=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ci||{});function _n(e){let t="";return Object.keys(e).forEach(r=>{t+=`${r}: ${e[r]};`}),t}function Xe(e,t=2){let r=String(e);const s=Math.pow(10,t-1);if(e<s)for(;String(s).length>r.length;)r=`0${e}`;return r}const Jo=1e3,hi=60*Jo,On=60*hi;function bt(e){if(e<=0)return"00:00";const t=Math.floor(e/On);e=e%On;const r=Math.floor(e/hi);e=e%hi;const s=Math.floor(e/Jo);return t?`${Xe(t)}:${Xe(r)}:${Xe(s)}`:`${Xe(r)}:${Xe(s)}`}function cc(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.resolve()}function hc(){return document.exitFullscreen?document.exitFullscreen():document.mozExitFullscreen?document.mozExitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.resolve()}function An(){let e=!1;return["fullscreen","webkitIsFullScreen","mozFullScreen","msFullscreenElement"].forEach(t=>{t in document&&(e=e||!!document[t])}),e}function fc(e){return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}function Dn(e){return{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[Object.prototype.toString.call(e)]}function dc(e){return e.type!==Fi.IncrementalSnapshot?!1:e.data.source>ci.Mutation&&e.data.source<=ci.Input}function pc(e,t){const r=[];let s=e[0].timestamp;for(const i of e)dc(i)&&(i.timestamp-s>t&&r.push([s,i.timestamp]),s=i.timestamp);return r}function mc(e){let t,r,s,i,a,o,u,d,l;return{c(){t=oe("div"),r=oe("input"),s=fe(),i=oe("label"),a=fe(),o=oe("span"),u=Te(e[3]),B(r,"type","checkbox"),B(r,"id",e[2]),r.disabled=e[1],B(r,"class","svelte-a6h7w7"),B(i,"for",e[2]),B(i,"class","svelte-a6h7w7"),B(o,"class","label svelte-a6h7w7"),B(t,"class","switch svelte-a6h7w7"),Ve(t,"disabled",e[1])},m(n,c){Ee(n,t,c),G(t,r),r.checked=e[0],G(t,s),G(t,i),G(t,a),G(t,o),G(o,u),d||(l=We(r,"change",e[4]),d=!0)},p(n,[c]){c&4&&B(r,"id",n[2]),c&2&&(r.disabled=n[1]),c&1&&(r.checked=n[0]),c&4&&B(i,"for",n[2]),c&8&&Ct(u,n[3]),c&2&&Ve(t,"disabled",n[1])},i:rt,o:rt,d(n){n&&ve(t),d=!1,l()}}}function gc(e,t,r){let{disabled:s}=t,{checked:i}=t,{id:a}=t,{label:o}=t;function u(){i=this.checked,r(0,i)}return e.$$set=d=>{"disabled"in d&&r(1,s=d.disabled),"checked"in d&&r(0,i=d.checked),"id"in d&&r(2,a=d.id),"label"in d&&r(3,o=d.label)},[i,s,a,o,u]}class yc extends gi{constructor(t){super(),mi(this,t,gc,mc,fi,{disabled:1,checked:0,id:2,label:3})}}function Pn(e,t,r){const s=e.slice();return s[38]=t[r],s}function Tn(e,t,r){const s=e.slice();return s[41]=t[r],s}function kn(e,t,r){const s=e.slice();return s[44]=t[r],s}function In(e){let t,r,s,i=bt(e[6])+"",a,o,u,d,l,n,c,f,h,p,m=bt(e[8].totalTime)+"",g,v,y,S,C,w,b,E,R,N,x,I,T,J=Fe(e[13]),U=[];for(let D=0;D<J.length;D+=1)U[D]=Ln(kn(e,J,D));let M=Fe(e[9]),q=[];for(let D=0;D<M.length;D+=1)q[D]=Fn(Tn(e,M,D));function L(D,A){return D[7]==="playing"?vc:wc}let j=L(e),H=j(e),z=Fe(e[3]),X=[];for(let D=0;D<z.length;D+=1)X[D]=Bn(Pn(e,z,D));function ae(D){e[29](D)}let _={id:"skip",disabled:e[10]==="skipping",label:"skip inactive"};return e[0]!==void 0&&(_.checked=e[0]),b=new yc({props:_}),Pe.push(()=>ma(b,"checked",ae)),{c(){t=oe("div"),r=oe("div"),s=oe("span"),a=Te(i),o=fe(),u=oe("div"),d=oe("div"),l=fe();for(let D=0;D<U.length;D+=1)U[D].c();n=fe();for(let D=0;D<q.length;D+=1)q[D].c();c=fe(),f=oe("div"),h=fe(),p=oe("span"),g=Te(m),v=fe(),y=oe("div"),S=oe("button"),H.c(),C=fe();for(let D=0;D<X.length;D+=1)X[D].c();w=fe(),Jn(b.$$.fragment),R=fe(),N=oe("button"),N.innerHTML=`<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M916 380c-26.4 0-48-21.6-48-48L868 223.2 613.6 477.6c-18.4
147
+ ***************************************************************************** */function yn(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s,i,a=r.call(e),o=[];try{for(;(t===void 0||t-- >0)&&!(s=a.next()).done;)o.push(s.value)}catch(u){i={error:u}}finally{try{s&&!s.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}var $e;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})($e||($e={}));var Fo={type:"xstate.init"};function Kr(e){return e===void 0?[]:[].concat(e)}function qe(e){return{type:"xstate.assign",assignment:e}}function wn(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 Nt(e){return function(t){return e===t}}function Bo(e){return typeof e=="string"?{type:e}:e}function vn(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Nt(e)}}function bn(e,t,r){var s=t,i=!1;return[e.filter(function(a){if(a.type==="xstate.assign"){i=!0;var o=Object.assign({},s);return typeof a.assignment=="function"?o=a.assignment(s,r):Object.keys(a.assignment).forEach(function(u){o[u]=typeof a.assignment[u]=="function"?a.assignment[u](s,r):a.assignment[u]}),s=o,!1}return!0}),s,i]}function Uo(e,t){t===void 0&&(t={});var r=yn(bn(Kr(e.states[e.initial].entry).map(function(o){return wn(o,t.actions)}),e.context,Fo),2),s=r[0],i=r[1],a={config:e,_options:t,initialState:{value:e.initial,actions:s,context:i,matches:Nt(e.initial)},transition:function(o,u){var d,l,n=typeof o=="string"?{value:o,context:e.context}:o,c=n.value,f=n.context,h=Bo(u),p=e.states[c];if(p.on){var m=Kr(p.on[h.type]);try{for(var g=function(L){var j=typeof Symbol=="function"&&Symbol.iterator,H=j&&L[j],z=0;if(H)return H.call(L);if(L&&typeof L.length=="number")return{next:function(){return L&&z>=L.length&&(L=void 0),{value:L&&L[z++],done:!L}}};throw new TypeError(j?"Object is not iterable.":"Symbol.iterator is not defined.")}(m),v=g.next();!v.done;v=g.next()){var y=v.value;if(y===void 0)return vn(c,f);var S=typeof y=="string"?{target:y}:y,C=S.target,w=S.actions,b=w===void 0?[]:w,E=S.cond,R=E===void 0?function(){return!0}:E,N=C===void 0,x=C!=null?C:c,I=e.states[x];if(R(f,h)){var T=yn(bn((N?Kr(b):[].concat(p.exit,b,I.entry).filter(function(L){return L})).map(function(L){return wn(L,a._options.actions)}),f,h),3),J=T[0],U=T[1],M=T[2],q=C!=null?C:c;return{value:q,context:U,actions:J,changed:C!==c||J.length>0||M,matches:Nt(q)}}}}catch(L){d={error:L}}finally{try{v&&!v.done&&(l=g.return)&&l.call(g)}finally{if(d)throw d.error}}}return vn(c,f)}};return a}var Sn=function(e,t){return e.actions.forEach(function(r){var s=r.exec;return s&&s(e.context,t)})};function zo(e){var t=e.initialState,r=$e.NotStarted,s=new Set,i={_machine:e,send:function(a){r===$e.Running&&(t=e.transition(t,a),Sn(t,Bo(a)),s.forEach(function(o){return o(t)}))},subscribe:function(a){return s.add(a),a(t),{unsubscribe:function(){return s.delete(a)}}},start:function(a){if(a){var o=typeof a=="object"?a:{context:e.config.context,value:a};t={value:o.value,actions:[],context:o.context,matches:Nt(o.value)}}return r=$e.Running,Sn(t,Fo),i},stop:function(){return r=$e.Stopped,s.clear(),i},get state(){return t},get status(){return r}};return i}function Fu(e,t){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.type===te.Meta&&s.timestamp<=t)return e.slice(r)}return e}function Bu(e,{getCastFn:t,applyEventsSynchronously:r,emitter:s}){const i=Uo({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:qe({lastPlayedEvent:(a,o)=>o.type==="CAST_EVENT"?o.payload.event:a.lastPlayedEvent}),recordTimeOffset:qe((a,o)=>{let u=a.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(u=o.payload.timeOffset),le(Q({},a),{timeOffset:u,baselineTime:a.events[0].timestamp+u})}),play(a){var o;const{timer:u,events:d,baselineTime:l,lastPlayedEvent:n}=a;u.clear();for(const p of d)gn(p,l);const c=Fu(d,l);let f=n==null?void 0:n.timestamp;(n==null?void 0:n.type)===te.IncrementalSnapshot&&n.data.source===Y.MouseMove&&(f=n.timestamp+((o=n.data.positions[0])==null?void 0:o.timeOffset)),l<(f||0)&&s.emit(V.PlayBack);const h=new Array;for(const p of c)if(!(f&&f<l&&(p.timestamp<=f||p===n)))if(p.timestamp<l)h.push(p);else{const m=t(p,!1);u.addAction({doAction:()=>{m()},delay:p.delay})}r(h),s.emit(V.Flush),u.start()},pause(a){a.timer.clear()},resetLastPlayedEvent:qe(a=>le(Q({},a),{lastPlayedEvent:null})),startLive:qe({baselineTime:(a,o)=>(a.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:qe((a,o)=>{const{baselineTime:u,timer:d,events:l}=a;if(o.type==="ADD_EVENT"){const{event:n}=o.payload;gn(n,u);let c=l.length-1;if(!l[c]||l[c].timestamp<=n.timestamp)l.push(n);else{let p=-1,m=0;for(;m<=c;){const g=Math.floor((m+c)/2);l[g].timestamp<=n.timestamp?m=g+1:c=g-1}p===-1&&(p=m),l.splice(p,0,n)}const f=n.timestamp<u,h=t(n,f);f?h():d.isActive()&&d.addAction({doAction:()=>{h()},delay:n.delay})}return le(Q({},a),{events:l})})}});return zo(i)}function Uu(e){const t=Uo({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:qe({normalSpeed:r=>r.timer.speed}),restoreSpeed:r=>{r.timer.setSpeed(r.normalSpeed)}}});return zo(t)}const zu=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],En=new Map;function qo(e,t){let r=En.get(e);return r||(r=new Map,En.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function xe(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 xe(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:a}=s;return qo(t,i)[a]}else if("args"in s){const{rr_type:i,args:a}=s,o=window[i];return new o(...await Promise.all(a.map(xe(e,t,r))))}else{if("base64"in s)return Pu(s.base64);if("src"in s){const i=e.get(s.src);if(i)return i;{const a=new Image;return a.src=s.src,e.set(s.src,a),a}}else if("data"in s&&s.rr_type==="Blob"){const i=await Promise.all(s.data.map(xe(e,t,r)));return new Blob(i,{type:s.type})}}else if(Array.isArray(s))return await Promise.all(s.map(xe(e,t,r)));return s}}function qu(e,t){try{return t===Mt.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(r){return null}}const Wu=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function $u(e,t){if(!(t!=null&&t.constructor))return;const{name:r}=t.constructor;if(!Wu.includes(r))return;const s=qo(e,r);s.includes(t)||s.push(t)}async function ju({mutation:e,target:t,type:r,imageMap:s,errorHandler:i}){try{const a=qu(t,r);if(!a)return;if(e.setter){a[e.property]=e.args[0];return}const o=a[e.property],u=await Promise.all(e.args.map(xe(s,a))),d=o.apply(a,u);$u(a,d);const l=!1}catch(a){i(e,a)}}async function Vu({event:e,mutations:t,target:r,imageMap:s,errorHandler:i}){const a=r.getContext("2d");if(!a){i(t[0],new Error("Canvas context is null"));return}const o=t.map(async d=>Promise.all(d.args.map(xe(s,a))));(await Promise.all(o)).forEach((d,l)=>{const n=t[l];try{if(n.setter){a[n.property]=n.args[0];return}const c=a[n.property];n.property==="drawImage"&&typeof n.args[0]=="string"?(s.get(e),c.apply(a,n.args)):c.apply(a,d)}catch(c){i(n,c)}})}async function Cn({event:e,mutation:t,target:r,imageMap:s,canvasEventMap:i,errorHandler:a}){try{const o=i.get(e)||t,u="commands"in o?o.commands:[o];if([Mt.WebGL,Mt.WebGL2].includes(t.type)){for(let d=0;d<u.length;d++){const l=u[d];await ju({mutation:l,type:t.type,target:r,imageMap:s,errorHandler:a})}return}await Vu({event:e,mutations:u,target:r,imageMap:s,errorHandler:a})}catch(o){a(t,o)}}const Rn=["AUDIO","VIDEO"];class Gu{constructor(t){F(this,"mediaMap",new Map),F(this,"warn"),F(this,"service"),F(this,"speedService"),F(this,"emitter"),F(this,"getCurrentTime"),F(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(V.Start,this.start.bind(this)),this.emitter.on(V.SkipStart,this.start.bind(this)),this.emitter.on(V.Pause,this.pause.bind(this)),this.emitter.on(V.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 a=(t-s.lastInteractionTimeOffset)/1e3*s.playbackRate,o="duration"in r&&r.duration;if(Number.isNaN(o)){this.waitForMetadata(r);return}let u=s.currentTimeAtLastInteraction+a;r.loop&&o!==!1&&(u=u%o),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 h,p,m,g,v;const i=this.mediaMap.get(t),{type:a,playbackRate:o,currentTime:u,muted:d,volume:l,loop:n}=s;return{isPlaying:a===ai.Play||a!==ai.Pause&&((i==null?void 0:i.isPlaying)||t.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(h=u!=null?u:i==null?void 0:i.currentTimeAtLastInteraction)!=null?h:0,lastInteractionTimeOffset:r,playbackRate:(p=o!=null?o:i==null?void 0:i.playbackRate)!=null?p:1,volume:(m=l!=null?l:i==null?void 0:i.volume)!=null?m:1,muted:(g=d!=null?d:i==null?void 0:i.muted)!=null?g:t.getAttribute("muted")===null,loop:(v=n!=null?n:i==null?void 0:i.loop)!=null?v:t.getAttribute("loop")===null}}syncTargetWithState(t){const r=this.mediaMap.get(t);if(!r)return;const{muted:s,loop:i,volume:a,isPlaying:o}=r,u=this.service.state.matches("paused"),d=r.playbackRate*this.speedService.state.context.timer.speed;try{this.seekTo({time:this.getCurrentTime(),target:t,mediaState:r}),t.volume!==a&&(t.volume=a),t.muted=s,t.loop=i,t.playbackRate!==d&&(t.playbackRate=d),o&&!u?t.play():t.pause()}catch(l){this.warn(`Failed to replay media interactions: ${l.message||l}`)}}addMediaElements(t,r,s){if(!this.isSupportedMediaElement(t))return;const i=t,a=s.getMeta(i);if(!a||!("attributes"in a))return;const o=this.service.state.matches("paused"),u=a.attributes;let d=!1;u.rr_mediaState?d=u.rr_mediaState==="played":d=i.getAttribute("autoplay")!==null,d&&o&&i.pause();let l=1;typeof u.rr_mediaPlaybackRate=="number"&&(l=u.rr_mediaPlaybackRate);let n=!1;typeof u.rr_mediaMuted=="boolean"?n=u.rr_mediaMuted:n=i.getAttribute("muted")!==null;let c=!1;typeof u.rr_mediaLoop=="boolean"?c=u.rr_mediaLoop:c=i.getAttribute("loop")!==null;let f=1;typeof u.rr_mediaVolume=="number"&&(f=u.rr_mediaVolume);let h=0;typeof u.rr_mediaCurrentTime=="number"&&(h=u.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:d,currentTimeAtLastInteraction:h,lastInteractionTimeOffset:r,playbackRate:l,volume:f,muted:n,loop:c}),this.syncTargetWithState(i)}mediaMutation({target:t,timeOffset:r,mutation:s}){Rn.includes(t.nodeName)&&(this.mediaMap.set(t,this.getMediaStateFromMutation({target:t,timeOffset:r,mutation:s})),this.syncTargetWithState(t))}isSupportedMediaElement(t){return Rn.includes(t.nodeName)}reset(){this.mediaMap.clear()}}function vt(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e,s=r.open,i=s&&r.matches("dialog:modal"),a=r.getAttribute("rr_open_mode"),o=typeof(t==null?void 0:t.attributes.open)=="string"||typeof r.getAttribute("open")=="string",u=a==="modal";if(!(s&&!(i&&a==="non-modal"||!i&&u))){if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}s&&r.close(),o&&(u?r.showModal():r.show())}}function Hu(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 Yu=5*1e3,Ju=Lo||ku,xn="[replayer]",Zr={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function Mn(e){return e.type==te.IncrementalSnapshot&&(e.data.source==Y.TouchMove||e.data.source==Y.MouseInteraction&&e.data.type==ne.TouchStart)}class Xu{constructor(t,r){if(F(this,"wrapper"),F(this,"iframe"),F(this,"service"),F(this,"speedService"),F(this,"config"),F(this,"usingVirtualDom",!1),F(this,"virtualDom",new Ye),F(this,"mouse"),F(this,"mouseTail",null),F(this,"tailPositions",[]),F(this,"emitter",Ju()),F(this,"nextUserInteractionEvent"),F(this,"legacy_missingNodeRetryMap",{}),F(this,"cache",_s()),F(this,"imageMap",new Map),F(this,"canvasEventMap",new Map),F(this,"mirror",Zn()),F(this,"styleMirror",new Du),F(this,"mediaManager"),F(this,"firstFullSnapshot",null),F(this,"newDocumentQueue",[]),F(this,"mousePos",null),F(this,"touchActive",null),F(this,"lastMouseDownEvent",null),F(this,"lastHoveredRootNode"),F(this,"lastSelectionData",null),F(this,"constructedStyleMutations",[]),F(this,"adoptedStyleSheets",[]),F(this,"emitterHandlers",[]),F(this,"serviceSubscription"),F(this,"speedServiceSubscription"),F(this,"timeouts",new Set),F(this,"styleSheetLoadListeners",new Map),F(this,"handleResize",l=>{this.iframe.style.display="inherit";for(const n of[this.mouseTail,this.iframe])n&&(n.setAttribute("width",String(l.width)),n.setAttribute("height",String(l.height)))}),F(this,"applyEventsSynchronously",l=>{for(const n of l){switch(n.type){case te.DomContentLoaded:case te.Load:case te.Custom:continue;case te.FullSnapshot:case te.Meta:case te.Plugin:case te.IncrementalSnapshot:break}this.getCastFn(n,!0)()}}),F(this,"getCastFn",(l,n=!1)=>{let c;switch(l.type){case te.DomContentLoaded:case te.Load:break;case te.Custom:c=()=>{this.emitter.emit(V.CustomEvent,l)};break;case te.Meta:c=()=>this.emitter.emit(V.Resize,{width:l.data.width,height:l.data.height});break;case te.FullSnapshot:c=()=>{var h;if(this.firstFullSnapshot){if(this.firstFullSnapshot===l){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(l,n),(h=this.iframe.contentWindow)==null||h.scrollTo(l.data.initialOffset)};break;case te.IncrementalSnapshot:c=()=>{if(this.applyIncremental(l,n),!n&&(l===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const h of this.service.state.context.events)if(!(h.timestamp<=l.timestamp)&&this.isUserInteraction(h)){h.delay-l.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=h);break}if(this.nextUserInteractionEvent){const h=this.nextUserInteractionEvent.delay-l.delay,p={speed:Math.min(Math.round(h/Yu),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:p}),this.emitter.emit(V.SkipStart,p)}}};break}return()=>{c&&c();for(const p of this.config.plugins||[])p.handler&&p.handler(l,n,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:l}});const h=this.service.state.context.events.length-1;if(!this.config.liveMode&&l===this.service.state.context.events[h]){const p=()=>{h<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(V.Finish))};let m=50;l.type===te.IncrementalSnapshot&&l.data.source===Y.MouseMove&&l.data.positions.length&&(m+=Math.max(0,-l.data.positions[0].timeOffset)),setTimeout(p,m)}this.emitter.emit(V.EventCast,l)}}),!(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:Zr,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.addEmitterHandler(V.Resize,this.handleResize),this.setupDom();for(const l of this.config.plugins||[])l.getMirror&&l.getMirror({nodeMirror:this.mirror});const i=()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(n,c,f)=>{Cn({event:n,mutation:c,target:f,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(n,c)=>{n.source===Y.StyleSheetRule?this.applyStyleSheetRule(n,c):n.source===Y.StyleDeclaration&&this.applyStyleDeclaration(n,c)},afterAppend:(n,c)=>{for(const f of this.config.plugins||[])f.onBuild&&f.onBuild(n,{id:c,replayer:this})}};if(this.iframe.contentDocument)try{Rt(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror)}catch(n){this.warn(n)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const n in this.legacy_missingNodeRetryMap)try{const c=this.legacy_missingNodeRetryMap[n],f=xt(c.node,this.mirror,this.virtualDom.mirror);Rt(f,c.node,l,this.virtualDom.mirror),c.node=f}catch(c){this.warn(c)}this.constructedStyleMutations.forEach(n=>{this.applyStyleSheetMutation(n)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(n=>{this.applyAdoptedStyleSheet(n)}),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[l,n]=this.lastMouseDownEvent;l.dispatchEvent(n)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)};this.addEmitterHandler(V.Flush,i);const a=()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()};this.addEmitterHandler(V.PlayBack,a);const o=new Lu([],{speed:this.config.speed});this.service=Bu({events:t.map(l=>r&&r.unpackFn?r.unpackFn(l):l).sort((l,n)=>l.timestamp-n.timestamp),timer:o,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.serviceSubscription=this.service.subscribe(l=>{this.emitter.emit(V.StateChange,{player:l})}),this.speedService=Uu({normalSpeed:-1,timer:o}),this.speedService.start(),this.speedServiceSubscription=this.speedService.subscribe(l=>{this.emitter.emit(V.StateChange,{speed:l})}),this.mediaManager=new Gu({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const u=this.service.state.context.events.find(l=>l.type===te.Meta),d=this.service.state.context.events.find(l=>l.type===te.FullSnapshot);if(u){const{width:l,height:n}=u.data;this.addTimeout(()=>{this.emitter.emit(V.Resize,{width:l,height:n})},0)}d&&this.addTimeout(()=>{var l;this.firstFullSnapshot||(this.firstFullSnapshot=d,this.rebuildFullSnapshot(d),(l=this.iframe.contentWindow)==null||l.scrollTo(d.data.initialOffset))},1),this.service.state.context.events.find(Mn)&&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}addEmitterHandler(t,r){this.emitter.on(t,r),this.emitterHandlers.push({event:t,handler:r})}addTimeout(t,r){const s=setTimeout(()=>{this.timeouts.delete(s),t()},r);return this.timeouts.add(s),s}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.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(V.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(V.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(V.Resume)}destroy(){var t,r;!this.wrapper||!this.wrapper.parentNode||(this.pause(),this.emitterHandlers.forEach(({event:s,handler:i})=>{this.emitter.off(s,i)}),this.emitterHandlers=[],(t=this.serviceSubscription)==null||t.unsubscribe(),(r=this.speedServiceSubscription)==null||r.unsubscribe(),this.serviceSubscription=void 0,this.speedServiceSubscription=void 0,this.service.stop(),this.speedService.stop(),this.timeouts.forEach(s=>clearTimeout(s)),this.timeouts.clear(),this.styleSheetLoadListeners.forEach((s,i)=>{i.removeEventListener("load",s)}),this.styleSheetLoadListeners.clear(),this.imageMap.clear(),this.canvasEventMap.clear(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.resetCache(),this.config.root.removeChild(this.wrapper),this.emitter.emit(V.Destroy))}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const r=this.config.unpackFn?this.config.unpackFn(t):t;Mn(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=_s()}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.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),this.iframe.contentWindow&&this.iframe.contentDocument&&(Iu(this.iframe.contentWindow,this.iframe.contentDocument),_u(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,a=(d,l)=>{if(d.nodeName==="DIALOG"&&i.add(d),this.collectIframeAndAttachDocument(s,d),this.mediaManager.isSupportedMediaElement(d)){const{events:n}=this.service.state.context;this.mediaManager.addMediaElements(d,t.timestamp-n[0].timestamp,this.mirror)}for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(d,{id:l,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),al(t.data.node,{doc:this.iframe.contentDocument,afterAppend:a,cache:this.cache,mirror:this.mirror}),a(this.iframe.contentDocument,t.data.node.id);for(const{mutationInQueue:d,builtNode:l}of s)this.attachDocumentToIframe(d,l),this.newDocumentQueue=this.newDocumentQueue.filter(n=>n!==d);const{documentElement:o,head:u}=this.iframe.contentDocument;this.insertStyleRules(o,u),i.forEach(d=>vt(d)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(V.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; }"),this.usingVirtualDom){const a=this.virtualDom.createElement("style");this.virtualDom.mirror.add(a,Po(a,this.virtualDom.unserializedId)),t.insertBefore(a,r),a.rules.push({source:Y.StyleSheetRule,adds:i.map((o,u)=>({rule:o,index:u}))})}else{const a=document.createElement("style");t.insertBefore(a,r);for(let o=0;o<i.length;o++)(s=a.sheet)==null||s.insertRule(i[o],o)}}attachDocumentToIframe(t,r){const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],a=new Set,o=(u,d)=>{u.nodeName==="DIALOG"&&a.add(u),this.collectIframeAndAttachDocument(i,u);const l=s.getMeta(u);if((l==null?void 0:l.type)===Re.Element&&(l==null?void 0:l.tagName.toUpperCase())==="HTML"){const{documentElement:n,head:c}=r.contentDocument;this.insertStyleRules(n,c)}if(!this.usingVirtualDom)for(const n of this.config.plugins||[])n.onBuild&&n.onBuild(u,{id:d,replayer:this})};et(t.node,{doc:r.contentDocument,mirror:s,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(r.contentDocument,t.node.id);for(const{mutationInQueue:u,builtNode:d}of i)this.attachDocumentToIframe(u,d),this.newDocumentQueue=this.newDocumentQueue.filter(l=>l!==u);a.forEach(u=>vt(u))}collectIframeAndAttachDocument(t,r){if(Qr(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,a=this.service.state;const o=()=>{a=this.service.state};this.emitter.on(V.Start,o),this.emitter.on(V.Pause,o);const u=()=>{this.emitter.off(V.Start,o),this.emitter.off(V.Pause,o)};r.querySelectorAll('link[rel="stylesheet"]').forEach(d=>{d.sheet||(s.add(d),d.addEventListener("load",()=>{s.delete(d),s.size===0&&i!==-1&&(a.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(V.LoadStylesheetEnd),i&&clearTimeout(i),u())}))}),s.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(V.LoadStylesheetStart),i=setTimeout(()=>{a.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===te.IncrementalSnapshot&&r.data.source===Y.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"),a=i==null?void 0:i.createImageData(s.width,s.height);i==null||i.putImageData(a,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 a=>{const o=await Promise.all(a.args.map(xe(this.imageMap,null,s)));return le(Q({},a),{args:o})}));s.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{commands:i}))}else{const i=await Promise.all(t.args.map(xe(this.imageMap,null,s)));s.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{args:i}))}}}applyIncremental(t,r){var s,i,a;const{data:o}=t;switch(o.source){case Y.Mutation:{try{this.applyMutation(o,r)}catch(u){this.warn(`Exception in mutation ${u.message||u}`,o)}break}case Y.Drag:case Y.TouchMove:case Y.MouseMove:if(r){const u=o.positions[o.positions.length-1];this.mousePos={x:u.x,y:u.y,id:u.id,debugData:o}}else o.positions.forEach(u=>{const d={doAction:()=>{this.moveAndHover(u.x,u.y,u.id,r,o)},delay:u.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(d)}),this.timer.addAction({doAction(){},delay:t.delay-((s=o.positions[0])==null?void 0:s.timeOffset)});break;case Y.MouseInteraction:{if(o.id===-1)break;const u=new Event(Fa(ne[o.type])),d=this.mirror.getNode(o.id);if(!d)return this.debugNodeNotFound(o,o.id);this.emitter.emit(V.MouseInteraction,{type:o.type,target:d});const{triggerFocus:l}=this.config;switch(o.type){case ne.Blur:"blur"in d&&d.blur();break;case ne.Focus:l&&d.focus&&d.focus({preventScroll:!0});break;case ne.Click:case ne.TouchStart:case ne.TouchEnd:case ne.MouseDown:case ne.MouseUp:r?(o.type===ne.TouchStart?this.touchActive=!0:o.type===ne.TouchEnd&&(this.touchActive=!1),o.type===ne.MouseDown?this.lastMouseDownEvent=[d,u]:o.type===ne.MouseUp&&(this.lastMouseDownEvent=null),this.mousePos={x:o.x||0,y:o.y||0,id:o.id,debugData:o}):(o.type===ne.TouchStart&&(this.tailPositions.length=0),this.moveAndHover(o.x||0,o.y||0,o.id,r,o),o.type===ne.Click?(this.mouse.classList.remove("active"),this.mouse.offsetWidth,this.mouse.classList.add("active")):o.type===ne.TouchStart?(this.mouse.offsetWidth,this.mouse.classList.add("touch-active")):o.type===ne.TouchEnd?this.mouse.classList.remove("touch-active"):d.dispatchEvent(u));break;case ne.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:d.dispatchEvent(u)}break}case Y.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.scrollData=o;break}this.applyScroll(o,r);break}case Y.ViewportResize:this.emitter.emit(V.Resize,{width:o.width,height:o.height});break;case Y.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.inputData=o;break}this.applyInput(o);break}case Y.MediaInteraction:{const u=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);const d=u,{events:l}=this.service.state.context;this.mediaManager.mediaMutation({target:d,timeOffset:t.timestamp-l[0].timestamp,mutation:o});break}case Y.StyleSheetRule:case Y.StyleDeclaration:{this.usingVirtualDom?o.styleId?this.constructedStyleMutations.push(o):o.id&&((i=this.virtualDom.mirror.getNode(o.id))==null||i.rules.push(o)):this.applyStyleSheetMutation(o);break}case Y.CanvasMutation:{if(!this.config.UNSAFE_replayCanvas)return;if(this.usingVirtualDom){const u=this.virtualDom.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);u.canvasMutations.push({event:t,mutation:o})}else{const u=this.mirror.getNode(o.id);if(!u)return this.debugNodeNotFound(o,o.id);Cn({event:t,mutation:o,target:u,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case Y.Font:{try{const u=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(a=this.iframe.contentDocument)==null||a.fonts.add(u)}catch(u){this.warn(u)}break}case Y.Selection:{if(r){this.lastSelectionData=o;break}this.applySelection(o);break}case Y.AdoptedStyleSheet:{this.usingVirtualDom?this.adoptedStyleSheets.push(o):this.applyAdoptedStyleSheet(o);break}}}applyMutation(t,r){if(this.config.useVirtualDom&&!this.usingVirtualDom&&r&&(this.usingVirtualDom=!0,cu(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const d in this.legacy_missingNodeRetryMap)try{const l=this.legacy_missingNodeRetryMap[d],n=Do(l.node,this.virtualDom,this.mirror);n&&(l.node=n)}catch(l){this.warn(l)}const s=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(d=>s.getNode(d.id)?!0:(this.warnNodeNotFound(t,d.id),!1)),t.removes.forEach(d=>{var l;const n=s.getNode(d.id);if(!n)return;let c=s.getNode(d.parentId);if(!c)return this.warnNodeNotFound(t,d.parentId);if(d.isShadow&&yt(c)&&(c=c.shadowRoot),s.removeNodeFromMap(n),c)try{c.removeChild(n),this.usingVirtualDom&&n.nodeName==="#text"&&c.nodeName==="STYLE"&&((l=c.rules)==null?void 0:l.length)>0&&(c.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",c,n,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),a=[],o=d=>{var l,n;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let c=s.getNode(d.parentId);if(!c)return d.node.type===Re.Document?this.newDocumentQueue.push(d):t.adds.some(S=>S.node.id===d.parentId)?a.push(d):void 0;d.node.isShadow&&(yt(c)||c.attachShadow({mode:"open"}),c=c.shadowRoot);let f=null,h=null;if(d.previousId&&(f=s.getNode(d.previousId)),d.nextId&&(h=s.getNode(d.nextId)),d.node.rootId&&!s.getNode(d.node.rootId))return;const p=d.node.rootId?s.getNode(d.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Qr(c,s)){this.attachDocumentToIframe(d,c);return}const m=(y,S)=>{if(!this.usingVirtualDom){vt(y);for(const C of this.config.plugins||[])C.onBuild&&C.onBuild(y,{id:S,replayer:this})}},g=et(d.node,{doc:p,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:m});if(d.previousId===-1||d.nextId===-1){i[d.node.id]={node:g,mutation:d};return}const v=s.getMeta(c);if(v&&v.type===Re.Element&&d.node.type===Re.Text){const y=Array.isArray(c.childNodes)?c.childNodes:Array.from(c.childNodes);if(v.tagName==="textarea")for(const S of y)S.nodeType===c.TEXT_NODE&&c.removeChild(S);else if(v.tagName==="style"&&y.length===1)for(const S of y)S.nodeType===c.TEXT_NODE&&!s.hasNode(S)&&(g.textContent=S.textContent,c.removeChild(S))}else if((v==null?void 0:v.type)===Re.Document){const y=c;d.node.type===Re.DocumentType&&((l=y.childNodes[0])==null?void 0:l.nodeType)===Node.DOCUMENT_TYPE_NODE&&y.removeChild(y.childNodes[0]),g.nodeName==="HTML"&&y.documentElement&&y.removeChild(y.documentElement)}if(f&&f.nextSibling&&f.nextSibling.parentNode?c.insertBefore(g,f.nextSibling):h&&h.parentNode?c.contains(h)?c.insertBefore(g,h):c.insertBefore(g,null):c.appendChild(g),m(g,d.node.id),this.usingVirtualDom&&g.nodeName==="#text"&&c.nodeName==="STYLE"&&((n=c.rules)==null?void 0:n.length)>0&&(c.rules=[]),Qr(g,this.mirror)){const y=this.mirror.getId(g),S=this.newDocumentQueue.find(C=>C.parentId===y);S&&(this.attachDocumentToIframe(S,g),this.newDocumentQueue=this.newDocumentQueue.filter(C=>C!==S))}(d.previousId||d.nextId)&&this.legacy_resolveMissingNode(i,c,g,d)};t.adds.forEach(d=>{o(d)});const u=performance.now();for(;a.length;){const d=Ou(a);if(a.length=0,performance.now()-u>150){this.warn("Timeout in the loop, please check the resolve tree data:",d);break}for(const l of d)s.getNode(l.value.parentId)?ko(l,c=>{o(c)}):this.debug("Drop resolve tree since there is no parent for the root node.",l)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),Au(t.texts).forEach(d=>{var l;const n=s.getNode(d.id);if(!n)return t.removes.find(c=>c.id===d.id)?void 0:this.warnNodeNotFound(t,d.id);if(n.textContent=d.value,this.usingVirtualDom){const c=n.parentNode;((l=c==null?void 0:c.rules)==null?void 0:l.length)>0&&(c.rules=[])}}),t.attributes.forEach(d=>{var l;const n=s.getNode(d.id);if(!n)return t.removes.find(c=>c.id===d.id)?void 0:this.warnNodeNotFound(t,d.id);for(const c in d.attributes)if(typeof c=="string"){const f=d.attributes[c];if(f===null)n.removeAttribute(c),c==="open"&&Hu(n,d);else if(typeof f=="string")try{if(c==="_cssText"&&(n.nodeName==="LINK"||n.nodeName==="STYLE"))try{const h=s.getMeta(n);Object.assign(h.attributes,d.attributes);const p=et(h,{doc:n.ownerDocument,mirror:s,skipChild:!0,hackCss:!0,cache:this.cache}),m=n.nextSibling,g=n.parentNode;if(p&&g){g.removeChild(n),g.insertBefore(p,m),s.replace(d.id,p);break}}catch(h){}if(c==="value"&&n.nodeName==="TEXTAREA"){const h=n;h.childNodes.forEach(m=>h.removeChild(m));const p=(l=n.ownerDocument)==null?void 0:l.createTextNode(f);p&&h.appendChild(p)}else n.setAttribute(c,f);c==="rr_open_mode"&&n.nodeName==="DIALOG"&&vt(n,d)}catch(h){this.warn("An error occurred may due to the checkout feature.",h)}else if(c==="style"){const h=f,p=n;for(const m in h)if(h[m]===!1)p.style.removeProperty(m);else if(h[m]instanceof Array){const g=h[m];p.style.setProperty(m,g[0],g[1])}else{const g=h[m];p.style.setProperty(m,g)}}}})}applyScroll(t,r){var s,i;const a=this.mirror.getNode(t.id);if(!a)return this.debugNodeNotFound(t,t.id);const o=this.mirror.getMeta(a);if(a===this.iframe.contentDocument)(s=this.iframe.contentWindow)==null||s.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else if((o==null?void 0:o.type)===Re.Document)(i=a.defaultView)==null||i.scrollTo({top:t.y,left:t.x,behavior:r?"auto":"smooth"});else try{a.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:a,end:o,endOffset:u})=>{const d=this.mirror.getNode(i),l=this.mirror.getNode(o);if(!d||!l)return;const n=new Range;n.setStart(d,a),n.setEnd(l,u);const c=d.ownerDocument,f=c==null?void 0:c.getSelection();return f&&r.add(f),{range:n,selection:f}});r.forEach(i=>i.removeAllRanges()),s.forEach(i=>{var a;return i&&((a=i.selection)==null?void 0:a.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===Y.StyleSheetRule?this.applyStyleSheetRule(t,s):t.source===Y.StyleDeclaration&&this.applyStyleDeclaration(t,s))}applyStyleSheetRule(t,r){var s,i,a,o;if((s=t.adds)==null||s.forEach(({rule:u,index:d})=>{try{if(Array.isArray(d)){const{positions:l,index:n}=pn(d);Qe(r.cssRules,l).insertRule(u,n)}else{const l=d===void 0?void 0:Math.min(d,r.cssRules.length);r==null||r.insertRule(u,l)}}catch(l){}}),(i=t.removes)==null||i.forEach(({index:u})=>{try{if(Array.isArray(u)){const{positions:d,index:l}=pn(u);Qe(r.cssRules,d).deleteRule(l||0)}else r==null||r.deleteRule(u)}catch(d){}}),t.replace)try{(a=r.replace)==null||a.call(r,t.replace)}catch(u){}if(t.replaceSync)try{(o=r.replaceSync)==null||o.call(r,t.replaceSync)}catch(u){}}applyStyleDeclaration(t,r){var s,i;if(t.set){const a=Qe(r.rules,t.index);(s=a==null?void 0:a.style)==null||s.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const a=Qe(r.rules,t.index);(i=a==null?void 0:a.style)==null||i.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 d;let l=null,n=null;if(yt(s)?n=((d=s.ownerDocument)==null?void 0:d.defaultView)||null:s.nodeName==="#document"&&(n=s.defaultView),!!n)try{l=new n.CSSStyleSheet,this.styleMirror.add(l,u.styleId),this.applyStyleSheetRule({source:Y.StyleSheetRule,adds:u.rules},l)}catch(c){}});const i=10;let a=0;const o=(u,d)=>{const l=d.map(n=>this.styleMirror.getStyle(n)).filter(n=>n!==null);yt(u)?u.shadowRoot.adoptedStyleSheets=l:u.nodeName==="#document"&&(u.adoptedStyleSheets=l),l.length!==d.length&&a<i&&(setTimeout(()=>o(u,d),0+100*a),a++)};o(s,t.styleIds)}legacy_resolveMissingNode(t,r,s,i){const{previousId:a,nextId:o}=i,u=a&&t[a],d=o&&t[o];if(u){const{node:l,mutation:n}=u;r.insertBefore(l,s),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,l,n)}if(d){const{node:l,mutation:n}=d;r.insertBefore(l,s.nextSibling),delete t[n.node.id],delete this.legacy_missingNodeRetryMap[n.node.id],(n.previousId||n.nextId)&&this.legacy_resolveMissingNode(t,r,l,n)}}moveAndHover(t,r,s,i,a){const o=this.mirror.getNode(s);if(!o)return this.debugNodeNotFound(a,s);const u=Io(o,this.iframe),d=t*u.absoluteScale+u.x,l=r*u.absoluteScale+u.y;this.mouse.style.left=`${d}px`,this.mouse.style.top=`${l}px`,i||this.drawMouseTail({x:d,y:l}),this.hoverElements(o)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:r,lineWidth:s,strokeStyle:i,duration:a}=this.config.mouseTail===!0?Zr:Object.assign({},Zr,this.config.mouseTail),o=()=>{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(d=>u.lineTo(d.x,d.y)),u.stroke())};this.tailPositions.push(t),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(u=>u!==t),o()},a/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!==te.IncrementalSnapshot?!1:t.data.source>Y.Mutation&&t.data.source<=Y.Input}backToNormal(){this.nextUserInteractionEvent=null,!this.speedService.state.matches("normal")&&(this.speedService.send({type:"BACK_TO_NORMAL"}),this.emitter.emit(V.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(xn,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(xn,...t)}}var de=Uint8Array,Me=Uint16Array,li=Uint32Array,Wo=new de([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),$o=new de([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Qu=new de([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),jo=function(e,t){for(var r=new Me(31),s=0;s<31;++s)r[s]=t+=1<<e[s-1];for(var i=new li(r[30]),s=1;s<30;++s)for(var a=r[s];a<r[s+1];++a)i[a]=a-r[s]<<5|s;return[r,i]},Vo=jo(Wo,2),Go=Vo[0],Ku=Vo[1];Go[28]=258,Ku[258]=28;var Zu=jo($o,0),ec=Zu[0],ui=new Me(32768);for(var K=0;K<32768;++K){var Ce=(K&43690)>>>1|(K&21845)<<1;Ce=(Ce&52428)>>>2|(Ce&13107)<<2,Ce=(Ce&61680)>>>4|(Ce&3855)<<4,ui[K]=((Ce&65280)>>>8|(Ce&255)<<8)>>>1}var tt=function(e,t,r){for(var s=e.length,i=0,a=new Me(t);i<s;++i)++a[e[i]-1];var o=new Me(t);for(i=0;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var u;if(r){u=new Me(1<<t);var d=15-t;for(i=0;i<s;++i)if(e[i])for(var l=i<<4|e[i],n=t-e[i],c=o[e[i]-1]++<<n,f=c|(1<<n)-1;c<=f;++c)u[ui[c]>>>d]=l}else for(u=new Me(s),i=0;i<s;++i)u[i]=ui[o[e[i]-1]++]>>>15-e[i];return u},lt=new de(288);for(var K=0;K<144;++K)lt[K]=8;for(var K=144;K<256;++K)lt[K]=9;for(var K=256;K<280;++K)lt[K]=7;for(var K=280;K<288;++K)lt[K]=8;var Ho=new de(32);for(var K=0;K<32;++K)Ho[K]=5;var tc=tt(lt,9,1),rc=tt(Ho,5,1),ei=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},pe=function(e,t,r){var s=t/8>>0;return(e[s]|e[s+1]<<8)>>>(t&7)&r},ti=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(t&7)},ic=function(e){return(e/8>>0)+(e&7&&1)},Yo=function(e,t,r){(r==null||r>e.length)&&(r=e.length);var s=new(e instanceof Me?Me:e instanceof li?li:de)(r-t);return s.set(e.subarray(t,r)),s},sc=function(e,t,r){var s=e.length,i=!t||r,a=!r||r.i;r||(r={}),t||(t=new de(s*3));var o=function(O){var P=t.length;if(O>P){var $=new de(Math.max(P*2,O));$.set(t),t=$}},u=r.f||0,d=r.p||0,l=r.b||0,n=r.l,c=r.d,f=r.m,h=r.n,p=s*8;do{if(!n){r.f=u=pe(e,d,1);var m=pe(e,d+1,3);if(d+=3,m)if(m==1)n=tc,c=rc,f=9,h=5;else if(m==2){var S=pe(e,d,31)+257,C=pe(e,d+10,15)+4,w=S+pe(e,d+5,31)+1;d+=14;for(var b=new de(w),E=new de(19),R=0;R<C;++R)E[Qu[R]]=pe(e,d+R*3,7);d+=C*3;var N=ei(E),x=(1<<N)-1;if(!a&&d+w*(N+7)>p)break;for(var I=tt(E,N,1),R=0;R<w;){var T=I[pe(e,d,x)];d+=T&15;var g=T>>>4;if(g<16)b[R++]=g;else{var J=0,U=0;for(g==16?(U=3+pe(e,d,3),d+=2,J=b[R-1]):g==17?(U=3+pe(e,d,7),d+=3):g==18&&(U=11+pe(e,d,127),d+=7);U--;)b[R++]=J}}var M=b.subarray(0,S),q=b.subarray(S);f=ei(M),h=ei(q),n=tt(M,f,1),c=tt(q,h,1)}else throw"invalid block type";else{var g=ic(d)+4,v=e[g-4]|e[g-3]<<8,y=g+v;if(y>s){if(a)throw"unexpected EOF";break}i&&o(l+v),t.set(e.subarray(g,y),l),r.b=l+=v,r.p=d=y*8;continue}if(d>p)throw"unexpected EOF"}i&&o(l+131072);for(var L=(1<<f)-1,j=(1<<h)-1,H=f+h+18;a||d+H<p;){var J=n[ti(e,d)&L],z=J>>>4;if(d+=J&15,d>p)throw"unexpected EOF";if(!J)throw"invalid length/literal";if(z<256)t[l++]=z;else if(z==256){n=null;break}else{var X=z-254;if(z>264){var R=z-257,ae=Wo[R];X=pe(e,d,(1<<ae)-1)+Go[R],d+=ae}var _=c[ti(e,d)&j],D=_>>>4;if(!_)throw"invalid distance";d+=_&15;var q=ec[D];if(D>3){var ae=$o[D];q+=ti(e,d)&(1<<ae)-1,d+=ae}if(d>p)throw"unexpected EOF";i&&o(l+131072);for(var A=l+X;l<A;l+=4)t[l]=t[l-q],t[l+1]=t[l+1-q],t[l+2]=t[l+2-q],t[l+3]=t[l+3-q];l=A}}r.l=n,r.p=d,r.b=l,n&&(u=1,r.m=f,r.d=c,r.n=h)}while(!u);return l==t.length?t:Yo(t,0,l)},nc=function(e){if((e[0]&15)!=8||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(e[1]&32)throw"invalid zlib data: preset dictionaries not supported"};function oc(e,t){return sc((nc(e),e.subarray(2,-4)),t)}function ac(e,t){for(var r=e.length,s=new de(e.length+(e.length>>>1)),i=0,a=function(l){s[i++]=l},o=0;o<r;++o){if(i+5>s.length){var u=new de(i+8+(r-o<<1));u.set(s),s=u}var d=e.charCodeAt(o);a(d)}return Yo(s,0,i)}function lc(e,t){var r="";if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);for(var s=0;s<e.length;){var i=e[s++];i<128||t?r+=String.fromCharCode(i):i<224?r+=String.fromCharCode((i&31)<<6|e[s++]&63):i<240?r+=String.fromCharCode((i&15)<<12|(e[s++]&63)<<6|e[s++]&63):(i=((i&15)<<18|(e[s++]&63)<<12|(e[s++]&63)<<6|e[s++]&63)-65536,r+=String.fromCharCode(55296|i>>10,56320|i&1023))}return r}const Nn="v1",uc=e=>{if(typeof e!="string")return e;try{const t=JSON.parse(e);if(t.timestamp)return t}catch(t){}try{const t=JSON.parse(lc(oc(ac(e,!0))));if(t.v===Nn)return t;throw new Error(`These events were packed with packer ${t.v} which is incompatible with current packer ${Nn}.`)}catch(t){throw console.error(t),new Error("Unknown data format.")}};var Fi=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(Fi||{}),ci=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ci||{});function _n(e){let t="";return Object.keys(e).forEach(r=>{t+=`${r}: ${e[r]};`}),t}function Xe(e,t=2){let r=String(e);const s=Math.pow(10,t-1);if(e<s)for(;String(s).length>r.length;)r=`0${e}`;return r}const Jo=1e3,hi=60*Jo,On=60*hi;function bt(e){if(e<=0)return"00:00";const t=Math.floor(e/On);e=e%On;const r=Math.floor(e/hi);e=e%hi;const s=Math.floor(e/Jo);return t?`${Xe(t)}:${Xe(r)}:${Xe(s)}`:`${Xe(r)}:${Xe(s)}`}function cc(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.resolve()}function hc(){return document.exitFullscreen?document.exitFullscreen():document.mozExitFullscreen?document.mozExitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.resolve()}function An(){let e=!1;return["fullscreen","webkitIsFullScreen","mozFullScreen","msFullscreenElement"].forEach(t=>{t in document&&(e=e||!!document[t])}),e}function fc(e){return document.addEventListener("fullscreenchange",e),document.addEventListener("webkitfullscreenchange",e),document.addEventListener("mozfullscreenchange",e),document.addEventListener("MSFullscreenChange",e),()=>{document.removeEventListener("fullscreenchange",e),document.removeEventListener("webkitfullscreenchange",e),document.removeEventListener("mozfullscreenchange",e),document.removeEventListener("MSFullscreenChange",e)}}function Dn(e){return{"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regExp","[object Undefined]":"undefined","[object Null]":"null","[object Object]":"object"}[Object.prototype.toString.call(e)]}function dc(e){return e.type!==Fi.IncrementalSnapshot?!1:e.data.source>ci.Mutation&&e.data.source<=ci.Input}function pc(e,t){const r=[];let s=e[0].timestamp;for(const i of e)dc(i)&&(i.timestamp-s>t&&r.push([s,i.timestamp]),s=i.timestamp);return r}function mc(e){let t,r,s,i,a,o,u,d,l;return{c(){t=oe("div"),r=oe("input"),s=fe(),i=oe("label"),a=fe(),o=oe("span"),u=Te(e[3]),B(r,"type","checkbox"),B(r,"id",e[2]),r.disabled=e[1],B(r,"class","svelte-a6h7w7"),B(i,"for",e[2]),B(i,"class","svelte-a6h7w7"),B(o,"class","label svelte-a6h7w7"),B(t,"class","switch svelte-a6h7w7"),Ve(t,"disabled",e[1])},m(n,c){Ee(n,t,c),G(t,r),r.checked=e[0],G(t,s),G(t,i),G(t,a),G(t,o),G(o,u),d||(l=We(r,"change",e[4]),d=!0)},p(n,[c]){c&4&&B(r,"id",n[2]),c&2&&(r.disabled=n[1]),c&1&&(r.checked=n[0]),c&4&&B(i,"for",n[2]),c&8&&Ct(u,n[3]),c&2&&Ve(t,"disabled",n[1])},i:rt,o:rt,d(n){n&&ve(t),d=!1,l()}}}function gc(e,t,r){let{disabled:s}=t,{checked:i}=t,{id:a}=t,{label:o}=t;function u(){i=this.checked,r(0,i)}return e.$$set=d=>{"disabled"in d&&r(1,s=d.disabled),"checked"in d&&r(0,i=d.checked),"id"in d&&r(2,a=d.id),"label"in d&&r(3,o=d.label)},[i,s,a,o,u]}class yc extends gi{constructor(t){super(),mi(this,t,gc,mc,fi,{disabled:1,checked:0,id:2,label:3})}}function Pn(e,t,r){const s=e.slice();return s[38]=t[r],s}function Tn(e,t,r){const s=e.slice();return s[41]=t[r],s}function kn(e,t,r){const s=e.slice();return s[44]=t[r],s}function In(e){let t,r,s,i=bt(e[6])+"",a,o,u,d,l,n,c,f,h,p,m=bt(e[8].totalTime)+"",g,v,y,S,C,w,b,E,R,N,x,I,T,J=Fe(e[13]),U=[];for(let D=0;D<J.length;D+=1)U[D]=Ln(kn(e,J,D));let M=Fe(e[9]),q=[];for(let D=0;D<M.length;D+=1)q[D]=Fn(Tn(e,M,D));function L(D,A){return D[7]==="playing"?vc:wc}let j=L(e),H=j(e),z=Fe(e[3]),X=[];for(let D=0;D<z.length;D+=1)X[D]=Bn(Pn(e,z,D));function ae(D){e[29](D)}let _={id:"skip",disabled:e[10]==="skipping",label:"skip inactive"};return e[0]!==void 0&&(_.checked=e[0]),b=new yc({props:_}),Pe.push(()=>ma(b,"checked",ae)),{c(){t=oe("div"),r=oe("div"),s=oe("span"),a=Te(i),o=fe(),u=oe("div"),d=oe("div"),l=fe();for(let D=0;D<U.length;D+=1)U[D].c();n=fe();for(let D=0;D<q.length;D+=1)q[D].c();c=fe(),f=oe("div"),h=fe(),p=oe("span"),g=Te(m),v=fe(),y=oe("div"),S=oe("button"),H.c(),C=fe();for(let D=0;D<X.length;D+=1)X[D].c();w=fe(),Jn(b.$$.fragment),R=fe(),N=oe("button"),N.innerHTML=`<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><defs><style type="text/css"></style></defs><path d="M916 380c-26.4 0-48-21.6-48-48L868 223.2 613.6 477.6c-18.4
148
148
  18.4-48.8 18.4-68 0-18.4-18.4-18.4-48.8 0-68L800 156 692 156c-26.4
149
149
  0-48-21.6-48-48 0-26.4 21.6-48 48-48l224 0c26.4 0 48 21.6 48 48l0
150
150
  224C964 358.4 942.4 380 916 380zM231.2 860l108.8 0c26.4 0 48 21.6 48