@posthog/rrweb-player 0.0.23 → 0.0.24

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.
@@ -156,7 +156,7 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
156
156
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
157
157
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
158
158
  PERFORMANCE OF THIS SOFTWARE.
159
- ***************************************************************************** */function rn(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(t===void 0||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(l){i={error:l}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}var qe;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(qe||(qe={}));var bo={type:"xstate.init"};function jr(e){return e===void 0?[]:[].concat(e)}function Ue(e){return{type:"xstate.assign",assignment:e}}function sn(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 Et(e){return function(t){return e===t}}function So(e){return typeof e=="string"?{type:e}:e}function nn(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Et(e)}}function on(e,t,r){var n=t,i=!1;return[e.filter(function(a){if(a.type==="xstate.assign"){i=!0;var o=Object.assign({},n);return typeof a.assignment=="function"?o=a.assignment(n,r):Object.keys(a.assignment).forEach(function(l){o[l]=typeof a.assignment[l]=="function"?a.assignment[l](n,r):a.assignment[l]}),n=o,!1}return!0}),n,i]}function Co(e,t){t===void 0&&(t={});var r=rn(on(jr(e.states[e.initial].entry).map(function(o){return sn(o,t.actions)}),e.context,bo),2),n=r[0],i=r[1],a={config:e,_options:t,initialState:{value:e.initial,actions:n,context:i,matches:Et(e.initial)},transition:function(o,l){var p,u,s=typeof o=="string"?{value:o,context:e.context}:o,c=s.value,f=s.context,h=So(l),d=e.states[c];if(d.on){var m=jr(d.on[h.type]);try{for(var g=function(I){var j=typeof Symbol=="function"&&Symbol.iterator,H=j&&I[j],z=0;if(H)return H.call(I);if(I&&typeof I.length=="number")return{next:function(){return I&&z>=I.length&&(I=void 0),{value:I&&I[z++],done:!I}}};throw new TypeError(j?"Object is not iterable.":"Symbol.iterator is not defined.")}(m),b=g.next();!b.done;b=g.next()){var y=b.value;if(y===void 0)return nn(c,f);var S=typeof y=="string"?{target:y}:y,E=S.target,w=S.actions,v=w===void 0?[]:w,C=S.cond,R=C===void 0?function(){return!0}:C,A=E===void 0,M=E!=null?E:c,B=e.states[M];if(R(f,h)){var k=rn(on((A?jr(v):[].concat(d.exit,v,B.entry).filter(function(I){return I})).map(function(I){return sn(I,a._options.actions)}),f,h),3),J=k[0],U=k[1],x=k[2],q=E!=null?E:c;return{value:q,context:U,actions:J,changed:E!==c||J.length>0||x,matches:Et(q)}}}}catch(I){p={error:I}}finally{try{b&&!b.done&&(u=g.return)&&u.call(g)}finally{if(p)throw p.error}}}return nn(c,f)}};return a}var an=function(e,t){return e.actions.forEach(function(r){var n=r.exec;return n&&n(e.context,t)})};function Eo(e){var t=e.initialState,r=qe.NotStarted,n=new Set,i={_machine:e,send:function(a){r===qe.Running&&(t=e.transition(t,a),an(t,So(a)),n.forEach(function(o){return o(t)}))},subscribe:function(a){return n.add(a),a(t),{unsubscribe:function(){return n.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:Et(o.value)}}return r=qe.Running,an(t,bo),i},stop:function(){return r=qe.Stopped,n.clear(),i},get state(){return t},get status(){return r}};return i}function jl(e,t){for(let r=e.length-1;r>=0;r--){const n=e[r];if(n.type===te.Meta&&n.timestamp<=t)return e.slice(r)}return e}function Gl(e,{getCastFn:t,applyEventsSynchronously:r,emitter:n}){const i=Co({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:Ue({lastPlayedEvent:(a,o)=>o.type==="CAST_EVENT"?o.payload.event:a.lastPlayedEvent}),recordTimeOffset:Ue((a,o)=>{let l=a.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(l=o.payload.timeOffset),le(Q({},a),{timeOffset:l,baselineTime:a.events[0].timestamp+l})}),play(a){var o;const{timer:l,events:p,baselineTime:u,lastPlayedEvent:s}=a;l.clear();for(const d of p)tn(d,u);const c=jl(p,u);let f=s==null?void 0:s.timestamp;(s==null?void 0:s.type)===te.IncrementalSnapshot&&s.data.source===Y.MouseMove&&(f=s.timestamp+((o=s.data.positions[0])==null?void 0:o.timeOffset)),u<(f||0)&&n.emit(G.PlayBack);const h=new Array;for(const d of c)if(!(f&&f<u&&(d.timestamp<=f||d===s)))if(d.timestamp<u)h.push(d);else{const m=t(d,!1);l.addAction({doAction:()=>{m()},delay:d.delay})}r(h),n.emit(G.Flush),l.start()},pause(a){a.timer.clear()},resetLastPlayedEvent:Ue(a=>le(Q({},a),{lastPlayedEvent:null})),startLive:Ue({baselineTime:(a,o)=>(a.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:Ue((a,o)=>{const{baselineTime:l,timer:p,events:u}=a;if(o.type==="ADD_EVENT"){const{event:s}=o.payload;tn(s,l);let c=u.length-1;if(!u[c]||u[c].timestamp<=s.timestamp)u.push(s);else{let d=-1,m=0;for(;m<=c;){const g=Math.floor((m+c)/2);u[g].timestamp<=s.timestamp?m=g+1:c=g-1}d===-1&&(d=m),u.splice(d,0,s)}const f=s.timestamp<l,h=t(s,f);f?h():p.isActive()&&p.addAction({doAction:()=>{h()},delay:s.delay})}return le(Q({},a),{events:u})})}});return Eo(i)}function $l(e){const t=Co({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,n)=>{"payload"in n&&r.timer.setSpeed(n.payload.speed)},recordSpeed:Ue({normalSpeed:r=>r.timer.speed}),restoreSpeed:r=>{r.timer.setSpeed(r.normalSpeed)}}});return Eo(t)}const Hl=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],ln=new Map;function Ro(e,t){let r=ln.get(e);return r||(r=new Map,ln.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function xe(e,t,r){return async n=>{if(n&&typeof n=="object"&&"rr_type"in n)if(r&&(r.isUnchanged=!1),n.rr_type==="ImageBitmap"&&"args"in n){const i=await xe(e,t,r)(n.args);return await createImageBitmap.apply(null,i)}else if("index"in n){if(r||t===null)return n;const{rr_type:i,index:a}=n;return Ro(t,i)[a]}else if("args"in n){const{rr_type:i,args:a}=n,o=window[i];return new o(...await Promise.all(a.map(xe(e,t,r))))}else{if("base64"in n)return Ul(n.base64);if("src"in n){const i=e.get(n.src);if(i)return i;{const a=new Image;return a.src=n.src,e.set(n.src,a),a}}else if("data"in n&&n.rr_type==="Blob"){const i=await Promise.all(n.data.map(xe(e,t,r)));return new Blob(i,{type:n.type})}}else if(Array.isArray(n))return await Promise.all(n.map(xe(e,t,r)));return n}}function Yl(e,t){try{return t===Ct.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(r){return null}}const Jl=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Xl(e,t){if(!(t!=null&&t.constructor))return;const{name:r}=t.constructor;if(!Jl.includes(r))return;const n=Ro(e,r);n.includes(t)||n.push(t)}async function Ql({mutation:e,target:t,type:r,imageMap:n,errorHandler:i}){try{const a=Yl(t,r);if(!a)return;if(e.setter){a[e.property]=e.args[0];return}const o=a[e.property],l=await Promise.all(e.args.map(xe(n,a))),p=o.apply(a,l);Xl(a,p);const u=!1}catch(a){i(e,a)}}async function Kl({event:e,mutations:t,target:r,imageMap:n,errorHandler:i}){const a=r.getContext("2d");if(!a){i(t[0],new Error("Canvas context is null"));return}const o=t.map(async p=>Promise.all(p.args.map(xe(n,a))));(await Promise.all(o)).forEach((p,u)=>{const s=t[u];try{if(s.setter){a[s.property]=s.args[0];return}const c=a[s.property];s.property==="drawImage"&&typeof s.args[0]=="string"?(n.get(e),c.apply(a,s.args)):c.apply(a,p)}catch(c){i(s,c)}})}async function un({event:e,mutation:t,target:r,imageMap:n,canvasEventMap:i,errorHandler:a}){try{const o=i.get(e)||t,l="commands"in o?o.commands:[o];if([Ct.WebGL,Ct.WebGL2].includes(t.type)){for(let p=0;p<l.length;p++){const u=l[p];await Ql({mutation:u,type:t.type,target:r,imageMap:n,errorHandler:a})}return}await Kl({event:e,mutations:l,target:r,imageMap:n,errorHandler:a})}catch(o){a(t,o)}}const cn=["AUDIO","VIDEO"];class Zl{constructor(t){L(this,"mediaMap",new Map),L(this,"warn"),L(this,"service"),L(this,"speedService"),L(this,"emitter"),L(this,"getCurrentTime"),L(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(G.Start,this.start.bind(this)),this.emitter.on(G.SkipStart,this.start.bind(this)),this.emitter.on(G.Pause,this.pause.bind(this)),this.emitter.on(G.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(t={pause:!1}){this.mediaMap.forEach((r,n)=>{this.syncTargetWithState(n),t.pause&&n.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:t,target:r,mediaState:n}){if(n.isPlaying){const a=(t-n.lastInteractionTimeOffset)/1e3*n.playbackRate,o="duration"in r&&r.duration;if(Number.isNaN(o)){this.waitForMetadata(r);return}let l=n.currentTimeAtLastInteraction+a;r.loop&&o!==!1&&(l=l%o),r.currentTime=l}else r.pause(),r.currentTime=n.currentTimeAtLastInteraction}waitForMetadata(t){if(this.metadataCallbackMap.has(t)||!("addEventListener"in t))return;const r=()=>{this.metadataCallbackMap.delete(t);const n=this.mediaMap.get(t);n&&this.seekTo({time:this.getCurrentTime(),target:t,mediaState:n})};this.metadataCallbackMap.set(t,r),t.addEventListener("loadedmetadata",r,{once:!0})}getMediaStateFromMutation({target:t,timeOffset:r,mutation:n}){var h,d,m,g,b;const i=this.mediaMap.get(t),{type:a,playbackRate:o,currentTime:l,muted:p,volume:u,loop:s}=n;return{isPlaying:a===Zr.Play||a!==Zr.Pause&&((i==null?void 0:i.isPlaying)||t.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(h=l!=null?l:i==null?void 0:i.currentTimeAtLastInteraction)!=null?h:0,lastInteractionTimeOffset:r,playbackRate:(d=o!=null?o:i==null?void 0:i.playbackRate)!=null?d:1,volume:(m=u!=null?u:i==null?void 0:i.volume)!=null?m:1,muted:(g=p!=null?p:i==null?void 0:i.muted)!=null?g:t.getAttribute("muted")===null,loop:(b=s!=null?s:i==null?void 0:i.loop)!=null?b:t.getAttribute("loop")===null}}syncTargetWithState(t){const r=this.mediaMap.get(t);if(!r)return;const{muted:n,loop:i,volume:a,isPlaying:o}=r,l=this.service.state.matches("paused"),p=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=n,t.loop=i,t.playbackRate!==p&&(t.playbackRate=p),o&&!l?t.play():t.pause()}catch(u){this.warn(`Failed to replay media interactions: ${u.message||u}`)}}addMediaElements(t,r,n){if(!this.isSupportedMediaElement(t))return;const i=t,a=n.getMeta(i);if(!a||!("attributes"in a))return;const o=this.service.state.matches("paused"),l=a.attributes;let p=!1;l.rr_mediaState?p=l.rr_mediaState==="played":p=i.getAttribute("autoplay")!==null,p&&o&&i.pause();let u=1;typeof l.rr_mediaPlaybackRate=="number"&&(u=l.rr_mediaPlaybackRate);let s=!1;typeof l.rr_mediaMuted=="boolean"?s=l.rr_mediaMuted:s=i.getAttribute("muted")!==null;let c=!1;typeof l.rr_mediaLoop=="boolean"?c=l.rr_mediaLoop:c=i.getAttribute("loop")!==null;let f=1;typeof l.rr_mediaVolume=="number"&&(f=l.rr_mediaVolume);let h=0;typeof l.rr_mediaCurrentTime=="number"&&(h=l.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:p,currentTimeAtLastInteraction:h,lastInteractionTimeOffset:r,playbackRate:u,volume:f,muted:s,loop:c}),this.syncTargetWithState(i)}mediaMutation({target:t,timeOffset:r,mutation:n}){cn.includes(t.nodeName)&&(this.mediaMap.set(t,this.getMediaStateFromMutation({target:t,timeOffset:r,mutation:n})),this.syncTargetWithState(t))}isSupportedMediaElement(t){return cn.includes(t.nodeName)}reset(){this.mediaMap.clear()}}function mt(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e,n=r.open,i=n&&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",l=a==="modal";if(!(n&&!(i&&a==="non-modal"||!i&&l))){if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}n&&r.close(),o&&(l?r.showModal():r.show())}}function eu(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 tu=5*1e3,ru=vo||ql,hn="[replayer]",Gr={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function fn(e){return e.type==te.IncrementalSnapshot&&(e.data.source==Y.TouchMove||e.data.source==Y.MouseInteraction&&e.data.type==ne.TouchStart)}class iu{constructor(t,r){if(L(this,"wrapper"),L(this,"iframe"),L(this,"service"),L(this,"speedService"),L(this,"config"),L(this,"usingVirtualDom",!1),L(this,"virtualDom",new $e),L(this,"mouse"),L(this,"mouseTail",null),L(this,"tailPositions",[]),L(this,"emitter",ru()),L(this,"nextUserInteractionEvent"),L(this,"legacy_missingNodeRetryMap",{}),L(this,"cache",gs()),L(this,"imageMap",new Map),L(this,"canvasEventMap",new Map),L(this,"mirror",Fn()),L(this,"styleMirror",new Bl),L(this,"mediaManager"),L(this,"firstFullSnapshot",null),L(this,"newDocumentQueue",[]),L(this,"mousePos",null),L(this,"touchActive",null),L(this,"lastMouseDownEvent",null),L(this,"lastHoveredRootNode"),L(this,"lastSelectionData",null),L(this,"constructedStyleMutations",[]),L(this,"adoptedStyleSheets",[]),L(this,"handleResize",l=>{this.iframe.style.display="inherit";for(const p of[this.mouseTail,this.iframe])p&&(p.setAttribute("width",String(l.width)),p.setAttribute("height",String(l.height)))}),L(this,"applyEventsSynchronously",l=>{for(const p of l){switch(p.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(p,!0)()}}),L(this,"getCastFn",(l,p=!1)=>{let u;switch(l.type){case te.DomContentLoaded:case te.Load:break;case te.Custom:u=()=>{this.emitter.emit(G.CustomEvent,l)};break;case te.Meta:u=()=>this.emitter.emit(G.Resize,{width:l.data.width,height:l.data.height});break;case te.FullSnapshot:u=()=>{var c;if(this.firstFullSnapshot){if(this.firstFullSnapshot===l){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(l,p),(c=this.iframe.contentWindow)==null||c.scrollTo(l.data.initialOffset)};break;case te.IncrementalSnapshot:u=()=>{if(this.applyIncremental(l,p),!p&&(l===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const c of this.service.state.context.events)if(!(c.timestamp<=l.timestamp)&&this.isUserInteraction(c)){c.delay-l.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=c);break}if(this.nextUserInteractionEvent){const c=this.nextUserInteractionEvent.delay-l.delay,f={speed:Math.min(Math.round(c/tu),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:f}),this.emitter.emit(G.SkipStart,f)}}};break}return()=>{u&&u();for(const f of this.config.plugins||[])f.handler&&f.handler(l,p,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:l}});const c=this.service.state.context.events.length-1;if(!this.config.liveMode&&l===this.service.state.context.events[c]){const f=()=>{c<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(G.Finish))};let h=50;l.type===te.IncrementalSnapshot&&l.data.source===Y.MouseMove&&l.data.positions.length&&(h+=Math.max(0,-l.data.positions[0].timeOffset)),setTimeout(f,h)}this.emitter.emit(G.EventCast,l)}}),!(r!=null&&r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const n={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:Gr,useVirtualDom:!0,logger:console};this.config=Object.assign({},n,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(G.Resize,this.handleResize),this.setupDom();for(const l of this.config.plugins||[])l.getMirror&&l.getMirror({nodeMirror:this.mirror});this.emitter.on(G.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(p,u,s)=>{un({event:p,mutation:u,target:s,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(p,u)=>{p.source===Y.StyleSheetRule?this.applyStyleSheetRule(p,u):p.source===Y.StyleDeclaration&&this.applyStyleDeclaration(p,u)},afterAppend:(p,u)=>{for(const s of this.config.plugins||[])s.onBuild&&s.onBuild(p,{id:u,replayer:this})}};if(this.iframe.contentDocument)try{bt(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror)}catch(p){this.warn(p)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const p in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[p],s=St(u.node,this.mirror,this.virtualDom.mirror);bt(s,u.node,l,this.virtualDom.mirror),u.node=s}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(p=>{this.applyStyleSheetMutation(p)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(p=>{this.applyAdoptedStyleSheet(p)}),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,p]=this.lastMouseDownEvent;l.dispatchEvent(p)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(G.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const i=new Vl([],{speed:this.config.speed});this.service=Gl({events:t.map(l=>r&&r.unpackFn?r.unpackFn(l):l).sort((l,p)=>l.timestamp-p.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(G.StateChange,{player:l})}),this.speedService=$l({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(G.StateChange,{speed:l})}),this.mediaManager=new Zl({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const a=this.service.state.context.events.find(l=>l.type===te.Meta),o=this.service.state.context.events.find(l=>l.type===te.FullSnapshot);if(a){const{width:l,height:p}=a.data;setTimeout(()=>{this.emitter.emit(G.Resize,{width:l,height:p})},0)}o&&setTimeout(()=>{var l;this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),(l=this.iframe.contentWindow)==null||l.scrollTo(o.data.initialOffset))},1),this.service.state.context.events.find(fn)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,r){return this.emitter.on(t,r),this}off(t,r){return this.emitter.off(t,r),this}setConfig(t){Object.keys(t).forEach(r=>{t[r],this.config[r]=t[r]}),this.config.skipInactive||this.backToNormal(),typeof t.speed!="undefined"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail!="undefined"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getMetaData(){const t=this.service.state.context.events[0],r=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:r.timestamp,totalTime:r.timestamp-t.timestamp}}getCurrentTime(){return this.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,n;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}})),(n=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||n.classList.remove("rrweb-paused"),this.emitter.emit(G.Start)}pause(t){var r,n;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(n=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||n.classList.add("rrweb-paused"),this.emitter.emit(G.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(G.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(G.Destroy)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const r=this.config.unpackFn?this.config.unpackFn(t):t;fn(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=gs()}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&&(Wl(this.iframe.contentWindow,this.iframe.contentDocument),Il(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 n=[],i=new Set,a=(p,u)=>{if(p.nodeName==="DIALOG"&&i.add(p),this.collectIframeAndAttachDocument(n,p),this.mediaManager.isSupportedMediaElement(p)){const{events:s}=this.service.state.context;this.mediaManager.addMediaElements(p,t.timestamp-s[0].timestamp,this.mirror)}for(const s of this.config.plugins||[])s.onBuild&&s.onBuild(p,{id:u,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),Aa(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:p,builtNode:u}of n)this.attachDocumentToIframe(p,u),this.newDocumentQueue=this.newDocumentQueue.filter(s=>s!==p);const{documentElement:o,head:l}=this.iframe.contentDocument;this.insertStyleRules(o,l),i.forEach(p=>mt(p)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(G.FullsnapshotRebuilded,t),r||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,r){var n;const i=Hl(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,mo(a,this.virtualDom.unserializedId)),t.insertBefore(a,r),a.rules.push({source:Y.StyleSheetRule,adds:i.map((o,l)=>({rule:o,index:l}))})}else{const a=document.createElement("style");t.insertBefore(a,r);for(let o=0;o<i.length;o++)(n=a.sheet)==null||n.insertRule(i[o],o)}}attachDocumentToIframe(t,r){const n=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],a=new Set,o=(l,p)=>{l.nodeName==="DIALOG"&&a.add(l),this.collectIframeAndAttachDocument(i,l);const u=n.getMeta(l);if((u==null?void 0:u.type)===Re.Element&&(u==null?void 0:u.tagName.toUpperCase())==="HTML"){const{documentElement:s,head:c}=r.contentDocument;this.insertStyleRules(s,c)}if(!this.usingVirtualDom)for(const s of this.config.plugins||[])s.onBuild&&s.onBuild(l,{id:p,replayer:this})};Ke(t.node,{doc:r.contentDocument,mirror:n,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(r.contentDocument,t.node.id);for(const{mutationInQueue:l,builtNode:p}of i)this.attachDocumentToIframe(l,p),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==l);a.forEach(l=>mt(l))}collectIframeAndAttachDocument(t,r){if(Vr(r,this.mirror)){const n=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(r));n&&t.push({mutationInQueue:n,builtNode:r})}}waitForStylesheetLoad(){var t;const r=(t=this.iframe.contentDocument)==null?void 0:t.head;if(r){const n=new Set;let i,a=this.service.state;const o=()=>{a=this.service.state};this.emitter.on(G.Start,o),this.emitter.on(G.Pause,o);const l=()=>{this.emitter.off(G.Start,o),this.emitter.off(G.Pause,o)};r.querySelectorAll('link[rel="stylesheet"]').forEach(p=>{p.sheet||(n.add(p),p.addEventListener("load",()=>{n.delete(p),n.size===0&&i!==-1&&(a.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(G.LoadStylesheetEnd),i&&clearTimeout(i),l())}))}),n.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(G.LoadStylesheetStart),i=setTimeout(()=>{a.matches("playing")&&this.play(this.getCurrentTime()),i=-1,l()},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 n=document.createElement("canvas"),i=n.getContext("2d"),a=i==null?void 0:i.createImageData(n.width,n.height);i==null||i.putImageData(a,0,0)}}async deserializeAndPreloadCanvasEvents(t,r){if(!this.canvasEventMap.has(r)){const n={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,n)));return le(Q({},a),{args:o})}));n.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{commands:i}))}else{const i=await Promise.all(t.args.map(xe(this.imageMap,null,n)));n.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{args:i}))}}}applyIncremental(t,r){var n,i,a;const{data:o}=t;switch(o.source){case Y.Mutation:{try{this.applyMutation(o,r)}catch(l){this.warn(`Exception in mutation ${l.message||l}`,o)}break}case Y.Drag:case Y.TouchMove:case Y.MouseMove:if(r){const l=o.positions[o.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:o}}else o.positions.forEach(l=>{const p={doAction:()=>{this.moveAndHover(l.x,l.y,l.id,r,o)},delay:l.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(p)}),this.timer.addAction({doAction(){},delay:t.delay-((n=o.positions[0])==null?void 0:n.timeOffset)});break;case Y.MouseInteraction:{if(o.id===-1)break;const l=new Event(oa(ne[o.type])),p=this.mirror.getNode(o.id);if(!p)return this.debugNodeNotFound(o,o.id);this.emitter.emit(G.MouseInteraction,{type:o.type,target:p});const{triggerFocus:u}=this.config;switch(o.type){case ne.Blur:"blur"in p&&p.blur();break;case ne.Focus:u&&p.focus&&p.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=[p,l]: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"):p.dispatchEvent(l));break;case ne.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:p.dispatchEvent(l)}break}case Y.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.scrollData=o;break}this.applyScroll(o,r);break}case Y.ViewportResize:this.emitter.emit(G.Resize,{width:o.width,height:o.height});break;case Y.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.inputData=o;break}this.applyInput(o);break}case Y.MediaInteraction:{const l=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const p=l,{events:u}=this.service.state.context;this.mediaManager.mediaMutation({target:p,timeOffset:t.timestamp-u[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 l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.canvasMutations.push({event:t,mutation:o})}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);un({event:t,mutation:o,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case Y.Font:{try{const l=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(a=this.iframe.contentDocument)==null||a.fonts.add(l)}catch(l){this.warn(l)}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,yl(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const p in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[p],s=po(u.node,this.virtualDom,this.mirror);s&&(u.node=s)}catch(u){this.warn(u)}const n=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(p=>n.getNode(p.id)?!0:(this.warnNodeNotFound(t,p.id),!1)),t.removes.forEach(p=>{var u;const s=n.getNode(p.id);if(!s)return;let c=n.getNode(p.parentId);if(!c)return this.warnNodeNotFound(t,p.parentId);if(p.isShadow&&pt(c)&&(c=c.shadowRoot),n.removeNodeFromMap(s),c)try{c.removeChild(s),this.usingVirtualDom&&s.nodeName==="#text"&&c.nodeName==="STYLE"&&((u=c.rules)==null?void 0:u.length)>0&&(c.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",c,s,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),a=[],o=p=>{var u,s;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let c=n.getNode(p.parentId);if(!c)return p.node.type===Re.Document?this.newDocumentQueue.push(p):t.adds.some(S=>S.node.id===p.parentId)?a.push(p):void 0;p.node.isShadow&&(pt(c)||c.attachShadow({mode:"open"}),c=c.shadowRoot);let f=null,h=null;if(p.previousId&&(f=n.getNode(p.previousId)),p.nextId&&(h=n.getNode(p.nextId)),p.node.rootId&&!n.getNode(p.node.rootId))return;const d=p.node.rootId?n.getNode(p.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Vr(c,n)){this.attachDocumentToIframe(p,c);return}const m=(y,S)=>{if(!this.usingVirtualDom){mt(y);for(const E of this.config.plugins||[])E.onBuild&&E.onBuild(y,{id:S,replayer:this})}},g=Ke(p.node,{doc:d,mirror:n,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:m});if(p.previousId===-1||p.nextId===-1){i[p.node.id]={node:g,mutation:p};return}const b=n.getMeta(c);if(b&&b.type===Re.Element&&p.node.type===Re.Text){const y=Array.isArray(c.childNodes)?c.childNodes:Array.from(c.childNodes);if(b.tagName==="textarea")for(const S of y)S.nodeType===c.TEXT_NODE&&c.removeChild(S);else if(b.tagName==="style"&&y.length===1)for(const S of y)S.nodeType===c.TEXT_NODE&&!n.hasNode(S)&&(g.textContent=S.textContent,c.removeChild(S))}else if((b==null?void 0:b.type)===Re.Document){const y=c;p.node.type===Re.DocumentType&&((u=y.childNodes[0])==null?void 0:u.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,p.node.id),this.usingVirtualDom&&g.nodeName==="#text"&&c.nodeName==="STYLE"&&((s=c.rules)==null?void 0:s.length)>0&&(c.rules=[]),Vr(g,this.mirror)){const y=this.mirror.getId(g),S=this.newDocumentQueue.find(E=>E.parentId===y);S&&(this.attachDocumentToIframe(S,g),this.newDocumentQueue=this.newDocumentQueue.filter(E=>E!==S))}(p.previousId||p.nextId)&&this.legacy_resolveMissingNode(i,c,g,p)};t.adds.forEach(p=>{o(p)});const l=performance.now();for(;a.length;){const p=Ll(a);if(a.length=0,performance.now()-l>150){this.warn("Timeout in the loop, please check the resolve tree data:",p);break}for(const u of p)n.getNode(u.value.parentId)?yo(u,c=>{o(c)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),Fl(t.texts).forEach(p=>{var u;const s=n.getNode(p.id);if(!s)return t.removes.find(c=>c.id===p.id)?void 0:this.warnNodeNotFound(t,p.id);if(s.textContent=p.value,this.usingVirtualDom){const c=s.parentNode;((u=c==null?void 0:c.rules)==null?void 0:u.length)>0&&(c.rules=[])}}),t.attributes.forEach(p=>{var u;const s=n.getNode(p.id);if(!s)return t.removes.find(c=>c.id===p.id)?void 0:this.warnNodeNotFound(t,p.id);for(const c in p.attributes)if(typeof c=="string"){const f=p.attributes[c];if(f===null)s.removeAttribute(c),c==="open"&&eu(s,p);else if(typeof f=="string")try{if(c==="_cssText"&&(s.nodeName==="LINK"||s.nodeName==="STYLE"))try{const h=n.getMeta(s);Object.assign(h.attributes,p.attributes);const d=Ke(h,{doc:s.ownerDocument,mirror:n,skipChild:!0,hackCss:!0,cache:this.cache}),m=s.nextSibling,g=s.parentNode;if(d&&g){g.removeChild(s),g.insertBefore(d,m),n.replace(p.id,d);break}}catch(h){}if(c==="value"&&s.nodeName==="TEXTAREA"){const h=s;h.childNodes.forEach(m=>h.removeChild(m));const d=(u=s.ownerDocument)==null?void 0:u.createTextNode(f);d&&h.appendChild(d)}else s.setAttribute(c,f);c==="rr_open_mode"&&s.nodeName==="DIALOG"&&mt(s,p)}catch(h){this.warn("An error occurred may due to the checkout feature.",h)}else if(c==="style"){const h=f,d=s;for(const m in h)if(h[m]===!1)d.style.removeProperty(m);else if(h[m]instanceof Array){const g=h[m];d.style.setProperty(m,g[0],g[1])}else{const g=h[m];d.style.setProperty(m,g)}}}})}applyScroll(t,r){var n,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)(n=this.iframe.contentWindow)==null||n.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(l){}}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(n){}}applySelection(t){try{const r=new Set,n=t.ranges.map(({start:i,startOffset:a,end:o,endOffset:l})=>{const p=this.mirror.getNode(i),u=this.mirror.getNode(o);if(!p||!u)return;const s=new Range;s.setStart(p,a),s.setEnd(u,l);const c=p.ownerDocument,f=c==null?void 0:c.getSelection();return f&&r.add(f),{range:s,selection:f}});r.forEach(i=>i.removeAllRanges()),n.forEach(i=>{var a;return i&&((a=i.selection)==null?void 0:a.addRange(i.range))})}catch(r){}}applyStyleSheetMutation(t){var r;let n=null;t.styleId?n=this.styleMirror.getStyle(t.styleId):t.id&&(n=((r=this.mirror.getNode(t.id))==null?void 0:r.sheet)||null),n&&(t.source===Y.StyleSheetRule?this.applyStyleSheetRule(t,n):t.source===Y.StyleDeclaration&&this.applyStyleDeclaration(t,n))}applyStyleSheetRule(t,r){var n,i,a,o;if((n=t.adds)==null||n.forEach(({rule:l,index:p})=>{try{if(Array.isArray(p)){const{positions:u,index:s}=Zs(p);Je(r.cssRules,u).insertRule(l,s)}else{const u=p===void 0?void 0:Math.min(p,r.cssRules.length);r==null||r.insertRule(l,u)}}catch(u){}}),(i=t.removes)==null||i.forEach(({index:l})=>{try{if(Array.isArray(l)){const{positions:p,index:u}=Zs(l);Je(r.cssRules,p).deleteRule(u||0)}else r==null||r.deleteRule(l)}catch(p){}}),t.replace)try{(a=r.replace)==null||a.call(r,t.replace)}catch(l){}if(t.replaceSync)try{(o=r.replaceSync)==null||o.call(r,t.replaceSync)}catch(l){}}applyStyleDeclaration(t,r){t.set&&Je(r.rules,t.index).style.setProperty(t.set.property,t.set.value,t.set.priority),t.remove&&Je(r.rules,t.index).style.removeProperty(t.remove.property)}applyAdoptedStyleSheet(t){var r;const n=this.mirror.getNode(t.id);if(!n)return;(r=t.styles)==null||r.forEach(l=>{var p;let u=null,s=null;if(pt(n)?s=((p=n.ownerDocument)==null?void 0:p.defaultView)||null:n.nodeName==="#document"&&(s=n.defaultView),!!s)try{u=new s.CSSStyleSheet,this.styleMirror.add(u,l.styleId),this.applyStyleSheetRule({source:Y.StyleSheetRule,adds:l.rules},u)}catch(c){}});const i=10;let a=0;const o=(l,p)=>{const u=p.map(s=>this.styleMirror.getStyle(s)).filter(s=>s!==null);pt(l)?l.shadowRoot.adoptedStyleSheets=u:l.nodeName==="#document"&&(l.adoptedStyleSheets=u),u.length!==p.length&&a<i&&(setTimeout(()=>o(l,p),0+100*a),a++)};o(n,t.styleIds)}legacy_resolveMissingNode(t,r,n,i){const{previousId:a,nextId:o}=i,l=a&&t[a],p=o&&t[o];if(l){const{node:u,mutation:s}=l;r.insertBefore(u,n),delete t[s.node.id],delete this.legacy_missingNodeRetryMap[s.node.id],(s.previousId||s.nextId)&&this.legacy_resolveMissingNode(t,r,u,s)}if(p){const{node:u,mutation:s}=p;r.insertBefore(u,n.nextSibling),delete t[s.node.id],delete this.legacy_missingNodeRetryMap[s.node.id],(s.previousId||s.nextId)&&this.legacy_resolveMissingNode(t,r,u,s)}}moveAndHover(t,r,n,i,a){const o=this.mirror.getNode(n);if(!o)return this.debugNodeNotFound(a,n);const l=wo(o,this.iframe),p=t*l.absoluteScale+l.x,u=r*l.absoluteScale+l.y;this.mouse.style.left=`${p}px`,this.mouse.style.top=`${u}px`,i||this.drawMouseTail({x:p,y:u}),this.hoverElements(o)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:r,lineWidth:n,strokeStyle:i,duration:a}=this.config.mouseTail===!0?Gr:Object.assign({},Gr,this.config.mouseTail),o=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=n,l.lineCap=r,l.strokeStyle=i,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(p=>l.lineTo(p.x,p.y)),l.stroke())};this.tailPositions.push(t),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==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 n=t;for(;n;)n.classList&&n.classList.add(":hover"),n=n.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(G.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(hn,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(hn,...t)}}var pe=Uint8Array,Me=Uint16Array,ei=Uint32Array,xo=new pe([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]),Mo=new pe([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]),su=new pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_o=function(e,t){for(var r=new Me(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new ei(r[30]),n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)i[a]=a-r[n]<<5|n;return[r,i]},No=_o(xo,2),Oo=No[0],nu=No[1];Oo[28]=258,nu[258]=28;var ou=_o(Mo,0),au=ou[0],ti=new Me(32768);for(var K=0;K<32768;++K){var Ee=(K&43690)>>>1|(K&21845)<<1;Ee=(Ee&52428)>>>2|(Ee&13107)<<2,Ee=(Ee&61680)>>>4|(Ee&3855)<<4,ti[K]=((Ee&65280)>>>8|(Ee&255)<<8)>>>1}var Ze=function(e,t,r){for(var n=e.length,i=0,a=new Me(t);i<n;++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 l;if(r){l=new Me(1<<t);var p=15-t;for(i=0;i<n;++i)if(e[i])for(var u=i<<4|e[i],s=t-e[i],c=o[e[i]-1]++<<s,f=c|(1<<s)-1;c<=f;++c)l[ti[c]>>>p]=u}else for(l=new Me(n),i=0;i<n;++i)l[i]=ti[o[e[i]-1]++]>>>15-e[i];return l},ot=new pe(288);for(var K=0;K<144;++K)ot[K]=8;for(var K=144;K<256;++K)ot[K]=9;for(var K=256;K<280;++K)ot[K]=7;for(var K=280;K<288;++K)ot[K]=8;var Ao=new pe(32);for(var K=0;K<32;++K)Ao[K]=5;var lu=Ze(ot,9,1),uu=Ze(Ao,5,1),$r=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},de=function(e,t,r){var n=t/8>>0;return(e[n]|e[n+1]<<8)>>>(t&7)&r},Hr=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(t&7)},cu=function(e){return(e/8>>0)+(e&7&&1)},Do=function(e,t,r){(r==null||r>e.length)&&(r=e.length);var n=new(e instanceof Me?Me:e instanceof ei?ei:pe)(r-t);return n.set(e.subarray(t,r)),n},hu=function(e,t,r){var n=e.length,i=!t||r,a=!r||r.i;r||(r={}),t||(t=new pe(n*3));var o=function(N){var P=t.length;if(N>P){var V=new pe(Math.max(P*2,N));V.set(t),t=V}},l=r.f||0,p=r.p||0,u=r.b||0,s=r.l,c=r.d,f=r.m,h=r.n,d=n*8;do{if(!s){r.f=l=de(e,p,1);var m=de(e,p+1,3);if(p+=3,m)if(m==1)s=lu,c=uu,f=9,h=5;else if(m==2){var S=de(e,p,31)+257,E=de(e,p+10,15)+4,w=S+de(e,p+5,31)+1;p+=14;for(var v=new pe(w),C=new pe(19),R=0;R<E;++R)C[su[R]]=de(e,p+R*3,7);p+=E*3;var A=$r(C),M=(1<<A)-1;if(!a&&p+w*(A+7)>d)break;for(var B=Ze(C,A,1),R=0;R<w;){var k=B[de(e,p,M)];p+=k&15;var g=k>>>4;if(g<16)v[R++]=g;else{var J=0,U=0;for(g==16?(U=3+de(e,p,3),p+=2,J=v[R-1]):g==17?(U=3+de(e,p,7),p+=3):g==18&&(U=11+de(e,p,127),p+=7);U--;)v[R++]=J}}var x=v.subarray(0,S),q=v.subarray(S);f=$r(x),h=$r(q),s=Ze(x,f,1),c=Ze(q,h,1)}else throw"invalid block type";else{var g=cu(p)+4,b=e[g-4]|e[g-3]<<8,y=g+b;if(y>n){if(a)throw"unexpected EOF";break}i&&o(u+b),t.set(e.subarray(g,y),u),r.b=u+=b,r.p=p=y*8;continue}if(p>d)throw"unexpected EOF"}i&&o(u+131072);for(var I=(1<<f)-1,j=(1<<h)-1,H=f+h+18;a||p+H<d;){var J=s[Hr(e,p)&I],z=J>>>4;if(p+=J&15,p>d)throw"unexpected EOF";if(!J)throw"invalid length/literal";if(z<256)t[u++]=z;else if(z==256){s=null;break}else{var X=z-254;if(z>264){var R=z-257,ae=xo[R];X=de(e,p,(1<<ae)-1)+Oo[R],p+=ae}var _=c[Hr(e,p)&j],D=_>>>4;if(!_)throw"invalid distance";p+=_&15;var q=au[D];if(D>3){var ae=Mo[D];q+=Hr(e,p)&(1<<ae)-1,p+=ae}if(p>d)throw"unexpected EOF";i&&o(u+131072);for(var O=u+X;u<O;u+=4)t[u]=t[u-q],t[u+1]=t[u+1-q],t[u+2]=t[u+2-q],t[u+3]=t[u+3-q];u=O}}r.l=s,r.p=p,r.b=u,s&&(l=1,r.m=f,r.d=c,r.n=h)}while(!l);return u==t.length?t:Do(t,0,u)},fu=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 pu(e,t){return hu((fu(e),e.subarray(2,-4)),t)}function du(e,t){for(var r=e.length,n=new pe(e.length+(e.length>>>1)),i=0,a=function(u){n[i++]=u},o=0;o<r;++o){if(i+5>n.length){var l=new pe(i+8+(r-o<<1));l.set(n),n=l}var p=e.charCodeAt(o);p<128||t?a(p):p<2048?(a(192|p>>>6),a(128|p&63)):p>55295&&p<57344?(p=65536+(p&1047552)|e.charCodeAt(++o)&1023,a(240|p>>>18),a(128|p>>>12&63),a(128|p>>>6&63),a(128|p&63)):(a(224|p>>>12),a(128|p>>>6&63),a(128|p&63))}return Do(n,0,i)}function mu(e,t){var r="";if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);for(var n=0;n<e.length;){var i=e[n++];i<128||t?r+=String.fromCharCode(i):i<224?r+=String.fromCharCode((i&31)<<6|e[n++]&63):i<240?r+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63):(i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,r+=String.fromCharCode(55296|i>>10,56320|i&1023))}return r}const pn="v1",gu=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(mu(pu(du(e,!0))));if(t.v===pn)return t;throw new Error(`These events were packed with packer ${t.v} which is incompatible with current packer ${pn}.`)}catch(t){throw console.error(t),new Error("Unknown data format.")}};var _i=(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))(_i||{}),ri=(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))(ri||{});function dn(e){let t="";return Object.keys(e).forEach(r=>{t+=`${r}: ${e[r]};`}),t}function Ye(e,t=2){let r=String(e);const n=Math.pow(10,t-1);if(e<n)for(;String(n).length>r.length;)r=`0${e}`;return r}const Po=1e3,ii=60*Po,mn=60*ii;function gt(e){if(e<=0)return"00:00";const t=Math.floor(e/mn);e=e%mn;const r=Math.floor(e/ii);e=e%ii;const n=Math.floor(e/Po);return t?`${Ye(t)}:${Ye(r)}:${Ye(n)}`:`${Ye(r)}:${Ye(n)}`}function yu(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.resolve()}function wu(){return document.exitFullscreen?document.exitFullscreen():document.mozExitFullscreen?document.mozExitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.resolve()}function gn(){let e=!1;return["fullscreen","webkitIsFullScreen","mozFullScreen","msFullscreenElement"].forEach(t=>{t in document&&(e=e||!!document[t])}),e}function vu(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 yn(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 bu(e){return e.type!==_i.IncrementalSnapshot?!1:e.data.source>ri.Mutation&&e.data.source<=ri.Input}function Su(e,t){const r=[];let n=e[0].timestamp;for(const i of e)bu(i)&&(i.timestamp-n>t&&r.push([n,i.timestamp]),n=i.timestamp);return r}function Cu(e){let t,r,n,i,a,o,l,p,u;return{c(){t=oe("div"),r=oe("input"),n=fe(),i=oe("label"),a=fe(),o=oe("span"),l=De(e[3]),F(r,"type","checkbox"),F(r,"id",e[2]),r.disabled=e[1],F(r,"class","svelte-a6h7w7"),F(i,"for",e[2]),F(i,"class","svelte-a6h7w7"),F(o,"class","label svelte-a6h7w7"),F(t,"class","switch svelte-a6h7w7"),Ve(t,"disabled",e[1])},m(s,c){Ce(s,t,c),$(t,r),r.checked=e[0],$(t,n),$(t,i),$(t,a),$(t,o),$(o,l),p||(u=ze(r,"change",e[4]),p=!0)},p(s,[c]){c&4&&F(r,"id",s[2]),c&2&&(r.disabled=s[1]),c&1&&(r.checked=s[0]),c&4&&F(i,"for",s[2]),c&8&&vt(l,s[3]),c&2&&Ve(t,"disabled",s[1])},i:et,o:et,d(s){s&&ve(t),p=!1,u()}}}function Eu(e,t,r){let{disabled:n}=t,{checked:i}=t,{id:a}=t,{label:o}=t;function l(){i=this.checked,r(0,i)}return e.$$set=p=>{"disabled"in p&&r(1,n=p.disabled),"checked"in p&&r(0,i=p.checked),"id"in p&&r(2,a=p.id),"label"in p&&r(3,o=p.label)},[i,n,a,o,l]}class Ru extends li{constructor(t){super(),ai(this,t,Eu,Cu,si,{disabled:1,checked:0,id:2,label:3})}}function wn(e,t,r){const n=e.slice();return n[38]=t[r],n}function vn(e,t,r){const n=e.slice();return n[41]=t[r],n}function bn(e,t,r){const n=e.slice();return n[44]=t[r],n}function Sn(e){let t,r,n,i=gt(e[6])+"",a,o,l,p,u,s,c,f,h,d,m=gt(e[8].totalTime)+"",g,b,y,S,E,w,v,C,R,A,M,B,k,J=Ie(e[13]),U=[];for(let D=0;D<J.length;D+=1)U[D]=Cn(bn(e,J,D));let x=Ie(e[9]),q=[];for(let D=0;D<x.length;D+=1)q[D]=En(vn(e,x,D));function I(D,O){return D[7]==="playing"?Mu:xu}let j=I(e),H=j(e),z=Ie(e[3]),X=[];for(let D=0;D<z.length;D+=1)X[D]=Rn(wn(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]),v=new Ru({props:_}),Ae.push(()=>Ko(v,"checked",ae)),{c(){t=oe("div"),r=oe("div"),n=oe("span"),a=De(i),o=fe(),l=oe("div"),p=oe("div"),u=fe();for(let D=0;D<U.length;D+=1)U[D].c();s=fe();for(let D=0;D<q.length;D+=1)q[D].c();c=fe(),f=oe("div"),h=fe(),d=oe("span"),g=De(m),b=fe(),y=oe("div"),S=oe("button"),H.c(),E=fe();for(let D=0;D<X.length;D+=1)X[D].c();w=fe(),In(v.$$.fragment),R=fe(),A=oe("button"),A.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
159
+ ***************************************************************************** */function rn(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n,i,a=r.call(e),o=[];try{for(;(t===void 0||t-- >0)&&!(n=a.next()).done;)o.push(n.value)}catch(l){i={error:l}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}return o}var qe;(function(e){e[e.NotStarted=0]="NotStarted",e[e.Running=1]="Running",e[e.Stopped=2]="Stopped"})(qe||(qe={}));var bo={type:"xstate.init"};function jr(e){return e===void 0?[]:[].concat(e)}function Ue(e){return{type:"xstate.assign",assignment:e}}function sn(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 Et(e){return function(t){return e===t}}function So(e){return typeof e=="string"?{type:e}:e}function nn(e,t){return{value:e,context:t,actions:[],changed:!1,matches:Et(e)}}function on(e,t,r){var n=t,i=!1;return[e.filter(function(a){if(a.type==="xstate.assign"){i=!0;var o=Object.assign({},n);return typeof a.assignment=="function"?o=a.assignment(n,r):Object.keys(a.assignment).forEach(function(l){o[l]=typeof a.assignment[l]=="function"?a.assignment[l](n,r):a.assignment[l]}),n=o,!1}return!0}),n,i]}function Co(e,t){t===void 0&&(t={});var r=rn(on(jr(e.states[e.initial].entry).map(function(o){return sn(o,t.actions)}),e.context,bo),2),n=r[0],i=r[1],a={config:e,_options:t,initialState:{value:e.initial,actions:n,context:i,matches:Et(e.initial)},transition:function(o,l){var p,u,s=typeof o=="string"?{value:o,context:e.context}:o,c=s.value,f=s.context,h=So(l),d=e.states[c];if(d.on){var m=jr(d.on[h.type]);try{for(var g=function(I){var j=typeof Symbol=="function"&&Symbol.iterator,H=j&&I[j],z=0;if(H)return H.call(I);if(I&&typeof I.length=="number")return{next:function(){return I&&z>=I.length&&(I=void 0),{value:I&&I[z++],done:!I}}};throw new TypeError(j?"Object is not iterable.":"Symbol.iterator is not defined.")}(m),b=g.next();!b.done;b=g.next()){var y=b.value;if(y===void 0)return nn(c,f);var S=typeof y=="string"?{target:y}:y,E=S.target,w=S.actions,v=w===void 0?[]:w,C=S.cond,R=C===void 0?function(){return!0}:C,A=E===void 0,M=E!=null?E:c,B=e.states[M];if(R(f,h)){var k=rn(on((A?jr(v):[].concat(d.exit,v,B.entry).filter(function(I){return I})).map(function(I){return sn(I,a._options.actions)}),f,h),3),J=k[0],U=k[1],x=k[2],q=E!=null?E:c;return{value:q,context:U,actions:J,changed:E!==c||J.length>0||x,matches:Et(q)}}}}catch(I){p={error:I}}finally{try{b&&!b.done&&(u=g.return)&&u.call(g)}finally{if(p)throw p.error}}}return nn(c,f)}};return a}var an=function(e,t){return e.actions.forEach(function(r){var n=r.exec;return n&&n(e.context,t)})};function Eo(e){var t=e.initialState,r=qe.NotStarted,n=new Set,i={_machine:e,send:function(a){r===qe.Running&&(t=e.transition(t,a),an(t,So(a)),n.forEach(function(o){return o(t)}))},subscribe:function(a){return n.add(a),a(t),{unsubscribe:function(){return n.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:Et(o.value)}}return r=qe.Running,an(t,bo),i},stop:function(){return r=qe.Stopped,n.clear(),i},get state(){return t},get status(){return r}};return i}function jl(e,t){for(let r=e.length-1;r>=0;r--){const n=e[r];if(n.type===te.Meta&&n.timestamp<=t)return e.slice(r)}return e}function Gl(e,{getCastFn:t,applyEventsSynchronously:r,emitter:n}){const i=Co({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:Ue({lastPlayedEvent:(a,o)=>o.type==="CAST_EVENT"?o.payload.event:a.lastPlayedEvent}),recordTimeOffset:Ue((a,o)=>{let l=a.timeOffset;return"payload"in o&&"timeOffset"in o.payload&&(l=o.payload.timeOffset),le(Q({},a),{timeOffset:l,baselineTime:a.events[0].timestamp+l})}),play(a){var o;const{timer:l,events:p,baselineTime:u,lastPlayedEvent:s}=a;l.clear();for(const d of p)tn(d,u);const c=jl(p,u);let f=s==null?void 0:s.timestamp;(s==null?void 0:s.type)===te.IncrementalSnapshot&&s.data.source===Y.MouseMove&&(f=s.timestamp+((o=s.data.positions[0])==null?void 0:o.timeOffset)),u<(f||0)&&n.emit(G.PlayBack);const h=new Array;for(const d of c)if(!(f&&f<u&&(d.timestamp<=f||d===s)))if(d.timestamp<u)h.push(d);else{const m=t(d,!1);l.addAction({doAction:()=>{m()},delay:d.delay})}r(h),n.emit(G.Flush),l.start()},pause(a){a.timer.clear()},resetLastPlayedEvent:Ue(a=>le(Q({},a),{lastPlayedEvent:null})),startLive:Ue({baselineTime:(a,o)=>(a.timer.start(),o.type==="TO_LIVE"&&o.payload.baselineTime?o.payload.baselineTime:Date.now())}),addEvent:Ue((a,o)=>{const{baselineTime:l,timer:p,events:u}=a;if(o.type==="ADD_EVENT"){const{event:s}=o.payload;tn(s,l);let c=u.length-1;if(!u[c]||u[c].timestamp<=s.timestamp)u.push(s);else{let d=-1,m=0;for(;m<=c;){const g=Math.floor((m+c)/2);u[g].timestamp<=s.timestamp?m=g+1:c=g-1}d===-1&&(d=m),u.splice(d,0,s)}const f=s.timestamp<l,h=t(s,f);f?h():p.isActive()&&p.addAction({doAction:()=>{h()},delay:s.delay})}return le(Q({},a),{events:u})})}});return Eo(i)}function $l(e){const t=Co({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,n)=>{"payload"in n&&r.timer.setSpeed(n.payload.speed)},recordSpeed:Ue({normalSpeed:r=>r.timer.speed}),restoreSpeed:r=>{r.timer.setSpeed(r.normalSpeed)}}});return Eo(t)}const Hl=e=>[`.${e} { background: currentColor }`,"noscript { display: none !important; }"],ln=new Map;function Ro(e,t){let r=ln.get(e);return r||(r=new Map,ln.set(e,r)),r.has(t)||r.set(t,[]),r.get(t)}function xe(e,t,r){return async n=>{if(n&&typeof n=="object"&&"rr_type"in n)if(r&&(r.isUnchanged=!1),n.rr_type==="ImageBitmap"&&"args"in n){const i=await xe(e,t,r)(n.args);return await createImageBitmap.apply(null,i)}else if("index"in n){if(r||t===null)return n;const{rr_type:i,index:a}=n;return Ro(t,i)[a]}else if("args"in n){const{rr_type:i,args:a}=n,o=window[i];return new o(...await Promise.all(a.map(xe(e,t,r))))}else{if("base64"in n)return Ul(n.base64);if("src"in n){const i=e.get(n.src);if(i)return i;{const a=new Image;return a.src=n.src,e.set(n.src,a),a}}else if("data"in n&&n.rr_type==="Blob"){const i=await Promise.all(n.data.map(xe(e,t,r)));return new Blob(i,{type:n.type})}}else if(Array.isArray(n))return await Promise.all(n.map(xe(e,t,r)));return n}}function Yl(e,t){try{return t===Ct.WebGL?e.getContext("webgl")||e.getContext("experimental-webgl"):e.getContext("webgl2")}catch(r){return null}}const Jl=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject"];function Xl(e,t){if(!(t!=null&&t.constructor))return;const{name:r}=t.constructor;if(!Jl.includes(r))return;const n=Ro(e,r);n.includes(t)||n.push(t)}async function Ql({mutation:e,target:t,type:r,imageMap:n,errorHandler:i}){try{const a=Yl(t,r);if(!a)return;if(e.setter){a[e.property]=e.args[0];return}const o=a[e.property],l=await Promise.all(e.args.map(xe(n,a))),p=o.apply(a,l);Xl(a,p);const u=!1}catch(a){i(e,a)}}async function Kl({event:e,mutations:t,target:r,imageMap:n,errorHandler:i}){const a=r.getContext("2d");if(!a){i(t[0],new Error("Canvas context is null"));return}const o=t.map(async p=>Promise.all(p.args.map(xe(n,a))));(await Promise.all(o)).forEach((p,u)=>{const s=t[u];try{if(s.setter){a[s.property]=s.args[0];return}const c=a[s.property];s.property==="drawImage"&&typeof s.args[0]=="string"?(n.get(e),c.apply(a,s.args)):c.apply(a,p)}catch(c){i(s,c)}})}async function un({event:e,mutation:t,target:r,imageMap:n,canvasEventMap:i,errorHandler:a}){try{const o=i.get(e)||t,l="commands"in o?o.commands:[o];if([Ct.WebGL,Ct.WebGL2].includes(t.type)){for(let p=0;p<l.length;p++){const u=l[p];await Ql({mutation:u,type:t.type,target:r,imageMap:n,errorHandler:a})}return}await Kl({event:e,mutations:l,target:r,imageMap:n,errorHandler:a})}catch(o){a(t,o)}}const cn=["AUDIO","VIDEO"];class Zl{constructor(t){L(this,"mediaMap",new Map),L(this,"warn"),L(this,"service"),L(this,"speedService"),L(this,"emitter"),L(this,"getCurrentTime"),L(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(G.Start,this.start.bind(this)),this.emitter.on(G.SkipStart,this.start.bind(this)),this.emitter.on(G.Pause,this.pause.bind(this)),this.emitter.on(G.Finish,this.pause.bind(this)),this.speedService.subscribe(()=>{this.syncAllMediaElements()})}syncAllMediaElements(t={pause:!1}){this.mediaMap.forEach((r,n)=>{this.syncTargetWithState(n),t.pause&&n.pause()})}start(){this.syncAllMediaElements()}pause(){this.syncAllMediaElements({pause:!0})}seekTo({time:t,target:r,mediaState:n}){if(n.isPlaying){const a=(t-n.lastInteractionTimeOffset)/1e3*n.playbackRate,o="duration"in r&&r.duration;if(Number.isNaN(o)){this.waitForMetadata(r);return}let l=n.currentTimeAtLastInteraction+a;r.loop&&o!==!1&&(l=l%o),r.currentTime=l}else r.pause(),r.currentTime=n.currentTimeAtLastInteraction}waitForMetadata(t){if(this.metadataCallbackMap.has(t)||!("addEventListener"in t))return;const r=()=>{this.metadataCallbackMap.delete(t);const n=this.mediaMap.get(t);n&&this.seekTo({time:this.getCurrentTime(),target:t,mediaState:n})};this.metadataCallbackMap.set(t,r),t.addEventListener("loadedmetadata",r,{once:!0})}getMediaStateFromMutation({target:t,timeOffset:r,mutation:n}){var h,d,m,g,b;const i=this.mediaMap.get(t),{type:a,playbackRate:o,currentTime:l,muted:p,volume:u,loop:s}=n;return{isPlaying:a===Zr.Play||a!==Zr.Pause&&((i==null?void 0:i.isPlaying)||t.getAttribute("autoplay")!==null),currentTimeAtLastInteraction:(h=l!=null?l:i==null?void 0:i.currentTimeAtLastInteraction)!=null?h:0,lastInteractionTimeOffset:r,playbackRate:(d=o!=null?o:i==null?void 0:i.playbackRate)!=null?d:1,volume:(m=u!=null?u:i==null?void 0:i.volume)!=null?m:1,muted:(g=p!=null?p:i==null?void 0:i.muted)!=null?g:t.getAttribute("muted")===null,loop:(b=s!=null?s:i==null?void 0:i.loop)!=null?b:t.getAttribute("loop")===null}}syncTargetWithState(t){const r=this.mediaMap.get(t);if(!r)return;const{muted:n,loop:i,volume:a,isPlaying:o}=r,l=this.service.state.matches("paused"),p=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=n,t.loop=i,t.playbackRate!==p&&(t.playbackRate=p),o&&!l?t.play():t.pause()}catch(u){this.warn(`Failed to replay media interactions: ${u.message||u}`)}}addMediaElements(t,r,n){if(!this.isSupportedMediaElement(t))return;const i=t,a=n.getMeta(i);if(!a||!("attributes"in a))return;const o=this.service.state.matches("paused"),l=a.attributes;let p=!1;l.rr_mediaState?p=l.rr_mediaState==="played":p=i.getAttribute("autoplay")!==null,p&&o&&i.pause();let u=1;typeof l.rr_mediaPlaybackRate=="number"&&(u=l.rr_mediaPlaybackRate);let s=!1;typeof l.rr_mediaMuted=="boolean"?s=l.rr_mediaMuted:s=i.getAttribute("muted")!==null;let c=!1;typeof l.rr_mediaLoop=="boolean"?c=l.rr_mediaLoop:c=i.getAttribute("loop")!==null;let f=1;typeof l.rr_mediaVolume=="number"&&(f=l.rr_mediaVolume);let h=0;typeof l.rr_mediaCurrentTime=="number"&&(h=l.rr_mediaCurrentTime),this.mediaMap.set(i,{isPlaying:p,currentTimeAtLastInteraction:h,lastInteractionTimeOffset:r,playbackRate:u,volume:f,muted:s,loop:c}),this.syncTargetWithState(i)}mediaMutation({target:t,timeOffset:r,mutation:n}){cn.includes(t.nodeName)&&(this.mediaMap.set(t,this.getMediaStateFromMutation({target:t,timeOffset:r,mutation:n})),this.syncTargetWithState(t))}isSupportedMediaElement(t){return cn.includes(t.nodeName)}reset(){this.mediaMap.clear()}}function mt(e,t){if(e.nodeName!=="DIALOG"||e instanceof ye)return;const r=e,n=r.open,i=n&&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",l=a==="modal";if(!(n&&!(i&&a==="non-modal"||!i&&l))){if(!r.isConnected){console.warn("dialog is not attached to the dom",r);return}n&&r.close(),o&&(l?r.showModal():r.show())}}function eu(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 tu=5*1e3,ru=vo||ql,hn="[replayer]",Gr={duration:500,lineCap:"round",lineWidth:3,strokeStyle:"red"};function fn(e){return e.type==te.IncrementalSnapshot&&(e.data.source==Y.TouchMove||e.data.source==Y.MouseInteraction&&e.data.type==ne.TouchStart)}class iu{constructor(t,r){if(L(this,"wrapper"),L(this,"iframe"),L(this,"service"),L(this,"speedService"),L(this,"config"),L(this,"usingVirtualDom",!1),L(this,"virtualDom",new $e),L(this,"mouse"),L(this,"mouseTail",null),L(this,"tailPositions",[]),L(this,"emitter",ru()),L(this,"nextUserInteractionEvent"),L(this,"legacy_missingNodeRetryMap",{}),L(this,"cache",gs()),L(this,"imageMap",new Map),L(this,"canvasEventMap",new Map),L(this,"mirror",Fn()),L(this,"styleMirror",new Bl),L(this,"mediaManager"),L(this,"firstFullSnapshot",null),L(this,"newDocumentQueue",[]),L(this,"mousePos",null),L(this,"touchActive",null),L(this,"lastMouseDownEvent",null),L(this,"lastHoveredRootNode"),L(this,"lastSelectionData",null),L(this,"constructedStyleMutations",[]),L(this,"adoptedStyleSheets",[]),L(this,"handleResize",l=>{this.iframe.style.display="inherit";for(const p of[this.mouseTail,this.iframe])p&&(p.setAttribute("width",String(l.width)),p.setAttribute("height",String(l.height)))}),L(this,"applyEventsSynchronously",l=>{for(const p of l){switch(p.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(p,!0)()}}),L(this,"getCastFn",(l,p=!1)=>{let u;switch(l.type){case te.DomContentLoaded:case te.Load:break;case te.Custom:u=()=>{this.emitter.emit(G.CustomEvent,l)};break;case te.Meta:u=()=>this.emitter.emit(G.Resize,{width:l.data.width,height:l.data.height});break;case te.FullSnapshot:u=()=>{var c;if(this.firstFullSnapshot){if(this.firstFullSnapshot===l){this.firstFullSnapshot=!0;return}}else this.firstFullSnapshot=!0;this.mediaManager.reset(),this.styleMirror.reset(),this.rebuildFullSnapshot(l,p),(c=this.iframe.contentWindow)==null||c.scrollTo(l.data.initialOffset)};break;case te.IncrementalSnapshot:u=()=>{if(this.applyIncremental(l,p),!p&&(l===this.nextUserInteractionEvent&&(this.nextUserInteractionEvent=null,this.backToNormal()),this.config.skipInactive&&!this.nextUserInteractionEvent)){for(const c of this.service.state.context.events)if(!(c.timestamp<=l.timestamp)&&this.isUserInteraction(c)){c.delay-l.delay>this.config.inactivePeriodThreshold*this.speedService.state.context.timer.speed&&(this.nextUserInteractionEvent=c);break}if(this.nextUserInteractionEvent){const c=this.nextUserInteractionEvent.delay-l.delay,f={speed:Math.min(Math.round(c/tu),this.config.maxSpeed)};this.speedService.send({type:"FAST_FORWARD",payload:f}),this.emitter.emit(G.SkipStart,f)}}};break}return()=>{u&&u();for(const f of this.config.plugins||[])f.handler&&f.handler(l,p,{replayer:this});this.service.send({type:"CAST_EVENT",payload:{event:l}});const c=this.service.state.context.events.length-1;if(!this.config.liveMode&&l===this.service.state.context.events[c]){const f=()=>{c<this.service.state.context.events.length-1||(this.backToNormal(),this.service.send("END"),this.emitter.emit(G.Finish))};let h=50;l.type===te.IncrementalSnapshot&&l.data.source===Y.MouseMove&&l.data.positions.length&&(h+=Math.max(0,-l.data.positions[0].timeOffset)),setTimeout(f,h)}this.emitter.emit(G.EventCast,l)}}),!(r!=null&&r.liveMode)&&t.length<2)throw new Error("Replayer need at least 2 events.");const n={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:Gr,useVirtualDom:!0,logger:console};this.config=Object.assign({},n,r),this.handleResize=this.handleResize.bind(this),this.getCastFn=this.getCastFn.bind(this),this.applyEventsSynchronously=this.applyEventsSynchronously.bind(this),this.emitter.on(G.Resize,this.handleResize),this.setupDom();for(const l of this.config.plugins||[])l.getMirror&&l.getMirror({nodeMirror:this.mirror});this.emitter.on(G.Flush,()=>{if(this.usingVirtualDom){const l={mirror:this.mirror,applyCanvas:(p,u,s)=>{un({event:p,mutation:u,target:s,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})},applyInput:this.applyInput.bind(this),applyScroll:this.applyScroll.bind(this),applyStyleSheetMutation:(p,u)=>{p.source===Y.StyleSheetRule?this.applyStyleSheetRule(p,u):p.source===Y.StyleDeclaration&&this.applyStyleDeclaration(p,u)},afterAppend:(p,u)=>{for(const s of this.config.plugins||[])s.onBuild&&s.onBuild(p,{id:u,replayer:this})}};if(this.iframe.contentDocument)try{bt(this.iframe.contentDocument,this.virtualDom,l,this.virtualDom.mirror)}catch(p){this.warn(p)}if(this.virtualDom.destroyTree(),this.usingVirtualDom=!1,Object.keys(this.legacy_missingNodeRetryMap).length)for(const p in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[p],s=St(u.node,this.mirror,this.virtualDom.mirror);bt(s,u.node,l,this.virtualDom.mirror),u.node=s}catch(u){this.warn(u)}this.constructedStyleMutations.forEach(p=>{this.applyStyleSheetMutation(p)}),this.constructedStyleMutations=[],this.adoptedStyleSheets.forEach(p=>{this.applyAdoptedStyleSheet(p)}),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,p]=this.lastMouseDownEvent;l.dispatchEvent(p)}this.lastMouseDownEvent=null,this.lastSelectionData&&(this.applySelection(this.lastSelectionData),this.lastSelectionData=null)}),this.emitter.on(G.PlayBack,()=>{this.firstFullSnapshot=null,this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset()});const i=new Vl([],{speed:this.config.speed});this.service=Gl({events:t.map(l=>r&&r.unpackFn?r.unpackFn(l):l).sort((l,p)=>l.timestamp-p.timestamp),timer:i,timeOffset:0,baselineTime:0,lastPlayedEvent:null},{getCastFn:this.getCastFn,applyEventsSynchronously:this.applyEventsSynchronously,emitter:this.emitter}),this.service.start(),this.service.subscribe(l=>{this.emitter.emit(G.StateChange,{player:l})}),this.speedService=$l({normalSpeed:-1,timer:i}),this.speedService.start(),this.speedService.subscribe(l=>{this.emitter.emit(G.StateChange,{speed:l})}),this.mediaManager=new Zl({warn:this.warn.bind(this),service:this.service,speedService:this.speedService,emitter:this.emitter,getCurrentTime:this.getCurrentTime.bind(this)});const a=this.service.state.context.events.find(l=>l.type===te.Meta),o=this.service.state.context.events.find(l=>l.type===te.FullSnapshot);if(a){const{width:l,height:p}=a.data;setTimeout(()=>{this.emitter.emit(G.Resize,{width:l,height:p})},0)}o&&setTimeout(()=>{var l;this.firstFullSnapshot||(this.firstFullSnapshot=o,this.rebuildFullSnapshot(o),(l=this.iframe.contentWindow)==null||l.scrollTo(o.data.initialOffset))},1),this.service.state.context.events.find(fn)&&this.mouse.classList.add("touch-device")}get timer(){return this.service.state.context.timer}on(t,r){return this.emitter.on(t,r),this}off(t,r){return this.emitter.off(t,r),this}setConfig(t){Object.keys(t).forEach(r=>{t[r],this.config[r]=t[r]}),this.config.skipInactive||this.backToNormal(),typeof t.speed!="undefined"&&this.speedService.send({type:"SET_SPEED",payload:{speed:t.speed}}),typeof t.mouseTail!="undefined"&&(t.mouseTail===!1?this.mouseTail&&(this.mouseTail.style.display="none"):(this.mouseTail||(this.mouseTail=document.createElement("canvas"),this.mouseTail.width=Number.parseFloat(this.iframe.width),this.mouseTail.height=Number.parseFloat(this.iframe.height),this.mouseTail.classList.add("replayer-mouse-tail"),this.wrapper.insertBefore(this.mouseTail,this.iframe)),this.mouseTail.style.display="inherit"))}getMetaData(){const t=this.service.state.context.events[0],r=this.service.state.context.events[this.service.state.context.events.length-1];return{startTime:t.timestamp,endTime:r.timestamp,totalTime:r.timestamp-t.timestamp}}getCurrentTime(){return this.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,n;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}})),(n=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||n.classList.remove("rrweb-paused"),this.emitter.emit(G.Start)}pause(t){var r,n;t===void 0&&this.service.state.matches("playing")&&this.service.send({type:"PAUSE"}),typeof t=="number"&&(this.play(t),this.service.send({type:"PAUSE"})),(n=(r=this.iframe.contentDocument)==null?void 0:r.getElementsByTagName("html")[0])==null||n.classList.add("rrweb-paused"),this.emitter.emit(G.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(G.Resume)}destroy(){this.pause(),this.mirror.reset(),this.styleMirror.reset(),this.mediaManager.reset(),this.config.root.removeChild(this.wrapper),this.emitter.emit(G.Destroy)}startLive(t){this.service.send({type:"TO_LIVE",payload:{baselineTime:t}})}addEvent(t){const r=this.config.unpackFn?this.config.unpackFn(t):t;fn(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=gs()}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&&(Wl(this.iframe.contentWindow,this.iframe.contentDocument),Il(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 n=[],i=new Set,a=(p,u)=>{if(p.nodeName==="DIALOG"&&i.add(p),this.collectIframeAndAttachDocument(n,p),this.mediaManager.isSupportedMediaElement(p)){const{events:s}=this.service.state.context;this.mediaManager.addMediaElements(p,t.timestamp-s[0].timestamp,this.mirror)}for(const s of this.config.plugins||[])s.onBuild&&s.onBuild(p,{id:u,replayer:this})};this.usingVirtualDom&&(this.virtualDom.destroyTree(),this.usingVirtualDom=!1),this.mirror.reset(),Aa(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:p,builtNode:u}of n)this.attachDocumentToIframe(p,u),this.newDocumentQueue=this.newDocumentQueue.filter(s=>s!==p);const{documentElement:o,head:l}=this.iframe.contentDocument;this.insertStyleRules(o,l),i.forEach(p=>mt(p)),this.service.state.matches("playing")||this.iframe.contentDocument.getElementsByTagName("html")[0].classList.add("rrweb-paused"),this.emitter.emit(G.FullsnapshotRebuilded,t),r||this.waitForStylesheetLoad(),this.config.UNSAFE_replayCanvas&&this.preloadAllImages()}insertStyleRules(t,r){var n;const i=Hl(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,mo(a,this.virtualDom.unserializedId)),t.insertBefore(a,r),a.rules.push({source:Y.StyleSheetRule,adds:i.map((o,l)=>({rule:o,index:l}))})}else{const a=document.createElement("style");t.insertBefore(a,r);for(let o=0;o<i.length;o++)(n=a.sheet)==null||n.insertRule(i[o],o)}}attachDocumentToIframe(t,r){const n=this.usingVirtualDom?this.virtualDom.mirror:this.mirror,i=[],a=new Set,o=(l,p)=>{l.nodeName==="DIALOG"&&a.add(l),this.collectIframeAndAttachDocument(i,l);const u=n.getMeta(l);if((u==null?void 0:u.type)===Re.Element&&(u==null?void 0:u.tagName.toUpperCase())==="HTML"){const{documentElement:s,head:c}=r.contentDocument;this.insertStyleRules(s,c)}if(!this.usingVirtualDom)for(const s of this.config.plugins||[])s.onBuild&&s.onBuild(l,{id:p,replayer:this})};Ke(t.node,{doc:r.contentDocument,mirror:n,hackCss:!0,skipChild:!1,afterAppend:o,cache:this.cache}),o(r.contentDocument,t.node.id);for(const{mutationInQueue:l,builtNode:p}of i)this.attachDocumentToIframe(l,p),this.newDocumentQueue=this.newDocumentQueue.filter(u=>u!==l);a.forEach(l=>mt(l))}collectIframeAndAttachDocument(t,r){if(Vr(r,this.mirror)){const n=this.newDocumentQueue.find(i=>i.parentId===this.mirror.getId(r));n&&t.push({mutationInQueue:n,builtNode:r})}}waitForStylesheetLoad(){var t;const r=(t=this.iframe.contentDocument)==null?void 0:t.head;if(r){const n=new Set;let i,a=this.service.state;const o=()=>{a=this.service.state};this.emitter.on(G.Start,o),this.emitter.on(G.Pause,o);const l=()=>{this.emitter.off(G.Start,o),this.emitter.off(G.Pause,o)};r.querySelectorAll('link[rel="stylesheet"]').forEach(p=>{p.sheet||(n.add(p),p.addEventListener("load",()=>{n.delete(p),n.size===0&&i!==-1&&(a.matches("playing")&&this.play(this.getCurrentTime()),this.emitter.emit(G.LoadStylesheetEnd),i&&clearTimeout(i),l())}))}),n.size>0&&(this.service.send({type:"PAUSE"}),this.emitter.emit(G.LoadStylesheetStart),i=setTimeout(()=>{a.matches("playing")&&this.play(this.getCurrentTime()),i=-1,l()},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 n=document.createElement("canvas"),i=n.getContext("2d"),a=i==null?void 0:i.createImageData(n.width,n.height);i==null||i.putImageData(a,0,0)}}async deserializeAndPreloadCanvasEvents(t,r){if(!this.canvasEventMap.has(r)){const n={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,n)));return le(Q({},a),{args:o})}));n.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{commands:i}))}else{const i=await Promise.all(t.args.map(xe(this.imageMap,null,n)));n.isUnchanged===!1&&this.canvasEventMap.set(r,le(Q({},t),{args:i}))}}}applyIncremental(t,r){var n,i,a;const{data:o}=t;switch(o.source){case Y.Mutation:{try{this.applyMutation(o,r)}catch(l){this.warn(`Exception in mutation ${l.message||l}`,o)}break}case Y.Drag:case Y.TouchMove:case Y.MouseMove:if(r){const l=o.positions[o.positions.length-1];this.mousePos={x:l.x,y:l.y,id:l.id,debugData:o}}else o.positions.forEach(l=>{const p={doAction:()=>{this.moveAndHover(l.x,l.y,l.id,r,o)},delay:l.timeOffset+t.timestamp-this.service.state.context.baselineTime};this.timer.addAction(p)}),this.timer.addAction({doAction(){},delay:t.delay-((n=o.positions[0])==null?void 0:n.timeOffset)});break;case Y.MouseInteraction:{if(o.id===-1)break;const l=new Event(oa(ne[o.type])),p=this.mirror.getNode(o.id);if(!p)return this.debugNodeNotFound(o,o.id);this.emitter.emit(G.MouseInteraction,{type:o.type,target:p});const{triggerFocus:u}=this.config;switch(o.type){case ne.Blur:"blur"in p&&p.blur();break;case ne.Focus:u&&p.focus&&p.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=[p,l]: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"):p.dispatchEvent(l));break;case ne.TouchCancel:r?this.touchActive=!1:this.mouse.classList.remove("touch-active");break;default:p.dispatchEvent(l)}break}case Y.Scroll:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.scrollData=o;break}this.applyScroll(o,r);break}case Y.ViewportResize:this.emitter.emit(G.Resize,{width:o.width,height:o.height});break;case Y.Input:{if(o.id===-1)break;if(this.usingVirtualDom){const l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.inputData=o;break}this.applyInput(o);break}case Y.MediaInteraction:{const l=this.usingVirtualDom?this.virtualDom.mirror.getNode(o.id):this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);const p=l,{events:u}=this.service.state.context;this.mediaManager.mediaMutation({target:p,timeOffset:t.timestamp-u[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 l=this.virtualDom.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);l.canvasMutations.push({event:t,mutation:o})}else{const l=this.mirror.getNode(o.id);if(!l)return this.debugNodeNotFound(o,o.id);un({event:t,mutation:o,target:l,imageMap:this.imageMap,canvasEventMap:this.canvasEventMap,errorHandler:this.warnCanvasMutationFailed.bind(this)})}break}case Y.Font:{try{const l=new FontFace(o.family,o.buffer?new Uint8Array(JSON.parse(o.fontSource)):o.fontSource,o.descriptors);(a=this.iframe.contentDocument)==null||a.fonts.add(l)}catch(l){this.warn(l)}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,yl(this.iframe.contentDocument,this.mirror,this.virtualDom),Object.keys(this.legacy_missingNodeRetryMap).length))for(const p in this.legacy_missingNodeRetryMap)try{const u=this.legacy_missingNodeRetryMap[p],s=po(u.node,this.virtualDom,this.mirror);s&&(u.node=s)}catch(u){this.warn(u)}const n=this.usingVirtualDom?this.virtualDom.mirror:this.mirror;t.removes=t.removes.filter(p=>n.getNode(p.id)?!0:(this.warnNodeNotFound(t,p.id),!1)),t.removes.forEach(p=>{var u;const s=n.getNode(p.id);if(!s)return;let c=n.getNode(p.parentId);if(!c)return this.warnNodeNotFound(t,p.parentId);if(p.isShadow&&pt(c)&&(c=c.shadowRoot),n.removeNodeFromMap(s),c)try{c.removeChild(s),this.usingVirtualDom&&s.nodeName==="#text"&&c.nodeName==="STYLE"&&((u=c.rules)==null?void 0:u.length)>0&&(c.rules=[])}catch(f){if(f instanceof DOMException)this.warn("parent could not remove child in mutation",c,s,t);else throw f}});const i=Q({},this.legacy_missingNodeRetryMap),a=[],o=p=>{var u,s;if(!this.iframe.contentDocument)return this.warn("Looks like your replayer has been destroyed.");let c=n.getNode(p.parentId);if(!c)return p.node.type===Re.Document?this.newDocumentQueue.push(p):t.adds.some(S=>S.node.id===p.parentId)?a.push(p):void 0;p.node.isShadow&&(pt(c)||c.attachShadow({mode:"open"}),c=c.shadowRoot);let f=null,h=null;if(p.previousId&&(f=n.getNode(p.previousId)),p.nextId&&(h=n.getNode(p.nextId)),p.node.rootId&&!n.getNode(p.node.rootId))return;const d=p.node.rootId?n.getNode(p.node.rootId):this.usingVirtualDom?this.virtualDom:this.iframe.contentDocument;if(Vr(c,n)){this.attachDocumentToIframe(p,c);return}const m=(y,S)=>{if(!this.usingVirtualDom){mt(y);for(const E of this.config.plugins||[])E.onBuild&&E.onBuild(y,{id:S,replayer:this})}},g=Ke(p.node,{doc:d,mirror:n,skipChild:!0,hackCss:!0,cache:this.cache,afterAppend:m});if(p.previousId===-1||p.nextId===-1){i[p.node.id]={node:g,mutation:p};return}const b=n.getMeta(c);if(b&&b.type===Re.Element&&p.node.type===Re.Text){const y=Array.isArray(c.childNodes)?c.childNodes:Array.from(c.childNodes);if(b.tagName==="textarea")for(const S of y)S.nodeType===c.TEXT_NODE&&c.removeChild(S);else if(b.tagName==="style"&&y.length===1)for(const S of y)S.nodeType===c.TEXT_NODE&&!n.hasNode(S)&&(g.textContent=S.textContent,c.removeChild(S))}else if((b==null?void 0:b.type)===Re.Document){const y=c;p.node.type===Re.DocumentType&&((u=y.childNodes[0])==null?void 0:u.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,p.node.id),this.usingVirtualDom&&g.nodeName==="#text"&&c.nodeName==="STYLE"&&((s=c.rules)==null?void 0:s.length)>0&&(c.rules=[]),Vr(g,this.mirror)){const y=this.mirror.getId(g),S=this.newDocumentQueue.find(E=>E.parentId===y);S&&(this.attachDocumentToIframe(S,g),this.newDocumentQueue=this.newDocumentQueue.filter(E=>E!==S))}(p.previousId||p.nextId)&&this.legacy_resolveMissingNode(i,c,g,p)};t.adds.forEach(p=>{o(p)});const l=performance.now();for(;a.length;){const p=Ll(a);if(a.length=0,performance.now()-l>150){this.warn("Timeout in the loop, please check the resolve tree data:",p);break}for(const u of p)n.getNode(u.value.parentId)?yo(u,c=>{o(c)}):this.debug("Drop resolve tree since there is no parent for the root node.",u)}Object.keys(i).length&&Object.assign(this.legacy_missingNodeRetryMap,i),Fl(t.texts).forEach(p=>{var u;const s=n.getNode(p.id);if(!s)return t.removes.find(c=>c.id===p.id)?void 0:this.warnNodeNotFound(t,p.id);if(s.textContent=p.value,this.usingVirtualDom){const c=s.parentNode;((u=c==null?void 0:c.rules)==null?void 0:u.length)>0&&(c.rules=[])}}),t.attributes.forEach(p=>{var u;const s=n.getNode(p.id);if(!s)return t.removes.find(c=>c.id===p.id)?void 0:this.warnNodeNotFound(t,p.id);for(const c in p.attributes)if(typeof c=="string"){const f=p.attributes[c];if(f===null)s.removeAttribute(c),c==="open"&&eu(s,p);else if(typeof f=="string")try{if(c==="_cssText"&&(s.nodeName==="LINK"||s.nodeName==="STYLE"))try{const h=n.getMeta(s);Object.assign(h.attributes,p.attributes);const d=Ke(h,{doc:s.ownerDocument,mirror:n,skipChild:!0,hackCss:!0,cache:this.cache}),m=s.nextSibling,g=s.parentNode;if(d&&g){g.removeChild(s),g.insertBefore(d,m),n.replace(p.id,d);break}}catch(h){}if(c==="value"&&s.nodeName==="TEXTAREA"){const h=s;h.childNodes.forEach(m=>h.removeChild(m));const d=(u=s.ownerDocument)==null?void 0:u.createTextNode(f);d&&h.appendChild(d)}else s.setAttribute(c,f);c==="rr_open_mode"&&s.nodeName==="DIALOG"&&mt(s,p)}catch(h){this.warn("An error occurred may due to the checkout feature.",h)}else if(c==="style"){const h=f,d=s;for(const m in h)if(h[m]===!1)d.style.removeProperty(m);else if(h[m]instanceof Array){const g=h[m];d.style.setProperty(m,g[0],g[1])}else{const g=h[m];d.style.setProperty(m,g)}}}})}applyScroll(t,r){var n,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)(n=this.iframe.contentWindow)==null||n.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(l){}}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(n){}}applySelection(t){try{const r=new Set,n=t.ranges.map(({start:i,startOffset:a,end:o,endOffset:l})=>{const p=this.mirror.getNode(i),u=this.mirror.getNode(o);if(!p||!u)return;const s=new Range;s.setStart(p,a),s.setEnd(u,l);const c=p.ownerDocument,f=c==null?void 0:c.getSelection();return f&&r.add(f),{range:s,selection:f}});r.forEach(i=>i.removeAllRanges()),n.forEach(i=>{var a;return i&&((a=i.selection)==null?void 0:a.addRange(i.range))})}catch(r){}}applyStyleSheetMutation(t){var r;let n=null;t.styleId?n=this.styleMirror.getStyle(t.styleId):t.id&&(n=((r=this.mirror.getNode(t.id))==null?void 0:r.sheet)||null),n&&(t.source===Y.StyleSheetRule?this.applyStyleSheetRule(t,n):t.source===Y.StyleDeclaration&&this.applyStyleDeclaration(t,n))}applyStyleSheetRule(t,r){var n,i,a,o;if((n=t.adds)==null||n.forEach(({rule:l,index:p})=>{try{if(Array.isArray(p)){const{positions:u,index:s}=Zs(p);Je(r.cssRules,u).insertRule(l,s)}else{const u=p===void 0?void 0:Math.min(p,r.cssRules.length);r==null||r.insertRule(l,u)}}catch(u){}}),(i=t.removes)==null||i.forEach(({index:l})=>{try{if(Array.isArray(l)){const{positions:p,index:u}=Zs(l);Je(r.cssRules,p).deleteRule(u||0)}else r==null||r.deleteRule(l)}catch(p){}}),t.replace)try{(a=r.replace)==null||a.call(r,t.replace)}catch(l){}if(t.replaceSync)try{(o=r.replaceSync)==null||o.call(r,t.replaceSync)}catch(l){}}applyStyleDeclaration(t,r){var n,i;if(t.set){const a=Je(r.rules,t.index);(n=a==null?void 0:a.style)==null||n.setProperty(t.set.property,t.set.value,t.set.priority)}if(t.remove){const a=Je(r.rules,t.index);(i=a==null?void 0:a.style)==null||i.removeProperty(t.remove.property)}}applyAdoptedStyleSheet(t){var r;const n=this.mirror.getNode(t.id);if(!n)return;(r=t.styles)==null||r.forEach(l=>{var p;let u=null,s=null;if(pt(n)?s=((p=n.ownerDocument)==null?void 0:p.defaultView)||null:n.nodeName==="#document"&&(s=n.defaultView),!!s)try{u=new s.CSSStyleSheet,this.styleMirror.add(u,l.styleId),this.applyStyleSheetRule({source:Y.StyleSheetRule,adds:l.rules},u)}catch(c){}});const i=10;let a=0;const o=(l,p)=>{const u=p.map(s=>this.styleMirror.getStyle(s)).filter(s=>s!==null);pt(l)?l.shadowRoot.adoptedStyleSheets=u:l.nodeName==="#document"&&(l.adoptedStyleSheets=u),u.length!==p.length&&a<i&&(setTimeout(()=>o(l,p),0+100*a),a++)};o(n,t.styleIds)}legacy_resolveMissingNode(t,r,n,i){const{previousId:a,nextId:o}=i,l=a&&t[a],p=o&&t[o];if(l){const{node:u,mutation:s}=l;r.insertBefore(u,n),delete t[s.node.id],delete this.legacy_missingNodeRetryMap[s.node.id],(s.previousId||s.nextId)&&this.legacy_resolveMissingNode(t,r,u,s)}if(p){const{node:u,mutation:s}=p;r.insertBefore(u,n.nextSibling),delete t[s.node.id],delete this.legacy_missingNodeRetryMap[s.node.id],(s.previousId||s.nextId)&&this.legacy_resolveMissingNode(t,r,u,s)}}moveAndHover(t,r,n,i,a){const o=this.mirror.getNode(n);if(!o)return this.debugNodeNotFound(a,n);const l=wo(o,this.iframe),p=t*l.absoluteScale+l.x,u=r*l.absoluteScale+l.y;this.mouse.style.left=`${p}px`,this.mouse.style.top=`${u}px`,i||this.drawMouseTail({x:p,y:u}),this.hoverElements(o)}drawMouseTail(t){if(!this.mouseTail)return;const{lineCap:r,lineWidth:n,strokeStyle:i,duration:a}=this.config.mouseTail===!0?Gr:Object.assign({},Gr,this.config.mouseTail),o=()=>{if(!this.mouseTail)return;const l=this.mouseTail.getContext("2d");!l||!this.tailPositions.length||(l.clearRect(0,0,this.mouseTail.width,this.mouseTail.height),l.beginPath(),l.lineWidth=n,l.lineCap=r,l.strokeStyle=i,l.moveTo(this.tailPositions[0].x,this.tailPositions[0].y),this.tailPositions.forEach(p=>l.lineTo(p.x,p.y)),l.stroke())};this.tailPositions.push(t),o(),setTimeout(()=>{this.tailPositions=this.tailPositions.filter(l=>l!==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 n=t;for(;n;)n.classList&&n.classList.add(":hover"),n=n.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(G.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(hn,...t)}debug(...t){this.config.showDebug&&this.config.logger.log(hn,...t)}}var pe=Uint8Array,Me=Uint16Array,ei=Uint32Array,xo=new pe([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]),Mo=new pe([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]),su=new pe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),_o=function(e,t){for(var r=new Me(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var i=new ei(r[30]),n=1;n<30;++n)for(var a=r[n];a<r[n+1];++a)i[a]=a-r[n]<<5|n;return[r,i]},No=_o(xo,2),Oo=No[0],nu=No[1];Oo[28]=258,nu[258]=28;var ou=_o(Mo,0),au=ou[0],ti=new Me(32768);for(var K=0;K<32768;++K){var Ee=(K&43690)>>>1|(K&21845)<<1;Ee=(Ee&52428)>>>2|(Ee&13107)<<2,Ee=(Ee&61680)>>>4|(Ee&3855)<<4,ti[K]=((Ee&65280)>>>8|(Ee&255)<<8)>>>1}var Ze=function(e,t,r){for(var n=e.length,i=0,a=new Me(t);i<n;++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 l;if(r){l=new Me(1<<t);var p=15-t;for(i=0;i<n;++i)if(e[i])for(var u=i<<4|e[i],s=t-e[i],c=o[e[i]-1]++<<s,f=c|(1<<s)-1;c<=f;++c)l[ti[c]>>>p]=u}else for(l=new Me(n),i=0;i<n;++i)l[i]=ti[o[e[i]-1]++]>>>15-e[i];return l},ot=new pe(288);for(var K=0;K<144;++K)ot[K]=8;for(var K=144;K<256;++K)ot[K]=9;for(var K=256;K<280;++K)ot[K]=7;for(var K=280;K<288;++K)ot[K]=8;var Ao=new pe(32);for(var K=0;K<32;++K)Ao[K]=5;var lu=Ze(ot,9,1),uu=Ze(Ao,5,1),$r=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},de=function(e,t,r){var n=t/8>>0;return(e[n]|e[n+1]<<8)>>>(t&7)&r},Hr=function(e,t){var r=t/8>>0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>>(t&7)},cu=function(e){return(e/8>>0)+(e&7&&1)},Do=function(e,t,r){(r==null||r>e.length)&&(r=e.length);var n=new(e instanceof Me?Me:e instanceof ei?ei:pe)(r-t);return n.set(e.subarray(t,r)),n},hu=function(e,t,r){var n=e.length,i=!t||r,a=!r||r.i;r||(r={}),t||(t=new pe(n*3));var o=function(N){var P=t.length;if(N>P){var V=new pe(Math.max(P*2,N));V.set(t),t=V}},l=r.f||0,p=r.p||0,u=r.b||0,s=r.l,c=r.d,f=r.m,h=r.n,d=n*8;do{if(!s){r.f=l=de(e,p,1);var m=de(e,p+1,3);if(p+=3,m)if(m==1)s=lu,c=uu,f=9,h=5;else if(m==2){var S=de(e,p,31)+257,E=de(e,p+10,15)+4,w=S+de(e,p+5,31)+1;p+=14;for(var v=new pe(w),C=new pe(19),R=0;R<E;++R)C[su[R]]=de(e,p+R*3,7);p+=E*3;var A=$r(C),M=(1<<A)-1;if(!a&&p+w*(A+7)>d)break;for(var B=Ze(C,A,1),R=0;R<w;){var k=B[de(e,p,M)];p+=k&15;var g=k>>>4;if(g<16)v[R++]=g;else{var J=0,U=0;for(g==16?(U=3+de(e,p,3),p+=2,J=v[R-1]):g==17?(U=3+de(e,p,7),p+=3):g==18&&(U=11+de(e,p,127),p+=7);U--;)v[R++]=J}}var x=v.subarray(0,S),q=v.subarray(S);f=$r(x),h=$r(q),s=Ze(x,f,1),c=Ze(q,h,1)}else throw"invalid block type";else{var g=cu(p)+4,b=e[g-4]|e[g-3]<<8,y=g+b;if(y>n){if(a)throw"unexpected EOF";break}i&&o(u+b),t.set(e.subarray(g,y),u),r.b=u+=b,r.p=p=y*8;continue}if(p>d)throw"unexpected EOF"}i&&o(u+131072);for(var I=(1<<f)-1,j=(1<<h)-1,H=f+h+18;a||p+H<d;){var J=s[Hr(e,p)&I],z=J>>>4;if(p+=J&15,p>d)throw"unexpected EOF";if(!J)throw"invalid length/literal";if(z<256)t[u++]=z;else if(z==256){s=null;break}else{var X=z-254;if(z>264){var R=z-257,ae=xo[R];X=de(e,p,(1<<ae)-1)+Oo[R],p+=ae}var _=c[Hr(e,p)&j],D=_>>>4;if(!_)throw"invalid distance";p+=_&15;var q=au[D];if(D>3){var ae=Mo[D];q+=Hr(e,p)&(1<<ae)-1,p+=ae}if(p>d)throw"unexpected EOF";i&&o(u+131072);for(var O=u+X;u<O;u+=4)t[u]=t[u-q],t[u+1]=t[u+1-q],t[u+2]=t[u+2-q],t[u+3]=t[u+3-q];u=O}}r.l=s,r.p=p,r.b=u,s&&(l=1,r.m=f,r.d=c,r.n=h)}while(!l);return u==t.length?t:Do(t,0,u)},fu=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 pu(e,t){return hu((fu(e),e.subarray(2,-4)),t)}function du(e,t){for(var r=e.length,n=new pe(e.length+(e.length>>>1)),i=0,a=function(u){n[i++]=u},o=0;o<r;++o){if(i+5>n.length){var l=new pe(i+8+(r-o<<1));l.set(n),n=l}var p=e.charCodeAt(o);p<128||t?a(p):p<2048?(a(192|p>>>6),a(128|p&63)):p>55295&&p<57344?(p=65536+(p&1047552)|e.charCodeAt(++o)&1023,a(240|p>>>18),a(128|p>>>12&63),a(128|p>>>6&63),a(128|p&63)):(a(224|p>>>12),a(128|p>>>6&63),a(128|p&63))}return Do(n,0,i)}function mu(e,t){var r="";if(typeof TextDecoder!="undefined")return new TextDecoder().decode(e);for(var n=0;n<e.length;){var i=e[n++];i<128||t?r+=String.fromCharCode(i):i<224?r+=String.fromCharCode((i&31)<<6|e[n++]&63):i<240?r+=String.fromCharCode((i&15)<<12|(e[n++]&63)<<6|e[n++]&63):(i=((i&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,r+=String.fromCharCode(55296|i>>10,56320|i&1023))}return r}const pn="v1",gu=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(mu(pu(du(e,!0))));if(t.v===pn)return t;throw new Error(`These events were packed with packer ${t.v} which is incompatible with current packer ${pn}.`)}catch(t){throw console.error(t),new Error("Unknown data format.")}};var _i=(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))(_i||{}),ri=(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))(ri||{});function dn(e){let t="";return Object.keys(e).forEach(r=>{t+=`${r}: ${e[r]};`}),t}function Ye(e,t=2){let r=String(e);const n=Math.pow(10,t-1);if(e<n)for(;String(n).length>r.length;)r=`0${e}`;return r}const Po=1e3,ii=60*Po,mn=60*ii;function gt(e){if(e<=0)return"00:00";const t=Math.floor(e/mn);e=e%mn;const r=Math.floor(e/ii);e=e%ii;const n=Math.floor(e/Po);return t?`${Ye(t)}:${Ye(r)}:${Ye(n)}`:`${Ye(r)}:${Ye(n)}`}function yu(e){return e.requestFullscreen?e.requestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen?e.webkitRequestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():Promise.resolve()}function wu(){return document.exitFullscreen?document.exitFullscreen():document.mozExitFullscreen?document.mozExitFullscreen():document.webkitExitFullscreen?document.webkitExitFullscreen():document.msExitFullscreen?document.msExitFullscreen():Promise.resolve()}function gn(){let e=!1;return["fullscreen","webkitIsFullScreen","mozFullScreen","msFullscreenElement"].forEach(t=>{t in document&&(e=e||!!document[t])}),e}function vu(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 yn(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 bu(e){return e.type!==_i.IncrementalSnapshot?!1:e.data.source>ri.Mutation&&e.data.source<=ri.Input}function Su(e,t){const r=[];let n=e[0].timestamp;for(const i of e)bu(i)&&(i.timestamp-n>t&&r.push([n,i.timestamp]),n=i.timestamp);return r}function Cu(e){let t,r,n,i,a,o,l,p,u;return{c(){t=oe("div"),r=oe("input"),n=fe(),i=oe("label"),a=fe(),o=oe("span"),l=De(e[3]),F(r,"type","checkbox"),F(r,"id",e[2]),r.disabled=e[1],F(r,"class","svelte-a6h7w7"),F(i,"for",e[2]),F(i,"class","svelte-a6h7w7"),F(o,"class","label svelte-a6h7w7"),F(t,"class","switch svelte-a6h7w7"),Ve(t,"disabled",e[1])},m(s,c){Ce(s,t,c),$(t,r),r.checked=e[0],$(t,n),$(t,i),$(t,a),$(t,o),$(o,l),p||(u=ze(r,"change",e[4]),p=!0)},p(s,[c]){c&4&&F(r,"id",s[2]),c&2&&(r.disabled=s[1]),c&1&&(r.checked=s[0]),c&4&&F(i,"for",s[2]),c&8&&vt(l,s[3]),c&2&&Ve(t,"disabled",s[1])},i:et,o:et,d(s){s&&ve(t),p=!1,u()}}}function Eu(e,t,r){let{disabled:n}=t,{checked:i}=t,{id:a}=t,{label:o}=t;function l(){i=this.checked,r(0,i)}return e.$$set=p=>{"disabled"in p&&r(1,n=p.disabled),"checked"in p&&r(0,i=p.checked),"id"in p&&r(2,a=p.id),"label"in p&&r(3,o=p.label)},[i,n,a,o,l]}class Ru extends li{constructor(t){super(),ai(this,t,Eu,Cu,si,{disabled:1,checked:0,id:2,label:3})}}function wn(e,t,r){const n=e.slice();return n[38]=t[r],n}function vn(e,t,r){const n=e.slice();return n[41]=t[r],n}function bn(e,t,r){const n=e.slice();return n[44]=t[r],n}function Sn(e){let t,r,n,i=gt(e[6])+"",a,o,l,p,u,s,c,f,h,d,m=gt(e[8].totalTime)+"",g,b,y,S,E,w,v,C,R,A,M,B,k,J=Ie(e[13]),U=[];for(let D=0;D<J.length;D+=1)U[D]=Cn(bn(e,J,D));let x=Ie(e[9]),q=[];for(let D=0;D<x.length;D+=1)q[D]=En(vn(e,x,D));function I(D,O){return D[7]==="playing"?Mu:xu}let j=I(e),H=j(e),z=Ie(e[3]),X=[];for(let D=0;D<z.length;D+=1)X[D]=Rn(wn(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]),v=new Ru({props:_}),Ae.push(()=>Ko(v,"checked",ae)),{c(){t=oe("div"),r=oe("div"),n=oe("span"),a=De(i),o=fe(),l=oe("div"),p=oe("div"),u=fe();for(let D=0;D<U.length;D+=1)U[D].c();s=fe();for(let D=0;D<q.length;D+=1)q[D].c();c=fe(),f=oe("div"),h=fe(),d=oe("span"),g=De(m),b=fe(),y=oe("div"),S=oe("button"),H.c(),E=fe();for(let D=0;D<X.length;D+=1)X[D].c();w=fe(),In(v.$$.fragment),R=fe(),A=oe("button"),A.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
160
160
  18.4-48.8 18.4-68 0-18.4-18.4-18.4-48.8 0-68L800 156 692 156c-26.4
161
161
  0-48-21.6-48-48 0-26.4 21.6-48 48-48l224 0c26.4 0 48 21.6 48 48l0
162
162
  224C964 358.4 942.4 380 916 380zM231.2 860l108.8 0c26.4 0 48 21.6 48